make name field auto-complete

This commit is contained in:
Xiaofeng An 2019-02-08 11:01:12 -05:00
parent 2d91c9d949
commit 128dcc637e
2 changed files with 21 additions and 2 deletions

View File

@ -1,6 +1,7 @@
<template> <template>
<div> <div>
<textarea <textarea
v-if="multiline"
ref="textarea" ref="textarea"
:value="text" :value="text"
@input="text = $event.target.value, $emit('input', $event.target.value), autoResize && resize($event)" @input="text = $event.target.value, $emit('input', $event.target.value), autoResize && resize($event)"
@ -17,6 +18,24 @@
@keydown.meta.enter="keydownMetaEnter && keydownMetaEnter()" @keydown.meta.enter="keydownMetaEnter && keydownMetaEnter()"
@keyup.ctrl.enter="keyupCtrlEnter && keyupCtrlEnter()"> @keyup.ctrl.enter="keyupCtrlEnter && keyupCtrlEnter()">
</textarea> </textarea>
<input
v-else
ref="textarea"
:value="text"
:id="id"
@input="text = $event.target.value, $emit('input', $event.target.value), autoResize && resize($event)"
@click="setCaret"
@keyup="setCaret" :placeholder="placeholder" rows="1" :class="classObj"
@keydown.down="cycleForward"
@keydown.up="cycleBackward"
@keydown.shift.tab="cycleBackward"
@keydown.tab="cycleForward"
@keydown.enter="replaceCandidate"
@drop="drop && drop()"
@dragover.prevent="dragoverPrevent && dragoverPrevent()"
@paste="paste && paste()"
@keydown.meta.enter="keydownMetaEnter && keydownMetaEnter()"
@keyup.ctrl.enter="keyupCtrlEnter && keyupCtrlEnter()"/>
<div style="position:relative;" v-if="candidates"> <div style="position:relative;" v-if="candidates">
<div class="autocomplete-panel"> <div class="autocomplete-panel">
<div v-for="candidate in candidates" @click="replace(candidate.utf || (candidate.screen_name + ' '))"> <div v-for="candidate in candidates" @click="replace(candidate.utf || (candidate.screen_name + ' '))">

View File

@ -9,9 +9,9 @@
<div class="setting-item" > <div class="setting-item" >
<h2>{{$t('settings.name_bio')}}</h2> <h2>{{$t('settings.name_bio')}}</h2>
<p>{{$t('settings.name')}}</p> <p>{{$t('settings.name')}}</p>
<input class='name-changer' id='username' v-model="newName"></input> <auto-complete-input :classObj="{ 'name-changer': true }" :id="'username'" v-model="newName"/>
<p>{{$t('settings.bio')}}</p> <p>{{$t('settings.bio')}}</p>
<auto-complete-input :classObj="{ bio: true }" v-model="newBio"/> <auto-complete-input :classObj="{ bio: true }" v-model="newBio" :multiline="true"/>
<p> <p>
<input type="checkbox" v-model="newLocked" id="account-locked"> <input type="checkbox" v-model="newLocked" id="account-locked">
<label for="account-locked">{{$t('settings.lock_account_description')}}</label> <label for="account-locked">{{$t('settings.lock_account_description')}}</label>