1 # -*- Mode
: Java
; tab
-width
: 4; indent
-tabs
-mode
: nil
; c
-basic
-offset
: 4 -*-
2 # ***** BEGIN LICENSE BLOCK
*****
3 # Version
: MPL
1.1/GPL 2.0/LGPL
2.1
5 # The contents
of this file are subject to the Mozilla Public License Version
6 # 1.1 (the
"License"); you may not
use this file except
in compliance
with
7 # the License
. You may obtain a copy
of the License at
8 # http
://www.mozilla.org/MPL/
10 # Software distributed under the License is distributed on an
"AS IS" basis
,
11 # WITHOUT WARRANTY OF ANY KIND
, either express or implied
. See the License
12 # for the specific language governing rights and limitations under the
15 # The Original Code is Mozilla
.org Code
.
17 # The Initial Developer
of the Original Code is Ben Goodger
.
18 # Portions created by the Initial Developer are
Copyright (C
) 2001
19 # the Initial Developer
. All Rights Reserved
.
22 # Ben Goodger
<ben
@bengoodger
.com
> (v2
.0)
24 # Alternatively
, the contents
of this file may be used under the terms
of
25 # either the GNU General Public License Version
2 or
later (the
"GPL"), or
26 # the GNU Lesser General Public License Version
2.1 or
later (the
"LGPL"),
27 # in which
case the provisions
of the GPL or the LGPL are applicable instead
28 # of those above
. If you wish to allow
use of your version
of this file only
29 # under the terms
of either the GPL or the LGPL
, and not to allow others to
30 # use your version
of this file under the terms
of the MPL
, indicate your
31 # decision by deleting the provisions above and replace them
with the notice
32 # and other provisions required by the GPL or the LGPL
. If you
do not
delete
33 # the provisions above
, a recipient may
use your version
of this file under
34 # the terms
of any one
of the MPL
, the GPL or the LGPL
.
36 # ***** END LICENSE BLOCK
*****
38 var XPInstallConfirm
=
44 XPInstallConfirm
.init = function ()
46 var _installCountdown
;
47 var _installCountdownInterval
;
51 var bundle
= document
.getElementById("xpinstallConfirmStrings");
53 this._param
= window
.arguments
[0].QueryInterface(Components
.interfaces
.nsIDialogParamBlock
);
57 this._param
.SetInt(0, 1); // The default return value is "Cancel"
59 var _installCountdownLength
= 5;
61 var prefs
= Components
.classes
["@mozilla.org/preferences-service;1"]
62 .getService(Components
.interfaces
.nsIPrefBranch
);
63 var delay_in_milliseconds
= prefs
.getIntPref("security.dialog_enable_delay");
64 _installCountdownLength
= Math
.round(delay_in_milliseconds
/ 500);
67 var itemList
= document
.getElementById("itemList");
69 var numItemsToInstall
= this._param
.GetInt(1);
70 for (var i
= 0; i
< numItemsToInstall
; ++i
) {
71 var installItem
= document
.createElement("installitem");
72 itemList
.appendChild(installItem
);
74 installItem
.name
= this._param
.GetString(i
);
75 installItem
.url
= this._param
.GetString(++i
);
76 var icon
= this._param
.GetString(++i
);
78 installItem
.icon
= icon
;
79 var cert
= this._param
.GetString(++i
);
81 installItem
.cert
= bundle
.getFormattedString("signed", [cert
]);
83 installItem
.cert
= bundle
.getString("unverified");
84 installItem
.signed
= cert
? "true" : "false";
87 var introString
= bundle
.getString("itemWarnIntroSingle");
88 if (numItemsToInstall
> 4)
89 introString
= bundle
.getFormattedString("itemWarnIntroMultiple", [numItemsToInstall
/ 4]);
90 if (this._param
.objects
&& this._param
.objects
.length
)
91 introString
= this._param
.objects
.queryElementAt(0, Components
.interfaces
.nsISupportsString
).data
;
92 var textNode
= document
.createTextNode(introString
);
93 var introNode
= document
.getElementById("itemWarningIntro");
94 while (introNode
.hasChildNodes())
95 introNode
.removeChild(introNode
.firstChild
);
96 introNode
.appendChild(textNode
);
98 var okButton
= document
.documentElement
.getButton("accept");
101 function okButtonCountdown() {
102 _installCountdown
-= 1;
104 if (_installCountdown
< 1) {
105 okButton
.label
= bundle
.getString("installButtonLabel");
106 okButton
.disabled
= false;
107 clearInterval(_installCountdownInterval
);
110 okButton
.label
= bundle
.getFormattedString("installButtonDisabledLabel", [_installCountdown
]);
114 // Clear the timeout if it exists so only the last one will be used.
116 clearTimeout(_timeout
);
118 // Use setTimeout since the last focus or blur event to fire is the one we
120 _timeout
= setTimeout(setWidgetsAfterFocus
, 0);
123 function setWidgetsAfterFocus() {
127 _installCountdown
= _installCountdownLength
;
128 _installCountdownInterval
= setInterval(okButtonCountdown
, 500);
129 okButton
.label
= bundle
.getFormattedString("installButtonDisabledLabel", [_installCountdown
]);
134 // Clear the timeout if it exists so only the last one will be used.
136 clearTimeout(_timeout
);
138 // Use setTimeout since the last focus or blur event to fire is the one we
140 _timeout
= setTimeout(setWidgetsAfterBlur
, 0);
143 function setWidgetsAfterBlur() {
147 // Set _installCountdown to the inital value set in setWidgetsAfterFocus
148 // plus 1 so when the window is focused there is immediate ui feedback.
149 _installCountdown
= _installCountdownLength
+ 1;
150 okButton
.label
= bundle
.getFormattedString("installButtonDisabledLabel", [_installCountdown
]);
151 okButton
.disabled
= true;
152 clearInterval(_installCountdownInterval
);
156 function myUnload() {
157 document
.removeEventListener("focus", myfocus
, true);
158 document
.removeEventListener("blur", myblur
, true);
159 window
.removeEventListener("unload", myUnload
, false);
162 if (_installCountdownLength
> 0) {
163 document
.addEventListener("focus", myfocus
, true);
164 document
.addEventListener("blur", myblur
, true);
165 window
.addEventListener("unload", myUnload
, false);
167 okButton
.disabled
= true;
168 setWidgetsAfterFocus();
171 okButton
.label
= bundle
.getString("installButtonLabel");
174 XPInstallConfirm
.onOK = function ()
176 this._param
.SetInt(0, 0);
180 XPInstallConfirm
.onCancel = function ()
182 this._param
.SetInt(0, 1);