[KSS-checkins] r49491 - kukit/kukit.js/trunk/kukit
gotcha at codespeak.net
gotcha at codespeak.net
Fri Dec 7 00:57:10 CET 2007
Author: gotcha
Date: Fri Dec 7 00:57:10 2007
New Revision: 49491
Modified:
kukit/kukit.js/trunk/kukit/kukit.js
kukit/kukit.js/trunk/kukit/plugin.js
kukit/kukit.js/trunk/kukit/utils.js
Log:
merge r48953:49490 from finish-closures branch
Modified: kukit/kukit.js/trunk/kukit/kukit.js
==============================================================================
--- kukit/kukit.js/trunk/kukit/kukit.js (original)
+++ kukit/kukit.js/trunk/kukit/kukit.js Fri Dec 7 00:57:10 2007
@@ -17,14 +17,18 @@
* 02111-1307, USA.
*/
-kukit.isDevelMode = false;
-;;; kukit.isDevelMode = true;
+kukit = new function() { /// MODULE START
+
+var ku = this;
+
+ku.isDevelMode = false;
+;;; ku.isDevelMode = true;
/*
* class Engine
*/
-kukit.Engine = function() {
+ku.Engine = function() {
this.baseUrl = this.calculateBase();
this.documentRules = new kukit.rd.MethodTable();
// table from res_type to rule processor
@@ -47,7 +51,7 @@
};
-kukit.Engine.prototype.calculateBase = function() {
+ku.Engine.prototype.calculateBase = function() {
var base = '';
try {
var _dummy = document;
@@ -82,11 +86,11 @@
return base;
};
-kukit.Engine.prototype.getRuleSheetLinks = function() {
+ku.Engine.prototype.getRuleSheetLinks = function() {
var nodes = document.getElementsByTagName("link");
var results = [];
for (var i=0; i<nodes.length; i++) {
- if (kukit.isKineticStylesheet(nodes[i])) {
+ if (_isKineticStylesheet(nodes[i])) {
var res_type = null;
// Resource syntax is decided on type attribute.
if((nodes[i].type == 'text/css') || (nodes[i].type == 'text/kss')) {
@@ -95,14 +99,14 @@
;;; // Just show this, and go on with the processing.
;;; kukit.logError("rel type is not text/css or text/kss");
}
- var newRuleLink = new kukit.RuleSheetLink(nodes[i].href, res_type);
+ var newRuleLink = new _RuleSheetLink(nodes[i].href, res_type);
results[results.length] = newRuleLink;
}
}
return results;
};
-kukit.Engine.prototype.createRuleProcessor = function(rulelink) {
+ku.Engine.prototype.createRuleProcessor = function(rulelink) {
var ruleProcessorClass = this._ruleProcessorClasses[rulelink.res_type];
if (ruleProcessorClass) {
;;; var msg = "Start loading and processing " + rulelink.href;
@@ -120,7 +124,7 @@
};
-kukit.Engine.prototype.getRules = function() {
+ku.Engine.prototype.getRules = function() {
var rules = new Array();
var ruleProcessors = this._ruleProcessors
for (var j=0; j<ruleProcessors.length; j++) {
@@ -132,11 +136,11 @@
return rules;
}
-kukit.Engine.prototype.getRuleProcessors = function() {
+ku.Engine.prototype.getRuleProcessors = function() {
return this._ruleProcessors
}
-kukit.isKineticStylesheet = function(node) {
+var _isKineticStylesheet = function(node) {
var rel = node.rel;
if (rel=="kinetic-stylesheet") {
return true;
@@ -151,7 +155,7 @@
return false;
};
-kukit.Engine.prototype.setupEvents = function(inNodes) {
+ku.Engine.prototype.setupEvents = function(inNodes) {
if (this.setupEventsInProgress) {
// remember them
this.setupEventsQueue = this.setupEventsQueue.concat(inNodes);
@@ -161,18 +165,18 @@
}
};
-kukit.Engine.prototype.beginSetupEventsCollection = function() {
+ku.Engine.prototype.beginSetupEventsCollection = function() {
this.setupEventsInProgress = true;
};
-kukit.Engine.prototype.finishSetupEventsCollection = function() {
+ku.Engine.prototype.finishSetupEventsCollection = function() {
this.setupEventsInProgress = false;
var setupEventsQueue = this.setupEventsQueue;
this.setupEventsQueue = [];
this.doSetupEvents(setupEventsQueue);
};
-kukit.Engine.prototype.doSetupEvents = function(inNodes) {
+ku.Engine.prototype.doSetupEvents = function(inNodes) {
var self = this;
var deferredEventsSetup = function() {
self._setupEvents(inNodes);
@@ -203,7 +207,7 @@
}
};
-kukit.Engine.prototype._setupEvents = function(inNodes) {
+ku.Engine.prototype._setupEvents = function(inNodes) {
// Decide phase. 1=initial, 2=insertion.
var phase;
if (typeof(inNodes) == 'undefined') {
@@ -233,7 +237,7 @@
-kukit.Engine.prototype.initializeRules = function() {
+ku.Engine.prototype.initializeRules = function() {
if (window.kukitRulesInitializing || window.kukitRulesInitialized) {
// Refuse to initialize a second time.
;;; kukit.log('[initializeRules] is called twice.');
@@ -287,7 +291,7 @@
* to allow the event-registration.js hook)
*/
-kukit.initializeRules = function() {
+ku.initializeRules = function() {
;;; var msg = '[kukit.initializeRules] is deprecated,';
;;; msg += 'use [kukit.bootstrap] instead !';
;;; kukit.logWarning(msg);
@@ -295,16 +299,17 @@
};
/*
-* class RuleSheetLink
+* class _RuleSheetLink
*/
-kukit.RuleSheetLink = function(href, res_type) {
+var _RuleSheetLink = function(href, res_type) {
this.href = href;
this.res_type = res_type;
};
-kukit.bootstrap = function() {
-;;; kukit.log('Engine instantiated.');
+ku.bootstrap = function() {
+;;; kukit.log('Instantiate engine.');
var engine = new kukit.Engine();
+;;; kukit.log('Engine instantiated.');
// Successful initializeRules will store the engine as kukit.engine.
// Subsequent activations will not delete the already set up engine.
// Subsequent activations may happen, if more event handlers are set up,
@@ -312,7 +317,7 @@
engine.initializeRules();
};
-kukit.bootstrapFromDOMLoad = function() {
+ku.bootstrapFromDOMLoad = function() {
;;; kukit.log('Engine instantiated in [DOMLoad].');
var engine = new kukit.Engine();
// Successful initializeRules will store the engine as kukit.engine.
@@ -323,7 +328,5 @@
engine.initializeRules();
};
-if (typeof(window) != 'undefined') {
- kukit.ut.registerEventListener(window, "load", kukit.bootstrap);
-}
+}(); /// MODULE END
Modified: kukit/kukit.js/trunk/kukit/plugin.js
==============================================================================
--- kukit/kukit.js/trunk/kukit/plugin.js (original)
+++ kukit/kukit.js/trunk/kukit/plugin.js Fri Dec 7 00:57:10 2007
@@ -975,6 +975,8 @@
//
// allows excess parms in the following check
;;; oper.componentName = '[executeCommand] action';
+;;; var msg = 'Deprecated the [executeCommand] action, use [kssSelector] in a standard action!';
+;;; kukit.logWarning(msg);
oper.evaluateParameters(['name', 'selector'],
{'selectorType': null},
'', true);
Modified: kukit/kukit.js/trunk/kukit/utils.js
==============================================================================
--- kukit/kukit.js/trunk/kukit/utils.js (original)
+++ kukit/kukit.js/trunk/kukit/utils.js Fri Dec 7 00:57:10 2007
@@ -237,44 +237,46 @@
/* utilities */
-kukit.ut = {};
+kukit.ut = new function() { /// MODULE START
+
+var ut = this;
/*
* class FifoQueue
*/
-kukit.ut.FifoQueue = function () {
+ut.FifoQueue = function () {
this.reset();
};
-kukit.ut.FifoQueue.prototype.reset = function() {
+ut.FifoQueue.prototype.reset = function() {
this.elements = new Array();
};
-kukit.ut.FifoQueue.prototype.push = function(obj) {
+ut.FifoQueue.prototype.push = function(obj) {
this.elements.push(obj);
};
-kukit.ut.FifoQueue.prototype.pop = function() {
+ut.FifoQueue.prototype.pop = function() {
return this.elements.shift();
};
-kukit.ut.FifoQueue.prototype.empty = function() {
+ut.FifoQueue.prototype.empty = function() {
return ! this.elements.length;
};
-kukit.ut.FifoQueue.prototype.size = function() {
+ut.FifoQueue.prototype.size = function() {
return this.elements.length;
};
-kukit.ut.FifoQueue.prototype.front = function() {
+ut.FifoQueue.prototype.front = function() {
return this.elements[0];
};
/*
* class SortedQueue
*/
-kukit.ut.SortedQueue = function (comparefunc) {
+ut.SortedQueue = function (comparefunc) {
// comparefunc(left, right) determines the order by returning
// -1 if left should occur before right,
// +1 if left should occur after right or
@@ -287,7 +289,7 @@
this.reset();
};
-kukit.ut.SortedQueue.prototype.comparefunc = function(a, b) {
+ut.SortedQueue.prototype.comparefunc = function(a, b) {
if (a < b) {
return -1;
} else if (a > b) {
@@ -297,11 +299,11 @@
}
};
-kukit.ut.SortedQueue.prototype.reset = function() {
+ut.SortedQueue.prototype.reset = function() {
this.elements = new Array();
};
-kukit.ut.SortedQueue.prototype.push = function(obj) {
+ut.SortedQueue.prototype.push = function(obj) {
// Find the position of the object.
var i = 0;
var length = this.elements.length;
@@ -312,33 +314,33 @@
this.elements.splice(i, 0, obj);
};
-kukit.ut.SortedQueue.prototype.pop = function() {
+ut.SortedQueue.prototype.pop = function() {
// takes minimal element
return this.elements.shift();
};
-kukit.ut.SortedQueue.prototype.popn = function(n) {
+ut.SortedQueue.prototype.popn = function(n) {
// takes first n minimal element
return this.elements.splice(0, n);
};
-kukit.ut.SortedQueue.prototype.empty = function() {
+ut.SortedQueue.prototype.empty = function() {
return ! this.elements.length;
};
-kukit.ut.SortedQueue.prototype.size = function() {
+ut.SortedQueue.prototype.size = function() {
return this.elements.length;
};
-kukit.ut.SortedQueue.prototype.get = function(n) {
+ut.SortedQueue.prototype.get = function(n) {
return this.elements[n];
};
-kukit.ut.SortedQueue.prototype.front = function() {
+ut.SortedQueue.prototype.front = function() {
return this.elements[0];
};
-kukit.ut.evalBool = function(value, errname) {
+ut.evalBool = function(value, errname) {
if (value == 'true' || value == 'True' || value == '1') {
value = true;
} else if (value == 'false' || value == 'False' || value == '0'
@@ -350,7 +352,7 @@
return value;
};
-kukit.ut.evalInt = function(value, errname) {
+ut.evalInt = function(value, errname) {
;;; try {
value = parseInt(value);
;;; } catch(e) {
@@ -359,7 +361,7 @@
return value;
};
-kukit.ut.evalList = function(value, errname) {
+ut.evalList = function(value, errname) {
;;; try {
// remove whitespace from beginning, end
value = value.replace(/^ +/, '');
@@ -384,7 +386,7 @@
*
* for repeating or one time timing
*/
-kukit.ut.TimerCounter = function(delay, func, restart) {
+ut.TimerCounter = function(delay, func, restart) {
this.delay = delay;
this.func = func;
if (typeof(restart) == 'undefined') {
@@ -394,7 +396,7 @@
this.timer = null;
};
-kukit.ut.TimerCounter.prototype.start = function() {
+ut.TimerCounter.prototype.start = function() {
if (this.timer) {
;;; kukit.E = 'Timer already started.';
@@ -407,7 +409,7 @@
this.timer = setTimeout(func, this.delay);
};
-kukit.ut.TimerCounter.prototype.timeout = function() {
+ut.TimerCounter.prototype.timeout = function() {
// Call the event action
this.func();
// Restart the timer
@@ -417,7 +419,7 @@
}
};
-kukit.ut.TimerCounter.prototype.clear = function() {
+ut.TimerCounter.prototype.clear = function() {
if (this.timer) {
window.clearTimeout(this.timer);
this.timer = null;
@@ -428,13 +430,13 @@
/*
* class Scheduler
*/
-kukit.ut.Scheduler = function(func) {
+ut.Scheduler = function(func) {
this.func = func;
this.timer = null;
this.nextWake = null;
};
-kukit.ut.Scheduler.prototype.setNextWake = function(ts) {
+ut.Scheduler.prototype.setNextWake = function(ts) {
// Sets wakeup time, null clears
if (this.nextWake) {
this.clear();
@@ -456,7 +458,7 @@
}
};
-kukit.ut.Scheduler.prototype.setNextWakeAtLeast = function(ts) {
+ut.Scheduler.prototype.setNextWakeAtLeast = function(ts) {
// Sets wakeup time, unless it would wake up later than the
// currently set timeout. Null clears the timer.
if (! ts || ! this.nextWake || ts < this.nextWake) {
@@ -467,7 +469,7 @@
}
};
-kukit.ut.Scheduler.prototype.timeout = function() {
+ut.Scheduler.prototype.timeout = function() {
// clear the timer
this.timer = null;
this.nextWake = null;
@@ -476,7 +478,7 @@
};
-kukit.ut.Scheduler.prototype.clear = function() {
+ut.Scheduler.prototype.clear = function() {
if (this.nextWake) {
window.clearTimeout(this.timer);
this.timer = null;
@@ -489,22 +491,22 @@
*
* Scheduler for serializing bind and load procedures
*/
-kukit.ut.SerializeScheduler = function() {
+ut.SerializeScheduler = function() {
this.items = [];
this.lock = false;
};
-kukit.ut.SerializeScheduler.prototype.addPre = function(func, remark) {
+ut.SerializeScheduler.prototype.addPre = function(func, remark) {
this.items.push({func: func, remark: remark});
this.execute();
};
-kukit.ut.SerializeScheduler.prototype.addPost = function(func, remark) {
+ut.SerializeScheduler.prototype.addPost = function(func, remark) {
this.items.unshift({func: func, remark: remark});
this.execute();
};
-kukit.ut.SerializeScheduler.prototype.execute = function() {
+ut.SerializeScheduler.prototype.execute = function() {
if (! this.lock) {
this.lock = true;
while (true) {
@@ -533,7 +535,7 @@
/* extracted from Plone */
// cross browser function for registering event handlers
-kukit.ut.registerEventListener = function(elem, event, func) {
+ut.registerEventListener = function(elem, event, func) {
if (elem.addEventListener) {
elem.addEventListener(event, func, false);
return true;
@@ -545,22 +547,27 @@
return false;
};
+if (typeof(window) != 'undefined') {
+ ut.registerEventListener(window, "load", kukit.bootstrap);
+}
/* collecting keys-values into a dict or into a tuple list */
-kukit.ut.DictCollector = function() {
+ut.DictCollector = function() {
this.result = {};
};
-kukit.ut.DictCollector.prototype.add = function(key, value) {
+ut.DictCollector.prototype.add = function(key, value) {
this.result[key] = value;
};
-kukit.ut.TupleCollector = function() {
+ut.TupleCollector = function() {
this.result = [];
};
-kukit.ut.TupleCollector.prototype.add = function(key, value) {
+ut.TupleCollector.prototype.add = function(key, value) {
this.result.push([key, value]);
};
+}(); /// MODULE END
+
More information about the Kukit-checkins
mailing list