Commits

Luke Plant committed d61d676

Added 'Show' and 'Hide' buttons for verses

Comments (0)

Files changed (3)

lukeplant_me_uk/bibleverses/templates/scheme.html

 
 {% for item in scheme.items %}
 <li class="verse" id="id_verseli_{{ item.verse.verseid }}">
-  <div class="versetopline"><a class="biblelink" href="{{ item.verse.verse|esvlink }}">{{ item.verse.verse }}</a><span class="verseadmin" id="id_verseadmin_{{ item.verse.verseid }}">Done: <input class="versecb" type="checkbox" id="id_versecb_{{ item.verse.verseid }}" /></span></div>
+  <div class="versetopline">
+    <a class="biblelink" href="{{ item.verse.verse|esvlink }}">{{ item.verse.verse }}</a>
+    <span class="versebtns">
+    <span id="id_show_{{ item.verse.verseid }}" class="showbtn hidden">Show</span>
+    <span id="id_hide_{{ item.verse.verseid }}" class="hidebtn">Hide</span>
+    &nbsp;<span class="verseadmin" id="id_verseadmin_{{  item.verse.verseid }}">
+     Done: <input class="versecb" type="checkbox" id="id_versecb_{{ item.verse.verseid }}" /></span>
+    </span>
+  </div>
   <div class="versebottom">
     {% if item.entries %}
     <ul>

lukeplant_me_uk/bibleverses/web/css/style.css

     background-color: #d0d0d0;
 }
 
-.memorised .versebottom {
-    display: none;    
-}
 
 a.biblelink {
     display: block;
     clear: both;
 }
 
+.versebtns {
+    float: right;
+}
+
 .verseadmin {
-    float: right;
     display: none;
 }
 
     margin-bottom: 1em;
 }
 
-li.verse.memorised {
+li.memorised,
+li.manuallyhidden {
     margin-bottom: 0em;
 }
 
+li.memorised .versebottom {
+    display: none;    
+}
+
+li.manuallyhidden .versebottom {
+    display: none;    
+}
+
+li.memorised.manuallyshown .versebottom {
+    display: block;
+}
+
 .sectionlink {
     color: #c8c8c8;
 }
+
+.showbtn, .hidebtn {
+    text-decoration: underline;
+    width: auto;
+    color: black;
+    cursor: pointer;
+}

lukeplant_me_uk/bibleverses/web/js/bibleverses.js

     }
 }
 
+
+
+function showBtnClicked(ev) {
+    var refid = ev.src().id.replace("id_show_","");
+    showVerseDiv(refid);
+    manuallyShow($("id_verseli_" + refid));
+}
+
+function manuallyShow(item) {
+    removeElementClass(item, "manuallyhidden");
+    addElementClass(item, "manuallyshown");
+}
+
+function showVerseDiv(refid) {
+    var showBtn = $("id_show_" + refid);
+    var hideBtn = $("id_hide_" + refid);
+    showBtn.style.display = 'none';
+    hideBtn.style.display = 'inline';
+}
+
+function hideBtnClicked(ev) {
+    var refid = ev.src().id.replace("id_hide_","");
+    hideVerseDiv(refid);
+    manuallyHide($("id_verseli_" + refid));
+}
+
+function manuallyHide(item) {
+    addElementClass(item, "manuallyhidden");
+    removeElementClass(item, "manuallyshown");
+}
+
+function hideVerseDiv(refid) {
+    var showBtn = $("id_show_" + refid);
+    var hideBtn = $("id_hide_" + refid);
+    hideBtn.style.display = 'none';
+    showBtn.style.display = 'inline';
+}
+
 function connectCheckBoxes() {
-    var vadmins = getElementsByTagAndClassName("span", "verseadmin");
-    for (var i = 0; i < vadmins.length; i++) {
-	cb = getFirstElementByTagAndClassName("input", "versecb", vadmins[i]);
+    var vbtns = getElementsByTagAndClassName("span", "versebtns");
+    for (var i = 0; i < vbtns.length; i++) {
+	cb = getFirstElementByTagAndClassName("input", "versecb", vbtns[i]);
 	connect(cb, 'onclick', toggleVerseCheckBox);
+	show = getFirstElementByTagAndClassName("span", "showbtn", vbtns[i]);
+	connect(show, 'onclick', showBtnClicked);
+	hide = getFirstElementByTagAndClassName("span", "hidebtn", vbtns[i]);
+	connect(hide, 'onclick', hideBtnClicked);
     }
 }
 
 }
 
 function showCheckBoxes() {
-    setCheckBoxDisplay('block');
+    setCheckBoxDisplay('inline');
 }
 
 function hideCheckBoxes() {
     var refid = verse.replace(/ |,|:|-/g, "");
     var elem = $('id_verseli_' + refid);
     if (elem) {
-	addElementClass(elem, "memorised");
+	addElementClass(elem, "memorised");	
 	$('id_versecb_' + refid).checked = true;
+	hideVerseDiv(refid);
+	removeElementClass($('id_verseli_' + refid), "manuallyshown");
     }
 }
 
 	var hidden_div = getFirstElementByTagAndClassName("div", "versebottom", elem);
 	removeElementClass(elem, "memorised");
 	$('id_versecb_' + refid).checked = false;
+	showVerseDiv(refid);
+	removeElementClass($('id_verseli_' + refid), "manuallyhidden");
     }
 }