web/data/cubicweb.js
changeset 6448 8590d82e9b1b
parent 6388 34317f395619
child 7284 a474cb989546
--- a/web/data/cubicweb.js	Mon Oct 11 17:46:22 2010 +0200
+++ b/web/data/cubicweb.js	Mon Oct 11 19:12:59 2010 +0200
@@ -7,6 +7,13 @@
 
 jQuery.extend(cw, {
     cubes: new Namespace('cubes'),
+    /* provide a removeEventListener / detachEvent definition to
+     * to bypass a jQuery 1.4.2 bug when unbind() is called on a
+     * plain JS object and not a DOM node.
+     * see http://dev.jquery.com/ticket/6184 for more details
+     */
+    removeEventListener: function() {},
+    detachEvent: function() {},
 
     log: function () {
         var args = [];
@@ -301,6 +308,17 @@
     },
 
     /**
+     * .. function:: difference(lst1, lst2)
+     *
+     * returns a list containing all elements in `lst1` that are not
+     * in `lst2`.
+     */
+    difference: function(lst1, lst2) {
+        return jQuery.grep(lst1, function(elt, i) {
+            return jQuery.inArray(elt, lst2) == -1;
+        });
+    },
+    /**
      * .. function:: domid(string)
      *
      * return a valid DOM id from a string (should also be usable in jQuery
@@ -417,22 +435,17 @@
 }
 
 // XXX avoid crashes / backward compat
-CubicWeb = {
+CubicWeb = cw;
+
+jQuery.extend(cw, {
     require: cw.utils.deprecatedFunction(
         '[3.9] CubicWeb.require() is not used anymore',
         function(module) {}),
     provide: cw.utils.deprecatedFunction(
         '[3.9] CubicWeb.provide() is not used anymore',
         function(module) {})
-};
+});
 
 jQuery(document).ready(function() {
-    jQuery(CubicWeb).trigger('server-response', [false, document]);
-    jQuery(cw).trigger('server-response', [false, document]);
+    $(cw).trigger('server-response', [false, document]);
 });
-
-// XXX as of 2010-04-07, no known cube uses this
-jQuery(CubicWeb).bind('ajax-loaded', function() {
-    log('[3.7] "ajax-loaded" event is deprecated, use "server-response" instead');
-    jQuery(cw).trigger('server-response', [false, document]);
-});