home *** CD-ROM | disk | FTP | other *** search
- <?xml version="1.0"?>
-
-
- <bindings id="placesMenuBindings"
- xmlns="http://www.mozilla.org/xbl"
- xmlns:xbl="http://www.mozilla.org/xbl"
- xmlns:html="http://www.w3.org/1999/xhtml"
- xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
-
- <binding id="places-popup-base"
- extends="chrome://global/content/bindings/popup.xml#popup">
- <content>
- <xul:hbox flex="1">
- <xul:vbox class="menupopup-drop-indicator-bar" hidden="true">
- <xul:image class="menupopup-drop-indicator" mousethrough="always"/>
- </xul:vbox>
- <xul:arrowscrollbox class="popup-internal-box" flex="1" orient="vertical">
- <children/>
- </xul:arrowscrollbox>
- </xul:hbox>
- </content>
-
- <implementation>
-
- <field name="_indicatorBar">
- document.getAnonymousElementByAttribute(this, "class",
- "menupopup-drop-indicator-bar");
- </field>
-
- <field name="_scrollBox">
- document.getAnonymousElementByAttribute(this, "class",
- "popup-internal-box");
- </field>
-
- <!-- markers for start and end of valid places items -->
- <field name="_startMarker">-1</field>
- <field name="_endMarker">-1</field>
-
- <!-- This is the view that manage the popup -->
- <field name="_rootView">PlacesUIUtils.getViewForNode(this);</field>
-
- <field name="_built">false</field>
-
- <method name="onDragOver">
- <parameter name="aEvent"/>
- <parameter name="aFlavour"/>
- <parameter name="aDragSession"/>
- <body><![CDATA[
- PlacesControllerDragHelper.currentDropTarget = aEvent.target;
- // check if we have a valid dropPoint
- var dropPoint = this._getDropPoint(aEvent);
- if (!dropPoint)
- return;
-
- // add a dragover attribute to this popup
- this.setAttribute("dragover", "true");
-
- if (dropPoint.folderNode) {
- // We are dragging over a folder
- // _overFolder should take the care of opening it on a timer
- if (this._overFolder.node &&
- this._overFolder.node != dropPoint.folderNode) {
- // we are dragging over a new folder, let's clear old values
- this._overFolder.clear();
- }
- if (!this._overFolder.node) {
- this._overFolder.node = dropPoint.folderNode;
- // create the timer to open this folder
- this._overFolder.openTimer = this._overFolder
- .setTimer(this._overFolder.hoverTime);
- }
- // since we are dropping into a folder set the corresponding style
- dropPoint.folderNode.setAttribute("dragover-into", "true");
- }
- else {
- // We are not dragging over a folder
- // Clear out old _overFolder information
- this._overFolder.clear();
- }
-
- // Check if we should hide the drop indicator for this target
- if (!aDragSession.canDrop ||
- !dropPoint || dropPoint.folderNode ||
- this._hideDropIndicator(aEvent, dropPoint)) {
- this._indicatorBar.hidden = true;
- return;
- }
-
- var scrollBoxObject = this._scrollBox.scrollBoxObject;
- // Autoscroll the popup strip if we drag over the scroll buttons
- var anonid = aEvent.originalTarget.getAttribute("anonid");
- var scrollDir = anonid == "scrollbutton-up" ? -1 :
- anonid == "scrollbutton-down" ? 1 : 0;
- if (scrollDir != 0)
- this._scrollBox.scrollByIndex(scrollDir);
-
- // We should display the drop indicator relative to the arrowscrollbox
- var newMarginTop = 0;
- if (scrollDir == 0) {
- var node = this.firstChild;
- while (node && aEvent.screenY > node.boxObject.screenY +
- node.boxObject.height / 2)
- node = node.nextSibling;
- newMarginTop = node ? node.boxObject.screenY - scrollBoxObject.screenY :
- scrollBoxObject.height;
- }
- else if (scrollDir == 1)
- newMarginTop = scrollBoxObject.height;
-
- // set the new marginTop based on arrowscrollbox
- newMarginTop += scrollBoxObject.y - this._scrollBox.boxObject.y;
- this._indicatorBar.firstChild.style.marginTop = newMarginTop + "px";
- this._indicatorBar.hidden = false;
- ]]></body>
- </method>
-
- <method name="onDragExit">
- <parameter name="aEvent"/>
- <parameter name="aDragSession"/>
- <body><![CDATA[
- PlacesControllerDragHelper.currentDropTarget = null;
- this.removeAttribute("dragover");
- // remove dragover-into style from previous target
- aEvent.target.removeAttribute("dragover-into");
-
- // if we have not moved to a valid new target clear the drop indicator
- // this happens when moving out of the popup
- var target = aEvent.relatedTarget;
- if (!target)
- this._indicatorBar.hidden = true;
-
- // Close any folder being hovered over
- if (this._overFolder.node) {
- this._overFolder.closeTimer = this._overFolder
- .setTimer(this._overFolder.hoverTime);
- }
-
- // The autoopened attribute is set when this folder was automatically
- // opened after the user dragged over it. If this attribute is set,
- // auto-close the folder on drag exit.
- if (this.hasAttribute("autoopened")) {
- this._overFolder.closeMenuTimer = this._overFolder
- .setTimer(this._overFolder.hoverTime);
- }
-
- this._rootView._draggedNode = null;
- ]]></body>
- </method>
-
- <method name="onDragStart">
- <parameter name="aEvent"/>
- <parameter name="aXferData"/>
- <parameter name="aDragAction"/>
- <body><![CDATA[
- // Force a copy action if parent node is a query or not-removable
- if (aEvent.ctrlKey ||
- PlacesUtils.nodeIsQuery(aEvent.target.node.parent) ||
- !PlacesControllerDragHelper.canMoveContainerNode(aEvent.target.node))
- aDragAction.action = Ci.nsIDragService.DRAGDROP_ACTION_COPY;
-
- // activate the view and cache the dragged node
- this._rootView._draggedNode = aEvent.target.node;
- this._rootView.focus();
-
- aXferData.data = this._rootView.controller
- .getTransferData(aDragAction.action);
- ]]></body>
- </method>
-
- <method name="onDrop">
- <parameter name="aEvent"/>
- <parameter name="aDropData"/>
- <parameter name="aSession"/>
- <body><![CDATA[
- var dropPoint = this._getDropPoint(aEvent);
- if (!dropPoint)
- return;
-
- PlacesControllerDragHelper.onDrop(dropPoint.ip);
- ]]></body>
- </method>
-
- <!-- This returns the FavourSet accepted by this popup -->
- <method name="getSupportedFlavours">
- <body><![CDATA[
- var flavourSet = new FlavourSet();
- var acceptedDropFlavours = PlacesUIUtils.GENERIC_VIEW_DROP_TYPES;
- acceptedDropFlavours.forEach(flavourSet.appendFlavour, flavourSet);
- return flavourSet;
- ]]></body>
- </method>
-
- <!-- Check if we should hide the drop indicator for the target -->
- <method name="_hideDropIndicator">
- <parameter name="aEvent"/>
- <body><![CDATA[
- var target = aEvent.target;
-
- // in some view we have _startMarker and _endMarker, we should not
- // draw the drop indicator outside of them
- var betweenMarkers = true;
- if (this._startMarker != -1 &&
- target.boxObject.y <= this.childNodes[this._startMarker].boxObject.y)
- betweenMarkers = false;
- if (this._endMarker != -1 &&
- target.boxObject.y >= this.childNodes[this._endMarker].boxObject.y)
- betweenMarkers = false;
-
- // hide the dropmarker if current node is not a places bookmark item
- return !(target && target.node && betweenMarkers && this.canDrop());
- ]]></body>
- </method>
-
- <!-- This function returns information about where to drop when
- dragging over this popup insertion point -->
- <method name="_getDropPoint">
- <parameter name="aEvent"/>
- <body><![CDATA[
- // Can't drop if the menu isn't a folder
- var resultNode = this._resultNode;
- if (!PlacesUtils.nodeIsFolder(resultNode))
- return null;
-
- var dropPoint = { ip: null, beforeIndex: null, folderNode: null };
-
- // set the limits for valid items
- var start = 0;
- var popup = this;
- var end = popup.childNodes.length;
- if (this._startMarker != -1)
- start = this._startMarker + 1;
- if (this._endMarker != -1)
- end = this._endMarker;
-
- // Loop through all the nodes to find the correct dropPoint
- var popupY = popup.boxObject.y;
- // we should add the scrollBox button height if visible
- popupY += this._scrollBox.scrollBoxObject.y - popup.boxObject.y;
- for (var i = start; i < end; i++) {
- var xulNode = popup.childNodes[i];
- var nodeY = xulNode.boxObject.y - popupY;
- var nodeHeight = xulNode.boxObject.height;
- if (xulNode.node &&
- (PlacesUtils.nodeIsFolder(xulNode.node) ||
- PlacesUtils.nodeIsTagQuery(xulNode.node)) &&
- !PlacesUtils.nodeIsReadOnly(xulNode.node)) {
- // This is a folder. If the mouse is in the top 25% of the
- // node, drop above the folder. If it's in the middle
- // 50%, drop into the folder. If it's past that, drop below.
- if (aEvent.layerY < nodeY + (nodeHeight * 0.25)) {
- // Drop above this folder.
- dropPoint.ip = new InsertionPoint(resultNode.itemId,
- i - start, -1);
- dropPoint.beforeIndex = i;
- return dropPoint;
- }
- else if (aEvent.layerY < nodeY + (nodeHeight * 0.75)) {
- // Drop inside this folder.
- dropPoint.ip = new InsertionPoint(xulNode.node.itemId, -1, 1);
- dropPoint.beforeIndex = i;
- dropPoint.folderNode = xulNode;
- return dropPoint;
- }
- }
- else {
- // This is a non-folder node. If the mouse is above the middle,
- // drop above the folder. Otherwise, drop below.
- if (aEvent.layerY <= nodeY + (nodeHeight / 2)) {
- // Drop above this bookmark.
- dropPoint.ip = new InsertionPoint(resultNode.itemId,
- i - start, -1);
- dropPoint.beforeIndex = i;
- return dropPoint;
- }
- }
- }
- // Should drop below the last node.
- dropPoint.ip = new InsertionPoint(resultNode.itemId, -1, 1);
- dropPoint.beforeIndex = -1;
- return dropPoint;
- ]]></body>
- </method>
-
- <method name="canDrop">
- <body><![CDATA[
- var ip = this._rootView.insertionPoint;
- return ip && PlacesControllerDragHelper.canDrop(ip);
- ]]></body>
- </method>
-
- <!-- Sub-menus should be opened when the mouse drags over them, and closed
- when the mouse drags off. The overFolder object manages opening and
- closing of folders when the mouse hovers. -->
- <field name="_overFolder"><![CDATA[({
- _self: this,
- _folder: {node: null, openTimer: null, hoverTime: 350, closeTimer: null},
- _closeMenuTimer: null,
-
- get node() {
- return this._folder.node;
- },
- set node(val) {
- return this._folder.node = val;
- },
-
- get openTimer() {
- return this._folder.openTimer;
- },
- set openTimer(val) {
- return this._folder.openTimer = val;
- },
-
- get hoverTime() {
- return this._folder.hoverTime;
- },
- set hoverTime(val) {
- return this._folder.hoverTime = val;
- },
-
- get closeTimer() {
- return this._folder.closeTimer;
- },
- set closeTimer(val) {
- return this._folder.closeTimer = val;
- },
-
- get closeMenuTimer() {
- return this._closeMenuTimer;
- },
- set closeMenuTimer(val) {
- return this._closeMenuTimer = val;
- },
-
- setTimer: function OF__setTimer(aTime) {
- var timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
- timer.initWithCallback(this, aTime, timer.TYPE_ONE_SHOT);
- return timer;
- },
-
- notify: function OF__notify(aTimer) {
- // Function to process all timer notifications.
-
- if (aTimer == this._folder.openTimer) {
- // Timer to open a submenu that's being dragged over.
- this._folder.node.lastChild.setAttribute("autoopened", "true");
- this._folder.node.lastChild.showPopup(this._folder.node);
- this._folder.openTimer = null;
- }
-
- else if (aTimer == this._folder.closeTimer) {
- // Timer to close a submenu that's been dragged off of.
- // Only close the submenu if the mouse isn't being dragged over any
- // of its child menus.
- var draggingOverChild = PlacesControllerDragHelper
- .draggingOverChildNode(this._folder.node);
- if (draggingOverChild)
- this._folder.node = null;
- this.clear();
-
- // Close any parent folders which aren't being dragged over.
- // (This is necessary because of the above code that keeps a folder
- // open while its children are being dragged over.)
- if (!draggingOverChild)
- this.closeParentMenus();
- }
-
- else if (aTimer == this.closeMenuTimer) {
- // Timer to close this menu after the drag exit.
- var popup = this._self;
- if (!PlacesControllerDragHelper.draggingOverChildNode(popup.parentNode)) {
- popup.hidePopup();
- // Close any parent menus that aren't being dragged over;
- // otherwise they'll stay open because they couldn't close
- // while this menu was being dragged over.
- this.closeParentMenus();
- }
- }
- },
-
- // Helper function to close all parent menus of this menu,
- // as long as none of the parent's children are currently being
- // dragged over.
- closeParentMenus: function OF__closeParentMenus() {
- var popup = this._self;
- var parent = popup.parentNode;
- while (parent) {
- if (parent.nodeName == "menupopup" && parent._resultNode) {
- if (PlacesControllerDragHelper.draggingOverChildNode(parent.parentNode))
- break;
- parent.hidePopup();
- }
- parent = parent.parentNode;
- }
- },
-
- // The mouse is no longer dragging over the stored menubutton.
- // Close the menubutton, clear out drag styles, and clear all
- // timers for opening/closing it.
- clear: function OF__clear() {
- if (this._folder.node && this._folder.node.lastChild) {
- if (!this._folder.node.lastChild.hasAttribute("dragover"))
- this._folder.node.lastChild.hidePopup();
- // remove dragover-into style
- this._folder.node.removeAttribute("dragover-into");
- this._folder.node = null;
- }
- if (this._folder.openTimer) {
- this._folder.openTimer.cancel();
- this._folder.openTimer = null;
- }
- if (this._folder.closeTimer) {
- this._folder.closeTimer.cancel();
- this._folder.closeTimer = null;
- }
- }
- })]]></field>
-
- </implementation>
-
- <handlers>
- <handler event="DOMMenuItemActive"><![CDATA[
- var node = event.target;
- if (node.parentNode != this)
- return;
-
-
- if (window.XULBrowserWindow) {
- var nodeItem = event.target.node;
- if (nodeItem && PlacesUtils.nodeIsURI(nodeItem))
- window.XULBrowserWindow.setOverLink(nodeItem.uri, null);
- }
- ]]></handler>
- <handler event="DOMMenuItemInactive"><![CDATA[
- var node = event.target;
- if (node.parentNode != this)
- return;
-
- if (window.XULBrowserWindow)
- window.XULBrowserWindow.setOverLink("", null);
- ]]></handler>
- <handler event="draggesture" action="if (event.target.node) nsDragAndDrop.startDrag(event, this);"/>
- <handler event="dragdrop" action="nsDragAndDrop.drop(event, this);"/>
- <handler event="dragover" action="nsDragAndDrop.dragOver(event, this);"/>
- <handler event="dragexit" action="nsDragAndDrop.dragExit(event, this);"/>
- </handlers>
- </binding>
-
-
- <binding id="places-menupopup"
- extends="chrome://browser/content/places/menu.xml#places-popup-base">
- <implementation>
- <destructor><![CDATA[
- this._resultNode = null;
- if (this._result) {
- this._result.viewer = null;
- this._result = null;
- }
- ]]></destructor>
-
- <field name="_initialized">false</field>
- <method name="_ensureInitialized">
- <body><![CDATA[
- if (this._initialized)
- return;
-
- this._controller = new PlacesController(this);
- this.controllers.appendController(this._controller);
-
- // This function should only be called for top-level menus like the bookmarks menu.
- // Submenus get their _result and _resultNode from their parents.
- if (this.hasAttribute("place")) {
- // Do the initial build.
- this.place = this.place;
- }
- this._initialized = true;
- ]]></body>
- </method>
-
- <property name="controller"
- readonly="true"
- onget="return this._controller;"/>
-
- <method name="onPopupShowing">
- <parameter name="aEvent"/>
- <body><![CDATA[
- var popup = aEvent.target;
- var resultNode = popup._resultNode;
- if (!resultNode.containerOpen)
- resultNode.containerOpen = true;
- if (!popup._built)
- this._rebuild(popup);
- ]]></body>
- </method>
-
- <!-- nsIPlacesView -->
- <method name="getResult">
- <body><![CDATA[
- return this._result;
- ]]></body>
- </method>
-
- <!-- nsIPlacesView -->
- <method name="getResultNode">
- <body><![CDATA[
- this._ensureInitialized();
- return this._resultNode;
- ]]></body>
- </method>
-
- <method name="removeItem">
- <parameter name="child"/>
- <body><![CDATA[
- if (PlacesUtils.nodeIsContainer(child.node)) {
- for (var i=0; i < this._containerNodesMap.length; i++) {
- if (this._containerNodesMap[i].resultNode == child.node) {
- this._containerNodesMap.splice(i, 1);
- break;
- }
- }
- }
-
- // if document.popupNode pointed to this child, null it out,
- // otherwise controller's command-updating may rely on the removed
- // item still being "selected".
- if (document.popupNode == child)
- document.popupNode = null;
- child.parentNode.removeChild(child);
- ]]></body>
- </method>
-
- <method name="insertNewItem">
- <parameter name="aChild"/>
- <parameter name="aParentPopup"/>
- <parameter name="aBefore"/>
- <body><![CDATA[
- var element =
- PlacesUIUtils.createMenuItemForNode(aChild, this._containerNodesMap);
-
- if (aBefore)
- aParentPopup.insertBefore(element, aBefore);
- else {
- // Add the new element to the menu. If there is static content at
- // the end of the menu, add the element before that. Otherwise,
- // just add to the end.
- if (aParentPopup._endMarker != -1)
- aParentPopup.insertBefore(element,
- aParentPopup.childNodes[aParentPopup._endMarker++]);
- else
- aParentPopup.appendChild(element);
- }
- ]]></body>
- </method>
-
- <method name="_showEmptyMenuItem">
- <parameter name="aPopup"/>
- <body><![CDATA[
- if (aPopup._emptyMenuItem) {
- aPopup._emptyMenuItem.hidden = false;
- return;
- }
-
- var label = PlacesUIUtils.getString("bookmarksMenuEmptyFolder");
- aPopup._emptyMenuItem = document.createElement("menuitem");
- aPopup._emptyMenuItem.setAttribute("label", label);
- aPopup._emptyMenuItem.setAttribute("disabled", true);
- aPopup.appendChild(aPopup._emptyMenuItem);
- ]]></body>
- </method>
-
- <method name="_rebuild">
- <parameter name="aPopup"/>
- <body><![CDATA[
- PlacesUIUtils.cleanPlacesPopup(aPopup);
-
- var cc = aPopup._resultNode.childCount;
- if (cc > 0) {
- if (aPopup._emptyMenuItem)
- aPopup._emptyMenuItem.hidden = true;
-
- for (var i = 0; i < cc; ++i) {
- var child = aPopup._resultNode.getChild(i);
- this.insertNewItem(child, aPopup, null);
- }
- }
- else {
- // This menu is empty. If there is no static content, add
- // an element to show it is empty.
- if (aPopup._startMarker == -1 && aPopup._endMarker == -1)
- this._showEmptyMenuItem(aPopup);
- }
- aPopup._built = true;
- ]]></body>
- </method>
-
- <!-- nsINavHistoryResultViewer -->
- <field name="_viewer"><![CDATA[({
- _self: this,
-
- _getPopupForContainer:
- function PMV__getPopupForContainer(aNode) {
- if (this._self._resultNode == aNode)
- return this._self;
-
- for (var i=0; i < this._self._containerNodesMap.length; i++) {
- if (this._self._containerNodesMap[i].resultNode == aNode)
- return this._self._containerNodesMap[i].domNode;
- }
- throw("Container view not found");
- },
-
- get result() {
- return this._self._result;
- },
-
- set result(val) {
- // some methods (e.g. getURLsFromContainer) temporarily null out the
- // viewer when they do temporary changes to the view, this does _not_
- // call setResult(null), but then, we're called again with the result
- // object which is already set for this viewer. At that point,
- // we should do nothing.
- if (this._self._result != val) {
- this._built = false;
- this._self._containerNodesMap = [];
- this._self._resultNode = val.root;
- this._self._result = val;
- }
- return val;
- },
-
- itemInserted: function PMV_itemInserted(aParentNode, aNode, aIndex) {
- var popup = this._getPopupForContainer(aParentNode);
- if (!popup._built)
- return;
-
- var index = popup._startMarker + 1 + aIndex;
- var before = popup.childNodes[index] || null;
- this._self.insertNewItem(aNode, popup, before);
- if (popup._emptyMenuItem)
- popup._emptyMenuItem.hidden = true;
- },
-
- itemRemoved: function PMV_itemRemoved(aParentNode, aNode, aIndex) {
- var popup = this._getPopupForContainer(aParentNode);
- if (!popup._built)
- return;
-
- var children = popup.childNodes;
- for (var i = 0; i < children.length; i++) {
- if (children[i].node == aNode) {
- this._self.removeItem(children[i]);
- if (!popup.hasChildNodes() ||
- (popup.childNodes.length == 1 &&
- popup.firstChild == popup._emptyMenuItem)) {
- this._self._showEmptyMenuItem(popup);
- }
- }
- }
- },
-
- itemMoved:
- function PMV_itemMoved(aItem, aOldParent, aOldIndex, aNewParent,
- aNewIndex) {
- // This cannot actually happen yet (see IDL)
- if (aNewParent != aOldParent)
- return;
-
- var popup = this._getPopupForContainer(aNewParent);
- var index = popup._startMarker + 1 + aNewIndex;
- var children = popup.childNodes;
- for (var i = 0; i < children.length; i++) {
- var menuItem = children[i];
- if (menuItem.node == aItem) {
- popup.removeChild(menuItem);
- popup.insertBefore(menuItem, children[index]);
- return;
- }
- }
- },
-
- itemChanged: function PMV_itemChanged(aNode) {
- // this check can be removed once we fix bug #382397
- var parentNode = aNode.parent;
- if (!parentNode)
- return;
-
- var popup = this._getPopupForContainer(parentNode);
- if (!popup._built)
- return;
-
- var children = popup.childNodes;
- var menuitem;
- for (var i = 0; i < children.length; i++) {
- if (children[i].node == aNode) {
- menuitem = children[i];
- break;
- }
- }
-
- if (PlacesUtils.nodeIsSeparator(aNode)) {
- // nothing to do when a separator changes
- return;
- }
-
- var iconURI = aNode.icon;
- if (iconURI) {
- var spec = iconURI.spec;
- if (menuitem.getAttribute("image") != spec)
- menuitem.setAttribute("image", spec);
- }
- else
- menuitem.removeAttribute("image");
-
- var title = PlacesUIUtils.getBestTitle(aNode);
- if (menuitem.getAttribute("label") != title)
- menuitem.setAttribute("label", title);
-
- if (!menuitem.hasAttribute("livemark") &&
- PlacesUtils.nodeIsLivemarkContainer(aNode))
- menuitem.setAttribute("livemark", "true");
- },
-
- itemReplaced:
- function PMV_itemReplaced(aParentNode, aOldNode, aNewNode, aIndex) {
- var popup = this._getPopupForContainer(aParentNode);
- if (!popup._built)
- return;
-
- var children = popup.childNodes;
- for (var i = 0; i < children.length; i++) {
- if (children[i].node == aOldNode) {
- var next = children[i].nextSibling;
- this._self.removeItem(children[i]);
- this._self.insertNewItem(aNewNode, popup, next);
- return;
- }
- }
- },
-
- containerOpened: function PMV_containerOpened(aNode) {
- this.invalidateContainer(aNode);
- },
-
- containerClosed: function PMV_containerClosed(aNode) {
- this.invalidateContainer(aNode);
- },
-
- invalidateContainer: function PMV_invalidateContainer(aContainer) {
- if (!this._self._built)
- return;
-
- function isChildOf(node, container) {
- var parent = node.parent;
- while (parent) {
- if (parent == container)
- return true;
- parent = parent.parent;
- }
- return false;
- }
-
- var popupToRebuild = null;
- for (var i=0; i < this._self._containerNodesMap.length; i++) {
- var node = this._self._containerNodesMap[i].resultNode;
-
- if (node == aContainer)
- popupToRebuild = this._self._containerNodesMap[i].domNode;
- if (isChildOf(node, aContainer)) {
- this._self._containerNodesMap.splice(i,1);
- i--;
- }
- }
-
- if (!popupToRebuild)
- popupToRebuild = this._self;
- popupToRebuild._built = false;
-
- // if the menupopup is open we should live-update it
- if (popupToRebuild.parentNode.open)
- this._self._rebuild(popupToRebuild);
- },
-
- invalidateAll: function PMV_invalidateAll() {
- this._self._containerNodesMap.splice(0);
- this._self._built = false;
- },
-
- sortingChanged: function PMV_sortingChanged(aSortingMode) {
- }
- })]]></field>
-
- <!-- nsIPlacesView -->
- <property name="place">
- <getter><![CDATA[
- return this.getAttribute("place");
- ]]></getter>
- <setter><![CDATA[
- this.setAttribute("place", val);
- var queries = { }, options = { };
- PlacesUtils.history.queryStringToQueries(val, queries, { }, options);
- if (!queries.value.length)
- queries.value = [PlacesUtils.history.getNewQuery()];
- var result =
- PlacesUtils.history.executeQueries(queries.value,
- queries.value.length,
- options.value);
- result.viewer = this._viewer;
- return val;
- ]]></setter>
- </property>
-
- <!-- nsIPlacesView -->
- <property name="hasSelection">
- <getter><![CDATA[
- return this.selectedNode != null;
- ]]></getter>
- </property>
-
- <!-- nsIPlacesView -->
- <method name="getSelectionNodes">
- <body><![CDATA[
- var selectedNode = this.selectedNode;
- return selectedNode ? [selectedNode] : [];
- ]]></body>
- </method>
-
- <!-- nsIPlacesView -->
- <method name="getRemovableSelectionRanges">
- <body><![CDATA[
- return [this.getSelectionNodes()];
- ]]></body>
- </method>
-
- <!-- nsIPlacesView -->
- <method name="getDragableSelection">
- <body><![CDATA[
- return [this._draggedNode];
- ]]></body>
- </method>
-
- <!-- nsIPlacesView -->
- <property name="selectedNode">
- <getter><![CDATA[
- if (this._contextMenuShown) {
- var popupNode = document.popupNode;
- return popupNode.node || popupNode.parentNode._resultNode || null;
- }
- return null;
- ]]></getter>
- </property>
-
- <!-- nsIPlacesView -->
- <property name="insertionPoint">
- <getter><![CDATA[
- // By default, the insertion point is at the top level, at the end.
- var index = PlacesUtils.bookmarks.DEFAULT_INDEX;
- var folderId = 0;
- var orientation = Ci.nsITreeView.DROP_BEFORE;
- var isTag = false;
-
- if (PlacesUtils.nodeIsFolder(this._resultNode)) {
- folderId = PlacesUtils.getConcreteItemId(this._resultNode);
- isTag = PlacesUtils.nodeIsTagQuery(this._resultNode);
- }
-
- var selectedNode = this.selectedNode;
- if (selectedNode) {
- var popupNode = document.popupNode;
- if (!popupNode.node) {
- // If a static menuitem is selected the insertion point
- // is inside the folder, at the end.
- folderId = PlacesUtils.getConcreteItemId(selectedNode);
- orientation = Ci.nsITreeView.DROP_ON;
- }
- else {
- // In all other cases the insertion point is before that node.
- folderId = PlacesUtils.getConcreteItemId(selectedNode.parent);
- index = PlacesUtils.getIndexOfNode(selectedNode);
- isTag = PlacesUtils.nodeIsTagQuery(selectedNode.parent);
- }
- }
- return new InsertionPoint(folderId, index, orientation, isTag);
- ]]></getter>
- </property>
-
- <!-- nsIPlacesView -->
- <method name="selectAll">
- <body/>
- </method>
-
- <method name="selectItems">
- <body/>
- </method>
-
- <property name="selType" readonly="true" onget="return 'single';"/>
-
- <method name="buildContextMenu">
- <parameter name="aPopup"/>
- <body><![CDATA[
- this._ensureInitialized();
- this._contextMenuShown = true;
- this.focus();
- var show = this.controller.buildContextMenu(aPopup);
- if (show) {
- // disable the Delete command if the selection isn't explicit
- if (document.popupNode && document.popupNode.localName == "menupopup")
- document.getElementById("cmd_delete").setAttribute("disabled", "true");
- return true;
- }
- return false;
- ]]></body>
- </method>
-
- <method name="destroyContextMenu">
- <parameter name="aPopup"/>
- <body>
- <![CDATA[
- this._contextMenuShown = false;
- if (window.content)
- window.content.focus();
- ]]>
- </body>
- </method>
- </implementation>
- <handlers>
- <handler event="popupshowing" phase="capturing"><![CDATA[
- this._ensureInitialized();
- var popup = event.target;
- // Avoid handling popupshowing of inner views
- if (!popup._resultNode || PlacesUIUtils.getViewForNode(popup) != this)
- return;
-
- this.onPopupShowing(event);
- ]]></handler>
-
- <handler event="popuphidden"><![CDATA[
- var popup = event.target;
- // We should avoid to handle events of inner views
- if (!popup._resultNode || PlacesUIUtils.getViewForNode(popup) != this)
- return;
-
- // UI performance: folder queries are cheap, keep the resultnode open
- // so we don't rebuild its contents whenever the popup is reopened.
- if (!PlacesUtils.nodeIsFolder(popup._resultNode))
- popup._resultNode.containerOpen = false;
-
- // The autoopened attribute is set for folders which have been
- // automatically opened when dragged over. Turn off this attribute
- // when the folder closes because it is no longer applicable.
- popup.removeAttribute("autoopened");
- ]]></handler>
- </handlers>
- </binding>
-
- </bindings>
-