|
|
@ -1090,9 +1090,9 @@ var httpObserver = {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var result = vAPI.tabs.onPopup({
|
|
|
|
var result = vAPI.tabs.onPopup({
|
|
|
|
tabId: tabId,
|
|
|
|
targetTabId: tabId,
|
|
|
|
sourceTabId: sourceTabId,
|
|
|
|
openerTabId: sourceTabId,
|
|
|
|
url: URI.asciiSpec
|
|
|
|
targetURL: URI.asciiSpec
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return result === true;
|
|
|
|
return result === true;
|
|
|
@ -1403,7 +1403,7 @@ if (vAPI.fennec) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return label;
|
|
|
|
return label;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
vAPI.toolbarButton.init = function() {
|
|
|
|
vAPI.toolbarButton.init = function() {
|
|
|
|
// Only actually expecting one window under Fennec (note, not tabs, windows)
|
|
|
|
// Only actually expecting one window under Fennec (note, not tabs, windows)
|
|
|
@ -1412,7 +1412,7 @@ if (vAPI.fennec) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
cleanupTasks.push(this.cleanUp);
|
|
|
|
cleanupTasks.push(this.cleanUp);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
vAPI.toolbarButton.addToWindow = function(win, label) {
|
|
|
|
vAPI.toolbarButton.addToWindow = function(win, label) {
|
|
|
|
var id = win.NativeWindow.menu.add({
|
|
|
|
var id = win.NativeWindow.menu.add({
|
|
|
@ -1420,13 +1420,7 @@ if (vAPI.fennec) {
|
|
|
|
callback: this.onClick
|
|
|
|
callback: this.onClick
|
|
|
|
});
|
|
|
|
});
|
|
|
|
this.menuItemIds.set(win, id);
|
|
|
|
this.menuItemIds.set(win, id);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
vAPI.toolbarButton.cleanUp = function() {
|
|
|
|
|
|
|
|
for (var win of vAPI.tabs.getWindows()) {
|
|
|
|
|
|
|
|
vAPI.toolbarButton.removeFromWindow(win);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vAPI.toolbarButton.removeFromWindow = function(win) {
|
|
|
|
vAPI.toolbarButton.removeFromWindow = function(win) {
|
|
|
|
var id = this.menuItemIds.get(win);
|
|
|
|
var id = this.menuItemIds.get(win);
|
|
|
@ -1434,27 +1428,24 @@ if (vAPI.fennec) {
|
|
|
|
win.NativeWindow.menu.remove(id);
|
|
|
|
win.NativeWindow.menu.remove(id);
|
|
|
|
this.menuItemIds.delete(win);
|
|
|
|
this.menuItemIds.delete(win);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
vAPI.toolbarButton.updateState = function (win, tabId) {
|
|
|
|
vAPI.toolbarButton.updateState = function(win, tabId) {
|
|
|
|
var id = this.menuItemIds.get(win);
|
|
|
|
var id = this.menuItemIds.get(win);
|
|
|
|
if (!id) {
|
|
|
|
if (!id) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
win.NativeWindow.menu.update(id, { name: this.getMenuItemLabel(tabId) });
|
|
|
|
win.NativeWindow.menu.update(id, { name: this.getMenuItemLabel(tabId) });
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
vAPI.toolbarButton.onClick = function() {
|
|
|
|
vAPI.toolbarButton.onClick = function() {
|
|
|
|
var win = Services.wm.getMostRecentWindow('navigator:browser');
|
|
|
|
var win = Services.wm.getMostRecentWindow('navigator:browser');
|
|
|
|
var curTabId = vAPI.tabs.getTabId(getTabBrowser(win).selectedTab);
|
|
|
|
var curTabId = vAPI.tabs.getTabId(getTabBrowser(win).selectedTab);
|
|
|
|
vAPI.tabs.open({ url: vAPI.getURL("popup.html?tabId=" + curTabId), index: -1, select: true });
|
|
|
|
vAPI.tabs.open({ url: "popup.html?tabId=" + curTabId, index: -1, select: true });
|
|
|
|
}
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// Toolbar button UI
|
|
|
|
// Toolbar button UI
|
|
|
|
|
|
|
|
vAPI.toolbarButton.init = function() {
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vAPI.toolbarButton.init = function() {
|
|
|
|
|
|
|
|
var CustomizableUI;
|
|
|
|
var CustomizableUI;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
CustomizableUI = Cu.import('resource:///modules/CustomizableUI.jsm', null).CustomizableUI;
|
|
|
|
CustomizableUI = Cu.import('resource:///modules/CustomizableUI.jsm', null).CustomizableUI;
|
|
|
@ -1495,7 +1486,7 @@ if (vAPI.fennec) {
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
this.CUIEvents = {};
|
|
|
|
this.CUIEvents = {};
|
|
|
|
|
|
|
|
|
|
|
|
this.CUIEvents.onCustomizeEnd = function() {
|
|
|
|
var updateBadge = function() {
|
|
|
|
var wId = vAPI.toolbarButton.id;
|
|
|
|
var wId = vAPI.toolbarButton.id;
|
|
|
|
var buttonInPanel = CustomizableUI.getWidget(wId).areaType === CustomizableUI.TYPE_MENU_PANEL;
|
|
|
|
var buttonInPanel = CustomizableUI.getWidget(wId).areaType === CustomizableUI.TYPE_MENU_PANEL;
|
|
|
|
|
|
|
|
|
|
|
@ -1516,9 +1507,12 @@ if (vAPI.fennec) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Anonymous elements need some time to be reachable
|
|
|
|
// Anonymous elements need some time to be reachable
|
|
|
|
setTimeout(this.updateBadgeStyle, 250);
|
|
|
|
setTimeout(this.updateBadgeStyle, 50);
|
|
|
|
}.bind(this.CUIEvents);
|
|
|
|
}.bind(this.CUIEvents);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.CUIEvents.onCustomizeEnd = updateBadge;
|
|
|
|
|
|
|
|
this.CUIEvents.onWidgetUnderflow = updateBadge;
|
|
|
|
|
|
|
|
|
|
|
|
this.CUIEvents.updateBadgeStyle = function() {
|
|
|
|
this.CUIEvents.updateBadgeStyle = function() {
|
|
|
|
var css = [
|
|
|
|
var css = [
|
|
|
|
'background: #666',
|
|
|
|
'background: #666',
|
|
|
@ -1545,7 +1539,7 @@ if (vAPI.fennec) {
|
|
|
|
|
|
|
|
|
|
|
|
this.onCreated = function(button) {
|
|
|
|
this.onCreated = function(button) {
|
|
|
|
button.setAttribute('badge', '');
|
|
|
|
button.setAttribute('badge', '');
|
|
|
|
setTimeout(this.CUIEvents.onCustomizeEnd, 250);
|
|
|
|
setTimeout(this.CUIEvents.onCustomizeEnd, 50);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
CustomizableUI.addListener(this.CUIEvents);
|
|
|
|
CustomizableUI.addListener(this.CUIEvents);
|
|
|
@ -1588,11 +1582,12 @@ if (vAPI.fennec) {
|
|
|
|
.removeSheet(this.styleURI, 1);
|
|
|
|
.removeSheet(this.styleURI, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}.bind(this));
|
|
|
|
}.bind(this));
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vAPI.toolbarButton.onBeforeCreated = function(doc) {
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vAPI.toolbarButton.onBeforeCreated = function(doc) {
|
|
|
|
var panel = doc.createElement('panelview');
|
|
|
|
var panel = doc.createElement('panelview');
|
|
|
|
panel.setAttribute('id', this.viewId);
|
|
|
|
panel.setAttribute('id', this.viewId);
|
|
|
|
|
|
|
|
|
|
|
@ -1644,41 +1639,20 @@ if (vAPI.fennec) {
|
|
|
|
doc.defaultView.QueryInterface(Ci.nsIInterfaceRequestor)
|
|
|
|
doc.defaultView.QueryInterface(Ci.nsIInterfaceRequestor)
|
|
|
|
.getInterface(Ci.nsIDOMWindowUtils)
|
|
|
|
.getInterface(Ci.nsIDOMWindowUtils)
|
|
|
|
.loadSheet(this.styleURI, 1);
|
|
|
|
.loadSheet(this.styleURI, 1);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
vAPI.toolbarButton.onViewShowing = function({target}) {
|
|
|
|
vAPI.toolbarButton.onViewShowing = function({target}) {
|
|
|
|
target.firstChild.setAttribute('src', vAPI.getURL('popup.html'));
|
|
|
|
target.firstChild.setAttribute('src', vAPI.getURL('popup.html'));
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
vAPI.toolbarButton.onViewHiding = function({target}) {
|
|
|
|
vAPI.toolbarButton.onViewHiding = function({target}) {
|
|
|
|
target.parentNode.style.maxWidth = '';
|
|
|
|
target.parentNode.style.maxWidth = '';
|
|
|
|
target.firstChild.setAttribute('src', 'about:blank');
|
|
|
|
target.firstChild.setAttribute('src', 'about:blank');
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
vAPI.toolbarButton.updateState = function(win, tabId) {
|
|
|
|
|
|
|
|
var button = win.document.getElementById(this.id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( !button ) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var icon = this.tabs[tabId];
|
|
|
|
|
|
|
|
button.setAttribute('badge', icon && icon.badge || '');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( !icon || !icon.img ) {
|
|
|
|
|
|
|
|
icon = '';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
icon = 'url(' + vAPI.getURL('img/browsericons/icon16.svg') + ')';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
button.style.listStyleImage = icon;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
@ -1876,6 +1850,40 @@ vAPI.punycodeURL = function(url) {
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vAPI.optionsObserver = {
|
|
|
|
|
|
|
|
register: function () {
|
|
|
|
|
|
|
|
var obs = Components.classes['@mozilla.org/observer-service;1'].getService(Components.interfaces.nsIObserverService);
|
|
|
|
|
|
|
|
obs.addObserver(this, "addon-options-displayed", false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cleanupTasks.push(this.unregister.bind(this));
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
observe: function (aSubject, aTopic, aData) {
|
|
|
|
|
|
|
|
if (aTopic === "addon-options-displayed" && aData === "{2b10c1c8-a11f-4bad-fe9c-1c11e82cac42}") {
|
|
|
|
|
|
|
|
var doc = aSubject;
|
|
|
|
|
|
|
|
this.setupOptionsButton(doc, "showDashboardButton", "dashboard.html");
|
|
|
|
|
|
|
|
this.setupOptionsButton(doc, "showNetworkLogButton", "devtools.html");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
setupOptionsButton: function (doc, id, page) {
|
|
|
|
|
|
|
|
var button = doc.getElementById(id);
|
|
|
|
|
|
|
|
button.addEventListener("command", function () {
|
|
|
|
|
|
|
|
vAPI.tabs.open({ url: page, index: -1 });
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
button.label = vAPI.i18n(id);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unregister: function () {
|
|
|
|
|
|
|
|
var obs = Components.classes['@mozilla.org/observer-service;1'].getService(Components.interfaces.nsIObserverService);
|
|
|
|
|
|
|
|
obs.removeObserver(this, "addon-options-displayed");
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vAPI.optionsObserver.register();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// clean up when the extension is disabled
|
|
|
|
// clean up when the extension is disabled
|
|
|
|
|
|
|
|
|
|
|
|
window.addEventListener('unload', function() {
|
|
|
|
window.addEventListener('unload', function() {
|
|
|
|