web/data/cubicweb.js
changeset 5949 2a273c896a38
parent 5727 29afb9e715bb
child 6388 34317f395619
--- a/web/data/cubicweb.js	Thu Jul 08 18:48:44 2010 +0200
+++ b/web/data/cubicweb.js	Thu Jul 08 18:59:42 2010 +0200
@@ -296,9 +296,38 @@
             result.push(lst[i]);
         }
         return result;
+    },
+
+    /**
+     * .. function:: domid(string)
+     *
+     * return a valid DOM id from a string (should also be usable in jQuery
+     * search expression...). This is the javascript implementation of
+     * :func:`cubicweb.uilib.domid`.
+     */
+    domid: function (string) {
+	var newstring = string.replace(".", "_").replace("-", "_");
+	while (newstring != string) {
+	    string = newstring;
+	    newstring = newstring.replace(".", "_").replace("-", "_");
+	}
+	return newstring; // XXX
+    },
+
+    /**
+     * .. function:: strFuncCall(fname, *args)
+     *
+     * return a string suitable to call the `fname` javascript function with the
+     * given arguments (which should be correctly typed).. This is providing
+     * javascript implementation equivalent to :func:`cubicweb.uilib.js`.
+     */
+    strFuncCall: function(fname /* ...*/) {
+	    return (fname + '(' +
+		    $.map(cw.utils.sliceList(arguments, 1), jQuery.toJSON).join(',')
+		    + ')'
+		    );
     }
 
-
 });
 
 String.prototype.startsWith = cw.utils.deprecatedFunction('[3.9] str.startsWith() is deprecated, use str.startswith() instead', function (prefix) {