Bug 191578 "Close Other Tabs" confirmation dialog p=tmeader@gmail.com r=me sr=jag

git-svn-id: svn://10.0.0.236/trunk@156320 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
neil%parkwaycc.co.uk 2004-05-12 21:45:25 +00:00
parent b4bc041626
commit 92d5e3bbfc
3 changed files with 48 additions and 8 deletions

View File

@ -137,6 +137,7 @@ pref("browser.tabs.opentabfor.urlbar", false);
pref("browser.tabs.opentabfor.windowopen", false);
pref("browser.tabs.opentabfor.bookmarks", false);
pref("browser.tabs.warnOnClose", true);
pref("browser.tabs.warnOnCloseOther", true);
// 0 = append, 1 = replace
pref("browser.tabs.loadGroup", 1);

View File

@ -850,15 +850,50 @@
<parameter name="aTab"/>
<body>
<![CDATA[
if (aTab.localName != "tab")
aTab = this.mCurrentTab;
else
this.mTabContainer.selectedItem = aTab;
var numTabs = this.mTabContainer.childNodes.length;
var childNodes = this.mTabContainer.childNodes;
for (var i = childNodes.length - 1; i >= 0; --i) {
if (childNodes[i] != aTab)
this.removeTab(childNodes[i]);
if (numTabs > 1) {
const closeOtherTabsPref = "browser.tabs.warnOnCloseOther";
var shouldPrompt = this.mPrefs.getBoolPref(closeOtherTabsPref);
var reallyClose = true;
if (shouldPrompt) {
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
//default to true: if it were false, we wouldn't get this far
var warnOnClose = { value:true };
var bundle = this.mStringBundle;
var tabsToClose = numTabs - 1; //number of tabs to be removed
var buttonPressed = promptService.confirmEx(window,
bundle.getString('tabs.closeWarningTitle'),
bundle.getFormattedString("tabs.closeWarning", [tabsToClose]),
(promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_0)
+ (promptService.BUTTON_TITLE_CANCEL * promptService.BUTTON_POS_1),
bundle.getString('tabs.closeButton'),
null, null,
bundle.getString('tabs.closeWarningPromptMe'),
warnOnClose);
reallyClose = (buttonPressed == 0);
//don't set the pref unless they press OK and it's false
if (reallyClose && !warnOnClose.value)
this.mPrefs.setBoolPref(closeOtherTabsPref, false);
}
if (reallyClose) {
if (aTab.localName != "tab")
aTab = this.mCurrentTab;
else
this.mTabContainer.selectedItem = aTab;
var childNodes = this.mTabContainer.childNodes;
for (var i = childNodes.length - 1; i >= 0; --i) {
if (childNodes[i] != aTab)
this.removeTab(childNodes[i]);
}
}
}
]]>
</body>

View File

@ -1,5 +1,9 @@
tabs.loading=Loading...
tabs.untitled=(Untitled)
tabs.closeWarningTitle=Confirm Closing Other Tabs
tabs.closeWarning=You are about to close %S other tab(s). Are you sure you want to continue?
tabs.closeButton=Close other tabs
tabs.closeWarningPromptMe=Warn me when I attempt to close other tabs
browsewithcaret.checkMsg=Do not show me this dialog box again.
browsewithcaret.checkWindowTitle=Caret Browsing
browsewithcaret.checkLabel=Pressing F7 turns Caret Browsing on or off. This feature places a moveable cursor in web pages, allowing you to select text with the keyboard. Do you want to turn Caret Browsing on?