[Drag and Drop] in the Collections Tree: Now checks to make sure that the correct type is being dragged, and that you aren't dropping a folder into subfolders, etc.

[Drag and Drop] in Items Tree: You can drag items from one window into another, directly into the Items list.
[Editing] Close the edit box and save when you click on its label
This commit is contained in:
David Norton 2006-06-14 15:51:05 +00:00
parent c8a74e96cd
commit 2399f044e1
4 changed files with 61 additions and 12 deletions

View file

@ -272,10 +272,35 @@ Scholar.CollectionTreeView.prototype._refreshHashMap = function()
Scholar.CollectionTreeView.prototype.canDrop = function(row, orient)
{
if((row == 0 && orient == 1) || orient == 0)
return true;
else
if(typeof row == 'object') //workaround... two different services call canDrop (nsDragAndDrop, and the tree)
return false;
try
{
var dataSet = nsTransferable.get(this.getSupportedFlavours(),nsDragAndDrop.getDragData, true);
}
catch (e)
{
//a work around a limitation in nsDragAndDrop.js -- the mDragSession is not set until the drag moves over another control. (this will only happen if the first drag is from the collection list)
nsDragAndDrop.mDragSession = nsDragAndDrop.mDragService.getCurrentSession();
return false;
}
var data = dataSet.first.first;
var dataType = data.flavour.contentType;
var rowCollection = this._getItemAtRow(row).ref;
if(orient == 1 && row == 0 && dataType == 'scholar/collection')
{
return true;
}
else if(orient == 0)
{
if(dataType == 'scholar/item' || dataType == "text/x-moz-url")
return true;
else if(dataType='scholar/collection' && data.data != rowCollection.getID() && !Scholar.Collections.get(data.data).hasDescendent('collection',rowCollection.getID()) )
return true;
}
return false;
}
Scholar.CollectionTreeView.prototype.drop = function(row, orient)
@ -283,7 +308,6 @@ Scholar.CollectionTreeView.prototype.drop = function(row, orient)
var dataSet = nsTransferable.get(this.getSupportedFlavours(),nsDragAndDrop.getDragData, true);
var data = dataSet.first.first;
var dataType = data.flavour.contentType;
var ids = data.data.split(',');
if(dataType == 'scholar/collection')
{
@ -292,10 +316,10 @@ Scholar.CollectionTreeView.prototype.drop = function(row, orient)
var targetCollectionID;
if(this._getItemAtRow(row).isCollection())
targetCollectionID = this._getItemAtRow(row).ref.getID();
var droppedCollection = Scholar.Collections.get(ids[0]);
var droppedCollection = Scholar.Collections.get(data.data);
droppedCollection.changeParent(targetCollectionID);
var selectRow = this._collectionRowMap[ids[0]];
var selectRow = this._collectionRowMap[data.data];
if(selectRow == null)
selectRow = this._collectionRowMap[targetCollectionID];
@ -307,10 +331,18 @@ Scholar.CollectionTreeView.prototype.drop = function(row, orient)
}
else if(dataType == 'scholar/item' && this.canDrop(row, orient))
{
var ids = data.data.split(',');
var targetCollection = this._getItemAtRow(row).ref;
for(var i = 0; i<ids.length; i++)
targetCollection.addItem(ids[i]);
}
else if(dataType == 'text/x-moz-url' && this.canDrop(row, orient))
{
alert(data.data);
var targetCollection = this._getItemAtRow(row).ref;
/*for(var i = 0; i<ids.length; i++)
targetCollection.addItem(ids[i]); */
}
}
Scholar.CollectionTreeView.prototype.onDragStart = function(evt,transferData,action)
@ -322,6 +354,7 @@ Scholar.CollectionTreeView.prototype.onDragStart = function(evt,transferData,act
Scholar.CollectionTreeView.prototype.getSupportedFlavours = function ()
{
var flavors = new FlavourSet();
flavors.appendFlavour("text/x-moz-url");
flavors.appendFlavour("scholar/item");
flavors.appendFlavour("scholar/collection");
return flavors;

View file

@ -68,6 +68,7 @@ ScholarItemPane = new function()
var label = document.createElement("label");
label.setAttribute("value",Scholar.getString("itemFields."+fieldNames[i])+":");
label.setAttribute("onclick","this.nextSibling.blur();");
addDynamicRow(label,valueElement);
}

View file

@ -314,11 +314,6 @@ Scholar.ItemTreeView.prototype.rememberSelection = function()
/* DRAG AND DROP FUNCTIONS */
Scholar.ItemTreeView.prototype.canDrop = function(index, orient)
{
return false;
}
Scholar.ItemTreeView.prototype.onDragStart = function (evt,transferData,action)
{
transferData.data=new TransferData();
@ -330,11 +325,30 @@ Scholar.ItemTreeView.prototype.getSupportedFlavours = function ()
{
var flavors = new FlavourSet();
flavors.appendFlavour("scholar/item");
flavors.appendFlavour("text/x-moz-url");
return flavors;
}
Scholar.ItemTreeView.prototype.onDrop = function (evt,data,session)
{
var dataType = data.flavour.contentType;
var ids = data.data.split(',');
if(dataType == 'scholar/item')
{
for(var i = 0; i<ids.length; i++)
this._itemGroup.ref.addItem(ids[i]);
}
else if(dataType == 'text/x-moz-url')
{
alert(data.data);
var targetCollection = this._itemGroup.ref;
/*for(var i = 0; i<ids.length; i++)
targetCollection.addItem(ids[i]); */
}
}
Scholar.ItemTreeView.prototype.onDragOver = function (evt,dropdata,session) { }
Scholar.ItemTreeView.prototype.onDrop = function (evt,dropdata,session) { }
/* MORE TREEVIEW FUNCTIONS THAT HAVE TO BE HERE */

View file

@ -59,6 +59,7 @@
enableColumnDrag="true" onkeypress="if(event.keyCode == event.DOM_VK_BACK_SPACE || event.keyCode == event.DOM_VK_DELETE){ ScholarPane.deleteItemSelection(); return false; }"
onselect="ScholarPane.itemSelected();"
ondraggesture="if (event.target.localName == 'treechildren') nsDragAndDrop.startDrag(event,ScholarPane.getItemsView());"
ondragover="nsDragAndDrop.dragOver(event,ScholarPane.getItemsView())"
ondragdrop="nsDragAndDrop.drop(event,ScholarPane.getItemsView())"
flex="1">
<treecols>