1 # ***** BEGIN LICENSE BLOCK *****
2 # Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 # The contents of this file are subject to the Mozilla Public License Version
5 # 1.1 (the "License"); you may not use this file except in compliance with
6 # the License. You may obtain a copy of the License at
7 # http://www.mozilla.org/MPL/
9 # Software distributed under the License is distributed on an "AS IS" basis,
10 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 # for the specific language governing rights and limitations under the
14 # The Original Code is the Places Browser Integration
16 # The Initial Developer of the Original Code is Google Inc.
17 # Portions created by the Initial Developer are Copyright (C) 2006
18 # the Initial Developer. All Rights Reserved.
21 # Ben Goodger <beng@google.com>
22 # Annie Sullivan <annie.sullivan@gmail.com>
23 # Joe Hughes <joe@retrovirus.com>
24 # Asaf Romano <mano@mozilla.com>
25 # Ehsan Akhgari <ehsan.akhgari@gmail.com>
27 # Alternatively, the contents of this file may be used under the terms of
28 # either the GNU General Public License Version 2 or later (the "GPL"), or
29 # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
30 # in which case the provisions of the GPL or the LGPL are applicable instead
31 # of those above. If you wish to allow use of your version of this file only
32 # under the terms of either the GPL or the LGPL, and not to allow others to
33 # use your version of this file under the terms of the MPL, indicate your
34 # decision by deleting the provisions above and replace them with the notice
35 # and other provisions required by the GPL or the LGPL. If you do not delete
36 # the provisions above, a recipient may use your version of this file under
37 # the terms of any one of the MPL, the GPL or the LGPL.
39 # ***** END LICENSE BLOCK *****
49 if (aIID.equals(
Ci.nsIDOMEventListener) ||
50 aIID.equals(
Ci.nsISupports))
53 throw Cr.NS_NOINTERFACE;
56 _element:
function(aID) {
57 return document.getElementById(aID);
63 var
element = this._element(
"editBookmarkPanel");
66 element.hidden =
false;
67 element.addEventListener(
"popuphidden",
this,
false);
68 element.addEventListener(
"keypress",
this,
false);
73 _blockedCommands: [
"cmd_close",
"cmd_closeWindow"],
74 _blockCommands:
function SU__blockCommands() {
75 for each(var
key in this._blockedCommands) {
76 var elt = this._element(key);
78 if (elt.hasAttribute(
"wasDisabled"))
80 if (elt.getAttribute(
"disabled") ==
"true")
81 elt.setAttribute(
"wasDisabled",
"true");
83 elt.setAttribute(
"wasDisabled",
"false");
84 elt.setAttribute(
"disabled",
"true");
89 _restoreCommandsState:
function SU__restoreCommandsState() {
90 for each(var key
in this._blockedCommands) {
91 var elt = this._element(key);
92 if (elt.getAttribute(
"wasDisabled") !=
"true")
93 elt.removeAttribute(
"disabled");
94 elt.removeAttribute(
"wasDisabled");
99 handleEvent:
function SU_handleEvent(aEvent) {
100 switch (aEvent.type) {
102 if (aEvent.originalTarget ==
this.panel) {
103 if (!this._element(
"editBookmarkPanelContent").
hidden)
105 this._restoreCommandsState();
108 if (this._batching) {
110 this._batching =
false;
115 if (aEvent.getPreventDefault()) {
119 switch (aEvent.keyCode) {
120 case KeyEvent.DOM_VK_ESCAPE:
121 if (!this._element(
"editBookmarkPanelContent").hidden)
122 this.cancelButtonOnCommand();
124 case KeyEvent.DOM_VK_RETURN:
125 if (aEvent.target.className ==
"expander-up" ||
126 aEvent.target.className ==
"expander-down" ||
127 aEvent.target.id ==
"editBMPanel_newFolderButton") {
132 this.panel.hidePopup();
139 _overlayLoaded:
false,
141 showEditBookmarkPopup:
142 function SU_showEditBookmarkPopup(aItemId, aAnchorElement, aPosition) {
148 if (this._overlayLoaded) {
149 this._doShowEditBookmarkPanel(aItemId, aAnchorElement, aPosition);
156 _anchorElement: aAnchorElement,
157 _position: aPosition,
159 this._self._overlayLoading =
false;
160 this._self._overlayLoaded =
true;
161 this._self._doShowEditBookmarkPanel(this._itemId, this._anchorElement,
166 document.loadOverlay(
"chrome://browser/content/places/editBookmarkOverlay.xul",
170 _doShowEditBookmarkPanel:
171 function SU__doShowEditBookmarkPanel(aItemId, aAnchorElement, aPosition) {
172 if (this.panel.state !=
"closed")
175 this._blockCommands();
179 var rows = this._element(
"editBookmarkPanelGrid").lastChild;
180 var
header = this._element(
"editBookmarkPanelHeader");
181 rows.insertBefore(header, rows.firstChild);
182 header.hidden =
false;
188 this._element(
"editBookmarkPanelTitle").value =
195 this._element(
"editBookmarkPanelDescription").textContent =
"";
196 this._element(
"editBookmarkPanelBottomButtons").hidden =
false;
197 this._element(
"editBookmarkPanelContent").hidden =
false;
198 this._element(
"editBookmarkPanelEditButton").hidden =
true;
199 this._element(
"editBookmarkPanelUndoRemoveButton").hidden =
true;
203 this._element(
"editBookmarkPanelRemoveButton").hidden = this._batching;
207 var bookmarks = PlacesUtils.getBookmarksForURI(gBrowser.currentURI);
208 var forms =
gNavigatorBundle.getString(
"editBookmark.removeBookmarks.label");
209 var
label = PluralForm.get(bookmarks.length, forms).replace(
"#1", bookmarks.length);
210 this._element(
"editBookmarkPanelRemoveButton").label =
label;
213 this._element(
"editBookmarkPanelStarIcon").removeAttribute(
"unstarred");
215 this._itemId = aItemId !== undefined ? aItemId : this._itemId;
219 this.panel.popupBoxObject
220 .setConsumeRollupEvent(
Ci.nsIPopupBoxObject.ROLLUP_CONSUME);
221 this.panel.openPopup(aAnchorElement, aPosition, -1, -1);
224 { hiddenRows: [
"description",
"location",
225 "loadInSidebar",
"keyword"] });
229 function SU_panelShown(aEvent) {
230 if (aEvent.target ==
this.panel) {
231 if (!this._element(
"editBookmarkPanelContent").
hidden) {
232 fieldToFocus =
"editBMPanel_" +
233 gPrefService.getCharPref(
"browser.bookmarks.editDialog.firstEditField");
234 var elt = this._element(fieldToFocus);
246 showPageBookmarkedNotification:
247 function PCH_showPageBookmarkedNotification(aItemId, aAnchorElement, aPosition) {
248 this._blockCommands();
251 var brandShortName = brandBundle.getString(
"brandShortName");
254 this._element(
"editBookmarkPanelTitle").value =
258 this._element(
"editBookmarkPanelDescription").textContent =
259 gNavigatorBundle.getFormattedString(
"editBookmarkPanel.pageBookmarkedDescription",
264 this._element(
"editBookmarkPanelEditButton").hidden =
false;
265 this._element(
"editBookmarkPanelRemoveButton").hidden =
false;
266 this._element(
"editBookmarkPanelUndoRemoveButton").hidden =
true;
269 this._element(
"editBookmarkPanelStarIcon").removeAttribute(
"unstarred");
271 this._itemId = aItemId !== undefined ? aItemId : this._itemId;
272 if (this.panel.state ==
"closed") {
274 this.panel.popupBoxObject
275 .setConsumeRollupEvent(
Ci.nsIPopupBoxObject.ROLLUP_CONSUME);
276 this.panel.openPopup(aAnchorElement, aPosition, -1, -1);
282 quitEditMode:
function SU_quitEditMode() {
283 this._element(
"editBookmarkPanelContent").hidden =
true;
284 this._element(
"editBookmarkPanelBottomButtons").hidden =
true;
288 editButtonCommand:
function SU_editButtonCommand() {
289 this.showEditBookmarkPopup();
292 cancelButtonOnCommand:
function SU_cancelButtonOnCommand() {
296 this.panel.hidePopup();
301 removeBookmarkButtonCommand:
function SU_removeBookmarkButtonCommand() {
302 #ifdef ADVANCED_STARRING_UI
307 if (this._batching) {
313 this._element(
"editBookmarkPanelTitle").value =
321 this._element(
"editBookmarkPanelUndoRemoveButton").hidden =
false;
322 this._element(
"editBookmarkPanelRemoveButton").hidden =
true;
323 this._element(
"editBookmarkPanelStarIcon").setAttribute(
"unstarred",
"true");
329 this._uri = PlacesUtils.bookmarks.getBookmarkURI(this._itemId);
333 var itemIds = PlacesUtils.getBookmarksForURI(this._uri);
334 for (var
i=0;
i < itemIds.length;
i++) {
339 #ifdef ADVANCED_STARRING_UI
344 this.panel.hidePopup();
347 undoRemoveBookmarkCommand:
function SU_undoRemoveBookmarkCommand() {
352 this._itemId = PlacesUtils.getMostRecentBookmarkForURI(this._uri);
353 this.showEditBookmarkPopup();
356 beginBatch:
function SU_beginBatch() {
357 if (!this._batching) {
359 this._batching =
true;
363 endBatch:
function SU_endBatch() {
364 if (this._batching) {
366 this._batching =
false;
371 var PlacesCommandHook = {
383 bookmarkPage:
function PCH_bookmarkPage(
aBrowser, aParent, aShowEditUI) {
385 var itemId = PlacesUtils.getMostRecentBookmarkForURI(uri);
393 var webNav =
aBrowser.webNavigation;
394 var
url = webNav.currentURI;
399 title = webNav.document.title || url.spec;
400 description =
PlacesUIUtils.getDescriptionFromDocument(webNav.document);
401 charset = webNav.document.characterSet;
412 var parent = aParent != undefined ?
413 aParent : PlacesUtils.unfiledBookmarksFolderId;
416 title,
null, [descAnno]);
420 PlacesUtils.history.setCharsetForURI(uri, charset);
421 itemId = PlacesUtils.getMostRecentBookmarkForURI(uri);
426 gURLBar.handleRevert();
431 var starIcon =
aBrowser.ownerDocument.getElementById(
"star-button");
435 var
position = (getComputedStyle(gNavToolbox,
"").direction ==
"rtl") ?
'after_start' :
'after_end';
437 StarUI.showEditBookmarkPopup(itemId, starIcon, position);
438 #ifdef ADVANCED_STARRING_UI
440 StarUI.showPageBookmarkedNotification(itemId, starIcon, position);
452 bookmarkCurrentPage:
function PCH_bookmarkCurrentPage(aShowEditUI, aParent) {
453 this.bookmarkPage(
getBrowser().selectedBrowser, aParent, aShowEditUI);
466 bookmarkLink:
function PCH_bookmarkLink(aParent, aURL, aTitle) {
468 var itemId = PlacesUtils.getMostRecentBookmarkForURI(linkURI);
473 PlacesUtils.bookmarks.TYPE_BOOKMARK);
485 _getUniqueTabInfo:
function BATC__getUniqueTabInfo() {
490 for (var
i = 0;
i < browsers.length; ++
i) {
491 var webNav = browsers[
i].webNavigation;
492 var uri = webNav.currentURI;
495 if (uri.spec in seenURIs)
499 seenURIs[uri.spec] =
true;
509 bookmarkCurrentPages:
function PCH_bookmarkCurrentPages() {
510 var tabURIs = this._getUniqueTabInfo();
527 var
doc = gBrowser.contentDocument;
538 PlacesUIUtils.showMinimalAddLivemarkUI(feedURI, gBrowser.currentURI,
539 title, description, toolbarIP,
true);
549 showPlacesOrganizer:
function PCH_showPlacesOrganizer(aLeftPaneRoot) {
550 var
wm =
Cc[
"@mozilla.org/appshell/window-mediator;1"].
552 var organizer = wm.getMostRecentWindow(
"Places:Organizer");
555 openDialog(
"chrome://browser/content/places/places.xul",
556 "",
"chrome,toolbar=yes,dialog=no,resizable", aLeftPaneRoot);
559 organizer.PlacesOrganizer.selectLeftPaneQuery(aLeftPaneRoot);
564 deleteButtonOnCommand:
function PCH_deleteButtonCommand() {
570 this.panel.hidePopup();
578 return this._ss =
Cc[
"@mozilla.org/browser/sessionstore;1"].
582 toggleRecentlyClosedTabs:
function PHM_toggleRecentlyClosedTabs() {
584 var undoPopup = document.getElementById(
"historyUndoPopup");
587 if (this._ss.getClosedTabCount(
window) == 0)
588 undoPopup.parentNode.setAttribute(
"disabled",
true);
590 undoPopup.parentNode.removeAttribute(
"disabled");
599 _undoCloseMiddleClick:
function PHM__undoCloseMiddleClick(aEvent) {
600 if (aEvent.button != 1)
604 gBrowser.moveTabToEnd();
610 populateUndoSubmenu:
function PHM_populateUndoSubmenu() {
611 var undoPopup = document.getElementById(
"historyUndoPopup");
614 while (undoPopup.hasChildNodes())
615 undoPopup.removeChild(undoPopup.firstChild);
618 if (this._ss.getClosedTabCount(
window) == 0) {
619 undoPopup.parentNode.setAttribute(
"disabled",
true);
624 undoPopup.parentNode.removeAttribute(
"disabled");
627 var undoItems = eval(
"(" + this._ss.getClosedTabData(
window) +
")");
628 for (var
i = 0;
i < undoItems.length;
i++) {
629 var m = document.createElement(
"menuitem");
630 m.setAttribute(
"label", undoItems[
i].title);
631 if (undoItems[
i].image) {
632 let iconURL = undoItems[
i].image;
634 if (/^https?:/.
test(iconURL))
635 iconURL =
"moz-anno:favicon:" + iconURL;
636 m.setAttribute(
"image", iconURL);
638 m.setAttribute(
"class",
"menuitem-iconic bookmark-item");
639 m.setAttribute(
"value",
i);
640 m.setAttribute(
"oncommand",
"undoCloseTab(" +
i +
");");
641 m.addEventListener(
"click", this._undoCloseMiddleClick,
false);
643 m.setAttribute(
"key",
"key_undoCloseTab");
644 undoPopup.appendChild(m);
649 undoPopup.appendChild(document.createElement(
"menuseparator"));
650 m = undoPopup.appendChild(document.createElement(
"menuitem"));
651 m.id =
"menu_restoreAllTabs";
652 m.setAttribute(
"label", strings.getString(
"menuRestoreAllTabs.label"));
653 m.setAttribute(
"accesskey", strings.getString(
"menuRestoreAllTabs.accesskey"));
654 m.addEventListener(
"command",
function() {
655 for (var
i = 0;
i < undoItems.length;
i++)
660 toggleRecentlyClosedWindows:
function PHM_toggleRecentlyClosedWindows() {
662 let undoPopup = document.getElementById(
"historyUndoWindowPopup");
665 if (this._ss.getClosedWindowCount() == 0)
666 undoPopup.parentNode.setAttribute(
"disabled",
true);
668 undoPopup.parentNode.removeAttribute(
"disabled");
674 populateUndoWindowSubmenu:
function PHM_populateUndoWindowSubmenu() {
675 let undoPopup = document.getElementById(
"historyUndoWindowPopup");
676 let menuLabelString =
gNavigatorBundle.getString(
"menuUndoCloseWindowLabel");
677 let menuLabelStringSingleTab =
681 while (undoPopup.hasChildNodes())
682 undoPopup.removeChild(undoPopup.firstChild);
685 if (this._ss.getClosedWindowCount() == 0) {
686 undoPopup.parentNode.setAttribute(
"disabled",
true);
691 undoPopup.parentNode.removeAttribute(
"disabled");
694 let undoItems =
JSON.parse(this._ss.getClosedWindowData());
695 for (let
i = 0;
i < undoItems.length;
i++) {
696 let undoItem = undoItems[
i];
697 let otherTabsCount = undoItem.tabs.length - 1;
698 let
label = (otherTabsCount == 0) ? menuLabelStringSingleTab
699 : PluralForm.get(otherTabsCount, menuLabelString);
700 let menuLabel = label.replace(
"#1", undoItem.title)
701 .replace(
"#2", otherTabsCount);
702 let m = document.createElement(
"menuitem");
703 m.setAttribute(
"label", menuLabel);
704 let selectedTab = undoItem.tabs[undoItem.selected - 1];
705 if (selectedTab.attributes.image) {
706 let iconURL = selectedTab.attributes.image;
708 if (/^https?:/.
test(iconURL))
709 iconURL =
"moz-anno:favicon:" + iconURL;
710 m.setAttribute(
"image", iconURL);
712 m.setAttribute(
"class",
"menuitem-iconic bookmark-item");
713 m.setAttribute(
"oncommand",
"undoCloseWindow(" +
i +
");");
715 m.setAttribute(
"key",
"key_undoCloseWindow");
716 undoPopup.appendChild(m);
720 undoPopup.appendChild(document.createElement(
"menuseparator"));
721 let m = undoPopup.appendChild(document.createElement(
"menuitem"));
722 m.id =
"menu_restoreAllWindows";
723 m.setAttribute(
"label",
gNavigatorBundle.getString(
"menuRestoreAllWindows.label"));
724 m.setAttribute(
"accesskey",
gNavigatorBundle.getString(
"menuRestoreAllWindows.accesskey"));
725 m.setAttribute(
"oncommand",
726 "for (var i = 0; i < " + undoItems.length +
"; i++) undoCloseWindow();");
734 onPopupShowing:
function PHM_onPopupShowing(aEvent) {
736 if (aEvent.target != aEvent.currentTarget)
739 var menuPopup = aEvent.target;
740 var resultNode = menuPopup.getResultNode();
741 resultNode.containerOpen =
true;
742 document.getElementById(
"endHistorySeparator").hidden =
743 resultNode.childCount == 0;
745 this.toggleRecentlyClosedTabs();
746 this.toggleRecentlyClosedWindows();
754 onPopupHidden:
function PHM_onPopupHidden(aEvent) {
756 if (aEvent.target != aEvent.currentTarget)
759 var menuPopup = aEvent.target;
760 var resultNode = menuPopup.getResultNode();
761 if (resultNode.containerOpen)
762 resultNode.containerOpen =
false;
779 onClick:
function BT_onClick(aEvent) {
782 var modifKey = aEvent.metaKey || aEvent.shiftKey;
784 var modifKey = aEvent.ctrlKey || aEvent.shiftKey;
786 if (aEvent.button == 2 || (aEvent.button == 0 && !modifKey))
789 var
target = aEvent.originalTarget;
792 if (target.localName ==
"menu" || target.localName ==
"menuitem") {
794 if (
node.localName ==
"menupopup")
796 else if (
node.localName !=
"menu")
801 if (target.node && PlacesUtils.nodeIsContainer(target.node)) {
805 if (target.localName ==
"menu" || target.localName ==
"toolbarbutton")
808 else if (aEvent.button == 1) {
810 this.onCommand(aEvent);
821 onCommand:
function BM_onCommand(aEvent) {
822 var
target = aEvent.originalTarget;
834 onPopupShowing:
function BM_onPopupShowing(
event) {
835 var
target =
event.originalTarget;
836 if (!target.hasAttribute(
"placespopup"))
841 var hasMultipleURIs =
false;
842 var currentChild = target.firstChild;
843 while (currentChild) {
844 if (currentChild.localName ==
"menuitem" && currentChild.node) {
845 if (++numNodes == 2) {
846 hasMultipleURIs =
true;
850 currentChild = currentChild.nextSibling;
853 var itemId = target._resultNode.itemId;
854 var siteURIString =
"";
855 if (itemId != -1 && PlacesUtils.itemIsLivemark(itemId)) {
856 var siteURI = PlacesUtils.livemarks.getSiteURI(itemId);
858 siteURIString = siteURI.spec;
861 if (!siteURIString && target._endOptOpenSiteURI) {
862 target.removeChild(target._endOptOpenSiteURI);
863 target._endOptOpenSiteURI =
null;
866 if (!hasMultipleURIs && target._endOptOpenAllInTabs) {
867 target.removeChild(target._endOptOpenAllInTabs);
868 target._endOptOpenAllInTabs =
null;
871 if (!(hasMultipleURIs || siteURIString)) {
873 if (target._endOptSeparator) {
874 target.removeChild(target._endOptSeparator);
875 target._endOptSeparator =
null;
876 target._endMarker = -1;
881 if (!target._endOptSeparator) {
883 target._endOptSeparator = document.createElement(
"menuseparator");
884 target._endOptSeparator.className =
"bookmarks-actions-menuseparator";
885 target._endMarker = target.childNodes.length;
886 target.appendChild(target._endOptSeparator);
889 if (siteURIString && !target._endOptOpenSiteURI) {
891 target._endOptOpenSiteURI = document.createElement(
"menuitem");
892 target._endOptOpenSiteURI.className =
"openlivemarksite-menuitem";
893 target._endOptOpenSiteURI.setAttribute(
"siteURI", siteURIString);
894 target._endOptOpenSiteURI.setAttribute(
"oncommand",
895 "openUILink(this.getAttribute('siteURI'), event);");
900 target._endOptOpenSiteURI.setAttribute(
"onclick",
901 "checkForMiddleClick(this, event); event.stopPropagation();");
902 target._endOptOpenSiteURI.setAttribute(
"label",
903 PlacesUIUtils.getFormattedString(
"menuOpenLivemarkOrigin.label",
904 [target.parentNode.getAttribute(
"label")]));
905 target.appendChild(target._endOptOpenSiteURI);
908 if (hasMultipleURIs && !target._endOptOpenAllInTabs) {
911 target._endOptOpenAllInTabs = document.createElement(
"menuitem");
912 target._endOptOpenAllInTabs.className =
"openintabs-menuitem";
913 target._endOptOpenAllInTabs.setAttribute(
"oncommand",
914 "PlacesUIUtils.openContainerNodeInTabs(this.parentNode._resultNode, event);");
915 target._endOptOpenAllInTabs.setAttribute(
"onclick",
916 "checkForMiddleClick(this, event); event.stopPropagation();");
917 target._endOptOpenAllInTabs.setAttribute(
"label",
919 target.appendChild(target._endOptOpenAllInTabs);
923 fillInBHTooltip:
function(
aDocument, aEvent) {
927 if (
aDocument.tooltipNode.localName ==
"treechildren") {
928 var tree =
aDocument.tooltipNode.parentNode;
929 var row = {}, column = {};
930 var tbo = tree.treeBoxObject;
931 tbo.getCellAt(aEvent.clientX, aEvent.clientY, row, column, {});
934 node = tree.view.nodeForTreeIndex(row.value);
935 cropped = tbo.isCellCropped(row.value, column.value);
943 var title =
node.title;
947 if (PlacesUtils.nodeIsURI(
node))
951 if (!cropped && !url)
954 var tooltipTitle =
aDocument.getElementById(
"bhtTitleText");
955 tooltipTitle.hidden = (!title || (title ==
url));
956 if (!tooltipTitle.hidden)
957 tooltipTitle.textContent = title;
959 var tooltipUrl =
aDocument.getElementById(
"bhtUrlText");
960 tooltipUrl.hidden = !
url;
961 if (!tooltipUrl.hidden)
962 tooltipUrl.value =
url;
981 event.dataTransfer.effectAllowed =
"none";
989 getSupportedFlavours:
function BMDH_getSupportedFlavours() {
990 var view = document.getElementById(
"bookmarksMenuPopup");
991 return view.getSupportedFlavours();
1006 var ip =
new InsertionPoint(PlacesUtils.bookmarksMenuFolderId, -1);
1023 var ip =
new InsertionPoint(PlacesUtils.bookmarksMenuFolderId, -1,
1024 Ci.nsITreeView.DROP_ON);
1043 _springLoadDelay: 350,
1055 onBookmarksMenuDragEnter:
function PMDC_onDragEnter(
event) {
1056 if (
"loadTime" in this._timers)
1059 this._setDragTimer(
"loadTime", this._openBookmarksMenu,
1060 this._springLoadDelay, [
event]);
1074 _setDragTimer:
function PMDC__setDragTimer(
id,
callback, delay,
args) {
1075 if (!this._dragSupported)
1079 if (
id in this._timers)
1080 this._timers[
id].cancel();
1086 function Callback(
object, method,
args) {
1087 this._method = method;
1091 Callback.prototype = {
1092 notify:
function C_notify(timer) {
1093 this._method.apply(this._object, this._args);
1097 var timer =
Cc[
"@mozilla.org/timer;1"].createInstance(
Ci.nsITimer);
1098 timer.initWithCallback(
new Callback(
this,
callback,
args), delay,
1099 timer.TYPE_ONE_SHOT);
1100 this._timers[
id] = timer;
1108 _isContainer:
function PMDC__isContainer(
node) {
1109 return node.localName ==
"menu" ||
1110 (
node.localName ==
"toolbarbutton" &&
1111 node.getAttribute(
"type") ==
"menu");
1121 _openBookmarksMenu:
function PMDC__openBookmarksMenu(
event) {
1122 if (
"loadTime" in this._timers)
1123 delete this._timers.loadTime;
1124 if (
event.target.id ==
"bookmarksMenu") {
1126 event.target.lastChild.setAttribute(
"autoopened",
"true");
1127 event.target.lastChild.showPopup(
event.target.lastChild);
1134 _dragSupported:
false
1136 _dragSupported:
true
1141 init:
function PSB_init() {
1143 PlacesUtils.bookmarks.addObserver(
this,
false);
1145 Components.utils.reportError(
"PlacesStarButton.init(): error adding bookmark observer: " + ex);
1149 uninit:
function PSB_uninit() {
1150 PlacesUtils.bookmarks.removeObserver(
this);
1154 if (aIID.equals(
Ci.nsINavBookmarkObserver) ||
1155 aIID.equals(
Ci.nsISupports))
1158 throw Cr.NS_NOINTERFACE;
1164 updateState:
function PSB_updateState() {
1165 var starIcon = document.getElementById(
"star-button");
1170 this._starred = uri && (PlacesUtils.getMostRecentBookmarkForURI(uri) != -1 ||
1171 PlacesUtils.getMostRecentFolderForFeedURI(uri) != -1);
1172 if (this._starred) {
1173 starIcon.setAttribute(
"starred",
"true");
1174 starIcon.setAttribute(
"tooltiptext",
gNavigatorBundle.getString(
"starButtonOn.tooltip"));
1177 starIcon.removeAttribute(
"starred");
1178 starIcon.setAttribute(
"tooltiptext",
gNavigatorBundle.getString(
"starButtonOff.tooltip"));
1182 onClick:
function PSB_onClick(aEvent) {
1183 if (aEvent.button == 0)
1184 PlacesCommandHook.bookmarkCurrentPage(this._starred);
1187 aEvent.stopPropagation();
1192 this._batching =
true;
1197 this._batching =
false;
1200 onItemAdded:
function PSB_onItemAdded(aItemId, aFolder, aIndex, aItemType) {
1201 if (!this._batching && !this._starred)
1205 onBeforeItemRemoved:
function() {},
1207 onItemRemoved:
function PSB_onItemRemoved(aItemId, aFolder, aIndex,
1209 if (!this._batching)
1213 onItemChanged:
function PSB_onItemChanged(aItemId, aProperty,
1214 aIsAnnotationProperty, aNewValue,
1215 aLastModified, aItemType) {
1216 if (!this._batching && aProperty ==
"uri")
1220 onItemVisited:
function() { },
1221 onItemMoved:
function() { }
var PlacesMenuDNDController
var BookmarksEventHandler
var BookmarksMenuDropHandler
onPageChanged onEndUpdateBatch
function doc() browser.contentDocument
dndDefaultHandler_module onDragOver
sbOSDControlService prototype QueryInterface
function getBrowser() gBrowser
getService(Ci.sbIFaceplateManager)
TimerLoop prototype notify
this _contentSandbox label
_collectFormDataForFrame aDocument
function makeURI(aURLSpec, aCharset)
function isElementVisible(aElement)
onPageChanged onBeginUpdateBatch
return!aWindow arguments!aWindow arguments[0]
_updateTextAndScrollDataForTab aBrowser
var PlacesControllerDragHelper
function InsertionPoint(aItemId, aIndex, aOrientation, aIsTag, aDropNearItemId)
_getSelectedPageStyle s i
_updateTextAndScrollDataForFrame aData
sbDeviceFirmwareAutoCheckForUpdate prototype observe
function undoCloseTab(aIndex)