mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-21 20:47:58 +01:00
Add config.browser, config.tabbrowser. Fix mailbird. &c.
This commit is contained in:
@@ -36,14 +36,14 @@ const Browser = Module("browser", {
|
|||||||
"string", "UTF-8",
|
"string", "UTF-8",
|
||||||
{
|
{
|
||||||
scope: Option.SCOPE_LOCAL,
|
scope: Option.SCOPE_LOCAL,
|
||||||
getter: function () getBrowser().docShell.QueryInterface(Ci.nsIDocCharset).charset,
|
getter: function () config.browser.docShell.QueryInterface(Ci.nsIDocCharset).charset,
|
||||||
setter: function (val) {
|
setter: function (val) {
|
||||||
if (options["encoding"] == val)
|
if (options["encoding"] == val)
|
||||||
return val;
|
return val;
|
||||||
|
|
||||||
// Stolen from browser.jar/content/browser/browser.js, more or less.
|
// Stolen from browser.jar/content/browser/browser.js, more or less.
|
||||||
try {
|
try {
|
||||||
getBrowser().docShell.QueryInterface(Ci.nsIDocCharset).charset = val;
|
config.browser.docShell.QueryInterface(Ci.nsIDocCharset).charset = val;
|
||||||
PlacesUtils.history.setCharsetForURI(getWebNavigation().currentURI, val);
|
PlacesUtils.history.setCharsetForURI(getWebNavigation().currentURI, val);
|
||||||
getWebNavigation().reload(Ci.nsIWebNavigation.LOAD_FLAGS_CHARSET_CHANGE);
|
getWebNavigation().reload(Ci.nsIWebNavigation.LOAD_FLAGS_CHARSET_CHANGE);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ const Buffer = Module("buffer", {
|
|||||||
|
|
||||||
destroy: function () {
|
destroy: function () {
|
||||||
try {
|
try {
|
||||||
getBrowser().removeProgressListener(this.progressListener);
|
config.browser.removeProgressListener(this.progressListener);
|
||||||
}
|
}
|
||||||
catch (e) {} // Why? --djk
|
catch (e) {} // Why? --djk
|
||||||
},
|
},
|
||||||
@@ -200,7 +200,7 @@ const Buffer = Module("buffer", {
|
|||||||
doc.pageIsFullyLoaded = 1;
|
doc.pageIsFullyLoaded = 1;
|
||||||
|
|
||||||
// code which is only relevant if the page load is the current tab goes here:
|
// code which is only relevant if the page load is the current tab goes here:
|
||||||
if (doc == getBrowser().contentDocument) {
|
if (doc == config.browser.contentDocument) {
|
||||||
// we want to stay in command mode after a page has loaded
|
// we want to stay in command mode after a page has loaded
|
||||||
// TODO: move somewhere else, as focusing can already happen earlier than on "load"
|
// TODO: move somewhere else, as focusing can already happen earlier than on "load"
|
||||||
if (options["focuscontent"]) {
|
if (options["focuscontent"]) {
|
||||||
@@ -387,7 +387,7 @@ const Buffer = Module("buffer", {
|
|||||||
* @property {number} The current browser's text zoom level, as a
|
* @property {number} The current browser's text zoom level, as a
|
||||||
* percentage with 100 as 'normal'. Only affects text size.
|
* percentage with 100 as 'normal'. Only affects text size.
|
||||||
*/
|
*/
|
||||||
get textZoom() getBrowser().markupDocumentViewer.textZoom * 100,
|
get textZoom() config.browser.markupDocumentViewer.textZoom * 100,
|
||||||
set textZoom(value) { Buffer.setZoom(value, false); },
|
set textZoom(value) { Buffer.setZoom(value, false); },
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -395,7 +395,7 @@ const Buffer = Module("buffer", {
|
|||||||
* percentage with 100 as 'normal'. Affects text size, as well as
|
* percentage with 100 as 'normal'. Affects text size, as well as
|
||||||
* image size and block size.
|
* image size and block size.
|
||||||
*/
|
*/
|
||||||
get fullZoom() getBrowser().markupDocumentViewer.fullZoom * 100,
|
get fullZoom() config.browser.markupDocumentViewer.fullZoom * 100,
|
||||||
set fullZoom(value) { Buffer.setZoom(value, true); },
|
set fullZoom(value) { Buffer.setZoom(value, true); },
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -618,7 +618,7 @@ const Buffer = Module("buffer", {
|
|||||||
* @property {nsISelectionController} The current document's selection
|
* @property {nsISelectionController} The current document's selection
|
||||||
* controller.
|
* controller.
|
||||||
*/
|
*/
|
||||||
get selectionController() getBrowser().docShell
|
get selectionController() config.browser.docShell
|
||||||
.QueryInterface(Ci.nsIInterfaceRequestor)
|
.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||||
.getInterface(Ci.nsISelectionDisplay)
|
.getInterface(Ci.nsISelectionDisplay)
|
||||||
.QueryInterface(Ci.nsISelectionController),
|
.QueryInterface(Ci.nsISelectionController),
|
||||||
@@ -1132,7 +1132,7 @@ const Buffer = Module("buffer", {
|
|||||||
options.setPref("print.always_print_silent", args.bang);
|
options.setPref("print.always_print_silent", args.bang);
|
||||||
options.setPref("print.show_print_progress", !args.bang);
|
options.setPref("print.show_print_progress", !args.bang);
|
||||||
|
|
||||||
getBrowser().contentWindow.print();
|
config.browser.contentWindow.print();
|
||||||
});
|
});
|
||||||
|
|
||||||
if (arg)
|
if (arg)
|
||||||
@@ -1180,7 +1180,7 @@ const Buffer = Module("buffer", {
|
|||||||
|
|
||||||
commands.add(["re[load]"],
|
commands.add(["re[load]"],
|
||||||
"Reload the current web page",
|
"Reload the current web page",
|
||||||
function (args) { tabs.reload(getBrowser().mCurrentTab, args.bang); },
|
function (args) { tabs.reload(config.browser.mCurrentTab, args.bang); },
|
||||||
{
|
{
|
||||||
bang: true,
|
bang: true,
|
||||||
argCount: "0"
|
argCount: "0"
|
||||||
@@ -1228,7 +1228,7 @@ const Buffer = Module("buffer", {
|
|||||||
|
|
||||||
commands.add(["st[op]"],
|
commands.add(["st[op]"],
|
||||||
"Stop loading the current web page",
|
"Stop loading the current web page",
|
||||||
function () { tabs.stop(getBrowser().mCurrentTab); },
|
function () { tabs.stop(config.browser.mCurrentTab); },
|
||||||
{ argCount: "0" });
|
{ argCount: "0" });
|
||||||
|
|
||||||
commands.add(["vie[wsource]"],
|
commands.add(["vie[wsource]"],
|
||||||
@@ -1333,14 +1333,16 @@ const Buffer = Module("buffer", {
|
|||||||
.XULBrowserWindow = this.progressListener;
|
.XULBrowserWindow = this.progressListener;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
getBrowser().addProgressListener(this.progressListener, Ci.nsIWebProgress.NOTIFY_ALL);
|
config.browser.addProgressListener(this.progressListener, Ci.nsIWebProgress.NOTIFY_ALL);
|
||||||
}
|
}
|
||||||
catch (e) {} // Why? --djk
|
catch (e) {} // Why? --djk
|
||||||
|
|
||||||
let appContent = document.getElementById("appcontent");
|
let appContent = document.getElementById("appcontent");
|
||||||
|
if (appContent) {
|
||||||
events.addSessionListener(appContent, "DOMContentLoaded", this.closure.onDOMContentLoaded, true);
|
events.addSessionListener(appContent, "DOMContentLoaded", this.closure.onDOMContentLoaded, true);
|
||||||
events.addSessionListener(appContent, "load", this.closure.onPageLoad, true);
|
events.addSessionListener(appContent, "load", this.closure.onPageLoad, true);
|
||||||
events.addSessionListener(appContent, "scroll", this.closure._updateBufferPosition, false);
|
events.addSessionListener(appContent, "scroll", this.closure._updateBufferPosition, false);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
mappings: function () {
|
mappings: function () {
|
||||||
var myModes = config.browserModes;
|
var myModes = config.browserModes;
|
||||||
@@ -1365,7 +1367,7 @@ const Buffer = Module("buffer", {
|
|||||||
|
|
||||||
mappings.add(myModes, ["<C-c>"],
|
mappings.add(myModes, ["<C-c>"],
|
||||||
"Stop loading the current web page",
|
"Stop loading the current web page",
|
||||||
function () { tabs.stop(getBrowser().mCurrentTab); });
|
function () { tabs.stop(config.browser.mCurrentTab); });
|
||||||
|
|
||||||
// scrolling
|
// scrolling
|
||||||
mappings.add(myModes, ["j", "<Down>", "<C-e>"],
|
mappings.add(myModes, ["j", "<Down>", "<C-e>"],
|
||||||
@@ -1520,11 +1522,11 @@ const Buffer = Module("buffer", {
|
|||||||
// reloading
|
// reloading
|
||||||
mappings.add(myModes, ["r"],
|
mappings.add(myModes, ["r"],
|
||||||
"Reload the current web page",
|
"Reload the current web page",
|
||||||
function () { tabs.reload(getBrowser().mCurrentTab, false); });
|
function () { tabs.reload(config.browser.mCurrentTab, false); });
|
||||||
|
|
||||||
mappings.add(myModes, ["R"],
|
mappings.add(myModes, ["R"],
|
||||||
"Reload while skipping the cache",
|
"Reload while skipping the cache",
|
||||||
function () { tabs.reload(getBrowser().mCurrentTab, true); });
|
function () { tabs.reload(config.browser.mCurrentTab, true); });
|
||||||
|
|
||||||
// yanking
|
// yanking
|
||||||
mappings.add(myModes, ["Y"],
|
mappings.add(myModes, ["Y"],
|
||||||
@@ -1635,8 +1637,8 @@ const Buffer = Module("buffer", {
|
|||||||
"Show current website with a minimal style sheet to make it easily accessible",
|
"Show current website with a minimal style sheet to make it easily accessible",
|
||||||
"boolean", false,
|
"boolean", false,
|
||||||
{
|
{
|
||||||
setter: function (value) getBrowser().markupDocumentViewer.authorStyleDisabled = value,
|
setter: function (value) config.browser.markupDocumentViewer.authorStyleDisabled = value,
|
||||||
getter: function () getBrowser().markupDocumentViewer.authorStyleDisabled
|
getter: function () config.browser.markupDocumentViewer.authorStyleDisabled
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -11,6 +11,9 @@ const ConfigBase = Class(ModuleBase, {
|
|||||||
*/
|
*/
|
||||||
autocommands: [],
|
autocommands: [],
|
||||||
|
|
||||||
|
browser: window.gBrowser,
|
||||||
|
tabbrowser: window.gBrowser,
|
||||||
|
|
||||||
get browserModes() [modes.NORMAL],
|
get browserModes() [modes.NORMAL],
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -83,7 +86,7 @@ const ConfigBase = Class(ModuleBase, {
|
|||||||
* @property {number} The height (px) that is available to the output
|
* @property {number} The height (px) that is available to the output
|
||||||
* window.
|
* window.
|
||||||
*/
|
*/
|
||||||
get outputHeight() getBrowser().mPanelContainer.boxObject.height,
|
get outputHeight() config.browser.mPanelContainer.boxObject.height,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property {[string]} A list of extra scripts in the liberator or
|
* @property {[string]} A list of extra scripts in the liberator or
|
||||||
|
|||||||
@@ -231,7 +231,7 @@ const Finder = Module("finder", {
|
|||||||
* @param {string} str The string to find.
|
* @param {string} str The string to find.
|
||||||
*/
|
*/
|
||||||
find: function (str) {
|
find: function (str) {
|
||||||
let fastFind = getBrowser().fastFind;
|
let fastFind = config.browser.fastFind;
|
||||||
|
|
||||||
this._processUserPattern(str);
|
this._processUserPattern(str);
|
||||||
fastFind.caseSensitive = this._caseSensitive;
|
fastFind.caseSensitive = this._caseSensitive;
|
||||||
@@ -252,11 +252,11 @@ const Finder = Module("finder", {
|
|||||||
// This hack is needed to make n/N work with the correct string, if
|
// This hack is needed to make n/N work with the correct string, if
|
||||||
// we typed /foo<esc> after the original search. Since searchString is
|
// we typed /foo<esc> after the original search. Since searchString is
|
||||||
// readonly we have to call find() again to update it.
|
// readonly we have to call find() again to update it.
|
||||||
if (getBrowser().fastFind.searchString != this._lastSearchString)
|
if (config.browser.fastFind.searchString != this._lastSearchString)
|
||||||
this.find(this._lastSearchString);
|
this.find(this._lastSearchString);
|
||||||
|
|
||||||
let up = reverse ? !this._lastSearchBackwards : this._lastSearchBackwards;
|
let up = reverse ? !this._lastSearchBackwards : this._lastSearchBackwards;
|
||||||
let result = getBrowser().fastFind.findAgain(up, this._linksOnly);
|
let result = config.browser.fastFind.findAgain(up, this._linksOnly);
|
||||||
|
|
||||||
if (result == Ci.nsITypeAheadFind.FIND_NOTFOUND)
|
if (result == Ci.nsITypeAheadFind.FIND_NOTFOUND)
|
||||||
liberator.echoerr("E486: Pattern not found: " + this._lastSearchPattern, commandline.FORCE_SINGLELINE);
|
liberator.echoerr("E486: Pattern not found: " + this._lastSearchPattern, commandline.FORCE_SINGLELINE);
|
||||||
@@ -361,7 +361,7 @@ const Finder = Module("finder", {
|
|||||||
|
|
||||||
// recreate selection since highlightDoc collapses the selection
|
// recreate selection since highlightDoc collapses the selection
|
||||||
if (window.content.getSelection().isCollapsed)
|
if (window.content.getSelection().isCollapsed)
|
||||||
getBrowser().fastFind.findAgain(this._backwards, this._linksOnly);
|
config.browser.fastFind.findAgain(this._backwards, this._linksOnly);
|
||||||
|
|
||||||
// TODO: remove highlighting from non-link matches (HTML - A/AREA with href attribute; XML - Xlink [type="simple"])
|
// TODO: remove highlighting from non-link matches (HTML - A/AREA with href attribute; XML - Xlink [type="simple"])
|
||||||
},
|
},
|
||||||
@@ -980,7 +980,7 @@ const RangeFind = Class("RangeFind", {
|
|||||||
get docShell() {
|
get docShell() {
|
||||||
if (this._docShell)
|
if (this._docShell)
|
||||||
return this._docShell;
|
return this._docShell;
|
||||||
for (let shell in iter(getBrowser().docShell.getDocShellEnumerator(Ci.nsIDocShellTreeItem.typeAll, Ci.nsIDocShell.ENUMERATE_FORWARDS)))
|
for (let shell in iter(config.browser.docShell.getDocShellEnumerator(Ci.nsIDocShellTreeItem.typeAll, Ci.nsIDocShell.ENUMERATE_FORWARDS)))
|
||||||
if (shell.QueryInterface(nsIWebNavigation).document == this.document)
|
if (shell.QueryInterface(nsIWebNavigation).document == this.document)
|
||||||
return this._docShell = shell;
|
return this._docShell = shell;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -400,7 +400,7 @@ const Hints = Module("hints", {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getBrowser().markupDocumentViewer.authorStyleDisabled) {
|
if (config.browser.markupDocumentViewer.authorStyleDisabled) {
|
||||||
let css = [];
|
let css = [];
|
||||||
// FIXME: Broken for imgspans.
|
// FIXME: Broken for imgspans.
|
||||||
for (let [, { doc: doc }] in Iterator(this._docs)) {
|
for (let [, { doc: doc }] in Iterator(this._docs)) {
|
||||||
|
|||||||
@@ -779,8 +779,7 @@ const Liberator = Module("liberator", {
|
|||||||
if (urls.length == 0)
|
if (urls.length == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
let browser = window.getBrowser();
|
let browser = config.browser;
|
||||||
|
|
||||||
function open(urls, where) {
|
function open(urls, where) {
|
||||||
let url = Array.concat(urls)[0];
|
let url = Array.concat(urls)[0];
|
||||||
let postdata = Array.concat(urls)[1];
|
let postdata = Array.concat(urls)[1];
|
||||||
@@ -1514,7 +1513,7 @@ const Liberator = Module("liberator", {
|
|||||||
liberator.has("tabs") ? "Quit current tab" : "Quit application",
|
liberator.has("tabs") ? "Quit current tab" : "Quit application",
|
||||||
function (args) {
|
function (args) {
|
||||||
if (liberator.has("tabs"))
|
if (liberator.has("tabs"))
|
||||||
tabs.remove(getBrowser().mCurrentTab, 1, false, 1);
|
tabs.remove(config.browser.mCurrentTab, 1, false, 1);
|
||||||
else
|
else
|
||||||
liberator.quit(false, args.bang);
|
liberator.quit(false, args.bang);
|
||||||
}, {
|
}, {
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ const Marks = Module("marks", {
|
|||||||
if (Marks.isURLMark(mark)) {
|
if (Marks.isURLMark(mark)) {
|
||||||
let slice = this._urlMarks.get(mark);
|
let slice = this._urlMarks.get(mark);
|
||||||
if (slice && slice.tab && slice.tab.linkedBrowser) {
|
if (slice && slice.tab && slice.tab.linkedBrowser) {
|
||||||
if (slice.tab.parentNode != getBrowser().tabContainer) {
|
if (slice.tab.parentNode != config.browser.tabContainer) {
|
||||||
this._pendingJumps.push(slice);
|
this._pendingJumps.push(slice);
|
||||||
// NOTE: this obviously won't work on generated pages using
|
// NOTE: this obviously won't work on generated pages using
|
||||||
// non-unique URLs :(
|
// non-unique URLs :(
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ const StatusLine = Module("statusline", {
|
|||||||
|
|
||||||
// update the ordinal which is used for numbered tabs
|
// update the ordinal which is used for numbered tabs
|
||||||
if (options.get("guioptions").has("n", "N"))
|
if (options.get("guioptions").has("n", "N"))
|
||||||
for (let [i, tab] in util.Array.iteritems(getBrowser().mTabs))
|
for (let [i, tab] in util.Array.iteritems(config.browser.mTabs))
|
||||||
tab.setAttribute("ordinal", i + 1);
|
tab.setAttribute("ordinal", i + 1);
|
||||||
|
|
||||||
this._tabCountWidget.value = "[" + (tabs.index() + 1) + "/" + tabs.count + "]";
|
this._tabCountWidget.value = "[" + (tabs.index() + 1) + "/" + tabs.count + "]";
|
||||||
|
|||||||
@@ -17,10 +17,7 @@ const Tabs = Module("tabs", {
|
|||||||
requires: ["config"],
|
requires: ["config"],
|
||||||
|
|
||||||
init: function () {
|
init: function () {
|
||||||
if (config.getBrowser)
|
this._alternates = [config.tabbrowser.mCurrentTab, null];
|
||||||
this.getBrowser = config.getBrowser;
|
|
||||||
|
|
||||||
this._alternates = [this.getBrowser().mCurrentTab, null];
|
|
||||||
|
|
||||||
// used for the "gb" and "gB" mappings to remember the last :buffer[!] command
|
// used for the "gb" and "gB" mappings to remember the last :buffer[!] command
|
||||||
this._lastBufferSwitchArgs = "";
|
this._lastBufferSwitchArgs = "";
|
||||||
@@ -29,7 +26,7 @@ const Tabs = Module("tabs", {
|
|||||||
// hide tabs initially to prevent flickering when 'stal' would hide them
|
// hide tabs initially to prevent flickering when 'stal' would hide them
|
||||||
// on startup
|
// on startup
|
||||||
if (config.hasTabbrowser)
|
if (config.hasTabbrowser)
|
||||||
this.getBrowser().mTabContainer.collapsed = true; // FIXME: see 'stal' comment
|
config.tabbrowser.mTabContainer.collapsed = true; // FIXME: see 'stal' comment
|
||||||
},
|
},
|
||||||
|
|
||||||
_updateTabCount: function () {
|
_updateTabCount: function () {
|
||||||
@@ -57,7 +54,7 @@ const Tabs = Module("tabs", {
|
|||||||
* in the current window.
|
* in the current window.
|
||||||
*/
|
*/
|
||||||
get browsers() {
|
get browsers() {
|
||||||
let browsers = this.getBrowser().browsers;
|
let browsers = config.tabbrowser.browsers;
|
||||||
for (let i = 0; i < browsers.length; i++)
|
for (let i = 0; i < browsers.length; i++)
|
||||||
yield [i, browsers[i]];
|
yield [i, browsers[i]];
|
||||||
},
|
},
|
||||||
@@ -81,7 +78,7 @@ const Tabs = Module("tabs", {
|
|||||||
/**
|
/**
|
||||||
* @property {number} The number of tabs in the current window.
|
* @property {number} The number of tabs in the current window.
|
||||||
*/
|
*/
|
||||||
get count() this.getBrowser().mTabs.length,
|
get count() config.tabbrowser.mTabs.length,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property {Object} The local options store for the current tab.
|
* @property {Object} The local options store for the current tab.
|
||||||
@@ -93,8 +90,6 @@ const Tabs = Module("tabs", {
|
|||||||
return store.options;
|
return store.options;
|
||||||
},
|
},
|
||||||
|
|
||||||
getBrowser: getBrowser,
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the local state store for the tab at the specified
|
* Returns the local state store for the tab at the specified
|
||||||
* <b>tabIndex</b>. If <b>tabIndex</b> is not specified then the
|
* <b>tabIndex</b>. If <b>tabIndex</b> is not specified then the
|
||||||
@@ -137,9 +132,9 @@ const Tabs = Module("tabs", {
|
|||||||
*/
|
*/
|
||||||
index: function (tab) {
|
index: function (tab) {
|
||||||
if (tab)
|
if (tab)
|
||||||
return Array.indexOf(this.getBrowser().mTabs, tab);
|
return Array.indexOf(config.tabbrowser.mTabs, tab);
|
||||||
else
|
else
|
||||||
return this.getBrowser().mTabContainer.selectedIndex;
|
return config.tabbrowser.mTabContainer.selectedIndex;
|
||||||
},
|
},
|
||||||
|
|
||||||
// TODO: implement filter
|
// TODO: implement filter
|
||||||
@@ -186,9 +181,9 @@ const Tabs = Module("tabs", {
|
|||||||
*/
|
*/
|
||||||
getTab: function (index) {
|
getTab: function (index) {
|
||||||
if (index != undefined)
|
if (index != undefined)
|
||||||
return this.getBrowser().mTabs[index];
|
return config.tabbrowser.mTabs[index];
|
||||||
else
|
else
|
||||||
return this.getBrowser().mCurrentTab;
|
return config.tabbrowser.mCurrentTab;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -212,7 +207,7 @@ const Tabs = Module("tabs", {
|
|||||||
*/
|
*/
|
||||||
move: function (tab, spec, wrap) {
|
move: function (tab, spec, wrap) {
|
||||||
let index = Tabs.indexFromSpec(spec, wrap);
|
let index = Tabs.indexFromSpec(spec, wrap);
|
||||||
this.getBrowser().moveTabTo(tab, index);
|
config.tabbrowser.moveTabTo(tab, index);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -230,31 +225,31 @@ const Tabs = Module("tabs", {
|
|||||||
remove: function (tab, count, focusLeftTab, quitOnLastTab) {
|
remove: function (tab, count, focusLeftTab, quitOnLastTab) {
|
||||||
let removeOrBlankTab = {
|
let removeOrBlankTab = {
|
||||||
Firefox: function (tab) {
|
Firefox: function (tab) {
|
||||||
if (tabs.getBrowser().mTabs.length > 1)
|
if (config.tabbrowser.mTabs.length > 1)
|
||||||
tabs.getBrowser().removeTab(tab);
|
config.tabbrowser.removeTab(tab);
|
||||||
else {
|
else {
|
||||||
if (buffer.URL != "about:blank" ||
|
if (buffer.URL != "about:blank" ||
|
||||||
window.getWebNavigation().sessionHistory.count > 0) {
|
window.getWebNavigation().sessionHistory.count > 0) {
|
||||||
liberator.open("about:blank", liberator.NEW_BACKGROUND_TAB);
|
liberator.open("about:blank", liberator.NEW_BACKGROUND_TAB);
|
||||||
tabs.getBrowser().removeTab(tab);
|
config.tabbrowser.removeTab(tab);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
liberator.beep();
|
liberator.beep();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Thunderbird: function (tab) {
|
Thunderbird: function (tab) {
|
||||||
if (tabs.getBrowser().mTabs.length > 1)
|
if (config.tabbrowser.mTabs.length > 1)
|
||||||
tabs.getBrowser().removeTab(tab);
|
config.tabbrowser.removeTab(tab);
|
||||||
else
|
else
|
||||||
liberator.beep();
|
liberator.beep();
|
||||||
},
|
},
|
||||||
Songbird: function (tab) {
|
Songbird: function (tab) {
|
||||||
if (tabs.getBrowser().mTabs.length > 1)
|
if (config.tabbrowser.mTabs.length > 1)
|
||||||
tabs.getBrowser().removeTab(tab);
|
config.tabbrowser.removeTab(tab);
|
||||||
else {
|
else {
|
||||||
if (buffer.URL != "about:blank" || window.getWebNavigation().sessionHistory.count > 0) {
|
if (buffer.URL != "about:blank" || window.getWebNavigation().sessionHistory.count > 0) {
|
||||||
liberator.open("about:blank", liberator.NEW_BACKGROUND_TAB);
|
liberator.open("about:blank", liberator.NEW_BACKGROUND_TAB);
|
||||||
tabs.getBrowser().removeTab(tab);
|
config.tabbrowser.removeTab(tab);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
liberator.beep();
|
liberator.beep();
|
||||||
@@ -265,7 +260,7 @@ const Tabs = Module("tabs", {
|
|||||||
if (typeof count != "number" || count < 1)
|
if (typeof count != "number" || count < 1)
|
||||||
count = 1;
|
count = 1;
|
||||||
|
|
||||||
if (quitOnLastTab >= 1 && this.getBrowser().mTabs.length <= count) {
|
if (quitOnLastTab >= 1 && config.tabbrowser.mTabs.length <= count) {
|
||||||
if (liberator.windows.length > 1)
|
if (liberator.windows.length > 1)
|
||||||
window.close();
|
window.close();
|
||||||
else
|
else
|
||||||
@@ -281,7 +276,7 @@ const Tabs = Module("tabs", {
|
|||||||
removeOrBlankTab(this.getTab(i));
|
removeOrBlankTab(this.getTab(i));
|
||||||
lastRemovedTab = i > 0 ? i : 1;
|
lastRemovedTab = i > 0 ? i : 1;
|
||||||
}
|
}
|
||||||
this.getBrowser().mTabContainer.selectedIndex = lastRemovedTab - 1;
|
config.tabbrowser.mTabContainer.selectedIndex = lastRemovedTab - 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
let i = index + count - 1;
|
let i = index + count - 1;
|
||||||
@@ -290,7 +285,7 @@ const Tabs = Module("tabs", {
|
|||||||
|
|
||||||
for (; i >= index; i--)
|
for (; i >= index; i--)
|
||||||
removeOrBlankTab(this.getTab(i));
|
removeOrBlankTab(this.getTab(i));
|
||||||
this.getBrowser().mTabContainer.selectedIndex = index;
|
config.tabbrowser.mTabContainer.selectedIndex = index;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -300,7 +295,7 @@ const Tabs = Module("tabs", {
|
|||||||
* @param {Object} tab The tab to keep.
|
* @param {Object} tab The tab to keep.
|
||||||
*/
|
*/
|
||||||
keepOnly: function (tab) {
|
keepOnly: function (tab) {
|
||||||
this.getBrowser().removeAllTabsBut(tab);
|
config.tabbrowser.removeAllTabsBut(tab);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -316,7 +311,7 @@ const Tabs = Module("tabs", {
|
|||||||
// FIXME:
|
// FIXME:
|
||||||
if (index == -1)
|
if (index == -1)
|
||||||
return void liberator.beep();
|
return void liberator.beep();
|
||||||
this.getBrowser().mTabContainer.selectedIndex = index;
|
config.tabbrowser.mTabContainer.selectedIndex = index;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -329,10 +324,10 @@ const Tabs = Module("tabs", {
|
|||||||
reload: function (tab, bypassCache) {
|
reload: function (tab, bypassCache) {
|
||||||
if (bypassCache) {
|
if (bypassCache) {
|
||||||
const flags = Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_PROXY | Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_CACHE;
|
const flags = Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_PROXY | Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_CACHE;
|
||||||
this.getBrowser().getBrowserForTab(tab).reloadWithFlags(flags);
|
config.tabbrowser.getBrowserForTab(tab).reloadWithFlags(flags);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
this.getBrowser().reloadTab(tab);
|
config.tabbrowser.reloadTab(tab);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -343,9 +338,9 @@ const Tabs = Module("tabs", {
|
|||||||
*/
|
*/
|
||||||
reloadAll: function (bypassCache) {
|
reloadAll: function (bypassCache) {
|
||||||
if (bypassCache) {
|
if (bypassCache) {
|
||||||
for (let i = 0; i < this.getBrowser().mTabs.length; i++) {
|
for (let i = 0; i < config.tabbrowser.mTabs.length; i++) {
|
||||||
try {
|
try {
|
||||||
this.reload(this.getBrowser().mTabs[i], bypassCache);
|
this.reload(config.tabbrowser.mTabs[i], bypassCache);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
// FIXME: can we do anything useful here without stopping the
|
// FIXME: can we do anything useful here without stopping the
|
||||||
@@ -354,7 +349,7 @@ const Tabs = Module("tabs", {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
this.getBrowser().reloadAllTabs();
|
config.tabbrowser.reloadAllTabs();
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -425,11 +420,11 @@ const Tabs = Module("tabs", {
|
|||||||
matches = [];
|
matches = [];
|
||||||
let lowerBuffer = buffer.toLowerCase();
|
let lowerBuffer = buffer.toLowerCase();
|
||||||
let first = tabs.index() + (reverse ? 0 : 1);
|
let first = tabs.index() + (reverse ? 0 : 1);
|
||||||
let nbrowsers = this.getBrowser().browsers.length;
|
let nbrowsers = config.tabbrowser.browsers.length;
|
||||||
for (let [i, ] in tabs.browsers) {
|
for (let [i, ] in tabs.browsers) {
|
||||||
let index = (i + first) % nbrowsers;
|
let index = (i + first) % nbrowsers;
|
||||||
let url = this.getBrowser().getBrowserAtIndex(index).contentDocument.location.href;
|
let url = config.tabbrowser.getBrowserAtIndex(index).contentDocument.location.href;
|
||||||
let title = this.getBrowser().getBrowserAtIndex(index).contentDocument.title.toLowerCase();
|
let title = config.tabbrowser.getBrowserAtIndex(index).contentDocument.title.toLowerCase();
|
||||||
if (url == buffer) {
|
if (url == buffer) {
|
||||||
tabs.select(index, false);
|
tabs.select(index, false);
|
||||||
return;
|
return;
|
||||||
@@ -462,11 +457,11 @@ const Tabs = Module("tabs", {
|
|||||||
* @param {boolean} activate Whether to select the newly cloned tab.
|
* @param {boolean} activate Whether to select the newly cloned tab.
|
||||||
*/
|
*/
|
||||||
cloneTab: function (tab, activate) {
|
cloneTab: function (tab, activate) {
|
||||||
let newTab = this.getBrowser().addTab();
|
let newTab = config.tabbrowser.addTab();
|
||||||
Tabs.copyTab(newTab, tab);
|
Tabs.copyTab(newTab, tab);
|
||||||
|
|
||||||
if (activate)
|
if (activate)
|
||||||
this.getBrowser().mTabContainer.selectedItem = newTab;
|
config.tabbrowser.mTabContainer.selectedItem = newTab;
|
||||||
|
|
||||||
return newTab;
|
return newTab;
|
||||||
},
|
},
|
||||||
@@ -479,7 +474,7 @@ const Tabs = Module("tabs", {
|
|||||||
*/
|
*/
|
||||||
detachTab: function (tab) {
|
detachTab: function (tab) {
|
||||||
if (!tab)
|
if (!tab)
|
||||||
tab = this.getBrowser().mTabContainer.selectedItem;
|
tab = config.tabbrowser.mTabContainer.selectedItem;
|
||||||
|
|
||||||
services.get("windowWatcher")
|
services.get("windowWatcher")
|
||||||
.openWindow(window, window.getBrowserURL(), null, "chrome,dialog=no,all", tab);
|
.openWindow(window, window.getBrowserURL(), null, "chrome,dialog=no,all", tab);
|
||||||
@@ -520,7 +515,7 @@ const Tabs = Module("tabs", {
|
|||||||
}, {
|
}, {
|
||||||
copyTab: function (to, from) {
|
copyTab: function (to, from) {
|
||||||
if (!from)
|
if (!from)
|
||||||
from = tabs.getBrowser().mTabContainer.selectedItem;
|
from = config.tabbrowser.mTabContainer.selectedItem;
|
||||||
|
|
||||||
let tabState = services.get("sessionStore").getTabState(from);
|
let tabState = services.get("sessionStore").getTabState(from);
|
||||||
services.get("sessionStore").setTabState(to, tabState);
|
services.get("sessionStore").setTabState(to, tabState);
|
||||||
@@ -535,8 +530,8 @@ const Tabs = Module("tabs", {
|
|||||||
* - "$" for the last tab
|
* - "$" for the last tab
|
||||||
*/
|
*/
|
||||||
indexFromSpec: function (spec, wrap) {
|
indexFromSpec: function (spec, wrap) {
|
||||||
let position = tabs.getBrowser().mTabContainer.selectedIndex;
|
let position = config.tabbrowser.mTabContainer.selectedIndex;
|
||||||
let length = tabs.getBrowser().mTabs.length;
|
let length = config.tabbrowser.mTabs.length;
|
||||||
let last = length - 1;
|
let last = length - 1;
|
||||||
|
|
||||||
if (spec === undefined || spec === "")
|
if (spec === undefined || spec === "")
|
||||||
@@ -579,7 +574,7 @@ const Tabs = Module("tabs", {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
let str = arg.toLowerCase();
|
let str = arg.toLowerCase();
|
||||||
let browsers = tabs.getBrowser().browsers;
|
let browsers = config.tabbrowser.browsers;
|
||||||
|
|
||||||
for (let i = browsers.length - 1; i >= 0; i--) {
|
for (let i = browsers.length - 1; i >= 0; i--) {
|
||||||
let host, title, uri = browsers[i].currentURI.spec;
|
let host, title, uri = browsers[i].currentURI.spec;
|
||||||
@@ -787,7 +782,7 @@ const Tabs = Module("tabs", {
|
|||||||
"E488: Trailing characters");
|
"E488: Trailing characters");
|
||||||
|
|
||||||
// if not specified, move to after the last tab
|
// if not specified, move to after the last tab
|
||||||
tabs.move(tabs.getBrowser().mCurrentTab, arg || "$", args.bang);
|
tabs.move(config.tabbrowser.mCurrentTab, arg || "$", args.bang);
|
||||||
}, {
|
}, {
|
||||||
argCount: "?",
|
argCount: "?",
|
||||||
bang: true
|
bang: true
|
||||||
@@ -795,7 +790,7 @@ const Tabs = Module("tabs", {
|
|||||||
|
|
||||||
commands.add(["tabo[nly]"],
|
commands.add(["tabo[nly]"],
|
||||||
"Close all other tabs",
|
"Close all other tabs",
|
||||||
function () { tabs.keepOnly(tabs.getBrowser().mCurrentTab); },
|
function () { tabs.keepOnly(config.tabbrowser.mCurrentTab); },
|
||||||
{ argCount: "0" });
|
{ argCount: "0" });
|
||||||
|
|
||||||
commands.add(["tabopen", "t[open]", "tabnew"],
|
commands.add(["tabopen", "t[open]", "tabnew"],
|
||||||
@@ -869,7 +864,7 @@ const Tabs = Module("tabs", {
|
|||||||
|
|
||||||
browser.moveTabTo(dummy, util.Math.constrain(tabIndex || last, 0, last));
|
browser.moveTabTo(dummy, util.Math.constrain(tabIndex || last, 0, last));
|
||||||
browser.selectedTab = dummy; // required
|
browser.selectedTab = dummy; // required
|
||||||
browser.swapBrowsersAndCloseOther(dummy, tabs.getBrowser().mCurrentTab);
|
browser.swapBrowsersAndCloseOther(dummy, config.tabbrowser.mCurrentTab);
|
||||||
}, {
|
}, {
|
||||||
argCount: "+",
|
argCount: "+",
|
||||||
completer: function (context, args) {
|
completer: function (context, args) {
|
||||||
@@ -937,7 +932,7 @@ const Tabs = Module("tabs", {
|
|||||||
completion.buffer);
|
completion.buffer);
|
||||||
},
|
},
|
||||||
events: function () {
|
events: function () {
|
||||||
let tabContainer = this.getBrowser().mTabContainer;
|
let tabContainer = config.tabbrowser.mTabContainer;
|
||||||
["TabMove", "TabOpen", "TabClose"].forEach(function (event) {
|
["TabMove", "TabOpen", "TabClose"].forEach(function (event) {
|
||||||
events.addSessionListener(tabContainer, event, this.closure._updateTabCount, false);
|
events.addSessionListener(tabContainer, event, this.closure._updateTabCount, false);
|
||||||
}, this);
|
}, this);
|
||||||
@@ -1036,7 +1031,7 @@ const Tabs = Module("tabs", {
|
|||||||
// don't have to fight against the host app's attempts to keep
|
// don't have to fight against the host app's attempts to keep
|
||||||
// it open - hack! Adding a filter watch to mStrip is probably
|
// it open - hack! Adding a filter watch to mStrip is probably
|
||||||
// the cleanest solution.
|
// the cleanest solution.
|
||||||
let tabStrip = tabs.getBrowser().mTabContainer;
|
let tabStrip = config.tabbrowser.mTabContainer;
|
||||||
|
|
||||||
if (value == 0)
|
if (value == 0)
|
||||||
tabStrip.collapsed = true;
|
tabStrip.collapsed = true;
|
||||||
|
|||||||
@@ -102,15 +102,14 @@ const Config = Module("config", ConfigBase, {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
getBrowser: function () {
|
get browser() getBrowser(),
|
||||||
var tabmail = { __proto__: document.getElementById("tabmail") };
|
tabbrowser: {
|
||||||
tabmail.__defineGetter__("mTabContainer", function () this.tabContainer);
|
__proto__: document.getElementById("tabmail"),
|
||||||
tabmail.__defineGetter__("mTabs", function () this.tabContainer.childNodes);
|
get mTabContainer() this.tabContainer,
|
||||||
tabmail.__defineGetter__("mCurrentTab", function () this.tabContainer.selectedItem);
|
get mTabs() this.tabContainer.childNodes,
|
||||||
tabmail.__defineGetter__("mStrip", function () this.tabStrip);
|
get mCurrentTab() this.tabContainer.selectedItem,
|
||||||
tabmail.__defineGetter__("browsers", function () [browser for (browser in Iterator(this.mTabs))]);
|
get mStrip() this.tabStrip,
|
||||||
config.getBrowser = function () tabmail;
|
get browsers() [browser for (browser in Iterator(this.mTabs))]
|
||||||
return tabmail;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// they are sorted by relevance, not alphabetically
|
// they are sorted by relevance, not alphabetically
|
||||||
|
|||||||
Reference in New Issue
Block a user