fix lists when receiving emtpy or error result - add myslice_warning and myslice_erro...
authorThierry Parmentelat <thierry.parmentelat@inria.fr>
Fri, 15 Mar 2013 09:56:33 +0000 (10:56 +0100)
committerThierry Parmentelat <thierry.parmentelat@inria.fr>
Fri, 15 Mar 2013 09:56:33 +0000 (10:56 +0100)
plugins/lists/simplelist.js
plugins/lists/simplelist.py
views/css/myslice.css
views/js/myslice.js [new file with mode: 0644]

index 6ea2a77..20f2a84 100644 (file)
@@ -10,7 +10,7 @@
 (function($){
 
     var debug=false;
-    //debug=true
+    debug=true
 
     $.fn.SimpleList = function( method ) {
         /* Method calling logic */
        $plugindiv.closest('.need-spin').spin(false);
 
         if (rows.length == 0) {
-           if (use_datatables) datatables_set_message ("No result");
-           else                regular_set_message ("No result");
+           if (use_datatables) datatables_set_message ($table, $tbody, myslice_warning("No result"));
+           else                regular_set_message ($table, $tbody, myslice_warning("No result"));
             return;
         }
         if (typeof rows[0].error != 'undefined') {
            var error="ERROR: " + rows[0].error;
-           if (use_datatables) datatables_set_message (error);
-           else                regular_set_message (error);
+           if (use_datatables) datatables_set_message ($table, $tbody, myslice_error(error));
+           else                regular_set_message ($table, $tbody, myslice_error(error));
             return;
         }
         var options = $plugindiv.data().SimpleList;
index 50cd573..405b2e7 100644 (file)
@@ -23,6 +23,7 @@ class SimpleList (Plugin) :
         reqs = { 'js_files' : [ "js/simplelist.js", "js/plugin.js", "js/query.js", "js/onavail.js",
                                 "js/manifold-pubsub.js", "js/manifold-async.js", 
                                 "js/spin.presets.js", "js/spin.min.js", "js/jquery.spin.js", 
+                                "js/myslice.js",
                                 ] ,
                  'css_files': [ "css/simplelist.css" ],
                  }
index a6167d2..9ae36c6 100644 (file)
@@ -4,3 +4,5 @@
     padding: 10;
     background-color: #fff2ff;
 }
+span.myslice-warning { background-color: orange; }
+span.myslice-error { background-color: red; }
diff --git a/views/js/myslice.js b/views/js/myslice.js
new file mode 100644 (file)
index 0000000..644a3d0
--- /dev/null
@@ -0,0 +1,2 @@
+function myslice_warning(text){ return "<span class='myslice-warning'>"+text+"</span>"; }
+function myslice_error(text){ return "<span class='myslice-error'>"+text+"</span>"; }