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 / filAF0BB33E9DAD0CEBC4B80E3E18AAEB34 < prev    next >
Extensible Markup Language  |  2010-07-12  |  21KB  |  566 lines

  1. <?xml version="1.0"?>
  2. <!DOCTYPE bindings [
  3.   <!ENTITY % yasearchDTD SYSTEM "chrome://yasearch/locale/yasearch.dtd">
  4.   %yasearchDTD;
  5.   <!ENTITY % yasearchFTabDTD SYSTEM "chrome://yasearch/locale/ftab/ftab.dtd" >
  6.   %yasearchFTabDTD;
  7. ]>
  8. <bindings xmlns="http://www.mozilla.org/xbl"
  9.           xmlns:xbl="http://www.mozilla.org/xbl"
  10.           xmlns:html="http://www.w3.org/1999/xhtml"
  11.           xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  12.   
  13.   <binding id="thumb">
  14.     <implementation>
  15.       <field name="controller">window.YaFTab</field>
  16.       
  17.       <method name="getElementByAnonid">
  18.         <parameter name="aAnonidAttr"/>
  19.         <body><![CDATA[
  20.           let elements = this.getElementsByClassName("thumb-" + aAnonidAttr);
  21.           return elements.length ? elements[0] : null;
  22.         ]]></body>
  23.       </method>
  24.       
  25.       <method name="updateProps">
  26.         <parameter name="aProps"/>
  27.         <body>
  28.         <![CDATA[
  29.           for (var [propName, propValue] in Iterator(aProps)) {
  30.             propValue = (propValue||"").toString();
  31.             
  32.             switch (propName) {
  33.               case "url":
  34.                 propValue ? this.setAttribute("href", propValue) : this.removeAttribute("href");
  35.                 break;
  36.               
  37.               case "state":
  38.                 this.setAttribute("yaThumbState", propValue);
  39.                 break;
  40.               
  41.               case "img":
  42.                 var el = this.getElementByAnonid(propName);
  43.                 el.removeAttributeNS("http://www.w3.org/1999/xlink", "href");
  44.                 el.setAttributeNS("http://www.w3.org/1999/xlink", "href", propValue);
  45.                 break;
  46.               
  47.               case "title":
  48.                 this.getElementByAnonid(propName).firstChild.textContent =
  49.                     propValue || aProps.url || this.getAttribute("href") || "";
  50.                 break;
  51.               
  52.               case "index":
  53.                 this.setAttribute("yaThumbIndex", propValue);
  54.                 break;
  55.             }
  56.           }
  57.         ]]>
  58.         </body>
  59.       </method>
  60.       
  61.       <method name="click">
  62.         <parameter name="aEvent"/>
  63.         <body>
  64.         <![CDATA[
  65.           let event = aEvent && aEvent.type == "click" ? aEvent : null;
  66.           
  67.           if (!this.controller.editor.showed) {
  68.             this.hasAttribute("href") ?
  69.               this.controller.loadURI(this.getAttribute("href"), event, {action:4600}, null, true) :
  70.               this.controller.showEditorForPage(this.getAttribute("yaThumbIndex"));
  71.           }
  72.           
  73.           if (event) {
  74.             event.preventDefault();
  75.             event.stopPropagation();
  76.           }
  77.         ]]>
  78.         </body>
  79.       </method>
  80.     </implementation>
  81.     
  82.     <handlers>
  83.       <handler event="click" button="0"><![CDATA[
  84.         if (!this.controller.editor.showed) {
  85.           var target = event.originalTarget;
  86.           var anonid = target.getAttribute("class");
  87.           
  88.           if (!this.hasAttribute("href")) {
  89.             anonid = "control-prefs";
  90.           }
  91.           
  92.           switch (anonid) {
  93.             case "control":
  94.               break;
  95.             
  96.             case "control-prefs":
  97.               this.controller.showEditorForPage(this.getAttribute("yaThumbIndex"));
  98.               break;
  99.             
  100.             case "control-remove":
  101.               this.controller.removePage(this.getAttribute("yaThumbIndex"));
  102.               break;
  103.             
  104.             default:
  105.               if (this.getAttribute("anonid") != "pref-thumb-holder")
  106.                 this.controller.loadURI(this.getAttribute("href"), event, {action:4600}, null, true);
  107.               break;
  108.           }
  109.         }
  110.         
  111.         event.preventDefault();
  112.         event.stopPropagation();
  113.       ]]></handler>
  114.     </handlers>
  115.   </binding>
  116.   
  117.   <binding id="editor">
  118.     <resources>
  119.       <stylesheet src="chrome://yasearch/skin/ftab/ftab-prefs.css"/>
  120.     </resources>
  121.     
  122.     <content>
  123.       <xul:stack flex="1">
  124.         <div xmlns="http://www.w3.org/1999/xhtml" class="content-shadow"/>
  125.         
  126.         <xul:vbox pack="center">
  127.           <div xmlns="http://www.w3.org/1999/xhtml" class="content-holder">
  128.             <table><tr><td>
  129.               <div>
  130.                 <div anonid="thumb-holder-container">
  131.                   <a class="thumb-holder" anonid="pref-thumb-holder"
  132.                      yaThumbIndex="0" yaThumbState="">
  133.                     
  134.                     <div class="thumb-container">
  135.                       <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 600 450">
  136.                         <defs>
  137.                             <linearGradient id="bg-gradient-0" gradientUnits="userSpaceOnUse"
  138.                                             x1="0" x2="0" y1="0" y2="100%">
  139.                             <stop offset="0" stop-color="rgb(246,246,246)"/>
  140.                             <stop offset="8%" stop-color="rgb(240,240,240)"/>
  141.                             <stop offset="15%" stop-color="rgb(232,232,232)"/>
  142.                             <stop offset="35%" stop-color="rgb(225,225,225)"/>
  143.                             <stop offset="40%" stop-color="rgb(230,230,230)"/>
  144.                             <stop offset="60%" stop-color="rgb(243,243,243)"/>
  145.                             <stop offset="100%" stop-color="rgb(246,246,246)"/>
  146.                             </linearGradient>
  147.                           </defs>
  148.                         
  149.                           <rect x="0" y="0" width="100%" height="100%" style="fill:rgb(240,240,240);"/>
  150.                           <rect x="0" y="0" width="100%" height="100%" fill="url(#bg-gradient-0)"/>
  151.                           
  152.                           <image xmlns:xlink="http://www.w3.org/1999/xlink"
  153.                                  class="thumb-img"
  154.                                x="0" y="0"
  155.                                width="100%" height="100%"/>
  156.                         
  157.                           <g class="error" style="display: none;">
  158.                             <rect x="0" y="0" width="100%" height="100%" fill="rgb(246,246,248)"/>
  159.                           
  160.                             <g transform="translate(300,200),rotate(45)">
  161.                               <circle cx="0" cy="0" r="120" fill="#ccc"/>
  162.                               <rect x="-90" y="-18" width="180" height="36" fill="rgb(248,248,248)"/>
  163.                               <rect x="-18" y="-90" width="36" height="180" fill="rgb(248,248,248)"/>
  164.                             </g>
  165.                           </g>
  166.                         </svg>
  167.                       
  168.                       <div class="text-holder">
  169.                         <div class="thumb-title"><p/>
  170.                           <div class="shade"/>
  171.                         </div>
  172.                         <div class="thumb-number">
  173.                           <div class="thumb-number-value"/>
  174.                         </div>
  175.                       </div>
  176.                       
  177.                         <div class="throbber"/>
  178.                       </div>
  179.                   </a>
  180.                 </div>
  181.                 
  182.                 <h2>&yaftab.edit.caption;</h2>
  183.                 
  184.                 <p>&yaftab.edit.history.label;:</p>
  185.                 
  186.                 <!-- not xul:listbox -->
  187.                 <div class="history-list-container">
  188.                   <xul:vbox anonid="history-list"/>
  189.                 </div>
  190.                 
  191.                 <p>&yaftab.edit.url.label;:</p>
  192.                 
  193.                 <xul:textbox class="padded"
  194.                              anonid="page-url"
  195.                              type="autocomplete"
  196.                              autocompletesearch="history"
  197.                              ontextentered="document.getBindingParent(this).hanleNewURL()"
  198.                              onchange="document.getBindingParent(this).hanleNewURL()"
  199.                              oninput="document.getBindingParent(this).checkAccepButton()"
  200.                              maxlength="10000"/>
  201.                 
  202.                 <p>&yaftab.edit.name.label;:</p>
  203.                 
  204.                 <xul:textbox anonid="page-title"
  205.                              onchange="document.getBindingParent(this).refreshThumbTitle()"
  206.                              oninput="document.getBindingParent(this).refreshThumbTitle()"
  207.                              maxlength="500"/>
  208.                 
  209.                 <xul:hbox class="dialog-buttons">
  210.                   <xul:button anonid="save-button" disabled="true"
  211.                               label="&yasearch._gen.dialog.save.label;"
  212.                               oncommand="document.getBindingParent(this).close()"/>
  213.                   <xul:space flex="1"/>
  214.                   <xul:button label="&yasearch._gen.dialog.cancel.label;"
  215.                               oncommand="document.getBindingParent(this).cancel()"/>
  216.                 </xul:hbox>
  217.               </div>
  218.             </td></tr></table>
  219.           </div>
  220.         </xul:vbox>
  221.       </xul:stack>
  222.       <children/>
  223.     </content>
  224.     
  225.     <implementation>
  226.       <method name="getElementByAnonid">
  227.         <parameter name="aAnonidAttr"/>
  228.         <body><![CDATA[
  229.           return document.getAnonymousElementByAttribute(this, "anonid", aAnonidAttr);
  230.         ]]></body>
  231.       </method>
  232.       
  233.       <method name="getElementByClass">
  234.         <parameter name="aClassAttr"/>
  235.         <body><![CDATA[
  236.           return document.getAnonymousElementByAttribute(this, "class", aClassAttr);
  237.         ]]></body>
  238.       </method>
  239.       
  240.       <field name="_openTimestamp">null</field>
  241.       <field name="editedPageIndex">null</field>
  242.       <field name="controller">window.YaFTab</field>
  243.       <field name="thumbHolder">this.getElementByAnonid("pref-thumb-holder")</field>
  244.       <field name="_animations">[]</field>
  245.       
  246.       <property name="showed">
  247.         <getter><![CDATA[
  248.           return this.style.display === "-moz-box";
  249.         ]]></getter>
  250.         
  251.         <setter><![CDATA[
  252.           while (this._animations.length) {
  253.             this._animations.pop().finish();
  254.           }
  255.           
  256.           let show = !!val;
  257.           if (this.showed === show)
  258.             return;
  259.           
  260.           let thumbContainer = this.getElementByAnonid("thumb-holder-container");
  261.           
  262.           if (show) {
  263.             this._openTimestamp = Date.now();
  264.             
  265.             let thumbHolder = this.thumbHolder;
  266.             
  267.             let pageThumb = this.controller.thumbElements[this.editedPageIndex-1];
  268.             
  269.             let width = parseInt(pageThumb.offsetWidth, 10);
  270.             thumbHolder.style.width = width + "px";
  271.             thumbContainer.style.minHeight = thumbHolder.style.height = 0.75 * width + "px";
  272.             
  273.             let pageThumbNumberValue = pageThumb.getElementsByClassName("thumb-number-value")[0];
  274.             let thumbNumberValue = this.getElementByClass("thumb-number-value");
  275.             
  276.             if (pageThumbNumberValue) {
  277.               thumbNumberValue.style.backgroundPosition = pageThumbNumberValue.style.backgroundPosition;
  278.               thumbNumberValue.style.display = "block";
  279.             } else {
  280.               thumbNumberValue.style.display = "none";
  281.             }
  282.             
  283.             if ("updateProps" in thumbHolder)
  284.               thumbHolder.updateProps(this.controller.getPageProps(this.editedPageIndex));
  285.             
  286.             this.style.display = "-moz-box";
  287.             
  288.             this.getElementByAnonid("page-url").focus();
  289.             
  290.           } else {
  291.             this._openTimestamp = null;
  292.             
  293.             thumbContainer.style.height = "auto";
  294.             
  295.             this.style.display = "none";
  296.           }
  297.         ]]></setter>
  298.       </property>
  299.       
  300.       <method name="toggle">
  301.         <body><![CDATA[
  302.           this.showed = !this.showed;
  303.         ]]></body>
  304.       </method>
  305.       
  306.       <method name="_animate">
  307.         <parameter name="aShow"/>
  308.         <body><![CDATA[
  309.           let me = this;
  310.           let thumbHolder = this.thumbHolder;
  311.           let thumbHolderStyle = thumbHolder.style;
  312.           
  313.           let pageThumb = this.controller.thumbElements[this.editedPageIndex-1];
  314.           
  315.           let callback;
  316.           let animateProps;
  317.           let containerBO = this.getElementByAnonid("thumb-holder-container").getBoundingClientRect();
  318.           
  319.           thumbHolderStyle.position = "fixed";
  320.           
  321.           if (aShow) {
  322.             thumbHolderStyle.top = pageThumb.offsetTop + "px";
  323.             thumbHolderStyle.left = pageThumb.offsetLeft + "px";
  324.             
  325.             callback = function() {
  326.               thumbHolderStyle.position = "relative";
  327.               thumbHolderStyle.top = 0;
  328.               thumbHolderStyle.left = 0;
  329.             };
  330.             
  331.             animateProps = { top: containerBO.top, left: containerBO.left };
  332.             
  333.           } else {
  334.             thumbHolderStyle.top = containerBO.top + "px";
  335.             thumbHolderStyle.left = containerBO.left + "px";
  336.             
  337.             callback = function() {
  338.               thumbHolderStyle.position = "relative";
  339.               thumbHolderStyle.top = 0;
  340.               thumbHolderStyle.left = 0;
  341.               
  342.               me.style.display = "none";
  343.             };
  344.             
  345.             animateProps = { top: pageThumb.offsetTop, left: pageThumb.offsetLeft };
  346.           }
  347.           
  348.           this._animations.push(this.Effects.animate(thumbHolder, animateProps, 200, callback));
  349.         ]]></body>
  350.       </method>
  351.       
  352.       <method name="fillHistory">
  353.         <parameter name="aHistoryArray"/>
  354.         <body><![CDATA[
  355.           let historyList = this.getElementByAnonid("history-list");
  356.           while (historyList.firstChild)
  357.             historyList.removeChild(historyList.firstChild);
  358.           
  359.           if (!(aHistoryArray && aHistoryArray.length))
  360.             return;
  361.           
  362.           function createElement(tagName) {
  363.             return document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", tagName);
  364.           }
  365.           
  366.           function createListItem(aFavicon, aURL, aTitle) {
  367.             let listItem = createElement("hbox");
  368.             listItem.setAttribute("class", "iconic-list-item");
  369.             listItem.setAttribute("yaURL", aURL || "");
  370.             listItem.setAttribute("yaTitle", aTitle || aURL || "");
  371.             listItem.setAttribute("tooltiptext", aURL || "");
  372.             
  373.             let image = createElement("image");
  374.             image.setAttribute("src", aFavicon);
  375.             
  376.             let label = createElement("label");
  377.             label.setAttribute("value", aTitle || aURL);
  378.             label.setAttribute("crop", "end");
  379.             
  380.             listItem.appendChild(image);
  381.             listItem.appendChild(label);
  382.             
  383.             return listItem;
  384.           }
  385.           
  386.           aHistoryArray.forEach(function(aHistoryObject) {
  387.             historyList.appendChild(createListItem(aHistoryObject.icon, aHistoryObject.url, aHistoryObject.title));
  388.           });
  389.         ]]></body>
  390.       </method>
  391.       
  392.       <method name="getText">
  393.         <parameter name="aType"/>
  394.         <body><![CDATA[
  395.           let textbox = this.getElementByAnonid("page-" + aType);
  396.           return (textbox && textbox.localName == "textbox") ? textbox.value : "";
  397.         ]]></body>
  398.       </method>
  399.       
  400.       <method name="setText">
  401.         <parameter name="aType"/>
  402.         <parameter name="aText"/>
  403.         <parameter name="aNotModifiedManual"/>
  404.         <body><![CDATA[
  405.           let textbox = this.getElementByAnonid("page-" + aType);
  406.           if (textbox && textbox.localName == "textbox") {
  407.             if (!(aNotModifiedManual && textbox.value) || (textbox.defaultValue === textbox.value)) {
  408.               textbox.value = aText;
  409.               textbox.defaultValue = aText;
  410.               
  411.               if (aType == "url")
  412.                 this.hanleNewURL();
  413.             }
  414.           }
  415.         ]]></body>
  416.       </method>
  417.       
  418.       <method name="refreshThumbTitle">
  419.         <parameter name="aTimeoutValue"/>
  420.         <body><![CDATA[
  421.           let timeout = typeof aTimeoutValue == "number" ? aTimeoutValue : 400;
  422.           if (this._refreshThumbTitleTimeout)
  423.             window.clearTimeout(this._refreshThumbTitleTimeout);
  424.           
  425.           let props = {title: this.getText("title")};
  426.           if (!timeout) {
  427.             this.thumbHolder.updateProps(props);
  428.           } else {
  429.             this._refreshThumbTitleTimeout = window.setTimeout(function(thumbHolder, props) {
  430.               thumbHolder.updateProps(props);
  431.             }, timeout, this.thumbHolder, {title: this.getText("title")});
  432.           }
  433.         ]]></body>
  434.       </method>
  435.       
  436.       <method name="hanleNewURL">
  437.         <body><![CDATA[
  438.           this.checkAccepButton();
  439.           
  440.           let url = this.controller.getURLFromString(this.getText("url"));
  441.           if (!url)
  442.             return false;
  443.           
  444.           let thumbHolder = this.thumbHolder;
  445.           if (thumbHolder.getAttribute("href") !== url) {
  446.             thumbHolder.setAttribute("href", url);
  447.             
  448.             if (this.showed)
  449.               this.controller.hanleNewURL(url, true);
  450.           }
  451.           
  452.           return true;
  453.         ]]></body>
  454.       </method>
  455.       
  456.       <method name="checkAccepButton">
  457.         <body><![CDATA[
  458.           let url = this.controller.getURLFromString(this.getText("url"));
  459.           this.getElementByAnonid("save-button").disabled = !url;
  460.         ]]></body>
  461.       </method>
  462.       
  463.       <method name="open">
  464.         <parameter name="aPageIndex"/>
  465.         <parameter name="aPageData"/>
  466.         <body><![CDATA[
  467.           this.editedPageIndex = aPageIndex;
  468.           
  469.           this.showed = true;
  470.           
  471.           this.setText("url", aPageData.url || "http://");
  472.           this.setText("title", aPageData.title || "");
  473.           
  474.           let me = this;
  475.           setTimeout(function(me) {
  476.             me.controller.getSitesFromHistory(function(res){me.fillHistory(res);});
  477.           }, 0, me);
  478.         ]]></body>
  479.       </method>
  480.       
  481.       <method name="close">
  482.         <parameter name="aIgroneChanges"/>
  483.         <body><![CDATA[
  484.           let data = null;
  485.           
  486.           if (!aIgroneChanges) {
  487.             let url = this.controller.getURLFromString(this.getText("url"));
  488.             
  489.             if (url) {
  490.               data = {
  491.                 url: url,
  492.                 title: this.getText("title")
  493.               };
  494.             }
  495.           }
  496.           
  497.           this.controller.onEditorCallback(this.editedPageIndex, data, this._openTimestamp);
  498.           
  499.           this.showed = false;
  500.         ]]></body>
  501.       </method>
  502.       
  503.       <method name="cancel">
  504.         <body><![CDATA[
  505.           this.close(true);
  506.         ]]></body>
  507.       </method>
  508.       
  509.       <destructor>
  510.         <![CDATA[
  511.           this.cancel();
  512.           this.editedPageIndex = null;
  513.         ]]>
  514.       </destructor>
  515.       
  516.       <method name="_hitEnter">
  517.         <parameter name="aEvent"/>
  518.         <body>
  519.         <![CDATA[
  520.           if (aEvent.getPreventDefault())
  521.             return;
  522.           
  523.           let saveButton = this.getElementByAnonid("save-button");
  524.           if (!saveButton.disabled)
  525.             saveButton.doCommand();
  526.         ]]>
  527.         </body>
  528.       </method>
  529.     </implementation>
  530.     
  531.     <handlers>
  532.       <handler event="click" button="0">
  533.         <![CDATA[
  534.         let target = event.originalTarget;
  535.         let node = target;
  536.         let level = 0;
  537.         while (level++ < 10 && node && !("hasAttribute" in node && node.hasAttribute("anonid"))) {
  538.           node = node.parentNode;
  539.         }
  540.         
  541.         let anonid = node && ("getAttribute" in node) ? node.getAttribute("anonid") : null;
  542.         switch (anonid) {
  543.           case "history-list":
  544.             let hbox = target;
  545.             while (hbox && hbox.localName !== "hbox") {
  546.               hbox = hbox.parentNode;
  547.             }
  548.             
  549.             this.setText("url", hbox.getAttribute("yaURL"));
  550.             this.setText("title", hbox.getAttribute("yaTitle"));
  551.             this.refreshThumbTitle(0);
  552.             
  553.             break;
  554.           
  555.           default:
  556.             break;
  557.         }
  558.         ]]>
  559.       </handler>
  560.       
  561.       <handler event="keypress" keycode="VK_ESCAPE" group="system" action="this.cancel();"/>
  562.       <handler event="keypress" keycode="VK_ENTER"  group="system" action="this._hitEnter(event);"/>
  563.       <handler event="keypress" keycode="VK_RETURN" group="system" action="this._hitEnter(event);"/>
  564.     </handlers>
  565.   </binding>
  566. </bindings>