Author: gotcha
Date: Mon Dec 24 17:26:43 2007
New Revision: 50064
Modified:
kukit/kukit.js/branch/finish-closures/kukit/TODO.txt
kukit/kukit.js/branch/finish-closures/kukit/forms.js
kukit/kukit.js/branch/finish-closures/kukit/plugin.js
Log:
unindent and initialize
Modified: kukit/kukit.js/branch/finish-closures/kukit/TODO.txt
==============================================================================
--- kukit/kukit.js/branch/finish-closures/kukit/TODO.txt (original)
+++ kukit/kukit.js/branch/finish-closures/kukit/TODO.txt Mon Dec 24
17:26:43 2007
@@ -1,7 +1,6 @@
files where indentation has to be undone and initialize needs to be done
eventreg.js
-forms.js
kssparser.js
providerreg.js
selectorreg.js
Modified: kukit/kukit.js/branch/finish-closures/kukit/forms.js
==============================================================================
--- kukit/kukit.js/branch/finish-closures/kukit/forms.js (original)
+++ kukit/kukit.js/branch/finish-closures/kukit/forms.js Mon Dec 24
17:26:43 2007
@@ -35,71 +35,78 @@
/*
* class _FormQueryElem
*/
-var _FormQueryElem = function(name, value) {
+var _FormQueryElem = function() {
+
+this.initialize = function(name, value) {
this.name = name;
this.value = value;
+};
- this.encode = function() {
- return this.name+ "=" + encodeURIComponent(this.value);
- };
-
+this.encode = function() {
+ return this.name+ "=" + encodeURIComponent(this.value);
+};
+this.initialize.apply(this, arguments);
};
/*
* class FormQuery
*/
fo.FormQuery = function() {
+
+this.initialize = function() {
this.l = [];
+};
- this.appendElem = function(name, value) {
- if (value == null) {
- // do not marshall nulls
-;;; var msg = "Parameter '" + name + "' is null,";
-;;; msg += " it is not marshalled.";
-;;; kukit.logDebug(msg);
- }
- else if (typeof(value) == 'string') {
- var elem = new _FormQueryElem(name, value);
+this.appendElem = function(name, value) {
+ if (value == null) {
+ // do not marshall nulls
+;;; var msg = "Parameter '" + name + "' is null,";
+;;; msg += " it is not marshalled.";
+;;; kukit.logDebug(msg);
+ }
+ else if (typeof(value) == 'string') {
+ var elem = new _FormQueryElem(name, value);
+ this.l.push(elem);
+ }
+ // value.length is for detection of an Array.
+ // In addition we also check that value.pop is a function
+ else if (typeof(value) == 'object' &&
+ typeof(value.length) == 'number' &&
+ typeof(value.pop) == 'function') {
+ // Special marshalling of arrays
+ for (var i=0; i < value.length; i++) {
+ var elem = new _FormQueryElem(name, value[i]);
this.l.push(elem);
}
- // value.length is for detection of an Array.
- // In addition we also check that value.pop is a function
- else if (typeof(value) == 'object' &&
- typeof(value.length) == 'number' &&
- typeof(value.pop) == 'function') {
- // Special marshalling of arrays
- for (var i=0; i < value.length; i++) {
- var elem = new _FormQueryElem(name, value[i]);
- this.l.push(elem);
- }
+ }
+ else if (typeof(value) == 'object') {
+ // Special marshalling of dicts
+ for (var key in value) {
+ var qkey = _dictPrefix + name + _dictSeparator;
+ qkey += key + _dictPostfix;
+ var elem = new _FormQueryElem(qkey, value[key]);
+ this.l.push(elem);
}
- else if (typeof(value) == 'object') {
- // Special marshalling of dicts
- for (var key in value) {
- var qkey = _dictPrefix + name + _dictSeparator;
- qkey += key + _dictPostfix;
- var elem = new _FormQueryElem(qkey, value[key]);
- this.l.push(elem);
- }
- }
- };
+ }
+};
- this.encode = function() {
- var poster = [];
- for (var i=0;i < this.l.length;i++) {
- poster[poster.length] = this.l[i].encode();
- }
- return poster.join("&");
- };
+this.encode = function() {
+ var poster = [];
+ for (var i=0;i < this.l.length;i++) {
+ poster[poster.length] = this.l[i].encode();
+ }
+ return poster.join("&");
+};
- this.toDict = function() {
- var d = {};
- for (var i=0;i < this.l.length;i++) {
- var elem = this.l[i];
- d[elem.name] = elem.value;
- }
- return d;
- };
+this.toDict = function() {
+ var d = {};
+ for (var i=0;i < this.l.length;i++) {
+ var elem = this.l[i];
+ d[elem.name] = elem.value;
+ }
+ return d;
+};
+this.initialize.apply(this, arguments);
};
/* Form data extraction, helpers */
@@ -121,31 +128,35 @@
*
*/
-fo.CurrentFormLocator = function(target) {
- this.target = target;
+fo.CurrentFormLocator = function() {
- this.queryForm = function() {
- // Find the form that contains the target node.
- return findContainer(this.target, function(node) {
- if (!node.nodeName) {
- return false;
- }
- if (node.nodeName.toLowerCase() == "form") {
- return true;
- } else {
- return false;
- }
- });
- };
+this.initialize = function(target) {
+ this.target = target;
+}
- this.getForm = function() {
- var form = this.queryForm();
- if (!form) {
-;;; kukit.logWarning("No form found");
- return null;
+this.queryForm = function() {
+ // Find the form that contains the target node.
+ return findContainer(this.target, function(node) {
+ if (!node.nodeName) {
+ return false;
}
- return form;
- };
+ if (node.nodeName.toLowerCase() == "form") {
+ return true;
+ } else {
+ return false;
+ }
+ });
+};
+
+this.getForm = function() {
+ var form = this.queryForm();
+ if (!form) {
+;;; kukit.logWarning("No form found");
+ return null;
+ }
+ return form;
+};
+this.initialize.apply(this, arguments);
};
/*
@@ -153,15 +164,19 @@
*
*/
-fo.NamedFormLocator = function(formname) {
+fo.NamedFormLocator = function() {
+
+this.initialize = function(formname) {
this.formname = formname;
+};
+
+this.getForm = fo.CurrentFormLocator.getForm;
- this.getForm = fo.CurrentFormLocator.getForm;
+this.queryForm = function() {
+ // Find the form with the given name.
+ return document.forms[this.formname];
+};
- this.queryForm = function() {
- // Find the form with the given name.
- return document.forms[this.formname];
- };
};
/* methods to take the desired value(s) from the form */
@@ -278,28 +293,32 @@
* class _FieldUpdateRegistry
*/
var _FieldUpdateRegistry = function() {
+
+this.initialize = function() {
this.editors = {};
+};
- this.register = function(node, editor) {
- var hash = kukit.rd.hashNode(node);
- if (typeof(this.editors[hash]) != 'undefined') {
-;;; kukit.E = 'Double registration of editor update on node.';
- throw new Error(kukit.E);
- }
- this.editors[hash] = editor;
- //kukit.logDebug('Registered '+node.name + ' hash=' + hash);
- //Initialize the editor
- editor.doInit();
- };
-
- this.doUpdate = function(node) {
- var hash = kukit.rd.hashNode(node);
- var editor = this.editors[hash];
- if (typeof(editor) != 'undefined') {
- editor.doUpdate(node);
- //kukit.logDebug('Updated '+node.name + ' hash=' + hash);
- }
- };
+this.register = function(node, editor) {
+ var hash = kukit.rd.hashNode(node);
+ if (typeof(this.editors[hash]) != 'undefined') {
+;;; kukit.E = 'Double registration of editor update on node.';
+ throw new Error(kukit.E);
+ }
+ this.editors[hash] = editor;
+ //kukit.logDebug('Registered '+node.name + ' hash=' + hash);
+ //Initialize the editor
+ editor.doInit();
+};
+
+this.doUpdate = function(node) {
+ var hash = kukit.rd.hashNode(node);
+ var editor = this.editors[hash];
+ if (typeof(editor) != 'undefined') {
+ editor.doUpdate(node);
+ //kukit.logDebug('Updated '+node.name + ' hash=' + hash);
+ }
+};
+this.initialize.apply(this, arguments);
};
// fieldUpdateRegistry is a public service, available to all components
@@ -322,17 +341,19 @@
*
*/
var _FormValueProvider = function() {
- this.check = function(args) {
-;;; if (args.length != 1) {
-;;; throw new Error('form method needs 1 arguments (formname)');
-;;; }
- };
- this.eval = function(args, node) {
- var locator = new fo.NamedFormLocator(args[0]);
- var collector = new kukit.ut.TupleCollector();
- return fo.getAllFormVars(locator, collector);
- };
+this.check = function(args) {
+;;; if (args.length != 1) {
+;;; throw new Error('form method needs 1 arguments (formname)');
+;;; }
+};
+
+this.eval = function(args, node) {
+ var locator = new fo.NamedFormLocator(args[0]);
+ var collector = new kukit.ut.TupleCollector();
+ return fo.getAllFormVars(locator, collector);
+};
+
};
fo.pproviderFormRegistry.register('form', _FormValueProvider);
@@ -343,17 +364,19 @@
*
*/
var _CurrentFormValueProvider = function() {
- this.check = function(args) {
-;;; if (args.length != 0) {
-;;; throw new Error('currentForm method needs no argument');
-;;; }
- };
- this.eval = function(args, node) {
- var locator = new fo.CurrentFormLocator(node);
- var collector = new kukit.ut.TupleCollector();
- return fo.getAllFormVars(locator, collector);
- };
+this.check = function(args) {
+;;; if (args.length != 0) {
+;;; throw new Error('currentForm method needs no argument');
+;;; }
+};
+
+this.eval = function(args, node) {
+ var locator = new fo.CurrentFormLocator(node);
+ var collector = new kukit.ut.TupleCollector();
+ return fo.getAllFormVars(locator, collector);
+};
+
};
fo.pproviderFormRegistry.register('currentForm', _CurrentFormValueProvider);
Modified: kukit/kukit.js/branch/finish-closures/kukit/plugin.js
==============================================================================
--- kukit/kukit.js/branch/finish-closures/kukit/plugin.js (original)
+++ kukit/kukit.js/branch/finish-closures/kukit/plugin.js Mon Dec 24
17:26:43 2007
@@ -508,14 +508,13 @@
this.initialize = function() {
this.state = false;
var self = this;
- var timeoutSetState = function(spinnerevent) {
+ var _timeoutSetState = function(spinnerevent) {
self.timeoutSetState(spinnerevent);
};
- this.scheduler = new kukit.ut.Scheduler(timeoutSetState);
+ this.scheduler = new kukit.ut.Scheduler(_timeoutSetState);
};
-this.__bind__ = function(name, func_to_bind,
- oper) {
+this.__bind__ = function(name, func_to_bind, oper) {
;;; oper.componentName = '[spinner] event binding';
oper.evaluateParameters([], {'laziness': 0});
oper.evalInt('laziness');
@@ -528,8 +527,7 @@
kukit.engine.requestManager.registerSpinnerEvent(func, state_to_bind);
};
-this.setState = function(func_to_bind, state,
- laziness) {
+this.setState = function(func_to_bind, state, laziness) {
// This is called when state changes. We introduce laziness
// before calling the func.
this.func_to_bind = func_to_bind;
@@ -541,7 +539,8 @@
this.timeoutSetState = function() {
// really call the bound actions which should set the spinner
- this.func_to_bind();
+ var func = this.func_to_bind;
+ func();
};
this.initialize.apply(this, arguments);
};
_______________________________________________
Kukit-checkins mailing list
[email protected]
http://codespeak.net/mailman/listinfo/kukit-checkins