Author: reebalazs
Date: Fri Dec 28 12:42:37 2007
New Revision: 50157
Modified:
kukit/kukit.js/branch/ree-service-layer-and-refactoring/ (props changed)
kukit/kukit.js/branch/ree-service-layer-and-refactoring/doc/HISTORY.txt
kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/commandreg.js
kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js
kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kssparser.js
kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kukit.js
kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/plugin.js
kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/selectorreg.js
kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_interfaces.js
kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_kssparser.js
Log:
Make selectors use the interfaces.
With this, all plugin registry in kss is reusing interfaces.
All ecma and selenium tests are GREEN, ecma tests in browser still broken.
Modified:
kukit/kukit.js/branch/ree-service-layer-and-refactoring/doc/HISTORY.txt
==============================================================================
--- kukit/kukit.js/branch/ree-service-layer-and-refactoring/doc/HISTORY.txt
(original)
+++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/doc/HISTORY.txt
Fri Dec 28 12:42:37 2007
@@ -6,11 +6,16 @@
- ...
- - Add service layers. Refactor plugin binding.
+ - Add a general registry for interfaces.
+
+ Add service layers.
Refactor event binding and registries.
- refactor processBindingEvents to make it iterate
+ Move event, action, command, selector, valueprovider
+ plugin registries into the interfaces registry,
+
+ Refactor processBindingEvents to make it iterate
on the binding sequence in a more efficient way.
Eliminate namespaces from refactored code.
@@ -31,6 +36,11 @@
This may break third party plugin code that reuses unpublished
internals from plugins.js. (Most particularly, the more_selectors
demo needed to be updated as well.)
+
+ Fix the issue that happened with value providers used for getting
+ the event binder id,
+ e.g. #div:click(kssAttr(blah, true) got wrongfully cut into
+ two places and considered as two broken selectors.
[ree]
- Fix multiple selection form fields
Modified:
kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/commandreg.js
==============================================================================
--- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/commandreg.js
(original)
+++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/commandreg.js
Fri Dec 28 12:42:37 2007
@@ -139,17 +139,21 @@
};
var _executeCommandOnSelector = function(oper) {
- var selfunc = kukit.selectorTypesGlobalRegistry.get(this.selectorType);
+ var info = kukit.interfaces.global.selectors[this.selectorType];
+ // Check if the selector name really exists.
+ if (! info || ! info.selectorFunc) {
+;;; kukit.E = 'Undefined selector [';
+;;; kukit.E += this.methodName + '].';
+ throw kukit.err.pluginRegistryError(null, kukit.E);
+ }
// When applying the selection, the original event target will be used
// as a starting point for the selection.
- var nodes = selfunc(this.selector, oper.orignode, {});
+ var nodes = info.selectorFunc(this.selector, oper.orignode, {});
;;;var printType;
;;;if (this.selectorType) {
;;; printType = this.selectorType;
;;;} else {
-;;; printType = 'default (';
-;;; printType += kukit.selectorTypesGlobalRegistry.defaultSelectorType;
-;;; printType += ')';
+;;; printType = 'default (css)';
;;;}
;;;var msg = 'Selector type [' + printType + '], selector [';
;;;msg += this.selector + '], selected nodes [' + nodes.length + '].';
Modified:
kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js
==============================================================================
--- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js
(original)
+++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/interfaces.js
Fri Dec 28 12:42:37 2007
@@ -408,7 +408,7 @@
this.global.get('actions', this.PluginMethodDescriptor).finalize({});
this.global.get('formproviders', this.PluginMethodDescriptor).finalize({});
this.global.get('valueproviders',
this.PluginMethodDescriptor).finalize({});
- this.global.get('selectorproviders',
this.PluginMethodDescriptor).finalize({});
+ this.global.get('selectors', this.PluginMethodDescriptor).finalize({});
};
this.cleanRoomTearDown = function(suite) {
Modified:
kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kssparser.js
==============================================================================
--- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kssparser.js
(original)
+++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kssparser.js
Fri Dec 28 12:42:37 2007
@@ -268,7 +268,7 @@
kukit.kssp.Block.prototype.addActionParameter = function(action, key, value) {
var interfaceForAction = {
'': kukit.interfaces.global.valueproviders,
- 'kssSelector': kukit.interfaces.global.selectorproviders,
+ 'kssSelector': kukit.interfaces.global.selectors,
'kssSubmitForm': kukit.interfaces.global.formproviders
};
Modified: kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kukit.js
==============================================================================
--- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kukit.js
(original)
+++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/kukit.js
Fri Dec 28 12:42:37 2007
@@ -248,7 +248,7 @@
interfaces.get('actions',
kukit.interfaces.PluginMethodDescriptor).finalize({});
interfaces.get('valueproviders',
kukit.interfaces.PluginMethodDescriptor).finalize({});
interfaces.get('formproviders',
kukit.interfaces.PluginMethodDescriptor).finalize({});
- interfaces.get('selectorproviders',
kukit.interfaces.PluginMethodDescriptor).finalize({});
+ interfaces.get('selectors',
kukit.interfaces.PluginMethodDescriptor).finalize({});
;;; kukit.log('All interfaces finalized.');
;;; kukit.log('Initializing kinetic stylesheets.');
// Succesful initialization. At the moment the engine is kept
Modified:
kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/plugin.js
==============================================================================
--- kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/plugin.js
(original)
+++ kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/plugin.js
Fri Dec 28 12:42:37 2007
@@ -985,7 +985,7 @@
;;; var msg = 'Deprecated the [executeCommand] action, use [kssSelector] in a
standard action!';
;;; kukit.logWarning(msg);
oper.evaluateParameters(['name', 'selector'],
- {'selectorType': null},
+ {'selectorType': ''},
'', true);
var parms = oper.parms;
// marshall it, the rest of the parms will be passed
Modified:
kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/selectorreg.js
==============================================================================
---
kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/selectorreg.js
(original)
+++
kukit/kukit.js/branch/ree-service-layer-and-refactoring/kukit/selectorreg.js
Fri Dec 28 12:42:37 2007
@@ -19,15 +19,12 @@
kukit.sr = {};
-// Registry of the pprovider functions for selecting
-
-// XXX XXX XXX TODO factor this with selector reg
-kukit.sr.pproviderSelRegistry = new
kukit.pr.ValueProviderRegistry('selectorproviders');
-
-
// this will provide an arbitrary selector, and is designed to
// be used with the makeAnyPP factory function.
-kukit.sr.AnyPP = function() {};
+kukit.sr.AnyPP = function(selectorFunc) {
+ this.selectorFunc = selectorFunc;
+};
+
kukit.sr.AnyPP.prototype = {
check: function(args) {
// check does not need to be used here actually.
@@ -36,22 +33,17 @@
;;; }
},
eval: function(args, node, defaultParameters) {
- var f = kukit.selectorTypesGlobalRegistry.get(this.selector_type);
// We don't have orignode if we evaluate from here, consequently
// the orignode parameter cannot be used from selectors. We pass
// node just to be sure...
- return f(args[0], node, defaultParameters, node);
+ return this.selectorFunc(args[0], node, defaultParameters, node);
}
};
-kukit.sr.pproviderSelRegistry.register('', kukit.sr.AnyPP);
-
-kukit.sr.makeAnyPP = function(selector_type) {
- var pp = function () {};
- pp.prototype.eval = kukit.sr.AnyPP.prototype.eval;
-;;; pp.prototype.check = kukit.sr.AnyPP.prototype.check;
- pp.prototype.selector_type = selector_type;
- return pp;
+kukit.sr.makeAnySelectorProvider = function(selectorFunc) {
+ var providerClass = function() {};
+ providerClass.prototype = new kukit.sr.AnyPP(selectorFunc);
+ return providerClass;
};
// this can be used to pass a node programmatically
@@ -73,7 +65,11 @@
return nodes;
}
};
-kukit.sr.pproviderSelRegistry.register('passnode', kukit.sr.PassnodePP);
+var iface = kukit.interfaces.global.get('selectors',
kukit.interfaces.PluginMethodDescriptor);
+var info = {providerClass: kukit.sr.PassnodePP};
+iface.getMethodDescriptor('passnode').register(info);
+// the item now will contain providerClass only,
+// as passnode is only allowed from the kss file, not as a command selector.
/*
@@ -87,40 +83,30 @@
*
*/
kukit.sr.SelectorTypeRegistry = function () {
- this.mapping = {};
};
-kukit.sr.SelectorTypeRegistry.prototype.defaultSelectorType = 'css';
-
-kukit.sr.SelectorTypeRegistry.prototype.register = function(name, func) {
+kukit.sr.SelectorTypeRegistry.prototype.register = function(name,
selectorFunc) {
;;; // Check func parameter: diagnostics only, as this will cause
;;; // an error later anyway.
-;;; if (typeof(func) == 'undefined') {
+;;; if (typeof(selectorFunc) == 'undefined') {
;;; kukit.E = 'Func is mandatory in SelectorTypeRegistry.register.';
;;; throw new Error(kukit.E);
;;; }
-;;; if (this.mapping[name]) {
-;;; // Do not allow redefinition
-;;; kukit.logError('Error : redefinition attempt of selector ' + name);
-;;; return;
-;;; }
- this.mapping[name] = func;
// Also register the selector param provider
- var pp = kukit.sr.makeAnyPP(name);
- kukit.sr.pproviderSelRegistry.register(name, pp);
+ var iface = kukit.interfaces.global.get('selectors',
kukit.interfaces.PluginMethodDescriptor);
+ var providerClass = kukit.sr.makeAnySelectorProvider(selectorFunc);
+ iface.getMethodDescriptor(name).register({
+ providerClass: providerClass,
+ selectorFunc: selectorFunc});
+ // the item now will contain providerClass and selectorFunc as well
};
kukit.sr.SelectorTypeRegistry.prototype.get = function(name) {
- if (! name) {
- // if name is null or undefined or '',
- // we use the default type.
- name = this.defaultSelectorType;
- }
- var result = this.mapping[name];
-;;; if (typeof(result) == 'undefined') {
+ var info = kukit.interfaces.global.selectors[name];
+;;; if (! info || ! info.selectorFunc) {
;;; throw new Error('Unknown selector type "' + name + '"');
;;; }
- return result;
+ return info.selectorFunc;
};
kukit.selectorTypesGlobalRegistry = new kukit.sr.SelectorTypeRegistry();
@@ -140,6 +126,15 @@
return nodes;
});
+// Since css is the default selector, copy the provider class
+// to the identity function. That is, if the selector is
+// not css() htmlid() etc. but a string,
+// we use the default selector, css.
+var iface = kukit.interfaces.global.get('selectors',
kukit.interfaces.PluginMethodDescriptor);
+var css_config = iface.getMethodDescriptor('css').config;
+iface.getMethodDescriptor('').register(css_config);
+// the item now will contain providerClass and selectorFunc: both are needed.
+
kukit.selectorTypesGlobalRegistry.register('samenode', function(expr, node) {
nodes = [node];
return nodes;
Modified:
kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_interfaces.js
==============================================================================
---
kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_interfaces.js
(original)
+++
kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_interfaces.js
Fri Dec 28 12:42:37 2007
@@ -457,13 +457,13 @@
iterName: 'Each',
binderClass: MSub,
bindMethodName: 'bind'});
- // initialize
+ // finalize
iface.finalize({});
// Check that our classes are set as expected.
- this.assert(this.interfaces.dummybinditeration.click.binderClass, M);
- this.assert(this.interfaces.dummybinditeration.timeout.binderClass, M);
- this.assert(this.interfaces.dummybinditeration.keydown.binderClass,
MSub);
- this.assert(this.interfaces.dummybinditeration.keypress.binderClass,
MSub);
+
this.assertEquals(this.interfaces.dummybinditeration.click.binderClass, M);
+
this.assertEquals(this.interfaces.dummybinditeration.timeout.binderClass, M);
+
this.assertEquals(this.interfaces.dummybinditeration.keydown.binderClass, MSub);
+
this.assertEquals(this.interfaces.dummybinditeration.keypress.binderClass,
MSub);
// Check that both classes have a class name.
this.assert(M.prototype.__className__);
this.assert(MSub.prototype.__className__);
Modified:
kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_kssparser.js
==============================================================================
---
kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_kssparser.js
(original)
+++
kukit/kukit.js/branch/ree-service-layer-and-refactoring/tests/test_kssparser.js
Fri Dec 28 12:42:37 2007
@@ -54,10 +54,13 @@
kukit.pprovidersGlobalRegistry.register('formVar', kukit.pr.FormVarPP);
kukit.pprovidersGlobalRegistry.register('nodeAttr',
kukit.pr.NodeAttrPP);
//
+ // Create the identity value provider for kssSelector, this is needed
+ // at least to evaluate strings.
+ var iface = kukit.interfaces.global.get('selectors',
kukit.interfaces.PluginMethodDescriptor);
+ var info = {providerClass: kukit.pr.IdentityPP};
+ iface.getMethodDescriptor('').register(info);
//Create some selectors
- //XXX this is temporary untul the selectors registry is finished
- kukit.sr.pproviderSelRegistry.register('', kukit.sr.AnyPP);
- kukit.sr.pproviderSelRegistry.register('htmlid', kukit.sr.AnyPP);
+ kukit.selectorTypesGlobalRegistry.register('htmlid', function(expr,
node) {});
//
// finalize the interfaces we just set up
kukit.interfaces.cleanRoomFinalize(this);
_______________________________________________
Kukit-checkins mailing list
[email protected]
http://codespeak.net/mailman/listinfo/kukit-checkins