| 1 |
// Store editor pop-up help state in localStorage |
| 2 |
// so it does not re-pop-up itself between page loads. |
| 3 |
// Do not even to pretend to support IE gracefully. |
| 4 |
(function($) { |
| 5 |
|
| 6 |
$(document).ready(function() { |
| 7 |
var box = $("#editor-trap"); |
| 8 |
var klass = "toggled"; |
| 9 |
var storageKey = "toggled"; |
| 10 |
|
| 11 |
function toggle() { |
| 12 |
box.toggleClass(klass); |
| 13 |
// Store the toggle status in local storage as "has value string" or null |
| 14 |
window.localStorage.setItem(storageKey, box.hasClass(klass) ? "toggled" : "not-toggled"); |
| 15 |
} |
| 16 |
|
| 17 |
box.click(toggle); |
| 18 |
|
| 19 |
// Check the persistent state of the editor pop-up |
| 20 |
// Note that localStorage does not necessarily support boolean values (ugh!) |
| 21 |
// http://stackoverflow.com/questions/3263161/cannot-set-boolean-values-in-localstorage |
| 22 |
var v = window.localStorage.getItem(storageKey); |
| 23 |
if(v == "toggled" || !v) { |
| 24 |
box.addClass(klass); |
| 25 |
} |
| 26 |
|
| 27 |
}); |
| 28 |
|
| 29 |
})(jQuery); |
| 30 |
|