You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by eh...@apache.org on 2007/06/24 22:17:21 UTC
svn commit: r550281 [3/3] - in
/incubator/wicket/trunk/jdk-1.4/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui:
VERSION calendar/VERSION calendar/assets/calendar.css calendar/calendar.js
dom.js event.js yahoo.js
Modified: incubator/wicket/trunk/jdk-1.4/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/dom.js
URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/dom.js?view=diff&rev=550281&r1=550280&r2=550281
==============================================================================
--- incubator/wicket/trunk/jdk-1.4/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/dom.js (original)
+++ incubator/wicket/trunk/jdk-1.4/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/dom.js Sun Jun 24 13:17:19 2007
@@ -1,8 +1,8 @@
/*
-Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Copyright (c) 2007, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.net/yui/license.txt
-version: 0.12.2
+version: 2.2.2
*/
/**
* The dom module provides helper methods for manipulating Dom elements.
@@ -26,10 +26,10 @@
// regex cache
var patterns = {
- HYPHEN: /(-[a-z])/i
+ HYPHEN: /(-[a-z])/i, // to normalize get/setStyle
+ ROOT_TAG: /body|html/i // body for quirks mode, html for standards
};
-
var toCamel = function(property) {
if ( !patterns.HYPHEN.test(property) ) {
return property; // no hyphens
@@ -38,14 +38,16 @@
if (propertyCache[property]) { // already converted
return propertyCache[property];
}
-
- while( patterns.HYPHEN.exec(property) ) {
- property = property.replace(RegExp.$1,
+
+ var converted = property;
+
+ while( patterns.HYPHEN.exec(converted) ) {
+ converted = converted.replace(RegExp.$1,
RegExp.$1.substr(1).toUpperCase());
}
- propertyCache[property] = property;
- return property;
+ propertyCache[property] = converted;
+ return converted;
//return property.replace(/-([a-z])/gi, function(m0, m1) {return m1.toUpperCase()}) // cant use function as 2nd arg yet due to safari bug
};
@@ -54,6 +56,10 @@
getStyle = function(el, property) {
var value = null;
+ if (property == 'float') { // fix reserved word
+ property = 'cssFloat';
+ }
+
var computed = document.defaultView.getComputedStyle(el, '');
if (computed) { // test computed before touching for safari
value = computed[toCamel(property)];
@@ -77,6 +83,8 @@
}
return val / 100;
break;
+ case 'float': // fix reserved word
+ property = 'styleFloat'; // fall through
default:
// test currentStyle before touching
var value = el.currentStyle ? el.currentStyle[property] : null;
@@ -91,7 +99,7 @@
setStyle = function(el, property, val) {
switch (property) {
case 'opacity':
- if ( typeof el.style.filter == 'string' ) { // in case not appended
+ if ( YAHOO.lang.isString(el.style.filter) ) { // in case not appended
el.style.filter = 'alpha(opacity=' + val * 100 + ')';
if (!el.currentStyle || !el.currentStyle.hasLayout) {
@@ -99,12 +107,17 @@
}
}
break;
+ case 'float':
+ property = 'styleFloat';
default:
el.style[property] = val;
}
};
} else {
setStyle = function(el, property, val) {
+ if (property == 'float') {
+ property = 'cssFloat';
+ }
el.style[property] = val;
};
}
@@ -122,25 +135,24 @@
* @return {HTMLElement | Array} A DOM reference to an HTML element or an array of HTMLElements.
*/
get: function(el) {
- if (!el) { return null; } // nothing to work with
-
- if (typeof el != 'string' && !(el instanceof Array) ) { // assuming HTMLElement or HTMLCollection, so pass back as is
- return el;
- }
-
- if (typeof el == 'string') { // ID
+ if ( YAHOO.lang.isString(el) ) { // ID
return document.getElementById(el);
}
- else { // array of ID's and/or elements
- var collection = [];
+
+ if ( YAHOO.lang.isArray(el) ) { // Array of IDs and/or HTMLElements
+ var c = [];
for (var i = 0, len = el.length; i < len; ++i) {
- collection[collection.length] = Y.Dom.get(el[i]);
+ c[c.length] = Y.Dom.get(el[i]);
}
- return collection;
+ return c;
}
- return null; // safety, should never happen
+ if (el) { // assuming HTMLElement or HTMLCollection, just pass back
+ return el;
+ }
+
+ return null; // el is likely null or undefined
},
/**
@@ -188,8 +200,8 @@
var f = function(el) {
// has to be part of document to have pageXY
- if (el.parentNode === null || el.offsetParent === null ||
- this.getStyle(el, 'display') == 'none') {
+ if ( (el.parentNode === null || el.offsetParent === null ||
+ this.getStyle(el, 'display') == 'none') && el != document.body) {
return false;
}
@@ -217,32 +229,40 @@
else { // safari, opera, & gecko
pos = [el.offsetLeft, el.offsetTop];
parentNode = el.offsetParent;
+
+ // safari: if el is abs or any parent is abs, subtract body offsets
+ var hasAbs = this.getStyle(el, 'position') == 'absolute';
+
if (parentNode != el) {
while (parentNode) {
pos[0] += parentNode.offsetLeft;
pos[1] += parentNode.offsetTop;
+ if (isSafari && !hasAbs &&
+ this.getStyle(parentNode,'position') == 'absolute' ) {
+ hasAbs = true; // we need to offset if any parent is absolutely positioned
+ }
parentNode = parentNode.offsetParent;
}
}
- if (isSafari && this.getStyle(el, 'position') == 'absolute' ) { // safari doubles in some cases
+
+ if (isSafari && hasAbs) { //safari doubles in this case
pos[0] -= document.body.offsetLeft;
pos[1] -= document.body.offsetTop;
}
}
- if (el.parentNode) { parentNode = el.parentNode; }
- else { parentNode = null; }
-
- while (parentNode && parentNode.tagName.toUpperCase() != 'BODY' && parentNode.tagName.toUpperCase() != 'HTML')
- { // account for any scrolled ancestors
- if (Y.Dom.getStyle(parentNode, 'display') != 'inline') { // work around opera inline scrollLeft/Top bug
+ parentNode = el.parentNode;
+
+ // account for any scrolled ancestors
+ while ( parentNode.tagName && !patterns.ROOT_TAG.test(parentNode.tagName) )
+ {
+ // work around opera inline scrollLeft/Top bug
+ if (Y.Dom.getStyle(parentNode, 'display') != 'inline') {
pos[0] -= parentNode.scrollLeft;
pos[1] -= parentNode.scrollTop;
}
- if (parentNode.parentNode) {
- parentNode = parentNode.parentNode;
- } else { parentNode = null; }
+ parentNode = parentNode.parentNode;
}
@@ -414,7 +434,7 @@
var re = new RegExp('(?:^|\\s+)' + className + '(?:\\s+|$)');
var f = function(el) {
- return re.test(el['className']);
+ return re.test(el.className);
};
return Y.Dom.batch(el, f, Y.Dom, true);
@@ -431,7 +451,7 @@
if (this.hasClass(el, className)) { return; } // already present
- el['className'] = [el['className'], className].join(' ');
+ el.className = [el.className, className].join(' ');
};
Y.Dom.batch(el, f, Y.Dom, true);
@@ -447,11 +467,13 @@
var re = new RegExp('(?:^|\\s+)' + className + '(?:\\s+|$)', 'g');
var f = function(el) {
- if (!this.hasClass(el, className)) { return; } // not present
-
+ if (!this.hasClass(el, className)) {
+ return; // not present
+ }
+
- var c = el['className'];
- el['className'] = c.replace(re, ' ');
+ var c = el.className;
+ el.className = c.replace(re, ' ');
if ( this.hasClass(el, className) ) { // in case of multiple adjacent
this.removeClass(el, className);
}
@@ -483,7 +505,7 @@
return; // note return
}
- el['className'] = el['className'].replace(re, ' ' + newClassName + ' ');
+ el.className = el.className.replace(re, ' ' + newClassName + ' ');
if ( this.hasClass(el, oldClassName) ) { // in case of multiple adjacent
this.replaceClass(el, oldClassName, newClassName);
@@ -582,6 +604,7 @@
* @param {String} tag (optional) The tag name of the elements being collected
* @param {String | HTMLElement} root (optional) The HTMLElement or an ID to use as the starting point
+ * @return {Array} Array of HTMLElements
*/
getElementsBy: function(method, tag, root) {
tag = tag || '*';
@@ -856,6 +879,7 @@
/////////////////////////////////////////////////////////////////////////////
+
/**
* A point is a region that is special in that it represents a single point on
* the grid.
@@ -890,3 +914,4 @@
YAHOO.util.Point.prototype = new YAHOO.util.Region();
+YAHOO.register("dom", YAHOO.util.Dom, {version: "2.2.2", build: "204"});
Modified: incubator/wicket/trunk/jdk-1.4/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/event.js
URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/event.js?view=diff&rev=550281&r1=550280&r2=550281
==============================================================================
--- incubator/wicket/trunk/jdk-1.4/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/event.js (original)
+++ incubator/wicket/trunk/jdk-1.4/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/event.js Sun Jun 24 13:17:19 2007
@@ -1,9 +1,10 @@
/*
-Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Copyright (c) 2007, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.net/yui/license.txt
-version: 0.12.2
+version: 2.2.2
*/
+
/**
* The CustomEvent class lets you define events for your application
* that can be subscribed to by one or more independent component.
@@ -144,6 +145,11 @@
* the execution scope.
*/
subscribe: function(fn, obj, override) {
+
+ if (!fn) {
+throw new Error("Invalid callback for subscriber to '" + this.type + "'");
+ }
+
if (this.subscribeEvent) {
this.subscribeEvent.fire(fn, obj, override);
}
@@ -152,13 +158,23 @@
},
/**
- * Unsubscribes the caller from this event
+ * Unsubscribes subscribers.
* @method unsubscribe
- * @param {Function} fn The function to execute
- * @param {Object} obj The custom object passed to subscribe (optional)
+ * @param {Function} fn The subscribed function to remove, if not supplied
+ * all will be removed
+ * @param {Object} obj The custom object passed to subscribe. This is
+ * optional, but if supplied will be used to
+ * disambiguate multiple listeners that are the same
+ * (e.g., you subscribe many object using a function
+ * that lives on the prototype)
* @return {boolean} True if the subscriber was found and detached.
*/
unsubscribe: function(fn, obj) {
+
+ if (!fn) {
+ return this.unsubscribeAll();
+ }
+
var found = false;
for (var i=0, len=this.subscribers.length; i<len; ++i) {
var s = this.subscribers[i];
@@ -237,11 +253,14 @@
/**
* Removes all listeners
* @method unsubscribeAll
+ * @return {int} The number of listeners unsubscribed
*/
unsubscribeAll: function() {
for (var i=0, len=this.subscribers.length; i<len; ++i) {
this._delete(len - 1 - i);
}
+
+ return i;
},
/**
@@ -366,6 +385,9 @@
*/
// The first instance of Event will win if it is loaded more than once.
+// @TODO this needs to be changed so that only the state data that needs to
+// be preserved is kept, while methods are overwritten/added as needed.
+// This means that the module pattern can't be used.
if (!YAHOO.util.Event) {
/**
@@ -388,6 +410,15 @@
var loadComplete = false;
/**
+ * True when the document is initially usable
+ * @property DOMReady
+ * @type boolean
+ * @static
+ * @private
+ */
+ var DOMReady = false;
+
+ /**
* Cache of wrapped listeners
* @property listeners
* @type array
@@ -456,8 +487,17 @@
* @private
*/
var counter = 0;
+
+ /**
+ * addListener/removeListener can throw errors in unexpected scenarios.
+ * These errors are suppressed, the method returns false, and this property
+ * is set
+ * @property lastError
+ * @type Error
+ */
+ var lastError = null;
- return { // PREPROCESS
+ return {
/**
* The number of times we should look for elements that are not
@@ -479,7 +519,7 @@
* @static
* @final
*/
- POLL_INTERVAL: 20,
+ POLL_INTERVAL: 10,
/**
* Element to bind, int constant
@@ -540,13 +580,42 @@
/**
* Safari detection is necessary to work around the preventDefault
* bug that makes it so you can't cancel a href click from the
- * handler. There is not a capabilities check we can use here.
+ * handler. Since this function has been used outside of this
+ * utility, it was changed to detect all KHTML browser to be more
+ * friendly towards the non-Safari browsers that share the engine.
+ * Internally, the preventDefault bug detection now uses the
+ * webkit property.
* @property isSafari
* @private
* @static
+ * @deprecated
*/
- isSafari: (/Safari|Konqueror|KHTML/gi).test(navigator.userAgent),
-
+ isSafari: (/KHTML/gi).test(navigator.userAgent),
+
+ /**
+ * If WebKit is detected, we keep track of the version number of
+ * the engine. The webkit property will contain a string with
+ * the webkit version number if webkit is detected, null
+ * otherwise.
+ * Safari 1.3.2 (312.6): 312.8.1 <-- currently the latest
+ * available on Mac OSX 10.3.
+ * Safari 2.0.2: 416 <-- hasOwnProperty introduced
+ * Safari 2.0.4: 418 <-- preventDefault fixed (I believe)
+ * Safari 2.0.4 (419.3): 418.9.1 <-- current release
+ *
+ * http://developer.apple.com/internet/safari/uamatrix.html
+ * @property webkit
+ * @type string
+ * @static
+ */
+ webkit: function() {
+ var v=navigator.userAgent.match(/AppleWebKit\/([^ ]*)/);
+ if (v&&v[1]) {
+ return v[1];
+ }
+ return null;
+ }(),
+
/**
* IE detection needed to properly calculate pageX and pageY.
* capabilities checking didn't seem to work because another
@@ -556,7 +625,7 @@
* @private
* @static
*/
- isIE: (!this.isSafari && !navigator.userAgent.match(/opera/gi) &&
+ isIE: (!this.webkit && !navigator.userAgent.match(/opera/gi) &&
navigator.userAgent.match(/msie/gi)),
/**
@@ -576,7 +645,6 @@
var self = this;
var callback = function() { self._tryPreloadAttach(); };
this._interval = setInterval(callback, this.POLL_INTERVAL);
- // this.timeout = setTimeout(callback, i);
}
},
@@ -605,12 +673,29 @@
obj: p_obj,
override: p_override,
checkReady: false } );
-
retryCount = this.POLL_RETRYS;
this.startInterval();
},
/**
+ * Executes the supplied callback when the DOM is first usable.
+ *
+ * @method onDOMReady
+ *
+ * @param {function} p_fn what to execute when the element is found.
+ * @param {object} p_obj an optional object to be passed back as
+ * a parameter to p_fn.
+ * @param {boolean} p_scope If set to true, p_fn will execute
+ * in the scope of p_obj, if set to an object it
+ * will execute in the scope of that object
+ *
+ * @static
+ */
+ onDOMReady: function(p_fn, p_obj, p_override) {
+ this.DOMReadyEvent.subscribe(p_fn, p_obj, p_override);
+ },
+
+ /**
* Works the same way as onAvailable, but additionally checks the
* state of sibling elements to determine if the content of the
* available element is safe to modify.
@@ -658,6 +743,7 @@
*/
addListener: function(el, sType, fn, obj, override) {
+
if (!fn || !fn.call) {
return false;
}
@@ -768,9 +854,10 @@
} else {
try {
this._simpleAdd(el, sType, wrappedFn, false);
- } catch(e) {
+ } catch(ex) {
// handle an error trying to attach an event. If it fails
// we need to clean up the cache
+ this.lastError = ex;
this.removeListener(el, sType, fn);
return false;
}
@@ -788,18 +875,27 @@
* @private
*/
fireLegacyEvent: function(e, legacyIndex) {
- var ok = true;
-
- var le = legacyHandlers[legacyIndex];
- for (var i=0,len=le.length; i<len; ++i) {
- var li = le[i];
+ var ok=true,le,lh,li,scope,ret;
+
+ lh = legacyHandlers[legacyIndex];
+ for (var i=0,len=lh.length; i<len; ++i) {
+ li = lh[i];
if ( li && li[this.WFN] ) {
- var scope = li[this.ADJ_SCOPE];
- var ret = li[this.WFN].call(scope, e);
+ scope = li[this.ADJ_SCOPE];
+ ret = li[this.WFN].call(scope, e);
ok = (ok && ret);
}
}
+ // Fire the original handler if we replaced one. We fire this
+ // after the other events to keep stopPropagation/preventDefault
+ // that happened in the DOM0 handler from touching our DOM2
+ // substitute
+ le = legacyEvents[legacyIndex];
+ if (le && le[2]) {
+ le[2](e);
+ }
+
return ok;
},
@@ -821,16 +917,16 @@
/**
* Logic that determines when we should automatically use legacy
- * events instead of DOM2 events.
+ * events instead of DOM2 events. Currently this is limited to old
+ * Safari browsers with a broken preventDefault
* @method useLegacyEvent
* @static
* @private
*/
useLegacyEvent: function(el, sType) {
- if (!el.addEventListener && !el.attachEvent) {
- return true;
- } else if (this.isSafari) {
- if ("click" == sType || "dblclick" == sType) {
+ if (this.webkit && ("click"==sType || "dblclick"==sType)) {
+ var v = parseInt(this.webkit, 10);
+ if (!isNaN(v) && v<418) {
return true;
}
}
@@ -872,6 +968,7 @@
return this.purgeElement(el, false, sType);
}
+
if ("unload" == sType) {
for (i=0, len=unloadListeners.length; i<len; i++) {
@@ -927,7 +1024,8 @@
} else {
try {
this._simpleRemove(el, sType, cacheItem[this.WFN], false);
- } catch(e) {
+ } catch(ex) {
+ this.lastError = ex;
return false;
}
}
@@ -1013,6 +1111,7 @@
}
}
+
return y;
},
@@ -1060,7 +1159,8 @@
var t = new Date().getTime();
try {
ev.time = t;
- } catch(e) {
+ } catch(ex) {
+ this.lastError = ex;
return t;
}
}
@@ -1187,6 +1287,7 @@
return id;
},
+
/**
* We want to be able to use getElementsByTagName as a collection
* to attach a group of events to. Unfortunately, different
@@ -1200,9 +1301,6 @@
* @private
*/
_isValidCollection: function(o) {
- // this.logger.debug(o.constructor.toString())
- // this.logger.debug(typeof o)
-
return ( o && // o is something
o.length && // o is indexed
typeof o != "string" && // o is not a string
@@ -1217,6 +1315,7 @@
* @property elCache
* DOM element cache
* @static
+ * @deprecated Elements are not cached any longer
*/
elCache: {},
@@ -1226,6 +1325,7 @@
* @method getEl
* @static
* @private
+ * @deprecated Elements are not cached any longer
*/
getEl: function(id) {
return document.getElementById(id);
@@ -1241,18 +1341,50 @@
clearCache: function() { },
/**
+ * Custom event the fires when the dom is initially usable
+ * @event DOMReadyEvent
+ */
+ DOMReadyEvent: new YAHOO.util.CustomEvent("DOMReady", this),
+
+ /**
* hook up any deferred listeners
* @method _load
* @static
* @private
*/
_load: function(e) {
- loadComplete = true;
- var EU = YAHOO.util.Event;
- // Remove the listener to assist with the IE memory issue, but not
- // for other browsers because FF 1.0x does not like it.
- if (this.isIE) {
- EU._simpleRemove(window, "load", EU._load);
+ if (!loadComplete) {
+ loadComplete = true;
+ var EU = YAHOO.util.Event;
+
+ // just in case DOMReady did not go off for some reason
+ EU._ready();
+
+ // Remove the listener to assist with the IE memory issue, but not
+ // for other browsers because FF 1.0x does not like it.
+ if (this.isIE) {
+ EU._simpleRemove(window, "load", EU._load);
+ }
+ }
+ },
+
+ /**
+ * Fires the DOMReady event listeners the first time the document is
+ * usable.
+ * @method _ready
+ * @static
+ * @private
+ */
+ _ready: function(e) {
+ if (!DOMReady) {
+ DOMReady=true;
+ var EU = YAHOO.util.Event;
+
+ // Fire the content ready custom event
+ EU.DOMReadyEvent.fire();
+
+ // Remove the DOMContentLoaded (FF/Opera)
+ EU._simpleRemove(document, "DOMContentLoaded", EU._ready);
}
},
@@ -1270,6 +1402,11 @@
return false;
}
+
+ if (this.isIE && !DOMReady) {
+ return false;
+ }
+
this.locked = true;
@@ -1284,32 +1421,46 @@
// onAvailable
var notAvail = [];
- for (var i=0,len=onAvailStack.length; i<len ; ++i) {
- var item = onAvailStack[i];
- if (item) {
- var el = this.getEl(item.id);
+
+ var executeItem = function (el, item) {
+ var scope = el;
+ if (item.override) {
+ if (item.override === true) {
+ scope = item.obj;
+ } else {
+ scope = item.override;
+ }
+ }
+ item.fn.call(scope, item.obj);
+ };
+
+ var i,len,item,el;
+
+ // onAvailable
+ for (i=0,len=onAvailStack.length; i<len; ++i) {
+ item = onAvailStack[i];
+ if (item && !item.checkReady) {
+ el = this.getEl(item.id);
+ if (el) {
+ executeItem(el, item);
+ onAvailStack[i] = null;
+ } else {
+ notAvail.push(item);
+ }
+ }
+ }
+
+ // onContentReady
+ for (i=0,len=onAvailStack.length; i<len; ++i) {
+ item = onAvailStack[i];
+ if (item && item.checkReady) {
+ el = this.getEl(item.id);
if (el) {
// The element is available, but not necessarily ready
- // @todo verify IE7 compatibility
// @todo should we test parentNode.nextSibling?
- // @todo re-evaluate global content ready
- if ( !item.checkReady ||
- loadComplete ||
- el.nextSibling ||
- (document && document.body) ) {
-
- var scope = el;
- if (item.override) {
- if (item.override === true) {
- scope = item.obj;
- } else {
- scope = item.override;
- }
- }
- item.fn.call(scope, item.obj);
- //delete onAvailStack[i];
- // null out instead of delete for Opera
+ if (loadComplete || el.nextSibling) {
+ executeItem(el, item);
onAvailStack[i] = null;
}
} else {
@@ -1380,24 +1531,35 @@
* @static
*/
getListeners: function(el, sType) {
- var elListeners = [];
- if (listeners && listeners.length > 0) {
- for (var i=0,len=listeners.length; i<len ; ++i) {
- var l = listeners[i];
- if ( l && l[this.EL] === el &&
- (!sType || sType === l[this.TYPE]) ) {
- elListeners.push({
- type: l[this.TYPE],
- fn: l[this.FN],
- obj: l[this.OBJ],
- adjust: l[this.ADJ_SCOPE],
- index: i
- });
+ var results=[], searchLists;
+ if (!sType) {
+ searchLists = [listeners, unloadListeners];
+ } else if (sType == "unload") {
+ searchLists = [unloadListeners];
+ } else {
+ searchLists = [listeners];
+ }
+
+ for (var j=0;j<searchLists.length; ++j) {
+ var searchList = searchLists[j];
+ if (searchList && searchList.length > 0) {
+ for (var i=0,len=searchList.length; i<len ; ++i) {
+ var l = searchList[i];
+ if ( l && l[this.EL] === el &&
+ (!sType || sType === l[this.TYPE]) ) {
+ results.push({
+ type: l[this.TYPE],
+ fn: l[this.FN],
+ obj: l[this.OBJ],
+ adjust: l[this.ADJ_SCOPE],
+ index: i
+ });
+ }
}
}
}
- return (elListeners.length) ? elListeners : null;
+ return (results.length) ? results : null;
},
/**
@@ -1500,6 +1662,16 @@
return [0, 0];
}
},
+
+ /**
+ * Used by old versions of CustomEvent, restored for backwards
+ * compatibility
+ * @method regCE
+ * @private
+ */
+ regCE: function() {
+ // does nothing
+ },
/**
* Adds a DOM event directly without the caching, cleanup, scope adj, etc
@@ -1565,21 +1737,62 @@
*/
EU.on = EU.addListener;
- // YAHOO.mix(EU, YAHOO.util.EventProvider.prototype);
- // EU.createEvent("DOMContentReady");
- // EU.subscribe("DOMContentReady", EU._load);
+ /////////////////////////////////////////////////////////////
+ // DOMReady
+ // based on work by: Dean Edwards/John Resig/Matthias Miller
+
+ // Internet Explorer: use the readyState of a defered script.
+ // This isolates what appears to be a safe moment to manipulate
+ // the DOM prior to when the document's readyState suggests
+ // it is safe to do so.
+ if (EU.isIE) {
+
+ document.write(
+'<scr' + 'ipt id="_yui_eu_dr" defer="true" src="//:"></script>');
+
+ var el = document.getElementById("_yui_eu_dr");
+ el.onreadystatechange = function() {
+ if ("complete" == this.readyState) {
+ this.parentNode.removeChild(this);
+ YAHOO.util.Event._ready();
+ }
+ };
+
+ el=null;
+
+ // Process onAvailable/onContentReady items when when the
+ // DOM is ready.
+ YAHOO.util.Event.onDOMReady(
+ YAHOO.util.Event._tryPreloadAttach,
+ YAHOO.util.Event, true);
+
+ // Safari: The document's readyState in Safari currently will
+ // change to loaded/complete before images are loaded.
+ } else if (EU.webkit) {
+
+ EU._drwatch = setInterval(function(){
+ var rs=document.readyState;
+ if ("loaded" == rs || "complete" == rs) {
+ clearInterval(EU._drwatch);
+ EU._drwatch = null;
+ EU._ready();
+ }
+ }, EU.POLL_INTERVAL);
- if (document && document.body) {
- EU._load();
+ // FireFox and Opera: These browsers provide a event for this
+ // moment.
} else {
- // EU._simpleAdd(document, "DOMContentLoaded", EU._load);
- EU._simpleAdd(window, "load", EU._load);
+
+ EU._simpleAdd(document, "DOMContentLoaded", EU._ready);
+
}
+ /////////////////////////////////////////////////////////////
+
+ EU._simpleAdd(window, "load", EU._load);
EU._simpleAdd(window, "unload", EU._unload);
EU._tryPreloadAttach();
})();
}
-
/**
* EventProvider is designed to be used with YAHOO.augment to wrap
* CustomEvents in an interface that allows events to be subscribed to
@@ -1640,11 +1853,16 @@
},
/**
- * Unsubscribes the from the specified event
+ * Unsubscribes one or more listeners the from the specified event
* @method unsubscribe
* @param p_type {string} The type, or name of the event
- * @param p_fn {Function} The function to execute
- * @param p_obj {Object} The custom object passed to subscribe (optional)
+ * @param p_fn {Function} The subscribed function to unsubscribe, if not
+ * supplied, all subscribers will be removed.
+ * @param p_obj {Object} The custom object passed to subscribe. This is
+ * optional, but if supplied will be used to
+ * disambiguate multiple listeners that are the same
+ * (e.g., you subscribe many object using a function
+ * that lives on the prototype)
* @return {boolean} true if the subscriber was found and detached.
*/
unsubscribe: function(p_type, p_fn, p_obj) {
@@ -1656,6 +1874,15 @@
return false;
}
},
+
+ /**
+ * Removes all listeners from the specified event
+ * @method unsubscribeAll
+ * @param p_type {string} The type, or name of the event
+ */
+ unsubscribeAll: function(p_type) {
+ return this.unsubscribe(p_type);
+ },
/**
* Creates a new custom event of the specified type. If a custom event
@@ -1720,6 +1947,7 @@
return events[p_type];
},
+
/**
* Fire a custom event by name. The callback functions will be executed
* from the scope specified when the event was created, and with the
@@ -1769,3 +1997,187 @@
};
+/**
+* KeyListener is a utility that provides an easy interface for listening for
+* keydown/keyup events fired against DOM elements.
+* @namespace YAHOO.util
+* @class KeyListener
+* @constructor
+* @param {HTMLElement} attachTo The element or element ID to which the key
+* event should be attached
+* @param {String} attachTo The element or element ID to which the key
+* event should be attached
+* @param {Object} keyData The object literal representing the key(s)
+* to detect. Possible attributes are
+* shift(boolean), alt(boolean), ctrl(boolean)
+* and keys(either an int or an array of ints
+* representing keycodes).
+* @param {Function} handler The CustomEvent handler to fire when the
+* key event is detected
+* @param {Object} handler An object literal representing the handler.
+* @param {String} event Optional. The event (keydown or keyup) to
+* listen for. Defaults automatically to keydown.
+*/
+YAHOO.util.KeyListener = function(attachTo, keyData, handler, event) {
+ if (!attachTo) {
+ } else if (!keyData) {
+ } else if (!handler) {
+ }
+
+ if (!event) {
+ event = YAHOO.util.KeyListener.KEYDOWN;
+ }
+
+ /**
+ * The CustomEvent fired internally when a key is pressed
+ * @event keyEvent
+ * @private
+ * @param {Object} keyData The object literal representing the key(s) to
+ * detect. Possible attributes are shift(boolean),
+ * alt(boolean), ctrl(boolean) and keys(either an
+ * int or an array of ints representing keycodes).
+ */
+ var keyEvent = new YAHOO.util.CustomEvent("keyPressed");
+
+ /**
+ * The CustomEvent fired when the KeyListener is enabled via the enable()
+ * function
+ * @event enabledEvent
+ * @param {Object} keyData The object literal representing the key(s) to
+ * detect. Possible attributes are shift(boolean),
+ * alt(boolean), ctrl(boolean) and keys(either an
+ * int or an array of ints representing keycodes).
+ */
+ this.enabledEvent = new YAHOO.util.CustomEvent("enabled");
+
+ /**
+ * The CustomEvent fired when the KeyListener is disabled via the
+ * disable() function
+ * @event disabledEvent
+ * @param {Object} keyData The object literal representing the key(s) to
+ * detect. Possible attributes are shift(boolean),
+ * alt(boolean), ctrl(boolean) and keys(either an
+ * int or an array of ints representing keycodes).
+ */
+ this.disabledEvent = new YAHOO.util.CustomEvent("disabled");
+
+ if (typeof attachTo == 'string') {
+ attachTo = document.getElementById(attachTo);
+ }
+
+ if (typeof handler == 'function') {
+ keyEvent.subscribe(handler);
+ } else {
+ keyEvent.subscribe(handler.fn, handler.scope, handler.correctScope);
+ }
+
+ /**
+ * Handles the key event when a key is pressed.
+ * @method handleKeyPress
+ * @param {DOMEvent} e The keypress DOM event
+ * @param {Object} obj The DOM event scope object
+ * @private
+ */
+ function handleKeyPress(e, obj) {
+ if (! keyData.shift) {
+ keyData.shift = false;
+ }
+ if (! keyData.alt) {
+ keyData.alt = false;
+ }
+ if (! keyData.ctrl) {
+ keyData.ctrl = false;
+ }
+
+ // check held down modifying keys first
+ if (e.shiftKey == keyData.shift &&
+ e.altKey == keyData.alt &&
+ e.ctrlKey == keyData.ctrl) { // if we pass this, all modifiers match
+
+ var dataItem;
+ var keyPressed;
+
+ if (keyData.keys instanceof Array) {
+ for (var i=0;i<keyData.keys.length;i++) {
+ dataItem = keyData.keys[i];
+
+ if (dataItem == e.charCode ) {
+ keyEvent.fire(e.charCode, e);
+ break;
+ } else if (dataItem == e.keyCode) {
+ keyEvent.fire(e.keyCode, e);
+ break;
+ }
+ }
+ } else {
+ dataItem = keyData.keys;
+ if (dataItem == e.charCode ) {
+ keyEvent.fire(e.charCode, e);
+ } else if (dataItem == e.keyCode) {
+ keyEvent.fire(e.keyCode, e);
+ }
+ }
+ }
+ }
+
+ /**
+ * Enables the KeyListener by attaching the DOM event listeners to the
+ * target DOM element
+ * @method enable
+ */
+ this.enable = function() {
+ if (! this.enabled) {
+ YAHOO.util.Event.addListener(attachTo, event, handleKeyPress);
+ this.enabledEvent.fire(keyData);
+ }
+ /**
+ * Boolean indicating the enabled/disabled state of the Tooltip
+ * @property enabled
+ * @type Boolean
+ */
+ this.enabled = true;
+ };
+
+ /**
+ * Disables the KeyListener by removing the DOM event listeners from the
+ * target DOM element
+ * @method disable
+ */
+ this.disable = function() {
+ if (this.enabled) {
+ YAHOO.util.Event.removeListener(attachTo, event, handleKeyPress);
+ this.disabledEvent.fire(keyData);
+ }
+ this.enabled = false;
+ };
+
+ /**
+ * Returns a String representation of the object.
+ * @method toString
+ * @return {String} The string representation of the KeyListener
+ */
+ this.toString = function() {
+ return "KeyListener [" + keyData.keys + "] " + attachTo.tagName +
+ (attachTo.id ? "[" + attachTo.id + "]" : "");
+ };
+
+};
+
+/**
+* Constant representing the DOM "keydown" event.
+* @property YAHOO.util.KeyListener.KEYDOWN
+* @static
+* @final
+* @type String
+*/
+YAHOO.util.KeyListener.KEYDOWN = "keydown";
+
+/**
+* Constant representing the DOM "keyup" event.
+* @property YAHOO.util.KeyListener.KEYUP
+* @static
+* @final
+* @type String
+*/
+YAHOO.util.KeyListener.KEYUP = "keyup";
+YAHOO.register("event", YAHOO.util.Event, {version: "2.2.2", build: "204"});
Modified: incubator/wicket/trunk/jdk-1.4/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/yahoo.js
URL: http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.4/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/yahoo.js?view=diff&rev=550281&r1=550280&r2=550281
==============================================================================
--- incubator/wicket/trunk/jdk-1.4/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/yahoo.js (original)
+++ incubator/wicket/trunk/jdk-1.4/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/yahoo.js Sun Jun 24 13:17:19 2007
@@ -1,8 +1,8 @@
/*
-Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Copyright (c) 2007, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.net/yui/license.txt
-version: 0.12.2
+version: 2.2.2
*/
/**
* The YAHOO object is the single global object used by YUI Library. It
@@ -13,9 +13,28 @@
* @title YAHOO Global
*/
+/**
+ * YAHOO_config is not included part of the library. Instead it is an object
+ * that can be defined by the implementer immediately before including the
+ * YUI library. The properties included in this object will be used to
+ * configure global properties needed as soon as the library begins to load.
+ * @class YAHOO_config
+ * @static
+ */
+
+/**
+ * A reference to a function that will be executed every time a YAHOO module
+ * is loaded. As parameter, this function will receive the version
+ * information for the module. See <a href="YAHOO.env.html#getVersion">
+ * YAHOO.env.getVersion</a> for the description of the version data structure.
+ * @property listener
+ * @static
+ */
if (typeof YAHOO == "undefined") {
/**
- * The YAHOO global namespace object
+ * The YAHOO global namespace object. If YAHOO is already defined, the
+ * existing YAHOO object will not be overwritten so that defined
+ * namespaces are preserved.
* @class YAHOO
* @static
*/
@@ -45,12 +64,12 @@
*/
YAHOO.namespace = function() {
var a=arguments, o=null, i, j, d;
- for (i=0; i<a.length; ++i) {
+ for (i=0; i<a.length; i=i+1) {
d=a[i].split(".");
o=YAHOO;
// YAHOO is implied, so it is ignored if it is included
- for (j=(d[0] == "YAHOO") ? 1 : 0; j<d.length; ++j) {
+ for (j=(d[0] == "YAHOO") ? 1 : 0; j<d.length; j=j+1) {
o[d[j]]=o[d[j]] || {};
o=o[d[j]];
}
@@ -60,7 +79,8 @@
};
/**
- * Uses YAHOO.widget.Logger to output a log message, if the widget is available.
+ * Uses YAHOO.widget.Logger to output a log message, if the widget is
+ * available.
*
* @method log
* @static
@@ -80,42 +100,321 @@
}
};
+
/**
- * Utility to set up the prototype, constructor and superclass properties to
- * support an inheritance strategy that can chain constructors and methods.
- *
- * @method extend
+ * Initializes the global by creating the default namespaces and applying
+ * any new configuration information that is detected.
+ * @method init
* @static
- * @param {Function} subc the object to modify
- * @param {Function} superc the object to inherit
- * @param {Object} overrides additional properties/methods to add to the
- * subclass prototype. These will override the
- * matching items obtained from the superclass
- * if present.
*/
-YAHOO.extend = function(subc, superc, overrides) {
- var F = function() {};
- F.prototype=superc.prototype;
- subc.prototype=new F();
- subc.prototype.constructor=subc;
- subc.superclass=superc.prototype;
- if (superc.prototype.constructor == Object.prototype.constructor) {
- superc.prototype.constructor=superc;
+YAHOO.init = function() {
+ this.namespace("util", "widget", "example");
+ if (typeof YAHOO_config != "undefined") {
+ var l=YAHOO_config.listener,ls=YAHOO.env.listeners,unique=true,i;
+ if (l) {
+ // if YAHOO is loaded multiple times we need to check to see if
+ // this is a new config object. If it is, add the new component
+ // load listener to the stack
+ for (i=0;i<ls.length;i=i+1) {
+ if (ls[i]==l) {
+ unique=false;
+ break;
+ }
+ }
+ if (unique) {
+ ls.push(l);
+ }
+ }
}
+};
- if (overrides) {
- for (var i in overrides) {
- subc.prototype[i]=overrides[i];
+/**
+ * Registers a module with the YAHOO object
+ * @method register
+ * @static
+ * @param {String} name the name of the module (event, slider, etc)
+ * @param {Function} mainClass a reference to class in the module. This
+ * class will be tagged with the version info
+ * so that it will be possible to identify the
+ * version that is in use when multiple versions
+ * have loaded
+ * @param {Object} data metadata object for the module. Currently it
+ * is expected to contain a "version" property
+ * and a "build" property at minimum.
+ */
+YAHOO.register = function(name, mainClass, data) {
+ var mods = YAHOO.env.modules;
+ if (!mods[name]) {
+ mods[name] = { versions:[], builds:[] };
+ }
+ var m=mods[name],v=data.version,b=data.build,ls=YAHOO.env.listeners;
+ m.name = name;
+ m.version = v;
+ m.build = b;
+ m.versions.push(v);
+ m.builds.push(b);
+ m.mainClass = mainClass;
+ // fire the module load listeners
+ for (var i=0;i<ls.length;i=i+1) {
+ ls[i](m);
+ }
+ // label the main class
+ if (mainClass) {
+ mainClass.VERSION = v;
+ mainClass.BUILD = b;
+ } else {
+ YAHOO.log("mainClass is undefined for module " + name, "warn");
+ }
+};
+
+/**
+ * YAHOO.env is used to keep track of what is known about the YUI library and
+ * the browsing environment
+ * @class YAHOO.env
+ * @type Object
+ * @static
+ */
+YAHOO.env = YAHOO.env || {
+ /**
+ * Keeps the version info for all YUI modules that have reported themselves
+ * @property modules
+ * @type Object[]
+ */
+ modules: [],
+
+ /**
+ * List of functions that should be executed every time a YUI module
+ * reports itself.
+ * @property listeners
+ * @type Function[]
+ */
+ listeners: [],
+
+ /**
+ * Returns the version data for the specified module:
+ * <dl>
+ * <dt>name:</dt> <dd>The name of the module</dd>
+ * <dt>version:</dt> <dd>The version in use</dd>
+ * <dt>build:</dt> <dd>The build number in use</dd>
+ * <dt>versions:</dt> <dd>All versions that were registered</dd>
+ * <dt>builds:</dt> <dd>All builds that were registered.</dd>
+ * <dt>mainClass:</dt> <dd>An object that was was stamped with the
+ * current version and build. If
+ * mainClass.VERSION != version or mainClass.BUILD != build,
+ * multiple versions of pieces of the library have been
+ * loaded, potentially causing issues.</dd>
+ * </dl>
+ *
+ * @method getVersion
+ * @static
+ * @param {String} name the name of the module (event, slider, etc)
+ * @return {Object} The version info
+ */
+ getVersion: function(name) {
+ return YAHOO.env.modules[name] || null;
+ }
+};
+
+/**
+ * Provides the language utilites and extensions used by the library
+ * @class YAHOO.lang
+ */
+YAHOO.lang = {
+ /**
+ * Determines whether or not the provided object is an array
+ * @method isArray
+ * @param {any} obj The object being testing
+ * @return Boolean
+ */
+ isArray: function(obj) { // frames lose type, so test constructor string
+ if (obj && obj.constructor &&
+ obj.constructor.toString().indexOf('Array') > -1) {
+ return true;
+ } else {
+ return YAHOO.lang.isObject(obj) && obj.constructor == Array;
+ }
+ },
+
+ /**
+ * Determines whether or not the provided object is a boolean
+ * @method isBoolean
+ * @param {any} obj The object being testing
+ * @return Boolean
+ */
+ isBoolean: function(obj) {
+ return typeof obj == 'boolean';
+ },
+
+ /**
+ * Determines whether or not the provided object is a function
+ * @method isFunction
+ * @param {any} obj The object being testing
+ * @return Boolean
+ */
+ isFunction: function(obj) {
+ return typeof obj == 'function';
+ },
+
+ /**
+ * Determines whether or not the provided object is null
+ * @method isNull
+ * @param {any} obj The object being testing
+ * @return Boolean
+ */
+ isNull: function(obj) {
+ return obj === null;
+ },
+
+ /**
+ * Determines whether or not the provided object is a legal number
+ * @method isNumber
+ * @param {any} obj The object being testing
+ * @return Boolean
+ */
+ isNumber: function(obj) {
+ return typeof obj == 'number' && isFinite(obj);
+ },
+
+ /**
+ * Determines whether or not the provided object is of type object
+ * or function
+ * @method isObject
+ * @param {any} obj The object being testing
+ * @return Boolean
+ */
+ isObject: function(obj) {
+ return obj && (typeof obj == 'object' || YAHOO.lang.isFunction(obj));
+ },
+
+ /**
+ * Determines whether or not the provided object is a string
+ * @method isString
+ * @param {any} obj The object being testing
+ * @return Boolean
+ */
+ isString: function(obj) {
+ return typeof obj == 'string';
+ },
+
+ /**
+ * Determines whether or not the provided object is undefined
+ * @method isUndefined
+ * @param {any} obj The object being testing
+ * @return Boolean
+ */
+ isUndefined: function(obj) {
+ return typeof obj == 'undefined';
+ },
+
+ /**
+ * Determines whether or not the property was added
+ * to the object instance. Returns false if the property is not present
+ * in the object, or was inherited from the prototype.
+ * This abstraction is provided to enable hasOwnProperty for Safari 1.3.x.
+ * There is a discrepancy between YAHOO.lang.hasOwnProperty and
+ * Object.prototype.hasOwnProperty when the property is a primitive added to
+ * both the instance AND prototype with the same value:
+ * <pre>
+ * var A = function() {};
+ * A.prototype.foo = 'foo';
+ * var a = new A();
+ * a.foo = 'foo';
+ * alert(a.hasOwnProperty('foo')); // true
+ * alert(YAHOO.lang.hasOwnProperty(a, 'foo')); // false when using fallback
+ * </pre>
+ * @method hasOwnProperty
+ * @param {any} obj The object being testing
+ * @return Boolean
+ */
+ hasOwnProperty: function(obj, prop) {
+ if (Object.prototype.hasOwnProperty) {
+ return obj.hasOwnProperty(prop);
+ }
+
+ return !YAHOO.lang.isUndefined(obj[prop]) &&
+ obj.constructor.prototype[prop] !== obj[prop];
+ },
+
+ /**
+ * Utility to set up the prototype, constructor and superclass properties to
+ * support an inheritance strategy that can chain constructors and methods.
+ *
+ * @method extend
+ * @static
+ * @param {Function} subc the object to modify
+ * @param {Function} superc the object to inherit
+ * @param {Object} overrides additional properties/methods to add to the
+ * subclass prototype. These will override the
+ * matching items obtained from the superclass
+ * if present.
+ */
+ extend: function(subc, superc, overrides) {
+ if (!superc||!subc) {
+ throw new Error("YAHOO.lang.extend failed, please check that " +
+ "all dependencies are included.");
+ }
+ var F = function() {};
+ F.prototype=superc.prototype;
+ subc.prototype=new F();
+ subc.prototype.constructor=subc;
+ subc.superclass=superc.prototype;
+ if (superc.prototype.constructor == Object.prototype.constructor) {
+ superc.prototype.constructor=superc;
+ }
+
+ if (overrides) {
+ for (var i in overrides) {
+ subc.prototype[i]=overrides[i];
+ }
+ }
+ },
+
+ /**
+ * Applies all prototype properties in the supplier to the receiver if the
+ * receiver does not have these properties yet. Optionally, one or more
+ * methods/properties can be specified (as additional parameters). This
+ * option will overwrite the property if receiver has it already.
+ *
+ * @method augment
+ * @static
+ * @param {Function} r the object to receive the augmentation
+ * @param {Function} s the object that supplies the properties to augment
+ * @param {String*} arguments zero or more properties methods to augment the
+ * receiver with. If none specified, everything
+ * in the supplier will be used unless it would
+ * overwrite an existing property in the receiver
+ */
+ augment: function(r, s) {
+ if (!s||!r) {
+ throw new Error("YAHOO.lang.augment failed, please check that " +
+ "all dependencies are included.");
+ }
+ var rp=r.prototype, sp=s.prototype, a=arguments, i, p;
+ if (a[2]) {
+ for (i=2; i<a.length; i=i+1) {
+ rp[a[i]] = sp[a[i]];
+ }
+ } else {
+ for (p in sp) {
+ if (!rp[p]) {
+ rp[p] = sp[p];
+ }
+ }
}
}
};
+YAHOO.init();
+
+/*
+ * An alias for <a href="YAHOO.lang.html">YAHOO.lang</a>
+ * @class YAHOO.util.Lang
+ */
+YAHOO.util.Lang = YAHOO.lang;
+
/**
- * Applies all prototype properties in the supplier to the receiver if the
- * receiver does not have these properties yet. Optionally, one or more
- * methods/properties can be specified (as additional parameters). This
- * option will overwrite the property if receiver has it already.
- *
+ * An alias for <a href="YAHOO.lang.html#augment">YAHOO.lang.augment</a>
+ * @for YAHOO
* @method augment
* @static
* @param {Function} r the object to receive the augmentation
@@ -125,19 +424,19 @@
* in the supplier will be used unless it would
* overwrite an existing property in the receiver
*/
-YAHOO.augment = function(r, s) {
- var rp=r.prototype, sp=s.prototype, a=arguments, i, p;
- if (a[2]) {
- for (i=2; i<a.length; ++i) {
- rp[a[i]] = sp[a[i]];
- }
- } else {
- for (p in sp) {
- if (!rp[p]) {
- rp[p] = sp[p];
- }
- }
- }
-};
+YAHOO.augment = YAHOO.lang.augment;
+
+/**
+ * An alias for <a href="YAHOO.lang.html#extend">YAHOO.lang.extend</a>
+ * @method extend
+ * @static
+ * @param {Function} subc the object to modify
+ * @param {Function} superc the object to inherit
+ * @param {Object} overrides additional properties/methods to add to the
+ * subclass prototype. These will override the
+ * matching items obtained from the superclass
+ * if present.
+ */
+YAHOO.extend = YAHOO.lang.extend;
-YAHOO.namespace("util", "widget", "example");
+YAHOO.register("yahoo", YAHOO, {version: "2.2.2", build: "204"});