Fix tag selector drag and drop in Firefox 4

This commit is contained in:
Dan Stillman 2010-12-26 02:49:49 +00:00
parent 31f9378da5
commit 1b7e2b412b

View File

@ -246,9 +246,9 @@
label.setAttribute('tagType', this._tags[tagID].type); label.setAttribute('tagType', this._tags[tagID].type);
if (this.editable) { if (this.editable) {
label.setAttribute('context', 'tag-menu'); label.setAttribute('context', 'tag-menu');
label.setAttribute('ondragover', 'nsDragAndDrop.dragOver(event, document.getBindingParent(this).dragObserver)'); label.setAttribute('ondragover', 'return document.getBindingParent(this).dragObserver.onDragOver(event)');
label.setAttribute('ondragexit', 'nsDragAndDrop.dragExit(event, document.getBindingParent(this).dragObserver)'); label.setAttribute('ondragexit', 'return document.getBindingParent(this).dragObserver.onDragExit(event)');
label.setAttribute('ondragdrop', 'nsDragAndDrop.drop(event, document.getBindingParent(this).dragObserver)'); label.setAttribute('ondrop', 'return document.getBindingParent(this).dragObserver.onDrop(event)');
} }
tagsToggleBox.appendChild(label); tagsToggleBox.appendChild(label);
} }
@ -697,41 +697,44 @@
<method name="_dragObserverConstructor"> <method name="_dragObserverConstructor">
<body> <body>
<![CDATA[ <![CDATA[
this.onDragOver = onDragOver; this.onDragOver = function (event) {
this.onDragExit = onDragExit; if (!event.dataTransfer.getData('zotero/item')) {
this.onDrop = onDrop; return true;
this.getSupportedFlavours = getSupportedFlavours; }
function onDragOver(event, flavour, session) {
/* /*
// TODO: get drop data // TODO: get drop data
var ids = dropData.data.split(','); var ids = dropData.data.split(',');
var items = Zotero.Items.get(ids); var items = Zotero.Items.get(ids);
for (var i=0; i<items.length; i++) { for (var i=0; i<items.length; i++) {
if (!Zotero.Items.isEditable(items[i])) { if (!Zotero.Items.isEditable(items[i])) {
return false; return true;
} }
} }
*/ */
event.target.setAttribute('draggedOver', true); event.target.setAttribute('draggedOver', true);
return true; return false;
} }
function onDragExit(event, session) { this.onDragExit = function (event) {
event.target.setAttribute('draggedOver', false); event.target.setAttribute('draggedOver', false);
return true;
} }
function onDrop(event, dropData, session) { this.onDrop = function (event) {
var node = event.target; var node = event.target;
node.setAttribute('draggedOver', false); node.setAttribute('draggedOver', false);
var dt = event.dataTransfer;
var ids = dt.getData('zotero/item');
if (!ids) {
return;
}
Zotero.DB.beginTransaction(); Zotero.DB.beginTransaction();
var ids = dropData.data.split(','); ids = ids.split(',');
var items = Zotero.Items.get(ids); var items = Zotero.Items.get(ids);
// Find a manual tag if there is one // Find a manual tag if there is one
@ -761,13 +764,6 @@
Zotero.DB.commitTransaction(); Zotero.DB.commitTransaction();
} }
function getSupportedFlavours() {
var flavours = new FlavourSet();
flavours.appendFlavour("zotero/item");
return flavours;
}
]]> ]]>
</body> </body>
</method> </method>