Browse Source

clean up

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

40
src/scripts/post.tag

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

Loading…
Cancel
Save