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 / filDF603C716FA0DCD62D95A1A9F252DA41 < prev    next >
Extensible Markup Language  |  2010-07-12  |  10KB  |  271 lines

  1. <?xml version="1.0"?>
  2. <!DOCTYPE bindings [
  3.   <!ENTITY % yasearchDTD SYSTEM "chrome://yasearch/locale/yasearch.dtd">
  4.   %yasearchDTD;
  5. ]>
  6. <bindings xmlns="http://www.mozilla.org/xbl"
  7.           xmlns:xbl="http://www.mozilla.org/xbl"
  8.           xmlns:html="http://www.w3.org/1999/xhtml"
  9.           xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  10.   
  11.   <binding id="balloon"
  12.            extends="chrome://global/content/bindings/popup.xml#panel">
  13.     <resources>
  14.       <stylesheet src="chrome://yasearch/skin/translate/balloon.css"/>
  15.     </resources>
  16.     
  17.     <content>
  18.       <html:div class="border">
  19.         <html:div>
  20.           <html:div
  21.             ><html:div class="translations"
  22.             /><html:div class="more"
  23.               ><html:span>&yasearch.translate.balloon.more.label;</html:span
  24.             ></html:div
  25.           ></html:div>
  26.         </html:div>
  27.       </html:div>
  28.     </content>
  29.     
  30.     <implementation implements="nsIDOMEventListener">
  31.       <field name="_tooltipController"/>
  32.       
  33.       <field name="_timeoutNodeCheckId"/>
  34.       <field name="_mouseoutTimestamp">0</field>
  35.       <field name="_mouseOver">false</field>
  36.       
  37.       <field name="_hideEvents">["mousemove", "mouseout", "click", "DOMAttrModified"]</field>
  38.       
  39.       <field name="_translations">document.getAnonymousElementByAttribute(this, "class", "translations")</field>
  40.       <field name="_more">document.getAnonymousElementByAttribute(this, "class", "more")</field>
  41.       
  42.       <property name="tooltipController"
  43.                 onget="return this._tooltipController;"
  44.                 onset="this._tooltipController = val;"/>
  45.       
  46.       <property name="from"
  47.                 onget="return this._from;"
  48.                 onset="this._from = val;"/>
  49.       
  50.       <property name="to"
  51.                 onget="return this._to;"
  52.                 onset="this._to = val;"/>
  53.       
  54.       <property name="language"
  55.                 readonly="true"
  56.                 onget="return this.from != 'ru' ? this.from : this.to"/>
  57.       
  58.       <property name="translations">
  59.         <setter><![CDATA[
  60.           let translations = this._translations;
  61.           
  62.           while (translations.firstChild)
  63.             translations.removeChild(translations.firstChild);
  64.           
  65.           const kHTMLNS = "http://www.w3.org/1999/xhtml";
  66.           var olTranslations = document.createElementNS(kHTMLNS, "ol");
  67.           
  68.           let language = document.createElementNS(kHTMLNS, "div");
  69.           language.className = "language";
  70.           language.textContent = "(" + Ya.stringBundleSet.getString("translate.balloon.language." + this.from) + ")";
  71.           
  72.           (val || []).forEach(function(translation) {
  73.             let liTranslation = document.createElementNS(kHTMLNS, "li");
  74.             liTranslation.className = "translation";
  75.             
  76.             let word = document.createElementNS(kHTMLNS, "div");
  77.             word.className = "word";
  78.             word.textContent = translation.word + "\u00a0";
  79.             
  80.             liTranslation.appendChild(word);
  81.             liTranslation.appendChild(language.cloneNode(true));
  82.             
  83.             let parts = translation.parts;
  84.             let part = translation.part;
  85.             
  86.             let olParts = document.createElementNS(kHTMLNS, "ol");
  87.             olParts.className = "parts";
  88.             
  89.             for (let j = 0; j < parts.length; j++) {
  90.               let partOfSpeech = parts[j];
  91.               let words = part[partOfSpeech];
  92.               
  93.               let liPart = document.createElementNS(kHTMLNS, "li");
  94.               liPart.className = "part";
  95.               
  96.               let divPartOfSpeech = document.createElementNS(kHTMLNS, "div");
  97.               divPartOfSpeech.className = "partOfSpeech";
  98.               divPartOfSpeech.textContent = "(" + partOfSpeech + ")";
  99.               
  100.               liPart.appendChild(divPartOfSpeech);
  101.               
  102.               let spanWords = document.createElementNS(kHTMLNS, "span");
  103.               spanWords.textContent = words.join(", ") + "\u00a0";
  104.               
  105.               liPart.appendChild(spanWords);
  106.               
  107.               olParts.appendChild(liPart);
  108.             }
  109.             
  110.             liTranslation.appendChild(olParts);
  111.             
  112.             olTranslations.appendChild(liTranslation);
  113.             
  114.           }, this);
  115.           
  116.           translations.appendChild(olTranslations);
  117.         ]]></setter>
  118.       </property>
  119.       
  120.       <method name="contains">
  121.         <parameter name="aChild"/>
  122.         <parameter name="aParent"/>
  123.         <body><![CDATA[
  124.           let parent = arguments.length == 1 ? this : aParent;
  125.           
  126.           try {
  127.             return (aChild == parent) ||
  128.                    !!(parent.compareDocumentPosition(aChild) & Node.DOCUMENT_POSITION_CONTAINED_BY);
  129.           } catch(e) {}
  130.           
  131.           return false;
  132.         ]]></body>
  133.       </method>
  134.       
  135.       <method name="showMore">
  136.         <parameter name="event"/>
  137.         <body><![CDATA[
  138.           this.tooltipController.hideBalloon();
  139.           Ya.loadURI(this.url, "new-tab", {action: 630});
  140.         ]]></body>
  141.       </method>
  142.       
  143.       <method name="_checkForNewNode">
  144.         <parameter name="aSelf"/>
  145.         <parameter name="aRangeParent"/>
  146.         <parameter name="aRangeOffset"/>
  147.         <body><![CDATA[
  148.           aSelf._clearNodeCheckTimeout();
  149.           aSelf.tooltipController.checkForNewNode(aRangeParent, aRangeOffset);
  150.         ]]></body>
  151.       </method>
  152.       
  153.       <method name="handleEvent">
  154.         <parameter name="aEvent"/>
  155.         <body><![CDATA[
  156.           switch (aEvent.type) {
  157.             case "DOMAttrModified":
  158.               if (aEvent.attrName == "active" &&
  159.                   aEvent.target == aEvent.originalTarget &&
  160.                   aEvent.newValue != "true") {
  161.                   
  162.                 this.tooltipController.hideBalloon();
  163.               }
  164.               
  165.               break;
  166.             
  167.             case "click":
  168.               this.tooltipController.hideBalloon();
  169.               break;
  170.             
  171.             case "mousemove":
  172.               if (!this._timeoutNodeCheckId && (Date.now() - this._mouseoutTimestamp) > 100) {
  173.                 this._timeoutNodeCheckId = setTimeout(this._checkForNewNode, 200,
  174.                                                       this, aEvent.rangeParent, aEvent.rangeOffset);
  175.               }
  176.               break;
  177.             
  178.             case "mouseout":
  179.               if (!aEvent.relatedTarget) {
  180.                 
  181.                 this.tooltipController.clearShowTimeout();
  182.                 
  183.                 if (aEvent.explicitOriginalTarget == this) {
  184.                   this._mouseoutTimestamp = Date.now();
  185.                   this._clearNodeCheckTimeout();
  186.                   
  187.                   setTimeout(function(aSelf) {
  188.                     if (aSelf && aSelf.state == "open" && !aSelf.tooltipController.showTimeout) {
  189.                       aSelf.tooltipController.hideBalloon();
  190.                     }
  191.                   }, 200, this);
  192.                 
  193.                 } else {
  194.                   setTimeout(function(aSelf) {
  195.                     if (aSelf && aSelf.state == "open" && !aSelf._mouseOver && !aSelf.tooltipController.showTimeout) {
  196.                       aSelf.tooltipController.hideBalloon();
  197.                     }
  198.                   }, 200, this);
  199.                 }
  200.                 
  201.               } else if (aEvent.target.localName == "tabbrowser" && !this.contains(aEvent.relatedTarget)) {
  202.                 this.tooltipController.hideBalloon();
  203.               }
  204.               
  205.               break;
  206.             
  207.             default:
  208.               break;
  209.           }
  210.         ]]></body>
  211.       </method>
  212.       
  213.       <method name="_clearNodeCheckTimeout">
  214.         <body><![CDATA[
  215.           if (this._timeoutNodeCheckId) {
  216.             clearTimeout(this._timeoutNodeCheckId);
  217.             this._timeoutNodeCheckId = null;
  218.           }
  219.         ]]></body>
  220.       </method>
  221.       
  222.       <destructor><![CDATA[
  223.         this.tooltipController = null;
  224.       ]]></destructor>
  225.       
  226.     </implementation>
  227.     
  228.     <handlers>
  229.       <handler event="click"><![CDATA[
  230.         if (this.contains(event.originalTarget, this._more))
  231.           this.showMore(event);
  232.       ]]></handler>
  233.       
  234.       <handler event="mousemove" phase="capturing"><![CDATA[
  235.         event.stopPropagation();
  236.       ]]></handler>
  237.       
  238.       <handler event="mouseover"><![CDATA[
  239.         this.tooltipController.clearShowTimeout();
  240.         this._mouseOver = true;
  241.       ]]></handler>
  242.       
  243.       <handler event="mouseout"><![CDATA[
  244.         this._mouseOver = false;
  245.       ]]></handler>
  246.       
  247.       <handler event="popupshowing"><![CDATA[
  248.         this._hideEvents.forEach(function(aEventName) {
  249.           window.addEventListener(aEventName, this, false, true);
  250.         }, this);
  251.         
  252.         if (this.getAttribute("yaIsLinux") == "true") {
  253.           this.style.height = "";
  254.           window.setTimeout(function(aSelf) {
  255.             aSelf.style.height = aSelf.boxObject.height + "px";
  256.           }, 0, this);
  257.         }
  258.       ]]></handler>
  259.       
  260.       <handler event="popuphiding"><![CDATA[
  261.         this._hideEvents.forEach(function(aEventName) {
  262.           window.removeEventListener(aEventName, this, false, true);
  263.         }, this);
  264.         
  265.         this._clearNodeCheckTimeout();
  266.         
  267.         this._mouseOver = false;
  268.       ]]></handler>
  269.     </handlers>
  270.   </binding>
  271. </bindings>