From: Thierry Parmentelat Date: Mon, 25 Mar 2013 08:18:36 +0000 (+0100) Subject: the move about plugin's 'toggled' becoming more elaborate and pas-aware : setting... X-Git-Tag: myslice-django-0.1-3~42 X-Git-Url: http://git.onelab.eu/?p=myslice.git;a=commitdiff_plain;h=81cad6f20ed7c2841fcc546caf455e6e54c3a5fd the move about plugin's 'toggled' becoming more elaborate and pas-aware : setting aside for now we only have True and False for now --- diff --git a/unfold/js/plugin.js b/unfold/js/plugin.js index 5aa90fac..599d0794 100644 --- a/unfold/js/plugin.js +++ b/unfold/js/plugin.js @@ -1,3 +1,6 @@ +// xxx NOTE : pending move towards a more elaborate mode for 'toggled' +// for now it's just True or False and most of this code is not in action yet +// init_all_plugins does kick in though var plugin = { debug:true, @@ -18,22 +21,6 @@ var plugin = { if (debug) console.log ("Applying retrieved status " + retrieved + " to " + domid); set_visible(domid,retrieved); }, - // triggered upon $(document).ready - init_all_plugins: function() { - $('.plugin-hide').each(function() { - $(this).click(function () { - var plugin='#'+this.id.replace('hide-',''); - var show='#'+this.id.replace('hide-','show-'); - $(plugin).slideUp(); $(show).show(); $(this).hide();}); - }); - $('.plugin-show').each(function() { - $(this).click(function () { - var plugin='#'+this.id.replace('show-',''); - var hide='#'+this.id.replace('show-','hide-'); - $(plugin).slideDown(); $(hide).show(); $(this).hide();}); - }); - $('.plugin-tooltip').each(function(){ $(this).tooltip({'selector':'','placement':'right'}); }); - }, toggle : function (domid) { var plugin=$('#'+domid); plugin.toggle(); @@ -56,6 +43,22 @@ var plugin = { plugin.toggle (domid); } }, + // triggered upon $(document).ready + init_all_plugins: function() { + $('.plugin-hide').each(function() { + $(this).click(function () { + var plugin='#'+this.id.replace('hide-',''); + var show='#'+this.id.replace('hide-','show-'); + $(plugin).slideUp(); $(show).show(); $(this).hide();}); + }); + $('.plugin-show').each(function() { + $(this).click(function () { + var plugin='#'+this.id.replace('show-',''); + var hide='#'+this.id.replace('show-','hide-'); + $(plugin).slideDown(); $(hide).show(); $(this).hide();}); + }); + $('.plugin-tooltip').each(function(){ $(this).tooltip({'selector':'','placement':'right'}); }); + }, } // global unfold /* upon document completion, we locate all the hide and show areas, diff --git a/unfold/plugin.py b/unfold/plugin.py index 278c362f..65195cd5 100644 --- a/unfold/plugin.py +++ b/unfold/plugin.py @@ -43,10 +43,19 @@ class Plugin: # . page: the context of the request being served # . title: is used visually for displaying the widget #### optional - # . togglable: whether it can be turned on and off (like PleKitToggle) - # . toggled: if togglable, what's the initial status # . visible: if not set the plugin does not show up at all # (not quite sure what this was for) + # . togglable: whether it can be turned on and off by clicking on the title (like PleKitToggle) + # . toggled: whether the plugin should startup open/shown or closed/hidden + #### xxx NOTE : pending move towards a more elaborate mode for 'toggled' + # . toggled: if togglable, what's the initial status; possible values are + # .. True : start up open/hidden + # .. False : start up closed/shown + # .. 'last' : start up as it was the last time that browser showed it (based on 'domid') + # .. None : if not passed to __init__ at all, then the DefaultTaggled() method is called + # .. : anything else, defaults to True + #### xxx NOTE : pending move towards a more elaborate mode for 'toggled' + # #### internal data # . domid: created internally, but can be set at creation time if needed # useful for hand-made css, or for selecting an active plugin in a composite