1 # ***** BEGIN LICENSE BLOCK *****
2 # Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 # The contents of this file are subject to the Mozilla Public License Version
5 # 1.1 (the "License"); you may not use this file except in compliance with
6 # the License. You may obtain a copy of the License at
7 # http://www.mozilla.org/MPL/
9 # Software distributed under the License is distributed on an "AS IS" basis,
10 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 # for the specific language governing rights and limitations under the
14 # The Original Code is mozilla.org Code.
16 # The Initial Developer of the Original Code is
17 # Mozilla Corporation.
18 # Portions created by the Initial Developer are Copyright (C) 2008
19 # the Initial Developer. All Rights Reserved.
22 # Florian Queze <florian@queze.net> (Original author)
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 *****
39 var
Cc = Components.classes;
40 var
Ci = Components.interfaces;
46 init:
function appManager_init() {
47 this.handlerInfo =
window.arguments[0];
49 var
bundle = document.getElementById(
"appManagerBundle");
52 contentText = bundle.getString(
"handleWebFeeds");
54 var description = gApplicationsPane._describeType(this.handlerInfo);
56 (this.handlerInfo.wrappedHandlerInfo instanceof
Ci.nsIMIMEInfo) ?
"handleFile"
58 contentText = bundle.getFormattedString(key, [description]);
60 contentText = bundle.getFormattedString(
"descriptionApplications", [contentText]);
61 document.getElementById(
"appDescription").textContent = contentText;
63 var list = document.getElementById(
"appList");
64 var apps = this.handlerInfo.possibleApplicationHandlers.enumerate();
65 while (apps.hasMoreElements()) {
66 let app = apps.getNext();
67 if (!gApplicationsPane.isValidHandlerApp(app))
70 app.QueryInterface(
Ci.nsIHandlerApp);
71 var item = list.appendItem(app.name);
72 item.setAttribute(
"image", gApplicationsPane._getIconURLForHandlerApp(app));
73 item.className =
"listitem-iconic";
77 list.selectedIndex = 0;
80 onOK:
function appManager_onOK() {
81 if (!this._removed.length) {
86 for (var
i = 0;
i < this._removed.length; ++
i)
87 this.handlerInfo.removePossibleApplicationHandler(
this._removed[
i]);
89 this.handlerInfo.store();
92 onCancel:
function appManager_onCancel() {
96 remove:
function appManager_remove() {
97 var list = document.getElementById(
"appList");
98 this._removed.push(list.selectedItem.app);
99 var index = list.selectedIndex;
100 list.removeItemAt(index);
101 if (list.getRowCount() == 0) {
103 document.getElementById(
"appDetails").hidden =
true;
108 if (index == list.getRowCount())
110 list.selectedIndex = index;
114 onSelect:
function appManager_onSelect() {
115 var list = document.getElementById(
"appList");
116 if (!list.selectedItem) {
117 document.getElementById(
"remove").disabled =
true;
120 document.getElementById(
"remove").disabled =
false;
121 var app = list.selectedItem.app;
123 if (app instanceof
Ci.nsILocalHandlerApp)
124 address = app.executable.path;
125 else if (app instanceof
Ci.nsIWebHandlerApp)
126 address = app.uriTemplate;
127 else if (app instanceof
Ci.nsIWebContentHandlerInfo)
129 document.getElementById(
"appLocation").value = address;
130 var
bundle = document.getElementById(
"appManagerBundle");
131 var appType = app instanceof
Ci.nsILocalHandlerApp ?
"descriptionLocalApp"
132 :
"descriptionWebApp";
133 document.getElementById(
"appType").value = bundle.getString(appType);
_dialogDatepicker onSelect
_getSelectedPageStyle s i