Bug 558461 - Don't warn about closing multiple tabs when closing only one tab. r=gavin, ui-r=faaborg

This commit is contained in:
Dão Gottwald 2010-04-12 10:01:34 +02:00
Родитель ae7a751767
Коммит d82ce495cd
2 изменённых файлов: 34 добавлений и 36 удалений

Просмотреть файл

@ -1286,46 +1286,46 @@
<parameter name="aAll"/>
<body>
<![CDATA[
var numTabs = this.tabs.length;
var reallyClose = true;
if (numTabs <= 1)
return reallyClose;
var tabsToClose = this.tabs.length;
if (!aAll)
--tabsToClose;
if (tabsToClose <= 1)
return true;
const pref = "browser.tabs.warnOnClose";
var shouldPrompt = Services.prefs.getBoolPref(pref);
if (shouldPrompt) {
let promptService = Services.prompt;
if (!shouldPrompt)
return true;
//default to true: if it were false, we wouldn't get this far
var warnOnClose = { value:true };
var bundle = this.mStringBundle;
var tabsToClose = numTabs; //number of tabs to be removed
if (!aAll)
--tabsToClose;
var ps = Services.prompt;
// default to true: if it were false, we wouldn't get this far
var warnOnClose = { value: true };
var bundle = this.mStringBundle;
// focus the window before prompting.
// this will raise any minimized window, which will
// make it obvious which window the prompt is for and will
// solve the problem of windows "obscuring" the prompt.
// see bug #350299 for more details
window.focus();
var buttonPressed =
ps.confirmEx(window,
bundle.getString("tabs.closeWarningTitle"),
bundle.getFormattedString("tabs.closeWarningMultipleTabs",
[tabsToClose]),
(ps.BUTTON_TITLE_IS_STRING * ps.BUTTON_POS_0)
+ (ps.BUTTON_TITLE_CANCEL * ps.BUTTON_POS_1),
bundle.getString("tabs.closeButtonMultiple"),
null, null,
bundle.getString('tabs.closeWarningPromptMe'),
warnOnClose);
var reallyClose = (buttonPressed == 0);
// don't set the pref unless they press OK and it's false
if (reallyClose && !warnOnClose.value)
Services.prefs.setBoolPref(pref, false);
var messageKey = (tabsToClose == 1) ? "tabs.closeWarningOneTab" : "tabs.closeWarningMultipleTabs";
var closeKey = (tabsToClose == 1) ? "tabs.closeButtonOne" : "tabs.closeButtonMultiple";
// focus the window before prompting.
// this will raise any minimized window, which will
// make it obvious which window the prompt is for and will
// solve the problem of windows "obscuring" the prompt.
// see bug #350299 for more details
window.focus();
var buttonPressed = promptService.confirmEx(window,
bundle.getString('tabs.closeWarningTitle'),
bundle.getFormattedString(messageKey, [tabsToClose]),
(promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_0)
+ (promptService.BUTTON_TITLE_CANCEL * promptService.BUTTON_POS_1),
bundle.getString(closeKey),
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)
Services.prefs.setBoolPref(pref, false);
}
return reallyClose;
]]>
</body>

Просмотреть файл

@ -3,8 +3,6 @@ tabs.emptyTabTitle=New Tab
tabs.closeTab=Close Tab
tabs.close=Close
tabs.closeWarningTitle=Confirm close
tabs.closeWarningOneTab=You are about to close %S tab. Are you sure you want to continue?
tabs.closeWarningMultipleTabs=You are about to close %S tabs. Are you sure you want to continue?
tabs.closeButtonOne=Close tab
tabs.closeButtonMultiple=Close tabs
tabs.closeWarningPromptMe=Warn me when I attempt to close multiple tabs