home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / firefox-3.0.14 / chrome / browser.jar / content / browser / preferences / applicationManager.js < prev    next >
Encoding:
JavaScript  |  2008-02-14  |  3.5 KB  |  98 lines

  1. //@line 37 "/build/buildd/firefox-3.0-3.0.14+build2+nobinonly/build-tree/mozilla/browser/components/preferences/applicationManager.js"
  2.  
  3. //@line 42 "/build/buildd/firefox-3.0-3.0.14+build2+nobinonly/build-tree/mozilla/browser/components/preferences/applicationManager.js"
  4.  
  5. var gAppManagerDialog = {
  6.   _removed: [],
  7.  
  8.   init: function appManager_init() {
  9.     this.handlerInfo = window.arguments[0];
  10.  
  11.     var bundle = document.getElementById("appManagerBundle");
  12.     var contentText;
  13.     if (this.handlerInfo.type == TYPE_MAYBE_FEED)
  14.       contentText = bundle.getString("handleWebFeeds");
  15.     else {
  16.       var description = gApplicationsPane._describeType(this.handlerInfo);
  17.       var key =
  18.         (this.handlerInfo.wrappedHandlerInfo instanceof Ci.nsIMIMEInfo) ? "handleFile"
  19.                                                                         : "handleProtocol";
  20.         contentText = bundle.getFormattedString(key, [description]);
  21.     }
  22.     contentText = bundle.getFormattedString("descriptionApplications", [contentText]);
  23.     document.getElementById("appDescription").textContent = contentText;
  24.  
  25.     var list = document.getElementById("appList");
  26.     var apps = this.handlerInfo.possibleApplicationHandlers.enumerate();
  27.     while (apps.hasMoreElements()) {
  28.       let app = apps.getNext();
  29.       if (!gApplicationsPane.isValidHandlerApp(app))
  30.         continue;
  31.  
  32.       app.QueryInterface(Ci.nsIHandlerApp);
  33.       var item = list.appendItem(app.name);
  34.       item.setAttribute("image", gApplicationsPane._getIconURLForHandlerApp(app));
  35.       item.className = "listitem-iconic";
  36.       item.app = app;
  37.     }
  38.  
  39.     list.selectedIndex = 0;
  40.   },
  41.  
  42.   onOK: function appManager_onOK() {
  43.     if (!this._removed.length) {
  44.       // return early to avoid calling the |store| method.
  45.       return;
  46.     }
  47.  
  48.     for (var i = 0; i < this._removed.length; ++i)
  49.       this.handlerInfo.removePossibleApplicationHandler(this._removed[i]);
  50.  
  51.     this.handlerInfo.store();
  52.   },
  53.  
  54.   onCancel: function appManager_onCancel() {
  55.     // do nothing
  56.   },
  57.  
  58.   remove: function appManager_remove() {
  59.     var list = document.getElementById("appList");
  60.     this._removed.push(list.selectedItem.app);
  61.     var index = list.selectedIndex;
  62.     list.removeItemAt(index);
  63.     if (list.getRowCount() == 0) {
  64.       // The list is now empty, make the bottom part disappear
  65.       document.getElementById("appDetails").hidden = true;
  66.     }
  67.     else {
  68.       // Select the item at the same index, if we removed the last
  69.       // item of the list, select the previous item
  70.       if (index == list.getRowCount())
  71.         --index;
  72.       list.selectedIndex = index;
  73.     }
  74.   },
  75.  
  76.   onSelect: function appManager_onSelect() {
  77.     var list = document.getElementById("appList");
  78.     if (!list.selectedItem) {
  79.       document.getElementById("remove").disabled = true;
  80.       return;
  81.     }
  82.     document.getElementById("remove").disabled = false;
  83.     var app = list.selectedItem.app;
  84.     var address = "";
  85.     if (app instanceof Ci.nsILocalHandlerApp)
  86.       address = app.executable.path;
  87.     else if (app instanceof Ci.nsIWebHandlerApp)
  88.       address = app.uriTemplate;
  89.     else if (app instanceof Ci.nsIWebContentHandlerInfo)
  90.       address = app.uri;
  91.     document.getElementById("appLocation").value = address;
  92.     var bundle = document.getElementById("appManagerBundle");
  93.     var appType = app instanceof Ci.nsILocalHandlerApp ? "descriptionLocalApp"
  94.                                                        : "descriptionWebApp";
  95.     document.getElementById("appType").value = bundle.getString(appType);
  96.   }
  97. };
  98.