diff options
author | JustOff <Off.Just.Off@gmail.com> | 2018-02-18 15:29:43 +0200 |
---|---|---|
committer | JustOff <Off.Just.Off@gmail.com> | 2018-02-18 15:29:43 +0200 |
commit | a933414a38b5f17d61860f02addca6af0fda4146 (patch) | |
tree | 1287437597fbb5d582d6acc0b4e31b995027df25 /browser | |
parent | 3cf6a70edcb9e08e5e2592354b375cbe5d6cfa5b (diff) | |
download | palemoon-gre-a933414a38b5f17d61860f02addca6af0fda4146.tar.gz |
Properly handle new tab selection dialog when instantApply is enabled
Diffstat (limited to 'browser')
-rw-r--r-- | browser/components/preferences/tabs.js | 30 | ||||
-rw-r--r-- | browser/components/preferences/tabs.xul | 3 |
2 files changed, 24 insertions, 9 deletions
diff --git a/browser/components/preferences/tabs.js b/browser/components/preferences/tabs.js index d88f6659d..f0ad8490c 100644 --- a/browser/components/preferences/tabs.js +++ b/browser/components/preferences/tabs.js @@ -101,6 +101,8 @@ var gTabsPane = { default: // Custom URL entered. document.getElementById("newtabPageCustom").hidden = false; newtabUrlChoice.value = 0; + // We need this to consider instantApply. + this.newtabPageCustom = newtabUrlPref.value; } }, @@ -109,33 +111,45 @@ var gTabsPane = { * if the choice is "my home page", get and sanitize the browser home page * URL to make it suitable for newtab use. * - * Called from prefwindow's ondialogaccept handler. + * Called from prefwindow's ondialogaccept handler and + * from browser.newtab.choice's oncommand to consider instantApply. */ - writeNewtabUrl: function() { + writeNewtabUrl: function(newtabUrlChoice) { try { - let newtabUrlChoice = Services.prefs.getIntPref("browser.newtab.choice"); + if (newtabUrlChoice) { + if (Services.prefs.getBoolPref("browser.preferences.instantApply")) { + newtabUrlChoice = parseInt(newtabUrlChoice); + } else { + return; + } + } else { + newtabUrlChoice = Services.prefs.getIntPref("browser.newtab.choice"); + } let browserHomepageUrl = Services.prefs.getComplexValue("browser.startup.homepage", Components.interfaces.nsIPrefLocalizedString).data; let newtabUrlPref = Services.prefs.getCharPref("browser.newtab.url"); switch (newtabUrlChoice) { case 1: - newtabUrlPref="about:logopage"; + newtabUrlPref = "about:logopage"; break; case 2: - newtabUrlPref="http://start.palemoon.org/"; + newtabUrlPref = "http://start.palemoon.org/"; break; case 3: // If url is a pipe-delimited set of pages, just take the first one. let newtabUrlSanitizedPref=browserHomepageUrl.split("|")[0]; // XXX: do we need extra sanitation here, e.g. for invalid URLs? Services.prefs.setCharPref("browser.newtab.myhome", newtabUrlSanitizedPref); - newtabUrlPref=newtabUrlSanitizedPref; + newtabUrlPref = newtabUrlSanitizedPref; break; case 4: - newtabUrlPref="about:newtab"; + newtabUrlPref = "about:newtab"; break; default: - // In case of any other value it's a custom URL, so don't change anything... + // In case of any other value it's a custom URL, consider instantApply. + if (this.newtabPageCustom) { + newtabUrlPref = this.newtabPageCustom; + } } Services.prefs.setCharPref("browser.newtab.url",newtabUrlPref); } catch(e) { console.error(e); } diff --git a/browser/components/preferences/tabs.xul b/browser/components/preferences/tabs.xul index fc15a87ef..f5b44b776 100644 --- a/browser/components/preferences/tabs.xul +++ b/browser/components/preferences/tabs.xul @@ -84,7 +84,8 @@ <label value="&newtabPage.label;"/> <menulist id="newtabPage" - preference="browser.newtab.choice"> + preference="browser.newtab.choice" + oncommand="gTabsPane.writeNewtabUrl(event.target.value);"> <menupopup> <menuitem label="&newtabPage.custom.label;" value="0" id="newtabPageCustom" hidden="true" /> <menuitem label="&newtabPage.blank.label;" value="1" /> |