home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2005 October / Gamestar_77_2005-10_dvd.iso / Programy / nsb-install-8-0.exe / chrome / toolkit.jar / content / mozapps / update / updates.xml < prev   
Extensible Markup Language  |  2005-07-29  |  11KB  |  283 lines

  1. <?xml version="1.0"?>
  2.  
  3. <!DOCTYPE bindings SYSTEM "chrome://mozapps/locale/update/update.dtd">
  4.  
  5. <bindings id="updatesBindings"
  6.           xmlns="http://www.mozilla.org/xbl"
  7.           xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  8.           xmlns:xbl="http://www.mozilla.org/xbl">
  9.  
  10.   <binding id="updateStatusbarNotification" 
  11.            extends="chrome://global/content/bindings/toolbarbutton.xml#toolbarbutton-image">
  12.     <resources>
  13.       <stylesheet src="chrome://mozapps/skin/update/update.css"/>
  14.     </resources>
  15.     <implementation implements="nsIObserver">
  16.       <destructor>
  17.       <![CDATA[
  18.         var os = Components.classes["@mozilla.org/observer-service;1"]
  19.                            .getService(Components.interfaces.nsIObserverService);
  20.         // MRR The reason for these failures should be determined and corrected.
  21.         try { os.removeObserver(this, "Update:Ended"); } catch(e) {}
  22.         try { os.removeObserver(this, "Update:Extension:Item-Ended"); } catch(e) {}
  23.         try { os.removeObserver(this, "Update:App:Ended"); } catch(e) {}
  24.       ]]>  
  25.       </destructor>
  26.  
  27.       <method name="init">
  28.         <body>
  29.         <![CDATA[
  30.           var os = Components.classes["@mozilla.org/observer-service;1"]
  31.                              .getService(Components.interfaces.nsIObserverService);
  32.           os.addObserver(this, "Update:Ended", false);
  33.           os.addObserver(this, "Update:Extension:Item-Ended", false);
  34.           os.addObserver(this, "Update:App:Ended", false);
  35.           
  36.           this.refreshData();
  37.         ]]>
  38.         </body>
  39.       </method>
  40.       
  41.       <method name="observe">
  42.         <parameter name="aSubject"/>
  43.         <parameter name="aTopic"/>
  44.         <parameter name="aData"/>
  45.         <body>
  46.         <![CDATA[
  47.           switch (aTopic) {
  48.           case "Update:Extension:Item-Ended":
  49.           case "Update:App:Ended":
  50.           case "Update:Ended":
  51.             this.refreshData();
  52.           }
  53.         ]]>
  54.         </body>
  55.       </method>
  56.       
  57.       <method name="refreshData">
  58.         <body>
  59.         <![CDATA[
  60.           var updates = Components.classes["@mozilla.org/updates/update-service;1"]
  61.                                   .getService(Components.interfaces.nsIUpdateService);
  62.           this.severity     = updates.updateSeverity;
  63.           this.updateCount  = updates.updateCount;
  64.           
  65.           var sbs = Components.classes["@mozilla.org/intl/stringbundle;1"]
  66.                               .getService(Components.interfaces.nsIStringBundleService);
  67.           var updateStrings = sbs.createBundle("chrome://mozapps/locale/update/update.properties");
  68.           var key;
  69.           if (this.updateCount > 0)
  70.             key = "updatesAvailableTooltip-" + this.severity;
  71.           else
  72.             key = "updatesCheckForUpdatesTooltip";
  73.           var tooltip = updateStrings.GetStringFromName(key);
  74.           this.setAttribute("tooltiptext", tooltip);
  75.         ]]>
  76.         </body>
  77.       </method>
  78.  
  79.       <method name="showUpdates">
  80.         <body>
  81.         <![CDATA[
  82.           var updates = Components.classes["@mozilla.org/updates/update-service;1"]
  83.                                   .getService(Components.interfaces.nsIUpdateService);
  84.           updates.checkForUpdates([], 0, Components.interfaces.nsIUpdateItem.TYPE_ANY, 
  85.                                   Components.interfaces.nsIUpdateService.SOURCE_EVENT_USER,
  86.                                   window);
  87.         ]]>
  88.         </body>
  89.       </method>
  90.       
  91.       <property name="severity"     onset="this.setAttribute('severity', val); return val;"
  92.                                     onget="return this.getAttribute('severity');"/>
  93.       <property name="updateCount"  onset="this.setAttribute('updateCount', val); return val;"
  94.                                     onget="return this.getAttribute('updateCount');"/>
  95.     </implementation>
  96.     <handlers>
  97.       <handler event="command">
  98.       <![CDATA[
  99.         this.showUpdates();
  100.       ]]>
  101.       </handler>
  102.     </handlers>
  103.   </binding>
  104.   
  105.   <binding id="updateCategorySet" extends="chrome://global/content/bindings/radio.xml#radiogroup">
  106.     <implementation>
  107.       <method name="computeSizes">
  108.         <body>
  109.         <![CDATA[
  110.           var kids = this._getRadioChildren();
  111.           for (var i = 0; i < kids.length; ++i)
  112.             kids[i].expandedHeight = kids[i]._content.boxObject.height;
  113.           this.removeAttribute("_uninitialized");
  114.         ]]>
  115.         </body>
  116.       </method>
  117.       <field name="lastSelectedItem">null</field>
  118.     </implementation>
  119.   </binding>
  120.   
  121.   <binding id="updateCategory" extends="chrome://global/content/bindings/radio.xml#radio">
  122.     <resources>
  123.       <stylesheet src="chrome://global/skin/radio.css"/>
  124.       <stylesheet src="chrome://mozapps/skin/update/update.css"/>
  125.     </resources>
  126.     <content>
  127.       <xul:hbox class="updateCategoryBox" xbl:inherits="selected,checked,disabled">
  128.         <xul:hbox class="radio-check-box1" xbl:inherits="selected,checked,disabled">
  129.           <xul:hbox class="radio-check-box2" flex="1">
  130.             <xul:image class="radio-check" xbl:inherits="selected,checked,disabled"/>
  131.           </xul:hbox>
  132.         </xul:hbox>
  133.         <xul:image class="updateCategoryIcon" xbl:inherits="src"/>
  134.         <xul:label class="updateCategoryLabel" xbl:inherits="xbl:text=label,accesskey,crop,selected" flex="1"/>
  135.       </xul:hbox>
  136.       <xul:vbox flex="1" class="updateCategoryContent">
  137.         <children/>
  138.       </xul:vbox>
  139.     </content>  
  140.     <implementation implements="nsITimerCallback">
  141.       <property name="expandedHeight" 
  142.                 onget="return this.getAttribute('expandedHeight');"
  143.                 onset="this.setAttribute('expandedHeight', val); return val;"/>
  144.       
  145.       <method name="notify">
  146.         <parameter name="aTimer"/>
  147.         <body>
  148.         <![CDATA[
  149.             var newHeight;
  150.             if (this._destinationSize == 0) {
  151.               if (this._content.boxObject.height > 0) {
  152.                 newHeight = this._content.boxObject.height - this._animateIncrement;
  153.                 newHeight = newHeight < 0 ? 0 : newHeight;
  154.                 this._content.style.height = newHeight + "px";
  155.                 this._timer.initWithCallback(this, this._animateDelay, 
  156.                                              Components.interfaces.nsITimer.TYPE_ONE_SHOT);
  157.               }
  158.               else {
  159.                 this._timer.cancel();
  160.                 this._content.style.visibility = "collapse";
  161.               }
  162.             }
  163.             else {
  164.               if (this._content.boxObject.height <= this._destinationSize) {
  165.                 newHeight = this._content.boxObject.height + this._animateIncrement;
  166.                 newHeight = newHeight > this.expandedHeight ? this.expandedHeight : newHeight;
  167.                 this._content.style.height = newHeight + "px";
  168.                 this._timer.initWithCallback(this, this._animateDelay, 
  169.                                              Components.interfaces.nsITimer.TYPE_ONE_SHOT);
  170.               }
  171.               else
  172.                 this._timer.cancel();
  173.             }
  174.         ]]>
  175.         </body>
  176.       </method>
  177.       
  178.       <method name="_setUpTimer">
  179.         <parameter name="aSelected"/>
  180.         <body>
  181.         <![CDATA[
  182.           if (!this._timer) 
  183.             this._timer = Components.classes["@mozilla.org/timer;1"]
  184.                                     .createInstance(Components.interfaces.nsITimer);
  185.           else
  186.             this._timer.cancel();
  187.           
  188.           this._content.style.visibility = "visible";
  189.  
  190.           this._destinationSize = aSelected ? this.expandedHeight : 0;
  191.           this._timer.initWithCallback(this, this._animateDelay, 
  192.                                        Components.interfaces.nsITimer.TYPE_ONE_SHOT);
  193.         ]]>
  194.         </body>
  195.       </method>
  196.       
  197.       <field name="_content">
  198.         document.getAnonymousElementByAttribute(this, "class", "updateCategoryContent");
  199.       </field>
  200.       <field name="_timer">null</field>
  201.       <field name="_animateDelay">50</field>
  202.       <field name="_animateIncrement">25</field>
  203.       <field name="_destinationSize">0</field>
  204.     </implementation>
  205.     <handlers>
  206.       <handler event="RadioStateChange">
  207.       <![CDATA[
  208.       /*
  209.         this._content.style.height = "0px";
  210.         
  211.         if (this.radioGroup.lastSelectedItem)
  212.           this.radioGroup.lastSelectedItem._setUpTimer(false);
  213.         this.radioGroup.lastSelectedItem = this;
  214.         
  215.         this._setUpTimer(true);*/
  216.       ]]>
  217.       </handler>
  218.     </handlers>
  219.   </binding>
  220.  
  221.   <binding id="updateItem" extends="chrome://global/content/bindings/checkbox.xml#checkbox">
  222.     <content>
  223.       <xul:image class="checkbox-check" xbl:inherits="checked,disabled"/>
  224.       <xul:hbox class="checkbox-label-box" flex="1">
  225.         <xul:label class="checkbox-label foundLabel" xbl:inherits="xbl:text=label,accesskey" flex="1"/>
  226.         <xul:label class="checkbox-label" value="&from.label;"/>
  227.         <xul:label class="checkbox-label foundSource" xbl:inherits="xbl:text=source,infoURL,accesskey,crop"/>
  228.       </xul:hbox>
  229.     </content>
  230.     <implementation>
  231.       <property name="type" 
  232.                 onget="return this.getAttribute('type');"
  233.                 onset="this.setAttribute('type', val); return val;"/>
  234.       <property name="source" 
  235.                 onget="return this.getAttribute('source');"
  236.                 onset="this.setAttribute('source', val); return val;"/>
  237.       <property name="URL" 
  238.                 onget="return this.getAttribute('URL');"
  239.                 onset="this.setAttribute('URL', val); return val;"/>
  240.       <property name="infoURL" 
  241.                 onget="return this.getAttribute('infoURL');"
  242.                 onset="this.setAttribute('infoURL', val); return val;"/>
  243.       <property name="internalName" 
  244.                 onget="return this.getAttribute('internalName');"
  245.                 onset="this.setAttribute('internalName', val); return val;"/>
  246.     </implementation>
  247.   </binding>
  248.  
  249.   <binding id="link" extends="chrome://global/content/bindings/text.xml#text-base">
  250.     <content>
  251.       <xul:label xbl:inherits="value=label,crop" class="linkLabel" flex="1"/>
  252.     </content>
  253.     <implementation>
  254.       <property name="href"
  255.                 onget="return this.getAttribute('href');"
  256.                 onset="this.setAttribute('href', val); return val;"/>
  257.     </implementation>
  258.     <handlers>
  259.       <handler event="keypress" keycode="VK_ENTER" action="this.click()" />
  260.       <handler event="keypress" keycode="VK_RETURN" action="this.click()" />
  261.       <handler event="click">
  262.       <![CDATA[
  263.         if (event.button != 0)
  264.           return;
  265.           
  266.         var ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
  267.                            .getService(Components.interfaces.nsIWindowWatcher);
  268.         var ary = Components.classes["@mozilla.org/supports-array;1"]
  269.                             .createInstance(Components.interfaces.nsISupportsArray);
  270.         var url = Components.classes["@mozilla.org/supports-string;1"]
  271.                             .createInstance(Components.interfaces.nsISupportsString);
  272.         url.data = this.getAttribute("href")
  273.         ary.AppendElement(url);
  274.         
  275.         ww.openWindow(null, "chrome://browser/content/browser.xul",
  276.                       "_blank", "chrome,all,dialog=no", ary);
  277.       ]]>
  278.       </handler>
  279.     </handlers>
  280.   </binding>
  281. </bindings>
  282.  
  283.