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 / fil00D090375CA0415E4E08135B185F43A5 < prev    next >
Extensible Markup Language  |  2010-07-12  |  16KB  |  469 lines

  1. <?xml version="1.0"?>
  2. <!DOCTYPE bindings [
  3.   <!ENTITY % yaBrandDTD SYSTEM "chrome://yasearch/locale/yasearch.dtd">
  4.   %yaBrandDTD;
  5.   <!ENTITY % yaBookmarksDTD SYSTEM "chrome://yasearch/locale/bookmarks/bookmarks.dtd">
  6.   %yaBookmarksDTD;
  7. ]>
  8.  
  9. <bindings xmlns="http://www.mozilla.org/xbl"
  10.           xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  11.           xmlns:xbl="http://www.mozilla.org/xbl"
  12.           xmlns:html="http://www.w3.org/1999/xhtml">
  13.   
  14.   <binding id="favicons" extends="chrome://global/content/bindings/general.xml#image">
  15.     <implementation>
  16.       <constructor><![CDATA[
  17.         this.__yaUrlForFav = this.parentNode.parentNode.getAttribute("statustext");
  18.       ]]></constructor>
  19.     </implementation>
  20.     
  21.     <handlers>
  22.       <handler event="load"><![CDATA[
  23.         if (!this.__yaUrlForFav)
  24.           return;
  25.         
  26.         var imgSrc = YaBookmarksUtils.getFaviconURL(this.__yaUrlForFav);
  27.         if (!imgSrc)
  28.           return;
  29.         
  30.         var img = document.createElementNS("http://www.w3.org/1999/xhtml", "img");
  31.         
  32.         var __me = this;
  33.         
  34.         img.onload = function() {
  35.           YaBookmarksUtils.checkExpirationTime(this.src);
  36.           __me.src = this.src;
  37.         },
  38.         
  39.         img.onerror = function() {
  40.           var response = false;
  41.           try {
  42.             if (this instanceof Components.interfaces.nsIImageLoadingContent)
  43.               response = this.getRequest(Components.interfaces.nsIImageLoadingContent.CURRENT_REQUEST).mimeType;
  44.           } catch(e) {}
  45.           
  46.           YaBookmarksUtils.addToMissedIconCache(this.src, !!response);
  47.         }
  48.         
  49.         img.src = imgSrc;
  50.       ]]></handler>
  51.     </handlers>
  52.   </binding>
  53.   
  54.   <binding id="tags-container">
  55.     <resources>
  56.       <stylesheet src="chrome://yasearch/skin/bookmarks/bookmarks.css"/>
  57.     </resources>
  58.     
  59.     <content>
  60.       <xul:textbox xbl:inherits="value,maxlength,disabled,emptytext"/>
  61.       
  62.       <xul:hbox>
  63.         <xul:vbox flex="1" anonid="tags-cloud-container">
  64.           <html:div anonid="tags-cloud" style="display:none;"/>
  65.         </xul:vbox>
  66.       </xul:hbox>
  67.       
  68.       <xul:tooltip anonid="maxLengthTooltip" orient="vertical" noautohide="true">
  69.         <xul:description value="&yasearch.bookmarks.maxLengthTooltipDefaultText;"/>
  70.       </xul:tooltip>
  71.     </content>
  72.     
  73.     <implementation>
  74.       <constructor><![CDATA[
  75.         this.tagsCloud = document.getAnonymousElementByAttribute(this, "anonid", "tags-cloud");
  76.         
  77.         this.mYaBookmarks = Components.classes["@yandex.ru/yasearch;1"].
  78.                             getService(Components.interfaces.nsIYaSearch).wrappedJSObject.
  79.                             yaBookmarks;
  80.       ]]></constructor>
  81.       
  82.       <destructor><![CDATA[
  83.         this.clearMaxLengthTooltipTimeout();
  84.         this.clearTextInputTimeout();
  85.         
  86.         this.lastTextValue = null;
  87.         this.lastTextComplete = null;
  88.         
  89.         this.tagsCloud = null;
  90.         
  91.         this._tagsList = null;
  92.         
  93.         this.mYaBookmarks = null;
  94.       ]]></destructor>
  95.       
  96.       <field name="lastCursorPosition">0</field>
  97.       
  98.       <field name="mTextbox">document.getAnonymousNodes(this)[0]</field>
  99.       
  100.       <field name="mMaxLengthTooltip">document.getAnonymousElementByAttribute(this, "anonid", "maxLengthTooltip");</field>
  101.       
  102.       <field name="_lastTextValue">null</field>
  103.       <property name="lastTextValue"
  104.                 onget="return this._lastTextValue;"
  105.                 onset="this._lastTextValue = val; return val;"/>
  106.       
  107.       <field name="_lastTextComplete">null</field>
  108.       <property name="lastTextComplete"
  109.                 onget="return this._lastTextComplete;"
  110.                 onset="this._lastTextComplete = val; return val;"/>
  111.       
  112.       <field name="_tagsList">null</field>
  113.       <property name="tagsList" readonly="true" onget="return this._tagsList"/>
  114.       
  115.       <field name="_maxLengthTooltipTimeout">null</field>
  116.       <field name="_handleTextInputTimeout">null</field>
  117.       
  118.       <property name="value"
  119.                 onget="return this.mTextbox.value;"
  120.                 onset="this.mTextbox.value = val; return val;"/>
  121.       
  122.       <property name="disabled"
  123.                 onget="return this.mTextbox.disabled;"
  124.                 onset="this.mTextbox.disabled = val; return val;"/>
  125.       
  126.       <property name="maxLength" readonly="true">
  127.         <getter>
  128.           <![CDATA[
  129.             return this.hasAttribute("maxlength") ? parseInt(this.getAttribute("maxlength"),10) : 0;
  130.           ]]>
  131.         </getter>
  132.       </property>
  133.  
  134.       <field name="tagMaxLength">this.hasAttribute("yatagmaxlength") ? parseInt(this.getAttribute("yatagmaxlength"), 10) : 0</field>
  135.       
  136.       <property name="selectionStart"
  137.                 onget="return this.mTextbox.selectionStart;"/>
  138.  
  139.       <property name="selectionEnd"
  140.                 onget="return this.mTextbox.selectionEnd;"/>
  141.       
  142.       <method name="selectTextRange">
  143.         <parameter name="aStartIndex"/>
  144.         <parameter name="aEndIndex"/>
  145.         <body><![CDATA[
  146.           this.mTextbox.setSelectionRange(aStartIndex, aEndIndex);
  147.           
  148.           const nsISelectionController = Components.interfaces.nsISelectionController;
  149.           this.mTextbox.editor.selectionController.scrollSelectionIntoView(
  150.               nsISelectionController.SELECTION_NORMAL,
  151.               nsISelectionController.SELECTION_FOCUS_REGION,
  152.               false
  153.           );
  154.         ]]></body>
  155.       </method>
  156.       
  157.       <method name="initWithValue">
  158.         <parameter name="aTagsListString"/>
  159.         <body><![CDATA[
  160.           this.trySetNewValue(aTagsListString, true);
  161.           this.mYaBookmarks.showTags(this, null, 10);
  162.         ]]></body>
  163.       </method>
  164.       
  165.       <method name="addTag">
  166.         <parameter name="aTagElement"/>
  167.         <body><![CDATA[
  168.           var span = aTagElement;
  169.           if (span) {
  170.             var spanDisabled = span.getAttribute("disabled");
  171.             var savedValue = this.value ? this.value.replace(/^[,\s]*/, "")
  172.                                                     .replace(/\s+,/g, ",")
  173.                                                     .replace(/\s+/g, " ")
  174.                                                     .replace(/,+/g, ",")
  175.                                                     .replace(/[,\s]*$/, ", ")
  176.                                         : "";
  177.             
  178.             switch (spanDisabled) {
  179.               case "false":
  180.                 savedValue += span.getAttribute("tooltiptext") + ", ";
  181.                 spanDisabled = "true";
  182.                 break;
  183.               
  184.               case "true":
  185.                 var re = new RegExp("(^|,\\s?)" +
  186.                                     span.getAttribute("tooltiptext").replace(/(\-|\.|\||\+|\?|\$|\(|\)|\[|\])/g,"\\\$1") +
  187.                                     "(,\\s?|$)", "gi");
  188.                 
  189.                 while(re.test(savedValue))
  190.                   savedValue = savedValue.replace(re, "$1");
  191.                 
  192.                 spanDisabled = "false";
  193.                 break;
  194.               
  195.               default:
  196.                 return false;
  197.             }
  198.             
  199.             if (!this.trySetNewValue(savedValue)) {
  200.               return false;
  201.             }
  202.             
  203.             span.setAttribute("disabled", spanDisabled);
  204.             return true;
  205.           }
  206.           
  207.           return false;
  208.         ]]></body>
  209.       </method>
  210.       
  211.       <method name="showTags">
  212.         <parameter name="aTagsFull"/>
  213.         <parameter name="aTagsLimited"/>
  214.         <body><![CDATA[
  215.           const HTMLNS = "http://www.w3.org/1999/xhtml";
  216.           
  217.           var tags = aTagsLimited || aTagsFull,
  218.               tagsCloud = this.tagsCloud,
  219.               style = this.tagsCloud.style,
  220.               frag = document.createDocumentFragment();
  221.           
  222.           for (var prop in tags) {
  223.             var tag = aTagsFull[prop];
  224.             
  225.             var el = document.createElementNS(HTMLNS, "span");
  226.             var spanContent = tag.value.length > 22 ? (tag.value.substr(0, 18) + "ΓǪ") : tag.value;
  227.             el.setAttribute("disabled", tag.disabled ? "true" : "false");
  228.             el.setAttribute("tooltiptext", tag.value);
  229.             el.appendChild(document.createTextNode(spanContent));
  230.             frag.appendChild(el);
  231.             
  232.             frag.appendChild(document.createTextNode(", "));
  233.             
  234.             aTagsFull[prop].element = el;
  235.           }
  236.           
  237.           this._tagsList = aTagsFull || null;
  238.           
  239.           while (tagsCloud.firstChild)
  240.             tagsCloud.removeChild(tagsCloud.firstChild);
  241.           
  242.           if (frag.lastChild) {
  243.             frag.removeChild(frag.lastChild);
  244.             
  245.             tagsCloud.appendChild(frag);
  246.             
  247.             style.display = "block";
  248.             
  249.             var bo = this.boxObject;
  250.             
  251.             style.left  = bo.x + 5 + "px";
  252.             style.width = Math.max(0, bo.width - 10) + "px";
  253.           } else {
  254.             style.display = "none";
  255.           }
  256.         ]]></body>
  257.       </method>
  258.       
  259.       <method name="fireInput">
  260.         <body><![CDATA[
  261.           var ev = document.createEvent("UIEvents");
  262.           ev.initEvent("input", true, true);
  263.           this.mTextbox.dispatchEvent(ev);
  264.         ]]></body>
  265.       </method>
  266.       
  267.       <method name="trySetNewValue">
  268.         <parameter name="aValue"/>
  269.         <parameter name="aSetAnyway"/>
  270.         <body><![CDATA[
  271.           if (this.maxLength && this.maxLength < aValue.length) {
  272.             if (!aSetAnyway)
  273.               return false;
  274.             this.removeAttribute("maxlength");
  275.           }
  276.           
  277.           this.value = aValue;
  278.           return true;
  279.         ]]></body>
  280.       </method>
  281.       
  282.       <method name="showMaxLengthTooltip">
  283.         <body><![CDATA[
  284.           this.clearMaxLengthTooltipTimeout();
  285.           
  286.           try {
  287.             var tooltipText = window.YaBookmarks.stringBundleSet.getFormattedString("MaxLengthTooltipText", [this.tagMaxLength]);
  288.             this.mMaxLengthTooltip.firstChild.setAttribute("value", tooltipText);
  289.           } catch(e) {}
  290.           
  291.           this.mMaxLengthTooltip.showPopup(this.mTextbox,
  292.                                            this.boxObject.screenX + 4, this.boxObject.screenY,
  293.                                            "tooltip", null, null);
  294.           
  295.           this._maxLengthTooltipTimeout = window.setTimeout(
  296.             function(tooltip) { tooltip.hidePopup() },
  297.             2000,
  298.             this.mMaxLengthTooltip
  299.           );
  300.         ]]></body>
  301.       </method>
  302.       
  303.       <method name="clearMaxLengthTooltipTimeout">
  304.         <body><![CDATA[
  305.           if (this._maxLengthTooltipTimeout)
  306.             window.clearTimeout(this._maxLengthTooltipTimeout);
  307.           
  308.           this._maxLengthTooltipTimeout = null;
  309.         ]]></body>
  310.       </method>
  311.       
  312.       <method name="clearTextInputTimeout">
  313.         <body><![CDATA[
  314.           if (this._handleTextInputTimeout)
  315.             window.clearTimeout(this._handleTextInputTimeout);
  316.           
  317.           this._handleTextInputTimeout = null;
  318.         ]]></body>
  319.       </method>
  320.       
  321.       <method name="handleTextInput">
  322.         <body><![CDATA[
  323.           this.clearTextInputTimeout();
  324.           
  325.           this._handleTextInputTimeout = window.setTimeout(
  326.             function(aInput) {
  327.               aInput.mYaBookmarks.handleTextInput(aInput);
  328.             }, 200, this
  329.           );
  330.         ]]></body>
  331.       </method>
  332.       
  333.     </implementation>
  334.     
  335.     <handlers>
  336.       <handler event="focus" phase="capturing">
  337.         <![CDATA[
  338.           this.lastTextComplete = null;
  339.         ]]>
  340.       </handler>
  341.       
  342.       <handler event="blur" phase="capturing">
  343.         <![CDATA[
  344.           this.fireInput();
  345.         ]]>
  346.       </handler>
  347.       
  348.       <handler event="input">
  349.         <![CDATA[
  350.           if (this.tagsList)
  351.             this.mYaBookmarks.handleTextChange(this);
  352.         ]]>
  353.       </handler>
  354.       
  355.       <handler event="keyup" phase="capturing">
  356.         <![CDATA[
  357.           if ((event.keyCode == 0 || event.keyCode > 46) && !event.ctrlKey && !event.altKey)
  358.             this.handleTextInput();
  359.           
  360.           return true;
  361.         ]]>
  362.       </handler>
  363.       
  364.       <handler event="keydown" phase="capturing">
  365.         <![CDATA[
  366.           this.clearTextInputTimeout();
  367.           
  368.           var keyCode = event.keyCode;
  369.           
  370.           if (this.lastTextComplete === this.value.substr(this.selectionStart, this.selectionEnd)) {
  371.             if (event.DOM_VK_RETURN == keyCode) {
  372.               
  373.               this.trySetNewValue(this.value + ", ");
  374.               
  375.               var len = this.value.length;
  376.               
  377.               this.selectTextRange(len, len);
  378.               this.fireInput();
  379.               
  380.               return false;
  381.             }
  382.           }
  383.           
  384.           return true;
  385.         ]]>
  386.       </handler>
  387.       
  388.       <handler event="click" button="0">
  389.         <![CDATA[
  390.           var target = event.originalTarget;
  391.           
  392.           switch (target.localName) {
  393.             case "span":
  394.               if (target.getAttribute("anonid") == "tags-cloud-closeButton") {
  395.                 this.hideTags();
  396.               } else if (target.parentNode.localName === "div") {
  397.                 this.addTag(target);
  398.               }
  399.               break;
  400.             
  401.             default:
  402.               break;
  403.           }
  404.         ]]>
  405.       </handler>
  406.     </handlers>
  407.   </binding>
  408.   
  409.   <binding id="extra-dialog-button-box">
  410.     <content>
  411.       <xul:checkbox anonid="dont-show-again" label="&yasearch.yaru.dontshowlivewindow.checkbox.label;"/>
  412.       <xul:spacer flex="1"/>
  413.       <children/>
  414.     </content>
  415.     
  416.     <handlers>
  417.       <handler event="command"><![CDATA[
  418.         if (event.originalTarget.localName == "checkbox" && window.YaYaRu)
  419.           window.YaYaRu.prefsObject.set("yaruLiveWindowDisabled", !!event.originalTarget.checked);
  420.       ]]></handler>
  421.     </handlers>
  422.   </binding>
  423.   
  424.   <binding id="links-tooltips">
  425.     <implementation>
  426.       <constructor>
  427.         <![CDATA[
  428.           var linkHref = this.getAttribute("href");
  429.           if (linkHref && !this.hasAttribute("tooltiptext"))
  430.             this.setAttribute("tooltiptext", linkHref);
  431.         ]]>
  432.       </constructor>
  433.     </implementation>
  434.   </binding>
  435.   
  436.   <binding id="links-tooltips-and-crop">
  437.     <implementation>
  438.       <constructor><![CDATA[
  439.         setTimeout(function(me){ me._init() }, 0, this)
  440.       ]]></constructor>
  441.       
  442.       <method name="_init">
  443.         <body><![CDATA[
  444.           var labels = this.getElementsByTagName("label");
  445.           
  446.           var children = this.childNodes;
  447.           var widthDiff = this.boxObject.width;
  448.  
  449.           for (var i = 0; i < children.length; i++) {
  450.             var childWidth = children[i].boxObject.width;
  451.             if (childWidth > 0)
  452.               widthDiff -= childWidth;
  453.           }
  454.           
  455.           if (widthDiff < 0) {
  456.             var chIndex = labels.length > 1 ? 1 : 0;
  457.             
  458.             labels[chIndex].style.maxWidth = labels[chIndex].boxObject.width + widthDiff - 1 + "px";
  459.             labels[chIndex].setAttribute("crop", "end");
  460.           
  461.           } else {
  462.             if (this.hasAttribute("yaTooltiptext"))
  463.               this.removeAttribute("yaTooltiptext");
  464.           }
  465.         ]]></body>
  466.       </method>
  467.     </implementation>
  468.   </binding>
  469. </bindings>