|
@ -28,6 +28,8 @@ import './raw.tag'; |
|
|
import 'whatwg-fetch'; |
|
|
import 'whatwg-fetch'; |
|
|
import { default as R } from 'ramda'; |
|
|
import { default as R } from 'ramda'; |
|
|
import { default as showdown } from 'showdown'; |
|
|
import { default as showdown } from 'showdown'; |
|
|
|
|
|
import { default as jquery } from 'jquery'; |
|
|
|
|
|
|
|
|
import './postcontrols.tag'; |
|
|
import './postcontrols.tag'; |
|
|
import route from 'riot-route'; |
|
|
import route from 'riot-route'; |
|
|
|
|
|
|
|
@ -43,7 +45,6 @@ self.title = ""; |
|
|
self.content = ""; |
|
|
self.content = ""; |
|
|
self.prevloading = ""; |
|
|
self.prevloading = ""; |
|
|
self.nextloading = ""; |
|
|
self.nextloading = ""; |
|
|
self.transition = ""; |
|
|
|
|
|
self.nomore = false; |
|
|
self.nomore = false; |
|
|
self.content = ""; |
|
|
self.content = ""; |
|
|
self.swipe = false; |
|
|
self.swipe = false; |
|
@ -72,13 +73,19 @@ next(ev) { |
|
|
self.nextPost(self._id, "fadeIn"); |
|
|
self.nextPost(self._id, "fadeIn"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
updatePost(body, transition) { |
|
|
toTop() { |
|
|
|
|
|
jquery('html, body').stop().animate({ |
|
|
|
|
|
scrollTop: jquery(".navigate").offset().top-15 |
|
|
|
|
|
}, 1000); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
updatePost(body) { |
|
|
if (body === "false") { |
|
|
if (body === "false") { |
|
|
self.nomore = true; |
|
|
self.nomore = true; |
|
|
self.prevloading = ""; |
|
|
self.prevloading = ""; |
|
|
self.nextloading = ""; |
|
|
self.nextloading = ""; |
|
|
self.loading = false; |
|
|
self.loading = false; |
|
|
self.update() |
|
|
self.update(); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
@ -88,7 +95,6 @@ updatePost(body, transition) { |
|
|
self.nextloading = ""; |
|
|
self.nextloading = ""; |
|
|
self.nomore = true; |
|
|
self.nomore = true; |
|
|
self.swipe = !self.swipe; |
|
|
self.swipe = !self.swipe; |
|
|
self.transition = ""; |
|
|
|
|
|
self.loading = false; |
|
|
self.loading = false; |
|
|
self.update(); |
|
|
self.update(); |
|
|
return; |
|
|
return; |
|
@ -97,32 +103,33 @@ updatePost(body, transition) { |
|
|
self.author = postcontent.author; |
|
|
self.author = postcontent.author; |
|
|
self.content = postcontent.content; |
|
|
self.content = postcontent.content; |
|
|
self.title = postcontent.title; |
|
|
self.title = postcontent.title; |
|
|
self.transition = transition; |
|
|
|
|
|
self.swipe = !self.swipe; |
|
|
self.swipe = !self.swipe; |
|
|
self.nomore = false; |
|
|
self.nomore = false; |
|
|
self.loading = false; |
|
|
self.loading = false; |
|
|
|
|
|
self.one("updated", self.toTop); |
|
|
self.update(); |
|
|
self.update(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
self.prevloading = ""; |
|
|
self.prevloading = ""; |
|
|
self.nextloading = ""; |
|
|
self.nextloading = ""; |
|
|
self.route(`/posts/${self._id}`); |
|
|
self.route(`/posts/${self._id}`); |
|
|
|
|
|
self.one("updated", self.toTop); |
|
|
self.update(); |
|
|
self.update(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
nextPost(_id, transition) { |
|
|
nextPost(_id) { |
|
|
fetch(`/blog/switchpost/${_id.slice(-8)}`) |
|
|
fetch(`/blog/switchpost/${_id.slice(-8)}`) |
|
|
.then((resp) => resp.text()) |
|
|
.then((resp) => resp.text()) |
|
|
.then((resp) => { self.updatePost(resp, transition) }) |
|
|
.then((resp) => { self.updatePost(resp) }) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
prevPost(_id, transition) { |
|
|
prevPost(_id) { |
|
|
fetch(`/blog/prevpost/${_id.slice(-8)}`) |
|
|
fetch(`/blog/prevpost/${_id.slice(-8)}`) |
|
|
.then((resp) => resp.text()) |
|
|
.then((resp) => resp.text()) |
|
|
.then((resp) => { self.updatePost(resp, transition) }) |
|
|
.then((resp) => { self.updatePost(resp) }) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
getPost(_id, transition) { |
|
|
getPost(_id) { |
|
|
var url; |
|
|
var url; |
|
|
if (_id !== undefined && _id) { |
|
|
if (_id !== undefined && _id) { |
|
|
url = `/blog/getpost/${_id.slice(-8)}`; |
|
|
url = `/blog/getpost/${_id.slice(-8)}`; |
|
@ -132,7 +139,7 @@ getPost(_id, transition) { |
|
|
} |
|
|
} |
|
|
fetch(url) |
|
|
fetch(url) |
|
|
.then((resp) => resp.text()) |
|
|
.then((resp) => resp.text()) |
|
|
.then((resp) => {self.updatePost(resp, transition) }) |
|
|
.then((resp) => {self.updatePost(resp) }) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
this.getPost(this.opts.state._id, "fadeIn"); |
|
|
this.getPost(this.opts.state._id, "fadeIn"); |
|
|