summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorこぴなたみぽ <syuilotan@yahoo.co.jp>2018-02-16 17:35:15 +0900
committerこぴなたみぽ <syuilotan@yahoo.co.jp>2018-02-16 17:35:15 +0900
commitc377ddf77a5cae98b04444dc93e738e06b9bd6e6 (patch)
tree4d1f6da27af576e6fe71329a0dae95cf7ee1a4f8 /src
parentwip (diff)
downloadmisskey-c377ddf77a5cae98b04444dc93e738e06b9bd6e6.tar.gz
misskey-c377ddf77a5cae98b04444dc93e738e06b9bd6e6.tar.bz2
misskey-c377ddf77a5cae98b04444dc93e738e06b9bd6e6.zip
wip
Diffstat (limited to 'src')
-rw-r--r--src/web/app/desktop/-tags/pages/search.tag20
-rw-r--r--src/web/app/desktop/-tags/search-posts.tag96
-rw-r--r--src/web/app/desktop/-tags/search.tag34
-rw-r--r--src/web/app/desktop/views/pages/search.vue115
4 files changed, 115 insertions, 150 deletions
diff --git a/src/web/app/desktop/-tags/pages/search.tag b/src/web/app/desktop/-tags/pages/search.tag
deleted file mode 100644
index eaa80a039c..0000000000
--- a/src/web/app/desktop/-tags/pages/search.tag
+++ /dev/null
@@ -1,20 +0,0 @@
-<mk-search-page>
- <mk-ui ref="ui">
- <mk-search ref="search" query={ parent.opts.query }/>
- </mk-ui>
- <style lang="stylus" scoped>
- :scope
- display block
- </style>
- <script lang="typescript">
- import Progress from '../../../common/scripts/loading';
-
- this.on('mount', () => {
- Progress.start();
-
- this.$refs.ui.refs.search.on('loaded', () => {
- Progress.done();
- });
- });
- </script>
-</mk-search-page>
diff --git a/src/web/app/desktop/-tags/search-posts.tag b/src/web/app/desktop/-tags/search-posts.tag
deleted file mode 100644
index 94a6f25247..0000000000
--- a/src/web/app/desktop/-tags/search-posts.tag
+++ /dev/null
@@ -1,96 +0,0 @@
-<mk-search-posts>
- <div class="loading" v-if="isLoading">
- <mk-ellipsis-icon/>
- </div>
- <p class="empty" v-if="isEmpty">%fa:search%「{ query }」に関する投稿は見つかりませんでした。</p>
- <mk-timeline ref="timeline">
- <yield to="footer">
- <template v-if="!parent.moreLoading">%fa:moon%</template>
- <template v-if="parent.moreLoading">%fa:spinner .pulse .fw%</template>
- </yield/>
- </mk-timeline>
- <style lang="stylus" scoped>
- :scope
- display block
- background #fff
-
- > .loading
- padding 64px 0
-
- > .empty
- display block
- margin 0 auto
- padding 32px
- max-width 400px
- text-align center
- color #999
-
- > [data-fa]
- display block
- margin-bottom 16px
- font-size 3em
- color #ccc
-
- </style>
- <script lang="typescript">
- import parse from '../../common/scripts/parse-search-query';
-
- this.mixin('api');
-
- this.query = this.opts.query;
- this.isLoading = true;
- this.isEmpty = false;
- this.moreLoading = false;
- this.limit = 30;
- this.offset = 0;
-
- this.on('mount', () => {
- document.addEventListener('keydown', this.onDocumentKeydown);
- window.addEventListener('scroll', this.onScroll);
-
- this.$root.$data.os.api('posts/search', parse(this.query)).then(posts => {
- this.update({
- isLoading: false,
- isEmpty: posts.length == 0
- });
- this.$refs.timeline.setPosts(posts);
- this.$emit('loaded');
- });
- });
-
- this.on('unmount', () => {
- document.removeEventListener('keydown', this.onDocumentKeydown);
- window.removeEventListener('scroll', this.onScroll);
- });
-
- this.onDocumentKeydown = e => {
- if (e.target.tagName != 'INPUT' && e.target.tagName != 'TEXTAREA') {
- if (e.which == 84) { // t
- this.$refs.timeline.focus();
- }
- }
- };
-
- this.more = () => {
- if (this.moreLoading || this.isLoading || this.timeline.posts.length == 0) return;
- this.offset += this.limit;
- this.update({
- moreLoading: true
- });
- return this.$root.$data.os.api('posts/search', Object.assign({}, parse(this.query), {
- limit: this.limit,
- offset: this.offset
- })).then(posts => {
- this.update({
- moreLoading: false
- });
- this.$refs.timeline.prependPosts(posts);
- });
- };
-
- this.onScroll = () => {
- const current = window.scrollY + window.innerHeight;
- if (current > document.body.offsetHeight - 16) this.more();
- };
- </script>
-</mk-search-posts>
diff --git a/src/web/app/desktop/-tags/search.tag b/src/web/app/desktop/-tags/search.tag
deleted file mode 100644
index 28127b721b..0000000000
--- a/src/web/app/desktop/-tags/search.tag
+++ /dev/null
@@ -1,34 +0,0 @@
-<mk-search>
- <header>
- <h1>{ query }</h1>
- </header>
- <mk-search-posts ref="posts" query={ query }/>
- <style lang="stylus" scoped>
- :scope
- display block
- padding-bottom 32px
-
- > header
- width 100%
- max-width 600px
- margin 0 auto
- color #555
-
- > mk-search-posts
- max-width 600px
- margin 0 auto
- border solid 1px rgba(0, 0, 0, 0.075)
- border-radius 6px
- overflow hidden
-
- </style>
- <script lang="typescript">
- this.query = this.opts.query;
-
- this.on('mount', () => {
- this.$refs.posts.on('loaded', () => {
- this.$emit('loaded');
- });
- });
- </script>
-</mk-search>
diff --git a/src/web/app/desktop/views/pages/search.vue b/src/web/app/desktop/views/pages/search.vue
new file mode 100644
index 0000000000..d8147e0d6a
--- /dev/null
+++ b/src/web/app/desktop/views/pages/search.vue
@@ -0,0 +1,115 @@
+<template>
+<mk-ui>
+ <header :class="$style.header">
+ <h1>{{ query }}</h1>
+ </header>
+ <div :class="$style.loading" v-if="fetching">
+ <mk-ellipsis-icon/>
+ </div>
+ <p :class="$style.empty" v-if="empty">%fa:search%「{{ query }}」に関する投稿は見つかりませんでした。</p>
+ <mk-posts ref="timeline" :class="$style.posts">
+ <div slot="footer">
+ <template v-if="!moreFetching">%fa:search%</template>
+ <template v-if="moreFetching">%fa:spinner .pulse .fw%</template>
+ </div>
+ </mk-posts>
+</mk-ui>
+</template>
+
+<script lang="ts">
+import Vue from 'vue';
+import Progress from '../../../common/scripts/loading';
+import parse from '../../../common/scripts/parse-search-query';
+
+const limit = 30;
+
+export default Vue.extend({
+ props: ['query'],
+ data() {
+ return {
+ fetching: true,
+ moreFetching: false,
+ offset: 0,
+ posts: []
+ };
+ },
+ computed: {
+ empty(): boolean {
+ return this.posts.length == 0;
+ }
+ },
+ mounted() {
+ Progress.start();
+
+ document.addEventListener('keydown', this.onDocumentKeydown);
+ window.addEventListener('scroll', this.onScroll);
+
+ this.$root.$data.os.api('posts/search', parse(this.query)).then(posts => {
+ this.fetching = false;
+ this.posts = posts;
+ });
+ },
+ beforeDestroy() {
+ document.removeEventListener('keydown', this.onDocumentKeydown);
+ window.removeEventListener('scroll', this.onScroll);
+ },
+ methods: {
+ onDocumentKeydown(e) {
+ if (e.target.tagName != 'INPUT' && e.target.tagName != 'TEXTAREA') {
+ if (e.which == 84) { // t
+ (this.$refs.timeline as any).focus();
+ }
+ }
+ },
+ more() {
+ if (this.moreFetching || this.fetching || this.posts.length == 0) return;
+ this.offset += limit;
+ this.moreFetching = true;
+ return this.$root.$data.os.api('posts/search', Object.assign({}, parse(this.query), {
+ limit: limit,
+ offset: this.offset
+ })).then(posts => {
+ this.moreFetching = false;
+ this.posts = this.posts.concat(posts);
+ });
+ },
+ onScroll() {
+ const current = window.scrollY + window.innerHeight;
+ if (current > document.body.offsetHeight - 16) this.more();
+ }
+ }
+});
+</script>
+
+<style lang="stylus" module>
+.header
+ width 100%
+ max-width 600px
+ margin 0 auto
+ color #555
+
+.posts
+ max-width 600px
+ margin 0 auto
+ border solid 1px rgba(0, 0, 0, 0.075)
+ border-radius 6px
+ overflow hidden
+
+.loading
+ padding 64px 0
+
+.empty
+ display block
+ margin 0 auto
+ padding 32px
+ max-width 400px
+ text-align center
+ color #999
+
+ > [data-fa]
+ display block
+ margin-bottom 16px
+ font-size 3em
+ color #ccc
+
+</style>