From reebalazs at codespeak.net Mon Jan 1 11:17:02 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Mon, 1 Jan 2007 11:17:02 +0100 (CET) Subject: [KSS-checkins] r36083 - kukit/kukit.js/trunk/kukit Message-ID: <20070101101702.456A910083@code0.codespeak.net> Author: reebalazs Date: Mon Jan 1 11:16:58 2007 New Revision: 36083 Modified: kukit/kukit.js/trunk/kukit/requestmanager.js kukit/kukit.js/trunk/kukit/utils.js Log: Put in a few ; as preparation for full compression in the future Modified: kukit/kukit.js/trunk/kukit/requestmanager.js ============================================================================== --- kukit/kukit.js/trunk/kukit/requestmanager.js (original) +++ kukit/kukit.js/trunk/kukit/requestmanager.js Mon Jan 1 11:16:58 2007 @@ -79,7 +79,7 @@ */ kukit.rm.TimerQueue = function(callback) { - this.callback = callback + this.callback = callback; this.queue = new kukit.ut.SortedQueue(this._sentSort); this.nr = 0; }; @@ -202,7 +202,7 @@ kukit.rm.RequestManager.prototype.pushWaitingRequest = function(item, now) { this.waitingQueue.push(item); // Set the timeout - this.checkTimeout(now) + this.checkTimeout(now); }; kukit.rm.RequestManager.prototype.popWaitingRequest = function() { @@ -225,7 +225,7 @@ // Set the spinner state this.setSpinnerState(true); // Set the timeout - this.checkTimeout(now) + this.checkTimeout(now); // Wrap up the callback func. It will be called // with the item as first parameter. var self = this; Modified: kukit/kukit.js/trunk/kukit/utils.js ============================================================================== --- kukit/kukit.js/trunk/kukit/utils.js (original) +++ kukit/kukit.js/trunk/kukit/utils.js Mon Jan 1 11:16:58 2007 @@ -115,7 +115,7 @@ return this.name + ': ' + this.message; } } - return err + return err; } exc.prototype.__init__ = function(name, message) { var kw = {}; @@ -123,7 +123,7 @@ kw.message = message; return kw; } - return exc + return exc; }; @@ -171,9 +171,13 @@ }; kukit.ut.SortedQueue.prototype.comparefunc = function(a, b) { - if (a < b) return -1; - else if (a > b) return +1; - else return 0; + if (a < b) { + return -1; + } else if (a > b) { + return +1; + } else { + return 0; + } }; kukit.ut.SortedQueue.prototype.reset = function() { @@ -273,7 +277,7 @@ var self = this; var func = function() { self.timeout(); - } + }; this.timer = setTimeout(func, this.delay); }; @@ -315,11 +319,11 @@ var self = this; var func = function() { self.timeout(); - } + }; this.timer = setTimeout(func, ts - now); } else { // if in the past, run immediately - this.func() + this.func(); } }; @@ -380,7 +384,7 @@ kukit.log('Starting ' + item.remark); var ts_start = (new Date()).valueOf(); try { - item.func() + item.func(); } catch(e) { this.lock = false; throw(e); From reebalazs at codespeak.net Mon Jan 1 14:09:13 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Mon, 1 Jan 2007 14:09:13 +0100 (CET) Subject: [KSS-checkins] r36089 - kukit/kukit.js/trunk/kukit Message-ID: <20070101130913.C181D1007F@code0.codespeak.net> Author: reebalazs Date: Mon Jan 1 14:09:06 2007 New Revision: 36089 Modified: kukit/kukit.js/trunk/kukit/commandreg.js kukit/kukit.js/trunk/kukit/dom.js kukit/kukit.js/trunk/kukit/eventreg.js kukit/kukit.js/trunk/kukit/kssparser.js kukit/kukit.js/trunk/kukit/kukit.js kukit/kukit.js/trunk/kukit/plugin.js kukit/kukit.js/trunk/kukit/requestmanager.js kukit/kukit.js/trunk/kukit/resourcedata.js kukit/kukit.js/trunk/kukit/tokenizer.js kukit/kukit.js/trunk/kukit/utils.js Log: make changes to enable full compression. Most of this will not be necessary with the enhanced parser though. workarounds: - missing semicolons - don't use _SARISSA... - /* */ in strings escaped Modified: kukit/kukit.js/trunk/kukit/commandreg.js ============================================================================== --- kukit/kukit.js/trunk/kukit/commandreg.js (original) +++ kukit/kukit.js/trunk/kukit/commandreg.js Mon Jan 1 14:09:06 2007 @@ -48,7 +48,7 @@ // register a given action as a command, using the given vactor var f = kukit.ar.actionRegistry.get(srcname); factory(name, f); -} +}; kukit.cr.CommandRegistry.prototype.register = function(name, klass) { if (this.content[name]) { @@ -81,7 +81,7 @@ command.parms = parms; command.transport = transport; return command; -} +}; kukit.cr._Command_execute = function(oper) { var newoper = oper.clone({ Modified: kukit/kukit.js/trunk/kukit/dom.js ============================================================================== --- kukit/kukit.js/trunk/kukit/dom.js (original) +++ kukit/kukit.js/trunk/kukit/dom.js Mon Jan 1 14:09:06 2007 @@ -38,13 +38,13 @@ toNode = toNode.nextSibling; } return toNode; -} +}; kukit.dom.insertBefore = function(nodeFrom, parentNode, nodeTo) { var ownerDoc = nodeTo.nodeType == Node.DOCUMENT_NODE ? nodeTo : nodeTo.ownerDocument; var nodes = nodeFrom.childNodes; var result = new Array(); - if(ownerDoc.importNode && (!_SARISSA_IS_IE)) { + if(ownerDoc.importNode && (!kukit.HAVE_IE)) { for(var i=0;i < nodes.length;i++) { result[i] = parentNode.insertBefore(ownerDoc.importNode(nodes[i], true), nodeTo); } @@ -59,7 +59,7 @@ kukit.dom.appendChildren = function(nodes, toNode) { var ownerDoc = toNode.nodeType == Node.DOCUMENT_NODE ? toNode : toNode.ownerDocument; var result = new Array(); - if(ownerDoc.importNode && (!_SARISSA_IS_IE)) { + if(ownerDoc.importNode && (!kukit.HAVE_IE)) { for(var i=0;i < nodes.length;i++) { result[i] = toNode.appendChild(ownerDoc.importNode(nodes[i], true)); } @@ -302,7 +302,7 @@ //this.counter.timeout(); // XXX can't execute immediately, it fails on IE. this.counter.start(); -} +}; // From http://xkr.us/articles/dom/iframe-document/ // Note it's not necessary for the iframe to have the name @@ -314,7 +314,7 @@ doc = doc.document; } return doc -} +}; kukit.dom.EmbeddedContentLoadedScheduler.prototype.check = function() { // quit if the init function has already been called Modified: kukit/kukit.js/trunk/kukit/eventreg.js ============================================================================== --- kukit/kukit.js/trunk/kukit/eventreg.js (original) +++ kukit/kukit.js/trunk/kukit/eventreg.js Mon Jan 1 14:09:06 2007 @@ -120,7 +120,7 @@ throw 'In EventRegistry.register namespace cannot contain -'; } return namespace + '-' + eventname; -} +}; kukit.er.EventRegistry.prototype.exists = function(namespace, eventname) { var key = this._getKey(namespace, eventname); @@ -165,7 +165,7 @@ oper.binderinstance = this; method.call(this, name, oper); } -} +}; /* This can be called on the event and will execute the * desired event action. Parameters will be these + those @@ -219,7 +219,7 @@ special += 1; } kukit.logDebug('Event "' + name + '" executed on ' + executed + ' nodes, ' + special + ' special kss targets.'); -} +}; kukit.er.EventBinder_triggerevent = function(name, oper) { // Private. Called from __trigger_event__ or from main event execution. @@ -232,7 +232,7 @@ // In case there is no event rule, just call the default event action. // This is programmatic calling. var namespace = this.__event_namespace__; - kukit.logDebug('Calling implicit event "' + name + '" on namespace "' + namespace + '"') + kukit.logDebug('Calling implicit event "' + name + '" on namespace "' + namespace + '"'); this._EventBinder_calldefault(namespace, name, oper); } }; Modified: kukit/kukit.js/trunk/kukit/kssparser.js ============================================================================== --- kukit/kukit.js/trunk/kukit/kssparser.js (original) +++ kukit/kukit.js/trunk/kukit/kssparser.js Mon Jan 1 14:09:06 2007 @@ -25,8 +25,8 @@ /* Tokens */ -kukit.kssp.commentbegin = kukit.tk.mkToken('commentbegin', "/*"); -kukit.kssp.commentend = kukit.tk.mkToken('commentend', "*/"); +kukit.kssp.commentbegin = kukit.tk.mkToken('commentbegin', "\/\*"); +kukit.kssp.commentend = kukit.tk.mkToken('commentend', "\*\/"); kukit.kssp.openbrace = kukit.tk.mkToken('openbrace', "{"); kukit.kssp.closebrace = kukit.tk.mkToken('closebrace', "}"); kukit.kssp.openbracket = kukit.tk.mkToken('openbracket', "["); @@ -44,7 +44,7 @@ /* Parsers */ kukit.kssp.document = kukit.tk.mkParser('document', { - "/*": 'new kukit.kssp.comment(this.src, kukit.kssp.commentbegin)', + "\/\*": 'new kukit.kssp.comment(this.src, kukit.kssp.commentbegin)', "{": 'new kukit.kssp.block(this.src, kukit.kssp.openbrace)' }); kukit.kssp.document.prototype.process = function() { @@ -78,7 +78,7 @@ // it's not 100% good, but will do kukit.kssp.comment = kukit.tk.mkParser('comment', { - "*/": 'this.emitAndReturn(new kukit.kssp.commentend(this.src))' + "\*\/": 'this.emitAndReturn(new kukit.kssp.commentend(this.src))' }); kukit.kssp.comment.prototype.process = function() { this.result = []; @@ -210,7 +210,7 @@ ",": 'this.emitAndReturn()', "'": 'new kukit.kssp.string(this.src, kukit.kssp.quote)', '"': 'new kukit.kssp.string2(this.src, kukit.kssp.dquote)', - "/*": 'new kukit.kssp.comment(this.src, kukit.kssp.commentbegin)', + "\/\*": 'new kukit.kssp.comment(this.src, kukit.kssp.commentbegin)', "(": 'new kukit.kssp.methodargs(this.src, kukit.kssp.openparent)' }); kukit.kssp.propvalue.prototype.process = function() { @@ -264,7 +264,7 @@ kukit.kssp.propvalue.prototype.produceTxt = function(txt) { // txt parms are returned embedded this.value = new kukit.rd.KssTextValue(txt); -} +}; // propvalue in method cannot contain method-style vars. kukit.kssp.propvalue_in_method = kukit.tk.mkParser('propvalue', { @@ -275,7 +275,7 @@ ",": 'this.emitAndReturn()', "'": 'new kukit.kssp.string(this.src, kukit.kssp.quote)', '"': 'new kukit.kssp.string2(this.src, kukit.kssp.dquote)', - "/*": 'new kukit.kssp.comment(this.src, kukit.kssp.commentbegin)' //, + "\/\*": 'new kukit.kssp.comment(this.src, kukit.kssp.commentbegin)' //, }); kukit.kssp.propvalue_in_method.prototype.multiword_allowed = false; kukit.kssp.propvalue_in_method.prototype.process = kukit.kssp.propvalue.prototype.process; @@ -291,7 +291,7 @@ "\t": 'this.emitAndReturn()', "\n": 'this.emitAndReturn()', "\r": 'this.emitAndReturn()', - "/*": 'this.emitAndReturn()', + "\/\*": 'this.emitAndReturn()', ":": 'this.emitAndReturn()', "(": 'this.emitAndReturn(new kukit.kssp.methodargs(this.src, kukit.kssp.openparent))' }); @@ -301,7 +301,7 @@ kukit.kssp.propvalue_in_pseudo.prototype.produceTxt = function(txt) { // txt parms are returned embedded this.value = new kukit.rd.KssPseudoValue(txt, []); -} +}; kukit.kssp.string = kukit.tk.mkParser('string', { "'": 'this.emitAndReturn(new kukit.kssp.quote(this.src))', @@ -345,7 +345,7 @@ '"': 'new kukit.kssp.string2(this.src, kukit.kssp.dquote)', ",": 'new kukit.kssp.comma(this.src)', ")": 'this.emitAndReturn(new kukit.kssp.closeparent(this.src))', - "/*": 'new kukit.kssp.comment(this.src, kukit.kssp.commentbegin)' + "\/\*": 'new kukit.kssp.comment(this.src, kukit.kssp.commentbegin)' }); kukit.kssp.methodargs.prototype.process = function() { this.args = []; @@ -381,7 +381,7 @@ kukit.kssp.kssselector = kukit.tk.mkParser('kssselector', { ":": '[new kukit.kssp.colon(this.src), new kukit.kssp.propvalue_in_pseudo(this.src)]', "{": 'this.emitAndReturn()', - "/*": 'new kukit.kssp.comment(this.src, kukit.kssp.commentbegin)' + "\/\*": 'new kukit.kssp.comment(this.src, kukit.kssp.commentbegin)' }); kukit.kssp.kssselector.prototype.process = function() { var name; Modified: kukit/kukit.js/trunk/kukit/kukit.js ============================================================================== --- kukit/kukit.js/trunk/kukit/kukit.js (original) +++ kukit/kukit.js/trunk/kukit/kukit.js Mon Jan 1 14:09:06 2007 @@ -271,10 +271,9 @@ }; kukit.notifyServer_done = function(domDoc, oper) { - if (domDoc.readyState == 4) - { + if (domDoc.readyState == 4) { // notify the queue that we are done - var success = oper.queueItem.receivedResult() + var success = oper.queueItem.receivedResult(); // We only process if the response has not been timed // out by the queue in the meantime. if (success) { Modified: kukit/kukit.js/trunk/kukit/plugin.js ============================================================================== --- kukit/kukit.js/trunk/kukit/plugin.js (original) +++ kukit/kukit.js/trunk/kukit/plugin.js Mon Jan 1 14:09:06 2007 @@ -255,7 +255,7 @@ // We want the event execute once the iframe is loaded. var f = function() { kukit.bindScheduler.addPost(func_to_bind, 'Execute load event for iframe ' + oper.node.name); - } + }; new kukit.dom.EmbeddedContentLoadedScheduler(oper.node.id, f); } else { @@ -275,7 +275,7 @@ var self = this; var timeoutSetState = function(spinnerevent) { self.timeoutSetState(spinnerevent); - } + }; this.scheduler = new kukit.ut.Scheduler(timeoutSetState); }; Modified: kukit/kukit.js/trunk/kukit/requestmanager.js ============================================================================== --- kukit/kukit.js/trunk/kukit/requestmanager.js (original) +++ kukit/kukit.js/trunk/kukit/requestmanager.js Mon Jan 1 14:09:06 2007 @@ -89,7 +89,7 @@ if (a.expire < b.expire) return -1; else if (a.expire > b.expire) return +1; else return 0; -} +}; kukit.rm.TimerQueue.prototype.push = function(item) { // push a given slot @@ -148,7 +148,7 @@ var self = this; var timeoutItem = function(item) { self.timeoutItem(item); - } + }; this.timerQueue = new kukit.rm.TimerQueue(timeoutItem); if (typeof(name) == 'undefined') { name = null; @@ -165,7 +165,7 @@ // sets the timeout scheduler var checkTimeout = function() { self.checkTimeout(); - } + }; if (typeof(schedulerClass) == 'undefined') { schedulerClass = kukit.ut.Scheduler; } @@ -231,7 +231,7 @@ var self = this; var func = function(item, now) { return self.receiveItem(item, now); - } + }; item.setReceivedCallback(func); // Call the function item.sendHook(item); Modified: kukit/kukit.js/trunk/kukit/resourcedata.js ============================================================================== --- kukit/kukit.js/trunk/kukit/resourcedata.js (original) +++ kukit/kukit.js/trunk/kukit/resourcedata.js Mon Jan 1 14:09:06 2007 @@ -350,7 +350,7 @@ */ kukit.rd.EventRule.prototype.bind = function(node) { - var oper = new kukit.op.Oper() + var oper = new kukit.op.Oper(); oper.node = node; oper.binderinstance = this.getBinderInstance(); oper.eventrule = this; @@ -371,7 +371,7 @@ newoper.binderinstance._EventBinder_triggerevent(name, newoper); }; // do the binding - var bindoper = new kukit.op.Oper() + var bindoper = new kukit.op.Oper(); bindoper.node = node; bindoper.binderinstance = oper.binderinstance; bindoper.eventrule = this; @@ -538,7 +538,7 @@ this.error = null; this.parms = {}; this.type = null; -} +}; kukit.rd.Action.prototype.setName = function(name) { if (this.name != null && this.name != name) { Modified: kukit/kukit.js/trunk/kukit/tokenizer.js ============================================================================== --- kukit/kukit.js/trunk/kukit/tokenizer.js (original) +++ kukit/kukit.js/trunk/kukit/tokenizer.js Mon Jan 1 14:09:06 2007 @@ -28,7 +28,7 @@ var kw = this.__superinit__(name, message); kw.errpos = errpos; kw.message = kw.message + ' at position ' + errpos; - return kw + return kw; }; /* Class methods of tokens and parsers */ @@ -195,7 +195,7 @@ } this.endpos = src.pos; this.src = null; - } + }; f.prototype = new kukit.tk._TokenBase; f.prototype.symbol = symbol; f.prototype.txt = txt; @@ -222,7 +222,7 @@ // post processing this.process(); this.src = null; - } + }; f.prototype = new kukit.tk._ParserBase; f.prototype.symbol = symbol; return f; Modified: kukit/kukit.js/trunk/kukit/utils.js ============================================================================== --- kukit/kukit.js/trunk/kukit/utils.js (original) +++ kukit/kukit.js/trunk/kukit/utils.js Mon Jan 1 14:09:06 2007 @@ -29,6 +29,9 @@ // Browser identification. We need this one only atm. try { kukit.HAVE_SAFARI = navigator.vendor && navigator.vendor.indexOf('Apple') != -1; + // this one is taken from sarissa. Howewer we can't reuse it since it starts with _. + kukit.HAVE_IE = document.all && window.ActiveXObject && navigator.userAgent.toLowerCase().indexOf("msie") > -1 && navigator.userAgent.toLowerCase().indexOf("opera") == -1; + } catch (e) {} /* check whether the logging stuff of Firebug is available */ @@ -116,13 +119,13 @@ } } return err; - } + }; exc.prototype.__init__ = function(name, message) { var kw = {}; kw.name = name; kw.message = message; return kw; - } + }; return exc; }; From reebalazs at codespeak.net Mon Jan 1 23:40:08 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Mon, 1 Jan 2007 23:40:08 +0100 (CET) Subject: [KSS-checkins] r36099 - kukit/kukit.js/trunk/kukit Message-ID: <20070101224008.43B8F10071@code0.codespeak.net> Author: reebalazs Date: Mon Jan 1 23:40:04 2007 New Revision: 36099 Modified: kukit/kukit.js/trunk/kukit/utils.js Log: Again, use HAVE_IE as provided by Sarissa. Modified: kukit/kukit.js/trunk/kukit/utils.js ============================================================================== --- kukit/kukit.js/trunk/kukit/utils.js (original) +++ kukit/kukit.js/trunk/kukit/utils.js Mon Jan 1 23:40:04 2007 @@ -29,9 +29,7 @@ // Browser identification. We need this one only atm. try { kukit.HAVE_SAFARI = navigator.vendor && navigator.vendor.indexOf('Apple') != -1; - // this one is taken from sarissa. Howewer we can't reuse it since it starts with _. - kukit.HAVE_IE = document.all && window.ActiveXObject && navigator.userAgent.toLowerCase().indexOf("msie") > -1 && navigator.userAgent.toLowerCase().indexOf("opera") == -1; - + kukit.HAVE_IE = eval("_SARISSA_IS_IE"); } catch (e) {} /* check whether the logging stuff of Firebug is available */ From reebalazs at codespeak.net Thu Jan 4 14:50:47 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Thu, 4 Jan 2007 14:50:47 +0100 (CET) Subject: [KSS-checkins] r36148 - kukit/kukit.js/branch/ree-events-cleanup Message-ID: <20070104135047.E308E10070@code0.codespeak.net> Author: reebalazs Date: Thu Jan 4 14:50:42 2007 New Revision: 36148 Added: kukit/kukit.js/branch/ree-events-cleanup/ - copied from r36147, kukit/kukit.js/trunk/ Log: Branch off From reebalazs at codespeak.net Thu Jan 4 17:36:07 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Thu, 4 Jan 2007 17:36:07 +0100 (CET) Subject: [KSS-checkins] r36152 - kukit/kss.core/branch/ree-events-cleanup Message-ID: <20070104163607.D709910074@code0.codespeak.net> Author: reebalazs Date: Thu Jan 4 17:36:03 2007 New Revision: 36152 Added: kukit/kss.core/branch/ree-events-cleanup/ - copied from r36151, kukit/kss.core/trunk/ Log: Branch off From reebalazs at codespeak.net Thu Jan 4 17:37:17 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Thu, 4 Jan 2007 17:37:17 +0100 (CET) Subject: [KSS-checkins] r36153 - kukit/kss.core/branch/ree-events-cleanup Message-ID: <20070104163717.232D010074@code0.codespeak.net> Author: reebalazs Date: Thu Jan 4 17:37:12 2007 New Revision: 36153 Modified: kukit/kss.core/branch/ree-events-cleanup/ (props changed) kukit/kss.core/branch/ree-events-cleanup/EXTERNALS.TXT Log: Branch off Modified: kukit/kss.core/branch/ree-events-cleanup/EXTERNALS.TXT ============================================================================== --- kukit/kss.core/branch/ree-events-cleanup/EXTERNALS.TXT (original) +++ kukit/kss.core/branch/ree-events-cleanup/EXTERNALS.TXT Thu Jan 4 17:37:12 2007 @@ -5,4 +5,4 @@ # You can update your working dir by: # svn propset svn:externals -F EXTERNALS.TXT . # -kukit http://codespeak.net/svn/kukit/kukit.js/trunk +kukit http://codespeak.net/svn/kukit/kukit.js/branch/ree-events-cleanup From reebalazs at codespeak.net Thu Jan 4 17:38:49 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Thu, 4 Jan 2007 17:38:49 +0100 (CET) Subject: [KSS-checkins] r36154 - kukit/kss.demo/branch/ree-event-cleanup Message-ID: <20070104163849.D9CFD10074@code0.codespeak.net> Author: reebalazs Date: Thu Jan 4 17:38:44 2007 New Revision: 36154 Added: kukit/kss.demo/branch/ree-event-cleanup/ - copied from r36153, kukit/kss.demo/trunk/ Log: Branch off From reebalazs at codespeak.net Fri Jan 5 10:12:14 2007 From: reebalazs at codespeak.net (reebalazs at codespeak.net) Date: Fri, 5 Jan 2007 10:12:14 +0100 (CET) Subject: [KSS-checkins] r36160 - kukit/kukit.js/branch/ree-events-cleanup/kukit Message-ID: <20070105091214.2F1C610071@code0.codespeak.net> Author: reebalazs Date: Fri Jan 5 10:12:10 2007 New Revision: 36160 Modified: kukit/kukit.js/branch/ree-events-cleanup/kukit/eventreg.js kukit/kukit.js/branch/ree-events-cleanup/kukit/oper.js kukit/kukit.js/branch/ree-events-cleanup/kukit/plugin.js kukit/kukit.js/branch/ree-events-cleanup/kukit/resourcedata.js Log: Clean up programmatic event triggering. Method for event continuation is provided, this atm supports both existing usecases (annoyclicker + livesearch) Modified: kukit/kukit.js/branch/ree-events-cleanup/kukit/eventreg.js ============================================================================== --- kukit/kukit.js/branch/ree-events-cleanup/kukit/eventreg.js (original) +++ kukit/kukit.js/branch/ree-events-cleanup/kukit/eventreg.js Fri Jan 5 10:12:10 2007 @@ -152,95 +152,162 @@ * */ -kukit.er.EventBinder_calldefault = function(namespace, name, oper) { - // private method for calling just a default method. - // params should be alredy prepared. - var methodname = kukit.er.eventRegistry.get(namespace, name).defaultactionmethodname; - if (methodname) { - var method = this[methodname]; - if (! method) { - throw 'Could not bind event name "' + name + '" on namespace "' + namespace + '", because the method "' + methodname + '" does not exist.'; - } - // call it - oper.binderinstance = this; - method.call(this, name, oper); - } -}; - -/* This can be called on the event and will execute the -* desired event action. Parameters will be these + those -* defined in the rule. +/* Provide callins on the state instance that execute a given +* continuation event. +* Parameters will be the ones specified in the call + +* those defined in the rule will be added too. (Parameters can +* be accessed with the "pass" kss parameter provider.) +* +* Call examples: +* +* trigger an event bound to a given state instance, same node +* +* binderinstance.__continue_event__('doit', oper.node, {'extravalue': '5'}); +* +* with kss rule: +* +* node.selector:doit { +* action-client: log; +* log-message: pass(extravalue); +* } +* +* or +* +* behaviour.selector:doit { +* action-client: log; +* log-message: pass(extravalue); +* } +* +* trigger an event bound to a given state instance, and the document +* (different from current scope) +* +* binderinstance.__continue_event__('doit', null, {'extravalue': '5'}); +* +* with kss rule: +* +* document:doit { +* action-client: log; +* log-message: pass(extravalue); +* } +* +* or +* +* behaviour.selector:doit { +* action-client: log; +* log-message: pass(extravalue); +* } +* +* trigger an event on all the nodes + document bound to a given state instance +* +* binderinstance.__continue_event_allnodes__('doit', {'extravalue': '5'}); * -* Call example: binderinstance.__trigger_event__('doit', {'extravalue': '5'}, node); +* with kss rule: +* +* node.selector:doit { +* action-client: log; +* log-message: pass(extravalue); +* } +* +* p.s. oper is not required to make it easy to adapt existing code +* so we create a new oper below */ -kukit.er.EventBinder__trigger_event__ = function(name, parms, node) { - // Called programmatically +kukit.er.EventBinder__continue_event__ = function(name, node, parms) { + // Trigger a continuation event bound to a given state instance, given node + // (or on document, if node = null) // - // XXX uhh this must go away. An implicit kss rule is only to be executed - // if no other nodes execute. - var executed = 0; - var special = 0; - // document rules. Execute them with node = null - eventrule = kukit.rd.methodTable.getMergedRule('document', name, this); - if (eventrule != null) { - var oper = new kukit.op.Oper(); + var eventrule; + var oper = new kukit.op.Oper(); + if (node) { + eventrule = oper.getBindingForNode(this, name, node); + } else { + eventrule = kukit.rd.methodTable.getMergedRule('document', name, this); + } + // Look up the behaviour rule, if any. + var behav_eventrule = kukit.rd.methodTable.getMergedRule('behaviour', name, this); + if (behav_eventrule) { + if (! eventrule) { + // There was no node matching for the rule, use behaviour rule + // this allows to set up parametrized actions in general. + eventrule = behav_eventrule; + } else { + kukit.logDebug('Behaviour rule for continuation event "' + name + '" will be ignored, because we found an explicit rule.'); + } + } + // (if eventrule is null here, we can yet have the default method, so go on.) + oper.eventrule = eventrule; + oper.node = node; + if (typeof(parms) != 'undefined') { oper.parms = parms; - oper.eventrule = eventrule; - // node is null. - this._EventBinder_triggerevent(name, oper); - special += 1; + } else { + oper.parms = {}; } + this._EventBinder_triggerevent(name, oper); + kukit.logDebug('Continuation event "' + name + '" executed on same node.'); +}; + +kukit.er.EventBinder__continue_event_allnodes__ = function(name, parms) { + // Trigger an event bound to a given state instance, on all nodes. + // (or on document, if node = null) + // if no other nodes execute. + var executed = 0; // Normal rules. If any of those match, execute them too // each on the node that it selects - not on the original node. - var opers = kukit.er.binderInstanceRegistry.getBinding(this, name); + var oper = new kukit.op.Oper(); + var opers = oper.getBinding(this, name); for (var i=0; i