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 / fil7AAC6FA3217C2DECD77C16F49E1E57B9 < prev    next >
Extensible Markup Language  |  2010-07-12  |  20KB  |  592 lines

  1. <?xml version="1.0"?>
  2.  
  3. <bindings xmlns="http://www.mozilla.org/xbl"
  4.           xmlns:xbl="http://www.mozilla.org/xbl"
  5.           xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  6.           xmlns:html="http://www.w3.org/1999/xhtml">
  7.   
  8.   <binding id="prefWindow-dlgbuttons-hack">
  9.     <content style="max-height:1px; overflow: hidden; visibility: hidden">
  10.       <grid xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  11.         <columns flex="1">
  12.           <column style="width:15em"/>
  13.           <column/>
  14.           <column flex="1"/>
  15.           <column/>
  16.         </columns>
  17.         <rows flex="1">
  18.           <row flex="1">
  19.             <vbox><richlistbox/></vbox>
  20.             <vbox class="buttons-container"><button class="minimal arrow-right"/></vbox>
  21.             <vbox><richlistbox/></vbox>
  22.             <vbox class="buttons-container"><button class="minimal arrow-up"/></vbox>
  23.           </row>
  24.           <row anonid="sizes-hack"><button/><hbox/><button/><hbox/></row>
  25.         </rows>
  26.       </grid>
  27.     </content>
  28.     
  29.     <implementation>
  30.       <constructor>
  31.       <![CDATA[
  32.         window.setTimeout(function(me) me.constructorEx(), 0, this);
  33.       ]]>
  34.       </constructor>
  35.       
  36.       <method name="constructorEx">
  37.         <body><![CDATA[
  38.           const dialog = document.documentElement;
  39.  
  40.           if (dialog.hasAttribute("prefWindow-dlgbuttons-hack"))
  41.             return;
  42.  
  43.           dialog.setAttribute("prefWindow-dlgbuttons-hack", "true");
  44.  
  45.           function setAttributes(aElement, aAttributes) {
  46.             for (let [name, val] in Iterator(aAttributes))
  47.               aElement.setAttribute(name, val);
  48.           }
  49.           
  50.           let hackChildNodes = document.getAnonymousElementByAttribute(this, "anonid", "sizes-hack").childNodes;
  51.           let [w1, w2, w3, w4] = Array.slice(hackChildNodes).map(function(aNode) aNode.boxObject.width);
  52.  
  53.           let extra2Button = dialog.getButton("extra2");
  54.           let container = extra2Button.parentNode;
  55.  
  56.           let clone = document.createElement("button");
  57.           setAttributes(clone, {
  58.             "command":  "cmd_deleteWidgets",
  59.             "observes": "canDeleteWidgetsBroadcaster",
  60.             "class":    "dialog-button",
  61.             "dlgtype":  "customdelete",
  62.             "width":    w1
  63.           });
  64.  
  65.           if (dialog.hasAttribute("buttonlabelcustomdelete")) {
  66.             let label = document.createElement("label");
  67.  
  68.             setAttributes(label, {
  69.               "flex":  "1",
  70.               "crop":  "end",
  71.               "class": "plain",
  72.               "value": dialog.getAttribute("buttonlabelcustomdelete"),
  73.               "style": "text-align: center;"
  74.             });
  75.  
  76.             clone.appendChild(label);
  77.           }
  78.  
  79.           container.insertBefore(clone, extra2Button);
  80.  
  81.           let hbox = document.createElement("hbox");
  82.           hbox.setAttribute("width", w2);
  83.           container.insertBefore(hbox, extra2Button);
  84.  
  85.           hbox = document.createElement("hbox");
  86.           hbox.setAttribute("width", w4);
  87.           container.appendChild(hbox);
  88.           
  89.           // for macos fx35-
  90.           const appInfo = Components.classes["@mozilla.org/xre/app-info;1"]
  91.                                     .getService(Components.interfaces.nsIXULAppInfo)
  92.                                     .QueryInterface(Components.interfaces.nsIXULRuntime);
  93.           
  94.           if (/darwin/i.test(appInfo.OS) && !Components.interfaces.nsIDOMGeoPositionAddress) {
  95.             let btnMargin = hackChildNodes[0].boxObject.screenX;
  96.             btnMargin -= clone.boxObject.screenX;
  97.             btnMargin += parseInt(window.getComputedStyle(clone, null).getPropertyValue("margin-left"), 10);          
  98.             clone.setAttribute("style", "margin-left:" + btnMargin + "px");
  99.           }
  100.         ]]></body>
  101.       </method>
  102.     </implementation>
  103.   </binding>
  104.   
  105.   <binding id="button-minimal"
  106.            extends="chrome://global/content/bindings/button.xml#button"
  107.            inheritstyle="false">
  108.       <resources>
  109.         <stylesheet src="button.css"/>
  110.       </resources>
  111.       
  112.       <content pack="center" align="center">
  113.         <xul:image/>
  114.       </content>
  115.   </binding>
  116.   
  117.   <binding id="richlistbox"
  118.            extends="chrome://global/content/bindings/richlistbox.xml#richlistbox">
  119.     <implementation>
  120.       <field name="mDNDDataType">"application/x-xb-node"</field>
  121.       
  122.       <method name="clear">
  123.         <body><![CDATA[
  124.           this.clearSelection();
  125.           
  126.           while (this.firstChild)
  127.             this.removeChild(this.firstChild);
  128.         ]]></body>
  129.       </method>
  130.       
  131.       <method name="insertItem">
  132.         <parameter name="aIsUnique"/>
  133.         <parameter name="aIsRemovable"/>
  134.         <parameter name="aId"/>
  135.         <parameter name="aLabel"/>
  136.         <parameter name="aIconURL"/>
  137.         <parameter name="aBeforeId"/>
  138.         <body><![CDATA[
  139.           const XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
  140.           
  141.           let richlistitem = this.ownerDocument.createElementNS(XULNS, "richlistitem");
  142.           richlistitem.setAttribute("id", aId);
  143.           richlistitem.setAttribute("isUnique", aIsUnique);
  144.           richlistitem.setAttribute("isRemovable", aIsRemovable);
  145.           richlistitem.setAttribute("label", aLabel);
  146.           richlistitem.setAttribute("image", aIconURL);
  147.           
  148.           let beforeElement = aBeforeId ? document.getElementById(aBeforeId) : null;
  149.           
  150.           if (beforeElement && beforeElement.parentNode == this)
  151.             this.insertBefore(richlistitem, beforeElement);
  152.           else
  153.             this.appendChild(richlistitem);
  154.           
  155.           return richlistitem;
  156.         ]]></body>
  157.       </method>
  158.       
  159.       <property name="selectedItemsSorted" reodonly="true">
  160.         <getter><![CDATA[
  161.           let selectedItems = Array.slice(this.selectedItems);
  162.           
  163.           let len = selectedItems.length;
  164.           if (!len)
  165.             return null;
  166.           
  167.           let me = this;
  168.           selectedItems = selectedItems.sort(function(a,b) {
  169.             let indxA = me.getIndexOfItem(a);
  170.             let indxB = me.getIndexOfItem(b);
  171.             return (indxA > indxB) ? 1 : (indxA < indxB) ? -1 : 0;
  172.           });
  173.           
  174.           return selectedItems;
  175.         ]]></getter>
  176.       </property>
  177.       
  178.       <method name="_dragWithCustomImage">
  179.         <parameter name="aEvent"/>
  180.         <parameter name="aRect"/>
  181.         <body><![CDATA[
  182.           let doc = this.ownerDocument;
  183.           
  184.           let canvas = doc.createElementNS("http://www.w3.org/1999/xhtml", "canvas");
  185.           canvas.width = aRect.right - aRect.left;
  186.           canvas.height = aRect.bottom - aRect.top;
  187.           
  188.           let ctx = canvas.getContext("2d");
  189.           
  190.           ctx.drawWindow(doc.defaultView,
  191.                          aRect.left,
  192.                          aRect.top,
  193.                          aRect.right,
  194.                          aRect.bottom,
  195.                          "rgb(255,255,255)");
  196.           
  197.           let dt = aEvent.dataTransfer;
  198.           dt.effectAllowed = "move";
  199.           dt.setDragImage(canvas, 5, 5);
  200.         ]]></body>
  201.       </method>
  202.       
  203.       <method name="_getListitemFromEvent">
  204.         <parameter name="aEvent"/>
  205.         <body><![CDATA[
  206.           return aEvent.dataTransfer.mozGetDataAt(this.mDNDDataType, 0);
  207.         ]]></body>
  208.       </method>
  209.     </implementation>
  210.     
  211.     <handlers>
  212.       <handler event="dragstart"><![CDATA[
  213.         if (!(event.target && event.target.localName == "richlistitem"))
  214.           return;
  215.         
  216.         // <menu/> DnD
  217.         let originalTarget = event.originalTarget;
  218.         if (originalTarget && (originalTarget.localName == "menuitem" || originalTarget.localName == "thumb"))
  219.           return;
  220.         
  221.         if ("expandItem" in this)
  222.           this.expandItem(null);
  223.         
  224.         let selectedItems = this.selectedItemsSorted;
  225.         let len = selectedItems.length;
  226.         
  227.         if (!len)
  228.           return;
  229.         
  230.         for (let i = 0; i < len; i++)
  231.           event.dataTransfer.mozSetDataAt(this.mDNDDataType, selectedItems[i], i);
  232.         
  233.         if (len == 1 && "collapsedSettings" in selectedItems[0])
  234.           selectedItems[0].collapsedSettings = true;
  235.         
  236.         let listRect = this.getBoundingClientRect();
  237.         let firstRect = selectedItems[0].getBoundingClientRect();
  238.         let lastRect = selectedItems[len-1].getBoundingClientRect();
  239.         
  240.         let rect = {
  241.           left:   firstRect.left,
  242.           right:  firstRect.right,
  243.           top:    firstRect.top > listRect.top ? firstRect.top : listRect.top,
  244.           bottom: lastRect.bottom < listRect.bottom ? lastRect.bottom : listRect.bottom
  245.         };
  246.         
  247.         this._dragWithCustomImage(event, rect);
  248.       ]]></handler>
  249.     </handlers>
  250.   </binding>
  251.   
  252.   <binding id="richlistbox-registered" extends="#richlistbox">
  253.     <handlers>
  254.       <handler event="dragover"><![CDATA[
  255.         let listitem = this._getListitemFromEvent(event);
  256.         if (listitem && listitem.parentNode !== this)
  257.           event.preventDefault();
  258.       ]]></handler>
  259.       
  260.       <handler event="drop"><![CDATA[
  261.         if (this._getListitemFromEvent(event))
  262.           Preferences.doCommand("cmd_removeWidgets");
  263.       ]]></handler>
  264.       
  265.       <handler event="focus" phase="capturing"><![CDATA[
  266.         if (event.target == this)
  267.           Preferences.checkControls();
  268.       ]]></handler>
  269.       
  270.       <handler event="blur" phase="capturing"><![CDATA[
  271.         if (event.target == this)
  272.           Preferences.checkControls();
  273.       ]]></handler>
  274.     </handlers>
  275.   </binding>
  276.   
  277.   <binding id="richlistbox-active" extends="#richlistbox">
  278.     <implementation>
  279.       <field name="mDragOverAttrName">"xb-dragover-node"</field>
  280.       <field name="mLastDragOverId">null</field>
  281.       
  282.       <method name="moveSelectedItems">
  283.         <parameter name="aDirection"/>
  284.         <parameter name="aBeforeElementId"/>
  285.         <body><![CDATA[
  286.           let selectedItems = this.selectedItemsSorted;
  287.           
  288.           if (!selectedItems)
  289.             return;
  290.           
  291.           let len = selectedItems.length;
  292.           if (len == this.itemCount)
  293.             return;
  294.           
  295.           let beforeElement;
  296.           
  297.           if (aBeforeElementId)
  298.             beforeElement = document.getElementById(aBeforeElementId);
  299.           
  300.           if (aDirection == "down")
  301.             beforeElement = beforeElement ? beforeElement.nextSibling : null;
  302.           
  303.           while (beforeElement && selectedItems.indexOf(beforeElement) != -1)
  304.             beforeElement = beforeElement.nextSibling;
  305.           
  306.           this.clearSelection();
  307.           
  308.           if (len == 1 && !selectedItems[0].collapsedSettings)
  309.             selectedItems[0].collapsedSettings = true;
  310.           
  311.           let docFrag = this.ownerDocument.createDocumentFragment();
  312.           
  313.           for (let i = 0; i < len; i++)
  314.             docFrag.appendChild(this.removeChild(selectedItems[i]));
  315.           
  316.           beforeElement ? this.insertBefore(docFrag, beforeElement)
  317.                         : this.appendChild(docFrag);
  318.           
  319.           this.selectItemRange(selectedItems[0], selectedItems[len - 1]);
  320.         ]]></body>
  321.       </method>
  322.       
  323.       <method name="expandItem">
  324.         <parameter name="aItem"/>
  325.         <parameter name="aSwitchState"/>
  326.         <body><![CDATA[
  327.           let state = this.getAttribute("last-selected").split(" ");
  328.           if (state) {
  329.             state.forEach(function(aId) {
  330.               let item = aId ? document.getElementById(aId) : null;
  331.               if (item && item != aItem)
  332.                 item.collapsedSettings = true;
  333.             });
  334.           }
  335.           
  336.           this._timedExpandItem(aItem, aSwitchState);
  337.         ]]></body>
  338.       </method>
  339.       
  340.       <field name="_timedExpandItemTimer">null</field>
  341.       
  342.       <method name="stopExpandItem">
  343.         <body><![CDATA[
  344.           if (this._timedExpandItemTimer) {
  345.             window.clearTimeout(this._timedExpandItemTimer);
  346.             this._timedExpandItemTimer = null;
  347.           }
  348.         ]]></body>
  349.       </method>
  350.       
  351.       <method name="_timedExpandItem">
  352.         <parameter name="aItem"/>
  353.         <parameter name="aSwitchState"/>
  354.         <body><![CDATA[
  355.           this.stopExpandItem();
  356.           
  357.           this._timedExpandItemTimer = window.setTimeout(function(item, switchState) {
  358.             if (item && "collapsedSettings" in item)
  359.               item.collapsedSettings = (typeof switchState == "undefined") ? false : !item.collapsedSettings;
  360.           }, 250, aItem, aSwitchState);
  361.         ]]></body>
  362.       </method>
  363.     </implementation>
  364.     
  365.     <handlers>
  366.       <handler event="click" button="0">
  367.         <![CDATA[
  368.           let target = event.target;
  369.           if (target.localName == "richlistitem" &&
  370.               this.selectedItems.length == 1 &&
  371.               target.isClickedOnCaption(event))
  372.             this.expandItem(target, true);
  373.         ]]>
  374.       </handler>
  375.       
  376.       <handler event="DOMMenuItemActive">
  377.         this.expandItem(this.selectedItems.length == 1 ? this.selectedItem : null);
  378.       </handler>
  379.       
  380.       <handler event="dragover"><![CDATA[
  381.         let listitem = this._getListitemFromEvent(event);
  382.         
  383.         if (!listitem)
  384.           return;
  385.         
  386.         let target = event.target;
  387.         
  388.         if (target && target == this.lastChild) {
  389.           let { top: top, bottom: bottom } = target.getBoundingClientRect();
  390.           let halfPoint = top + parseInt((bottom - top) / 2, 10);
  391.           
  392.           if (halfPoint < event.clientY) {
  393.             target.setAttribute(this.mDragOverAttrName, "after");
  394.             this.mLastDragOverId = null;
  395.           } else {
  396.             target.setAttribute(this.mDragOverAttrName, "before");
  397.             this.mLastDragOverId = target.id;
  398.           }
  399.         }
  400.         
  401.         event.preventDefault();
  402.       ]]></handler>
  403.       
  404.       <handler event="dragenter"><![CDATA[
  405.         let listitem = this._getListitemFromEvent(event);
  406.         
  407.         if (!listitem)
  408.           return;
  409.         
  410.         let target = event.target;
  411.         
  412.         if (target.localName != "richlistitem")
  413.           return;
  414.         
  415.         target.setAttribute(this.mDragOverAttrName, "before");
  416.         this.mLastDragOverId = target.id;
  417.         
  418.         window.setTimeout(function(me, target) {
  419.           if (!(me && target && target.parentNode == me && "ensureElementIsVisible" in me))
  420.             return;
  421.           
  422.           let listRect = me.getBoundingClientRect();
  423.           
  424.           let prevSibling = target.previousSibling;
  425.           if (prevSibling) {
  426.             let { top: top } = prevSibling.getBoundingClientRect();
  427.             
  428.             if (top < listRect.top) {
  429.               me.ensureElementIsVisible(prevSibling);
  430.               return;
  431.             }
  432.           }
  433.           
  434.           let nextSibling = target.nextSibling;
  435.           if (nextSibling) {
  436.             let { bottom: bottom } = nextSibling.getBoundingClientRect();
  437.             
  438.             if (bottom > listRect.bottom) {
  439.               me.ensureElementIsVisible(nextSibling);
  440.               return;
  441.             }
  442.           }
  443.           
  444.           me.ensureElementIsVisible(target);
  445.           
  446.         }, 150, this, target);
  447.         
  448.         event.preventDefault();
  449.       ]]></handler>
  450.       
  451.       <handler event="dragleave"><![CDATA[
  452.         let listitem = this._getListitemFromEvent(event);
  453.         
  454.         if (listitem) {
  455.           let target = event.target;
  456.           
  457.           if (target.localName == "richlistitem") {
  458.             target.removeAttribute(this.mDragOverAttrName);
  459.           } else if (target == this) {
  460.             this.mLastDragOverId = null;
  461.           }
  462.         }
  463.       ]]></handler>
  464.       
  465.       <handler event="drop"><![CDATA[
  466.         let listitem = this._getListitemFromEvent(event);
  467.         
  468.         if (listitem) {
  469.           let nodeBefore = this.mLastDragOverId ? document.getElementById(this.mLastDragOverId) : null;
  470.           let cmd = listitem.parentNode == this ? "cmd_moveWidgets" : "cmd_addWidgets";
  471.           Preferences.doCommand(cmd, nodeBefore);
  472.         }
  473.         
  474.         this.mLastDragOverId = null;
  475.       ]]></handler>
  476.     </handlers>
  477.   </binding>
  478.   
  479.   <binding id="richlistitem-base"
  480.            extends="chrome://global/content/bindings/richlistbox.xml#richlistitem">
  481.     <implementation>
  482.       
  483.       <property name="isUnique" readonly="true"
  484.                 onget="return this.getAttribute('isUnique') == 'true';"/>
  485.       
  486.       <property name="isRemovable" readonly="true"
  487.                 onget="return this.getAttribute('isRemovable') == 'true';"/>
  488.     
  489.     </implementation>
  490.   </binding>
  491.   
  492.   <binding id="registered-richlistitem" extends="#richlistitem-base">
  493.     <content>
  494.       <xul:hbox flex="1" xbl:inherits="tooltiptext=label" anonid="caption">
  495.         <xul:hbox align="center" pack="center">
  496.           <xul:image class="xb-widget-icon" xbl:inherits="src=image"/>
  497.         </xul:hbox>
  498.         <xul:label xbl:inherits="value=label" flex="1" crop="end"/>
  499.       </xul:hbox>
  500.     </content>
  501.     
  502.     <handlers>
  503.       <handler event="dblclick" button="0"><![CDATA[
  504.         if (event.target == this)
  505.           Preferences.doCommand("cmd_addWidgets");
  506.       ]]></handler>
  507.     </handlers>
  508.   </binding>
  509.   
  510.   <binding id="active-richlistitem" extends="#richlistitem-base">
  511.     <content collapsedSettings="true">
  512.       <xul:vbox flex="1">
  513.         <xul:hbox flex="1" anonid="caption">
  514.           <xul:hbox align="center" pack="center">
  515.             <xul:image class="xb-widget-icon" xbl:inherits="src=image"/>
  516.           </xul:hbox>
  517.           <xul:label xbl:inherits="value=label" flex="1" crop="end"/>
  518.         </xul:hbox>
  519.         <xul:vbox anonid="settingsContainer" xbl:inherits="collapsed=collapsedSettings">
  520.           <children/>
  521.         </xul:vbox>
  522.       </xul:vbox>
  523.     </content>
  524.     
  525.     <implementation>
  526.       <field name="mListitemCaption">
  527.         document.getAnonymousElementByAttribute(this, "anonid", "caption")
  528.       </field>
  529.       
  530.       <field name="settingsContainer">
  531.         document.getAnonymousElementByAttribute(this, "anonid", "settingsContainer")
  532.       </field>
  533.       
  534.       <property name="collapsedSettings">
  535.         <getter><![CDATA[
  536.           return this.getAttribute("collapsedSettings") == "true";
  537.         ]]></getter>
  538.         
  539.         <setter><![CDATA[
  540.           let collapsedBefore = this.collapsedSettings;
  541.           this.setAttribute("collapsedSettings", !!val);
  542.           
  543.           if (collapsedBefore == this.collapsedSettings)
  544.             return;
  545.           
  546.           if (collapsedBefore) {
  547.             ActiveWidgetsController.initItemSettings(this);
  548.             this.parentNode.ensureElementIsVisible(this);
  549.           } else {
  550.             let focusedElement = document.commandDispatcher.focusedElement;
  551.             
  552.             if (focusedElement &&
  553.                 focusedElement.ownerDocument == document &&
  554.                 focusedElement.localName == "input") {
  555.               focusedElement.blur();
  556.             }
  557.             
  558.             let settingsContainer = this.settingsContainer;
  559.             while (settingsContainer.firstChild) {
  560.               settingsContainer.firstChild.blur();
  561.               settingsContainer.removeChild(settingsContainer.firstChild);
  562.             }
  563.           }
  564.         ]]></setter>
  565.       </property>
  566.       
  567.       <method name="isClickedOnCaption">
  568.         <parameter name="aEvent"/>
  569.         <body><![CDATA[
  570.           if (aEvent.target == this) {
  571.             try {
  572.               return (aEvent.originalTarget == this.mListitemCaption) ||
  573.                      !!(this.mListitemCaption.compareDocumentPosition(aEvent.originalTarget)
  574.                         & Node.DOCUMENT_POSITION_CONTAINED_BY);
  575.             } catch(e) {}
  576.           }
  577.           
  578.           return false;
  579.         ]]></body>
  580.       </method>
  581.     </implementation>
  582.     
  583.     <handlers>
  584.       <handler event="dblclick" button="0"><![CDATA[
  585.         if (this.isClickedOnCaption(event))
  586.             Preferences.doCommand("cmd_removeWidgets");
  587.       ]]></handler>
  588.     </handlers>
  589.   </binding>
  590.   
  591. </bindings>
  592.