From: Thierry Parmentelat <thierry.parmentelat@inria.fr>
Date: Wed, 13 Mar 2013 19:40:36 +0000 (+0100)
Subject: no spinner on querycode
X-Git-Tag: myslice-django-0.1-1~16
X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=d6f36d854cbc8533f75ca17ce7ec07f35d7a639f;p=unfold.git

no spinner on querycode
---

diff --git a/engine/plugin.py b/engine/plugin.py
index ad88024c..36d60dfc 100644
--- a/engine/plugin.py
+++ b/engine/plugin.py
@@ -118,10 +118,14 @@ class Plugin:
         return result
 
     # as a first approximation, only plugins that are associated with a query
-    # need to be prepared for js - others just get displayed and that's it
-    def is_asynchroneous (self):
+    # need to be prepared for js - meaning their json settings get exposed to js
+    # others just get displayed and that's it
+    def export_json_settings (self):
         return 'query' in self.__dict__
     
+    def start_with_spin (self):
+        return self.export_json_settings()
+
     # returns the html code for that plugin
     # in essence, wraps the results of self.render_content ()
     def render (self, request):
@@ -130,12 +134,13 @@ class Plugin:
         # shove this into plugin.html
         env = {}
         env ['plugin_content']= plugin_content
-        self.need_spin=self.is_asynchroneous()
+        # need_spin is used in plugin.html
+        self.need_spin=self.start_with_spin()
         env.update(self.__dict__)
         result = render_to_string ('plugin.html',env)
 
         # export this only for relevant plugins
-        if self.is_asynchroneous():
+        if self.export_json_settings():
             env ['settings_json' ] = self.settings_json()
             # compute plugin-specific initialization
             js_init = render_to_string ( 'plugin-setenv.js', env )
@@ -233,5 +238,13 @@ class Plugin:
     # also 'query_uuid' gets replaced with query.uuid
     def json_settings_list (self): return ['json_settings_list-must-be-redefined']
 
-    # might also define this one; see e.g. slicelist.py that piggybacks simplelist js code
-    # def plugin_classname (self):
+    # might also define these ones:
+    #
+    # see e.g. slicelist.py that piggybacks simplelist js code
+    # def plugin_classname (self)
+    #
+    # whether we export the json settings to js
+    # def export_json_settings (self)
+    #
+    # whether we show an initial spinner
+    # def start_with_spin (self)
diff --git a/plugins/querycode.py b/plugins/querycode.py
index e8b80bf4..cdc2929c 100644
--- a/plugins/querycode.py
+++ b/plugins/querycode.py
@@ -27,3 +27,4 @@ class QueryCode (Plugin):
 
     def json_settings_list (self): return ['plugin_uuid', 'query','query_uuid']
         
+    def start_with_spin (self): return False
diff --git a/plugins/static/js/querycode.js b/plugins/static/js/querycode.js
index b4165cb1..a8e1e890 100644
--- a/plugins/static/js/querycode.js
+++ b/plugins/static/js/querycode.js
@@ -17,7 +17,6 @@ function debug_object (msg, o) {
 }
 
 // xxx TODO
-// . the spinner is still turning after the first refresh - find a means to shut it down completely
 // . turn back on syntax highlighting
 
 (function($) {
@@ -79,8 +78,6 @@ function debug_object (msg, o) {
     }
  
     function do_update ($plugindiv) {
-	// just in case
-	$plugindiv.closest('.need-spin').spin(false);
 
 	var lang=$plugindiv.find(".querycode-lang").val();
 	var dom=$plugindiv.find(".querycode-viz");