diff --git a/package.json b/package.json index 963e606..d0a75f0 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "axios": "^0.16.1", "font-awesome": "^4.7.0", "immutable": "^3.8.1", + "jquery": "^3.2.1", "moment": "^2.18.1", "querystring": "^0.2.0", "rollup-plugin-json": "^2.1.1", diff --git a/src/scripts/editor.tag b/src/scripts/editor.tag index 310e7ca..91ea0df 100644 --- a/src/scripts/editor.tag +++ b/src/scripts/editor.tag @@ -218,7 +218,7 @@ loadPost(_id) { return false; } self.update({"loading" : true}); - axios.get(`/blog/getpost/${_id}`) + axios.get(`/blog/getpost/${_id.slice(-8)}`) .then(function(resp) { self.update({"loading" : false}); self.refs.textarea.value = resp.data.content; diff --git a/src/scripts/post.tag b/src/scripts/post.tag index 0099642..b11abf0 100644 --- a/src/scripts/post.tag +++ b/src/scripts/post.tag @@ -28,6 +28,8 @@ import './raw.tag'; import 'whatwg-fetch'; import { default as R } from 'ramda'; import { default as showdown } from 'showdown'; +import { default as jquery } from 'jquery'; + import './postcontrols.tag'; import route from 'riot-route'; @@ -43,7 +45,6 @@ self.title = ""; self.content = ""; self.prevloading = ""; self.nextloading = ""; -self.transition = ""; self.nomore = false; self.content = ""; self.swipe = false; @@ -72,13 +73,19 @@ next(ev) { 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") { self.nomore = true; self.prevloading = ""; self.nextloading = ""; self.loading = false; - self.update() + self.update(); return; } else { @@ -88,7 +95,6 @@ updatePost(body, transition) { self.nextloading = ""; self.nomore = true; self.swipe = !self.swipe; - self.transition = ""; self.loading = false; self.update(); return; @@ -97,32 +103,33 @@ updatePost(body, transition) { self.author = postcontent.author; self.content = postcontent.content; self.title = postcontent.title; - self.transition = transition; self.swipe = !self.swipe; self.nomore = false; self.loading = false; + self.one("updated", self.toTop); self.update(); } self.prevloading = ""; self.nextloading = ""; self.route(`/posts/${self._id}`); + self.one("updated", self.toTop); self.update(); } -nextPost(_id, transition) { +nextPost(_id) { fetch(`/blog/switchpost/${_id.slice(-8)}`) .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)}`) .then((resp) => resp.text()) - .then((resp) => { self.updatePost(resp, transition) }) + .then((resp) => { self.updatePost(resp) }) } -getPost(_id, transition) { +getPost(_id) { var url; if (_id !== undefined && _id) { url = `/blog/getpost/${_id.slice(-8)}`; @@ -132,7 +139,7 @@ getPost(_id, transition) { } fetch(url) .then((resp) => resp.text()) - .then((resp) => {self.updatePost(resp, transition) }) + .then((resp) => {self.updatePost(resp) }) } this.getPost(this.opts.state._id, "fadeIn"); diff --git a/src/styles/riotblog.scss b/src/styles/riotblog.scss index 77ba35a..b3715d0 100644 --- a/src/styles/riotblog.scss +++ b/src/styles/riotblog.scss @@ -66,6 +66,7 @@ p, h6, h4 { .post-title { font-family: 'Open Sans',sans-serif; font-size: 1.6em; + font-weight: 600; line-height: 1.6em; color: #3A4145; } diff --git a/yarn.lock b/yarn.lock index b816100..22b3957 100644 --- a/yarn.lock +++ b/yarn.lock @@ -672,6 +672,10 @@ jodid25519@^1.0.0: dependencies: jsbn "~0.1.0" +jquery@^3.2.1: + version "3.2.1" + resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.2.1.tgz#5c4d9de652af6cd0a770154a631bba12b015c787" + jsbn@~0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513"