mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-12-24 05:33:08 +02:00
parent
2faa58928f
commit
b7c5c71c6f
7 changed files with 31 additions and 18 deletions
|
@ -9,7 +9,7 @@
|
|||
@keypress="onKeypress"
|
||||
@paste="onPaste"
|
||||
:placeholder="$t('input-message-here')"
|
||||
v-autocomplete="'text'"
|
||||
v-autocomplete="{ model: 'text' }"
|
||||
></textarea>
|
||||
<div class="file" @click="file = null" v-if="file">{{ file.name }}</div>
|
||||
<mk-uploader ref="uploader" @uploaded="onUploaded"/>
|
||||
|
|
|
@ -21,21 +21,23 @@ class Autocomplete {
|
|||
private suggestion: any;
|
||||
private textarea: any;
|
||||
private vm: any;
|
||||
private model: any;
|
||||
private currentType: string;
|
||||
private opts: {
|
||||
model: string;
|
||||
};
|
||||
|
||||
private get text(): string {
|
||||
return this.vm[this.model];
|
||||
return this.vm[this.opts.model];
|
||||
}
|
||||
|
||||
private set text(text: string) {
|
||||
this.vm[this.model] = text;
|
||||
this.vm[this.opts.model] = text;
|
||||
}
|
||||
|
||||
/**
|
||||
* 対象のテキストエリアを与えてインスタンスを初期化します。
|
||||
*/
|
||||
constructor(textarea, vm, model) {
|
||||
constructor(textarea, vm, opts) {
|
||||
//#region BIND
|
||||
this.onInput = this.onInput.bind(this);
|
||||
this.complete = this.complete.bind(this);
|
||||
|
@ -45,7 +47,7 @@ class Autocomplete {
|
|||
this.suggestion = null;
|
||||
this.textarea = textarea;
|
||||
this.vm = vm;
|
||||
this.model = model;
|
||||
this.opts = opts;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,12 +17,12 @@
|
|||
<a v-for="tag in recentHashtags.slice(0, 5)" @click="addTag(tag)" :title="$t('click-to-tagging')">#{{ tag }}</a>
|
||||
</div>
|
||||
<div class="local-only" v-if="localOnly == true">{{ $t('local-only-message') }}</div>
|
||||
<input v-show="useCw" ref="cw" v-model="cw" :placeholder="$t('annotations')" v-autocomplete="'cw'">
|
||||
<input v-show="useCw" ref="cw" v-model="cw" :placeholder="$t('annotations')" v-autocomplete="{ model: 'cw' }">
|
||||
<div class="textarea">
|
||||
<textarea :class="{ with: (files.length != 0 || poll) }"
|
||||
ref="text" v-model="text" :disabled="posting"
|
||||
@keydown="onKeydown" @paste="onPaste" :placeholder="placeholder"
|
||||
v-autocomplete="'text'"
|
||||
v-autocomplete="{ model: 'text' }"
|
||||
></textarea>
|
||||
<button class="emoji" @click="emoji" ref="emoji">
|
||||
<fa :icon="['far', 'laugh']"/>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<template>
|
||||
<form class="search" @submit.prevent="onSubmit">
|
||||
<form class="wlvfdpkp" @submit.prevent="onSubmit">
|
||||
<i><fa icon="search"/></i>
|
||||
<input v-model="q" type="search" :placeholder="$t('placeholder')"/>
|
||||
<input v-model="q" type="search" :placeholder="$t('placeholder')" v-autocomplete="{ model: 'q' }"/>
|
||||
<div class="result"></div>
|
||||
</form>
|
||||
</template>
|
||||
|
@ -19,10 +19,13 @@ export default Vue.extend({
|
|||
},
|
||||
methods: {
|
||||
onSubmit() {
|
||||
if (this.q.startsWith('#')) {
|
||||
this.$router.push(`/tags/${encodeURIComponent(this.q.substr(1))}`);
|
||||
const q = this.q.trim();
|
||||
if (q.startsWith('@')) {
|
||||
this.$router.push(`/${q}`);
|
||||
} else if (q.startsWith('#')) {
|
||||
this.$router.push(`/tags/${encodeURIComponent(q.substr(1))}`);
|
||||
} else {
|
||||
this.$router.push(`/search?q=${encodeURIComponent(this.q)}`);
|
||||
this.$router.push(`/search?q=${encodeURIComponent(q)}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +33,7 @@ export default Vue.extend({
|
|||
</script>
|
||||
|
||||
<style lang="stylus" scoped>
|
||||
.search
|
||||
.wlvfdpkp
|
||||
@media (max-width 800px)
|
||||
display none !important
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
@paste="onPaste"
|
||||
:placeholder="placeholder"
|
||||
ref="text"
|
||||
v-autocomplete="'text'"
|
||||
v-autocomplete="{ model: 'text' }"
|
||||
></textarea>
|
||||
<button class="emoji" @click="emoji" ref="emoji">
|
||||
<fa :icon="['far', 'laugh']"/>
|
||||
|
|
|
@ -19,8 +19,8 @@
|
|||
</span>
|
||||
<a @click="addVisibleUser">+{{ $t('add-visible-user') }}</a>
|
||||
</div>
|
||||
<input v-show="useCw" ref="cw" v-model="cw" :placeholder="$t('annotations')" v-autocomplete="'cw'">
|
||||
<textarea v-model="text" ref="text" :disabled="posting" :placeholder="placeholder" v-autocomplete="'text'"></textarea>
|
||||
<input v-show="useCw" ref="cw" v-model="cw" :placeholder="$t('annotations')" v-autocomplete="{ model: 'cw' }">
|
||||
<textarea v-model="text" ref="text" :disabled="posting" :placeholder="placeholder" v-autocomplete="{ model: 'text' }"></textarea>
|
||||
<div class="attaches" v-show="files.length != 0">
|
||||
<x-draggable class="files" :list="files" :options="{ animation: 150 }">
|
||||
<div class="file" v-for="file in files" :key="file.id">
|
||||
|
|
|
@ -100,7 +100,15 @@ export default Vue.extend({
|
|||
input: true
|
||||
}).then(({ canceled, result: query }) => {
|
||||
if (canceled) return;
|
||||
this.$router.push(`/search?q=${encodeURIComponent(query)}`);
|
||||
|
||||
const q = query.trim();
|
||||
if (q.startsWith('@')) {
|
||||
this.$router.push(`/${q}`);
|
||||
} else if (q.startsWith('#')) {
|
||||
this.$router.push(`/tags/${encodeURIComponent(q.substr(1))}`);
|
||||
} else {
|
||||
this.$router.push(`/search?q=${encodeURIComponent(q)}`);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in a new issue