2011-01-08 07:03:27 -08:00
|
|
|
var BookmarkPopup = {
|
|
|
|
get box() {
|
|
|
|
delete this.box;
|
|
|
|
this.box = document.getElementById("bookmark-popup");
|
|
|
|
|
|
|
|
// Hide the popup if there is any new page loading
|
|
|
|
let self = this;
|
|
|
|
messageManager.addMessageListener("pagehide", function(aMessage) {
|
|
|
|
self.hide();
|
|
|
|
});
|
|
|
|
return this.box;
|
|
|
|
},
|
|
|
|
|
|
|
|
hide : function hide() {
|
|
|
|
this.box.hidden = true;
|
|
|
|
BrowserUI.popPopup(this);
|
|
|
|
},
|
|
|
|
|
|
|
|
show : function show() {
|
2011-08-05 16:01:33 -07:00
|
|
|
// Set the box position.
|
|
|
|
let button = document.getElementById("tool-star");
|
2011-09-02 10:16:48 -07:00
|
|
|
let anchorPosition = "";
|
2011-08-05 16:01:33 -07:00
|
|
|
if (getComputedStyle(button).visibility == "visible") {
|
|
|
|
let [tabsSidebar, controlsSidebar] = [Elements.tabs.getBoundingClientRect(), Elements.controls.getBoundingClientRect()];
|
|
|
|
this.box.setAttribute(tabsSidebar.left < controlsSidebar.left ? "right" : "left", controlsSidebar.width - this.box.offset);
|
|
|
|
this.box.top = button.getBoundingClientRect().top - this.box.offset;
|
|
|
|
} else {
|
|
|
|
button = document.getElementById("tool-star2");
|
2011-09-02 10:16:48 -07:00
|
|
|
anchorPosition = "after_start";
|
2011-08-05 16:01:33 -07:00
|
|
|
}
|
|
|
|
|
2011-01-08 07:03:27 -08:00
|
|
|
this.box.hidden = false;
|
2011-09-02 10:16:48 -07:00
|
|
|
this.box.anchorTo(button, anchorPosition);
|
2011-01-08 07:03:27 -08:00
|
|
|
|
2011-08-05 16:01:33 -07:00
|
|
|
// include the star button here, so that click-to-dismiss works as expected
|
|
|
|
BrowserUI.pushPopup(this, [this.box, button]);
|
2011-01-08 07:03:27 -08:00
|
|
|
},
|
|
|
|
|
|
|
|
toggle : function toggle() {
|
|
|
|
if (this.box.hidden)
|
|
|
|
this.show();
|
|
|
|
else
|
|
|
|
this.hide();
|
2011-08-09 18:32:22 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
addToHome: function addToHome() {
|
|
|
|
this.hide();
|
|
|
|
|
|
|
|
let browser = getBrowser();
|
2011-09-26 17:32:10 -07:00
|
|
|
Util.createShortcut(browser.contentTitle, browser.currentURI.spec, browser.mIconURL, "bookmark");
|
2011-01-08 07:03:27 -08:00
|
|
|
}
|
|
|
|
};
|