X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fviews%2FVariants.vue;h=e5d02856f5ade3bdcb2de8e47ecca8cabf5ba1c1;hb=ba65b8def2a0f3b187babaeed39fec0df55999f7;hp=31061158975f194901d34e8ab034a6b682d377a4;hpb=6808d7a16ec1e761c6a2dffec2281c96953e4d89;p=vchess.git diff --git a/client/src/views/Variants.vue b/client/src/views/Variants.vue index 31061158..e5d02856 100644 --- a/client/src/views/Variants.vue +++ b/client/src/views/Variants.vue @@ -2,10 +2,14 @@ main .row .col-sm-12.col-md-10.col-md-offset-1.col-lg-8.col-lg-offset-2 - input#prefixFilter(v-model="curPrefix" :placeholder="st.tr['Prefix?']") + input#prefixFilter( + v-model="curPrefix" + @input="setCurPrefix($event)" + :placeholder="st.tr['Prefix?']" + ) .variant.col-sm-12.col-md-5.col-lg-4( v-for="(v,idx) in filteredVariants" - :class="{'col-md-offset-1': idx%2==0, 'col-lg-offset-2': idx%2==0}" + :class="getVclasses(filteredVariants, idx)" ) router-link(:to="getLink(v.name)") h4.boxtitle.text-center {{ v.name }} @@ -22,6 +26,9 @@ export default { st: store.state }; }, + mounted: function() { + document.getElementById("prefixFilter").focus(); + }, computed: { filteredVariants: function() { const capitalizedPrefix = this.curPrefix.replace(/^\w/, c => @@ -44,18 +51,30 @@ export default { } }, methods: { + // oninput listener, required for smartphones: + setCurPrefix: function(e) { + this.curPrefix = e.target.value; + }, getLink: function(vname) { return "/variants/" + vname; - } + }, + getVclasses: function(varray, idx) { + const idxMod2 = idx % 2; + return { + 'col-md-offset-1': idxMod2 == 0, + 'col-lg-offset-2': idxMod2 == 0, + 'last-noneighb': idxMod2 == 0 && idx == varray.length - 1 + }; + }, } };