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 / fil8F3156516DABB7E1ABCD3A7F5C73BFDB < prev    next >
Extensible Markup Language  |  2010-07-12  |  26KB  |  780 lines

  1. <?xml version="1.0"?>
  2. <!DOCTYPE bindings [
  3.   <!ENTITY % preferencesDTD SYSTEM "chrome://yasearch/locale/preferences/preferences.dtd">
  4.   %preferencesDTD;
  5. ]>
  6.  
  7. <bindings xmlns="http://www.mozilla.org/xbl"
  8.           xmlns:xbl="http://www.mozilla.org/xbl"
  9.           xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  10.           xmlns:html="http://www.w3.org/1999/xhtml">
  11.   
  12.   <binding id="global-setting-icon">
  13.     <content xb-tooltip-prefix="&global.setting.tooltip.prefix;">
  14.       <xul:hbox flex="1">
  15.         <xul:spacer flex="1"/>
  16.         <xul:image xbl:inherits="tooltiptext=xb-global-setting-warning"/>
  17.       </xul:hbox>
  18.     </content>
  19.     
  20.     <implementation>
  21.       <constructor><![CDATA[
  22.         let tooltiptext = this.getAttribute("xb-global-setting-warning");
  23.         if (tooltiptext == "auto") {
  24.           let widgetNames = this.getAttribute("xb-global-setting-names")
  25.                                 .split(",")
  26.                                 .map(function(str) "┬½" + str + "┬╗")
  27.                                 .join(", ");
  28.           
  29.           this.setAttribute("xb-global-setting-warning", this.getAttribute("xb-tooltip-prefix").replace("%S", widgetNames));
  30.         }
  31.       ]]></constructor>
  32.     </implementation>
  33.   </binding>
  34.   
  35.   <binding id="base">
  36.     <implementation>
  37.       <field name="mListItem">
  38.         this.parentNode.parentNode.parentNode
  39.       </field>
  40.       
  41.       <field name="mPreferencesController">
  42.         this.mListItem.parentNode.PreferencesController
  43.       </field>
  44.       
  45.       <field name="mSource"/>
  46.       <field name="mSourceTemplate"/>
  47.       <field name="mShortcuts"/>
  48.       <field name="mShortcutsTemplate"/>
  49.       
  50.       <property name="hasSourceURL" readonly="true" onget="return this.hasAttribute('source');"/>
  51.       <property name="hasSourceTemplateURL" readonly="true" onget="return this.hasAttribute('template');"/>
  52.       
  53.       <property name="hasShortcutsURL" readonly="true" onget="return this.hasAttribute('shortcuts-source');"/>
  54.       <property name="hasShortcutsTemplateURL" readonly="true" onget="return this.hasAttribute('shortcuts-template');"/>
  55.       
  56.       <method name="_getXMLData">
  57.         <parameter name="aType"/>
  58.         <body><![CDATA[
  59.           let url = this.getAttribute(aType);
  60.           
  61.           if (!url)
  62.             return this._onXMLDataResponse(aType, null);
  63.           
  64.           let me = this;
  65.           
  66.           function callback(aRequest) {
  67.             let xmlString = "";
  68.             try {
  69.               xmlString = aRequest.target.responseText || "";
  70.             } catch (ex) {}
  71.             
  72.             if (me && "_onXMLDataResponse" in me)
  73.               me._onXMLDataResponse(aType, xmlString);
  74.           }
  75.           
  76.           let req = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]
  77.                               .createInstance(Components.interfaces.nsIXMLHttpRequest);
  78.           try {
  79.             req.open("GET", url, true);
  80.           } catch (ex) {
  81.             return this._onXMLDataResponse(aType, null);
  82.           }
  83.           
  84.           let target = req.QueryInterface(Components.interfaces.nsIDOMEventTarget);
  85.           target.addEventListener("load", callback, false);
  86.           target.addEventListener("error", callback, false);
  87.           
  88.           req.send(null);
  89.         ]]></body>
  90.       </method>
  91.       
  92.       <method name="_onXMLDataResponse">
  93.         <parameter name="aType"/>
  94.         <parameter name="aXMLString"/>
  95.         <body><![CDATA[
  96.           if (aType == "template") {
  97.             if (aXMLString === "") {
  98.               this._getXMLData("alt-template");
  99.             } else {
  100.               this.mSourceTemplate = aXMLString;
  101.               this._getXMLData("source");
  102.             }
  103.             
  104.             return;
  105.           }
  106.           
  107.           if (aType == "alt-template") {
  108.             if (aXMLString === "") {
  109.               this._onXMLDataResponse("alt-source", null);
  110.             }
  111.             
  112.             this.mSourceTemplate = aXMLString;
  113.             this._getXMLData("alt-source");
  114.             
  115.             return;
  116.           }
  117.           
  118.           if (aType == "shortcuts-template") {
  119.             if (aXMLString === "") {
  120.               this._getXMLData("shortcuts-alt-template");
  121.             } else {
  122.               this.mShortcutsTemplate = aXMLString;
  123.               this._getXMLData("shortcuts-source");
  124.             }
  125.             
  126.             return;
  127.           }
  128.           
  129.           if (aType == "shortcuts-alt-template") {
  130.             if (aXMLString === "") {
  131.               this._onXMLDataResponse("shortcuts-alt-source", null);
  132.             }
  133.             
  134.             this.mShortcutsTemplate = aXMLString;
  135.             this._getXMLData("shortcuts-alt-source");
  136.             
  137.             return;
  138.           }
  139.           
  140.           if (aType == "source" || aType == "alt-source") {
  141.             this.mSource = this.mPreferencesController
  142.                                .transformSourceXMLData(this.mListItem.id, aType, aXMLString, this.mSourceTemplate);
  143.             
  144.             if (!this.mSource) {
  145.               if (aType != "alt-source") {
  146.                 if (this.hasAttribute("alt-template")) {
  147.                   this.mSourceTemplate = null;
  148.                   this._getXMLData("alt-template");
  149.                 } else {
  150.                   this._getXMLData("alt-source");
  151.                 }
  152.                 
  153.                 return;
  154.               }
  155.             }
  156.             
  157.             this._constructSource();
  158.             
  159.           } else if (aType == "shortcuts-source" || aType == "shortcuts-alt-source") {
  160.             this.mShortcuts = this.mPreferencesController
  161.                                   .transformSourceXMLData(this.mListItem.id, aType, aXMLString, this.mShortcutsTemplate);
  162.             
  163.             if (!this.mShortcuts) {
  164.               if (aType != "shortcuts-alt-source") {
  165.                 if (this.hasAttribute("shortcuts-alt-template")) {
  166.                   this.mShortcutsTemplate = null;
  167.                   this._getXMLData("shortcuts-alt-template");
  168.                 } else {
  169.                   this._getXMLData("shortcuts-alt-source");
  170.                 }
  171.                 
  172.                 return;
  173.               }
  174.             }
  175.             
  176.             this._constructShortcuts();
  177.           }
  178.         ]]></body>
  179.       </method>
  180.       
  181.       <method name="_getSource">
  182.         <body><![CDATA[
  183.           if (this.hasSourceURL) {
  184.             this._getXMLData(this.hasSourceTemplateURL ? "template" : "source");
  185.           } else {
  186.             this._constructSource();
  187.           }
  188.         ]]></body>
  189.       </method>
  190.       
  191.       <method name="_getShortcuts">
  192.         <body><![CDATA[
  193.           if (this.hasShortcutsURL) {
  194.             this._getXMLData(this.hasShortcutsTemplateURL ? "shortcuts-template" : "shortcuts-source");
  195.           } else {
  196.             this._constructShortcuts();
  197.           }
  198.         ]]></body>
  199.       </method>
  200.       
  201.       <constructor><![CDATA[
  202.         setTimeout(function(me) {
  203.           if (me && "_init" in me)
  204.             me._init();
  205.         }, 0, this);
  206.       ]]></constructor>
  207.       
  208.       <method name="_init">
  209.         <body><![CDATA[
  210.           switch (this.getAttribute("xb-preftype")) {
  211.             case "combobox":
  212.             case "radiogroup":
  213.               this._getSource();
  214.               this._getShortcuts();
  215.               break;
  216.  
  217.             default:
  218.               break;
  219.           }
  220.         ]]></body>
  221.       </method>
  222.       
  223.       <method name="_handleChange">
  224.         <parameter name="aEvent"/>
  225.         <body><![CDATA[
  226.           if (aEvent.target === this && this.getAttribute("disabled") !== "true") {
  227.             let val = this.value;
  228.             this.mPreferencesController.onPrefChange(this.mListItem, this.getAttribute("prefName"), val);
  229.           }
  230.         ]]></body>
  231.       </method>
  232.     </implementation>
  233.     
  234.     <handlers>
  235.       <handler event="CheckboxStateChange">
  236.         this._handleChange(event);
  237.       </handler>
  238.       
  239.       <handler event="change">
  240.         this._handleChange(event);
  241.       </handler>
  242.       
  243.       <handler event="select">
  244.         if (["menulist", "radiogroup"].indexOf(event.originalTarget.localName) != -1)
  245.           this._handleChange(event);
  246.       </handler>
  247.     </handlers>
  248.   </binding>
  249.   
  250.   <binding id="checkbox" extends="#base">
  251.     <content flex="1">
  252.       <xul:box xbl:inherits="orient">
  253.         <xul:checkbox anonid="checkbox" xbl:inherits="label,checked=value,disabled"/>
  254.         <xul:hbox class="global-setting-icon" xbl:inherits="xb-global-setting-warning,xb-global-setting-names"/>
  255.       </xul:box>
  256.     </content>
  257.     
  258.     <implementation>
  259.       <field name="checkbox">
  260.         document.getAnonymousElementByAttribute(this, "anonid", "checkbox")
  261.       </field>
  262.       
  263.       <property name="value">
  264.         <getter><![CDATA[
  265.           return !!this.checkbox.checked;
  266.         ]]></getter>
  267.       </property>
  268.       
  269.       <constructor><![CDATA[
  270.         
  271.       ]]></constructor>
  272.     </implementation>
  273.   </binding>
  274.   
  275.   <binding id="textedit" extends="#base">
  276.     <content>
  277.       <xul:box align="center" xbl:inherits="orient">
  278.         <xul:label xbl:inherits="value=label"/>
  279.         <xul:textbox flex="1" anonid="textbox" xbl:inherits="value,disabled,align,dir,pack,orient"/>
  280.         <xul:label xbl:inherits="value=label-after"/>
  281.         <xul:hbox class="global-setting-icon" xbl:inherits="xb-global-setting-warning,xb-global-setting-names"/>
  282.       </xul:box>
  283.     </content>
  284.     
  285.     <implementation>
  286.       <field name="textbox">
  287.         document.getAnonymousElementByAttribute(this, "anonid", "textbox")
  288.       </field>
  289.       
  290.       <property name="value">
  291.         <getter><![CDATA[
  292.           return this.textbox.value || this.getAttribute("empty-default");
  293.         ]]></getter>
  294.       </property>
  295.       
  296.       <constructor><![CDATA[
  297.         let type = this.getAttribute("value-type");
  298.         switch (type) {
  299.           case "string":
  300.           case "number":
  301.           case "int":
  302.             break;
  303.           
  304.           default:
  305.             type = "string";
  306.             break;
  307.         }
  308.         
  309.         let textbox = this.textbox;
  310.         
  311.         let maxLength = (type == "string" && this.hasAttribute("max-length")) ?
  312.                             parseInt(this.getAttribute("max-length"), 10) : 0;
  313.         if (maxLength > 0)
  314.           textbox.setAttribute("maxlength", maxLength);
  315.         
  316.         if (type == "int" || type == "number") {
  317.           textbox.removeAttribute("flex");
  318.           
  319.           textbox.setAttribute("type", "number");
  320.           
  321.           if (type == "number")
  322.             textbox.setAttribute("decimalplaces", "Infinity");
  323.           
  324.           let size = 4;
  325.           ["min", "max"].forEach(function(aAttrName) {
  326.             if (this.hasAttribute(aAttrName)) {
  327.               let val = this.getAttribute(aAttrName);
  328.               size = Math.max(size, val.length);
  329.               
  330.               val = (type == "number") ? parseFloat(val, 10) : parseInt(val, 10);
  331.               textbox.setAttribute(aAttrName, val);
  332.             }
  333.           }, this);
  334.           
  335.           if (type == "int") {
  336.             let increment = this.hasAttribute("spin") ? parseInt(this.getAttribute("spin"), 10) : 1;
  337.             if (!increment || increment < 1)
  338.               textbox.setAttribute("hidespinbuttons", "true");
  339.             else
  340.               textbox.setAttribute("increment", increment);
  341.           }
  342.           
  343.           textbox.setAttribute("size", Math.min(12, size));
  344.         }
  345.         
  346.         if (!this.hasAttribute("value") && this.hasAttribute("empty-default")) {
  347.           this.setAttribute("value", this.getAttribute("empty-default"));
  348.         }
  349.       ]]></constructor>
  350.     </implementation>
  351.     
  352.     <handlers>
  353.       <handler event="select" phase="capturing" preventdefault="true">
  354.         <![CDATA[
  355.           if (event.target == this.textbox.inputField)
  356.             event.stopPropagation();
  357.         ]]>
  358.       </handler>
  359.     </handlers>
  360.   </binding>
  361.   
  362.   <binding id="combobox" extends="#base">
  363.     <content disabled="true" busy="true">
  364.       <xul:box align="center" xbl:inherits="orient">
  365.         <xul:label xbl:inherits="value=label"/>
  366.         <xul:menulist anonid="menulist" flex="1" xbl:inherits="value,editable,disabled,align,dir,pack,orient">
  367.           <xul:menupopup anonid="menupopup">
  368.             <xul:menuitem label=" ...&controls.combobox.creating.label;... "/>
  369.           </xul:menupopup>
  370.         </xul:menulist>
  371.         <xul:label xbl:inherits="value=label-after"/>
  372.         <xul:hbox class="global-setting-icon" xbl:inherits="xb-global-setting-warning,xb-global-setting-names"/>
  373.         <html:div style="display:none">
  374.           <children/>
  375.         </html:div>
  376.       </xul:box>
  377.     </content>
  378.     
  379.     <implementation>
  380.       <field name="menulist">
  381.         document.getAnonymousElementByAttribute(this, "anonid", "menulist")
  382.       </field>
  383.       
  384.       <field name="menupopup">
  385.         document.getAnonymousElementByAttribute(this, "anonid", "menupopup")
  386.       </field>
  387.       
  388.       <property name="value">
  389.         <getter><![CDATA[
  390.           return this.menulist.value;
  391.         ]]></getter>
  392.       </property>
  393.       
  394.       <constructor><![CDATA[
  395.         let menuitemNodes = Array.slice(this.childNodes)
  396.                                  .filter(function (aNode) aNode.localName === "menuitem");
  397.         
  398.         menuitemNodes.forEach(function(aNode) {
  399.           if (!aNode.hasAttribute("label") && aNode.hasAttribute("value"))
  400.             aNode.setAttribute("label", aNode.getAttribute("value"));
  401.           
  402.           this.appendChild(aNode);
  403.         }, this.menupopup);
  404.       ]]></constructor>
  405.       
  406.       <method name="_nodesAppender">
  407.         <parameter name="aDestination"/>
  408.         <parameter name="aSource"/>
  409.         <body><![CDATA[
  410.           let i = 0,
  411.               node = aSource.firstChild,
  412.               nodes = document.createDocumentFragment(),
  413.               t = Date.now();
  414.           
  415.           while (node) {
  416.             nodes.appendChild(node);
  417.             node = (i++ < 500 || (Date.now() - t) < 5) ? aSource.firstChild : null;
  418.           }
  419.           
  420.           if (!nodes.childNodes.length) {
  421.             this._constructSourceDone();
  422.           } else {
  423.             aDestination.appendChild(nodes);
  424.             
  425.             window.setTimeout(function(me, dst, src) {
  426.               if (me && "_nodesAppender" in me)
  427.                 me._nodesAppender(dst,src);
  428.             }, 10, this, aDestination, aSource);
  429.           }
  430.         ]]></body>
  431.       </method>
  432.         
  433.       <method name="_constructSource">
  434.         <body><![CDATA[
  435.           let menupopup = this.menupopup;
  436.           
  437.           if (this.mSource && this.mSource.childNodes.length) {
  438.             while (menupopup.firstChild)
  439.               menupopup.removeChild(menupopup.firstChild);
  440.             
  441.             Array.slice(this.mSource.childNodes).forEach(function(aNode) {
  442.               if (!aNode.hasAttribute("label") && aNode.hasAttribute("value"))
  443.                 aNode.setAttribute("label", aNode.getAttribute("value"));
  444.             });
  445.             
  446.             this._nodesAppender(menupopup, this.mSource);
  447.             
  448.           } else {
  449.             this._constructSourceDone();
  450.           }
  451.         ]]></body>
  452.       </method>
  453.       
  454.       <method name="_constructSourceDone">
  455.         <body><![CDATA[
  456.           if (this.menupopup.childNodes.length) {
  457.             this.menulist.value = this.getAttribute("value");
  458.             this.setAttribute("disabled", "false");
  459.           }
  460.           
  461.           this.removeAttribute("busy");
  462.         ]]></body>
  463.       </method>
  464.       
  465.       <method name="_constructShortcuts">
  466.         <body><![CDATA[
  467.         ]]></body>
  468.       </method>
  469.     </implementation>
  470.   </binding>
  471.   
  472.   <binding id="combobox-editable" extends="#base">
  473.     <content disabled="true" busy="true">
  474.       <xul:box align="center" xbl:inherits="orient">
  475.         <xul:label xbl:inherits="value=label"/>
  476.         <xul:textbox anonid="textbox"
  477.                      flex="100"
  478.                      type="autocomplete"
  479.                      timeout="100"
  480.                      enablehistory="true"
  481.                      autocompletesearch="yacustombar-autocomplete"
  482.                      autocompletesearchparam=""
  483.                      completeselectedindex="false"
  484.                      completedefaultindex="false"
  485.                      forcecomplete="false"
  486.                      showcommentcolumn="false"
  487.                      tabscrolling="true"
  488.                      newlines="replacewithspaces"
  489.                      xbl:inherits="value,disabled,align,dir,pack,orient"/>
  490.         <xul:label xbl:inherits="value=label-after"/>
  491.         <xul:hbox class="global-setting-icon" xbl:inherits="xb-global-setting-warning,xb-global-setting-names"/>
  492.         <html:div style="display:none">
  493.           <children/>
  494.         </html:div>
  495.       </xul:box>
  496.       <xul:vbox onclick="onShortcutsClick(event)">
  497.         <html:div anonid="shortcuts" style="-moz-column-count:2;"/>
  498.       </xul:vbox>
  499.     </content>
  500.     
  501.     <implementation implements="nsIObserver">
  502.       <field name="textbox">
  503.         document.getAnonymousElementByAttribute(this, "anonid", "textbox")
  504.       </field>
  505.       
  506.       <field name="shortcuts">
  507.         document.getAnonymousElementByAttribute(this, "anonid", "shortcuts")
  508.       </field>
  509.       
  510.       <field name="mFreeInput">
  511.         this.getAttribute("free-input") != "false"
  512.       </field>
  513.       
  514.       <field name="autocompleteData">[]</field>
  515.       
  516.       <field name="mACompleteCustomController">null</field>
  517.       
  518.       <property name="value">
  519.         <getter><![CDATA[
  520.           let val = this.textbox.value;
  521.           if (this.mFreeInput)
  522.             return val;
  523.           
  524.           let result = this._getAutocompleteResult(val);
  525.           let realValue = result ? result.realValue : "";
  526.           
  527.           return realValue;
  528.         ]]></getter>
  529.       </property>
  530.       
  531.       <property name="mAutoCompleteSearch" readonly="true">
  532.         <getter><![CDATA[
  533.           let autoCompleteSearchName = this.textbox.getAttribute("autocompletesearch");
  534.           let autoCompleteSearch = Cc["@mozilla.org/autocomplete/search;1?name=" + autoCompleteSearchName]
  535.                                        .getService(Ci.nsIAutoCompleteSearch);
  536.           
  537.           return autoCompleteSearch.wrappedJSObject;
  538.         ]]></getter>
  539.       </property>
  540.       
  541.       <method name="_getAutocompleteResult">
  542.         <parameter name="aString"/>
  543.         <body><![CDATA[
  544.           if (this.mFreeInput) {
  545.             return {
  546.               value: aString,
  547.               realValue: aString
  548.             };
  549.           }
  550.           
  551.           let result = this.mAutoCompleteSearch.lastResult.getResultForString(aString);
  552.           
  553.           if (!result) {
  554.             let lowercaseSearchString = aString.toLowerCase();
  555.             
  556.             this.autocompleteData.some(function(aDataObj) {
  557.               return (aDataObj.value.toLowerCase().indexOf(lowercaseSearchString) == 0)
  558.                          ? (result = aDataObj, true)
  559.                          : false;
  560.             });
  561.             
  562.             if (!result)
  563.               result = this.autocompleteData[0];
  564.           }
  565.           
  566.           return result;
  567.         ]]></body>
  568.       </method>
  569.       
  570.       <method name="_getValueFromRealValue">
  571.         <parameter name="aRealValue"/>
  572.         <body><![CDATA[
  573.           let data = null;
  574.           this.autocompleteData.some(function(aDataObj) {
  575.             return (aDataObj.realValue == aRealValue) ? (data = aDataObj, true) : false;
  576.           });
  577.           
  578.           return data ? data.value : null;
  579.         ]]></body>
  580.       </method>
  581.       
  582.       <constructor>
  583.         <![CDATA[
  584.           let os = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
  585.           os.addObserver(this, "autocomplete-did-enter-text", false);
  586.           
  587.           let textbox = this.textbox;
  588.           let forceComplete = !this.mFreeInput;
  589.           
  590.           ["completeselectedindex", "completedefaultindex", "forcecomplete"]
  591.           .forEach(function(aAttr) textbox.setAttribute(aAttr, forceComplete));
  592.         ]]>
  593.       </constructor>
  594.       
  595.       <destructor>
  596.         <![CDATA[
  597.           let os = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
  598.           os.removeObserver(this, "autocomplete-did-enter-text", false);
  599.           
  600.           this.autocompleteData = null;
  601.           this.mAutoCompleteSearch.lastResult.clear();
  602.         ]]>
  603.       </destructor>
  604.       
  605.       <method name="_constructSource">
  606.         <body><![CDATA[
  607.           let JSON = this.mPreferencesController.JSON;
  608.           
  609.           let autocompleteData = [];
  610.           
  611.           if (this.mSource) {
  612.             Array.slice(this.mSource.childNodes).forEach(function(aNode) {
  613.               let dataObj = {
  614.                 value: aNode.getAttribute("label"),
  615.                 realValue: aNode.getAttribute("value")
  616.               };
  617.               
  618.               autocompleteData.push(dataObj);
  619.             });
  620.             
  621.             this.autocompleteData = autocompleteData;
  622.             
  623.             this.textbox.setAttribute("autocompletesearchparam", JSON.stringify(autocompleteData));
  624.           }
  625.           
  626.           let val = this.getAttribute("value");
  627.           this.textbox.value = this.mFreeInput ? val : (this._getValueFromRealValue(val) || "");
  628.           
  629.           this.setAttribute("disabled", "false");
  630.           this.textbox.disabled = false;
  631.           
  632.           this.removeAttribute("busy");
  633.         ]]></body>
  634.       </method>
  635.       
  636.       <method name="_constructShortcuts">
  637.         <body><![CDATA[
  638.           //if (!this.mShortcuts) {
  639.           //  ...
  640.           //}
  641.           
  642.           if (this.mShortcuts) {
  643.             const kXULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
  644.             
  645.             let shortcuts = this.shortcuts;
  646.             
  647.             Array.slice(this.mShortcuts.childNodes).forEach(function(aNode) {
  648.               let label = document.createElementNS(kXULNS, "label");
  649.               label.setAttribute("style", "display: block;")
  650.               label.setAttribute("crop", "end");
  651.               label.setAttribute("value", aNode.getAttribute("label"));
  652.               label.setAttribute("xb-value", aNode.hasAttribute("value") ? aNode.getAttribute("value")
  653.                                                                          : aNode.getAttribute("label"));
  654.               
  655.               shortcuts.appendChild(label);
  656.             });
  657.           }
  658.         ]]></body>
  659.       </method>
  660.       
  661.       <method name="onShortcutsClick">
  662.         <parameter name="aEvent"/>
  663.         <body><![CDATA[
  664.           let originalTarget = aEvent.originalTarget;
  665.           if (originalTarget.localName == "label") {
  666.             this.textbox.value = originalTarget.getAttribute("value");
  667.             //this... = originalTarget.getAttribute("xb-value");
  668.           }
  669.         ]]></body>
  670.       </method>
  671.       
  672.       <method name="observe">
  673.         <parameter name="aSubject"/>
  674.         <parameter name="aTopic"/>
  675.         <parameter name="aData"/>
  676.         <body><![CDATA[
  677.           switch (aTopic) {
  678.             case "autocomplete-did-enter-text":
  679.               if (aSubject === this.textbox) {
  680.                 let result = this.mAutoCompleteSearch.lastResult.lastResult;
  681.                 if (result)
  682.                   this.textbox.value = result.value;
  683.               }
  684.               break;
  685.             
  686.             default:
  687.               break;
  688.           }
  689.         ]]></body>
  690.       </method>
  691.     </implementation>
  692.     
  693.     <handlers>
  694.       <handler event="focus">
  695.         <![CDATA[
  696.           if (this.getAttribute("editable") == "true" && event.originalTarget.localName == "input")
  697.             this.mAutoCompleteSearch.lastResult.clear();
  698.         ]]>
  699.       </handler>
  700.       
  701.       <handler event="blur">
  702.         <![CDATA[
  703.           if (this.getAttribute("editable") == "true" && event.originalTarget.localName == "input") {
  704.             let result = this._getAutocompleteResult(this.textbox.value);
  705.             this.textbox.value = result ? result.value : "";
  706.             this._handleChange(event);
  707.           }
  708.         ]]>
  709.       </handler>
  710.     </handlers>
  711.   </binding>
  712.   
  713.   <binding id="radiogroup" extends="#base">
  714.     <content disabled="true" busy="true">
  715.       <xul:box xbl:inherits="orient">
  716.         <xul:groupbox>
  717.           <xul:caption xbl:inherits="label" flex="1" crop="end"/>
  718.           <xul:hbox class="global-setting-icon" xbl:inherits="xb-global-setting-warning,xb-global-setting-names"/>
  719.           <xul:radiogroup anonid="radiogroup" xbl:inherits="value,disabled,align,dir,pack,orient"/>
  720.         </xul:groupbox>
  721.         <html:div style="display:none">
  722.           <children/>
  723.         </html:div>
  724.       </xul:box>
  725.     </content>
  726.     
  727.     <implementation>
  728.       <field name="radiogroup">
  729.         document.getAnonymousElementByAttribute(this, "anonid", "radiogroup")
  730.       </field>
  731.       
  732.       <property name="value">
  733.         <getter><![CDATA[
  734.           return this.radiogroup.value;
  735.         ]]></getter>
  736.       </property>
  737.       
  738.       <constructor><![CDATA[
  739.         let radioNodes = Array.slice(this.childNodes)
  740.                               .filter(function (aNode) aNode.localName === "radio");
  741.         
  742.         radioNodes.forEach(function(aNode) {
  743.           this.appendChild(aNode);
  744.         }, this.radiogroup);
  745.       ]]></constructor>
  746.       
  747.       <method name="_constructSource">
  748.         <body><![CDATA[
  749.           let radiogroup = this.radiogroup;
  750.           
  751.           if (this.mSource && this.mSource.childNodes.length) {
  752.             while (radiogroup.firstChild)
  753.               radiogroup.removeChild(radiogroup.firstChild);
  754.             
  755.             radiogroup.appendChild(this.mSource);
  756.           }
  757.           
  758.           if (radiogroup.childNodes.length) {
  759.             let value = radiogroup.value;
  760.             if (value)
  761.               radiogroup.value = value;
  762.             else
  763.               radiogroup.selectedIndex = 0;
  764.             
  765.             this.setAttribute("disabled", "false");
  766.             radiogroup.disabled = false;
  767.           }
  768.           
  769.           this.removeAttribute("busy");
  770.         ]]></body>
  771.       </method>
  772.       
  773.       <method name="_constructShortcuts">
  774.         <body><![CDATA[
  775.         ]]></body>
  776.       </method>
  777.     </implementation>
  778.   </binding>
  779. </bindings>
  780.