X-Git-Url: http://git.onelab.eu/?p=myslice.git;a=blobdiff_plain;f=unfold%2Fstatic%2Fjs%2Fplugin_helper.js;h=7f81a3c327df4f29dbfab2ddbb3fcb0227ea68f2;hp=d15e7a7173c215b3bd253bc4cd997411ea50ab61;hb=f19bceaa080ab47bae751cd0597a9fb32d1b6b4f;hpb=c37b38da17ad1530ebb76e7fa5ddb1bc634c59a4 diff --git a/unfold/static/js/plugin_helper.js b/unfold/static/js/plugin_helper.js index d15e7a71..7f81a3c3 100644 --- a/unfold/static/js/plugin_helper.js +++ b/unfold/static/js/plugin_helper.js @@ -1,18 +1,19 @@ // // storing toggle's status in localStorage // NOTE that localStorage only stores strings, so true becomes "true" +// var plugin_helper = { debug:false, ////////// use local storage to remember open/closed toggles - store_status : function (domid,status) { + store_toggle_status : function (domid,status) { var key='toggle.'+domid; if (plugin_helper.debug) messages.debug("storing toggle status " + status + " for " + domid + " key=" + key); $.localStorage.setItem(key,status); }, // restore last status - retrieve_last_status : function (domid) { + retrieve_last_toggle_status : function (domid) { var key='toggle.'+domid; // don't do anything if nothing stored var retrieved=$.localStorage.getItem(key); @@ -27,20 +28,22 @@ var plugin_helper = { var hidebtn=$('#hide-'+domid); if (status=="true") { plugindiv.slideDown(); hidebtn.show(); showbtn.hide(); } else { plugindiv.slideUp(); hidebtn.hide(); showbtn.show(); } - plugin_helper.store_status(domid,status); + plugin_helper.store_toggle_status(domid,status); }, - set_from_saved_status : function (domid) { - var previous_status=plugin_helper.retrieve_last_status (domid); + set_from_saved_toggle_status : function (domid) { + var previous_status=plugin_helper.retrieve_last_toggle_status (domid); if (plugin_helper.debug) messages.debug("restoring initial status for domid " + domid + " -> " + previous_status); plugin_helper.set_toggle_status (domid,previous_status); }, + + // triggered upon $(document).ready init_all_plugins : function() { // plugins marked as persistent start with all 3 parts turned off // let us first make sure the right parts are turned on $('.persistent-toggle').each(function() { var domid=this.id.replace('complete-',''); - plugin_helper.set_from_saved_status(domid); + plugin_helper.set_from_saved_toggle_status(domid); }); // program the hide buttons so they do the right thing $('.plugin-hide').each(function() { @@ -57,7 +60,7 @@ var plugin_helper = { // arm tooltips $('.plugin-tooltip').each(function(){ $(this).tooltip({'selector':'','placement':'right'}); }); }, -} // global var plugin +} // global var plugin_helper /* upon document completion, we locate all the hide and show areas, * and configure their behaviour