Updated Branches: refs/heads/develop c48f7c9e4 -> b0c5be187
IE8 and IE9 support Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/b0c5be18 Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/b0c5be18 Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/b0c5be18 Branch: refs/heads/develop Commit: b0c5be18722ccfd3e42e1ae3b769687b80166e76 Parents: c48f7c9 Author: Alex Harui <[email protected]> Authored: Mon Apr 1 15:13:13 2013 -0700 Committer: Alex Harui <[email protected]> Committed: Mon Apr 1 15:14:40 2013 -0700 ---------------------------------------------------------------------- .../js/FlexJS/src/org/apache/flex/FlexGlobal.js | 10 +- .../FlexJS/src/org/apache/flex/core/Application.js | 105 +---------- .../src/org/apache/flex/core/HTMLElementWrapper.js | 144 +++++++++++++++ .../js/FlexJS/src/org/apache/flex/core/UIBase.js | 111 +----------- .../src/org/apache/flex/events/EventDispatcher.js | 19 ++ .../flex/html/staticControls/DropDownList.js | 7 +- .../org/apache/flex/html/staticControls/List.js | 7 +- .../FlexJS/src/org/apache/flex/net/HTTPService.js | 59 ++----- .../FlexJS/src/org/apache/flex/utils/IE8Utils.js | 103 ++++++++++ .../js/FlexJS/src/org/apache/flex/utils/Timer.js | 3 +- 10 files changed, 304 insertions(+), 264 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/b0c5be18/frameworks/js/FlexJS/src/org/apache/flex/FlexGlobal.js ---------------------------------------------------------------------- diff --git a/frameworks/js/FlexJS/src/org/apache/flex/FlexGlobal.js b/frameworks/js/FlexJS/src/org/apache/flex/FlexGlobal.js index b61f0bc..01f06bf 100644 --- a/frameworks/js/FlexJS/src/org/apache/flex/FlexGlobal.js +++ b/frameworks/js/FlexJS/src/org/apache/flex/FlexGlobal.js @@ -44,9 +44,7 @@ org.apache.flex.FlexGlobal.newObject = function(ctor, ctorArgs) { if ((ctor === org.apache.flex.events.Event || ctor === org.apache.flex.events.CustomEvent) && ctorArgs.length === 1) { - evt = document.createEvent('Event'); - evt.initEvent(ctorArgs[0], false, false); - + evt = org.apache.flex.events.EventDispatcher.createEvent(ctorArgs[0]); return evt; } @@ -61,9 +59,3 @@ org.apache.flex.FlexGlobal.newObject = function(ctor, ctorArgs) { return {}; }; -/** - * @enum {string} - */ -org.apache.flex.FlexGlobal.EventMap = { - CLICK: 'onClick' -}; http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/b0c5be18/frameworks/js/FlexJS/src/org/apache/flex/core/Application.js ---------------------------------------------------------------------- diff --git a/frameworks/js/FlexJS/src/org/apache/flex/core/Application.js b/frameworks/js/FlexJS/src/org/apache/flex/core/Application.js index 2dcfaeb..84a7c72 100644 --- a/frameworks/js/FlexJS/src/org/apache/flex/core/Application.js +++ b/frameworks/js/FlexJS/src/org/apache/flex/core/Application.js @@ -14,8 +14,7 @@ goog.provide('org.apache.flex.core.Application'); -goog.require('org.apache.flex.FlexGlobal'); -goog.require('org.apache.flex.FlexObject'); +goog.require('org.apache.flex.core.HTMLElementWrapper'); goog.require('org.apache.flex.core.SimpleValuesImpl'); goog.require('org.apache.flex.core.ValuesManager'); @@ -24,10 +23,10 @@ goog.require('org.apache.flex.utils.MXMLDataInterpreter'); /** * @constructor - * @extends {org.apache.flex.FlexObject} + * @extends {org.apache.flex.core.HTMLElementWrapper} */ org.apache.flex.core.Application = function() { - org.apache.flex.FlexObject.call(this); + org.apache.flex.core.HTMLElementWrapper.call(this); /** * @private @@ -35,13 +34,9 @@ org.apache.flex.core.Application = function() { */ this.queuedListeners_; - /** - * @private - * @type {Array} - */ - this.strand; }; -goog.inherits(org.apache.flex.core.Application, org.apache.flex.FlexObject); +goog.inherits(org.apache.flex.core.Application, + org.apache.flex.core.HTMLElementWrapper); /** * @expose @@ -83,11 +78,7 @@ org.apache.flex.core.Application.prototype.addEventListener = function(t, fn) { return; } - if (typeof this.element.attachEvent == 'function') { - this.element.attachEvent(org.apache.flex.FlexGlobal.EventMap[t], fn); - } else if (typeof this.element.addEventListener == 'function') { - this.element.addEventListener(t, fn); - } + goog.base(this, 'addEventListener', t, fn); }; /** @@ -113,89 +104,13 @@ org.apache.flex.core.Application.prototype.start = function() { org.apache.flex.core.ValuesManager.valuesImpl = this.valuesImpl; - evt = document.createEvent('Event'); - evt.initEvent('initialize', true, true); - this.element.dispatchEvent(evt); + evt = this.createEvent('initialize'); + this.dispatchEvent(evt); this.initialView.addToParent(this.element); this.initialView.initUI(this.model); - evt = document.createEvent('Event'); - evt.initEvent('viewChanged', true, true); - this.element.dispatchEvent(evt); -}; - -/** - * @expose - * @this {org.apache.flex.core.Application} - * @return {Array} The array of descriptors. - */ -org.apache.flex.core.Application.prototype.get_MXMLDescriptor = function() { - return null; -}; - -/** - * @expose - * @this {org.apache.flex.core.Application} - * @return {Array} The array of properties. - */ -org.apache.flex.core.Application.prototype.get_MXMLProperties = function() { - return null; -}; - -/** - * @expose - * @this {org.apache.flex.core.Application} - * @param {object} bead The new bead. - */ -org.apache.flex.core.Application.prototype.addBead = function(bead) { - if (!this.strand) - this.strand = []; - this.strand.push(bead); - if (typeof(bead.constructor.$implements) != 'undefined' && - typeof(bead.constructor.$implements.IBeadModel != 'undefined')) - this.model = bead; - bead.set_strand(this); -}; - -/** - * @expose - * @this {org.apache.flex.core.Application} - * @param {object} classOrInterface The requested bead type. - * @return {object} The bead. - */ -org.apache.flex.core.Application.prototype.getBeadByType = - function(classOrInterface) { - var n; - n = this.strand.length; - for (var i = 0; i < n; i++) - { - var bead = strand[i]; - if (bead instanceof classOrInterface) - return bead; - if (classOrInterface in bead.constructor.$implements) - return bead; - } - return null; -}; - -/** - * @expose - * @this {org.apache.flex.core.Application} - * @param {object} bead The bead to remove. - * @return {object} The bead. - */ -org.apache.flex.core.Application.prototype.removeBead = function(bead) { - var n = this.strand.length; - for (var i = 0; i < n; i++) - { - var bead = strand[i]; - if (bead == value) - { - this.strand.splice(i, 1); - return bead; - } - } - return null; + evt = this.createEvent('viewChanged'); + this.dispatchEvent(evt); }; http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/b0c5be18/frameworks/js/FlexJS/src/org/apache/flex/core/HTMLElementWrapper.js ---------------------------------------------------------------------- diff --git a/frameworks/js/FlexJS/src/org/apache/flex/core/HTMLElementWrapper.js b/frameworks/js/FlexJS/src/org/apache/flex/core/HTMLElementWrapper.js new file mode 100644 index 0000000..ed123dc --- /dev/null +++ b/frameworks/js/FlexJS/src/org/apache/flex/core/HTMLElementWrapper.js @@ -0,0 +1,144 @@ +/** + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +goog.provide('org.apache.flex.core.HTMLElementWrapper'); + +goog.require('org.apache.flex.FlexObject'); +goog.require('org.apache.flex.utils.IE8Utils'); + +/** + * @constructor + * @extends {org.apache.flex.FlexObject} + */ +org.apache.flex.core.HTMLElementWrapper = function() { + org.apache.flex.FlexObject.call(this); + + /** + * @private + * @type {Array} + */ + this.strand; +}; +goog.inherits(org.apache.flex.core.HTMLElementWrapper, + org.apache.flex.FlexObject); + +/** + * @this {org.apache.flex.core.HTMLElementWrapper} + * @param {string} type The event type. + * @param {function(?): ?} fn The event handler. + */ +org.apache.flex.core.HTMLElementWrapper.prototype.addEventListener = + function(type, fn) { + if (this.element.addEventListener) { + this.element.addEventListener(type, fn); + } + else if (this.element.attachEvent || !this.element.dispatchEvent) { + org.apache.flex.utils.IE8Utils.addEventListener(this, this.element, type, fn); + } +}; + +/** + * @this {org.apache.flex.core.HTMLElementWrapper} + * @param {org.apache.flex.events.Event} evt The event. + */ +org.apache.flex.core.HTMLElementWrapper.prototype.dispatchEvent = + function(evt) { + if (this.element.addEventListener) + this.element.dispatchEvent(evt); + else if (this.element.attachEvent || !this.element.dispatchEvent) + org.apache.flex.utils.IE8Utils.dispatchEvent(this, this.element, evt) +}; + +/** + * @this {org.apache.flex.core.HTMLElementWrapper} + * @param {string} type The event type. + */ +org.apache.flex.core.HTMLElementWrapper.prototype.createEvent = + function(type) { + return org.apache.flex.events.EventDispatcher.createEvent(type); +}; + +/** + * @expose + * @this {org.apache.flex.core.HTMLElementWrapper} + * @param {object} bead The new bead. + */ +org.apache.flex.core.HTMLElementWrapper.prototype.addBead = function(bead) { + if (!this.strand) + this.strand = []; + this.strand.push(bead); + if (typeof(bead.constructor.$implements) != 'undefined' && + typeof(bead.constructor.$implements.IBeadModel != 'undefined')) + this.model = bead; + bead.set_strand(this); +}; + +/** + * @expose + * @this {org.apache.flex.core.HTMLElementWrapper} + * @param {object} classOrInterface The requested bead type. + * @return {object} The bead. + */ +org.apache.flex.core.HTMLElementWrapper.prototype.getBeadByType = + function(classOrInterface) { + var n; + n = this.strand.length; + for (var i = 0; i < n; i++) + { + var bead = strand[i]; + if (bead instanceof classOrInterface) + return bead; + if (classOrInterface in bead.constructor.$implements) + return bead; + } + return null; +}; + +/** + * @expose + * @this {org.apache.flex.core.HTMLElementWrapper} + * @param {object} bead The bead to remove. + * @return {object} The bead. + */ +org.apache.flex.core.HTMLElementWrapper.prototype.removeBead = function(bead) { + var n = this.strand.length; + for (var i = 0; i < n; i++) + { + var bead = strand[i]; + if (bead == value) + { + this.strand.splice(i, 1); + return bead; + } + } + return null; +}; + +/** + * @expose + * @this {org.apache.flex.core.HTMLElementWrapper} + * @return {Array} The array of descriptors. + */ +org.apache.flex.core.HTMLElementWrapper.prototype.get_MXMLDescriptor = function() { + return null; +}; + +/** + * @expose + * @this {org.apache.flex.core.HTMLElementWrapper} + * @return {Array} The array of properties. + */ +org.apache.flex.core.HTMLElementWrapper.prototype.get_MXMLProperties = function() { + return null; +}; http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/b0c5be18/frameworks/js/FlexJS/src/org/apache/flex/core/UIBase.js ---------------------------------------------------------------------- diff --git a/frameworks/js/FlexJS/src/org/apache/flex/core/UIBase.js b/frameworks/js/FlexJS/src/org/apache/flex/core/UIBase.js index c26de71..45df41f 100644 --- a/frameworks/js/FlexJS/src/org/apache/flex/core/UIBase.js +++ b/frameworks/js/FlexJS/src/org/apache/flex/core/UIBase.js @@ -15,14 +15,14 @@ goog.provide('org.apache.flex.core.UIBase'); goog.require('org.apache.flex.FlexGlobal'); -goog.require('org.apache.flex.FlexObject'); +goog.require('org.apache.flex.core.HTMLElementWrapper'); /** * @constructor - * @extends {org.apache.flex.FlexObject} + * @extends {org.apache.flex.core.HTMLElementWrapper} */ org.apache.flex.core.UIBase = function() { - org.apache.flex.FlexObject.call(this); + org.apache.flex.core.HTMLElementWrapper.call(this); /** * @protected @@ -30,26 +30,9 @@ org.apache.flex.core.UIBase = function() { */ this.positioner; - /** - * @private - * @type {Array} - */ - this.strand; -}; -goog.inherits(org.apache.flex.core.UIBase, org.apache.flex.FlexObject); - -/** - * @this {org.apache.flex.core.UIBase} - * @param {string} type The event type. - * @param {function(?): ?} fn The event handler. - */ -org.apache.flex.core.UIBase.prototype.addEventListener = function(type, fn) { - if (typeof this.element.attachEvent == 'function') { - this.element.attachEvent(org.apache.flex.FlexGlobal.EventMap[type], fn); - } else if (typeof this.element.addEventListener == 'function') { - this.element.addEventListener(type, fn); - } }; +goog.inherits(org.apache.flex.core.UIBase, + org.apache.flex.core.HTMLElementWrapper); /** * @this {org.apache.flex.core.UIBase} @@ -62,14 +45,6 @@ org.apache.flex.core.UIBase.prototype.addToParent = function(p) { }; /** - * @this {org.apache.flex.core.UIBase} - * @param {org.apache.flex.events.Event} evt The event. - */ -org.apache.flex.core.UIBase.prototype.dispatchEvent = function(evt) { - this.element.dispatchEvent(evt); -}; - -/** * @expose * @this {org.apache.flex.core.UIBase} * @param {number} pixels The pixel count from the left edge. @@ -131,8 +106,7 @@ org.apache.flex.core.UIBase.prototype.set_id = function(value) { if (this.id != value) { this.id = value; - var evt = document.createEvent('Event'); - evt.initEvent('idChanged', false, false); + var evt = this.createEvent('idChanged'); this.dispatchEvent(evt); } }; @@ -165,76 +139,3 @@ org.apache.flex.core.UIBase.prototype.set_model = function(value) { } }; -/** - * @expose - * @this {org.apache.flex.core.UIBase} - * @param {object} bead The new bead. - */ -org.apache.flex.core.UIBase.prototype.addBead = function(bead) { - if (!this.strand) - this.strand = []; - this.strand.push(bead); - if (typeof(bead.constructor.$implements) != 'undefined' && - typeof(bead.constructor.$implements.IBeadModel != 'undefined')) - this.model = bead; - bead.set_strand(this); -}; - -/** - * @expose - * @this {org.apache.flex.core.UIBase} - * @param {object} classOrInterface The requested bead type. - * @return {object} The bead. - */ -org.apache.flex.core.UIBase.prototype.getBeadByType = - function(classOrInterface) { - var n; - n = this.strand.length; - for (var i = 0; i < n; i++) - { - var bead = strand[i]; - if (bead instanceof classOrInterface) - return bead; - if (classOrInterface in bead.constructor.$implements) - return bead; - } - return null; -}; - -/** - * @expose - * @this {org.apache.flex.core.UIBase} - * @param {object} bead The bead to remove. - * @return {object} The bead. - */ -org.apache.flex.core.UIBase.prototype.remove = function(bead) { - var n = this.strand.length; - for (var i = 0; i < n; i++) - { - var bead = strand[i]; - if (bead == value) - { - this.strand.splice(i, 1); - return bead; - } - } - return null; -}; - -/** - * @expose - * @this {org.apache.flex.core.UIBase} - * @return {Array} The array of descriptors. - */ -org.apache.flex.core.UIBase.prototype.get_MXMLDescriptor = function() { - return null; -}; - -/** - * @expose - * @this {org.apache.flex.core.UIBase} - * @return {Array} The array of properties. - */ -org.apache.flex.core.UIBase.prototype.get_MXMLProperties = function() { - return null; -}; http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/b0c5be18/frameworks/js/FlexJS/src/org/apache/flex/events/EventDispatcher.js ---------------------------------------------------------------------- diff --git a/frameworks/js/FlexJS/src/org/apache/flex/events/EventDispatcher.js b/frameworks/js/FlexJS/src/org/apache/flex/events/EventDispatcher.js index b686db2..be66990 100644 --- a/frameworks/js/FlexJS/src/org/apache/flex/events/EventDispatcher.js +++ b/frameworks/js/FlexJS/src/org/apache/flex/events/EventDispatcher.js @@ -84,3 +84,22 @@ org.apache.flex.events.EventDispatcher.prototype.dispatchEvent = function(event) } } }; + +/** + * @param {String} type The event type. + * @returns {Object} event The event to dispatch. + */ +org.apache.flex.events.EventDispatcher.createEvent = function(type) { + var evt; + if (document.createEvent) + { + evt = document.createEvent('Event'); + evt.initEvent(type, false, false); + } + else if (document.createEventObject) + { + evt = document.createEventObject(); + evt.type = type; + } + return evt; +}; http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/b0c5be18/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/DropDownList.js ---------------------------------------------------------------------- diff --git a/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/DropDownList.js b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/DropDownList.js index f888f19..5d315ed 100644 --- a/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/DropDownList.js +++ b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/DropDownList.js @@ -41,7 +41,7 @@ goog.inherits( */ org.apache.flex.html.staticControls.DropDownList.prototype.addToParent = function(p) { this.element = document.createElement('select'); - this.element.onChange = org.apache.flex.FlexGlobal.createProxy( + this.element.onchange = org.apache.flex.FlexGlobal.createProxy( this, this.changeHandler); p.appendChild(this.element); @@ -138,8 +138,7 @@ function(value) { */ org.apache.flex.html.staticControls.DropDownList.prototype.changeHandler = function() { - evt = document.createEvent('Event'); - evt.initEvent('change', false, false); - this.element.dispatchEvent(evt); + evt = this.createEvent('change'); + this.dispatchEvent(evt); }; http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/b0c5be18/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/List.js ---------------------------------------------------------------------- diff --git a/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/List.js b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/List.js index 14c0c6d..8986501 100644 --- a/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/List.js +++ b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/List.js @@ -41,7 +41,7 @@ goog.inherits( */ org.apache.flex.html.staticControls.List.prototype.addToParent = function(p) { this.element = document.createElement('select'); - this.element.onChange = org.apache.flex.FlexGlobal.createProxy( + this.element.onchange = org.apache.flex.FlexGlobal.createProxy( this, this.changeHandler); this.element.size = 5; @@ -139,8 +139,7 @@ function(value) { */ org.apache.flex.html.staticControls.List.prototype.changeHandler = function() { - evt = document.createEvent('Event'); - evt.initEvent('change', false, false); - this.element.dispatchEvent(evt); + evt = this.createEvent('change'); + this.dispatchEvent(evt); }; http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/b0c5be18/frameworks/js/FlexJS/src/org/apache/flex/net/HTTPService.js ---------------------------------------------------------------------- diff --git a/frameworks/js/FlexJS/src/org/apache/flex/net/HTTPService.js b/frameworks/js/FlexJS/src/org/apache/flex/net/HTTPService.js index 908c158..8c87ae6 100644 --- a/frameworks/js/FlexJS/src/org/apache/flex/net/HTTPService.js +++ b/frameworks/js/FlexJS/src/org/apache/flex/net/HTTPService.js @@ -15,15 +15,15 @@ goog.provide('org.apache.flex.net.HTTPService'); goog.require('org.apache.flex.FlexGlobal'); -goog.require('org.apache.flex.FlexObject'); +goog.require('org.apache.flex.core.HTMLElementWrapper'); goog.require('org.apache.flex.net.HTTPHeader'); /** * @constructor - * @extends {org.apache.flex.FlexObject} + * @extends {org.apache.flex.core.HTMLElementWrapper} */ org.apache.flex.net.HTTPService = function() { - org.apache.flex.FlexObject.call(this); + org.apache.flex.core.HTMLElementWrapper.call(this); /** * @protected @@ -65,7 +65,7 @@ org.apache.flex.net.HTTPService = function() { * @private * @type {Number} */ - this._timeout; + this._timeout = 0; /** * @private @@ -81,19 +81,14 @@ org.apache.flex.net.HTTPService = function() { /** * @private - * @type {Array} - */ - this.strand; - - /** - * @private * @type {XMLHttpRequest} */ this.element; this.element = new XMLHttpRequest(); }; -goog.inherits(org.apache.flex.net.HTTPService, org.apache.flex.FlexObject); +goog.inherits(org.apache.flex.net.HTTPService, + org.apache.flex.core.HTMLElementWrapper); /** * @expose @@ -120,28 +115,6 @@ org.apache.flex.net.HTTPService.HTTP_METHOD_PUT = "PUT"; org.apache.flex.net.HTTPService.HTTP_METHOD_DELETE = "DELETE"; /** - * @this {org.apache.flex.net.HTTPService} - * @param {string} type The event type. - * @param {function(?): ?} fn The event handler. - */ -org.apache.flex.net.HTTPService.prototype.addEventListener = -function(type, fn) { - if (typeof this.element.attachEvent == 'function') { - this.element.attachEvent(org.apache.flex.FlexGlobal.EventMap[type], fn); - } else if (typeof this.element.addEventListener == 'function') { - this.element.addEventListener(type, fn); - } -}; - -/** - * @this {org.apache.flex.net.HTTPService} - * @param {org.apache.flex.events.Event} evt The event. - */ -org.apache.flex.net.HTTPService.prototype.dispatchEvent = function(evt) { - this.element.dispatchEvent(evt); -}; - -/** * @expose * @this {org.apache.flex.net.HTTPService} * @return {string} value The data. @@ -323,8 +296,8 @@ org.apache.flex.net.HTTPService.prototype.send = function() { contentData = this._contentData; } - this.element.timeout = this._timeout; this.element.open(this._method,this._url,true); + this.element.timeout = this._timeout; var sawContentType = false; if (this._headers) { @@ -363,18 +336,15 @@ org.apache.flex.net.HTTPService.prototype.progressHandler = function() { if (this.element.readyState == 2) { this._status = this.element.status; - var evt = document.createEvent('Event'); - evt.initEvent('httpResponseStatus', true, true); - this.element.dispatchEvent(evt); - evt = document.createEvent('Event'); - evt.initEvent('httpStatus', true, true); - this.element.dispatchEvent(evt); + var evt = this.createEvent('httpResponseStatus'); + this.dispatchEvent(evt); + evt = this.createEvent('httpStatus'); + this.dispatchEvent(evt); } else if (this.element.readyState == 4) { - var evt = document.createEvent('Event'); - evt.initEvent('complete', true, true); - this.element.dispatchEvent(evt); + var evt = this.createEvent('complete'); + this.dispatchEvent(evt); } }; @@ -402,8 +372,7 @@ org.apache.flex.net.HTTPService.prototype.set_id = function(value) { if (this.id != value) { this.id = value; - var evt = document.createEvent('Event'); - evt.initEvent('idChanged', false, false); + var evt = this.createEvent('idChanged'); this.dispatchEvent(evt); } }; http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/b0c5be18/frameworks/js/FlexJS/src/org/apache/flex/utils/IE8Utils.js ---------------------------------------------------------------------- diff --git a/frameworks/js/FlexJS/src/org/apache/flex/utils/IE8Utils.js b/frameworks/js/FlexJS/src/org/apache/flex/utils/IE8Utils.js new file mode 100644 index 0000000..b9d5216 --- /dev/null +++ b/frameworks/js/FlexJS/src/org/apache/flex/utils/IE8Utils.js @@ -0,0 +1,103 @@ +/** + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +goog.provide('org.apache.flex.utils.IE8Utils'); + +/** + * @constructor + * @extends {org.apache.flex.events.EventDispatcher} + */ +org.apache.flex.utils.IE8Utils = function(obj, fn) { + /* + obj.attachEvent("onmousedown", + org.apache.flex.FlexGlobals.createProxy(this, this.mouseDownHandler)); + obj.attachEvent("onmouseup", + org.apache.flex.FlexGlobals.createProxy(this, this.mouseUpHandler)); + obj.attachEvent("onmouseup", + org.apache.flex.FlexGlobals.createProxy(this, this.mouseUpHandler)); + */ +}; + +/** + * @expose + * Adds an event listener for IE8 + * @param {object} obj The object that we're adding a listener to. + * @param {object} el The html element we listen to if possible. + * @param {string} t The event type. + * @param {function(?): ?} fn The event handler. + */ +org.apache.flex.utils.IE8Utils.addEventListener = function(obj, el, t, fn) { + var ie8Event = org.apache.flex.utils.IE8Utils.EventMap[t]; + if (ie8Event == undefined) + { + if (obj.listeners_ == undefined) + obj.listeners_ = {}; + + if (obj.listeners_[t] == undefined) + { + obj.listeners_[t] = [ fn ]; + } + else + obj.listeners_[t].push(fn); + /* + if (t == "click") + { + var proxy = new org.apache.flex.utils.IE8Utils(obj, fn); + } + */ + } + else + el.attachEvent(ie8Event, fn); +}; + +/** + * @expose + * Dispatches an event for IE8 + * @param {object} obj The object that we're dispatching from. + * @param {object} el The html element we listen to if possible. + * @param {object} event The event object. + */ +org.apache.flex.utils.IE8Utils.dispatchEvent = function(obj, el, event) { + var ie8Event = org.apache.flex.utils.IE8Utils.EventMap[event.type]; + if (ie8Event == undefined) + { + var arr, i, n, type; + + type = event.type; + + if (obj.listeners_ && obj.listeners_[type]) { + arr = obj.listeners_[type]; + n = arr.length; + for (i = 0; i < n; i++) { + arr[i](event); + } + } + } + else + el.fireEvent(ie8Event, event); +}; + + +/** + * @enum {string} + */ +org.apache.flex.utils.IE8Utils.EventMap = { + click: 'onclick', + mouseUp: 'onmouseup', + mouseDown: 'onmousedown', + mouseMove: 'onmousemove', + mouseOver: 'onmouseover', + mouseOut: 'onmouseout' +}; + http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/b0c5be18/frameworks/js/FlexJS/src/org/apache/flex/utils/Timer.js ---------------------------------------------------------------------- diff --git a/frameworks/js/FlexJS/src/org/apache/flex/utils/Timer.js b/frameworks/js/FlexJS/src/org/apache/flex/utils/Timer.js index ca18e8e..9481118 100644 --- a/frameworks/js/FlexJS/src/org/apache/flex/utils/Timer.js +++ b/frameworks/js/FlexJS/src/org/apache/flex/utils/Timer.js @@ -96,8 +96,7 @@ org.apache.flex.utils.Timer.prototype.timerHandler = if (this._repeatCount > 0 && this._currentCount >= this._repeatCount) this.stop(); - var evt = document.createEvent('Event'); - evt.initEvent('timer', false, false); + var evt = org.apache.flex.events.EventDispatcher.createEvent('timer'); this.dispatchEvent(evt); };
