X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fcomponents%2FMoveList.vue;h=d2ae3f3514e4081e0fe2a74ac5ac1057ec618161;hb=49dad26138d3dee0cacbb94ad8d3d3eff12c477a;hp=43570984a2c2495841e3919f1d702270ef22df01;hpb=c51c301fdff91790e80de7f7431a596732780fb5;p=vchess.git diff --git a/client/src/components/MoveList.vue b/client/src/components/MoveList.vue index 43570984..d2ae3f35 100644 --- a/client/src/components/MoveList.vue +++ b/client/src/components/MoveList.vue @@ -27,6 +27,12 @@ div :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( @@ -34,12 +40,6 @@ div :aria-label="st.tr['Download'] + ' PGN'" ) img.inline(src="/images/icons/download.svg") - button.tooltip( - v-if="canAnalyze" - @click="$emit('analyze')" - :aria-label="st.tr['Analyse']" - ) - img.inline(src="/images/icons/analyse.svg") #scoreInfo(v-if="score!='*'") span.score {{ score }} span.score-msg {{ st.tr[message] }} @@ -53,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]) }} @@ -74,9 +74,14 @@ export default { }; }, 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) { @@ -108,13 +113,14 @@ export default { if (window.innerWidth <= 767) return; //scrolling would hide chessboard // $nextTick to wait for table > tr to be rendered this.$nextTick(() => { - let curLine = document.querySelector(".td.highlight-lm"); - if (!!curLine) curLine = curLine.parentNode; - if (!curLine && this.moves.length > 0) + let curMove = document.querySelector(".td.highlight-lm"); + if (!curMove && this.moves.length > 0) { // Cursor is before game beginning, and some moves were made: - curLine = document.querySelector(".moves-list .tr:first-child") - if (!!curLine) { - curLine.scrollIntoView({ + curMove = + document.querySelector(".moves-list > .tr:first-child > .td"); + } + if (!!curMove) { + curMove.scrollIntoView({ behavior: "auto", block: "nearest" }); @@ -131,12 +137,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... @@ -155,6 +170,7 @@ export default {