diff --git a/src/web/app/auth/tags/form.tag b/src/web/app/auth/tags/form.tag index 21a9a7404..619c71065 100644 --- a/src/web/app/auth/tags/form.tag +++ b/src/web/app/auth/tags/form.tag @@ -114,13 +114,13 @@ this.cancel = () => { this.api('auth/deny', { token: @session.token - .then => + }).then(() => { this.trigger('denied'); this.accept = () => { this.api('auth/accept', { token: @session.token - .then => + }).then(() => { this.trigger('accepted'); diff --git a/src/web/app/auth/tags/index.tag b/src/web/app/auth/tags/index.tag index 13abf0790..e52aeed4d 100644 --- a/src/web/app/auth/tags/index.tag +++ b/src/web/app/auth/tags/index.tag @@ -110,7 +110,7 @@ if @session.app.is_authorized this.api('auth/accept', { token: @session.token - .then => + }).then(() => { @accepted! else this.state = 'waiting' diff --git a/src/web/app/common/scripts/contains.js b/src/web/app/common/scripts/contains.js new file mode 100644 index 000000000..fe7366619 --- /dev/null +++ b/src/web/app/common/scripts/contains.js @@ -0,0 +1,8 @@ +module.exports = function(parent, child) { + let node = child.parentNode; + while (node) { + if (node == parent) return true; + node = node.parentNode; + } + return false; +} diff --git a/src/web/app/common/tags/signin.tag b/src/web/app/common/tags/signin.tag index 7b297b7b8..e2b873682 100644 --- a/src/web/app/common/tags/signin.tag +++ b/src/web/app/common/tags/signin.tag @@ -126,7 +126,7 @@ this.api('signin', { username: this.refs.username.value password: this.refs.password.value - .then => + }).then(() => { location.reload(); .catch => alert 'something happened' diff --git a/src/web/app/common/tags/signup.tag b/src/web/app/common/tags/signup.tag index 7646f8c86..39d4522e7 100644 --- a/src/web/app/common/tags/signup.tag +++ b/src/web/app/common/tags/signup.tag @@ -277,11 +277,11 @@ username: username, password: password, 'g-recaptcha-response': grecaptcha.getResponse() - .then => + }).then(() => { this.api('signin', { username: username password: password - .then => + }).then(() => { location.href = CONFIG.url .catch => alert '何らかの原因によりアカウントの作成に失敗しました。再度お試しください。' diff --git a/src/web/app/desktop/tags/analog-clock.tag b/src/web/app/desktop/tags/analog-clock.tag index ec627ec65..4ac6d2281 100644 --- a/src/web/app/desktop/tags/analog-clock.tag +++ b/src/web/app/desktop/tags/analog-clock.tag @@ -6,100 +6,92 @@ display block width 256px height 256px - diff --git a/src/web/app/desktop/tags/autocomplete-suggestion.tag b/src/web/app/desktop/tags/autocomplete-suggestion.tag index 40f5f5759..c7cc29dc1 100644 --- a/src/web/app/desktop/tags/autocomplete-suggestion.tag +++ b/src/web/app/desktop/tags/autocomplete-suggestion.tag @@ -80,108 +80,118 @@ diff --git a/src/web/app/desktop/tags/big-follow-button.tag b/src/web/app/desktop/tags/big-follow-button.tag index ba607c837..309e6ce8e 100644 --- a/src/web/app/desktop/tags/big-follow-button.tag +++ b/src/web/app/desktop/tags/big-follow-button.tag @@ -106,21 +106,21 @@ if this.user.is_following this.api('following/delete', { user_id: this.user.id - .then => + }).then(() => { this.user.is_following = false .catch (err) -> console.error err - .then => + }).then(() => { this.wait = false this.update(); else this.api('following/create', { user_id: this.user.id - .then => + }).then(() => { this.user.is_following = true .catch (err) -> console.error err - .then => + }).then(() => { this.wait = false this.update(); diff --git a/src/web/app/desktop/tags/contextmenu.tag b/src/web/app/desktop/tags/contextmenu.tag index 92c8b71a2..8df11c381 100644 --- a/src/web/app/desktop/tags/contextmenu.tag +++ b/src/web/app/desktop/tags/contextmenu.tag @@ -1,4 +1,5 @@ - + + diff --git a/src/web/app/desktop/tags/dialog.tag b/src/web/app/desktop/tags/dialog.tag index 61a40e7b3..c0df0b330 100644 --- a/src/web/app/desktop/tags/dialog.tag +++ b/src/web/app/desktop/tags/dialog.tag @@ -79,69 +79,72 @@ diff --git a/src/web/app/desktop/tags/drive/browser.tag b/src/web/app/desktop/tags/drive/browser.tag index 13019dd16..51c26943a 100644 --- a/src/web/app/desktop/tags/drive/browser.tag +++ b/src/web/app/desktop/tags/drive/browser.tag @@ -408,7 +408,7 @@ this.api('drive/files/update', { file_id: file folder_id: if this.folder? then this.folder.id else null - .then => + }).then(() => { // something .catch (err, text-status) => console.error err @@ -425,7 +425,7 @@ this.api('drive/folders/update', { folder_id: folder parent_id: if this.folder? then this.folder.id else null - .then => + }).then(() => { // something .catch (err) => if err == 'detected-circular-definition' diff --git a/src/web/app/desktop/tags/drive/file-contextmenu.tag b/src/web/app/desktop/tags/drive/file-contextmenu.tag index 9a615a902..933ae6db0 100644 --- a/src/web/app/desktop/tags/drive/file-contextmenu.tag +++ b/src/web/app/desktop/tags/drive/file-contextmenu.tag @@ -68,7 +68,7 @@ this.api('drive/files/update', { file_id: this.file.id name: name - .then => + }).then(() => { // something .catch (err) => console.error err diff --git a/src/web/app/desktop/tags/drive/folder-contextmenu.tag b/src/web/app/desktop/tags/drive/folder-contextmenu.tag index 833eff42e..582aa5e52 100644 --- a/src/web/app/desktop/tags/drive/folder-contextmenu.tag +++ b/src/web/app/desktop/tags/drive/folder-contextmenu.tag @@ -54,7 +54,7 @@ this.api('drive/folders/update', { folder_id: this.folder.id name: name - .then => + }).then(() => { // something .catch (err) => console.error err diff --git a/src/web/app/desktop/tags/drive/folder.tag b/src/web/app/desktop/tags/drive/folder.tag index fff3c13eb..c9bc5d7f0 100644 --- a/src/web/app/desktop/tags/drive/folder.tag +++ b/src/web/app/desktop/tags/drive/folder.tag @@ -118,7 +118,7 @@ this.api('drive/files/update', { file_id: file folder_id: this.folder.id - .then => + }).then(() => { // something .catch (err, text-status) => console.error err @@ -133,7 +133,7 @@ this.api('drive/folders/update', { folder_id: folder parent_id: this.folder.id - .then => + }).then(() => { // something .catch (err) => if err == 'detected-circular-definition' diff --git a/src/web/app/desktop/tags/drive/nav-folder.tag b/src/web/app/desktop/tags/drive/nav-folder.tag index 3f57fc129..b485ddb53 100644 --- a/src/web/app/desktop/tags/drive/nav-folder.tag +++ b/src/web/app/desktop/tags/drive/nav-folder.tag @@ -72,7 +72,7 @@ this.api('drive/files/update', { file_id: file folder_id: if this.folder? then this.folder.id else null - .then => + }).then(() => { // something .catch (err, text-status) => console.error err @@ -87,7 +87,7 @@ this.api('drive/folders/update', { folder_id: folder parent_id: if this.folder? then this.folder.id else null - .then => + }).then(() => { // something .catch (err, text-status) => console.error err diff --git a/src/web/app/desktop/tags/ellipsis-icon.tag b/src/web/app/desktop/tags/ellipsis-icon.tag index 731c2525f..8462bfc4a 100644 --- a/src/web/app/desktop/tags/ellipsis-icon.tag +++ b/src/web/app/desktop/tags/ellipsis-icon.tag @@ -33,9 +33,5 @@ 40% transform scale(1) - - - - diff --git a/src/web/app/desktop/tags/follow-button.tag b/src/web/app/desktop/tags/follow-button.tag index 7b5ab7d0e..64055a158 100644 --- a/src/web/app/desktop/tags/follow-button.tag +++ b/src/web/app/desktop/tags/follow-button.tag @@ -103,21 +103,21 @@ if this.user.is_following this.api('following/delete', { user_id: this.user.id - .then => + }).then(() => { this.user.is_following = false .catch (err) -> console.error err - .then => + }).then(() => { this.wait = false this.update(); else this.api('following/create', { user_id: this.user.id - .then => + }).then(() => { this.user.is_following = true .catch (err) -> console.error err - .then => + }).then(() => { this.wait = false this.update(); diff --git a/src/web/app/desktop/tags/go-top.tag b/src/web/app/desktop/tags/go-top.tag deleted file mode 100644 index cb75c0480..000000000 --- a/src/web/app/desktop/tags/go-top.tag +++ /dev/null @@ -1,14 +0,0 @@ - - - - diff --git a/src/web/app/desktop/tags/images-viewer.tag b/src/web/app/desktop/tags/images-viewer.tag index 986debab4..8d10ec656 100644 --- a/src/web/app/desktop/tags/images-viewer.tag +++ b/src/web/app/desktop/tags/images-viewer.tag @@ -39,7 +39,7 @@ this.click = () => { dialog = document.body.appendChild(document.createElement('mk-image-dialog')); - riot.mount dialog, do + riot.mount dialog, do image: @image diff --git a/src/web/app/desktop/tags/index.js b/src/web/app/desktop/tags/index.js index ed100ef75..a90e42211 100644 --- a/src/web/app/desktop/tags/index.js +++ b/src/web/app/desktop/tags/index.js @@ -16,7 +16,6 @@ require('./crop-window.tag'); require('./settings.tag'); require('./settings-window.tag'); require('./analog-clock.tag'); -require('./go-top.tag'); require('./ui-header.tag'); require('./ui-header-account.tag'); require('./ui-header-notifications.tag'); diff --git a/src/web/app/desktop/tags/input-dialog.tag b/src/web/app/desktop/tags/input-dialog.tag index dbfd1cfc7..aa417f0a7 100644 --- a/src/web/app/desktop/tags/input-dialog.tag +++ b/src/web/app/desktop/tags/input-dialog.tag @@ -1,13 +1,17 @@ - { parent.title } - -
- -
-
- - -
+ + + { parent.title } + + +
+ +
+
+ + +
+
diff --git a/src/web/app/desktop/tags/post-detail.tag b/src/web/app/desktop/tags/post-detail.tag index 3b5671452..00426ea9b 100644 --- a/src/web/app/desktop/tags/post-detail.tag +++ b/src/web/app/desktop/tags/post-detail.tag @@ -412,13 +412,13 @@ if this.p.is_liked this.api('posts/likes/delete', { post_id: this.p.id - .then => + }).then(() => { this.p.is_liked = false this.update(); else this.api('posts/likes/create', { post_id: this.p.id - .then => + }).then(() => { this.p.is_liked = true this.update(); diff --git a/src/web/app/desktop/tags/post-form.tag b/src/web/app/desktop/tags/post-form.tag index fe435c4e4..cb1693420 100644 --- a/src/web/app/desktop/tags/post-form.tag +++ b/src/web/app/desktop/tags/post-form.tag @@ -455,7 +455,7 @@ .catch (err) => console.error err @notify '投稿できませんでした' - .then => + }).then(() => { this.wait = false this.update(); diff --git a/src/web/app/desktop/tags/repost-form.tag b/src/web/app/desktop/tags/repost-form.tag index c3e3e02df..7d309bf75 100644 --- a/src/web/app/desktop/tags/repost-form.tag +++ b/src/web/app/desktop/tags/repost-form.tag @@ -127,14 +127,14 @@ this.wait = true this.api('posts/create', { repost_id: this.opts.post.id - text: if @quote then this.refs.text.value else undefined + text: if this.quote then this.refs.text.value else undefined }).then((data) => { this.trigger('posted'); @notify 'Repostしました!' .catch (err) => console.error err @notify 'Repostできませんでした' - .then => + }).then(() => { this.wait = false this.update(); diff --git a/src/web/app/desktop/tags/search-posts.tag b/src/web/app/desktop/tags/search-posts.tag index bad055eb0..248b8cc87 100644 --- a/src/web/app/desktop/tags/search-posts.tag +++ b/src/web/app/desktop/tags/search-posts.tag @@ -42,7 +42,7 @@ window.addEventListener 'scroll' this.on-scroll this.api('posts/search', { - query: @query + query: this.query }).then((posts) => { this.is-loading = false this.is-empty = posts.length == 0 @@ -68,7 +68,7 @@ this.more-loading = true this.update(); this.api('posts/search', { - query: @query + query: this.query page: this.page + 1 }).then((posts) => { this.more-loading = false diff --git a/src/web/app/desktop/tags/sub-post-content.tag b/src/web/app/desktop/tags/sub-post-content.tag index 8d4a06b49..e0509ab7d 100644 --- a/src/web/app/desktop/tags/sub-post-content.tag +++ b/src/web/app/desktop/tags/sub-post-content.tag @@ -1,5 +1,11 @@ - +
+ + + + + RP: ... +
({ post.media.length }つのメディア) @@ -31,15 +37,17 @@ this.mixin('text'); this.mixin('user-preview'); - this.post = this.opts.post + this.post = this.opts.post; this.on('mount', () => { - if this.post.text? - tokens = @analyze this.post.text - this.refs.text.innerHTML = @compile tokens, false + if (this.post.text) { + const tokens = this.analyze(this.post.text); + this.refs.text.innerHTML = this.compile(tokens, false); - this.refs.text.children.forEach (e) => - if e.tag-name == 'MK-URL' - riot.mount e + this.refs.text.children.forEach(e => { + if (e.tagName == 'MK-URL') riot.mount(e); + }); + } + }); diff --git a/src/web/app/desktop/tags/timeline-post.tag b/src/web/app/desktop/tags/timeline-post.tag index 5b656f812..440d5d9f4 100644 --- a/src/web/app/desktop/tags/timeline-post.tag +++ b/src/web/app/desktop/tags/timeline-post.tag @@ -324,7 +324,7 @@ this.mixin('NotImplementedException'); this.post = this.opts.post; - this.isRepost = this.post.repost != null && this.post.text == null; + this.isRepost = this.post.repost && this.post.text == null; this.p = this.isRepost ? this.post.repost : this.post; this.title = this.dateStringify(this.p.created_at); @@ -354,58 +354,87 @@ }); this.reply = () => { - form = document.body.appendChild(document.createElement('mk-post-form-window')); - riot.mount form, do + riot.mount(document.body.appendChild(document.createElement('mk-post-form-window')), { reply: this.p + }); + }; this.repost = () => { - form = document.body.appendChild(document.createElement('mk-repost-form-window')); - riot.mount form, do + riot.mount(document.body.appendChild(document.createElement('mk-repost-form-window')), { post: this.p + }); + }; this.like = () => { - if this.p.is_liked + if (this.p.is_liked) { this.api('posts/likes/delete', { post_id: this.p.id - .then => - this.p.is_liked = false + }).then(() => { + this.p.is_liked = false; this.update(); - else + }); + } else { this.api('posts/likes/create', { post_id: this.p.id - .then => - this.p.is_liked = true + }).then(() => { + this.p.is_liked = true; this.update(); + }); + } + }; - this.toggle-detail = () => { - this.is-detail-opened = !@is-detail-opened - this.update(); + this.toggleDetail = () => { + this.update({ + isDetailOpened: !this.isDetailOpened + }); + }; - this.on-key-down = (e) => { - should-be-cancel = true - switch - | e.which == 38 or e.which == 74 or (e.which == 9 and e.shift-key) => // ↑, j or Shift+Tab - focus this.root, (e) -> e.previousElementSibling - | e.which == 40 or e.which == 75 or e.which == 9 => // ↓, k or Tab - focus this.root, (e) -> e.nextElementSibling - | e.which == 81 or e.which == 69 => // q or e - @repost! - | e.which == 70 or e.which == 76 => // f or l - @like! - | e.which == 82 => // r - @reply! - | _ => - should-be-cancel = false + this.onKeyDown = e => { + let shouldBeCancel = true; - if should-be-cancel - e.preventDefault(); + switch (true) { + case e.which == 38: // [↑] + case e.which == 74: // [j] + case e.which == 9 && e.shiftKey: // [Shift] + [Tab] + focus(this.root, e => e.previousElementSibling); + break; - function focus(el, fn) - target = fn el - if target? - if target.has-attribute 'tabindex' + case e.which == 40: // [↓] + case e.which == 75: // [k] + case e.which == 9: // [Tab] + focus(this.root, e => e.nextElementSibling); + break; + + case e.which == 81: // [q] + case e.which == 69: // [e] + this.repost(); + break; + + case e.which == 70: // [f] + case e.which == 76: // [l] + this.like(); + break; + + case e.which == 82: // [r] + this.reply(); + break; + + default: + shouldBeCancel = false; + } + + if (shouldBeCancel) e.preventDefault(); + }; + + function focus(el, fn) { + const target = fn(el); + if (target) { + if (target.hasAttribute('tabindex')) { target.focus(); - else - focus target, fn + } else { + focus(target, fn); + } + } + } diff --git a/src/web/app/desktop/tags/window.tag b/src/web/app/desktop/tags/window.tag index 33bb244fa..bd9df8823 100644 --- a/src/web/app/desktop/tags/window.tag +++ b/src/web/app/desktop/tags/window.tag @@ -501,7 +501,7 @@ this.ondragover = (e) => { e.dataTransfer.dropEffect = 'none' - this.on-keydown = (e) => { + this.onKeydown = (e) => { if e.which == 27 // Esc if @can-close e.preventDefault(); diff --git a/src/web/app/dev/tags/new-app-form.tag b/src/web/app/dev/tags/new-app-form.tag index 6be1c5448..c75eec37d 100644 --- a/src/web/app/dev/tags/new-app-form.tag +++ b/src/web/app/dev/tags/new-app-form.tag @@ -233,7 +233,7 @@ description: description callback_url: cb permission: permission.join ',' - .then => + }).then(() => { location.href = '/apps' .catch => alert 'アプリの作成に失敗しました。再度お試しください。' diff --git a/src/web/app/mobile/tags/drive/file-viewer.tag b/src/web/app/mobile/tags/drive/file-viewer.tag index 5f2c5f61f..e91a451c0 100644 --- a/src/web/app/mobile/tags/drive/file-viewer.tag +++ b/src/web/app/mobile/tags/drive/file-viewer.tag @@ -192,9 +192,9 @@ name = window.prompt '名前を変更' this.file.name if name? and name != '' and name != this.file.name this.api('drive/files/update', { - file_id: this.file.id + file_id: this.file.id, name: name - .then => + }).then(() => { this.parent.cf this.file, true diff --git a/src/web/app/mobile/tags/follow-button.tag b/src/web/app/mobile/tags/follow-button.tag index ecd0dc594..43fcc3499 100644 --- a/src/web/app/mobile/tags/follow-button.tag +++ b/src/web/app/mobile/tags/follow-button.tag @@ -84,21 +84,21 @@ if this.user.is_following this.api('following/delete', { user_id: this.user.id - .then => + }).then(() => { this.user.is_following = false .catch (err) -> console.error err - .then => + }).then(() => { this.wait = false this.update(); else this.api('following/create', { user_id: this.user.id - .then => + }).then(() => { this.user.is_following = true .catch (err) -> console.error err - .then => + }).then(() => { this.wait = false this.update(); diff --git a/src/web/app/mobile/tags/post-detail.tag b/src/web/app/mobile/tags/post-detail.tag index 61983a159..2b4bef1da 100644 --- a/src/web/app/mobile/tags/post-detail.tag +++ b/src/web/app/mobile/tags/post-detail.tag @@ -406,13 +406,13 @@ if this.p.is_liked this.api('posts/likes/delete', { post_id: this.p.id - .then => + }).then(() => { this.p.is_liked = false this.update(); else this.api('posts/likes/create', { post_id: this.p.id - .then => + }).then(() => { this.p.is_liked = true this.update(); diff --git a/src/web/app/mobile/tags/search-posts.tag b/src/web/app/mobile/tags/search-posts.tag index 83c4b9cfb..2dbb162d7 100644 --- a/src/web/app/mobile/tags/search-posts.tag +++ b/src/web/app/mobile/tags/search-posts.tag @@ -9,24 +9,24 @@ diff --git a/src/web/app/mobile/tags/user-timeline.tag b/src/web/app/mobile/tags/user-timeline.tag index 2d3716b84..71fb1ac27 100644 --- a/src/web/app/mobile/tags/user-timeline.tag +++ b/src/web/app/mobile/tags/user-timeline.tag @@ -11,21 +11,21 @@