Web Development with jQuery®

(Elliott) #1

(^304) ❘ CHAPTER 11 HTML5 DRAG AND DROP
}
case (bytes > Math.pow(2,30)):
{
return Math.round(
(bytes / Math.pow(2,30)) * 100
) / 100 + ' GB';
}
}
},
applyEvents : function()
{
var context = null;
if (arguments[0])
{
context = arguments[0];
}
else
{
context = $('div.finderDirectory, div.finderFile');
}
context
.on(
'dragstart.finder',
function(event)
{
event.stopPropagation();
var html = $(this).outerHTML();
var dataTransfer = event.originalEvent.dataTransfer;
dataTransfer.effectAllowed = 'copyMove';
try
{
dataTransfer.setData('text/html', html);
dataTransfer.setData('text/plain', html);
}
catch (error)
{
dataTransfer.setData('Text', html);
}
}
)
.on(
'dragend.finder',
function(event)
{
if ($('div.finderDirectoryDrop').length)
{
$(this).removeClass('finderDirectoryDrop');
http://www.it-ebooks.info

Free download pdf