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
/
fil041F7E245CB099473C7C5F52D56E7833
< prev
next >
Wrap
Extensible Markup Language
|
2010-07-12
|
7KB
|
209 lines
<?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="avatar">
<content>
<xul:vbox anonid="holder">
<html:img src="chrome://yasearch/skin/dialogs/images/avatar.default.png"/>
</xul:vbox>
<children/>
</content>
<implementation implements="nsIDOMEventListener">
<field name="imgMaxSize">50</field>
<field name="holder">document.getAnonymousElementByAttribute(this, "anonid", "holder")</field>
<field name="defaultImageSrc">"chrome://yasearch/skin/dialogs/images/avatar.default.png"</field>
<property name="imgHolder" readonly="true">
<getter><![CDATA[
return this.holder.getElementsByTagNameNS("http://www.w3.org/1999/xhtml", "img")[0];
]]></getter>
</property>
<constructor><![CDATA[
this.avatarSrc = this.defaultImageSrc;
]]></constructor>
<destructor><![CDATA[
this.imgHolder.parentNode.removeChild(this.imgHolder);
]]></destructor>
<property name="avatarSrc">
<getter><![CDATA[
return this.getAttribute("avatarSrc");
]]></getter>
<setter><![CDATA[
val = val.replace(/[\r\n]/g, "");//e4x+fx2; keep it...
if (this.avatarSrc != val) {
this.setAttribute("avatarSrc", val);
var img = document.createElementNS("http://www.w3.org/1999/xhtml", "img");
var __me = this;
img.onload = function() {
var response;
try {
const nsIImageLoadingContent = Components.interfaces.nsIImageLoadingContent;
if (this instanceof nsIImageLoadingContent)
response = this.naturalWidth && this.getRequest(nsIImageLoadingContent.CURRENT_REQUEST).mimeType;
} catch(e) {}
if (response) {
var width = this.naturalWidth,
height = this.naturalHeight;
var k = 1;
if (width > __me.imgMaxSize) k = __me.imgMaxSize / width;
if (height > __me.imgMaxSize) k = Math.min(__me.imgMaxSize / height);
width = Math.floor(width * k);
height = Math.floor(height * k);
this.setAttribute("width", width);
this.setAttribute("height", height);
var currentImage = __me.imgHolder;
currentImage.parentNode.replaceChild(this, currentImage);
}
img = null;
},
img.onerror = function() {
img = null;
}
img.src = val;
}
return val;
]]></setter>
</property>
</implementation>
</binding>
<binding id="checkbox"
extends="chrome://global/content/bindings/checkbox.xml#checkbox-baseline">
<resources>
<stylesheet src="chrome://yasearch/skin/dialogs/checkbox.css"/>
</resources>
</binding>
<binding id="cropped">
<content>
<xul:stack flex="1">
<xul:hbox style="overflow:hidden; white-space: nowrap" flex="1">
<html:span anonid="text-label" xbl:inherits="value" style="position:absolute; width:1px"/>
</xul:hbox>
<xul:vbox anonid="canvas-holder"
style="overflow:hidden; margin-right:-2px; -moz-box-align:end; -moz-box-pack:center; height:1px;">
<html:div style="text-align:right; min-width:2.5em;">
<html:canvas anonid="canvas"
style="display:none; width:2.5em; margin:0 !important; padding:0 !important;"></html:canvas>
</html:div>
</xul:vbox>
</xul:stack>
</content>
<implementation>
<field name="_label">document.getAnonymousElementByAttribute(this, "anonid", "text-label")</field>
<field name="_canvas">document.getAnonymousElementByAttribute(this, "anonid", "canvas")</field>
<field name="_inited">null</field>
<constructor><![CDATA[
this.value = this.value;
]]></constructor>
<property name="value">
<getter><![CDATA[
return this.getAttribute("value");
]]></getter>
<setter><![CDATA[
this.setAttribute("value", val);
this._label.textContent = val;
return val;
]]></setter>
</property>
<method name="drawGradient">
<body><![CDATA[
this.setAttribute("yaoverflowed", "true");
setTimeout(function(me) {
if (me._drawGradient)
me._drawGradient();
}, 10, this)
]]></body>
</method>
<method name="_drawGradient">
<body><![CDATA[
var canvas = this._canvas;
canvas.style.display = "";//"inline";
var canvasStyle = document.defaultView.getComputedStyle(canvas, "");
var w = parseInt(canvasStyle.width, 10),
h = parseInt(canvasStyle.height, 10);
canvas.setAttribute("width", w);
canvas.setAttribute("height", h);
canvas.width = w;
canvas.height = h;
var bo = this.boxObject;
var ctx = canvas.getContext("2d");
ctx.drawWindow(window, bo.x, bo.y, bo.x + w, bo.y + h, "rgb(0,0,0)");
function fillCtx(aPattern) {
var pattern = typeof aPattern == "string" ? aPattern : ctx.createPattern(aPattern, "no-repeat");
ctx.fillStyle = pattern;
ctx.fillRect(0, 0, w, h);
ctx.globalCompositeOperation = "destination-out";
var gradient = ctx.createLinearGradient(w, 0, 0, 0);
gradient.addColorStop(0.0, "rgba(255, 255, 255, 0.0)");
gradient.addColorStop(0.2, "rgba(255, 255, 255, 0.2)");
gradient.addColorStop(0.5, "rgba(255, 255, 255, 0.4)");
gradient.addColorStop(1.0, "rgba(255, 255, 255, 0.8)");
ctx.fillStyle = gradient;
ctx.fillRect(0, 0, w, h);
}
var img = new Image();
img.src = canvas.toDataURL("image/png", "");
img.onload = function() {
setTimeout(function() { fillCtx(img); }, 1)
}
this._label.style.visibility = "";
]]></body>
</method>
</implementation>
<handlers>
<handler event="overflow"><![CDATA[
if (this._inited)
return;
this._inited = true;
this._label.style.visibility = "hidden";
this.drawGradient();
]]></handler>
</handlers>
</binding>
</bindings>