(^308) ❘ CHAPTER 11 HTML5 DRAG AND DROP
);
}
else
{
try
{
var html = dataTransfer.getData('text/html');
}
catch (error)
{
var html = dataTransfer.getData('Text');
}
html = $(html);
if (drop.data('path') == html.data('path'))
{
// Prevent file from being dragged onto itself
drop.removeClass('finderDirectoryDrop');
return;
}
if (!html.hasClass('finderDirectory finderFile'))
{
return;
}
var fileExists = false;
$('div.finderFile, div.finderDirectory').each(
function()
{
if ($(this).data('path') == html.data('path'))
{
fileExists = true;
return false;
}
}
);
if (!fileExists)
{
dragAndDrop.applyEvents(html);
drop.append(html);
}
}
}
);
}
);
The preceding JavaScript is saved as Example 11-2.js, and loading Example 11-2.html in Safari
produces the screen shot that you see in Figure 11-2 when you drag some fi les onto the browser
window.
http://www.it-ebooks.info
elliott
(Elliott)
#1