home *** CD-ROM | disk | FTP | other *** search
- <?xml version="1.0"?>
-
- <bindings xmlns="http://www.mozilla.org/xbl"
- xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
- xmlns:xbl="http://www.mozilla.org/xbl"
- xmlns:html="http://www.w3.org/1999/xhtml">
-
- <binding id="tab-base">
- <resources>
- <stylesheet src="chrome://yasearch/skin/dialogs/tabbox.css"/>
- </resources>
- </binding>
-
- <binding id="dialogcontent"
- extends="chrome://yasearch/content/dialogs/tabs-bindings.xbl#tab-base">
- <content>
- <xul:deck flex="1" anonid="deck">
- <children includes="ya:tabbox"/>
- </xul:deck>
- <children/>
- </content>
-
- <implementation>
- <property name="selectedIndex">
- <getter><![CDATA[
- var indexStr = this.getAttribute("selectedIndex");
- return indexStr ? parseInt(indexStr, 10) : -1;
- ]]></getter>
-
- <setter><![CDATA[
- this.setAttribute("selectedIndex", val);
- this.deck.selectedIndex = val;
- return val;
- ]]></setter>
- </property>
-
- <property name="selectedPanel" readonly="true">
- <getter><![CDATA[
- return this.deck.panels[this.selectedIndex];
- ]]></getter>
- </property>
-
- <field name="deck">document.getAnonymousElementByAttribute(this, "anonid", "deck")</field>
-
- <constructor><![CDATA[
- this.selectedIndex = 0;
- ]]></constructor>
-
- </implementation>
-
- <handlers>
- <handler event="click" button="0">
- <![CDATA[
- var anonid, target = event.originalTarget;
- while (target && 'getAttribute' in target && !(anonid = target.getAttribute("anonid")))
- target = target.parentNode;
-
- if (anonid == "closeButton") {
- document.documentElement.cancelDialog();
- }
- ]]>
- </handler>
- </handlers>
- </binding>
-
- <binding id="deck-stack">
- <implementation>
- <property name="panels" readonly="true">
- <getter><![CDATA[
- return Array.slice(document.getBindingParent(this)
- .getElementsByTagNameNS("http://bar.yandex.ru/firefox", "tabbox"));
- ]]></getter>
- </property>
-
- <property name="selectedIndex">
- <getter><![CDATA[
- var indexStr = this.getAttribute("selectedIndex");
- return indexStr ? parseInt(indexStr, 10) : -1;
- ]]></getter>
-
- <setter><![CDATA[
- if (val < 0 || val >= this.panels.length)
- return val;
-
- this.setAttribute("selectedIndex", val);
-
- var panelToSelect = this.panels[this.selectedIndex];
- panelToSelect.setAttribute("selected", "true");
-
- Array.forEach(this.panels, function (aPanel) {
- if (aPanel != panelToSelect)
- aPanel.setAttribute("selected", "false");
- });
-
- return val;
- ]]></setter>
- </property>
- </implementation>
- </binding>
-
- <binding id="tabbox"
- extends="chrome://yasearch/content/dialogs/tabs-bindings.xbl#tab-base">
- <content yaSingleTabbox="true">
- <xul:stack anonid="title" yadraggable="true">
- <xul:image anonid="title-bg"/>
- <xul:vbox anonid="throbber-container" flex="1" pack="center" align="start">
- <xul:image/>
- </xul:vbox>
- <xul:hbox anonid="label-container" flex="1" pack="center" align="center">
- <xul:label xbl:inherits="value=title" flex="1"/>
- </xul:hbox>
- <xul:vbox flex="1" pack="center" align="end">
- <html:div anonid="closeButton" yadraggable="false"/>
- </xul:vbox>
- </xul:stack>
- <xul:stack anonid="content-stack" flex="1">
- <html:div class="content-background" flex="1">
- <html:img src="chrome://yasearch/skin/dialogs/images/dialog/content.bg.png"/>
- </html:div>
- <xul:vbox anonid="content" flex="1">
- <children/>
- </xul:vbox>
- </xul:stack>
- </content>
-
- <implementation>
- <field name="content">document.getAnonymousElementByAttribute(this, "anonid", "content")</field>
- <field name="contentTitle">document.getAnonymousElementByAttribute(this, "anonid", "title")</field>
-
- <property name="currentHeight" readonly="true">
- <getter><![CDATA[
- return this.contentTitle.boxObject.height +
- this.content.boxObject.height;
- ]]></getter>
- </property>
-
- <field name="_busy">false</field>
- <field name="_busyTimeout">null</field>
-
- <method name="_clearBusyTimeout">
- <body><![CDATA[
- if (this._busyTimeout) {
- window.clearTimeout(this._busyTimeout);
- this._busyTimeout = null;
- }
- ]]></body>
- </method>
-
- <property name="busy">
- <getter><![CDATA[
- return this._busy;
- ]]></getter>
-
- <setter><![CDATA[
- val = !!val;
-
- if (this._busy != val) {
- this._busy = val;
-
- this._clearBusyTimeout();
- this._busyTimeout = window.setTimeout(function(me) {
- me.setAttribute("busy", val);
- }, 1000, this)
- }
-
- return val;
- ]]></setter>
- </property>
-
- <property name="tabs" readonly="true">
- <getter><![CDATA[
- return this.getElementsByTagNameNS("http://bar.yandex.ru/firefox", "tabs").item(0);
- ]]></getter>
- </property>
-
- <property name="tabpanels" readonly="true">
- <getter><![CDATA[
- return this.getElementsByTagNameNS("http://bar.yandex.ru/firefox", "tabpanels").item(0);
- ]]></getter>
- </property>
-
- <property name="selectedIndex">
- <getter><![CDATA[
- var tabs = this.tabs;
- return tabs ? tabs.selectedIndex : -1;
- ]]></getter>
-
- <setter><![CDATA[
- var tabs = this.tabs;
-
- if (tabs)
- tabs.selectedIndex = val;
-
- this.setAttribute("selectedIndex", val);
-
- return val;
- ]]></setter>
- </property>
-
- <property name="selectedTab">
- <getter><![CDATA[
- var tabs = this.tabs;
- return tabs && tabs.selectedItem;
- ]]></getter>
-
- <setter><![CDATA[
- if (val) {
- var tabs = this.tabs;
- if (tabs)
- tabs.selectedItem = val;
- }
- return val;
- ]]></setter>
- </property>
-
- <property name="selectedPanel">
- <getter><![CDATA[
- var tabpanels = this.tabpanels;
- return tabpanels && tabpanels.selectedPanel;
- ]]></getter>
-
- <setter><![CDATA[
- if (val) {
- var tabpanels = this.tabpanels;
- if (tabpanels)
- tabpanels.selectedPanel = val;
- }
- return val;
- ]]></setter>
- </property>
-
- <constructor><![CDATA[
- ]]></constructor>
-
- <destructor><![CDATA[
- this._clearBusyTimeout();
- ]]></destructor>
- </implementation>
-
- </binding>
-
- <binding id="tabs"
- extends="chrome://yasearch/content/dialogs/tabs-bindings.xbl#tab-base">
- <content>
- <xul:hbox xbl:inherits="equalsize">
- <children/>
- </xul:hbox>
- </content>
-
- <implementation>
- <property name="tabs" readonly="true"
- onget="return this.getElementsByTagNameNS('http://bar.yandex.ru/firefox', 'tab')"/>
-
- <constructor><![CDATA[
- for (var parent = this.parentNode; parent; parent = parent.parentNode) {
- if (parent.localName == "tabbox" && parent.hasAttribute("selectedIndex")) {
- var selectedIndex = parseInt(parent.getAttribute("selectedIndex"), 10);
- this.selectedIndex = selectedIndex > 0 ? selectedIndex : 0;
- return;
- }
- }
-
- var children = this.tabs;
- var length = children.length;
- for (var i = 0; i < length; i++) {
- if (children[i].getAttribute("selected") == "true") {
- this.selectedIndex = i;
- return;
- }
- }
-
- this.selectedIndex = 0;
- ]]></constructor>
-
- <property name="itemCount" readonly="true"
- onget="return this.tabs.length"/>
-
- <property name="selectedIndex">
- <getter><![CDATA[
- const tabs = this.tabs;
- for (var i = 0; i < tabs.length; i++) {
- if (tabs[i].selected)
- return i;
- }
- return -1;
- ]]></getter>
-
- <setter><![CDATA[
- var tab = this.getItemAtIndex(val);
- if (tab) {
- var alreadySelected = tab.selected;
-
- Array.forEach(this.tabs, function (aTab) {
- if (aTab.selected && aTab != tab)
- aTab._selected = false;
- });
-
- tab._selected = true;
-
- for (var parent = this.parentNode; parent; parent = parent.parentNode) {
- if (parent.localName == 'tabbox') {
- parent.setAttribute("selectedIndex", val);
-
- var tabpanels = parent.tabpanels;
- if (tabpanels)
- tabpanels.selectedIndex = val;
-
- break;
- }
- }
-
- if (!alreadySelected) {
- var event = document.createEvent('Events');
- event.initEvent('select', true, true);
- this.dispatchEvent(event);
- }
- }
- return val;
- ]]></setter>
- </property>
-
- <property name="selectedItem">
- <getter><![CDATA[
- const tabs = this.tabs;
- for (var i = 0; i < tabs.length; i++) {
- if (tabs[i].selected)
- return tabs[i];
- }
- return null;
- ]]></getter>
-
- <setter><![CDATA[
- if (val && !val.selected) {
- this.selectedIndex = this.getIndexOfItem(val);
- }
- return val;
- ]]>
- </setter>
- </property>
-
- <method name="getIndexOfItem">
- <parameter name="item"/>
- <body><![CDATA[
- return Array.indexOf(this.tabs, item);
- ]]></body>
- </method>
-
- <method name="getItemAtIndex">
- <parameter name="index"/>
- <body><![CDATA[
- return this.tabs.item(index);
- ]]></body>
- </method>
-
- <method name="_selectNewTab">
- <parameter name="aNewTab"/>
- <parameter name="aFallbackDir"/>
- <parameter name="aWrap"/>
- <body><![CDATA[
- this.selectedItem = aNewTab;
- ]]></body>
- </method>
-
- </implementation>
- </binding>
-
- <binding id="tab"
- extends="chrome://yasearch/content/dialogs/tabs-bindings.xbl#tab-base">
- <content>
- <xul:stack>
- <xul:vbox anonid="tab-corner-container">
- <xul:image anonid="tab-corner-image"/>
- </xul:vbox>
- <xul:image anonid="title-bg"/>
- <xul:hbox flex="1" pack="center" align="center">
- <xul:label xbl:inherits="value=label" flex="1" crop="end"/>
- </xul:hbox>
- </xul:stack>
- </content>
-
- <implementation>
- <property name="selected" readonly="true"
- onget="return this.getAttribute('selected') == 'true';"/>
-
- <property name="_selected">
- <setter>
- <![CDATA[
- this.setAttribute("selected", val);
- return val;
- ]]>
- </setter>
- </property>
- </implementation>
-
- <handlers>
- <handler event="mousedown" button="0">
- <![CDATA[
- if (this.disabled)
- return;
-
- if (this != this.parentNode.selectedItem) {
- window.setTimeout(function setTab(tab) {
- tab.parentNode._selectNewTab(tab);
- }, 0, this);
- }
- ]]>
- </handler>
- </handlers>
- </binding>
-
- <binding id="tabpanels"
- extends="chrome://yasearch/content/dialogs/tabs-bindings.xbl#tab-base">
- <content>
- <xul:deck flex="1" anonid="panelsDeck" xbl:inherits="selectedIndex">
- <children includes="ya:tabpanel"/>
- </xul:deck>
- <children/>
- </content>
-
- <implementation>
- <property name="panels" readonly="true">
- <getter><![CDATA[
- return this.getElementsByTagNameNS("http://bar.yandex.ru/firefox", "tabpanel");
- ]]></getter>
- </property>
-
- <property name="selectedIndex">
- <getter><![CDATA[
- var indexStr = this.getAttribute("selectedIndex");
- return indexStr ? parseInt(indexStr, 10) : -1;
- ]]></getter>
-
- <setter><![CDATA[
- if (val < 0 || val >= this.panels.length)
- return val;
-
- var panel = this._selectedPanel;
-
- this._selectedPanel = this.panels.item(val);
- this.setAttribute("selectedIndex", val);
-
- if (this._selectedPanel != panel) {
- if (panel && panel.selected)
- panel._selected = false;
-
- this._selectedPanel.setAttribute("selected", true);
- }
-
- return val;
- ]]></setter>
- </property>
-
- <property name="selectedPanel">
- <getter><![CDATA[
- return this._selectedPanel;
- ]]></getter>
-
- <setter><![CDATA[
- var selectedIndex = -1;
- for (var panel = val; panel != null; panel = panel.previousSibling)
- ++selectedIndex;
-
- this.selectedIndex = selectedIndex;
-
- return val;
- ]]></setter>
- </property>
-
- <field name="_selectedPanel">this.panels.item(this.selectedIndex)</field>
-
- </implementation>
- </binding>
-
- <binding id="tabpanel"
- extends="chrome://yasearch/content/dialogs/tabs-bindings.xbl#tab-base">
- <implementation>
- <property name="selected" readonly="true"
- onget="return this.getAttribute('selected') == 'true';"/>
-
- <property name="_selected">
- <setter>
- <![CDATA[
- this.setAttribute("selected", val);
- return val;
- ]]>
- </setter>
- </property>
- </implementation>
- </binding>
- </bindings>