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
/
filFB66E56B5A10E55458B31762FEEC3B3C
< prev
next >
Wrap
Extensible Markup Language
|
2010-07-12
|
10KB
|
281 lines
<?xml version="1.0"?>
<!DOCTYPE bindings SYSTEM "chrome://yasearch/locale/dialogs/welcome.dtd">
<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="status">
<resources>
<stylesheet src="chrome://yasearch/skin/dialogs/status.css"/>
</resources>
<content>
<xul:vbox flex="1" tooltip="_child">
<xul:tooltip orient="vertical"
noautohide="true" onpopupshowing="return _fillTooltip(this);"
style="max-width:40em">
<xul:vbox flex="1">
<html:div/>
</xul:vbox>
</xul:tooltip>
<html:div class="ya-status" mode="text">
<!-- arrow -->
<html:div class="ya-status-arrow"/>
<html:div class="ya-status-border">
<html:div/>
<!-- content -->
<html:div class="ya-status-content">
<!-- error -->
<html:div class="ya-status-error">&yasearch.welcome.status.request.error.label; <html:span>&yasearch.welcome.status.request.error.close.label;</html:span></html:div>
<!-- text -->
<html:div class="ya-status-text"><html:span/><html:span class="ya-status-text-empty">&yasearch.welcome.status.empty.label;</html:span><html:div class="ya-status-fade"/></html:div>
<!-- edit -->
<html:div class="ya-status-edit">
<html:div class="left">
<html:textarea id="ya-status-textarea" class="ya-status-textarea"></html:textarea>
</html:div>
<html:div class="right">
<xul:scrollbar orient="vertical"/>
<html:div class="ya-status-ok"/>
</html:div>
</html:div>
<!-- throbber -->
<html:div class="ya-status-throbber"/>
</html:div>
<html:div/>
</html:div>
</html:div>
</xul:vbox>
</content>
<implementation implements="nsIDOMEventListener">
<field name="status">document.getAnonymousElementByAttribute(this, "class", "ya-status")</field>
<field name="text">document.getAnonymousElementByAttribute(this, "class", "ya-status-text")</field>
<field name="edit">document.getAnonymousElementByAttribute(this, "class", "ya-status-textarea")</field>
<field name="content">document.getAnonymousElementByAttribute(this, "class", "ya-status-content")</field>
<field name="ok">document.getAnonymousElementByAttribute(this, "class", "ya-status-ok")</field>
<field name="error">document.getAnonymousElementByAttribute(this, "class", "ya-status-error")</field>
<property name="value">
<setter><![CDATA[
this.theValue = val;
var node = this.text.firstChild;
var n = this.text;
if (!node.firstChild)
node.appendChild(document.createTextNode(""));
var textNode = node.firstChild;
var text = this.softHyphen(this.normalize(val));
textNode.nodeValue = text;
this.shade();
this.text.setAttribute("empty", val == "" ? "true" : "false");
]]></setter>
<getter><![CDATA[
return this.theValue;
]]></getter>
</property>
<constructor><![CDATA[
this.nsIYa = Cc["@yandex.ru/yasearch;1"].getService(Ci.nsIYaSearch).wrappedJSObject;
]]></constructor>
<method name="softHyphen">
<parameter name="text"/>
<body><![CDATA[
var result = "", space = 0;
for (var i = 0; i < text.length; i++) {
if (text.charAt(i) <= 32)
space = 0;
result += text.charAt(i) + ((i > 22) || (space > 10) ? "\u200B" : "");
space++;
}
text = result;
return text;
]]></body>
</method>
<method name="onTextClick">
<parameter name="event"/>
<body><![CDATA[
this.status.setAttribute("mode", "edit");
this.edit.value = this.value;
this.edit.focus();
this.edit.select();
]]></body>
</method>
<method name="normalize">
<parameter name="string"/>
<body><![CDATA[
return string.replace(/[\s\xA0]{2,}/g, ' ').replace(/(^[\s\xA0]+|[\s\xA0]+$)/g, '');
]]></body>
</method>
<method name="onOkClick">
<parameter name="event"/>
<body><![CDATA[
if (this.edit.value != this.value) {
this.value = this.normalize(this.edit.value);
this.request();
}
this.status.setAttribute("mode", "text");
]]></body>
</method>
<method name="onErrorClick">
<parameter name="event"/>
<body><![CDATA[
this.status.removeAttribute("request");
]]></body>
</method>
<method name="request">
<body><![CDATA[
var xml =
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:y="yandex:data">
<category term="status" scheme="urn:wow.ya.ru:posttypes"/>
<content>{this.value}</content>
</entry>;
var uid = this.nsIYa.yaAuth.session.id.split(".")[3];
var url = "http://api-yaru.yandex.ru/person/" + uid + "/post/";
var request = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(Ci.nsIXMLHttpRequest);
request.open("POST", url, true);
request.setRequestHeader("Content-Type", "application/atom+xml; type=entry; charset=utf-8");
request.setRequestHeader("Connection", "close");
var target = request.QueryInterface(Ci.nsIDOMEventTarget);
var context = this;
target.addEventListener("load", this, false);
target.addEventListener("error", this, false);
request.send(xml.toString());
this.status.setAttribute("request", "wait");
]]></body>
</method>
<method name="handleEvent">
<parameter name="aEvent"/>
<body><![CDATA[
switch (aEvent.type) {
case "load":
case "error":
if (this.response)
this.response(aEvent);
break;
default:
break;
}
]]></body>
</method>
<method name="response">
<parameter name="event"/>
<body><![CDATA[
var request = event.target;
if (request && request.responseXML) {
this.status.removeAttribute("request");
} else {
this.status.setAttribute("request", "error");
}
]]></body>
</method>
<method name="onEditKeyDown">
<parameter name="event"/>
<body><![CDATA[
switch (event.keyCode) {
case event.DOM_VK_RETURN:
case event.DOM_VK_ENTER:
this.onOkClick(event);
break;
case event.DOM_VK_CANCEL:
case event.DOM_VK_ESCAPE:
event.stopPropagation();
event.preventDefault();
this.status.setAttribute("mode", "text");
break;
}
]]></body>
</method>
<method name="contains">
<parameter name="child"/>
<parameter name="parent"/>
<body><![CDATA[
return (child == parent) || (parent.compareDocumentPosition(child) & Node.DOCUMENT_POSITION_CONTAINED_BY);
]]></body>
</method>
<method name="shade">
<body><![CDATA[
setTimeout(function(context) {
if (context && "shadeEx" in context)
context.shadeEx();
}, 100, this);
]]></body>
</method>
<method name="shadeEx">
<body><![CDATA[
if (this.text.clientHeight >= this.text.scrollHeight - 3)
this.text.removeAttribute("overflow");
else
this.text.setAttribute("overflow", "overflow");
]]></body>
</method>
<method name="_fillTooltip">
<parameter name="aTooltip"/>
<body><![CDATA[
var tooltiptext = this.softHyphen(this.normalize(this.value));
if (!tooltiptext)
return false;
if (tooltiptext.length > 1000)
tooltiptext = tooltiptext.substr(0, 1000) + "\u2026";
var descr = aTooltip.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "div")[0];
descr.textContent = tooltiptext;
aTooltip.style.height = "";
window.setTimeout(function() {
aTooltip.style.height = aTooltip.boxObject.height + "px";
}, 0);
return true;
]]></body>
</method>
</implementation>
<handlers>
<handler event="keydown"><![CDATA[
if (this.contains(event.originalTarget, this.edit))
this.onEditKeyDown(event);
]]></handler>
<handler event="click"><![CDATA[
if (this.contains(event.originalTarget, this.error))
this.onErrorClick(event);
else if (this.contains(event.originalTarget, this.ok))
this.onOkClick(event);
else if (this.contains(event.originalTarget, this.text))
this.onTextClick(event);
]]></handler>
</handlers>
</binding>
</bindings>