[KSS-checkins] r46594 - kukit/kukit.js/trunk/kukit

gotcha at codespeak.net gotcha at codespeak.net
Sat Sep 15 00:27:23 CEST 2007


Author: gotcha
Date: Sat Sep 15 00:27:23 2007
New Revision: 46594

Modified:
   kukit/kukit.js/trunk/kukit/actionreg.js
Log:
closures

Modified: kukit/kukit.js/trunk/kukit/actionreg.js
==============================================================================
--- kukit/kukit.js/trunk/kukit/actionreg.js	(original)
+++ kukit/kukit.js/trunk/kukit/actionreg.js	Sat Sep 15 00:27:23 2007
@@ -17,56 +17,58 @@
 * 02111-1307, USA.
 */
 
-kukit.ar = {};
-
+kukit.ar = new function() {   /// MODULE START
+ 
 /*
 *  class ActionRegistry
 * 
 *  The local event actions need to be registered here.
 */
-kukit.ar.ActionRegistry = function () {
-    this.content = {};
-};
-
-kukit.ar.ActionRegistry.prototype.register = function(name, func) {
-;;; if (typeof(func) == 'undefined') {
-;;;     kukit.E = '[func] argument is mandatory when registering an action';
-;;;     kukit.E += ' [ActionRegistry.register].';
-;;;     throw new Error(kukit.E);
-;;; }
-    if (this.content[name]) {
-        // Do not allow redefinition
-;;;     kukit.logError('Error : action [' + name + '] already registered.');
-        return;
-        }
-    this.content[name] = func;
-};
-
-kukit.ar.ActionRegistry.prototype.exists = function(name) {
-    var entry = this.content[name];
-    return (typeof(entry) != 'undefined');
-};
-
-kukit.ar.ActionRegistry.prototype.get = function(name) {
-    var func = this.content[name];
-    if (! func) {
-        // not found
-;;;     kukit.E = 'Error : undefined local action [' + name + '].';
-        throw Error(kukit.E);
-        }
-    return func;
-};
+    var ActionRegistry = function () {
+        this.content = {};
+    };
+
+    ActionRegistry.prototype.register = function(name, func) {
+;;;     if (typeof(func) == 'undefined') {
+;;;         kukit.E = '[func] argument is mandatory when registering an action';
+;;;         kukit.E += ' [ActionRegistry.register].';
+;;;         throw new Error(kukit.E);
+;;;     }
+        if (this.content[name]) {
+            // Do not allow redefinition
+;;;         kukit.logError('Error : action [' + name + '] already registered.');
+            return;
+            }
+        this.content[name] = func;
+    };
+
+    ActionRegistry.prototype.exists = function(name) {
+        var entry = this.content[name];
+        return (typeof(entry) != 'undefined');
+    };
+
+    ActionRegistry.prototype.get = function(name) {
+        var func = this.content[name];
+        if (! func) {
+            // not found
+;;;         kukit.E = 'Error : undefined local action [' + name + '].';
+            throw Error(kukit.E);
+            }
+        return func;
+    };
 
-kukit.actionsGlobalRegistry = new kukit.ar.ActionRegistry();
+    kukit.actionsGlobalRegistry = new ActionRegistry();
 
 
 /* XXX deprecated methods, to be removed asap */
 
-kukit.ar.actionRegistry = {};
-kukit.ar.actionRegistry.register = function(name, func) {
-;;; var msg='Deprecated kukit.ar.actionRegistry.register, use ';
-;;; msg += 'kukit.actionsGlobalRegistry.register instead !';
-;;; kukit.logWarning(msg);
-    kukit.actionsGlobalRegistry.register(name, func);
-};
+    this.actionRegistry = {};
+    this.actionRegistry.register = function(name, func) {
+;;;     var msg='Deprecated kukit.ar.actionRegistry.register, use ';
+;;;     msg += 'kukit.actionsGlobalRegistry.register instead !';
+;;;     kukit.logWarning(msg);
+        kukit.actionsGlobalRegistry.register(name, func);
+    };
+
+}();                              /// MODULE END
 


More information about the Kukit-checkins mailing list