feat(inputs): add better autofocus (#26)

fix issue #25
pull/739/head
Hugo Massing 2018-08-06 13:20:20 +02:00 committed by Henrique Dias
parent 208f21728f
commit 157b2da133
9 changed files with 18 additions and 12 deletions

View File

@ -7,11 +7,11 @@
<div class="card-content"> <div class="card-content">
<p>{{ $t('prompts.downloadMessage') }}</p> <p>{{ $t('prompts.downloadMessage') }}</p>
<button class="block cancel" @click="download('zip')" autofocus>zip</button> <button class="block cancel" @click="download('zip')" v-focus>zip</button>
<button class="block cancel" @click="download('tar')" autofocus>tar</button> <button class="block cancel" @click="download('tar')" v-focus>tar</button>
<button class="block cancel" @click="download('targz')" autofocus>tar.gz</button> <button class="block cancel" @click="download('targz')" v-focus>tar.gz</button>
<button class="block cancel" @click="download('tarbz2')" autofocus>tar.bz2</button> <button class="block cancel" @click="download('tarbz2')" v-focus>tar.bz2</button>
<button class="block cancel" @click="download('tarxz')" autofocus>tar.xz</button> <button class="block cancel" @click="download('tarxz')" v-focus>tar.xz</button>
</div> </div>
</div> </div>
</template> </template>

View File

@ -6,7 +6,7 @@
<div class="card-content"> <div class="card-content">
<p>{{ $t('prompts.newArchetype') }}</p> <p>{{ $t('prompts.newArchetype') }}</p>
<input autofocus type="text" @keyup.enter="submit" v-model.trim="name"> <input v-focus type="text" @keyup.enter="submit" v-model.trim="name">
<input type="text" @keyup.enter="submit" v-model.trim="archetype"> <input type="text" @keyup.enter="submit" v-model.trim="archetype">
</div> </div>

View File

@ -6,7 +6,7 @@
<div class="card-content"> <div class="card-content">
<p>{{ $t('prompts.newDirMessage') }}</p> <p>{{ $t('prompts.newDirMessage') }}</p>
<input autofocus type="text" @keyup.enter="submit" v-model.trim="name"> <input type="text" @keyup.enter="submit" v-model.trim="name" v-focus >
</div> </div>
<div class="card-action"> <div class="card-action">

View File

@ -6,7 +6,7 @@
<div class="card-content"> <div class="card-content">
<p>{{ $t('prompts.newFileMessage') }}</p> <p>{{ $t('prompts.newFileMessage') }}</p>
<input autofocus type="text" @keyup.enter="submit" v-model.trim="name"> <input v-focus type="text" @keyup.enter="submit" v-model.trim="name">
</div> </div>
<div class="card-action"> <div class="card-action">

View File

@ -6,7 +6,7 @@
<div class="card-content"> <div class="card-content">
<p>{{ $t('prompts.renameMessage') }} <code>{{ oldName() }}</code>:</p> <p>{{ $t('prompts.renameMessage') }} <code>{{ oldName() }}</code>:</p>
<input autofocus type="text" @keyup.enter="submit" v-model.trim="name"> <input v-focus type="text" @keyup.enter="submit" v-model.trim="name">
</div> </div>
<div class="card-action"> <div class="card-action">

View File

@ -6,7 +6,7 @@
<div class="card-content"> <div class="card-content">
<p>{{ $t('prompts.scheduleMessage') }}</p> <p>{{ $t('prompts.scheduleMessage') }}</p>
<input autofocus type="datetime-local" v-model="date"> <input v-focus type="datetime-local" v-model="date">
</div> </div>
<div class="card-action"> <div class="card-action">

View File

@ -28,7 +28,7 @@
</li> </li>
<li> <li>
<input autofocus <input v-focus
type="number" type="number"
max="2147483647" max="2147483647"
min="0" min="0"

View File

@ -43,6 +43,12 @@ Vue.prototype.$showError = function (error) {
n.show() n.show()
} }
Vue.directive('focus', {
inserted: function (el) {
el.focus()
}
})
/* eslint-disable no-new */ /* eslint-disable no-new */
new Vue({ new Vue({
el: '#app', el: '#app',

View File

@ -78,7 +78,7 @@
<div class="card-action"> <div class="card-action">
<button class="cancel flat" <button class="cancel flat"
@click="closeHovers" @click="closeHovers"
autofocus v-focus
:aria-label="$t('buttons.cancel')" :aria-label="$t('buttons.cancel')"
:title="$t('buttons.cancel')"> :title="$t('buttons.cancel')">
{{ $t('buttons.cancel') }} {{ $t('buttons.cancel') }}