<zk xmlns:w="client">
<tabbox width="200px">
<tabs>
<attribute w:name="bind_"><![CDATA[
function (a, b, c) {
this.$bind_(a, b, c);
var first = this.firstChild,
second;
if (first) {
second = first.nextSibling;
if (second) {
var header = this.$n('header'),
fn = first.$n(),
$fn = jq(fn),
fofs = $fn.offset(),
fnstyle = fn.style;
fnstyle.position = 'absolute';
fnstyle.zIndex = 9999;
second.$n().style.marginLeft = $fn.outerWidth() + 'px';
header.onscroll = function () {
fnstyle.left = header.scrollLeft + 'px';
};
}
}
}
]]></attribute>
<attribute w:name="_doClick"><![CDATA[
function(evt) {
var cave = this.$n("cave"),
allTab = jq(cave).children(),
count = allTab.length;
if (!allTab.length) return; // nothing to do
var ele = evt.domTarget,
move = 0,
tabbox = this.getTabbox(),
head = this.$n("header"),
scrollLength = tabbox.isVertical() ? head.scrollTop : head.scrollLeft;
if (ele.id == this.uuid + "-left") {//Scroll to next left tab
if (count > 0)
scrollLength += jq(allTab[0]).outerWidth();
for (var i = 0; i < count; i++) {
if (allTab[i].offsetLeft >= scrollLength) {
//if no Sibling tab no sroll
var tabli = jq(allTab[i]).prev("li")[0];
if (!tabli) return;
move = scrollLength - tabli.offsetLeft;
if (isNaN(move)) return;
this._doScroll("left", move);
return;
};
};
move = scrollLength - allTab[allTab.length-1].offsetLeft;
if (isNaN(move)) return;
this._doScroll("left", move);
return;
} else {
this.$_doClick(evt);
}
}
]]></attribute>
<tab label="tab 1" />
<tab label="tab 2 long" />
<tab label="tab 3 long long long" />
<tab label="tab 4 long" />
<tab label="tab 5" />
<tab label="tab 6" />
<tab label="tab 7" />
</tabs>
<tabpanels>
<tabpanel>tabpanel 1</tabpanel>
<tabpanel>tabpanel 2</tabpanel>
<tabpanel>tabpanel 3</tabpanel>
<tabpanel>tabpanel 4</tabpanel>
<tabpanel>tabpanel 5</tabpanel>
<tabpanel>tabpanel 6</tabpanel>
<tabpanel>tabpanel 7</tabpanel>
</tabpanels>
</tabbox>
</zk>
<tabbox width="200px">
<tabs>
<attribute w:name="bind_"><![CDATA[
function (a, b, c) {
this.$bind_(a, b, c);
var first = this.firstChild,
second;
if (first) {
second = first.nextSibling;
if (second) {
var header = this.$n('header'),
fn = first.$n(),
$fn = jq(fn),
fofs = $fn.offset(),
fnstyle = fn.style;
fnstyle.position = 'absolute';
fnstyle.zIndex = 9999;
second.$n().style.marginLeft = $fn.outerWidth() + 'px';
header.onscroll = function () {
fnstyle.left = header.scrollLeft + 'px';
};
}
}
}
]]></attribute>
<attribute w:name="_doClick"><![CDATA[
function(evt) {
var cave = this.$n("cave"),
allTab = jq(cave).children(),
count = allTab.length;
if (!allTab.length) return; // nothing to do
var ele = evt.domTarget,
move = 0,
tabbox = this.getTabbox(),
head = this.$n("header"),
scrollLength = tabbox.isVertical() ? head.scrollTop : head.scrollLeft;
if (ele.id == this.uuid + "-left") {//Scroll to next left tab
if (count > 0)
scrollLength += jq(allTab[0]).outerWidth();
for (var i = 0; i < count; i++) {
if (allTab[i].offsetLeft >= scrollLength) {
//if no Sibling tab no sroll
var tabli = jq(allTab[i]).prev("li")[0];
if (!tabli) return;
move = scrollLength - tabli.offsetLeft;
if (isNaN(move)) return;
this._doScroll("left", move);
return;
};
};
move = scrollLength - allTab[allTab.length-1].offsetLeft;
if (isNaN(move)) return;
this._doScroll("left", move);
return;
} else {
this.$_doClick(evt);
}
}
]]></attribute>
<tab label="tab 1" />
<tab label="tab 2 long" />
<tab label="tab 3 long long long" />
<tab label="tab 4 long" />
<tab label="tab 5" />
<tab label="tab 6" />
<tab label="tab 7" />
</tabs>
<tabpanels>
<tabpanel>tabpanel 1</tabpanel>
<tabpanel>tabpanel 2</tabpanel>
<tabpanel>tabpanel 3</tabpanel>
<tabpanel>tabpanel 4</tabpanel>
<tabpanel>tabpanel 5</tabpanel>
<tabpanel>tabpanel 6</tabpanel>
<tabpanel>tabpanel 7</tabpanel>
</tabpanels>
</tabbox>
</zk>
No comments:
Post a Comment