[javascript] add a name property to namespaces, mainly for convenience in helpers such as movedToNamespace
authorAdrien Di Mascio <Adrien.DiMascio@logilab.fr>
Wed, 09 Jun 2010 16:16:54 +0200
changeset 5705 30b94973bc67
parent 5700 2b2d8c2310aa
child 5707 3586d36d2a45
[javascript] add a name property to namespaces, mainly for convenience in helpers such as movedToNamespace
web/data/cubicweb.js
--- a/web/data/cubicweb.js	Wed Jun 09 13:42:17 2010 +0200
+++ b/web/data/cubicweb.js	Wed Jun 09 16:16:54 2010 +0200
@@ -1,5 +1,9 @@
 
-cw = {};
+function Namespace(name) {
+   this.__name__ = name;
+}
+
+cw = new Namespace('cw');
 
 jQuery.extend(cw, {
     log: function () {
@@ -66,7 +70,8 @@
 });
 
 
-cw.utils = {
+cw.utils = new Namespace('cw.utils');
+jQuery.extend(cw.utils, {
 
     deprecatedFunction: function (msg, newfunc) {
         return function () {
@@ -78,7 +83,8 @@
     movedToNamespace: function (funcnames, namespace) {
         for (var i = 0; i < funcnames.length; i++) {
             var funcname = funcnames[i];
-            var msg = '[3.9] ' + funcname + ' is deprecated, use cw.' + funcname + ' instead';
+            var msg = ('[3.9] ' + funcname + ' is deprecated, use ' +
+		       namespace.__name__ + '.' + funcname + ' instead');
             window[funcname] = cw.utils.deprecatedFunction(msg, namespace[funcname]);
         }
     },
@@ -284,7 +290,7 @@
     }
 
 
-};
+});
 
 String.prototype.startsWith = cw.utils.deprecatedFunction('[3.9] str.startsWith() is deprecated, use str.startswith() instead', function (prefix) {
     return this.startswith(prefix);