Permalink
Browse files

persist acronym expansion state with session cookie

  • Loading branch information...
1 parent b770f9b commit ab261f408b46c78912575c68a6a94786c382375a @yourcelf committed Nov 2, 2010
Showing with 13 additions and 0 deletions.
  1. +13 −0 media/js/script.js
View
@@ -568,5 +568,18 @@ function toggleAcronyms(expand, selector) {
$(".acronyms-expanded").hide();
}
});
+ // session cookie. Cleared at end of session.
+ document.cookie = "expandAcronyms=" + ($("#toggleAcronyms").is(":checked") ? 1 : 0) + "; path=/;";
}
+$(document).ready(function() {
+ var expand = document.cookie.match('(?:^|;) ?expandAcronyms=([^;]*)(?:;|$)');
+ if (expand && expand.length > 1 && expand[1] == '1' && !$("toggleAcronyms").is(':checked')) {
+ // set checked state, so toggleAcronyms works...
+ $("#toggleAcronyms").attr('checked', true);
+ // Display message and run toggleAcronyms (also toggles checked state)
+ $("#toggleAcronyms").trigger('click');
+ // switch checked state back to checked.
+ $("#toggleAcronyms").attr('checked', true);
+ }
+});

0 comments on commit ab261f4

Please sign in to comment.