ad1444d9ed43f9d26ec10ab7558bf6199b400305
[emels.git] / emels / static / fnpdjango / annoy / annoy.js
1 (function($) {
2 $(function() {
3
4 $("#annoy").each(function(i, annoy) {
5
6     var edition = "annoyed" + new Date().getFullYear();
7
8     var have_localstorage;
9     try {
10         localStorage.setItem("test", "test");
11         localStorage.removeItem("test");
12         have_localstorage = true;
13     } catch(e) {
14         have_localstorage = false;
15     }
16
17     $("#annoy-on").click(function(e) {
18         e.preventDefault();
19         $(annoy).slideDown('fast');
20         $(this).hide();
21         if (have_localstorage) localStorage.removeItem(edition);
22     });
23
24     $("#annoy-off").click(function() {
25         $(annoy).slideUp('fast');
26         $("#annoy-on").show();
27         if (have_localstorage) localStorage[edition] = true;
28     });
29
30     if (have_localstorage) {
31         if (!localStorage[edition]) {
32             $("#annoy-on").hide();
33             $(annoy).show();
34         }
35     }
36     });
37
38
39 });
40 })(jQuery);