presist checklist states in localStorage

pull/339/head
Michael Q Larson 2015-04-18 01:29:10 -07:00
parent e39dfee5ef
commit 6106dfa31a
1 changed files with 6 additions and 8 deletions

View File

@ -24,12 +24,10 @@ $(document).ready(function() {
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');
}
var checklistElementId = $(this).attr('id');
if(!!localStorage[checklistElementId]) {
$(this).children('.step-text').addClass('italic');
$(this).children().children('input').trigger('click');
}
});
@ -49,13 +47,13 @@ $(document).ready(function() {
if ($(this).is(":checked")) {
$(this).parent().parent().children('.step-text').addClass('italic');
if (!localStorage || !localStorage[checkboxId]) {
localStorage[checkboxId] = "true";
localStorage[checkboxId] = true;
}
}
if (!$(this).is(":checked")) {
$(this).parent().parent().children('.step-text').removeClass('italic');
if (localStorage[checkboxId]) {
localStorage[checkboxId] = "false";
localStorage.removeItem(checkboxId);
}
}
});