www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 2399f044e1d9ef7bff6432d0da9f2898b3f62c12
parent c8a74e96cd4837f5f9c5438e3362d6b100fd7675
Author: David Norton <david@nortoncrew.com>
Date:   Wed, 14 Jun 2006 15:51:05 +0000

[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

Diffstat:
Mchrome/chromeFiles/content/scholar/collectionTreeView.js | 45+++++++++++++++++++++++++++++++++++++++------
Mchrome/chromeFiles/content/scholar/itemPane.js | 1+
Mchrome/chromeFiles/content/scholar/itemTreeView.js | 26++++++++++++++++++++------
Mchrome/chromeFiles/content/scholar/overlay.xul | 1+
4 files changed, 61 insertions(+), 12 deletions(-)

diff --git a/chrome/chromeFiles/content/scholar/collectionTreeView.js b/chrome/chromeFiles/content/scholar/collectionTreeView.js @@ -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; diff --git a/chrome/chromeFiles/content/scholar/itemPane.js b/chrome/chromeFiles/content/scholar/itemPane.js @@ -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); } diff --git a/chrome/chromeFiles/content/scholar/itemTreeView.js b/chrome/chromeFiles/content/scholar/itemTreeView.js @@ -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 */ diff --git a/chrome/chromeFiles/content/scholar/overlay.xul b/chrome/chromeFiles/content/scholar/overlay.xul @@ -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>