Browse Source

clean up

pull/1/head
wes 8 years ago
parent
commit
a7c199f59a
  1. 45
      src/scripts/app.tag
  2. 40
      src/scripts/post.tag

45
src/scripts/app.tag

@ -101,6 +101,10 @@ var self = this;
self.cache = {}; self.cache = {};
self.showBorder = false; self.showBorder = false;
self.route = route;
self.riot = riot;
self.menuActive = false;
self.currentPage = "";
window.addEventListener("scroll", window.addEventListener("scroll",
throttle((ev) => { throttle((ev) => {
@ -109,6 +113,14 @@ window.addEventListener("scroll",
400) 400)
); );
document.addEventListener("click", function(event) {
if(!event.target.closest('#menu')) {
if (self.menuActive) {
self.menuOff();
}
}
});
self.cached = fetchCached({ self.cached = fetchCached({
fetch: fetch, fetch: fetch,
cache: { cache: {
@ -121,11 +133,6 @@ self.cached = fetchCached({
} }
}); });
self.route = route;
self.riot = riot;
self.menuActive = false;
self.currentPage = "";
RiotControl.on("postswitch", RiotControl.on("postswitch",
(ev) => { (ev) => {
self.update( self.update(
@ -137,13 +144,13 @@ RiotControl.on("postswitch",
self.route.base('#!') self.route.base('#!')
this.state = { self.state = {
"_id" : false, "_id" : false,
"projects" : Z.empty, "projects" : Z.empty,
"loaded" : false "loaded" : false
}; };
this.active = lens.actives({ self.active = lens.actives({
"projects" : false, "projects" : false,
"posts" : false, "posts" : false,
"links" : false, "links" : false,
@ -165,14 +172,6 @@ menuOff(ev) {
self.update(); self.update();
} }
document.addEventListener("click", function(event) {
if(!event.target.closest('#menu')) {
if (self.menuActive) {
self.menuOff();
}
}
});
function activate(page) { function activate(page) {
return function() { return function() {
if (page !== "posts") { if (page !== "posts") {
@ -210,14 +209,14 @@ to(name) {
}).bind(this); }).bind(this);
} }
this.route("/", self.to("posts")); self.route("/", self.to("posts"));
this.route("posts/*", posts); self.route("posts/*", posts);
this.route("posts", (() => {posts(self.state._id)})); self.route("posts", (() => {posts(self.state._id)}));
this.route("projects", projects); self.route("projects", projects);
this.route("about", about); self.route("about", about);
this.route("links", links); self.route("links", links);
this.on("mount", () => { self.on("mount", () => {
route.start(true); route.start(true);
}); });
@ -235,7 +234,7 @@ function loaduser() {
}); });
} }
this.on("mount", loaduser); self.on("mount", loaduser);
</script> </script>
</app> </app>

40
src/scripts/post.tag

@ -2,27 +2,27 @@
<div class="posts-box post centered"> <div class="posts-box post centered">
<div <div
data-is="postcontrols" data-is="postcontrols"
prevloading={this.prevloading} prevloading={prevloading}
prev={this.prev} prev={prev}
atstart={this.start} atstart={start}
atend={this.end} atend={end}
nextloading={this.nextloading} nextloading={nextloading}
next={this.next} next={next}
> >
</div> </div>
<loading if={this.loading && this.opts.state.loaded}></loading> <loading if={loading && opts.state.loaded}></loading>
<div class="text-break"> <div class="text-break">
<div class={"animated " + (this.loading ? "invisible" : "fadeIn")}> <div class={"animated " + (loading ? "invisible" : "fadeIn")}>
<social <social
show={!this.loading} show={!loading}
ref="social" ref="social"
postid={this.opts.state._id} postid={opts.state._id}
> >
</social> </social>
<p class="post-content centered text-break"> <p class="post-content centered text-break">
<raw <raw
content="{ this.converter.makeHtml(this.content) }" content="{ converter.makeHtml(content) }"
> >
</raw> </raw>
</p> </p>
@ -31,12 +31,12 @@
</div> </div>
<div <div
data-is="postcontrols" data-is="postcontrols"
prevloading={this.prevloading} prevloading={prevloading}
prev={this.prev} prev={prev}
atstart={this.start} atstart={start}
atend={this.end} atend={end}
nextloading={this.nextloading} nextloading={nextloading}
next={this.next} next={next}
> >
</div> </div>
</div> </div>
@ -64,8 +64,8 @@ self.content = "";
self.swipe = false; self.swipe = false;
self.loading = self.opts.state.loaded; self.loading = self.opts.state.loaded;
this.start = false; self.start = false;
this.end = false; self.end = false;
const hashLength = 8; const hashLength = 8;
@ -176,7 +176,7 @@ getPost(_id) {
.then((resp) => { self.updatePost(JSON.parse(resp)) }) .then((resp) => { self.updatePost(JSON.parse(resp)) })
} }
this.getPost(this.opts.state._id, "fadeIn"); self.getPost(self.opts.state._id, "fadeIn");
</script> </script>
</post> </post>

Loading…
Cancel
Save