X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/6746dc89c47ed01b165cc1152533605f97eb8e8d..HEAD:/src/core/src/EventManager.js
diff --git a/src/core/src/EventManager.js b/src/core/src/EventManager.js
index 9f4aa923..fbd33b7c 100644
--- a/src/core/src/EventManager.js
+++ b/src/core/src/EventManager.js
@@ -63,6 +63,7 @@ Ext.EventManager = {
if(window.attachEvent){
// See here for reference: http://javascript.nwbox.com/IEContentLoaded/
+ // licensed courtesy of http://developer.yahoo.com/yui/license.html
if (window != top) {
return false;
}
@@ -145,7 +146,7 @@ Ext.EventManager = {
* accessed shorthanded as Ext.onReady().
* @param {Function} fn The method the event invokes.
* @param {Object} scope (optional) The scope (this
reference) in which the handler function executes. Defaults to the browser window.
- * @param {boolean} options (optional) Options object as passed to {@link Ext.core.Element#addListener}.
+ * @param {Boolean} options (optional) Options object as passed to {@link Ext.Element#addListener}.
*/
onDocumentReady: function(fn, scope, options){
options = options || {};
@@ -183,15 +184,15 @@ Ext.EventManager = {
/**
* Get the id of the element. If one has not been assigned, automatically assign it.
- * @param {Mixed} element The element to get the id for.
+ * @param {HTMLElement/Ext.Element} element The element to get the id for.
* @return {String} id
*/
getId : function(element) {
var skipGarbageCollection = false,
id;
-
+
element = Ext.getDom(element);
-
+
if (element === document || element === window) {
id = element === document ? Ext.documentId : Ext.windowId;
}
@@ -202,9 +203,9 @@ Ext.EventManager = {
if (element && (element.getElementById || element.navigator)) {
skipGarbageCollection = true;
}
-
+
if (!Ext.cache[id]){
- Ext.core.Element.addToCache(new Ext.core.Element(element), id);
+ Ext.Element.addToCache(new Ext.Element(element), id);
if (skipGarbageCollection) {
Ext.cache[id].skipGarbageCollection = true;
}
@@ -297,13 +298,13 @@ Ext.EventManager = {
/**
* Appends an event handler to an element. The shorthand version {@link #on} is equivalent. Typically you will
- * use {@link Ext.core.Element#addListener} directly on an Element in favor of calling this version.
+ * use {@link Ext.Element#addListener} directly on an Element in favor of calling this version.
* @param {String/HTMLElement} el The html element or id to assign the event handler to.
* @param {String} eventName The name of the event to listen for.
* @param {Function} handler The handler function the event invokes. This function is passed
* the following parameters:
See {@link Ext.core.Element#addListener} for examples of how to use these options.
+ *See {@link Ext.Element#addListener} for examples of how to use these options.
*/ addListener: function(element, eventName, fn, scope, options){ // Check if we've been passed a "config style" event. @@ -384,7 +385,7 @@ Ext.EventManager = { /** * Removes an event handler from an element. The shorthand version {@link #un} is equivalent. Typically - * you will use {@link Ext.core.Element#removeListener} directly on an Element in favor of calling this version. + * you will use {@link Ext.Element#removeListener} directly on an Element in favor of calling this version. * @param {String/HTMLElement} el The id or html element from which to remove the listener. * @param {String} eventName The name of the event. * @param {Function} fn The handler function to remove. This must be a reference to the function passed into the {@link #addListener} call. @@ -443,7 +444,7 @@ Ext.EventManager = { }, /** - * Removes all event handers from an element. Typically you will use {@link Ext.core.Element#removeAllListeners} + * Removes all event handers from an element. Typically you will use {@link Ext.Element#removeAllListeners} * directly on an Element in favor of calling this version. * @param {String/HTMLElement} el The id or html element from which to remove all event handlers. */ @@ -464,7 +465,7 @@ Ext.EventManager = { }, /** - * Recursively removes all previous added listeners from an element and its children. Typically you will use {@link Ext.core.Element#purgeAllListeners} + * Recursively removes all previous added listeners from an element and its children. Typically you will use {@link Ext.Element#purgeAllListeners} * directly on an Element in favor of calling this version. * @param {String/HTMLElement} el The id or html element from which to remove all event handlers. * @param {String} eventName (optional) The name of the event. @@ -582,7 +583,7 @@ Ext.EventManager = { if (!element) { return []; } - + var eventCache = this.getElementEventCache(element); return eventCache[eventName] || (eventCache[eventName] = []); }, @@ -686,9 +687,9 @@ Ext.EventManager = { }, /** - * Gets the x & ycoordinate from the event + * Gets the x & y coordinate from the event * @param {Object} event The event - * @return {Array} The x/y coordinate + * @return {Number[]} The x/y coordinate */ getPageXY: function(event) { event = event.browserEvent || event; @@ -748,7 +749,7 @@ Ext.EventManager = { * passes new viewport width and height to handlers. * @param {Function} fn The handler function the window resize event invokes. * @param {Object} scope The scope (this
reference) in which the handler function executes. Defaults to the browser window.
- * @param {boolean} options Options object as passed to {@link Ext.core.Element#addListener}
+ * @param {Boolean} options Options object as passed to {@link Ext.Element#addListener}
*/
onWindowResize: function(fn, scope, options){
var resize = this.resizeEvent;
@@ -765,8 +766,8 @@ Ext.EventManager = {
*/
fireResize: function(){
var me = this,
- w = Ext.core.Element.getViewWidth(),
- h = Ext.core.Element.getViewHeight();
+ w = Ext.Element.getViewWidth(),
+ h = Ext.Element.getViewHeight();
//whacky problem in IE where the resize event will sometimes fire even though the w/h are the same.
if(me.curHeight != h || me.curWidth != w){
@@ -838,7 +839,7 @@ Ext.EventManager = {
/**
* note 1: IE fires ONLY the keydown event on specialkey autorepeat
* note 2: Safari < 3.1, Gecko (Mac/Linux) & Opera fire only the keypress event on specialkey autorepeat
- * (research done by @Jan Wolter at http://unixpapa.com/js/key.html)
+ * (research done by Jan Wolter at http://unixpapa.com/js/key.html)
* @private
*/
useKeyDown: Ext.isWebKit ?
@@ -899,66 +900,107 @@ Ext.EventManager.un = Ext.EventManager.removeListener;
html = bd.parentNode;
+ function add (c) {
+ cls.push(baseCSSPrefix + c);
+ }
+
//Let's keep this human readable!
if (Ext.isIE) {
- cls.push(baseCSSPrefix + 'ie');
- }
- if (Ext.isIE6) {
- cls.push(baseCSSPrefix + 'ie6');
- }
- if (Ext.isIE7) {
- cls.push(baseCSSPrefix + 'ie7');
- }
- if (Ext.isIE8) {
- cls.push(baseCSSPrefix + 'ie8');
- }
- if (Ext.isIE9) {
- cls.push(baseCSSPrefix + 'ie9');
+ add('ie');
+
+ // very often CSS needs to do checks like "IE7+" or "IE6 or 7". To help
+ // reduce the clutter (since CSS/SCSS cannot do these tests), we add some
+ // additional classes:
+ //
+ // x-ie7p : IE7+ : 7 <= ieVer
+ // x-ie7m : IE7- : ieVer <= 7
+ // x-ie8p : IE8+ : 8 <= ieVer
+ // x-ie8m : IE8- : ieVer <= 8
+ // x-ie9p : IE9+ : 9 <= ieVer
+ // x-ie78 : IE7 or 8 : 7 <= ieVer <= 8
+ //
+ if (Ext.isIE6) {
+ add('ie6');
+ } else { // ignore pre-IE6 :)
+ add('ie7p');
+
+ if (Ext.isIE7) {
+ add('ie7');
+ } else {
+ add('ie8p');
+
+ if (Ext.isIE8) {
+ add('ie8');
+ } else {
+ add('ie9p');
+
+ if (Ext.isIE9) {
+ add('ie9');
+ }
+ }
+ }
+ }
+
+ if (Ext.isIE6 || Ext.isIE7) {
+ add('ie7m');
+ }
+ if (Ext.isIE6 || Ext.isIE7 || Ext.isIE8) {
+ add('ie8m');
+ }
+ if (Ext.isIE7 || Ext.isIE8) {
+ add('ie78');
+ }
}
if (Ext.isGecko) {
- cls.push(baseCSSPrefix + 'gecko');
- }
- if (Ext.isGecko3) {
- cls.push(baseCSSPrefix + 'gecko3');
- }
- if (Ext.isGecko4) {
- cls.push(baseCSSPrefix + 'gecko4');
+ add('gecko');
+ if (Ext.isGecko3) {
+ add('gecko3');
+ }
+ if (Ext.isGecko4) {
+ add('gecko4');
+ }
+ if (Ext.isGecko5) {
+ add('gecko5');
+ }
}
if (Ext.isOpera) {
- cls.push(baseCSSPrefix + 'opera');
+ add('opera');
}
if (Ext.isWebKit) {
- cls.push(baseCSSPrefix + 'webkit');
+ add('webkit');
}
if (Ext.isSafari) {
- cls.push(baseCSSPrefix + 'safari');
- }
- if (Ext.isSafari2) {
- cls.push(baseCSSPrefix + 'safari2');
- }
- if (Ext.isSafari3) {
- cls.push(baseCSSPrefix + 'safari3');
- }
- if (Ext.isSafari4) {
- cls.push(baseCSSPrefix + 'safari4');
+ add('safari');
+ if (Ext.isSafari2) {
+ add('safari2');
+ }
+ if (Ext.isSafari3) {
+ add('safari3');
+ }
+ if (Ext.isSafari4) {
+ add('safari4');
+ }
+ if (Ext.isSafari5) {
+ add('safari5');
+ }
}
if (Ext.isChrome) {
- cls.push(baseCSSPrefix + 'chrome');
+ add('chrome');
}
if (Ext.isMac) {
- cls.push(baseCSSPrefix + 'mac');
+ add('mac');
}
if (Ext.isLinux) {
- cls.push(baseCSSPrefix + 'linux');
+ add('linux');
}
if (!Ext.supports.CSS3BorderRadius) {
- cls.push(baseCSSPrefix + 'nbr');
+ add('nbr');
}
if (!Ext.supports.CSS3LinearGradient) {
- cls.push(baseCSSPrefix + 'nlg');
+ add('nlg');
}
if (!Ext.scopeResetCSS) {
- cls.push(baseCSSPrefix + 'reset');
+ add('reset');
}
// add to the parent to allow for selectors x-strict x-border-box, also set the isBorderBox property correctly
@@ -973,9 +1015,6 @@ Ext.EventManager.un = Ext.EventManager.removeListener;
htmlCls.push(baseCSSPrefix + (Ext.isBorderBox ? 'border-box' : 'strict'));
if (!Ext.isStrict) {
htmlCls.push(baseCSSPrefix + 'quirks');
- if (Ext.isIE && !Ext.isStrict) {
- Ext.isIEQuirks = true;
- }
}
Ext.fly(html, '_internal').addCls(htmlCls);
}