2008-07-16 08:41:38 -07:00
|
|
|
<?xml version="1.0"?>
|
2008-12-15 08:44:27 -08:00
|
|
|
|
|
|
|
<!DOCTYPE bindings [
|
|
|
|
<!ENTITY % browserDTD SYSTEM "chrome://browser/locale/browser.dtd">
|
|
|
|
%browserDTD;
|
|
|
|
]>
|
2008-07-16 08:41:38 -07:00
|
|
|
|
|
|
|
<bindings
|
|
|
|
xmlns="http://www.mozilla.org/xbl"
|
|
|
|
xmlns:xbl="http://www.mozilla.org/xbl"
|
2010-04-13 15:41:17 -07:00
|
|
|
xmlns:svg="http://www.w3.org/2000/svg"
|
2008-07-16 08:41:38 -07:00
|
|
|
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
|
|
|
|
|
|
|
<binding id="autocomplete-aligned" extends="chrome://global/content/bindings/autocomplete.xml#autocomplete">
|
|
|
|
<implementation>
|
2010-09-12 07:28:53 -07:00
|
|
|
<property name="mIgnoreFocus" onget="return true;" onset="val;"/>
|
2010-10-10 14:23:28 -07:00
|
|
|
<property name="mIgnoreClick" onget="return true;" onset="val;"/>
|
|
|
|
<property name="readOnly" onget="return this.inputField.readOnly;">
|
|
|
|
<setter><![CDATA[
|
2010-10-14 06:15:29 -07:00
|
|
|
if (val == this.inputField.readOnly)
|
|
|
|
return;
|
|
|
|
|
2010-10-10 14:23:28 -07:00
|
|
|
this.inputField.readOnly = val;
|
|
|
|
val ? this.setAttribute("readonly", "true")
|
|
|
|
: this.removeAttribute("readonly");
|
|
|
|
|
|
|
|
// This is a workaround needed to cycle focus for the IME state
|
|
|
|
// to be set properly (bug 488420)
|
|
|
|
this.inputField.blur();
|
|
|
|
this.inputField.focus();
|
|
|
|
return val;
|
|
|
|
]]></setter>
|
|
|
|
</property>
|
|
|
|
|
2008-07-16 08:41:38 -07:00
|
|
|
<method name="openPopup">
|
|
|
|
<body><![CDATA[
|
2009-07-31 14:03:47 -07:00
|
|
|
this.popup.openAutocompletePopup(this, null);
|
2008-07-16 08:41:38 -07:00
|
|
|
]]></body>
|
|
|
|
</method>
|
2010-10-10 14:23:28 -07:00
|
|
|
|
2008-07-16 08:41:38 -07:00
|
|
|
<method name="closePopup">
|
|
|
|
<body><![CDATA[
|
2009-07-31 14:03:47 -07:00
|
|
|
// hack! we want to revert to the "all results" popup when the
|
|
|
|
// controller would otherwise close us because of an empty search
|
2009-09-18 21:17:52 -07:00
|
|
|
// string.
|
2009-07-31 14:03:47 -07:00
|
|
|
if (this.value == "")
|
|
|
|
this.showHistoryPopup();
|
2008-07-16 08:41:38 -07:00
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
</implementation>
|
2009-07-31 14:03:47 -07:00
|
|
|
<handlers>
|
2010-08-27 12:16:53 -07:00
|
|
|
<handler event="text" phase="bubbling">
|
|
|
|
<![CDATA[
|
|
|
|
if (this.mController.input == this)
|
|
|
|
this.mController.handleText();
|
|
|
|
]]>
|
|
|
|
</handler>
|
2010-10-10 14:23:28 -07:00
|
|
|
|
|
|
|
<handler event="focus" phase="bubbling">
|
|
|
|
<![CDATA[
|
|
|
|
if (this.clickSelectsAll)
|
|
|
|
this.select();
|
|
|
|
]]>
|
|
|
|
</handler>
|
|
|
|
|
2010-08-27 12:16:53 -07:00
|
|
|
<handler event="blur" phase="capturing">
|
2009-07-31 14:03:47 -07:00
|
|
|
<![CDATA[
|
2010-09-09 02:08:43 -07:00
|
|
|
// Bug 583341 - suppress disconnect of autocomplete controller
|
2010-08-27 12:16:53 -07:00
|
|
|
this._dontBlur = true;
|
2009-07-31 14:03:47 -07:00
|
|
|
]]>
|
|
|
|
</handler>
|
|
|
|
</handlers>
|
2008-07-16 08:41:38 -07:00
|
|
|
</binding>
|
2009-02-24 22:20:45 -08:00
|
|
|
|
2009-07-28 15:49:09 -07:00
|
|
|
<binding id="popup_autocomplete_result">
|
2010-09-09 02:16:09 -07:00
|
|
|
<handlers>
|
|
|
|
<handler event="contextmenu" phase="capturing">
|
|
|
|
<![CDATA[
|
|
|
|
let url = this.getAttribute("url");
|
|
|
|
if (!url)
|
|
|
|
return;
|
|
|
|
|
|
|
|
let value = this.getAttribute("value");
|
|
|
|
let data = {
|
|
|
|
target: this,
|
|
|
|
json: {
|
2010-10-08 22:35:09 -07:00
|
|
|
types: ["link-shareable"],
|
2010-09-09 02:16:09 -07:00
|
|
|
label: value,
|
|
|
|
linkTitle: value,
|
|
|
|
linkURL: url
|
|
|
|
}
|
|
|
|
};
|
|
|
|
ContextHelper.showPopup(data);
|
|
|
|
]]>
|
|
|
|
</handler>
|
|
|
|
</handlers>
|
2009-09-21 14:09:47 -07:00
|
|
|
<content orient="vertical">
|
2010-09-23 06:26:00 -07:00
|
|
|
<xul:hbox class="autocomplete-item-container" align="top" xbl:inherits="favorite,remote" mousethrough="always">
|
2009-09-21 14:09:47 -07:00
|
|
|
<xul:image xbl:inherits="src"/>
|
2010-04-19 21:01:40 -07:00
|
|
|
<xul:vbox flex="1">
|
2010-09-09 07:10:27 -07:00
|
|
|
<xul:label class="autocomplete-item-label" crop="center" xbl:inherits="value"/>
|
|
|
|
<xul:label class="autocomplete-item-url" xbl:inherits="value=url" crop="center"/>
|
|
|
|
</xul:vbox>
|
|
|
|
<xul:vbox align="end">
|
|
|
|
<xul:label class="autocomplete-item-tags" value="" xbl:inherits="value=tags"/>
|
|
|
|
<xul:label class="autocomplete-item-badge" value="" xbl:inherits="value=badge"/>
|
2010-04-19 21:01:40 -07:00
|
|
|
</xul:vbox>
|
2009-09-21 14:09:47 -07:00
|
|
|
</xul:hbox>
|
2009-07-28 15:49:09 -07:00
|
|
|
</content>
|
|
|
|
</binding>
|
|
|
|
|
2008-12-09 10:38:31 -08:00
|
|
|
<binding id="popup_autocomplete">
|
2010-08-24 01:42:28 -07:00
|
|
|
<content orient="vbox" class="autocomplete-box" flex="1">
|
|
|
|
<!-- 24 child items, to match browser.urlbar.maxRichResults -->
|
|
|
|
<xul:scrollbox orient="vertical"
|
|
|
|
class="autocomplete-items"
|
|
|
|
anonid="autocomplete-items"
|
|
|
|
flex="1000">
|
|
|
|
<xul:autocompleteresult/>
|
|
|
|
<xul:autocompleteresult/>
|
|
|
|
<xul:autocompleteresult/>
|
|
|
|
<xul:autocompleteresult/>
|
|
|
|
<xul:autocompleteresult/>
|
|
|
|
<xul:autocompleteresult/>
|
|
|
|
<xul:autocompleteresult/>
|
|
|
|
<xul:autocompleteresult/>
|
|
|
|
<xul:autocompleteresult/>
|
|
|
|
<xul:autocompleteresult/>
|
|
|
|
<xul:autocompleteresult/>
|
|
|
|
<xul:autocompleteresult/>
|
|
|
|
<xul:autocompleteresult/>
|
|
|
|
<xul:autocompleteresult/>
|
|
|
|
<xul:autocompleteresult/>
|
|
|
|
<xul:autocompleteresult/>
|
|
|
|
<xul:autocompleteresult/>
|
|
|
|
<xul:autocompleteresult/>
|
|
|
|
<xul:autocompleteresult/>
|
|
|
|
<xul:autocompleteresult/>
|
|
|
|
<xul:autocompleteresult/>
|
|
|
|
<xul:autocompleteresult/>
|
|
|
|
<xul:autocompleteresult/>
|
|
|
|
<xul:autocompleteresult/>
|
|
|
|
</xul:scrollbox>
|
|
|
|
<children/>
|
2008-12-09 10:38:31 -08:00
|
|
|
</content>
|
|
|
|
|
2009-11-05 14:02:22 -08:00
|
|
|
<implementation implements="nsIAutoCompletePopup">
|
2009-04-30 18:09:48 -07:00
|
|
|
<!-- Used by the chrome input handler -->
|
|
|
|
<property name="boxObject"
|
|
|
|
readonly="true"
|
|
|
|
onget="return this._items.boxObject;"/>
|
|
|
|
|
2009-07-02 11:49:08 -07:00
|
|
|
<field name="_scrollBoxObject">
|
2010-07-13 07:36:09 -07:00
|
|
|
this.boxObject.QueryInterface(Ci.nsIScrollBoxObject);
|
2009-07-02 11:49:08 -07:00
|
|
|
</field>
|
|
|
|
|
2010-09-09 07:10:27 -07:00
|
|
|
<!-- Used by the badges implementation -->
|
|
|
|
<field name="_badges">[]</field>
|
|
|
|
<field name="_badgesTimeout">-1</field>
|
|
|
|
|
2008-12-09 10:38:31 -08:00
|
|
|
<!-- nsIAutocompleteInput -->
|
|
|
|
<property name="overrideValue"
|
|
|
|
readonly="true"
|
|
|
|
onget="return null;"/>
|
|
|
|
|
|
|
|
<field name="_input"/>
|
|
|
|
<property name="input"
|
|
|
|
readonly="true"
|
|
|
|
onget="return this._input;"/>
|
|
|
|
|
|
|
|
<field name="_selectedIndex">-1</field>
|
|
|
|
<field name="_selectedItem"/>
|
2010-08-24 01:42:28 -07:00
|
|
|
<property name="selectedIndex" onget="return this._selectedIndex;">
|
2008-12-09 10:38:31 -08:00
|
|
|
<setter><![CDATA[
|
|
|
|
// Ignore invalid indices
|
|
|
|
if (val < -1 ||
|
|
|
|
val > this._matchCount - 1)
|
|
|
|
return val;
|
|
|
|
|
|
|
|
if (this._selectedItem)
|
|
|
|
this._styleItem(this._selectedItem, false);
|
|
|
|
|
|
|
|
// highlight the selected item
|
|
|
|
let item = this._items.childNodes.item(val);
|
|
|
|
if (item) {
|
|
|
|
this._selectedItem = item;
|
|
|
|
this._styleItem(this._selectedItem, true);
|
2009-08-18 22:55:03 -07:00
|
|
|
this._scrollBoxObject.ensureElementIsVisible(this._selectedItem);
|
2008-12-09 10:38:31 -08:00
|
|
|
}
|
2009-02-24 22:20:45 -08:00
|
|
|
|
2008-12-09 10:38:31 -08:00
|
|
|
return this._selectedIndex = val;
|
|
|
|
]]></setter>
|
|
|
|
</property>
|
|
|
|
|
|
|
|
<field name="_popupOpen">false</field>
|
|
|
|
<property name="popupOpen"
|
|
|
|
readonly="true"
|
|
|
|
onget="return this._popupOpen;"/>
|
|
|
|
|
|
|
|
<method name="openAutocompletePopup">
|
|
|
|
<parameter name="aInput"/>
|
|
|
|
<parameter name="aElement"/>
|
|
|
|
<body><![CDATA[
|
|
|
|
if (this._popupOpen)
|
|
|
|
return;
|
|
|
|
|
2009-09-22 08:36:45 -07:00
|
|
|
this._selectedItem = null;
|
2008-12-09 10:38:31 -08:00
|
|
|
this._input = aInput;
|
|
|
|
this._popupOpen = true;
|
|
|
|
|
|
|
|
this.invalidate();
|
2010-05-03 10:52:39 -07:00
|
|
|
|
|
|
|
let event = document.createEvent("Events");
|
|
|
|
event.initEvent("popupshown", true, false);
|
|
|
|
this.dispatchEvent(event);
|
2008-12-09 10:38:31 -08:00
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="closePopup">
|
|
|
|
<body><![CDATA[
|
|
|
|
if (!this._popupOpen)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this.selectedIndex = -1;
|
|
|
|
this.input.controller.stopSearch();
|
|
|
|
this._popupOpen = false;
|
2009-07-08 07:55:07 -07:00
|
|
|
|
2010-05-03 10:52:39 -07:00
|
|
|
let event = document.createEvent("Events");
|
|
|
|
event.initEvent("popuphidden", true, false);
|
|
|
|
this.dispatchEvent(event);
|
2009-07-08 07:55:07 -07:00
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
2010-03-16 20:14:43 -07:00
|
|
|
<method name="scrollToTop">
|
|
|
|
<body><![CDATA[
|
|
|
|
if (this._items.scrollTop || this._items.scrollLeft)
|
|
|
|
this._scrollBoxObject.scrollTo(0, 0);
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
2009-07-08 07:55:07 -07:00
|
|
|
<!-- Helper used by active dialog system -->
|
|
|
|
<method name="close">
|
|
|
|
<body><![CDATA[
|
|
|
|
this.closePopup();
|
2008-12-09 10:38:31 -08:00
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
2009-04-30 18:09:48 -07:00
|
|
|
<field name="_XULNS">("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul")</field>
|
|
|
|
|
2008-12-09 10:38:31 -08:00
|
|
|
<method name="invalidate">
|
|
|
|
<body><![CDATA[
|
|
|
|
// Don't bother doing work if we're not even open
|
|
|
|
if (!this.popupOpen)
|
|
|
|
return;
|
|
|
|
|
2009-07-31 14:03:47 -07:00
|
|
|
let controller = this.input.controller;
|
|
|
|
let searchString = controller.searchString;
|
|
|
|
let items = this._items;
|
|
|
|
|
2009-04-30 18:09:48 -07:00
|
|
|
// Need to iterate over all our existing entries at a minimum, to make
|
|
|
|
// sure they're either updated or cleared out. We might also have to
|
|
|
|
// add extra items.
|
2009-05-26 08:46:39 -07:00
|
|
|
let matchCount = this._matchCount;
|
2009-07-28 15:49:09 -07:00
|
|
|
let children = items.childNodes;
|
2009-05-26 08:46:39 -07:00
|
|
|
let iterCount = Math.max(children.length, matchCount);
|
2009-04-30 18:09:48 -07:00
|
|
|
for (let i = 0; i < iterCount; ++i) {
|
2009-07-28 15:49:09 -07:00
|
|
|
let item = children.item(i);
|
2009-04-30 18:09:48 -07:00
|
|
|
|
2009-07-28 15:49:09 -07:00
|
|
|
// Create an item if needed
|
|
|
|
if (!item) {
|
|
|
|
item = document.createElementNS(this._XULNS, "xul:autocompleteresult");
|
|
|
|
items.appendChild(item);
|
2009-05-26 08:46:39 -07:00
|
|
|
}
|
2009-09-02 11:11:00 -07:00
|
|
|
|
2009-07-28 15:49:09 -07:00
|
|
|
item._index = i;
|
2009-05-26 08:46:39 -07:00
|
|
|
|
2008-12-09 10:38:31 -08:00
|
|
|
// Check whether there's an entry to fill
|
|
|
|
if (i > matchCount - 1) {
|
2009-11-10 11:47:38 -08:00
|
|
|
// Just clear out the old item's value. CSS takes care of hiding
|
|
|
|
// everything else based on value="" (star, tags, etc.)
|
2009-07-28 15:49:09 -07:00
|
|
|
item.setAttribute("value", "");
|
|
|
|
item._empty = true;
|
2008-12-09 10:38:31 -08:00
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2009-07-28 15:49:09 -07:00
|
|
|
// Assign the values
|
2008-12-09 10:38:31 -08:00
|
|
|
let type = controller.getStyleAt(i);
|
2009-07-28 15:49:09 -07:00
|
|
|
let title = controller.getCommentAt(i);
|
|
|
|
let tags = '';
|
2010-03-16 20:14:43 -07:00
|
|
|
|
2010-08-24 01:55:51 -07:00
|
|
|
if (type == "tag") {
|
|
|
|
try {
|
|
|
|
[, title, tags] = title.match(/^(.+) \u2013 (.+)$/);
|
|
|
|
} catch (e) {}
|
|
|
|
}
|
2009-07-28 15:49:09 -07:00
|
|
|
item.setAttribute("tags", tags);
|
2008-12-09 10:38:31 -08:00
|
|
|
|
2009-07-28 15:49:09 -07:00
|
|
|
let url = controller.getValueAt(i);
|
2009-09-21 14:09:47 -07:00
|
|
|
item.setAttribute("value", title || url);
|
2010-09-09 07:10:27 -07:00
|
|
|
|
|
|
|
// remove the badge only if the url has changed
|
|
|
|
if (item._empty || item.getAttribute("url") != url) {
|
|
|
|
item.setAttribute("url", url);
|
|
|
|
item.removeAttribute("badge");
|
2010-09-23 06:26:00 -07:00
|
|
|
item.removeAttribute("remote");
|
2010-09-09 07:10:27 -07:00
|
|
|
}
|
2009-07-28 15:49:09 -07:00
|
|
|
|
|
|
|
let isBookmark = ((type == "bookmark") || (type == "tag"));
|
|
|
|
item.setAttribute("favorite", isBookmark);
|
|
|
|
item.setAttribute("src", controller.getImageAt(i));
|
2010-09-09 07:10:27 -07:00
|
|
|
|
|
|
|
item._empty = false;
|
2009-07-28 15:49:09 -07:00
|
|
|
}
|
|
|
|
|
2009-07-31 14:03:47 -07:00
|
|
|
// Show the "no results" or "all bookmarks" entries as needed
|
2009-07-28 15:49:09 -07:00
|
|
|
this._updateNoResultsItem(matchCount);
|
2010-05-13 10:45:23 -07:00
|
|
|
|
|
|
|
// Make sure the list is scrolled to the top
|
|
|
|
this.scrollToTop();
|
2010-09-09 07:10:27 -07:00
|
|
|
this._invalidateBadges();
|
2009-07-28 15:49:09 -07:00
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="_updateNoResultsItem">
|
|
|
|
<parameter name="isResults" />
|
|
|
|
<body><![CDATA[
|
|
|
|
let noResultsItem = this._items.childNodes.item(1);
|
|
|
|
if (isResults) {
|
|
|
|
noResultsItem.className = "";
|
2010-08-24 01:42:28 -07:00
|
|
|
} else {
|
2009-07-28 15:49:09 -07:00
|
|
|
noResultsItem.className = "noresults";
|
|
|
|
noResultsItem.setAttribute("value", "]]>&noResults.label;<![CDATA[");
|
2009-11-10 11:47:38 -08:00
|
|
|
noResultsItem.removeAttribute("favorite");
|
|
|
|
noResultsItem.removeAttribute("url");
|
|
|
|
noResultsItem.removeAttribute("src");
|
|
|
|
noResultsItem.removeAttribute("tags");
|
2010-09-09 07:10:27 -07:00
|
|
|
noResultsItem.removeAttribute("badge");
|
2010-09-23 06:26:00 -07:00
|
|
|
noResultsItem.removeAttribute("remote");
|
2009-07-28 15:49:09 -07:00
|
|
|
}
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
2008-12-09 10:38:31 -08:00
|
|
|
<method name="selectBy">
|
|
|
|
<parameter name="aReverse"/>
|
|
|
|
<parameter name="aPage"/>
|
|
|
|
<body><![CDATA[
|
|
|
|
let newIndex;
|
|
|
|
let lastIndex = this._matchCount - 1;
|
|
|
|
|
|
|
|
if (this._selectedIndex == -1)
|
|
|
|
newIndex = aReverse ? lastIndex : 0;
|
|
|
|
else
|
|
|
|
newIndex = this._selectedIndex + (aReverse ? -1 : 1);
|
|
|
|
|
|
|
|
// Deal with rollover
|
|
|
|
if (newIndex > lastIndex)
|
|
|
|
newIndex = 0;
|
|
|
|
else if (newIndex < 0)
|
|
|
|
newIndex = lastIndex;
|
|
|
|
|
|
|
|
this.selectedIndex = newIndex;
|
|
|
|
]]></body>
|
|
|
|
</method>
|
2009-02-24 22:20:45 -08:00
|
|
|
|
2010-09-09 07:10:27 -07:00
|
|
|
<method name="registerBadgeHandler">
|
|
|
|
<parameter name="aURL"/>
|
|
|
|
<parameter name="aHandler"/>
|
|
|
|
<body><![CDATA[
|
|
|
|
if (!aHandler)
|
|
|
|
return false;
|
|
|
|
|
2010-10-13 07:57:12 -07:00
|
|
|
this._badges[aURL] = aHandler;
|
2010-09-09 07:10:27 -07:00
|
|
|
return true;
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="unregisterBagdeHandler">
|
|
|
|
<parameter name="aURL"/>
|
|
|
|
<body><![CDATA[
|
2010-10-13 07:57:12 -07:00
|
|
|
if (this._badges[aURL])
|
|
|
|
delete this._badges[aURL];
|
2010-09-09 07:10:27 -07:00
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="_invalidateBadges">
|
|
|
|
<body><![CDATA[
|
|
|
|
window.clearTimeout(this._badgesTimeout);
|
|
|
|
|
|
|
|
this._badgesTimeout = window.setTimeout(function(self) {
|
2010-09-23 06:26:00 -07:00
|
|
|
#ifdef MOZ_SERVICES_SYNC
|
|
|
|
let remoteItems = RemoteTabsList.panel._getRemoteTabs();
|
|
|
|
#endif
|
2010-09-09 07:10:27 -07:00
|
|
|
for (let i = 0; i < self._items.childNodes.length; i++) {
|
|
|
|
let item = self._items.childNodes[i];
|
|
|
|
if (!item.hasAttribute("url"))
|
|
|
|
continue;
|
|
|
|
|
2010-10-13 07:57:12 -07:00
|
|
|
let itemURL = item.getAttribute("url");
|
|
|
|
let itemURI = Services.io.newURI(itemURL, null, null);
|
2010-10-06 08:04:46 -07:00
|
|
|
|
|
|
|
#ifdef MOZ_SERVICES_SYNC
|
|
|
|
// check if the tab is in the remote list
|
|
|
|
for (let i = 0; i < remoteItems.length; i++) {
|
2010-10-13 07:57:12 -07:00
|
|
|
let remoteURL = remoteItems[i].uri;
|
|
|
|
if (remoteURL) {
|
|
|
|
let remoteURI = Services.io.newURI(remoteURL, null, null);
|
|
|
|
if (itemURI.equals(remoteURI))
|
2010-10-06 08:04:46 -07:00
|
|
|
item.setAttribute("remote", "true");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-10-13 07:57:12 -07:00
|
|
|
for (let badgeURL in self._badges) {
|
|
|
|
if (itemURL.indexOf(badgeURL) == 0) {
|
2010-09-12 07:25:41 -07:00
|
|
|
// wrap the item to prevent setting a badge on a wrong item
|
|
|
|
let wrapper = {
|
|
|
|
set: function(aBadge) {
|
2010-10-13 07:57:12 -07:00
|
|
|
if (item.getAttribute("url") != itemURL)
|
2010-09-12 07:25:41 -07:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (!aBadge || aBadge == "")
|
|
|
|
item.removeAttribute("badge");
|
|
|
|
else
|
|
|
|
item.setAttribute("badge", aBadge);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2010-10-13 07:57:12 -07:00
|
|
|
let handler = self._badges[badgeURL];
|
2010-09-12 07:25:41 -07:00
|
|
|
handler.updateBadge ? handler.updateBadge(wrapper) : handler(wrapper);
|
2010-09-09 07:10:27 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, 300, this);
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
2008-12-09 10:38:31 -08:00
|
|
|
<!-- Helpers -->
|
|
|
|
<field name="_items">
|
|
|
|
document.getAnonymousElementByAttribute(this,
|
|
|
|
"anonid", "autocomplete-items");
|
|
|
|
</field>
|
|
|
|
|
|
|
|
<property name="_matchCount"
|
|
|
|
readonly="true">
|
|
|
|
<getter><![CDATA[
|
2010-08-24 01:42:28 -07:00
|
|
|
return this.input.controller.matchCount;
|
2008-12-09 10:38:31 -08:00
|
|
|
]]></getter>
|
|
|
|
</property>
|
|
|
|
|
|
|
|
<method name="_styleItem">
|
|
|
|
<parameter name="aItem"/>
|
|
|
|
<parameter name="aAddStyle"/>
|
|
|
|
<body><![CDATA[
|
|
|
|
if (aAddStyle)
|
2009-07-31 14:03:47 -07:00
|
|
|
aItem.className += " autocompleteresult-selected";
|
2008-12-09 10:38:31 -08:00
|
|
|
else
|
2009-07-31 14:03:47 -07:00
|
|
|
aItem.className = aItem.className.replace(/\s*autocompleteresult-selected/, "");
|
2008-12-09 10:38:31 -08:00
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
</implementation>
|
|
|
|
|
|
|
|
<handlers>
|
2009-07-31 14:03:47 -07:00
|
|
|
<handler event="click" button="0">
|
2008-12-09 10:38:31 -08:00
|
|
|
<![CDATA[
|
2009-09-15 10:06:21 -07:00
|
|
|
let target = event.originalTarget;
|
2010-10-10 14:23:28 -07:00
|
|
|
if (target._empty)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this._selectedIndex = target._index;
|
|
|
|
this.input.controller.handleEnter(true);
|
2008-12-09 10:38:31 -08:00
|
|
|
]]>
|
|
|
|
</handler>
|
|
|
|
</handlers>
|
|
|
|
</binding>
|
2008-07-16 08:41:38 -07:00
|
|
|
|
2009-02-24 22:20:45 -08:00
|
|
|
<binding id="place-base">
|
|
|
|
<content/>
|
2010-03-24 08:31:09 -07:00
|
|
|
|
|
|
|
<handlers>
|
|
|
|
<handler event="click" button="0">
|
2010-07-23 13:49:56 -07:00
|
|
|
<![CDATA[
|
2010-07-26 10:52:17 -07:00
|
|
|
if (this.control)
|
|
|
|
this.control._fireOpen(event, this);
|
2010-07-23 13:49:56 -07:00
|
|
|
]]>
|
|
|
|
</handler>
|
|
|
|
<handler event="contextmenu" phase="capturing">
|
|
|
|
<![CDATA[
|
2010-08-31 14:48:34 -07:00
|
|
|
if (!this.uri || this._isEditing)
|
2010-07-23 13:49:56 -07:00
|
|
|
return;
|
|
|
|
|
|
|
|
let data = {
|
|
|
|
target: this,
|
|
|
|
json: {
|
2010-10-08 22:35:09 -07:00
|
|
|
types: ["edit-bookmark", "link-shareable"],
|
2010-09-09 02:16:09 -07:00
|
|
|
label: this.name,
|
|
|
|
linkTitle: this.name,
|
|
|
|
linkURL: this.spec
|
|
|
|
}};
|
|
|
|
ContextHelper.showPopup(data);
|
|
|
|
]]>
|
|
|
|
</handler>
|
|
|
|
</handlers>
|
2010-03-24 08:31:09 -07:00
|
|
|
|
2008-12-15 08:44:27 -08:00
|
|
|
<implementation>
|
2009-04-08 22:40:05 -07:00
|
|
|
<field name="_uri">null</field>
|
2009-02-24 22:20:45 -08:00
|
|
|
<field name="_control">null</field>
|
2009-02-24 22:20:45 -08:00
|
|
|
<field name="_isEditing">false</field>
|
|
|
|
|
2008-12-15 08:44:27 -08:00
|
|
|
<field name="_nameField">
|
|
|
|
document.getAnonymousElementByAttribute(this, "anonid", "name");
|
|
|
|
</field>
|
|
|
|
<field name="_uriField">
|
|
|
|
document.getAnonymousElementByAttribute(this, "anonid", "uri");
|
|
|
|
</field>
|
|
|
|
<field name="_tagsField">
|
|
|
|
document.getAnonymousElementByAttribute(this, "anonid", "tags");
|
|
|
|
</field>
|
2009-11-23 08:44:34 -08:00
|
|
|
<property name="itemId" onget="return this.getAttribute('itemid');"/>
|
2009-02-24 22:20:45 -08:00
|
|
|
<property name="type" onget="return this.getAttribute('type');"/>
|
2009-02-24 22:20:45 -08:00
|
|
|
|
2009-11-23 08:44:34 -08:00
|
|
|
<property name="uri">
|
|
|
|
<getter><![CDATA[
|
|
|
|
if (!this._uri && this.getAttribute("uri"))
|
2010-07-13 07:36:09 -07:00
|
|
|
this._uri = Services.io.newURI(this.getAttribute("uri"), null, null);
|
2009-11-23 08:44:34 -08:00
|
|
|
|
|
|
|
return this._uri;
|
|
|
|
]]></getter>
|
|
|
|
</property>
|
|
|
|
|
2008-12-15 08:44:27 -08:00
|
|
|
<property name="name" onget="return this._nameField.value"
|
|
|
|
onset="this._nameField.value = val; return val;"/>
|
2009-02-24 22:20:45 -08:00
|
|
|
<property name="spec" onget="return this._uriField.value"
|
|
|
|
onset="this._uriField.value = val; return val;"/>
|
2008-12-15 08:44:27 -08:00
|
|
|
<property name="tags" onget="return this._tagsField.value"
|
|
|
|
onset="this._tagsField.value = val; return val;"/>
|
|
|
|
<property name="tagsAsArray" readonly="true">
|
|
|
|
<getter>
|
|
|
|
<![CDATA[
|
|
|
|
// we don't require the leading space (after each comma)
|
|
|
|
var tags = this.tags.split(",");
|
|
|
|
for (var i = 0; i < tags.length; i++) {
|
|
|
|
// remove trailing and leading spaces
|
|
|
|
tags[i] = tags[i].trim();
|
|
|
|
|
|
|
|
// remove empty entries from the array.
|
|
|
|
if (tags[i] == "") {
|
|
|
|
tags.splice(i, 1);
|
|
|
|
i--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return tags;
|
|
|
|
]]>
|
|
|
|
</getter>
|
|
|
|
</property>
|
2009-02-24 22:20:45 -08:00
|
|
|
<property name="isEditing" readonly="true" onget="return this._isEditing;"/>
|
2010-08-03 13:28:30 -07:00
|
|
|
<property name="isReadOnly" readonly="true">
|
|
|
|
<getter><![CDATA[
|
|
|
|
return this.control && this.control._readOnlyFolders.indexOf(parseInt(this.itemId, 10)) != -1;
|
|
|
|
]]></getter>
|
|
|
|
</property>
|
2009-02-24 22:20:45 -08:00
|
|
|
<property name="control" readonly="true">
|
|
|
|
<getter>
|
|
|
|
<![CDATA[
|
2009-02-24 22:20:45 -08:00
|
|
|
if (this._control)
|
|
|
|
return this._control;
|
|
|
|
|
2009-02-24 22:20:45 -08:00
|
|
|
let parent = this.parentNode;
|
|
|
|
while (parent) {
|
2009-02-24 22:20:45 -08:00
|
|
|
if (parent.localName == "placelist") {
|
|
|
|
this._control = parent;
|
|
|
|
return this._control;
|
|
|
|
}
|
2009-02-24 22:20:45 -08:00
|
|
|
parent = parent.parentNode;
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
]]>
|
|
|
|
</getter>
|
|
|
|
</property>
|
|
|
|
|
2008-12-15 08:44:27 -08:00
|
|
|
<method name="startEditing">
|
2009-03-03 06:31:51 -08:00
|
|
|
<parameter name="autoSelect"/>
|
2008-12-15 08:44:27 -08:00
|
|
|
<body>
|
|
|
|
<![CDATA[
|
2010-08-03 13:28:30 -07:00
|
|
|
if (!this.itemId || this.isReadOnly)
|
2008-12-15 08:44:27 -08:00
|
|
|
return;
|
|
|
|
|
2009-02-24 22:20:45 -08:00
|
|
|
this._isEditing = true;
|
2009-09-09 18:47:37 -07:00
|
|
|
if (this.control) {
|
|
|
|
this.setAttribute("selected", "true");
|
2010-09-30 14:14:47 -07:00
|
|
|
let self = this;
|
|
|
|
setTimeout(function() {
|
|
|
|
self.control.scrollBoxObject.ensureElementIsVisible(self);
|
|
|
|
}, 0);
|
2009-02-24 22:20:45 -08:00
|
|
|
this.control.activeItem = this;
|
2009-09-09 18:47:37 -07:00
|
|
|
}
|
2008-12-15 08:44:27 -08:00
|
|
|
|
2009-02-24 22:20:45 -08:00
|
|
|
this.updateFields();
|
|
|
|
|
2008-12-15 08:44:27 -08:00
|
|
|
this._nameField.focus();
|
2009-03-03 06:31:51 -08:00
|
|
|
if (autoSelect)
|
|
|
|
this._nameField.select();
|
2008-12-15 08:44:27 -08:00
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
<method name="stopEditing">
|
|
|
|
<parameter name="shouldSave"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
2010-08-03 13:28:30 -07:00
|
|
|
if (!this.itemId || this.isReadOnly)
|
2010-07-28 13:31:07 -07:00
|
|
|
return;
|
|
|
|
|
2008-12-15 08:44:27 -08:00
|
|
|
if (shouldSave)
|
|
|
|
this.save();
|
|
|
|
|
2009-02-24 22:20:45 -08:00
|
|
|
this._isEditing = false;
|
2010-07-23 13:49:56 -07:00
|
|
|
if (this.control && this.control.activeItem) {
|
2009-09-09 18:47:37 -07:00
|
|
|
this.control.activeItem.removeAttribute("selected");
|
2009-02-24 22:20:45 -08:00
|
|
|
this.control.activeItem = null;
|
2009-09-09 18:47:37 -07:00
|
|
|
}
|
2009-02-24 22:20:45 -08:00
|
|
|
|
|
|
|
this.updateFields();
|
|
|
|
|
2009-10-21 19:01:54 -07:00
|
|
|
let focusedElement = document.commandDispatcher.focusedElement;
|
|
|
|
if (focusedElement)
|
|
|
|
focusedElement.blur();
|
|
|
|
|
2008-12-15 08:44:27 -08:00
|
|
|
let event = document.createEvent("Events");
|
2010-04-07 10:47:08 -07:00
|
|
|
event.initEvent("close", false, false);
|
2008-12-15 08:44:27 -08:00
|
|
|
this.dispatchEvent(event);
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
<method name="save">
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
// Update the tags
|
2009-11-23 08:44:34 -08:00
|
|
|
if (this.uri && this.type != "folder") {
|
|
|
|
let currentTags = PlacesUtils.tagging.getTagsForURI(this.uri, {});
|
2009-04-21 13:55:05 -07:00
|
|
|
let tags = this.tagsAsArray;
|
2009-02-24 22:20:45 -08:00
|
|
|
if (tags.length > 0 || currentTags.length > 0) {
|
2009-04-21 13:55:05 -07:00
|
|
|
let tagsToRemove = [];
|
|
|
|
let tagsToAdd = [];
|
|
|
|
for (let i = 0; i < currentTags.length; i++) {
|
2009-02-24 22:20:45 -08:00
|
|
|
if (tags.indexOf(currentTags[i]) == -1)
|
|
|
|
tagsToRemove.push(currentTags[i]);
|
|
|
|
}
|
2009-04-21 13:55:05 -07:00
|
|
|
for (let i = 0; i < tags.length; i++) {
|
2009-02-24 22:20:45 -08:00
|
|
|
if (currentTags.indexOf(tags[i]) == -1)
|
|
|
|
tagsToAdd.push(tags[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tagsToAdd.length > 0)
|
2009-11-23 08:44:34 -08:00
|
|
|
PlacesUtils.tagging.tagURI(this.uri, tagsToAdd);
|
2009-02-24 22:20:45 -08:00
|
|
|
if (tagsToRemove.length > 0)
|
2009-11-23 08:44:34 -08:00
|
|
|
PlacesUtils.tagging.untagURI(this.uri, tagsToRemove);
|
2008-12-15 08:44:27 -08:00
|
|
|
}
|
2009-09-09 18:47:37 -07:00
|
|
|
this.setAttribute('tags', this.tags);
|
2008-12-15 08:44:27 -08:00
|
|
|
|
2009-04-21 13:55:05 -07:00
|
|
|
// If the URI was updated change it in the bookmark, but don't
|
|
|
|
// allow a blank URI. Revert to previous URI if blank.
|
|
|
|
let spec = this.spec;
|
2009-11-23 08:44:34 -08:00
|
|
|
if (spec && this.uri.spec != spec) {
|
2009-04-21 13:55:05 -07:00
|
|
|
try {
|
2010-02-16 15:38:16 -08:00
|
|
|
let oldURI = this._uri;
|
2010-07-13 07:36:09 -07:00
|
|
|
this._uri = Services.io.newURI(spec, null, null);
|
2009-11-23 08:44:34 -08:00
|
|
|
PlacesUtils.bookmarks.changeBookmarkURI(this.itemId, this.uri);
|
2009-09-09 18:47:37 -07:00
|
|
|
this.setAttribute('uri', this.spec);
|
2010-02-16 15:38:16 -08:00
|
|
|
|
|
|
|
// move tags from old URI to new URI
|
|
|
|
let tags = this.tagsAsArray;
|
|
|
|
if (tags.length != 0) {
|
|
|
|
// only untag the old URI if this is the only bookmark
|
|
|
|
if (PlacesUtils.getBookmarksForURI(oldURI, {}).length == 0)
|
|
|
|
PlacesUtils.tagging.untagURI(oldURI, tags);
|
|
|
|
|
|
|
|
PlacesUtils.tagging.tagURI(this._uri, tags);
|
|
|
|
}
|
2009-04-21 13:55:05 -07:00
|
|
|
}
|
|
|
|
catch (e) { }
|
2009-02-24 22:20:45 -08:00
|
|
|
}
|
2009-11-23 08:44:34 -08:00
|
|
|
if (spec != this.uri.spec)
|
2009-11-24 06:37:26 -08:00
|
|
|
this.spec = this.uri.spec;
|
2008-12-15 08:44:27 -08:00
|
|
|
}
|
2009-04-21 13:55:05 -07:00
|
|
|
|
|
|
|
// Update the name and use the URI if name is blank
|
2009-11-24 06:37:26 -08:00
|
|
|
this.name = this.name || this.spec;
|
2009-09-09 18:47:37 -07:00
|
|
|
this.setAttribute('title', this.name);
|
2009-11-23 08:44:34 -08:00
|
|
|
PlacesUtils.bookmarks.setItemTitle(this.itemId, this.name);
|
2008-12-15 08:44:27 -08:00
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
<method name="remove">
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
2009-11-23 08:44:34 -08:00
|
|
|
PlacesUtils.bookmarks.removeItem(this.itemId);
|
2008-12-15 08:44:27 -08:00
|
|
|
|
|
|
|
// If this was the last bookmark (excluding tag-items and livemark
|
|
|
|
// children, see getMostRecentBookmarkForURI) for the bookmark's url,
|
|
|
|
// remove the url from tag containers as well.
|
2009-11-23 08:44:34 -08:00
|
|
|
if (this.uri && this.type != "folder") {
|
|
|
|
if (PlacesUtils.getMostRecentBookmarkForURI(this.uri) == -1) {
|
|
|
|
var tags = PlacesUtils.tagging.getTagsForURI(this.uri, {});
|
|
|
|
PlacesUtils.tagging.untagURI(this.uri, tags);
|
2009-02-24 22:20:45 -08:00
|
|
|
}
|
2008-12-15 08:44:27 -08:00
|
|
|
}
|
|
|
|
|
2009-02-24 22:20:45 -08:00
|
|
|
this.stopEditing(false);
|
|
|
|
|
2008-12-15 08:44:27 -08:00
|
|
|
let event = document.createEvent("Events");
|
2009-02-24 22:20:45 -08:00
|
|
|
event.initEvent("BookmarkRemove", true, false);
|
2008-12-15 08:44:27 -08:00
|
|
|
this.dispatchEvent(event);
|
2009-10-20 20:32:36 -07:00
|
|
|
|
|
|
|
if (this.control)
|
|
|
|
this.control.removeItem(this);
|
|
|
|
|
2009-02-24 22:20:45 -08:00
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
<method name="updateFields">
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
// implemented by sub classes
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
</implementation>
|
|
|
|
</binding>
|
2008-12-15 08:44:27 -08:00
|
|
|
|
2009-02-24 22:20:45 -08:00
|
|
|
<binding id="place-item" extends="chrome://browser/content/bindings.xml#place-base">
|
2009-10-09 11:06:51 -07:00
|
|
|
<content orient="vertical">
|
2010-09-09 07:10:27 -07:00
|
|
|
<xul:hbox anonid="bookmark-item" class="bookmark-item-container" align="top" flex="1" mousethrough="always">
|
2009-10-09 11:06:51 -07:00
|
|
|
<xul:image xbl:inherits="src"/>
|
2010-04-19 21:01:40 -07:00
|
|
|
<xul:vbox flex="1">
|
2010-09-09 07:10:27 -07:00
|
|
|
<xul:label class="bookmark-item-label" crop="center" xbl:inherits="value=title"/>
|
2010-04-19 21:01:40 -07:00
|
|
|
<xul:label anonid="bookmark-url" class="bookmark-item-url" xbl:inherits="value=uri" crop="center" mousethrough="always"/>
|
|
|
|
</xul:vbox>
|
2010-09-09 07:10:27 -07:00
|
|
|
<xul:vbox>
|
|
|
|
<xul:label class="bookmark-item-tags" xbl:inherits="value=tags"/>
|
|
|
|
</xul:vbox>
|
2009-10-09 11:06:51 -07:00
|
|
|
</xul:hbox>
|
2009-09-09 18:47:37 -07:00
|
|
|
|
2009-10-09 11:06:51 -07:00
|
|
|
<xul:hbox anonid="bookmark-manage" class="bookmark-manage" hidden="true" flex="1">
|
|
|
|
<xul:image xbl:inherits="src"/>
|
2009-09-09 18:47:37 -07:00
|
|
|
<xul:vbox flex="1">
|
2009-10-09 11:06:51 -07:00
|
|
|
<xul:vbox flex="1">
|
2009-09-09 18:47:37 -07:00
|
|
|
<xul:textbox anonid="name" xbl:inherits="value=title"/>
|
2009-02-24 22:20:45 -08:00
|
|
|
<xul:textbox anonid="uri" xbl:inherits="value=uri"/>
|
|
|
|
<xul:textbox anonid="tags" xbl:inherits="value=tags" emptytext="&editBookmarkTags.label;"/>
|
2009-09-09 18:47:37 -07:00
|
|
|
</xul:vbox>
|
2010-07-23 13:49:56 -07:00
|
|
|
|
2009-10-09 11:06:51 -07:00
|
|
|
<xul:hbox class="bookmark-controls" align="center">
|
2009-09-09 18:47:37 -07:00
|
|
|
<xul:spacer flex="1"/>
|
2009-10-15 19:55:17 -07:00
|
|
|
<xul:button anonid="done-button" class="bookmark-done" label="&editBookmarkDone.label;"
|
2009-09-09 18:47:37 -07:00
|
|
|
oncommand="document.getBindingParent(this).stopEditing(true)"/>
|
|
|
|
</xul:hbox>
|
|
|
|
</xul:vbox>
|
|
|
|
</xul:hbox>
|
2009-02-24 22:20:45 -08:00
|
|
|
</content>
|
2009-09-09 18:47:37 -07:00
|
|
|
|
2009-02-24 22:20:45 -08:00
|
|
|
<implementation>
|
|
|
|
<method name="updateFields">
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
2009-10-09 11:06:51 -07:00
|
|
|
document.getAnonymousElementByAttribute(this, "anonid", "bookmark-item").hidden = this._isEditing;
|
|
|
|
document.getAnonymousElementByAttribute(this, "anonid", "bookmark-url").hidden = this._isEditing;
|
2009-02-24 22:20:45 -08:00
|
|
|
|
2009-10-09 11:06:51 -07:00
|
|
|
document.getAnonymousElementByAttribute(this, "anonid", "bookmark-manage").hidden = !this._isEditing;
|
2009-02-24 22:20:45 -08:00
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
</implementation>
|
|
|
|
</binding>
|
|
|
|
|
2009-09-09 18:47:37 -07:00
|
|
|
<binding id="place-folder" extends="chrome://browser/content/bindings.xml#place-item">
|
2009-02-24 22:20:45 -08:00
|
|
|
<implementation>
|
|
|
|
<method name="updateFields">
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
2009-10-09 11:06:51 -07:00
|
|
|
document.getAnonymousElementByAttribute(this, "anonid", "bookmark-item").hidden = this._isEditing;
|
|
|
|
document.getAnonymousElementByAttribute(this, "anonid", "bookmark-url").hidden = this._isEditing;
|
|
|
|
|
2009-09-09 18:47:37 -07:00
|
|
|
this._uriField.hidden = true;
|
|
|
|
this._tagsField.hidden = true;
|
2009-10-09 11:06:51 -07:00
|
|
|
document.getAnonymousElementByAttribute(this, "anonid", "bookmark-manage").hidden = !this._isEditing;
|
2008-12-15 08:44:27 -08:00
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
</implementation>
|
|
|
|
</binding>
|
2009-02-24 22:20:45 -08:00
|
|
|
|
|
|
|
<binding id="place-label" extends="chrome://browser/content/bindings.xml#place-base">
|
2010-03-24 08:31:09 -07:00
|
|
|
<handlers>
|
|
|
|
<handler event="click" button="0">
|
|
|
|
<![CDATA[
|
|
|
|
if (this.control)
|
2010-08-24 01:42:28 -07:00
|
|
|
this.control.open(this.previousSibling.itemId);
|
2010-03-24 08:31:09 -07:00
|
|
|
]]>
|
|
|
|
</handler>
|
|
|
|
</handlers>
|
|
|
|
|
2009-02-24 22:20:45 -08:00
|
|
|
<content align="center">
|
|
|
|
<xul:spacer xbl:inherits="width=indent"/>
|
|
|
|
<xul:image anonid="favicon" class="bookmark-folder-image"/>
|
2009-04-08 22:40:05 -07:00
|
|
|
<xul:label anonid="name" crop="end" flex="1" xbl:inherits="value=title"/>
|
2009-02-24 22:20:45 -08:00
|
|
|
</content>
|
|
|
|
</binding>
|
|
|
|
|
|
|
|
<binding id="place-list">
|
|
|
|
<content orient="vertical" flex="1">
|
2009-10-20 20:32:36 -07:00
|
|
|
<xul:vbox anonid="parent-items" class="place-list-parents" />
|
2010-03-24 08:31:09 -07:00
|
|
|
<xul:richlistbox anonid="child-items" class="place-list-children" flex="1" batch="25"/>
|
2009-02-24 22:20:45 -08:00
|
|
|
</content>
|
|
|
|
<implementation>
|
|
|
|
<constructor>
|
|
|
|
<![CDATA[
|
|
|
|
this._type = this.getAttribute("type");
|
|
|
|
this._mode = this.getAttribute("mode");
|
2009-12-14 12:26:51 -08:00
|
|
|
|
|
|
|
this._folderParents = {};
|
2010-04-13 08:39:46 -07:00
|
|
|
this._folderParents[this._desktopFolderId] = this.mobileRoot;
|
|
|
|
this._folderParents[PlacesUtils.bookmarks.unfiledBookmarksFolder] = this._desktopFolderId;
|
|
|
|
this._folderParents[PlacesUtils.bookmarksMenuFolderId] = this._desktopFolderId;
|
|
|
|
this._folderParents[PlacesUtils.toolbarFolderId] = this._desktopFolderId;
|
2009-02-24 22:20:45 -08:00
|
|
|
]]>
|
|
|
|
</constructor>
|
2009-04-08 22:40:05 -07:00
|
|
|
|
2010-04-13 08:39:46 -07:00
|
|
|
<field name="_desktopFolderId">-1000</field>
|
2009-12-14 12:26:51 -08:00
|
|
|
<field name="_desktopFolder"><![CDATA[
|
|
|
|
({
|
2010-04-13 08:39:46 -07:00
|
|
|
itemId: this._desktopFolderId, tags: "", uri: "",
|
2009-12-14 12:26:51 -08:00
|
|
|
title: Elements.browserBundle.getString("bookmarkList.desktop"),
|
|
|
|
type: Ci.nsINavHistoryResultNode.RESULT_TYPE_FOLDER
|
|
|
|
})
|
|
|
|
]]></field>
|
|
|
|
<field name="_desktopChildren"><![CDATA[
|
|
|
|
[
|
|
|
|
{
|
|
|
|
itemId: PlacesUtils.bookmarks.unfiledBookmarksFolder, tags: "", uri: "",
|
|
|
|
title: PlacesUtils.bookmarks.getItemTitle(PlacesUtils.bookmarks.unfiledBookmarksFolder),
|
|
|
|
type: Ci.nsINavHistoryResultNode.RESULT_TYPE_FOLDER
|
|
|
|
},
|
|
|
|
{
|
|
|
|
itemId: PlacesUtils.bookmarksMenuFolderId, tags: "", uri: "",
|
|
|
|
title: PlacesUtils.bookmarks.getItemTitle(PlacesUtils.bookmarksMenuFolderId),
|
|
|
|
type: Ci.nsINavHistoryResultNode.RESULT_TYPE_FOLDER
|
|
|
|
},
|
2010-07-23 13:49:56 -07:00
|
|
|
{
|
2009-12-14 12:26:51 -08:00
|
|
|
itemId: PlacesUtils.toolbarFolderId, tags: "", uri: "",
|
|
|
|
title: PlacesUtils.bookmarks.getItemTitle(PlacesUtils.toolbarFolderId),
|
|
|
|
type: Ci.nsINavHistoryResultNode.RESULT_TYPE_FOLDER
|
|
|
|
}
|
|
|
|
];
|
|
|
|
]]></field>
|
|
|
|
|
2010-04-26 22:10:52 -07:00
|
|
|
<field name="_readOnlyFolders"><![CDATA[
|
|
|
|
[
|
|
|
|
this._desktopFolderId,
|
|
|
|
PlacesUtils.bookmarks.unfiledBookmarksFolder,
|
|
|
|
PlacesUtils.bookmarksMenuFolderId,
|
|
|
|
PlacesUtils.toolbarFolderId
|
|
|
|
];
|
|
|
|
]]></field>
|
|
|
|
|
2009-02-24 22:20:45 -08:00
|
|
|
<field name="_type"/>
|
|
|
|
<field name="_mode"/>
|
|
|
|
<field name="_ignoreEditing">false</field>
|
|
|
|
<field name="_parents">
|
|
|
|
document.getAnonymousElementByAttribute(this, "anonid", "parent-items");
|
|
|
|
</field>
|
|
|
|
<field name="_children">
|
|
|
|
document.getAnonymousElementByAttribute(this, "anonid", "child-items");
|
|
|
|
</field>
|
|
|
|
|
2009-12-09 16:14:40 -08:00
|
|
|
<field name="scrollBoxObject">this._children.scrollBoxObject</field>
|
2009-02-27 11:44:35 -08:00
|
|
|
|
2009-10-20 20:32:36 -07:00
|
|
|
<property name="items" readonly="true" onget="return this._children.childNodes"/>
|
|
|
|
|
2009-11-19 11:40:54 -08:00
|
|
|
<field name="mobileRoot"><![CDATA[
|
|
|
|
PlacesUtils.annotations.getItemsWithAnnotation("mobile/bookmarksRoot", {})[0];
|
|
|
|
]]></field>
|
|
|
|
|
2009-10-20 20:32:36 -07:00
|
|
|
<property name="isRootFolder" readonly="true">
|
|
|
|
<getter>
|
|
|
|
<![CDATA[
|
2010-04-26 22:10:52 -07:00
|
|
|
let currentFolderId = this._parents.lastChild.itemId;
|
2009-11-19 11:40:54 -08:00
|
|
|
return currentFolderId == this.mobileRoot;
|
2009-10-20 20:32:36 -07:00
|
|
|
]]>
|
|
|
|
</getter>
|
|
|
|
</property>
|
|
|
|
|
2010-09-30 14:14:47 -07:00
|
|
|
<field name="_activeItem">null</field>
|
2009-02-24 22:20:45 -08:00
|
|
|
<property name="activeItem">
|
|
|
|
<getter>
|
|
|
|
<![CDATA[
|
|
|
|
return this._activeItem;
|
|
|
|
]]>
|
|
|
|
</getter>
|
|
|
|
<setter>
|
|
|
|
<![CDATA[
|
|
|
|
if (!this._ignoreEditing) {
|
|
|
|
if (this._activeItem && this._activeItem.isEditing) {
|
|
|
|
this._ignoreEditing = true;
|
|
|
|
this._activeItem.stopEditing(false);
|
|
|
|
this._ignoreEditing = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
this._activeItem = val;
|
|
|
|
}
|
|
|
|
return val;
|
|
|
|
]]>
|
|
|
|
</setter>
|
|
|
|
</property>
|
|
|
|
|
2009-12-14 12:26:51 -08:00
|
|
|
<method name="isDesktopFolderEmpty">
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
let options = PlacesUtils.history.getNewQueryOptions();
|
|
|
|
options.queryType = options.QUERY_TYPE_BOOKMARKS;
|
|
|
|
let query = PlacesUtils.history.getNewQuery();
|
|
|
|
let folders = [ PlacesUtils.bookmarks.unfiledBookmarksFolder,
|
|
|
|
PlacesUtils.bookmarksMenuFolderId,
|
|
|
|
PlacesUtils.toolbarFolderId
|
|
|
|
];
|
|
|
|
query.setFolders(folders, 3);
|
|
|
|
let result = PlacesUtils.history.executeQuery(query, options);
|
|
|
|
let rootNode = result.root;
|
|
|
|
rootNode.containerOpen = true;
|
|
|
|
let isEmpty = !rootNode.childCount;
|
|
|
|
rootNode.containerOpen = false;
|
|
|
|
|
|
|
|
return isEmpty;
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
2009-02-24 22:20:45 -08:00
|
|
|
<method name="_getChildren">
|
|
|
|
<parameter name="aFolder"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
let items = [];
|
|
|
|
|
|
|
|
let options = PlacesUtils.history.getNewQueryOptions();
|
|
|
|
options.queryType = (this._type == "bookmarks" ? options.QUERY_TYPE_BOOKMARKS : options.QUERY_TYPE_HISTORY);
|
2009-12-17 12:59:45 -08:00
|
|
|
|
|
|
|
// Exclude "query" items (e.g. "smart folders")
|
|
|
|
options.excludeQueries = true;
|
|
|
|
|
2009-02-24 22:20:45 -08:00
|
|
|
let query = PlacesUtils.history.getNewQuery();
|
|
|
|
|
|
|
|
if (aFolder)
|
|
|
|
query.setFolders([aFolder], 1);
|
2009-12-17 12:59:45 -08:00
|
|
|
|
2009-02-24 22:20:45 -08:00
|
|
|
let result = PlacesUtils.history.executeQuery(query, options);
|
|
|
|
let rootNode = result.root;
|
|
|
|
rootNode.containerOpen = true;
|
2010-07-28 13:31:07 -07:00
|
|
|
|
2009-02-24 22:20:45 -08:00
|
|
|
let cc = rootNode.childCount;
|
|
|
|
for (var i=0; i<cc; ++i) {
|
2009-12-17 12:59:45 -08:00
|
|
|
let node = rootNode.getChild(i);
|
|
|
|
|
|
|
|
// Ignore separators
|
|
|
|
if (node.type == node.RESULT_TYPE_SEPARATOR)
|
|
|
|
continue;
|
|
|
|
|
2009-02-24 22:20:45 -08:00
|
|
|
if (this._mode == "folders" && node.type == node.RESULT_TYPE_FOLDER) {
|
|
|
|
items.push(node);
|
|
|
|
}
|
|
|
|
else if (this._mode == "") {
|
|
|
|
items.push(node);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
rootNode.containerOpen = false;
|
|
|
|
return items;
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
2010-08-24 01:42:28 -07:00
|
|
|
<method name="open">
|
2009-02-24 22:20:45 -08:00
|
|
|
<parameter name="aRootFolder"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
2009-11-19 11:40:54 -08:00
|
|
|
aRootFolder = aRootFolder || this.mobileRoot;
|
2009-02-24 22:20:45 -08:00
|
|
|
|
|
|
|
this._activeItem = null;
|
|
|
|
|
|
|
|
let parents = this._parents;
|
|
|
|
while (parents.firstChild)
|
|
|
|
parents.removeChild(parents.firstChild);
|
|
|
|
|
|
|
|
const XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
|
|
|
var self = this;
|
|
|
|
|
|
|
|
let folderId = aRootFolder;
|
|
|
|
do {
|
2009-12-14 12:26:51 -08:00
|
|
|
let title;
|
2010-04-13 08:39:46 -07:00
|
|
|
if (folderId == this._desktopFolderId)
|
2009-12-14 12:26:51 -08:00
|
|
|
title = this._desktopFolder.title;
|
|
|
|
else
|
|
|
|
title = PlacesUtils.bookmarks.getItemTitle(folderId);
|
2009-04-08 22:40:05 -07:00
|
|
|
|
2009-02-24 22:20:45 -08:00
|
|
|
let parent = document.createElementNS(XULNS, "placelabel");
|
|
|
|
parent.setAttribute("class", "bookmark-folder");
|
|
|
|
parent.setAttribute("itemid", folderId);
|
|
|
|
parent.setAttribute("indent", 0);
|
2009-04-08 22:40:05 -07:00
|
|
|
parent.setAttribute("title", title);
|
2009-02-24 22:20:45 -08:00
|
|
|
parents.insertBefore(parent, parents.firstChild);
|
|
|
|
|
2009-12-14 12:26:51 -08:00
|
|
|
folderId = this._folderParents[folderId] || PlacesUtils.bookmarks.getFolderIdForItem(folderId);
|
2009-02-24 22:20:45 -08:00
|
|
|
} while (folderId != PlacesUtils.bookmarks.placesRoot)
|
|
|
|
|
|
|
|
let children = this._children;
|
2010-08-24 01:42:28 -07:00
|
|
|
while (children.lastChild)
|
|
|
|
children.removeChild(children.lastChild);
|
2009-02-24 22:20:45 -08:00
|
|
|
|
2009-03-03 06:31:51 -08:00
|
|
|
children.scrollBoxObject.scrollTo(0, 0);
|
|
|
|
|
2010-04-13 08:39:46 -07:00
|
|
|
let items = (aRootFolder == this._desktopFolderId) ? this._desktopChildren.concat()
|
2010-08-24 01:42:28 -07:00
|
|
|
: this._getChildren(aRootFolder);
|
2009-12-14 12:26:51 -08:00
|
|
|
|
|
|
|
if (aRootFolder == this.mobileRoot && !this.isDesktopFolderEmpty())
|
2010-03-24 08:31:09 -07:00
|
|
|
items.unshift(this._desktopFolder);
|
2009-12-09 16:14:40 -08:00
|
|
|
|
2010-03-24 08:31:09 -07:00
|
|
|
children.setItems(items.map(this.createItem));
|
2009-02-24 22:20:45 -08:00
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
2010-09-30 14:14:47 -07:00
|
|
|
<method name="close">
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
this.activeItem = null;
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
2009-04-08 22:40:05 -07:00
|
|
|
<method name="createItem">
|
|
|
|
<parameter name="aItem"/>
|
2009-02-24 22:20:45 -08:00
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
const XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
|
|
|
|
|
|
|
let child = document.createElementNS(XULNS, "placeitem");
|
2009-04-08 22:40:05 -07:00
|
|
|
child.setAttribute("itemid", aItem.itemId);
|
2009-02-24 22:20:45 -08:00
|
|
|
child.setAttribute("class", "bookmark-item");
|
2009-04-08 22:40:05 -07:00
|
|
|
child.setAttribute("title", aItem.title);
|
|
|
|
child.setAttribute("uri", aItem.uri);
|
|
|
|
child.setAttribute("tags", aItem.tags);
|
|
|
|
if (aItem.type == Ci.nsINavHistoryResultNode.RESULT_TYPE_FOLDER)
|
2009-02-24 22:20:45 -08:00
|
|
|
child.setAttribute("type", "folder");
|
2009-11-23 08:44:34 -08:00
|
|
|
else
|
|
|
|
child.setAttribute("src", aItem.icon);
|
2009-02-24 22:20:45 -08:00
|
|
|
|
|
|
|
return child;
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="removeItem">
|
|
|
|
<parameter name="aItem"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
this._children.removeChild(aItem);
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="_fireOpen">
|
|
|
|
<parameter name="aEvent"/>
|
|
|
|
<parameter name="aItem"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
2010-04-13 08:39:46 -07:00
|
|
|
let target = aEvent.originalTarget;
|
2010-04-26 22:10:52 -07:00
|
|
|
if (target.localName == "button" || this._activeItem == aItem)
|
2009-02-24 22:20:45 -08:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (aItem.type == "folder") {
|
2010-08-24 01:42:28 -07:00
|
|
|
this.open(aItem.itemId);
|
|
|
|
} else {
|
2009-02-24 22:20:45 -08:00
|
|
|
// Force the item to be active
|
|
|
|
this._activeItem = aItem;
|
|
|
|
|
|
|
|
// This is a callback used to forward information to some
|
|
|
|
// external code [we fire an event & a pseudo attribute event]
|
|
|
|
let event = document.createEvent("Events");
|
|
|
|
event.initEvent("BookmarkOpen", true, false);
|
|
|
|
this.dispatchEvent(event);
|
2010-08-24 01:42:28 -07:00
|
|
|
|
2009-02-24 22:20:45 -08:00
|
|
|
let func = new Function("event", this.getAttribute("onopen"));
|
2010-08-24 01:42:28 -07:00
|
|
|
func.call(this, aEvent);
|
|
|
|
}
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
</implementation>
|
|
|
|
</binding>
|
|
|
|
|
|
|
|
<binding id="history-list">
|
|
|
|
<handlers>
|
|
|
|
<handler event="click" button="0">
|
|
|
|
<![CDATA[
|
|
|
|
let func = new Function("event", this.getAttribute("onopen"));
|
|
|
|
func.call(this, event);
|
|
|
|
]]>
|
|
|
|
</handler>
|
|
|
|
</handlers>
|
|
|
|
<content orient="vertical" flex="1">
|
|
|
|
<xul:richlistbox anonid="child-items" class="history-list-children" flex="1" batch="25"/>
|
|
|
|
</content>
|
|
|
|
<implementation>
|
|
|
|
<method name="open">
|
|
|
|
<body><![CDATA[
|
|
|
|
let children = this._children;
|
|
|
|
while (children.lastChild)
|
|
|
|
children.removeChild(children.lastChild);
|
|
|
|
|
|
|
|
let items = this._getHistory();
|
|
|
|
children.setItems(items.map(this.createItem));
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<field name="_children">
|
|
|
|
document.getAnonymousElementByAttribute(this, "anonid", "child-items");
|
|
|
|
</field>
|
|
|
|
|
|
|
|
<field name="scrollBoxObject">this._children.scrollBoxObject</field>
|
|
|
|
|
|
|
|
<method name="_getHistory">
|
|
|
|
<body><![CDATA[
|
|
|
|
let items = [];
|
|
|
|
let historyService = Cc["@mozilla.org/browser/nav-history-service;1"].getService(Ci.nsINavHistoryService);
|
|
|
|
let query = historyService.getNewQuery();
|
|
|
|
|
|
|
|
let options = historyService.getNewQueryOptions();
|
|
|
|
options.excludeQueries = true;
|
|
|
|
options.queryType = options.QUERY_TYPE_HISTORY;
|
|
|
|
options.maxResults = Services.prefs.getIntPref("browser.display.history.maxresults");
|
|
|
|
options.resultType = options.RESULTS_AS_URI;
|
|
|
|
options.sortingMode = options.SORT_BY_DATE_DESCENDING;
|
|
|
|
|
|
|
|
let result = historyService.executeQuery(query, options);
|
|
|
|
let rootNode = result.root;
|
|
|
|
rootNode.containerOpen = true;
|
|
|
|
let childCount = rootNode.childCount;
|
|
|
|
|
|
|
|
// Get the rows title
|
|
|
|
let titleToday = PlacesUtils.getString("finduri-AgeInDays-is-0");
|
|
|
|
let titleYesterday = PlacesUtils.getString("finduri-AgeInDays-is-1");
|
|
|
|
let titleLastWeek = PlacesUtils.getFormattedString("finduri-AgeInDays-last-is", [7]);
|
|
|
|
let titleOlder = PlacesUtils.getFormattedString("finduri-AgeInDays-isgreater", [7]);
|
|
|
|
|
|
|
|
let lastTitle = null;
|
|
|
|
let msPerDay = 86400000;
|
|
|
|
let msPerWeek = msPerDay * 7;
|
|
|
|
let today = new Date(Date.now() - (Date.now() % msPerDay));
|
|
|
|
for (let i = 0; i < childCount; i++) {
|
|
|
|
let node = rootNode.getChild(i);
|
|
|
|
let time = new Date(node.time / 1000); // node.time is microseconds
|
|
|
|
|
|
|
|
// Insert a row title if needed
|
|
|
|
let msDelta = today - time;
|
|
|
|
if (msDelta < 0 && lastTitle == null) {
|
|
|
|
lastTitle = titleToday;
|
|
|
|
items.push({ title: lastTitle });
|
|
|
|
} else if (msDelta > 0 && msDelta < msPerDay && lastTitle != titleYesterday) {
|
|
|
|
lastTitle = titleYesterday;
|
|
|
|
items.push({ title: lastTitle });
|
|
|
|
} else if (msDelta > msPerDay && msDelta < msPerWeek && lastTitle != titleLastWeek) {
|
|
|
|
lastTitle = titleLastWeek;
|
|
|
|
items.push({ title: lastTitle });
|
|
|
|
} else if (msDelta > msPerWeek && lastTitle != titleOlder) {
|
|
|
|
lastTitle = titleOlder;
|
|
|
|
items.push({ title: lastTitle });
|
|
|
|
}
|
|
|
|
|
|
|
|
items.push(node);
|
|
|
|
}
|
|
|
|
|
|
|
|
rootNode.containerOpen = false;
|
|
|
|
return items;
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="createItem">
|
|
|
|
<parameter name="aItem"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
const XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
|
|
|
|
|
|
|
let child = document.createElementNS(XULNS, "autocompleteresult");
|
|
|
|
child.setAttribute("value", aItem.title || aItem.uri);
|
|
|
|
if (!aItem.uri) {
|
|
|
|
child.setAttribute("class", "history-item-title");
|
|
|
|
} else {
|
|
|
|
child.setAttribute("class", "history-item");
|
|
|
|
child.setAttribute("url", aItem.uri);
|
|
|
|
child.setAttribute("src", aItem.icon);
|
2009-02-24 22:20:45 -08:00
|
|
|
}
|
2010-08-24 01:42:28 -07:00
|
|
|
|
|
|
|
return child;
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
</implementation>
|
|
|
|
</binding>
|
|
|
|
|
|
|
|
<binding id="remotetabs-list">
|
|
|
|
<handlers>
|
|
|
|
<handler event="click" button="0">
|
|
|
|
<![CDATA[
|
|
|
|
let func = new Function("event", this.getAttribute("onopen"));
|
|
|
|
func.call(this, event);
|
|
|
|
]]>
|
|
|
|
</handler>
|
|
|
|
</handlers>
|
|
|
|
<content orient="vertical" flex="1">
|
|
|
|
<xul:richlistbox anonid="child-items" class="remotetabs-list-children" flex="1" batch="25"/>
|
|
|
|
</content>
|
|
|
|
<implementation>
|
|
|
|
<method name="open">
|
|
|
|
<body><![CDATA[
|
|
|
|
let children = this._children;
|
|
|
|
while (children.lastChild)
|
|
|
|
children.removeChild(children.lastChild);
|
|
|
|
|
|
|
|
let items = this._getRemoteTabs();
|
|
|
|
children.setItems(items.map(this.createItem));
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<field name="_children">
|
|
|
|
document.getAnonymousElementByAttribute(this, "anonid", "child-items");
|
|
|
|
</field>
|
|
|
|
|
|
|
|
<field name="scrollBoxObject">this._children.scrollBoxObject</field>
|
|
|
|
|
|
|
|
<method name="_getRemoteTabs">
|
|
|
|
<body><![CDATA[
|
2010-10-06 08:04:46 -07:00
|
|
|
// Don't do anything if the Weave isn't ready
|
|
|
|
if (document.getElementById("cmd_remoteTabs").getAttribute("disabled") == "true")
|
|
|
|
return [];
|
|
|
|
|
2010-08-24 01:42:28 -07:00
|
|
|
// Don't do anything if the tabs engine isn't ready
|
|
|
|
let engine = Weave.Engines.get("tabs");
|
|
|
|
if (!engine)
|
|
|
|
return [];
|
|
|
|
|
|
|
|
// Don't bother refetching tabs if we already did so recently
|
|
|
|
let lastFetch = Weave.Svc.Prefs.get("lastTabFetch", 0);
|
|
|
|
let now = Math.floor(Date.now() / 1000);
|
|
|
|
if (now - lastFetch >= 30) {
|
|
|
|
// Force a sync only for the tabs engine
|
|
|
|
engine.lastModified = null;
|
|
|
|
engine.sync();
|
|
|
|
Weave.Svc.Prefs.set("lastTabFetch", now);
|
|
|
|
};
|
|
|
|
|
|
|
|
// Generate the list of tabs
|
|
|
|
let tabs = [];
|
|
|
|
for (let [guid, client] in Iterator(engine.getAllClients())) {
|
|
|
|
tabs.push({ name: client.clientName });
|
|
|
|
|
|
|
|
client.tabs.forEach(function({title, urlHistory, icon}) {
|
2010-09-12 07:25:41 -07:00
|
|
|
let pageURL = urlHistory[0];
|
2010-08-24 01:42:28 -07:00
|
|
|
|
|
|
|
// Skip tabs that are already open
|
2010-09-12 07:25:41 -07:00
|
|
|
if (engine.locallyOpenTabMatchesURL(pageURL))
|
2010-08-24 01:42:28 -07:00
|
|
|
return;
|
|
|
|
|
|
|
|
tabs.push({
|
2010-09-12 07:25:41 -07:00
|
|
|
title: title || pageURL,
|
|
|
|
uri: pageURL,
|
2010-08-24 01:42:28 -07:00
|
|
|
icon: Weave.Utils.getIcon(icon, "chrome://browser/skin/images/tab.png")
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
return tabs;
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="createItem">
|
|
|
|
<parameter name="aItem"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
const XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
|
|
|
|
|
|
|
let child = document.createElementNS(XULNS, "autocompleteresult");
|
|
|
|
child.setAttribute("value", aItem.title || aItem.name);
|
|
|
|
if (aItem.name) {
|
|
|
|
child.setAttribute("class", "remotetabs-item-title");
|
|
|
|
} else {
|
|
|
|
child.setAttribute("class", "remotetabs-item");
|
|
|
|
child.setAttribute("url", aItem.uri);
|
|
|
|
child.setAttribute("src", aItem.icon);
|
|
|
|
}
|
|
|
|
|
|
|
|
return child;
|
2009-02-24 22:20:45 -08:00
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
</implementation>
|
|
|
|
</binding>
|
|
|
|
|
2010-03-24 08:31:09 -07:00
|
|
|
<binding id="richlistbox-batch" extends="chrome://global/content/bindings/richlistbox.xml#richlistbox">
|
|
|
|
<handlers>
|
|
|
|
<handler event="scroll">
|
|
|
|
<![CDATA[
|
|
|
|
// if there no more items to insert, just return early
|
|
|
|
if (this._items.length == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (this._contentScrollHeight == -1) {
|
|
|
|
let scrollheight = {};
|
|
|
|
this.scrollBoxObject.getScrolledSize({}, scrollheight);
|
|
|
|
this._contentScrollHeight = scrollheight.value;
|
|
|
|
}
|
|
|
|
|
|
|
|
let y = {};
|
|
|
|
this.scrollBoxObject.getPosition({}, y);
|
|
|
|
let scrollRatio = (y.value + this._childrenHeight) / this._contentScrollHeight;
|
|
|
|
|
|
|
|
// If we're scrolled 80% to the bottom of the list, append the next
|
|
|
|
// set of items
|
|
|
|
if (scrollRatio > 0.8)
|
|
|
|
this._insertItems();
|
|
|
|
]]>
|
|
|
|
</handler>
|
|
|
|
</handlers>
|
|
|
|
<implementation>
|
|
|
|
<!-- Number of elements to add to the list initially. If there are more
|
|
|
|
than this many elements to display, only add them to the list once
|
|
|
|
the user has scrolled towards them. This is a performance
|
|
|
|
optimization to avoid locking up while attempting to append hundreds
|
|
|
|
of nodes to our richlistbox.
|
|
|
|
-->
|
|
|
|
<property name="batchSize" readonly="true" onget="return this.getAttribute('batch')"/>
|
|
|
|
|
|
|
|
<field name="_childrenHeight">this.scrollBoxObject.height;</field>
|
|
|
|
<field name="_items">[]</field>
|
|
|
|
|
|
|
|
<method name="setItems">
|
|
|
|
<parameter name="aItems"/>
|
|
|
|
<body><![CDATA[
|
|
|
|
this._items = aItems;
|
|
|
|
this._insertItems();
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="_insertItems">
|
|
|
|
<body><![CDATA[
|
|
|
|
let items = this._items.splice(0, this.batchSize);
|
|
|
|
if (!items.length)
|
|
|
|
return; // no items to insert
|
|
|
|
|
|
|
|
let count = items.length;
|
|
|
|
for (let i = 0; i<count; i++)
|
|
|
|
this.appendChild(items[i]);
|
|
|
|
|
|
|
|
|
|
|
|
// make sure we recalculate the scrollHeight of the content
|
|
|
|
this._contentScrollHeight = -1;
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
</implementation>
|
|
|
|
</binding>
|
|
|
|
|
2009-09-11 06:26:42 -07:00
|
|
|
<binding id="richlistitem" extends="chrome://global/content/bindings/richlistbox.xml#richlistitem">
|
|
|
|
<handlers>
|
|
|
|
<handler event="mousedown" phase="capturing">
|
|
|
|
<![CDATA[
|
|
|
|
event.stopPropagation();
|
|
|
|
]]>
|
|
|
|
</handler>
|
|
|
|
</handlers>
|
|
|
|
</binding>
|
|
|
|
|
2010-07-19 07:51:03 -07:00
|
|
|
<binding id="content-navigator">
|
|
|
|
<content pack="end">
|
2010-07-21 16:35:47 -07:00
|
|
|
<children includes="vbox"/>
|
2010-07-30 12:03:03 -07:00
|
|
|
<xul:hbox class="content-navigator-box panel-dark" pack="end">
|
2010-07-21 16:35:47 -07:00
|
|
|
<children includes="textbox|arrowscrollbox"/>
|
2010-10-07 22:21:17 -07:00
|
|
|
<xul:toolbarbutton anonid="previous-button" class="content-navigator-item button-image previous-button" xbl:inherits="command=previous"/>
|
|
|
|
<xul:toolbarbutton anonid="next-button" class="content-navigator-item button-image next-button" xbl:inherits="command=next"/>
|
2010-07-19 07:51:03 -07:00
|
|
|
</xul:hbox>
|
|
|
|
</content>
|
|
|
|
|
|
|
|
<implementation>
|
|
|
|
<field name="_previousButton">
|
|
|
|
document.getAnonymousElementByAttribute(this, "anonid", "previous-button");
|
|
|
|
</field>
|
|
|
|
|
|
|
|
<field name="_nextButton">
|
|
|
|
document.getAnonymousElementByAttribute(this, "anonid", "next-button");
|
|
|
|
</field>
|
|
|
|
|
|
|
|
<field name="_spacer">
|
|
|
|
document.getElementById(this.getAttribute("spacer"));
|
|
|
|
</field>
|
|
|
|
|
|
|
|
<method name="contentHasChanged">
|
|
|
|
<body><![CDATA[
|
|
|
|
let height = Math.floor(this.getBoundingClientRect().height);
|
|
|
|
this.top = window.innerHeight - height;
|
|
|
|
this._spacer.setAttribute("height", height);
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
2010-09-28 16:19:00 -07:00
|
|
|
<property name="isActive" onget="return !this._spacer.hidden;"/>
|
|
|
|
|
2010-07-19 07:51:03 -07:00
|
|
|
<field name="_model">null</field>
|
|
|
|
<method name="show">
|
|
|
|
<parameter name="aModel" />
|
|
|
|
<body><![CDATA[
|
|
|
|
// call the hide callback of the current object if any
|
|
|
|
if (this._model && this._model.type != aModel.type)
|
|
|
|
this._model.hide();
|
|
|
|
|
|
|
|
this.setAttribute("type", aModel.type);
|
|
|
|
this.setAttribute("next", aModel.commands.next);
|
|
|
|
this.setAttribute("previous", aModel.commands.previous);
|
|
|
|
this.setAttribute("close", aModel.commands.close);
|
|
|
|
|
|
|
|
// buttons attributes sync with commands doesn not look updated when
|
|
|
|
// we dynamically switch the "command" attribute so we need to ensure
|
|
|
|
// the disabled state of the buttons is right when switching commands
|
|
|
|
this._previousButton.disabled = document.getElementById(aModel.commands.previous).disabled;
|
|
|
|
this._nextButton.disabled = document.getElementById(aModel.commands.next).disabled;
|
|
|
|
|
|
|
|
this._model = aModel;
|
|
|
|
this.contentHasChanged();
|
|
|
|
this._spacer.hidden = false;
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="hide">
|
|
|
|
<parameter name="aModel" />
|
|
|
|
<body><![CDATA[
|
|
|
|
this.removeAttribute("next");
|
|
|
|
this.removeAttribute("previous");
|
|
|
|
this.removeAttribute("close");
|
|
|
|
this.removeAttribute("type");
|
|
|
|
|
|
|
|
this._model = null;
|
2010-07-19 16:23:27 -07:00
|
|
|
this._spacer.hidden = true;
|
2010-07-19 07:51:03 -07:00
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
</implementation>
|
|
|
|
</binding>
|
|
|
|
|
2009-09-17 13:17:57 -07:00
|
|
|
<binding id="menulist" display="xul:box" extends="chrome://global/content/bindings/menulist.xml#menulist">
|
|
|
|
<handlers>
|
|
|
|
<handler event="mousedown" phase="capturing">
|
|
|
|
<![CDATA[
|
|
|
|
// Stop the normal menupopup from appearing
|
|
|
|
event.stopPropagation();
|
|
|
|
]]>
|
|
|
|
</handler>
|
|
|
|
|
|
|
|
<handler event="click" button="0">
|
|
|
|
<![CDATA[
|
|
|
|
if (this.disabled || this.itemCount == 0)
|
|
|
|
return;
|
2010-06-21 13:36:56 -07:00
|
|
|
|
2009-09-17 13:17:57 -07:00
|
|
|
this.focus();
|
2010-08-24 01:53:22 -07:00
|
|
|
MenuListHelperUI.show(this);
|
2009-09-17 13:17:57 -07:00
|
|
|
]]>
|
|
|
|
</handler>
|
2010-10-13 06:44:31 -07:00
|
|
|
|
|
|
|
<handler event="command" phase="capturing">
|
|
|
|
<![CDATA[
|
|
|
|
// The dropmark (button) fires a command event too. Don't forward that.
|
|
|
|
// Just forward the menuitem command events, which the toolkit version does.
|
|
|
|
if (event.target.parentNode.parentNode != this)
|
|
|
|
event.stopPropagation();
|
|
|
|
]]>
|
|
|
|
</handler>
|
2009-09-17 13:17:57 -07:00
|
|
|
</handlers>
|
|
|
|
</binding>
|
|
|
|
|
2009-06-24 09:42:53 -07:00
|
|
|
<binding id="chrome-select-option">
|
2009-07-06 10:14:46 -07:00
|
|
|
<content orient="horizontal" flex="1">
|
2010-07-30 11:20:48 -07:00
|
|
|
<xul:image class="chrome-select-option-image" anonid="check"/>
|
2009-06-24 09:42:53 -07:00
|
|
|
<xul:label anonid="label" xbl:inherits="value=label"/>
|
|
|
|
</content>
|
|
|
|
|
|
|
|
<implementation>
|
|
|
|
<property name="selected">
|
|
|
|
<getter>
|
|
|
|
<![CDATA[
|
|
|
|
return this.hasAttribute("selected");
|
|
|
|
]]>
|
|
|
|
</getter>
|
|
|
|
<setter>
|
|
|
|
<![CDATA[
|
|
|
|
if (val)
|
|
|
|
this.setAttribute("selected", "true");
|
|
|
|
else
|
|
|
|
this.removeAttribute("selected");
|
|
|
|
return val;
|
|
|
|
]]>
|
|
|
|
</setter>
|
|
|
|
</property>
|
|
|
|
</implementation>
|
|
|
|
</binding>
|
2010-04-13 15:41:17 -07:00
|
|
|
|
2010-06-11 07:19:25 -07:00
|
|
|
<binding id="select-button" extends="xul:box">
|
2010-04-13 15:41:17 -07:00
|
|
|
<content>
|
2010-09-15 16:54:57 -07:00
|
|
|
<svg:svg width="11px" version="1.1" xmlns="http://www.w3.org/2000/svg" style="position: absolute; top: -moz-calc(50% - 2px); left: 4px;">
|
2010-04-13 15:41:17 -07:00
|
|
|
<svg:polyline points="1 1 5 6 9 1" stroke="#414141" stroke-width="2" stroke-linecap="round" fill="transparent" stroke-linejoin="round"/>
|
|
|
|
</svg:svg>
|
|
|
|
</content>
|
|
|
|
</binding>
|
2008-07-16 08:41:38 -07:00
|
|
|
</bindings>
|