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
/
filCA33185A6107B785B94E620BED65A7B4
< prev
next >
Wrap
Extensible Markup Language
|
2010-07-12
|
5KB
|
124 lines
<?xml version="1.0"?>
<!DOCTYPE bindings [
<!ENTITY % yasearchDTD SYSTEM "chrome://yasearch/locale/yasearch.dtd">
%yasearchDTD;
]>
<bindings xmlns="http://www.mozilla.org/xbl"
xmlns:xbl="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<binding id="extend-translate-toolbarbutton"
extends="chrome://yasearch/content/yasearch.xml#extend-toolbarbutton-base">
<resources>
<stylesheet src="chrome://yasearch/skin/translate/translate.css"/>
</resources>
<implementation implements="nsIDOMEventListener">
<field name="_menuEnable">this.getElementsByAttribute("anonid", "translate-enable")[0]</field>
<field name="_menuReverse">this.getElementsByAttribute("anonid", "translate-reverse")[0]</field>
<field name="ENABLE_PREF">"general.ui.translate.enabled"</field>
<field name="REVERSE_PREF">"general.ui.translate.reverse"</field>
<field name="FROM_PREF">"general.ui.translate.from"</field>
<field name="TO_PREF">"general.ui.translate.to"</field>
<constructor><![CDATA[
if (!(typeof Ya == "object" && Ya.YaTranslate))
return;
Components.utils.import("resource://yasearch/Preferences.jsm", this);
this.onEnableChanged();
this.onReverseChanged();
this.Prefs.observe(this.ENABLE_PREF, this.onEnableChanged, this);
this.Prefs.observe(this.REVERSE_PREF, this.onReverseChanged, this);
Ya.YaTranslate.available = true;
]]></constructor>
<destructor><![CDATA[
this.yaDestroy();
]]></destructor>
<method name="yaDestroy">
<body><![CDATA[
if (this.Prefs) {
this.Prefs.ignore(this.ENABLE_PREF, this.onEnableChanged, this);
this.Prefs.ignore(this.REVERSE_PREF, this.onReverseChanged, this);
}
if ((typeof Ya == "object" && Ya.YaTranslate))
Ya.YaTranslate.available = false;
]]></body>
</method>
<method name="onEnableChanged">
<body><![CDATA[
this.checked = this.Prefs.get(this.ENABLE_PREF, false);
this._menuEnable.setAttribute("checked", this.checked);
]]></body>
</method>
<method name="onReverseChanged">
<body><![CDATA[
this._menuReverse.setAttribute("checked", this.Prefs.get(this.REVERSE_PREF, false));
]]></body>
</method>
<method name="handleEvent">
<parameter name="aEvent"/>
<body><![CDATA[
var target = aEvent.target;
switch (aEvent.type) {
case "popupshowing":
var from = this.Prefs.get(this.FROM_PREF, "en");
var to = this.Prefs.get(this.TO_PREF, "ru");
var directions = target.getElementsByAttribute("anonid", "translate-direction");
for (var i = directions.length; i--;) {
var item = directions[i];
if ((item.getAttribute("from") == from) && (item.getAttribute("to") == to)) {
item.setAttribute("checked", "true");
} else if (item.hasAttribute("checked")) {
item.removeAttribute("checked");
}
}
break;//case "popupshowing"
case "command":
var action = target == this ? "translate-enable" : (target.hasAttribute("anonid") ? target.getAttribute("anonid") : null);
switch (action) {
case "translate-enable":
this.checked = !this.checked;
this.Prefs.set(this.ENABLE_PREF, this.checked);
break;
case "translate-reverse":
this.Prefs.set(this.REVERSE_PREF, target.hasAttribute("checked"));
break;
case "translate-direction":
this.Prefs.set(this.FROM_PREF, target.getAttribute("from"));
this.Prefs.set(this.TO_PREF, target.getAttribute("to"));
break;
default:
break;
}
break;//case "command"
default:
break;
}
]]></body>
</method>
</implementation>
<handlers>
<handler event="command" action="this.handleEvent(event);"/>
<handler event="popupshowing" action="this.handleEvent(event);"/>
</handlers>
</binding>
</bindings>