1 // xxx NOTE : pending move towards a more elaborate mode for 'toggled'
2 // for now it's just True or False and most of this code is not in action yet
3 // init_all_plugins does kick in though
8 ////////// use local storage to remember open/closed toggles
9 store_status : function (domid) {
10 var plugin=$('#'+domid);
12 if (debug) console.log('storing toggle status for '+domid);
13 $.localStorage.setItem(key,plugin.visible());
15 // restore last status
16 restore_last_status : function (domid) {
18 // don't do anything if nothing stored
19 var retrieved=$.localStorage.getItem(key,undefined);
20 if (retrieved===null) return;
21 if (debug) console.log ("Applying retrieved status " + retrieved + " to " + domid);
22 set_visible(domid,retrieved);
24 toggle : function (domid) {
25 var plugin=$('#'+domid);
27 var showbtn=$('#show-'+domid);
28 var hidebtn=$('#hide-'+domid);
29 if (plugin.visible()) {
36 plugin.store_status(domid);
38 // 'target' is retrieved from storage so essentially a string 'true' or 'false'
39 set_visible : function (domid, target) {
40 var plugin=$('#'+domid);
41 if (plugin.visible()!=target) {
42 if (debug) console.log('set_visible: toggling ' + domid);
43 plugin.toggle (domid);
46 // triggered upon $(document).ready
47 init_all_plugins: function() {
48 $('.plugin-hide').each(function() {
49 $(this).click(function () {
50 var plugin='#'+this.id.replace('hide-','');
51 var show='#'+this.id.replace('hide-','show-');
52 $(plugin).slideUp(); $(show).show(); $(this).hide();});
54 $('.plugin-show').each(function() {
55 $(this).click(function () {
56 var plugin='#'+this.id.replace('show-','');
57 var hide='#'+this.id.replace('show-','hide-');
58 $(plugin).slideDown(); $(hide).show(); $(this).hide();});
60 $('.plugin-tooltip').each(function(){ $(this).tooltip({'selector':'','placement':'right'}); });
64 /* upon document completion, we locate all the hide and show areas,
65 * and configure their behaviour
67 $(document).ready(plugin.init_all_plugins)