# the js async methods (see manifold_async_success)
# offer the option to deliver the result to a specific DOM elt
# otherwise it goes through the pubsub using query's uuid
- def query_enqueue (self, query, domid=None):
+ def enqueue_query (self, query, domid=None):
self._queue.append ( (query,domid,) )
# return the javascript that triggers all the queries
def exec_queue_asynchroneously (self):
js = ""
- js += "var manifold_query_array = new Array();"
+ js += "var manifold_query_array = new Array();\n"
for (query,domid) in self._queue:
qjson=query.to_json()
- id="'%s'"%domid if domid else undefined
- js += "manifold_query_array.push({'query':'%(qjson)s', 'id':%(id)s});"%locals()
+ id="'%s'"%domid if domid else 'undefined'
+ js += "manifold_query_array.push({'query':%(qjson)s, 'id':%(id)s});\n"%locals()
js += "onFunctionAvailable('manifold_async_exec', function() {manifold_async_exec(manifold_query_array);}, this, true);"
self.reset_queue()
# run only once the document is ready
- js = "jQuery(function(){%(js)s})"%locals()
+ js = "$(document).ready(function(){%(js)s})"%locals()
self.add_js_chunks (js)
#################### requirements/prelude management
//
function manifold_async_exec(arr)
{
-
+ console.log('manifold_async_exec length='+ arr.length);
// start spinners
- //onObjectAvailable('Spinners', function(){ Spinners.create('.loading').play(); }, this, true);
- jQuery('.loading').spin();
+ // xxx todo - I don't have the spinner jquery plugin yet
+// jQuery('.loading').spin();
// We use js function closure to be able to pass the query (array) to the
// callback function used when data is received
- var manifold_async_success_wrapper = function(query, id) {
- return function(data, textStatus) {
- manifold_async_success(data, query, id);
- };
+ var manifold_async_success_closure = function(query, id) {
+ return function(data, textStatus) {manifold_async_success(data, query, id);}
};
// Loop through query array and issue XML/RPC queries
jQuery.each(arr, function(index, elt) {
- // we do rendering by default
- jQuery.post(api_url, {'query': elt.query.to_hash()}, manifold_async_success_wrapper(elt.query, elt.id));
+ console.log ('sending POST on ' + api_url + " iterating on " + elt);
+ jQuery.post(api_url, {'query': elt.query.to_hash()}, manifold_async_success_closure(elt.query, elt.id));
})
}
-function manifold_async_exec_render(arr)
-{
-
- // start spinners
- //onObjectAvailable('Spinners', function(){ Spinners.create('.loading').play(); }, this, true);
- jQuery('.loading').spin();
-
- // We use js function closure to be able to pass the query (array) to the
- // callback function used when data is received
- var manifold_async_success_wrapper = function(query, id) {
- return function(data, textStatus) {
- manifold_async_success(data, query, id);
- };
- };
-
- // Loop through query array and issue XML/RPC queries
- jQuery.each(arr, function(index, elt) {
- // we do rendering by default
- jQuery.post(api_render_url, {'query': elt.query.to_hash()}, manifold_async_success_wrapper(elt.query, elt.id));
- })
-}
-
-function manifold_async_render(data, query)
-{
- // We use js function closure to be able to pass the query (array) to the
- // callback function used when data is received
- var manifold_async_render_success_wrapper = function(query) {
- return function(data, textStatus) {
- manifold_async_render_success(data, query);
- };
- };
-
- jQuery.post(api_render_url, {'data': data, 'query': query.to_hash()}, manifold_async_render_success_wrapper(data, query));
-}
-
function manifold_async_error(str) {
var out = '<div class="error"><h2>Error</h2><dl id="system-message"><dt class="error">Notice</dt><dd class="error message"><ul><li>' + jQuery('<div />').text(str).html() + '</li></ul></dd></dl></div>';
jQuery('#manifold_message').html(out);
jQuery('.loading').spin();
}
+/* what the hell is this doing here ?
function apply_format(key, value, type, method) {
// type = type, key =
var link = {
return key;
}
}
+*/
function manifold_html_a(key, value, type) {
if (type == 'network_hrn') {
class SimpleList (Plugin) :
- # it would make sense to *not* define any constructor here and let Plugin kick in
- # however it feels nicer this way as we document the settings used in our own template
- # plus it's less confusing for any subclass if they can be sure which constructor to call
+ # only deal with our own stuff here and let Plugin handle the rest
def __init__ (self, list=[], with_datatables=False, **settings):
Plugin.__init__ (self, **settings)
self.list=list
reqs['js_files'].append ("datatables/js/dataTables.js")
reqs['js_files'].append ("js/with-datatables.js")
return reqs
-# for tests
-# 'js_chunks' : "/* a javascript chunk */",
-# 'css_chunks': "/* a css style */ ",
def json_settings_list (self): return ['plugin_uuid', 'query','query_uuid','key','value']