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
/
fil00D090375CA0415E4E08135B185F43A5
< prev
next >
Wrap
Extensible Markup Language
|
2010-07-12
|
16KB
|
469 lines
<?xml version="1.0"?>
<!DOCTYPE bindings [
<!ENTITY % yaBrandDTD SYSTEM "chrome://yasearch/locale/yasearch.dtd">
%yaBrandDTD;
<!ENTITY % yaBookmarksDTD SYSTEM "chrome://yasearch/locale/bookmarks/bookmarks.dtd">
%yaBookmarksDTD;
]>
<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="favicons" extends="chrome://global/content/bindings/general.xml#image">
<implementation>
<constructor><![CDATA[
this.__yaUrlForFav = this.parentNode.parentNode.getAttribute("statustext");
]]></constructor>
</implementation>
<handlers>
<handler event="load"><![CDATA[
if (!this.__yaUrlForFav)
return;
var imgSrc = YaBookmarksUtils.getFaviconURL(this.__yaUrlForFav);
if (!imgSrc)
return;
var img = document.createElementNS("http://www.w3.org/1999/xhtml", "img");
var __me = this;
img.onload = function() {
YaBookmarksUtils.checkExpirationTime(this.src);
__me.src = this.src;
},
img.onerror = function() {
var response = false;
try {
if (this instanceof Components.interfaces.nsIImageLoadingContent)
response = this.getRequest(Components.interfaces.nsIImageLoadingContent.CURRENT_REQUEST).mimeType;
} catch(e) {}
YaBookmarksUtils.addToMissedIconCache(this.src, !!response);
}
img.src = imgSrc;
]]></handler>
</handlers>
</binding>
<binding id="tags-container">
<resources>
<stylesheet src="chrome://yasearch/skin/bookmarks/bookmarks.css"/>
</resources>
<content>
<xul:textbox xbl:inherits="value,maxlength,disabled,emptytext"/>
<xul:hbox>
<xul:vbox flex="1" anonid="tags-cloud-container">
<html:div anonid="tags-cloud" style="display:none;"/>
</xul:vbox>
</xul:hbox>
<xul:tooltip anonid="maxLengthTooltip" orient="vertical" noautohide="true">
<xul:description value="&yasearch.bookmarks.maxLengthTooltipDefaultText;"/>
</xul:tooltip>
</content>
<implementation>
<constructor><![CDATA[
this.tagsCloud = document.getAnonymousElementByAttribute(this, "anonid", "tags-cloud");
this.mYaBookmarks = Components.classes["@yandex.ru/yasearch;1"].
getService(Components.interfaces.nsIYaSearch).wrappedJSObject.
yaBookmarks;
]]></constructor>
<destructor><![CDATA[
this.clearMaxLengthTooltipTimeout();
this.clearTextInputTimeout();
this.lastTextValue = null;
this.lastTextComplete = null;
this.tagsCloud = null;
this._tagsList = null;
this.mYaBookmarks = null;
]]></destructor>
<field name="lastCursorPosition">0</field>
<field name="mTextbox">document.getAnonymousNodes(this)[0]</field>
<field name="mMaxLengthTooltip">document.getAnonymousElementByAttribute(this, "anonid", "maxLengthTooltip");</field>
<field name="_lastTextValue">null</field>
<property name="lastTextValue"
onget="return this._lastTextValue;"
onset="this._lastTextValue = val; return val;"/>
<field name="_lastTextComplete">null</field>
<property name="lastTextComplete"
onget="return this._lastTextComplete;"
onset="this._lastTextComplete = val; return val;"/>
<field name="_tagsList">null</field>
<property name="tagsList" readonly="true" onget="return this._tagsList"/>
<field name="_maxLengthTooltipTimeout">null</field>
<field name="_handleTextInputTimeout">null</field>
<property name="value"
onget="return this.mTextbox.value;"
onset="this.mTextbox.value = val; return val;"/>
<property name="disabled"
onget="return this.mTextbox.disabled;"
onset="this.mTextbox.disabled = val; return val;"/>
<property name="maxLength" readonly="true">
<getter>
<![CDATA[
return this.hasAttribute("maxlength") ? parseInt(this.getAttribute("maxlength"),10) : 0;
]]>
</getter>
</property>
<field name="tagMaxLength">this.hasAttribute("yatagmaxlength") ? parseInt(this.getAttribute("yatagmaxlength"), 10) : 0</field>
<property name="selectionStart"
onget="return this.mTextbox.selectionStart;"/>
<property name="selectionEnd"
onget="return this.mTextbox.selectionEnd;"/>
<method name="selectTextRange">
<parameter name="aStartIndex"/>
<parameter name="aEndIndex"/>
<body><![CDATA[
this.mTextbox.setSelectionRange(aStartIndex, aEndIndex);
const nsISelectionController = Components.interfaces.nsISelectionController;
this.mTextbox.editor.selectionController.scrollSelectionIntoView(
nsISelectionController.SELECTION_NORMAL,
nsISelectionController.SELECTION_FOCUS_REGION,
false
);
]]></body>
</method>
<method name="initWithValue">
<parameter name="aTagsListString"/>
<body><![CDATA[
this.trySetNewValue(aTagsListString, true);
this.mYaBookmarks.showTags(this, null, 10);
]]></body>
</method>
<method name="addTag">
<parameter name="aTagElement"/>
<body><![CDATA[
var span = aTagElement;
if (span) {
var spanDisabled = span.getAttribute("disabled");
var savedValue = this.value ? this.value.replace(/^[,\s]*/, "")
.replace(/\s+,/g, ",")
.replace(/\s+/g, " ")
.replace(/,+/g, ",")
.replace(/[,\s]*$/, ", ")
: "";
switch (spanDisabled) {
case "false":
savedValue += span.getAttribute("tooltiptext") + ", ";
spanDisabled = "true";
break;
case "true":
var re = new RegExp("(^|,\\s?)" +
span.getAttribute("tooltiptext").replace(/(\-|\.|\||\+|\?|\$|\(|\)|\[|\])/g,"\\\$1") +
"(,\\s?|$)", "gi");
while(re.test(savedValue))
savedValue = savedValue.replace(re, "$1");
spanDisabled = "false";
break;
default:
return false;
}
if (!this.trySetNewValue(savedValue)) {
return false;
}
span.setAttribute("disabled", spanDisabled);
return true;
}
return false;
]]></body>
</method>
<method name="showTags">
<parameter name="aTagsFull"/>
<parameter name="aTagsLimited"/>
<body><![CDATA[
const HTMLNS = "http://www.w3.org/1999/xhtml";
var tags = aTagsLimited || aTagsFull,
tagsCloud = this.tagsCloud,
style = this.tagsCloud.style,
frag = document.createDocumentFragment();
for (var prop in tags) {
var tag = aTagsFull[prop];
var el = document.createElementNS(HTMLNS, "span");
var spanContent = tag.value.length > 22 ? (tag.value.substr(0, 18) + "…") : tag.value;
el.setAttribute("disabled", tag.disabled ? "true" : "false");
el.setAttribute("tooltiptext", tag.value);
el.appendChild(document.createTextNode(spanContent));
frag.appendChild(el);
frag.appendChild(document.createTextNode(", "));
aTagsFull[prop].element = el;
}
this._tagsList = aTagsFull || null;
while (tagsCloud.firstChild)
tagsCloud.removeChild(tagsCloud.firstChild);
if (frag.lastChild) {
frag.removeChild(frag.lastChild);
tagsCloud.appendChild(frag);
style.display = "block";
var bo = this.boxObject;
style.left = bo.x + 5 + "px";
style.width = Math.max(0, bo.width - 10) + "px";
} else {
style.display = "none";
}
]]></body>
</method>
<method name="fireInput">
<body><![CDATA[
var ev = document.createEvent("UIEvents");
ev.initEvent("input", true, true);
this.mTextbox.dispatchEvent(ev);
]]></body>
</method>
<method name="trySetNewValue">
<parameter name="aValue"/>
<parameter name="aSetAnyway"/>
<body><![CDATA[
if (this.maxLength && this.maxLength < aValue.length) {
if (!aSetAnyway)
return false;
this.removeAttribute("maxlength");
}
this.value = aValue;
return true;
]]></body>
</method>
<method name="showMaxLengthTooltip">
<body><![CDATA[
this.clearMaxLengthTooltipTimeout();
try {
var tooltipText = window.YaBookmarks.stringBundleSet.getFormattedString("MaxLengthTooltipText", [this.tagMaxLength]);
this.mMaxLengthTooltip.firstChild.setAttribute("value", tooltipText);
} catch(e) {}
this.mMaxLengthTooltip.showPopup(this.mTextbox,
this.boxObject.screenX + 4, this.boxObject.screenY,
"tooltip", null, null);
this._maxLengthTooltipTimeout = window.setTimeout(
function(tooltip) { tooltip.hidePopup() },
2000,
this.mMaxLengthTooltip
);
]]></body>
</method>
<method name="clearMaxLengthTooltipTimeout">
<body><![CDATA[
if (this._maxLengthTooltipTimeout)
window.clearTimeout(this._maxLengthTooltipTimeout);
this._maxLengthTooltipTimeout = null;
]]></body>
</method>
<method name="clearTextInputTimeout">
<body><![CDATA[
if (this._handleTextInputTimeout)
window.clearTimeout(this._handleTextInputTimeout);
this._handleTextInputTimeout = null;
]]></body>
</method>
<method name="handleTextInput">
<body><![CDATA[
this.clearTextInputTimeout();
this._handleTextInputTimeout = window.setTimeout(
function(aInput) {
aInput.mYaBookmarks.handleTextInput(aInput);
}, 200, this
);
]]></body>
</method>
</implementation>
<handlers>
<handler event="focus" phase="capturing">
<![CDATA[
this.lastTextComplete = null;
]]>
</handler>
<handler event="blur" phase="capturing">
<![CDATA[
this.fireInput();
]]>
</handler>
<handler event="input">
<![CDATA[
if (this.tagsList)
this.mYaBookmarks.handleTextChange(this);
]]>
</handler>
<handler event="keyup" phase="capturing">
<![CDATA[
if ((event.keyCode == 0 || event.keyCode > 46) && !event.ctrlKey && !event.altKey)
this.handleTextInput();
return true;
]]>
</handler>
<handler event="keydown" phase="capturing">
<![CDATA[
this.clearTextInputTimeout();
var keyCode = event.keyCode;
if (this.lastTextComplete === this.value.substr(this.selectionStart, this.selectionEnd)) {
if (event.DOM_VK_RETURN == keyCode) {
this.trySetNewValue(this.value + ", ");
var len = this.value.length;
this.selectTextRange(len, len);
this.fireInput();
return false;
}
}
return true;
]]>
</handler>
<handler event="click" button="0">
<![CDATA[
var target = event.originalTarget;
switch (target.localName) {
case "span":
if (target.getAttribute("anonid") == "tags-cloud-closeButton") {
this.hideTags();
} else if (target.parentNode.localName === "div") {
this.addTag(target);
}
break;
default:
break;
}
]]>
</handler>
</handlers>
</binding>
<binding id="extra-dialog-button-box">
<content>
<xul:checkbox anonid="dont-show-again" label="&yasearch.yaru.dontshowlivewindow.checkbox.label;"/>
<xul:spacer flex="1"/>
<children/>
</content>
<handlers>
<handler event="command"><![CDATA[
if (event.originalTarget.localName == "checkbox" && window.YaYaRu)
window.YaYaRu.prefsObject.set("yaruLiveWindowDisabled", !!event.originalTarget.checked);
]]></handler>
</handlers>
</binding>
<binding id="links-tooltips">
<implementation>
<constructor>
<![CDATA[
var linkHref = this.getAttribute("href");
if (linkHref && !this.hasAttribute("tooltiptext"))
this.setAttribute("tooltiptext", linkHref);
]]>
</constructor>
</implementation>
</binding>
<binding id="links-tooltips-and-crop">
<implementation>
<constructor><![CDATA[
setTimeout(function(me){ me._init() }, 0, this)
]]></constructor>
<method name="_init">
<body><![CDATA[
var labels = this.getElementsByTagName("label");
var children = this.childNodes;
var widthDiff = this.boxObject.width;
for (var i = 0; i < children.length; i++) {
var childWidth = children[i].boxObject.width;
if (childWidth > 0)
widthDiff -= childWidth;
}
if (widthDiff < 0) {
var chIndex = labels.length > 1 ? 1 : 0;
labels[chIndex].style.maxWidth = labels[chIndex].boxObject.width + widthDiff - 1 + "px";
labels[chIndex].setAttribute("crop", "end");
} else {
if (this.hasAttribute("yaTooltiptext"))
this.removeAttribute("yaTooltiptext");
}
]]></body>
</method>
</implementation>
</binding>
</bindings>