Skip to content

Instantly share code, notes, and snippets.

@LinZap
Last active November 17, 2015 04:46
Show Gist options
  • Save LinZap/f66c626579e1e1dcf4bf to your computer and use it in GitHub Desktop.
Save LinZap/f66c626579e1e1dcf4bf to your computer and use it in GitHub Desktop.
穩定版 v2.2
function main(){
page.base(i3s_awesome.base);
page('/', function(){
re_render({params:["首頁"]});
});
page(/^\/([\D\/]+)$/, function(context){
re_render(context);
});
page(/^\/([\D\/]+)(\d+)$/, function(context){
re_render(context);
});
page();
}
function show_path(tar){
render({
ejs:'views/i3s-showpath',
data:{path:this.path},
target:tar,
cache: true,
name: 'show_path'
})
}
function show_class(tar){
api({did:1,params:this.path,cache:true},function(data){
render({
ejs:'views/i3s-showclass',
data:data,
target:tar,
cache: true,
name: 'show_class'
})
});
}
function show_object(tar){
api({did:2,params:this.path,cache:true},function(data){
render({
ejs:'views/i3s-showobject',
data:data,
target:tar,
cache: true
})
});
}
function show_lighbox(tar){
var url = this.oid? this.path+"/"+this.oid : "";
api({did:3,params:url,cache:true},function(data){
if(data.item){
var cover = render({
ejs:'views/i3s-showlightbox',
data:data,
target:tar
});
cover.click(function(event) { history.go(-1);});
cover.children('.lightbox').click(function(event) { event.stopPropagation(); });
}
else tar.html('');
});
}
// // 定義點擊 Class 要往下瀏覽的功能
function re_render(context){
var path = context.params[0].replace(/\/$/,'');
var d = {
path: path,
oid: context.params[1]
};
show_path.call(d,$('.box-path'));
show_class.call(d,$('.box-class'));
show_object.call(d,$('.box-object'));
show_lighbox.call(d,$('.box-lightbox'));
document.title = path;
}
@LinZap
Copy link
Author

LinZap commented Nov 17, 2015

V2.2 穩定版 SPA

上面是 app.js 裡面的 code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment