Esempio n. 1
0
define("mods/trans/staticpage",function(require,a,b){var c=require("common/transmission"),d=new c,e=d.register.bind(d);e("staticPageArticlecontent",{url:"",cache:!0}),b.exports=d}),define("mods/staticpage",function(require,a,b){var c=require("core/chaos/jquery"),d=require("more/base"),e=require("common/channel"),f=require("common/location"),g=require("mods/util/getFormatedUrl"),h=require("mods/trans/staticpage"),i=require("vendor/highlight.pack"),j=require("vendor/bower/nprogress"),k=d.extend({parseDom:function(){this.nodes={root:c("section.posts")}},build:function(){this.objs;this.set("currentUrl",f.get().url);c("section.posts")},setBound:function(){var a=this;this.bound={onAttach:function(){a.onAttach()},checkUpdate:function(){a.checkUpdate()},onDetach:function(){a.onDetach()}}},setListener:function(a){var b=this.bound;a="add"===a?"add":"remove",e[a]("locationChange",b.checkUpdate)},setCustEvents:function(a){var b=this.bound;a="add"===a?"on":"off",this[a]("attach",b.onAttach),this[a]("detach",b.onDetach)},matchUrl:function(a){return a=g(a),/^(\/(about|projects|links)\/|($)|\/)(\?.*|\#.*|$)/.test(a)},checkUpdate:function(){var a=f.get().url,b=this.get("currentUrl");b!==a&&this.matchUrl(a)&&(this.set("currentUrl",a),this.getContent(a))},getContent:function(a){var b=this;window.scrollTo(0,1),j.start(),h.request("staticPageArticlecontent",{url:a,type:"get",dataType:"html",onSuccess:function(a){a=c(a).find("section.posts").html(),b.nodes.root.html(a),c("pre code").each(function(a,b){i.highlightBlock(b)}),j.done()},onFailure:function(){console.log("网络错误")}})},onAttach:function(){this.checkUpdate(),this.set("currentUrl",f.get().url),this.getContent(this.get("currentUrl"))},onDetach:function(){}});b.exports=k}),define("conf/pl/staticpage",function(require,a,b){var c=(require("core/chaos/jquery"),require("mods/staticpage"));b.exports={init:function(){var a=this.objs={};a.staticpage=new c},attach:function(){},detach:function(){},destroy:function(){}}});
Esempio n. 2
0
File: blog.js Progetto: JoveX/penman
define("mods/channel/blog",function(require,a,b){var c=require("common/listener");b.exports=new c(["bloglistUpdate","contentUpdate"])}),define("mods/trans/blog",function(require,a,b){var c=require("common/transmission"),d=new c,e=d.register.bind(d);e("blogArticlecontent",{url:"",cache:!0}),b.exports=d}),define("mods/blog",function(require,a,b){var c=require("core/chaos/jquery"),d=require("more/base"),e=require("common/channel"),f=require("common/location"),g=(require("mods/channel/blog"),require("mods/util/getFormatedUrl")),h=require("mods/trans/blog"),i=require("vendor/highlight.pack"),j=require("vendor/bower/nprogress"),k=d.extend({parseDom:function(){this.nodes={root:c("section.posts")}},build:function(){},setBound:function(){var a=this;this.bound={onAttach:function(){a.onAttach()},checkUpdate:function(){a.checkUpdate()},onDetach:function(){a.onDetach()}}},setListener:function(a){var b=this.bound;a="add"===a?"add":"remove",e[a]("locationChange",b.checkUpdate)},setCustEvents:function(a){var b=this.bound;a="add"===a?"on":"off",this[a]("attach",b.onAttach),this[a]("detach",b.onDetach)},matchUrl:function(a){return a=g(a),"/"===a||""===a?!1:/^(\/\d{4}\/\d{2}\/\d{2}\/[^\/]+\/|($)|\/)(\?.*|\#.*|$)/.test(a)},checkUpdate:function(){var a=this,b=f.get().url,c=a.get("currentUrl"),d=a.nodes.root.attr("data-filled");a.nodes.root.removeAttr("data-filled"),c!==b&&a.matchUrl(b)&&"true"!==d?(a.set("currentUrl",b),a.getContent(b)):(a.updateHljs(),a.updateDisqus())},updateDisqus:function(){var a=f.get().url;"object"==typeof DISQUS&&DISQUS.reset({reload:!0,config:function(){this.page.identifier=""+(new Date).getTime(),this.page.url=a}})},updateHljs:function(){c("pre code").each(function(a,b){i.highlightBlock(b)})},getContent:function(a){var b=this;j.start(),h.request("blogArticlecontent",{url:a,type:"get",dataType:"html",onSuccess:function(a){a=c(a).find("section.posts").html(),b.nodes.root.html(a),b.updateHljs(),window.scrollTo(0,1),b.updateDisqus()},onFailure:function(){c.log("网络错误")},onComplete:function(){j.done()}})},onAttach:function(){this.checkUpdate()},onDetach:function(){this.set("currentUrl","")}});b.exports=k}),define("conf/pl/blog",function(require,a,b){var c=(require("core/chaos/jquery"),require("mods/blog"));b.exports={init:function(){var a=this.objs={};a.blog=new c},attach:function(){},detach:function(){},destroy:function(){}}});