diff --git a/src/web/app/common/tags/messaging/index.tag b/src/web/app/common/tags/messaging/index.tag index 6ba6cb7d94..2dbf76bd9a 100644 --- a/src/web/app/common/tags/messaging/index.tag +++ b/src/web/app/common/tags/messaging/index.tag @@ -309,49 +309,64 @@ const q = this.refs.search.value; if (q == '') { this.searchResult = []; - } else { - this.api('users/search', { - query: q - max: 5 - }).then((users) => { - users.forEach (user) => - user._click = => - this.trigger 'navigate-user' user - this.searchResult = [] - this.searchResult = users - this.update(); - .catch (err) => - console.error err + return; + } + this.api('users/search', { + query: q, + max: 5 + }).then(users => { + users.forEach(user => { + user._click = () => { + this.trigger('navigate-user', user); + this.searchResult = []; + }; + }); + this.update({ + searchResult: users + }); + }); }; - this.on-search-keydown = e => { - const key = e.which; - switch (key) - | 9, 40 => // Key[TAB] or Key[↓] + this.onSearchKeydown = e => { + switch (e.which) { + case 9: // [TAB] + case 40: // [↓] e.preventDefault(); e.stopPropagation(); this.refs.searchResult.childNodes[0].focus(); + break; + } }; - this.on-searchResult-keydown = (i, e) => { - key = e.which - switch (key) - | 10, 13 => // Key[ENTER] - e.preventDefault(); - e.stopPropagation(); + this.onSearchResultKeydown = (i, e) => { + const cancel = () => { + e.preventDefault(); + e.stopPropagation(); + }; + switch (true) { + case e.which == 10: // [ENTER] + case e.which == 13: // [ENTER] + cancel(); this.searchResult[i]._click(); - | 27 => // Key[ESC] - e.preventDefault(); - e.stopPropagation(); + break; + + case e.which == 27: // [ESC] + cancel(); this.refs.search.focus(); - | 38 => // Key[↑] - e.preventDefault(); - e.stopPropagation(); + break; + + case e.which == 9 && e.shiftKey: // [TAB] + [Shift] + case e.which == 38: // [↑] + cancel(); (this.refs.searchResult.childNodes[i].previousElementSibling || this.refs.searchResult.childNodes[this.searchResult.length - 1]).focus(); - | 9, 40 => // Key[TAB] or Key[↓] - e.preventDefault(); - e.stopPropagation(); + break; + + case e.which == 9: // [TAB] + case e.which == 40: // [↓] + cancel(); (this.refs.searchResult.childNodes[i].nextElementSibling || this.refs.searchResult.childNodes[0]).focus(); + break; + } }; diff --git a/src/web/app/desktop/tags/pages/entrance.tag b/src/web/app/desktop/tags/pages/entrance.tag index 486f83f9dd..82ac8539ca 100644 --- a/src/web/app/desktop/tags/pages/entrance.tag +++ b/src/web/app/desktop/tags/pages/entrance.tag @@ -63,18 +63,24 @@ diff --git a/src/web/app/desktop/tags/pages/entrance/signin.tag b/src/web/app/desktop/tags/pages/entrance/signin.tag index b620c88b88..bd4b47c7df 100644 --- a/src/web/app/desktop/tags/pages/entrance/signin.tag +++ b/src/web/app/desktop/tags/pages/entrance/signin.tag @@ -120,11 +120,15 @@ diff --git a/src/web/app/desktop/tags/pages/entrance/signup.tag b/src/web/app/desktop/tags/pages/entrance/signup.tag index 1a777fe965..7ab53759c9 100644 --- a/src/web/app/desktop/tags/pages/entrance/signup.tag +++ b/src/web/app/desktop/tags/pages/entrance/signup.tag @@ -43,9 +43,5 @@ > i padding 14px - - - - diff --git a/src/web/app/desktop/tags/pages/home.tag b/src/web/app/desktop/tags/pages/home.tag index 433137e9cb..e988cbc76e 100644 --- a/src/web/app/desktop/tags/pages/home.tag +++ b/src/web/app/desktop/tags/pages/home.tag @@ -5,7 +5,6 @@ diff --git a/src/web/app/desktop/tags/pages/not-found.tag b/src/web/app/desktop/tags/pages/not-found.tag index a7cbad0b82..e62ea11008 100644 --- a/src/web/app/desktop/tags/pages/not-found.tag +++ b/src/web/app/desktop/tags/pages/not-found.tag @@ -1,54 +1,11 @@
-

Not Found

-
+

Not Found

diff --git a/src/web/app/desktop/tags/pages/post.tag b/src/web/app/desktop/tags/pages/post.tag index c3298b890c..b04ba69dc5 100644 --- a/src/web/app/desktop/tags/pages/post.tag +++ b/src/web/app/desktop/tags/pages/post.tag @@ -18,15 +18,18 @@ diff --git a/src/web/app/desktop/tags/pages/search.tag b/src/web/app/desktop/tags/pages/search.tag index fa0ebee0a9..ace9e27ab9 100644 --- a/src/web/app/desktop/tags/pages/search.tag +++ b/src/web/app/desktop/tags/pages/search.tag @@ -5,7 +5,6 @@ diff --git a/src/web/app/desktop/tags/pages/user.tag b/src/web/app/desktop/tags/pages/user.tag index 3bbfbe859c..767af31e9a 100644 --- a/src/web/app/desktop/tags/pages/user.tag +++ b/src/web/app/desktop/tags/pages/user.tag @@ -5,21 +5,23 @@ diff --git a/src/web/app/desktop/tags/search-posts.tag b/src/web/app/desktop/tags/search-posts.tag index 248b8cc87d..95ee33a5a4 100644 --- a/src/web/app/desktop/tags/search-posts.tag +++ b/src/web/app/desktop/tags/search-posts.tag @@ -31,56 +31,61 @@ this.mixin('api'); this.mixin('get-post-summary'); - this.query = this.opts.query - this.is-loading = true - this.is-empty = false - this.more-loading = false - this.page = 0 + this.query = this.opts.query; + this.isLoading = true; + this.isEmpty = false; + this.moreLoading = false; + this.page = 0; this.on('mount', () => { - document.addEventListener 'keydown' this.on-document-keydown - window.addEventListener 'scroll' this.on-scroll + document.addEventListener('keydown', this.onDocumentKeydown); + window.addEventListener('scroll', this.onScroll); this.api('posts/search', { query: this.query - }).then((posts) => { - this.is-loading = false - this.is-empty = posts.length == 0 - this.update(); - this.refs.timeline.set-posts posts + }).then(posts => { + this.update({ + isLoading: false, + isEmpty: posts.length == 0 + }); + this.refs.timeline.setPosts(posts); this.trigger('loaded'); - .catch (err) => - console.error err + }); + }); this.on('unmount', () => { - document.removeEventListener 'keydown' this.on-document-keydown - window.removeEventListener 'scroll' this.on-scroll + document.removeEventListener('keydown', this.onDocumentKeydown); + window.removeEventListener('scroll', this.onScroll); + }); - this.on-document-keydown = (e) => { - tag = e.target.tag-name.to-lower-case! - if tag != 'input' and tag != 'textarea' - if e.which == 84 // t + this.onDocumentKeydown = e => { + if (e.target.tagName != 'INPUT' && e.target.tagName != 'TEXTAREA') { + if (e.which == 84) { // t this.refs.timeline.focus(); + } + } + }; this.more = () => { - if @more-loading or @is-loading or this.timeline.posts.length == 0 - return - this.more-loading = true - this.update(); + if (this.moreLoading || this.isLoading || this.timeline.posts.length == 0) return; + this.update({ + moreLoading: true + }); this.api('posts/search', { - query: this.query + query: this.query, page: this.page + 1 - }).then((posts) => { - this.more-loading = false - this.page++ - this.update(); - this.refs.timeline.prepend-posts posts - .catch (err) => - console.error err + }).then(posts => { + this.update({ + moreLoading: false, + page: page + 1 + }); + this.refs.timeline.prependPosts(posts); + }); + }; - this.on-scroll = () => { - current = window.scrollY + window.inner-height - if current > document.body.offset-height - 16 // 遊び - @more! + this.onScroll = () => { + const current = window.scrollY + window.innerHeight; + if (current > document.body.offsetHeight - 16) this.more(); + }; diff --git a/src/web/app/desktop/tags/search.tag b/src/web/app/desktop/tags/search.tag index 82a1d79860..681b4c8aed 100644 --- a/src/web/app/desktop/tags/search.tag +++ b/src/web/app/desktop/tags/search.tag @@ -23,10 +23,12 @@ diff --git a/src/web/app/desktop/tags/user-photos.tag b/src/web/app/desktop/tags/user-photos.tag index 9cde9b8c4c..a72b1f3020 100644 --- a/src/web/app/desktop/tags/user-photos.tag +++ b/src/web/app/desktop/tags/user-photos.tag @@ -60,27 +60,33 @@ this.mixin('api'); this.mixin('is-promise'); - this.images = [] - this.initializing = true - - this.user = null - this.user-promise = if @is-promise this.opts.user then this.opts.user else Promise.resolve this.opts.user + this.images = []; + this.initializing = true; + this.user = null; + this.userPromise = this.isPromise(this.opts.user) + ? this.opts.user + : Promise.resolve(this.opts.user); this.on('mount', () => { - this.user-promise}).then((user) => { - this.user = user - this.update(); + this.userPromise.then(user => { + this.update({ + user: user + }); this.api('users/posts', { - user_id: this.user.id - with_media: true - limit: 9posts - }).then((posts) => { - this.initializing = false - posts.forEach (post) => - post.media.forEach (image) => - if @images.length < 9 - @images.push image + user_id: this.user.id, + with_media: true, + limit: 9 + }).then(posts => { + this.initializing = false; + posts.forEach(post => { + post.media.forEach(media => { + if (this.images.length < 9) this.images.push(image); + }); + }); this.update(); + }); + }); + }); diff --git a/src/web/app/desktop/tags/user-posts-graph.tag b/src/web/app/desktop/tags/user-posts-graph.tag deleted file mode 100644 index d1760c6b37..0000000000 --- a/src/web/app/desktop/tags/user-posts-graph.tag +++ /dev/null @@ -1,71 +0,0 @@ - - - - - diff --git a/src/web/app/desktop/tags/user-preview.tag b/src/web/app/desktop/tags/user-preview.tag index 8dd6551c41..f9806534e2 100644 --- a/src/web/app/desktop/tags/user-preview.tag +++ b/src/web/app/desktop/tags/user-preview.tag @@ -100,44 +100,47 @@ this.mixin('i'); this.mixin('api'); - this.u = this.opts.user - this.user = null - this.user-promise = - if typeof @u == 'string' - new Promise (resolve, reject) => + this.u = this.opts.user; + this.user = null; + this.userPromise = + typeof this.u == 'string' ? + new Promise((resolve, reject) => { this.api('users/show', { - user_id: if @u.0 == '@' then undefined else @u - username: if @u.0 == '@' then @u.substr 1 else undefined - }).then((user) => { - resolve user - else - Promise.resolve @u + user_id: this.u[0] == '@' ? undefined : this.u, + username: this.u[0] == '@' ? this.u.substr(1) : undefined + }).then(resolve); + }) + : Promise.resolve(this.u); this.on('mount', () => { - this.user-promise}).then((user) => { - this.user = user - this.update(); + this.userPromise.then(user => { + this.update({ + user: user + }); + }); Velocity(this.root, { - opacity: 0 - 'margin-top': '-8px' - } 0ms + opacity: 0, + 'margin-top': '-8px' + }, 0); Velocity(this.root, { - opacity: 1 + opacity: 1, 'margin-top': 0 }, { - duration: 200ms - easing: 'ease-out' - } + duration: 200, + easing: 'ease-out' + }); + }); this.close = () => { Velocity(this.root, { - opacity: 0 - 'margin-top': '-8px' + opacity: 0, + 'margin-top': '-8px' }, { - duration: 200ms - easing: 'ease-out' - complete: => this.unmount(); - } + duration: 200, + easing: 'ease-out', + complete: () => this.unmount() + }); + };