From c5d0cd2824e3c3bb2f6f3834177a71c1d7b78519 Mon Sep 17 00:00:00 2001 From: xue <> Date: Tue, 27 Mar 2007 00:47:38 +0000 Subject: merge from 3.0 branch till 1779. --- framework/Web/Javascripts/extended/event.js | 110 ---------------------------- 1 file changed, 110 deletions(-) delete mode 100644 framework/Web/Javascripts/extended/event.js (limited to 'framework/Web/Javascripts/extended/event.js') diff --git a/framework/Web/Javascripts/extended/event.js b/framework/Web/Javascripts/extended/event.js deleted file mode 100644 index e257931a..00000000 --- a/framework/Web/Javascripts/extended/event.js +++ /dev/null @@ -1,110 +0,0 @@ -/** - * @class Event extensions. - */ -Object.extend(Event, -{ - /** - * Register a function to be executed when the page is loaded. - * Note that the page is only loaded if all resources (e.g. images) - * are loaded. - * - * Example: Show an alert box with message "Page Loaded!" when the - * page finished loading. - * - * Event.OnLoad(function(){ alert("Page Loaded!"); }); - * - * - * @param {Function} function to execute when page is loaded. - */ - OnLoad : function (fn) - { - // opera onload is in document, not window - var w = document.addEventListener && - !window.addEventListener ? document : window; - Event.observe(w,'load',fn); - }, - - /** - * @param {Event} a keyboard event - * @return {Number} the Unicode character code generated by the key - * that was struck. - */ - keyCode : function(e) - { - return e.keyCode != null ? e.keyCode : e.charCode - }, - - /** - * @param {String} event type or event name. - * @return {Boolean} true if event type is of HTMLEvent, false - * otherwise - */ - isHTMLEvent : function(type) - { - var events = ['abort', 'blur', 'change', 'error', 'focus', - 'load', 'reset', 'resize', 'scroll', 'select', - 'submit', 'unload']; - return events.include(type); - }, - - /** - * @param {String} event type or event name - * @return {Boolean} true if event type is of MouseEvent, - * false otherwise - */ - isMouseEvent : function(type) - { - var events = ['click', 'mousedown', 'mousemove', 'mouseout', - 'mouseover', 'mouseup']; - return events.include(type); - }, - - /** - * Dispatch the DOM event of a given type on a DOM - * element. Only HTMLEvent and MouseEvent can be - * dispatched, keyboard events or UIEvent can not be dispatch - * via javascript consistently. - * For the "submit" event the submit() method is called. - * @param {Object} element id string or a DOM element. - * @param {String} event type to dispatch. - */ - fireEvent : function(element,type,canBubble) - { - canBubble = (typeof(canBubble) == undefined) ? true : canBubble; - element = $(element); - if(type == "submit") - return element.submit(); - if(document.createEvent) - { - if(Event.isHTMLEvent(type)) - { - var event = document.createEvent('HTMLEvents'); - event.initEvent(type, canBubble, true); - } - else if(Event.isMouseEvent(type)) - { - var event = document.createEvent('MouseEvents'); - if (event.initMouseEvent) - { - event.initMouseEvent(type,canBubble,true, - document.defaultView, 1, 0, 0, 0, 0, false, - false, false, false, 0, null); - } - else - { - // Safari - // TODO we should be initialising other mouse-event related attributes here - event.initEvent(type, canBubble, true); - } - } - element.dispatchEvent(event); - } - else if(document.createEventObject) - { - var evObj = document.createEventObject(); - element.fireEvent('on'+type, evObj); - } - else if(typeof(element['on'+type]) == "function") - element['on'+type](); - } -}); \ No newline at end of file -- cgit v1.2.3