X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fcomponents%2FMoveList.vue;h=4c351dd51cf54207fcd242d125a0bb85fac57bbc;hb=1ef65040168ab7d55ce921abc9d63644a937d689;hp=f41e7e2e0280d608808954b8fe0ed291082e4fe0;hpb=658c47bf5843fb0855659f22f7b1c38318c66ce5;p=vchess.git diff --git a/client/src/components/MoveList.vue b/client/src/components/MoveList.vue index f41e7e2e..4c351dd5 100644 --- a/client/src/components/MoveList.vue +++ b/client/src/components/MoveList.vue @@ -15,13 +15,35 @@ div value="50" @input="adjustBoard()" ) - div#boardSizeBtnContainer - button#boardSizeBtn(onClick="window.doClick('modalAdjust')") - | {{ st.tr["Set board size"] }} + #aboveMoves + // NOTE: variants pages already have a "Rules" link on top + span#rulesBtn( + v-if="!$route.path.match('/variants/')" + @click="$emit('showrules')" + ) + | {{ st.tr["Rules"] }} + button.tooltip( + onClick="window.doClick('modalAdjust')" + :aria-label="st.tr['Resize board']" + ) + img.inline(src="/images/icons/resize.svg") + button.tooltip( + v-if="canAnalyze" + @click="$emit('analyze')" + :aria-label="st.tr['Analyse']" + ) + img.inline(src="/images/icons/analyse.svg") + #downloadDiv(v-if="canDownload") + a#download(href="#") + button.tooltip( + @click="$emit('download')" + :aria-label="st.tr['Download'] + ' PGN'" + ) + img.inline(src="/images/icons/download.svg") #scoreInfo(v-if="score!='*'") - p {{ score }} - p {{ st.tr[message] }} - .moves-list(v-if="show != 'none'") + span.score {{ score }} + span.score-msg {{ st.tr[message] }} + .moves-list(v-if="!['none','highlight'].includes(show)") .tr(v-for="moveIdx in evenNumbers") .td {{ firstNum + moveIdx / 2 + 1 }} .td(v-if="moveIdx < moves.length-1 || show == 'all'" @@ -31,7 +53,7 @@ div | {{ notation(moves[moveIdx]) }} .td( v-if="moveIdx < moves.length-1" - :class="{'highlight-lm': cursor == moveIdx+1}" + :class="{'highlight-lm': highlightBlackmove(moveIdx+1)}" @click="() => gotoMove(moveIdx+1)" ) | {{ notation(moves[moveIdx+1]) }} @@ -43,16 +65,23 @@ import { getFullNotation } from "@/utils/notation"; import { processModalClick } from "@/utils/modalClick"; export default { name: "my-move-list", - props: ["moves", "show", "cursor", "score", "message", "firstNum"], + props: [ + "moves", "show", "canAnalyze", "canDownload", + "cursor", "score", "message", "firstNum"], data: function() { return { st: store.state }; }, mounted: function() { - document.getElementById("adjuster").addEventListener( - "click", - processModalClick); + document.getElementById("adjuster") + .addEventListener("click", processModalClick); + if ("ontouchstart" in window) { + // Disable tooltips on smartphones: + document.querySelectorAll("#aboveMoves .tooltip").forEach(elt => { + elt.classList.remove("tooltip"); + }); + } // Take full width on small screens: let boardSize = parseInt(localStorage.getItem("boardSize")); if (!boardSize) { @@ -72,10 +101,8 @@ export default { window.addEventListener("resize", () => { if (!timeoutLaunched) { timeoutLaunched = true; - setTimeout(() => { - this.adjustBoard(); - timeoutLaunched = false; - }, 500); + this.adjustBoard(); + setTimeout(() => { timeoutLaunched = false; }, 500); } }); }, @@ -85,7 +112,12 @@ export default { // $nextTick to wait for table > tr to be rendered this.$nextTick(() => { let curMove = document.querySelector(".td.highlight-lm"); - if (curMove) { + if (!curMove && this.moves.length > 0) { + // Cursor is before game beginning, and some moves were made: + curMove = + document.querySelector(".moves-list > .tr:first-child > .td"); + } + if (!!curMove) { curMove.scrollIntoView({ behavior: "auto", block: "nearest" @@ -103,12 +135,21 @@ export default { notation: function(move) { return getFullNotation(move); }, + highlightBlackmove: function(moveIdx) { + return ( + this.cursor == moveIdx || + (this.show == "byrow" && this.cursor == moveIdx + 1) + ); + }, gotoMove: function(index) { this.$emit("goto-move", index); }, adjustBoard: function() { const boardContainer = document.getElementById("boardContainer"); if (!boardContainer) return; //no board on page + let arrows = document.getElementById("arrowCanvas"); + // TODO: arrows on board don't scale + if (!!arrows) this.$emit("reset-arrows"); const k = document.getElementById("boardSize").value; const movesWidth = window.innerWidth >= 768 ? 280 : 0; const minBoardWidth = 240; //TODO: these 240 and 280 are arbitrary... @@ -127,6 +168,7 @@ export default {