plugins: reworked the framework using inheritance + added active_filters
[myslice.git] / unfold / js / plugin_helper.js
similarity index 71%
rename from unfold/js/plugin.js
rename to unfold/js/plugin_helper.js
index 65d4d20..d15e7a7 100644 (file)
@@ -1,14 +1,14 @@
 //
 // storing toggle's status in localStorage
 // NOTE that localStorage only stores strings, so true becomes "true"
-var plugin = {
+var plugin_helper = {
 
     debug:false,
 
     ////////// use local storage to remember open/closed toggles
     store_status : function (domid,status) {
        var key='toggle.'+domid;
-       if (plugin.debug) messages.debug("storing toggle status " + status + " for " + domid + " key=" + key);
+       if (plugin_helper.debug) messages.debug("storing toggle status " + status + " for " + domid + " key=" + key);
        $.localStorage.setItem(key,status);
     },
     // restore last status
@@ -18,7 +18,7 @@ var plugin = {
        var retrieved=$.localStorage.getItem(key);
        // set default to true
        if (retrieved==null) retrieved="true";
-       if (plugin.debug) messages.debug ("retrieved toggle status for " + domid + " (key=" + key + ") -> " + retrieved);
+       if (plugin_helper.debug) messages.debug ("retrieved toggle status for " + domid + " (key=" + key + ") -> " + retrieved);
        return retrieved;
     },
     set_toggle_status : function (domid,status) {
@@ -27,12 +27,12 @@ var plugin = {
        var hidebtn=$('#hide-'+domid);
        if (status=="true")     { plugindiv.slideDown(); hidebtn.show(); showbtn.hide(); }
        else                    { plugindiv.slideUp();   hidebtn.hide(); showbtn.show(); }
-       plugin.store_status(domid,status);
+       plugin_helper.store_status(domid,status);
     },
     set_from_saved_status : function (domid) {
-       var previous_status=plugin.retrieve_last_status (domid);
-       if (plugin.debug) messages.debug("restoring initial status for domid " + domid + " -> " + previous_status);
-       plugin.set_toggle_status (domid,previous_status);
+       var previous_status=plugin_helper.retrieve_last_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() {
@@ -40,19 +40,19 @@ var plugin = {
        // let us first make sure the right parts are turned on 
        $('.persistent-toggle').each(function() {
            var domid=this.id.replace('complete-','');
-           plugin.set_from_saved_status(domid);
+           plugin_helper.set_from_saved_status(domid);
        });
        // program the hide buttons so they do the right thing
        $('.plugin-hide').each(function() {
            $(this).click(function () { 
                var domid=this.id.replace('hide-','');
-               plugin.set_toggle_status(domid,"false");
+               plugin_helper.set_toggle_status(domid,"false");
            })});
        // same for show buttons
        $('.plugin-show').each(function() {
            $(this).click(function () { 
                var domid=this.id.replace('show-','');
-               plugin.set_toggle_status(domid,"true");
+               plugin_helper.set_toggle_status(domid,"true");
            })});
        // arm tooltips
        $('.plugin-tooltip').each(function(){ $(this).tooltip({'selector':'','placement':'right'}); });
@@ -62,5 +62,5 @@ var plugin = {
 /* upon document completion, we locate all the hide and show areas, 
  * and configure their behaviour 
  */
-$(document).ready(plugin.init_all_plugins)
+$(document).ready(plugin_helper.init_all_plugins)