getting closer with the persisted checklists

This commit is contained in:
Michael Q Larson
2015-04-17 23:51:57 -07:00
parent 11ece0fda1
commit e39dfee5ef
2 changed files with 19 additions and 2 deletions

View File

@ -23,6 +23,16 @@ $(document).ready(function() {
setCSRFToken($('meta[name="csrf-token"]').attr('content')); setCSRFToken($('meta[name="csrf-token"]').attr('content'));
$('.checklist-element').each(function() {
if (!!$(this).attr('id')) {
var checklistElementId = $('.checklist-element').attr('id');
if(localStorage[checklistElementId]) {
$(this).children('.step-text').addClass('italic');
$(this).children('input').trigger('click');
}
}
});
$('.start-challenge').on('click', function() { $('.start-challenge').on('click', function() {
$(this).parent().remove(); $(this).parent().remove();
$('.challenge-content') $('.challenge-content')
@ -35,11 +45,18 @@ $(document).ready(function() {
}); });
$('.challenge-list-checkbox').on('change', function() { $('.challenge-list-checkbox').on('change', function() {
var checkboxId = $(this).parent().parent().attr('id');
if ($(this).is(":checked")) { if ($(this).is(":checked")) {
$(this).parent().parent().children('.step-text').addClass('italic'); $(this).parent().parent().children('.step-text').addClass('italic');
if (!localStorage || !localStorage[checkboxId]) {
localStorage[checkboxId] = "true";
}
} }
if (!$(this).is(":checked")) { if (!$(this).is(":checked")) {
$(this).parent().parent().children('.step-text').removeClass('italic'); $(this).parent().parent().children('.step-text').removeClass('italic');
if (localStorage[checkboxId]) {
localStorage[checkboxId] = "false";
}
} }
}); });

View File

@ -6,9 +6,9 @@ block content
.well .well
h4 h4
ol ol
for step in details for step, index in details
.row .row
li li.checklist-element(id="#{dashedName + index}")
.col-xs-2 .col-xs-2
input(type='checkbox' class='challenge-list-checkbox') input(type='checkbox' class='challenge-list-checkbox')
.col-xs-10.step-text!= step .col-xs-10.step-text!= step