# ***** BEGIN LICENSE BLOCK ***** # Version: MPL 1.1/GPL 2.0/LGPL 2.1 # # The contents of this file are subject to the Mozilla Public License Version # 1.1 (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # http://www.mozilla.org/MPL/ # # Software distributed under the License is distributed on an "AS IS" basis, # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License # for the specific language governing rights and limitations under the # License. # # The Original Code is the Places Menupopup View. # # The Initial Developer of the Original Code is Google Inc. # Portions created by the Initial Developer are Copyright (C) 2005-2006 # the Initial Developer. All Rights Reserved. # # Contributor(s): # Annie Sullivan # Ben Goodger # Asaf Romano # Simon Bünzli # Marco Bonardo # # Alternatively, the contents of this file may be used under the terms of # either the GNU General Public License Version 2 or later (the "GPL"), or # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), # in which case the provisions of the GPL or the LGPL are applicable instead # of those above. If you wish to allow use of your version of this file only # under the terms of either the GPL or the LGPL, and not to allow others to # use your version of this file under the terms of the MPL, indicate your # decision by deleting the provisions above and replace them with the notice # and other provisions required by the GPL or the LGPL. If you do not delete # the provisions above, a recipient may use your version of this file under # the terms of any one of the MPL, the GPL or the LGPL. # # ***** END LICENSE BLOCK ***** document.getAnonymousElementByAttribute(this, "class", "menupopup-drop-indicator-bar"); document.getAnonymousElementByAttribute(this, "class", "popup-internal-box"); -1 -1 PlacesUIUtils.getViewForNode(this); = this.childNodes[this._endMarker].boxObject.y) betweenMarkers = false; // Hide the dropmarker if current node is not a Places node. return !(target && target.node && betweenMarkers); ]]> node.boxObject.screenY + node.boxObject.height / 2) node = node.nextSibling; newMarginTop = node ? node.boxObject.screenY - sbo.screenY : sbo.height; } else if (scrollDir == 1) newMarginTop = sbo.height; // Set the new marginTop based on arrowscrollbox. newMarginTop += sbo.y - this._scrollBox.boxObject.y; this._indicatorBar.firstChild.style.marginTop = newMarginTop + "px"; this._indicatorBar.hidden = false; event.preventDefault(); event.stopPropagation(); ]]> false null null 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.parentNode._built = true; ]]> element for the container, // we need the let popup = parentElt.firstChild; let index = popup._startMarker + 1 + aIndex; this._self.insertNewItem(aNode, popup, popup.childNodes[index]); if (popup._emptyMenuItem) popup._emptyMenuItem.hidden = true; }, nodeRemoved: function PMV_nodeRemoved(aParentNode, aNode, aIndex) { let parentElt = aParentNode._DOMElement; NS_ASSERT(parentElt, "parent node must have _DOMElement set"); if (!parentElt._built) return; // parentElt is the element for the container, // we need the let popup = parentElt.firstChild; let nodeElt = aNode._DOMElement; NS_ASSERT(nodeElt, "node must have _DOMElement set"); popup.removeChild(nodeElt); // Figure out if we need to show the "" menu-item. // TODO Bug 517701: This doesn't seem to handle the case of an empty // root (parentElt == this._self.parentNode). if (!popup.hasChildNodes() || (popup.childNodes.length == 1 && popup.firstChild == popup._emptyMenuItem)) this._self._showEmptyMenuItem(popup); if (popup._endMarker != -1) popup._endMarker--; }, nodeMoved: function PMV_nodeMoved(aNode, aOldParent, aOldIndex, aNewParent, aNewIndex) { // Note: the current implementation of moveItem does not actually // use this notification when the item in question is moved from one // folder to another. Instead, it calls nodeRemoved and nodeInserted // for the two folders. Thus, we can assume aOldParent == aNewParent. let nodeElt = aNode._DOMElement; NS_ASSERT(nodeElt, "node must have _DOMElement set"); // If our root node is a folder, it might be moved. There's nothing // we need to do in that case. if (nodeElt == this._self.parentNode) return; // Move the node. let popup = nodeElt.parentNode; let index = popup._startMarker + 1 + aNewIndex; popup.removeChild(nodeElt); popup.insertBefore(nodeElt, popup.childNodes[index]); }, nodeTitleChanged: function PMV__nodeTitleChanged(aNode, aNewTitle) { let nodeElt = aNode._DOMElement; NS_ASSERT(nodeElt, "node must have _DOMElement set"); // There's no UI representation for the root node, thus there's // nothing to be done when the title changes. if (nodeElt == this._self.parentNode) return; nodeElt.label = aNewTitle || PlacesUIUtils.getBestTitle(aNode); }, nodeURIChanged: function PMV_nodeURIChanged(aNode, aURIString) { let nodeElt = aNode._DOMElement; NS_ASSERT(nodeElt, "node must have _DOMElement set"); nodeElt.setAttribute("scheme", PlacesUIUtils.guessUrlSchemeForUI(aURIString)); }, nodeIconChanged: function PMV_nodeIconChanged(aNode) { let nodeElt = aNode._DOMElement; NS_ASSERT(nodeElt, "node must have _DOMElement set"); // There's no UI representation for the root node, thus there's // nothing to be done when the icon changes. if (nodeElt == this._self.parentNode) return; var icon = aNode.icon; if (icon) { if (nodeElt.getAttribute("image") != icon) nodeElt.setAttribute("image", icon); } else nodeElt.removeAttribute("image"); }, nodeAnnotationChanged: function PMV_nodeAnnotationChanged(aNode, aAnno) { // Ensure the changed annotation is a livemark one. if (/^livemark\//.test(aAnno) && PlacesUtils.nodeIsLivemarkContainer(aNode)) { let nodeElt = aNode._DOMElement; NS_ASSERT(nodeElt, "node must have _DOMElement set"); if (!nodeElt.hasAttribute("livemark")) nodeElt.setAttribute("livemark", "true"); // Add or remove the livemark status menuitem. PlacesUIUtils.ensureLivemarkStatusMenuItem(nodeElt.firstChild); } }, nodeHistoryDetailsChanged: function() { }, nodeTagsChanged: function() { }, nodeDateAddedChanged: function() { }, nodeLastModifiedChanged: function() { }, nodeKeywordChanged: function() { }, nodeReplaced: function PMV_nodeReplaced(aParentNode, aOldNode, aNewNode, aIndex) { let parentElt = aParentNode._DOMElement; NS_ASSERT(parentElt, "parent node must have _DOMElement set"); if (!parentElt._built) return; // parentElt is the element for the container, // we need the . let popup = parentElt.firstChild; let nodeElt = aOldNode._DOMElement; NS_ASSERT(nodeElt, "node must have _DOMElement set"); // No worries: If nodeElt is the last item (i.e. no nextSibling), // insertNewItem will insert the new element as the last item. let next = nodeElt.nextSibling; this._self.removeItem(nodeElt); this._self.insertNewItem(aNewNode, popup, next); }, containerOpened: function PMV_containerOpened(aNode) { this.invalidateContainer(aNode); }, containerClosed: function PMV_containerClosed(aNode) { this.invalidateContainer(aNode); }, containerStateChanged: function PMV_containerStateChanged(aNode, aOldState, aNewState) {}, invalidateContainer: function PMV_invalidateContainer(aContainer) { // Do nothing if the entire view is already marked un-built. if (!this._self.parentNode._built) return; let containerNodeElt = aContainer._DOMElement; NS_ASSERT(containerNodeElt, "node must have _DOMElement set"); containerNodeElt._built = false; // If the menupopup is open we should live-update it. if (containerNodeElt.open) this._self._rebuild(containerNodeElt.firstChild); }, sortingChanged: function PMV_sortingChanged(aSortingMode) { }, QueryInterface: function PTV_QueryInterface(aIID) { if (aIID.equals(Ci.nsINavHistoryResultObserver) || aIID.equals(Ci.nsISupportsWeakReference) || aIID.equals(Ci.nsISupports)) return this; throw Cr.NS_ERROR_NO_INTERFACE; } })]]>