From 68e0811883d0790679f0539300a230677f7b9743 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Fri, 21 Dec 2012 10:51:10 +0100 Subject: [PATCH] renaming plugin attributes - now uses - visible - togglable - toggled --- engine/plugin.py | 12 +++++----- engine/static/css/plugin.css | 2 +- engine/templates/plugin.html | 18 +++++++------- engine/templates/plugin_setenv.js | 4 ++-- engine/views.py | 39 ++++++++++++++++--------------- 5 files changed, 38 insertions(+), 37 deletions(-) diff --git a/engine/plugin.py b/engine/plugin.py index ff5a5986..fa01567e 100644 --- a/engine/plugin.py +++ b/engine/plugin.py @@ -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.. diff --git a/engine/static/css/plugin.css b/engine/static/css/plugin.css index b178a975..53ff87bd 100644 --- a/engine/static/css/plugin.css +++ b/engine/static/css/plugin.css @@ -1,4 +1,4 @@ -div.plugin-manage { +div.plugin-toggle { padding: 10px; border-style: dotted; border-width: 1px; diff --git a/engine/templates/plugin.html b/engine/templates/plugin.html index ae4be739..7d5195e7 100644 --- a/engine/templates/plugin.html +++ b/engine/templates/plugin.html @@ -1,22 +1,22 @@ {##} {% if visible %} -
-{% if hidable %} - {% if hidden %} +
+{% if togglable %} + {% if not toggled %}

» Show {{ classname }} "{{ title }}"

{% else %}

« Hide {{ classname }} "{{ title }}"

- {% endif %} -{% endif %} -{% endif %} + {% endif %}{# toggled #} +{% endif %}{# togglable #} +{% endif %}{# visible #} -
+
{{ plugin_content|safe }} -
+
{% if visible %}
-{% endif %} +{% endif %}{# visible #} {##} diff --git a/engine/templates/plugin_setenv.js b/engine/templates/plugin_setenv.js index 605c89b1..ae01f6da 100644 --- a/engine/templates/plugin_setenv.js +++ b/engine/templates/plugin_setenv.js @@ -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');#} }; diff --git a/engine/views.py b/engine/views.py index 96dfa66a..52e22d23 100644 --- a/engine/views.py +++ b/engine/views.py @@ -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) -- 2.43.0