ViewStack: {
xml: "<div id='viewstack'/>",
fun: function (sys, items, opts) {
var args, children = this.children(),
table = children.call("hide").hash(),
ptr = table[opts.index] || children[0];
if (ptr) ptr = ptr.trigger("show").show();
this.on("switch", function ( e, to ) {
table = this.children().hash();
if ( !table[to] || table[to] == ptr ) return;
e.stopPropagation();
args = [].slice.call(arguments).slice(2);
ptr.trigger("hide", [to+''].concat(args)).hide();
ptr = table[to].trigger("show", [ptr+''].concat(args)).show();
});
return Object.defineProperty({}, "selected", { get: function() {return ptr;}});
}
}
Example1: {
xml: `<ViewStack index='bar'>
<button id='foo'>foo</button>
<button id='bar'>bar</button>
</ViewStack>`
}
Example2: {
xml: "<ViewStack id='viewstack'>\
<button id='foo'>foo</button>\
<button id='bar'>bar</button>\
</ViewStack>"
fun: function (sys, items, opts) {
sys.viewstack.on("click", "*", function(e) {
var to = this + '' == "foo" ? "bar" : "foo",
data = "hello, world";
this.trigger("switch", [to, data]);
});
sys.foo.on("show", function (e, prev, data) {
console.log("previous page is " + prev, "from data is " + data);
});
sys.bar.on("hide", function (e, prev, data) {
console.log("previous page is " + prev, "from data is " + data);
});
}
}
Example3: {
xml: "<ViewStack id='viewstack'>\
<button id='foo'>foo</button>\
</ViewStack>"
fun: function (sys, items, opts) {
var xml = "<button id='bar'>bar</button>";
sys.viewstack.append(xml).trigger("switch", "bar");
}
}
Example4: {
xml: `<ViewStack>
<button id='foo'>foo</button>
<button id='bar'>bar</button>
<button id='alice'>alice</button>
</ViewStack>`
map: { defer: "bar alice" }
}
Example5: {
xml: `<ViewStack id='example'>
<button id='foo'>foo</button>
<button id='bar'>bar</button>
<button id='alice'>alice</button>
</ViewStack>`,
fun: function (sys, items, opts) {
sys.example.on("show", "button", function (e, prev) {
window.history.pushState({name: this + ""}, null, "/" + this);
});
window.addEventListener("popstate", function(e) {
sys.example.trigger("switch", e.state.name);
});
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有