renaming plugin attributes - now uses - visible - togglable - toggled
authorThierry Parmentelat <thierry.parmentelat@inria.fr>
Fri, 21 Dec 2012 09:51:10 +0000 (10:51 +0100)
committerThierry Parmentelat <thierry.parmentelat@inria.fr>
Fri, 21 Dec 2012 09:51:10 +0000 (10:51 +0100)
engine/plugin.py
engine/static/css/plugin.css
engine/templates/plugin.html
engine/templates/plugin_setenv.js
engine/views.py

index ff5a598..fa01567 100644 (file)
@@ -33,9 +33,9 @@ class Plugin:
     # . title: is used visually for displaying the widget
     # . name:  a simple id suitable for forging css names
     #### optional
-    # . hidable: whether it can be turned on and off from the UI
+    # . togglable: whether it can be turned on and off from the UI
     #   like e.g. PleKitToggle
-    # . hidden_by_default: if hidable, what's the initial status
+    # . 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
     #### internal data
@@ -47,7 +47,7 @@ class Plugin:
     # which will result in 'foo' being accessible to the template engine
     # 
     def __init__ (self, title, name,
-                  visible=True, hidable=True, hidden_by_default=False, **settings):
+                  visible=True, togglable=True, toggled=True, **settings):
         # what is in this dictionary will get exposed to template and to javascript
         self._settings=settings
         self.title=title
@@ -57,9 +57,9 @@ class Plugin:
         self.classname=self._classname()
         self.add_to_settings ( [ 'uuid', 'classname' ] )
         self.visible=visible
-        self.hidable=hidable
-        self.hidden_by_default=hidden_by_default
-        self.add_to_settings( ['visible','hidable','hidden_by_default'] )
+        self.togglable=togglable
+        self.toggled=toggled
+        self.add_to_settings( ['visible','togglable','toggled'] )
         # we store as a dictionary the arguments passed to constructor
         # e.g. SimpleList (list=[1,2,3]) => _settings = { 'list':[1,2,3] }
         # our own settings are not made part of _settings but could be..
index b178a97..53ff87b 100644 (file)
@@ -1,4 +1,4 @@
-div.plugin-manage {
+div.plugin-toggle {
     padding:           10px;
     border-style:      dotted;
     border-width:      1px;
index ae4be73..7d5195e 100644 (file)
@@ -1,22 +1,22 @@
 {#<!--begin {{ classname }}{{ name }}{{ uuid }}-->#}
 {% if visible %}
-<div class='plugin-manage' id='{{ name }}'>
-{% if hidable %}
-  {% if hidden %}
+<div class='plugin-toggle' id='{{ name }}'>
+{% if togglable %}
+  {% if not toggled %}
 <p id='show-{{ uuid }}' class='plugin-show'><a href='#'><span>&raquo; Show {{ classname }} "{{ title }}"</span></a></p>
 <p id='hide-{{ uuid }}' class='plugin-hide' style='display:none;'><a href='#'><span>&laquo; Hide {{ classname }} "{{ title }}"</span></a></p>
   {% else %}
 <p id='show-{{ uuid }}' class='plugin-show' style='display:none;'><a href='#'><span>&raquo; Show {{ classname }} "{{ title }}"</span></a></p>
 <p id='hide-{{ uuid }}' class='plugin-hide'><a href='#'><span>&laquo; Hide {{ classname }} "{{ title }}"</span></a></p>
-  {% endif %}
-{% endif %}
-{% endif %}
+  {% endif %}{# toggled #}
+{% endif %}{# togglable #}
+{% endif %}{# visible #}
 
-<div class='plugin {{ classname }}' id='plugin-{{ uuid }}'>
+<div class='plugin {{ classname }}' id='plugin-{{ uuid }}' {% if not toggled %}style='display:none'{% endif %}>
 {{ plugin_content|safe }}
-</div><!--plugin {{ classname }}-->
+</div><!--plugin {{ classname }}{{ name }}{{ uuid }}-->
 
 {% if visible %}
 </div>
-{% endif %}
+{% endif %}{# visible #}
 {#<!--end {{ classname }}{{ name }}{{ uuid }}-->#}
index 605c89b..ae01f6d 100644 (file)
@@ -1,6 +1,6 @@
 {# from plugin.php Plugin.render() #}
 {# Plugin initialization (if the plugin has the right structure) #}
-if (typeof jQuery('#{{ uuid }}').{{ classname }} != 'undefined') {
-    jQuery('#{{ uuid }}').{{ classname }}({{ settings_json|safe }});
+if (typeof jQuery('#plugin-{{ uuid }}').{{ classname }} != 'undefined') {
+    jQuery('#plugin-{{ uuid }}').{{ classname }}({{ settings_json|safe }});
     {#jQuery('#{{ uuid }}').{{ classname }}('show');#}
 }; 
index 96dfa66..52e22d2 100644 (file)
@@ -22,25 +22,26 @@ def test_plugin_view (request):
     main_plugin = \
         VerticalLayout ( title='title for the vertical layout',name='vertical1',
         sons = [ SimpleList (title='SimpleList and dataTables',
-                                              name='simplelist1',
-                                              list=hard_wired_list, 
-                                              header='Hard wired', 
-                                              foo='the value for foo',
-                                              with_datatables=True),
-                                  Tabs (title='Sample Tabs',name='tabs1',
-                                        active='raw1',
-                                        sons = [ Raw (title='a raw plugin',name='raw1',
-                                                      hidable=False,
-                                                      html= 3*lorem_p),
-                                                 SliceList(title='a slice list',name='slicelist-main',
-                                                           hidable=False,
-                                                           list=hard_wired_slice_names),
-                                                 Raw (title='raw title',name='raw2',
-                                                      hidable=False,html=lorem) ]),
-                                  SimpleList (title='SimpleList with slice names', 
-                                              name='simplelist2',
-                                              list=hard_wired_slice_names,
-                                              ) ] )
+                             name='simplelist1',
+                             list=hard_wired_list, 
+                             header='Hard wired', 
+                             foo='the value for foo',
+                             with_datatables=True,
+                             toggled=False),
+                 Tabs (title='Sample Tabs',name='tabs1',
+                       active='raw1',
+                       sons = [ Raw (title='a raw plugin',name='raw1',
+                                     togglable=False,
+                                     html= 3*lorem_p),
+                                SliceList(title='a slice list',name='slicelist-main',
+                                          togglable=False,
+                                          list=hard_wired_slice_names),
+                                Raw (title='raw title',name='raw2',
+                                     togglable=False,html=lorem) ]),
+                 SimpleList (title='SimpleList with slice names', 
+                             name='simplelist2',
+                             list=hard_wired_slice_names,
+                             ) ] )
     # define 'content_main' to the template engine
     template_env [ 'content_main' ] = main_plugin.render(request)