!import
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1 //@line 37 "/home/visbrero/mnt/roisin/rev_control/hg/mozilla/toolkit/mozapps/xpinstall/content/xpinstallConfirm.js"
2
3 var XPInstallConfirm =
4 {
5 _param: null
6 };
7
8
anon:9:24
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
9 XPInstallConfirm.init = function ()
10 {
11 var _installCountdown;
12 var _installCountdownInterval;
13 var _focused;
14 var _timeout;
15
16 var bundle = document.getElementById("xpinstallConfirmStrings");
17
18 this._param = window.arguments[0].QueryInterface(Components.interfaces.nsIDialogParamBlock);
19 if (!this._param)
20 close();
21
22 this._param.SetInt(0, 1); // The default return value is "Cancel"
23
24 var _installCountdownLength = 5;
25 try {
26 var prefs = Components.classes["@mozilla.org/preferences-service;1"]
27 .getService(Components.interfaces.nsIPrefBranch);
28 var delay_in_milliseconds = prefs.getIntPref("security.dialog_enable_delay");
29 _installCountdownLength = Math.round(delay_in_milliseconds / 500);
30 } catch (ex) { }
31
32 var itemList = document.getElementById("itemList");
33
34 var numItemsToInstall = this._param.GetInt(1);
35 for (var i = 0; i < numItemsToInstall; ++i) {
36 var installItem = document.createElement("installitem");
37 itemList.appendChild(installItem);
38
39 installItem.name = this._param.GetString(i);
40 installItem.url = this._param.GetString(++i);
41 var icon = this._param.GetString(++i);
42 if (icon != "")
43 installItem.icon = icon;
44 var cert = this._param.GetString(++i);
45 if (cert)
46 installItem.cert = bundle.getFormattedString("signed", [cert]);
47 else
48 installItem.cert = bundle.getString("unverified");
49 installItem.signed = cert ? "true" : "false";
50 }
51
52 var introString = bundle.getString("itemWarnIntroSingle");
53 if (numItemsToInstall > 4)
54 introString = bundle.getFormattedString("itemWarnIntroMultiple", [numItemsToInstall / 4]);
55 if (this._param.objects && this._param.objects.length)
56 introString = this._param.objects.queryElementAt(0, Components.interfaces.nsISupportsString).data;
57 var textNode = document.createTextNode(introString);
58 var introNode = document.getElementById("itemWarningIntro");
59 while (introNode.hasChildNodes())
60 introNode.removeChild(introNode.firstChild);
61 introNode.appendChild(textNode);
62
63 var okButton = document.documentElement.getButton("accept");
64 okButton.focus();
65
okButtonCountdown
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
66 function okButtonCountdown() {
67 _installCountdown -= 1;
68
69 if (_installCountdown < 1) {
70 okButton.label = bundle.getString("installButtonLabel");
71 okButton.disabled = false;
72 clearInterval(_installCountdownInterval);
73 }
74 else
75 okButton.label = bundle.getFormattedString("installButtonDisabledLabel", [_installCountdown]);
76 }
77
myfocus
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
78 function myfocus() {
79 // Clear the timeout if it exists so only the last one will be used.
80 if (_timeout)
81 clearTimeout(_timeout);
82
83 // Use setTimeout since the last focus or blur event to fire is the one we
84 // want
85 _timeout = setTimeout(setWidgetsAfterFocus, 0);
86 }
87
setWidgetsAfterFocus
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
88 function setWidgetsAfterFocus() {
89 if (_focused)
90 return;
91
92 _installCountdown = _installCountdownLength;
93 _installCountdownInterval = setInterval(okButtonCountdown, 500);
94 okButton.label = bundle.getFormattedString("installButtonDisabledLabel", [_installCountdown]);
95 _focused = true;
96 }
97
myblur
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
98 function myblur() {
99 // Clear the timeout if it exists so only the last one will be used.
100 if (_timeout)
101 clearTimeout(_timeout);
102
103 // Use setTimeout since the last focus or blur event to fire is the one we
104 // want
105 _timeout = setTimeout(setWidgetsAfterBlur, 0);
106 }
107
setWidgetsAfterBlur
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
108 function setWidgetsAfterBlur() {
109 if (!_focused)
110 return;
111
112 // Set _installCountdown to the inital value set in setWidgetsAfterFocus
113 // plus 1 so when the window is focused there is immediate ui feedback.
114 _installCountdown = _installCountdownLength + 1;
115 okButton.label = bundle.getFormattedString("installButtonDisabledLabel", [_installCountdown]);
116 okButton.disabled = true;
117 clearInterval(_installCountdownInterval);
118 _focused = false;
119 }
120
myUnload
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
121 function myUnload() {
122 document.removeEventListener("focus", myfocus, true);
123 document.removeEventListener("blur", myblur, true);
124 window.removeEventListener("unload", myUnload, false);
125 }
126
127 if (_installCountdownLength > 0) {
128 document.addEventListener("focus", myfocus, true);
129 document.addEventListener("blur", myblur, true);
130 window.addEventListener("unload", myUnload, false);
131
132 okButton.disabled = true;
133 setWidgetsAfterFocus();
134 }
135 else
136 okButton.label = bundle.getString("installButtonLabel");
137 }
138
anon:139:24
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
139 XPInstallConfirm.onOK = function ()
140 {
141 this._param.SetInt(0, 0);
142 return true;
143 }
144
anon:145:28
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
145 XPInstallConfirm.onCancel = function ()
146 {
147 this._param.SetInt(0, 1);
148 return true;
149 }