315940 - implement index restrict in the places tree to prevent drop of items at certain indices NPOB

This commit is contained in:
beng%bengoodger.com 2005-11-28 18:29:42 +00:00
Родитель f175783805
Коммит 23cc61f267
4 изменённых файлов: 16 добавлений и 2 удалений

Просмотреть файл

@ -820,7 +820,6 @@ var PlacesControllerDragHelper = {
* An object implementing the AVI
* @param orientation
* The orientation of the drop
* XXXben implement index param!
* @returns true if the data being dragged is of a type supported by the view
* it is being dragged over, false otherwise.
*/

Просмотреть файл

@ -90,6 +90,7 @@
element = document.createElementNS(XULNS, "menu");
element.setAttribute("type", "menu");
element.setAttribute("container", "true");
element.setAttribute("label", child.title);
var popup = document.createElementNS(XULNS, "menupopup");
popup.setAttribute("type", "places");
element.appendChild(popup);

Просмотреть файл

@ -111,6 +111,8 @@ var PlacesPage = {
this._content.supportedDropTypes = [TYPE_X_MOZ_PLACE_CONTAINER,
TYPE_X_MOZ_PLACE, TYPE_X_MOZ_URL];
this._content.supportedDropOnTypes = this._content.supportedDropTypes;
this._places.firstDropIndex = 2;
this._content.firstDropIndex = 0;
// Hook the browser UI
PlacesUIHook.init(this._content);

Просмотреть файл

@ -296,6 +296,9 @@
<!-- AVI Method -->
<property name="browserWindow" onget="return this._browserWindow"/>
<!-- AVI Method -->
<field name="firstDropIndex">null</field>
<!-- AVI Method -->
<field name="supportedDropTypes">null</field>
@ -337,12 +340,21 @@
_self: this,
canDrop: function VO_canDrop(index, orientation) {
var root = this._self.getResult();
var node = root.nodeForTreeIndex(index);
// Cannot drop before fixed items in the list.
if (node.parent == root &&
PlacesController.getIndexOfNode(node) < this._self.firstDropIndex &&
orientation != Ci.nsINavHistoryResultViewObserver.DROP_ON)
return false;
return PlacesControllerDragHelper.canDrop(this._self, orientation);
},
onDrop: function VO_onDrop(index, orientation) {
LOG("VO: onDrop: " + index + ", orientation: " + orientation);
if (!this.canDrop(index, orientation))
return;
// We are responsible for translating the |index| and |orientation|
// parameters into a container id and index within the container,
// since this information is specific to the tree view.