diff --git a/chrome/content/vimperator/commands.js b/chrome/content/vimperator/commands.js index 73f08233..9e3258de 100644 --- a/chrome/content/vimperator/commands.js +++ b/chrome/content/vimperator/commands.js @@ -601,7 +601,7 @@ function Commands() //{{{ } )); addDefaultCommand(new Command(["re[load]"], - function(args, special) { reload(getBrowser().mCurrentTab, special); }, + function(args, special) { vimperator.tabs.reload(getBrowser().mCurrentTab, special); }, { usage: ["re[load][!]"], short_help: "Reload current page", @@ -609,7 +609,7 @@ function Commands() //{{{ } )); addDefaultCommand(new Command(["reloada[ll]"], - function(args, special) { reload_all(special); }, + function(args, special) { vimperator.tabs.reloadAll(special); }, { usage: ["reloada[ll][!]"], short_help: "Reload all pages", @@ -1622,42 +1622,6 @@ Vimperator.prototype.quit = function(save_session) goQuitApplication(); } -function reload(tab, bypass_cache) -{ - if (bypass_cache) - { - const nsIWebNavigation = Components.interfaces.nsIWebNavigation; - const flags = nsIWebNavigation.LOAD_FLAGS_BYPASS_PROXY | nsIWebNavigation.LOAD_FLAGS_BYPASS_CACHE; - getBrowser().getBrowserForTab(tab).reloadWithFlags(flags); - } - else - { - getBrowser().reloadTab(tab); - } -} - -function reload_all(bypass_cache) -{ - if (bypass_cache) - { - for (var i = 0; i < getBrowser().mTabs.length; i++) - { - try - { - reload(getBrowser().mTabs[i], bypass_cache) - } - catch (e) { - // FIXME: can we do anything useful here without stopping the - // other tabs from reloading? - } - } - } - else - { - getBrowser().reloadAllTabs(); - } -} - Vimperator.prototype.restart = function() { // if (!arguments[1]) return; diff --git a/chrome/content/vimperator/mappings.js b/chrome/content/vimperator/mappings.js index 66e00795..f1d54afd 100644 --- a/chrome/content/vimperator/mappings.js +++ b/chrome/content/vimperator/mappings.js @@ -373,14 +373,14 @@ function Mappings() //{{{ } )); addDefaultMap(new Map(vimperator.modes.NORMAL, ["r"], - function(count) { reload(getBrowser().mCurrentTab, false); }, + function(count) { vimperator.tabs.reload(getBrowser().mCurrentTab, false); }, { short_help: "Reload", help: "Forces reloading of the current page." } )); addDefaultMap(new Map(vimperator.modes.NORMAL, ["R"], - function(count) { reload(getBrowser().mCurrentTab, true); }, + function(count) { vimperator.tabs.reload(getBrowser().mCurrentTab, true); }, { short_help: "Reload while skipping the cache", help: "Forces reloading of the current page skipping the cache." diff --git a/chrome/content/vimperator/vimperator.js b/chrome/content/vimperator/vimperator.js index 8f19bc8e..da3a0603 100644 --- a/chrome/content/vimperator/vimperator.js +++ b/chrome/content/vimperator/vimperator.js @@ -1021,6 +1021,41 @@ function Tabs() //{{{ this.alternate = this.getTab(); + this.reload = function(tab, bypass_cache) + { + if (bypass_cache) + { + const nsIWebNavigation = Components.interfaces.nsIWebNavigation; + const flags = nsIWebNavigation.LOAD_FLAGS_BYPASS_PROXY | nsIWebNavigation.LOAD_FLAGS_BYPASS_CACHE; + getBrowser().getBrowserForTab(tab).reloadWithFlags(flags); + } + else + { + getBrowser().reloadTab(tab); + } + } + + this.reloadAll = function(bypass_cache) + { + if (bypass_cache) + { + for (var i = 0; i < getBrowser().mTabs.length; i++) + { + try + { + this.reload(getBrowser().mTabs[i], bypass_cache) + } + catch (e) { + // FIXME: can we do anything useful here without stopping the + // other tabs from reloading? + } + } + } + else + { + getBrowser().reloadAllTabs(); + } + } //}}} } //}}}