Files
Mozilla/mozilla/browser/components/places/content/menu.xml
bryner%brianryner.com 19f36b2aa0 Add support for bookmark separators (bug 320261). r=brettw, ben.
git-svn-id: svn://10.0.0.236/branches/MOZILLA_1_8_BRANCH@189381 18797224-902f-48f8-a5cc-f745e15eee43
2006-02-08 01:10:57 +00:00

258 lines
8.9 KiB
XML
Executable File

<?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-menupopup"
extends="chrome://global/content/bindings/popup.xml#popup">
<implementation>
<constructor><![CDATA[
]]></constructor>
<destructor><![CDATA[
]]></destructor>
<method name="onPopupShowing">
<body><![CDATA[
if (PlacesController.nodeIsContainer(this._resultNode)) {
this._resultNode.QueryInterface(Ci.nsINavHistoryContainerResultNode);
this._resultNode.containerOpen = true;
}
this._rebuild();
if (this.popupShowingCallback)
this.popupShowingCallback();
]]></body>
</method>
<field name="_selection">null</field>
<field name="_result">null</field>
<filed name="_resultNode">null</filed>
<method name="setResultAndNode">
<parameter name="result"/>
<parameter name="resultNode"/>
<body><![CDATA[
this._result = result;
this._resultNode = resultNode;
this._rebuild();
]]></body>
</method>
<method name="getResult">
<body><![CDATA[
return this._result;
]]></body>
</method>
<method name="_cleanMenu">
<body><![CDATA[
var foundStartMarker = false;
var foundEndMarker = false;
var items = [];
for (var i = 0; i < this.childNodes.length; ++i) {
var item = this.childNodes[i];
if (item.getAttribute("builder") == "start") {
foundStartMarker = true;
continue;
}
if (item.getAttribute("builder") == "end") {
foundEndMarker = true;
continue;
}
if (foundStartMarker && !foundEndMarker)
items.push(item);
}
for (var i = 0; i < items.length; ++i)
items[i].parentNode.removeChild(items[i]);
if (!foundStartMarker && !foundEndMarker) {
while (this.hasChildNodes())
this.removeChild(this.firstChild);
}
LOG("KIDS = " + this.childNodes.length);
]]></body>
</method>
<method name="_rebuild">
<body><![CDATA[
this._cleanMenu();
const XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
if (PlacesController.nodeIsContainer(this._resultNode))
this._resultNode.QueryInterface(Ci.nsINavHistoryContainerResultNode);
else
return; // Nothing to do if this menu isn't a container.
var cc = this._resultNode.childCount;
if (cc > 0) {
for (var i = 0; i < cc; ++i) {
var child = this._resultNode.getChild(i);
var element = null;
if (PlacesController.nodeIsURI(child)) {
element = document.createElementNS(XULNS, "menuitem");
element.setAttribute("label", child.title);
element.setAttribute("url", child.uri);
element.setAttribute("statustext", child.url);
element.className = "menuitem-iconic bookmark-item";
}
else if (PlacesController.nodeIsContainer(child)) {
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);
// The context menu is set here instead of in the xbl constructor
// because it doesn't get initialized properly if set in the constructor.
popup.setAttribute("context", "placesContext");
popup._result = this._result;
popup._resultNode = child;
element.className = "menu-iconic bookmark-item";
}
// else if (nodeIsQuery) ... add menu to build kids
if (element) {
element.node = child;
this.appendChild(element);
}
if (child.icon)
element.setAttribute("image", child.icon.spec);
}
} else {
var bundle = document.getElementById("placeBundle");
var label = bundle.getString("bookmarksMenuEmptyFolder");
var element = null;
element = document.createElementNS(XULNS, "menuitem");
element.setAttribute("label", label);
element.setAttribute("disabled", true);
this.appendChild(element);
}
]]></body>
</method>
<property name="isBookmarks">
<getter><![CDATA[
return PlacesController.nodeIsFolder(this.getResult());
]]></getter>
</property>
<property name="hasSelection">
<getter><![CDATA[
return this._selection != null;
]]></getter>
</property>
<property name="hasSingleSelection">
<getter><![CDATA[
return this.hasSelection;
]]></getter>
</property>
<method name="getSelectionNodes">
<body><![CDATA[
return this.hasSelection ? [this.selectedNode] : [];
]]></body>
</method>
<method name="getRemovableSelectionRanges">
<body><![CDATA[
return [this.getSelectionNodes()];
]]></body>
</method>
<method name="getCopyableSelection">
<body><![CDATA[
return this.getSelectionNodes();
]]></body>
</method>
<property name="selectedNode">
<getter><![CDATA[
return this.hasSelection ? this._selection : null;
]]></getter>
</property>
<property name="selectedURINode">
<getter><![CDATA[
var node = this.selectedNode;
return node && PlacesController.nodeIsURI(node) ? node : null;
]]></getter>
</property>
<property name="insertionPoint">
<getter><![CDATA[
// By default, the insertion point is at the top level, at the end.
var index = -1;
var folderId = 0;
if(PlacesController.nodeIsFolder(this._resultNode))
folderId = this._resultNode.QueryInterface(Ci.nsINavHistoryFolderResultNode).folderId;
if (this.hasSelection) {
if(PlacesController.nodeIsFolder(this.selectedNode)) {
// If there is a folder selected, the insertion point is the
// end of the folder.
folderId = this.selectedNode.QueryInterface(Ci.nsINavHistoryFolderResultNode).folderId;
} else {
// If there is another type of node selected, the insertion point
// is after that node.
index = PlacesController.getIndexOfNode(this.selectedNode)
}
}
return new InsertionPoint(folderId, index);
]]></getter>
</property>
<property name="browserWindow" onget="return window;"/>
<field name="filterTransactions">false</field>
<field name="supportedDropTypes">
[TYPE_X_MOZ_PLACE_CONTAINER, TYPE_X_MOZ_PLACE_SEPARATOR, TYPE_X_MOZ_PLACE, TYPE_X_MOZ_URL]
</field>
<field name="supportedDropOnTypes">
[TYPE_X_MOZ_PLACE_CONTAINER, TYPE_X_MOZ_PLACE_SEPARATOR, TYPE_X_MOZ_PLACE, TYPE_X_MOZ_URL]
</field>
<method name="selectAll">
<body><![CDATA[
// Nothing
]]></body>
</method>
<method name="saveSelection">
<parameter name="mode"/>
<body><![CDATA[
]]></body>
</method>
<method name="restoreSelection">
<body><![CDATA[
]]></body>
</method>
</implementation>
<handlers>
<handler event="popupshowing">
if (event.target == this) {
this.onPopupShowing();
}
</handler>
<handler event="popuphidden">
if (event.target == this) {
if (PlacesController.nodeIsContainer(this._resultNode)) {
this._resultNode.QueryInterface(Ci.nsINavHistoryContainerResultNode);
this._resultNode.containerOpen = false;
}
}
</handler>
<handler event="click"><![CDATA[
if (event.target.localName != "menuitem" &&
event.target.localName != "menu")
return;
this._selection = event.target.node;
PlacesController.activeView = this;
PlacesController.mouseLoadURI(event);
]]></handler>
</handlers>
</binding>
</bindings>