home *** CD-ROM | disk | FTP | other *** search
/ Chip 2011 November / CHIP_2011_11.iso / Programy / Narzedzia / AIMP2 / aimp_2.61.583.exe / $TEMP / YandexPackSetup.msi / fil0BF1E4021DE73CEFBD37B07B2A7AFB24 < prev    next >
Text File  |  2010-07-12  |  7KB  |  200 lines

  1. var YaSearchPrefs = {
  2.     nsIYa: Cc["@yandex.ru/yasearch;1"].getService(Ci.nsIYaSearch).wrappedJSObject,
  3.     
  4.     setYandexAsHomepage: function YaSearchPrefs_setYandexAsHomepage() {
  5.         this.nsIYa.setHomePageUrl(true);
  6.     },
  7.     
  8.     readUrlbarCorrectorState: function YaSearchPrefs_readUrlbarCorrectorState() {
  9.         return (this.nsIYa.KeyCorrector.currentState > 0);
  10.     },
  11.     
  12.     writeUrlbarCorrectorState: function YaSearchPrefs_writeUrlbarCorrectorState(aCheckbox) {
  13.         let res = aCheckbox && aCheckbox.checked ? 2 : 0;
  14.         this.nsIYa.KeyCorrector.currentState = res;
  15.         return res;
  16.     },
  17.     
  18.     loadHelpURI: function YaSearchPrefs_loadHelpURI() {
  19.         this.nsIYa.loadURI(this.nsIYa.getLocaleDependedUrl("HelpPageUrl"), "window", {action:3000});
  20.     },
  21.     
  22.     get _toolbar() {
  23.         return Preferences.gBrowser[APP_NAME + "OverlayController"]._appToolbar;
  24.     },
  25.     
  26.     _setToolbarMode: function YaSearchPrefs__setToolbarMode(aDontCheckInstApply, aMode) {
  27.         if (!(aDontCheckInstApply || Preferences.instantApply))
  28.             return;
  29.         
  30.         let toolbarMode = this._toolbar.getAttribute("mode");
  31.         
  32.         let changedToolbarMode = aMode || document.getElementById("misc-prefs-ui-buttons-text-checkbox")
  33.                                                   .getAttribute("currentToolbarMode");
  34.         
  35.         if (changedToolbarMode != toolbarMode) {
  36.             this._toolbar.setAttribute("mode", changedToolbarMode);
  37.             this._toolbar.ownerDocument.persist("yasearch-bar", "mode");
  38.         }
  39.     },
  40.     
  41.     _inited: false,
  42.     
  43.     onPaneLoad: function YaSearchPrefs_onPaneLoad() {
  44.         if (this._inited)
  45.             return;
  46.         
  47.         this._inited = true;
  48.         
  49.         let toolbarMode = this._toolbar.getAttribute("mode");
  50.         
  51.         let showButtonsTextCheckbox = document.getElementById("misc-prefs-ui-buttons-text-checkbox");
  52.         showButtonsTextCheckbox.setAttribute("currentToolbarMode", toolbarMode);
  53.         showButtonsTextCheckbox.setAttribute("checked", (toolbarMode == "icons" ? "false" : "true"));
  54.         showButtonsTextCheckbox.setAttribute("oncommand",
  55.             "this.setAttribute('currentToolbarMode', this.checked ? 'full' : 'icons'); \
  56.              YaSearchPrefs._setToolbarMode(false);");
  57.         
  58.         if (!this.nsIYa.yaGeolocation)
  59.             document.getElementById("yasearch-geolocation-checkbox").hidden = true;
  60.     },
  61.     
  62.     onDialogAccept: function YaSearchPrefs_onDialogAccept() {
  63.         if (!this._inited)
  64.             return;
  65.         
  66.         this._setToolbarMode(true);
  67.     },
  68.     
  69.     onDialogUnload: function YaSearchPrefs_onDialogUnload() {
  70.     }
  71. }
  72.  
  73. var StaticHelper = {
  74.     nsIYa: Cc["@yandex.ru/yasearch;1"].getService(Ci.nsIYaSearch).wrappedJSObject,
  75.     
  76.     OBSERVER_SERVICE: Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService),
  77.     
  78.     get browsers() {
  79.         return this.nsIYa.getWindows("navigator:browser");
  80.     },
  81.     
  82.     get _toolbar() {
  83.         return Preferences.gBrowser[APP_NAME + "OverlayController"]._appToolbar;
  84.     },
  85.     
  86.     onRestoreDefault: function StaticHelper_onRestoreDefault() {
  87.         let searchbox = this._toolbar.ownerDocument.getElementById("yasearchbox");
  88.         if (searchbox) {
  89.             let defWidth = parseInt(searchbox.getAttribute("yaDefaultWidth"),10);
  90.             
  91.             if (defWidth) {
  92.                 searchbox.setAttribute("width", defWidth);
  93.                 if ("updateWidthOnResize" in searchbox)
  94.                     searchbox.updateWidthOnResize();
  95.             } else {
  96.                 ["width", "yaSHistoryWidth"].forEach(function(aAttrName) {
  97.                     if (this.hasAttribute(aAttrName))
  98.                         this.removeAttribute(aAttrName);
  99.                 }, searchbox);
  100.             }
  101.         }
  102.         
  103.         [".general.ui.translate."]
  104.         .forEach(function(aPrefBranch) {
  105.           try {
  106.             this.resetBranch(APP_NAME + aPrefBranch);
  107.           } catch(ex) {}
  108.         }, Preferences.barCore.Preferences);
  109.     },
  110.     
  111.     _inited: false,
  112.     
  113.     onPaneLoad: function StaticHelper_onPaneLoad() {
  114.         if (this._inited)
  115.             return;
  116.         
  117.         this._inited = true;
  118.     },
  119.     
  120.     onWindowBeforeUnload: function StaticHelper_onWindowBeforeUnload() {
  121.         if (!this._inited)
  122.             return;
  123.         
  124.         this._inited = false;
  125.         
  126.         for each (let browser in this.browsers) {
  127.           browser.Ya.updateFeedsAttribute();
  128.           
  129.           let bloggers = browser.Ya.Bloggers;
  130.           if (bloggers)
  131.             bloggers.checkWindowState();
  132.         }
  133.         
  134.         this.nsIYa.refreshCYInAllBrowsers();
  135.         
  136.         this.OBSERVER_SERVICE.notifyObservers(null, "Ya-Refresh-Login-Status", false);
  137.     },
  138.     
  139.     syncHttpUpdateEnabled: function StaticHelper_syncHttpUpdateEnabled(aCheckbox) {
  140.         setTimeout(function(aCheckbox) {
  141.           let disabled = !aCheckbox.checked;
  142.           aCheckbox.nextSibling.disabled = disabled;
  143.         }, 1, aCheckbox);
  144.     },
  145.     
  146.     Sound: {
  147.         sync: function StaticHelper_Sound_sync(aType) {
  148.             setTimeout(function() {
  149.                 let prfx = "wgt-" + aType + "-soundnotification-";
  150.                 let disabled = !document.getElementById(prfx + "enabled").checked;
  151.                 let textbox = document.getElementById(prfx + "textbox");
  152.                 
  153.                 document.getElementById(prfx + "select").disabled = textbox.disabled = disabled;
  154.                 document.getElementById(prfx + "preview").disabled = !(!disabled && !!textbox.value);
  155.             }, 1);
  156.         },
  157.  
  158.         select: function StaticHelper_Sound_select(aType) {
  159.             const nsIFilePicker = Ci.nsIFilePicker;
  160.  
  161.             let filepicker = Cc["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker);
  162.  
  163.             let stringBundle = StaticHelper.nsIYa.getStringBundle("preferences/preferences.properties");
  164.  
  165.             filepicker.init(window, stringBundle.GetStringFromName("ChooseASoundFile"), nsIFilePicker.modeOpen);
  166.             filepicker.appendFilter(stringBundle.GetStringFromName("ChooseASoundFilterWav"), "*.wav;*.mp3");
  167.             filepicker.appendFilter(stringBundle.GetStringFromName("ChooseASoundFilterAll"), "*.*");
  168.  
  169.             let ret = filepicker.show();
  170.  
  171.             if (ret == nsIFilePicker.returnOK) {
  172.                 let textbox = document.getElementById("wgt-" + aType + "-soundnotification-textbox");
  173.                 textbox.value = filepicker.file.path;
  174.                 textbox.doCommand();
  175.             }
  176.  
  177.             this.sync(aType);
  178.         },
  179.  
  180.         play: function StaticHelper_Sound_play(aType) {
  181.             StaticHelper.nsIYa.playSoundURL(document.getElementById("wgt-" + aType + "-soundnotification-textbox").value);
  182.         }
  183.     },
  184.     
  185.     Container: {
  186.         _historyParamName: "yasearch-history",
  187.         
  188.         _nsIFormHistory: Cc["@mozilla.org/satchel/form-history;1"].getService(Ci.nsIFormHistory2),
  189.         
  190.         checkClearButtonState: function() {
  191.             document.getElementById("wgt-container-clear-history-button")
  192.                 .disabled = !this._nsIFormHistory.nameExists(this._historyParamName);
  193.         },
  194.         
  195.         clearSearchHistory: function() {
  196.             this._nsIFormHistory.removeEntriesForName(this._historyParamName);
  197.             this.checkClearButtonState();
  198.         }
  199.     }
  200. };