From cb9041c7ca2e7559aca3d19b9a15788908143fad Mon Sep 17 00:00:00 2001 From: Robbie Antenesse Date: Wed, 24 Feb 2016 13:07:32 -0700 Subject: [PATCH] Re-lock word form if dictionary is completed. Broke out Lock and Unlock word form functions for use elsewhere. --- js/ui.js | 53 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 37 insertions(+), 16 deletions(-) diff --git a/js/ui.js b/js/ui.js index 129764c..0a0ae8a 100644 --- a/js/ui.js +++ b/js/ui.js @@ -209,25 +209,40 @@ function ToggleWordFormLock() { var wordForm = document.getElementById("wordEntryForm"); if (wordFormIsLocked()) { //If it is already locked, change it to Unlocked and get everything working as it needs to. - var wordFormWidth = wordForm.offsetWidth - 20; - var leftColumnWidth = leftColumn.offsetWidth; - var leftColumnHeight = leftColumn.offsetHeight; - - lockButton.innerHTML = "🔓"; - - wordForm.style.position = "fixed"; - wordForm.style.top = document.getElementsByTagName("header")[0].offsetHeight.toString() + "px"; - wordForm.style.width = wordFormWidth.toString() + "px"; - - leftColumn.style.width = leftColumnWidth.toString() + "px"; - leftColumn.style.height = leftColumnHeight.toString() + "px"; + UnlockWordForm(); } else { - lockButton.innerHTML = "🔒"; - leftColumn.removeAttribute('style'); - wordForm.removeAttribute('style'); + LockWordForm(); } } +function UnlockWordForm() { + var lockButton = document.getElementById("formLockButton"); + var leftColumn = document.getElementById("leftColumn"); + var wordForm = document.getElementById("wordEntryForm"); + var wordFormWidth = wordForm.offsetWidth - 20; + var leftColumnWidth = leftColumn.offsetWidth; + var leftColumnHeight = leftColumn.offsetHeight; + + lockButton.innerHTML = "🔓"; // Change to the "Unlocked lock" icon. + + wordForm.style.position = "fixed"; + wordForm.style.top = document.getElementsByTagName("header")[0].offsetHeight.toString() + "px"; + wordForm.style.width = wordFormWidth.toString() + "px"; + + leftColumn.style.width = leftColumnWidth.toString() + "px"; + leftColumn.style.height = leftColumnHeight.toString() + "px"; +} + +function LockWordForm() { + var lockButton = document.getElementById("formLockButton"); + var leftColumn = document.getElementById("leftColumn"); + var wordForm = document.getElementById("wordEntryForm"); + + lockButton.innerHTML = "🔒"; // Change to the "locked" icon. + leftColumn.removeAttribute('style'); + wordForm.removeAttribute('style'); +} + function CloseUpdateConflictArea(displayId) { displayId = (typeof displayId !== 'undefined' && displayId != null) ? displayId : false; if (displayId != false) { @@ -422,7 +437,13 @@ function ShowFilterWordCount(numberOfWords) { function HideSettings() { document.getElementById("settingsScreen").style.display = "none"; - document.getElementById("wordEntryForm").style.display = (currentDictionary.settings.isComplete) ? "none" : "block"; + if (currentDictionary.settings.isComplete) { + LockWordForm(); + document.getElementById("wordEntryForm").style.display = "none"; + } else { + document.getElementById("wordEntryForm").style.display = "block"; + } + } function NewWordNotification(word) {