2008-11-21 21:12:25 -08:00
|
|
|
<?xml version="1.0"?>
|
|
|
|
|
|
|
|
<bindings
|
|
|
|
xmlns="http://www.mozilla.org/xbl"
|
|
|
|
xmlns:xbl="http://www.mozilla.org/xbl"
|
|
|
|
xmlns:html="http://www.w3.org/1999/xhtml"
|
|
|
|
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
|
|
|
|
2009-09-09 20:32:13 -07:00
|
|
|
<binding id="documenttab">
|
2008-11-21 21:12:25 -08:00
|
|
|
<content>
|
|
|
|
<xul:stack anonid="page" class="documenttab-container" flex="1">
|
2010-09-02 18:27:20 -07:00
|
|
|
<html:canvas anonid="canvas" class="documenttab-canvas" left="0" width="106" height="64" moz-opaque="true"
|
2010-08-26 15:27:17 -07:00
|
|
|
onclick="document.getBindingParent(this)._onClick()" xbl:inherits="selected"/>
|
2010-09-02 18:27:20 -07:00
|
|
|
<xul:hbox class="documenttab-close-container" left="0" top="10" height="64" width="55" align="center" onclick="document.getBindingParent(this)._close()">
|
2009-11-10 07:48:37 -08:00
|
|
|
<xul:image anonid="close" class="documenttab-close" mousethrough="always"/>
|
2009-10-12 12:36:49 -07:00
|
|
|
</xul:hbox>
|
2008-11-21 21:12:25 -08:00
|
|
|
</xul:stack>
|
|
|
|
</content>
|
2009-09-09 20:32:13 -07:00
|
|
|
|
|
|
|
<implementation>
|
|
|
|
<method name="_onClick">
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
this.parentNode.selectedTab = this;
|
|
|
|
|
|
|
|
let selectFn = new Function("event", this.parentNode.getAttribute('onselect'));
|
|
|
|
selectFn.call(this);
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="_close">
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
let closeFn = new Function("event", this.parentNode.getAttribute('onclosetab'));
|
|
|
|
closeFn.call(this);
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
2008-11-21 21:12:25 -08:00
|
|
|
|
|
|
|
<method name="updateThumbnail">
|
|
|
|
<parameter name="browser"/>
|
2010-06-23 12:23:06 -07:00
|
|
|
<parameter name="width"/>
|
|
|
|
<parameter name="height"/>
|
2008-11-21 21:12:25 -08:00
|
|
|
<body>
|
|
|
|
<![CDATA[
|
2009-08-19 13:08:52 -07:00
|
|
|
const tabWidth = 106;
|
|
|
|
const tabHeight = 64;
|
2008-11-21 21:12:25 -08:00
|
|
|
|
2010-09-24 17:41:10 -07:00
|
|
|
let ratio = tabHeight / tabWidth;
|
|
|
|
height = width * ratio;
|
|
|
|
|
2010-06-23 12:23:06 -07:00
|
|
|
let canvas = document.getAnonymousElementByAttribute(this, "anonid", "canvas");
|
2010-09-03 13:23:55 -07:00
|
|
|
let renderer = rendererFactory(browser, canvas)
|
|
|
|
renderer.drawContent(function(ctx, callback) {
|
2010-09-27 08:11:56 -07:00
|
|
|
ctx.save();
|
2010-09-24 17:41:10 -07:00
|
|
|
ctx.clearRect(0, 0, tabWidth, tabHeight);
|
2010-09-03 13:23:55 -07:00
|
|
|
ctx.scale(tabWidth / width, tabHeight / height);
|
|
|
|
callback(browser, 0, 0, width, height, "white");
|
|
|
|
ctx.restore();
|
|
|
|
});
|
2008-11-21 21:12:25 -08:00
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
</implementation>
|
|
|
|
</binding>
|
|
|
|
|
2009-09-09 20:32:13 -07:00
|
|
|
<binding id="tablist">
|
2008-11-21 21:12:25 -08:00
|
|
|
<implementation>
|
2009-09-09 20:32:13 -07:00
|
|
|
<field name="_selectedTab">null</field>
|
|
|
|
|
|
|
|
<property name="selectedTab">
|
2008-11-21 21:12:25 -08:00
|
|
|
<getter>
|
|
|
|
<![CDATA[
|
2009-09-09 20:32:13 -07:00
|
|
|
return this._selectedTab;
|
2008-11-21 21:12:25 -08:00
|
|
|
]]>
|
|
|
|
</getter>
|
2009-09-09 20:32:13 -07:00
|
|
|
<setter>
|
|
|
|
<![CDATA[
|
|
|
|
if (this._selectedTab)
|
|
|
|
this._selectedTab.removeAttribute('selected');
|
|
|
|
|
|
|
|
if (val)
|
|
|
|
val.setAttribute('selected', 'true');
|
|
|
|
|
|
|
|
this._selectedTab = val;
|
|
|
|
]]>
|
|
|
|
</setter>
|
2008-11-21 21:12:25 -08:00
|
|
|
</property>
|
2009-09-09 20:32:13 -07:00
|
|
|
|
2008-11-21 21:12:25 -08:00
|
|
|
<method name="addTab">
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
2009-09-09 20:32:13 -07:00
|
|
|
let tab = document.createElement("box");
|
|
|
|
tab.setAttribute("type", "documenttab");
|
|
|
|
this.appendChild(tab);
|
|
|
|
this._updateWidth();
|
2008-11-21 21:12:25 -08:00
|
|
|
return tab;
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
2009-09-09 20:32:13 -07:00
|
|
|
|
2008-11-21 21:12:25 -08:00
|
|
|
<method name="removeTab">
|
2009-09-09 20:32:13 -07:00
|
|
|
<parameter name="aTab"/>
|
2008-11-21 21:12:25 -08:00
|
|
|
<body>
|
|
|
|
<![CDATA[
|
2009-09-09 20:32:13 -07:00
|
|
|
this.removeChild(aTab);
|
|
|
|
this._updateWidth();
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="resize">
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
2009-11-17 06:23:56 -08:00
|
|
|
let container = this.parentNode.getBoundingClientRect();
|
|
|
|
let element = this.getBoundingClientRect();
|
2009-09-18 07:03:39 -07:00
|
|
|
|
2009-11-17 06:23:56 -08:00
|
|
|
let height = (element.top - container.top) +
|
|
|
|
((container.top + container.height) - (element.top + element.height));
|
|
|
|
this.style.height = height + "px";
|
2008-11-21 21:12:25 -08:00
|
|
|
|
2009-09-09 20:32:13 -07:00
|
|
|
this._updateWidth();
|
2008-11-21 21:12:25 -08:00
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
2009-09-09 20:32:13 -07:00
|
|
|
|
|
|
|
<field name="_columnsCount">1</field>
|
|
|
|
<method name="_updateWidth">
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
2010-08-20 13:32:00 -07:00
|
|
|
let firstBox = this.firstChild.getBoundingClientRect();
|
|
|
|
let lastBox = this.lastChild.getBoundingClientRect();
|
|
|
|
let columnsCount = Math.ceil(this.childNodes.length / Math.floor(this.style.height / firstBox.height));
|
2009-09-09 20:32:13 -07:00
|
|
|
if (this._columnsCount != columnsCount) {
|
2010-08-20 13:32:00 -07:00
|
|
|
let width = Math.max(lastBox.right - firstBox.left, firstBox.right - lastBox.left);
|
|
|
|
this.style.width = width + "px";
|
2009-09-09 20:32:13 -07:00
|
|
|
this._columnsCount = columnsCount;
|
|
|
|
}
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
2008-11-21 21:12:25 -08:00
|
|
|
</implementation>
|
|
|
|
</binding>
|
|
|
|
|
|
|
|
</bindings>
|