5 ////////// use local storage to remember open/closed toggles
6 store_status : function (domid) {
7 var plugin=$('#'+domid);
9 if (debug) console.log('storing toggle status for '+domid);
10 $.localStorage.setItem(key,plugin.visible());
12 // restore last status
13 restore_last_status : function (domid) {
15 // don't do anything if nothing stored
16 var retrieved=$.localStorage.getItem(key,undefined);
17 if (retrieved===null) return;
18 if (debug) console.log ("Applying retrieved status " + retrieved + " to " + domid);
19 set_visible(domid,retrieved);
21 // triggered upon $(document).ready
22 init_all_plugins: function() {
23 $('.plugin-hide').each(function() {
24 $(this).click(function () {
25 var plugin='#'+this.id.replace('hide-','');
26 var show='#'+this.id.replace('hide-','show-');
27 $(plugin).slideUp(); $(show).show(); $(this).hide();});
29 $('.plugin-show').each(function() {
30 $(this).click(function () {
31 var plugin='#'+this.id.replace('show-','');
32 var hide='#'+this.id.replace('show-','hide-');
33 $(plugin).slideDown(); $(hide).show(); $(this).hide();});
35 $('.plugin-tooltip').each(function(){ $(this).tooltip({'selector':'','placement':'right'}); });
37 toggle : function (domid) {
38 var plugin=$('#'+domid);
40 var showbtn=$('#show-'+domid);
41 var hidebtn=$('#hide-'+domid);
42 if (plugin.visible()) {
49 plugin.store_status(domid);
51 // 'target' is retrieved from storage so essentially a string 'true' or 'false'
52 set_visible : function (domid, target) {
53 var plugin=$('#'+domid);
54 if (plugin.visible()!=target) {
55 if (debug) console.log('set_visible: toggling ' + domid);
56 plugin.toggle (domid);
61 /* upon document completion, we locate all the hide and show areas,
62 * and configure their behaviour
64 $(document).ready(plugin.init_all_plugins)