Le tri est effectué directement par le catalogue.
[Plinn.git] / skins / ajax_scripts / javascript_events_api.js
index 62ec577..4e721e2 100644 (file)
@@ -26,6 +26,7 @@ var getCopyOfNode; /* (node) returns a clone of the given node.
                                                * the node came from a foreign document (eg. XmlHttpRequest xml reponse)
                                                * to inject HMTL code inside tags where innerHtml is read only (IE)
                                        */
                                                * the node came from a foreign document (eg. XmlHttpRequest xml reponse)
                                                * to inject HMTL code inside tags where innerHtml is read only (IE)
                                        */
+var copyPrototype; // (descendant, parent) lightwheight javascript inheritance
 
 (function(){
 
 
 (function(){
 
@@ -43,17 +44,17 @@ function buildMetaFunctions() {
        clearSelection = _build_clearSelection();
 }
 
        clearSelection = _build_clearSelection();
 }
 
-__groupListeners = {};
+var __groupListeners = {};
 
 function _build_addListener() {
        var _browserSpecific;
 
 function _build_addListener() {
        var _browserSpecific;
-       if (browser.isIE55 || browser.isIE6up) {
+       if (!browser.isDOM2Event) {
                _browserSpecific = function(ob, eventName, listenerFunction) {
                        eventName = "on" + eventName;
                        ob.attachEvent(eventName, listenerFunction);
                };
        }
                _browserSpecific = function(ob, eventName, listenerFunction) {
                        eventName = "on" + eventName;
                        ob.attachEvent(eventName, listenerFunction);
                };
        }
-       else if (browser.isDOM2Event) {
+       else {
                _browserSpecific = function(ob, eventName, listenerFunction) {
                        ob.addEventListener(eventName, listenerFunction, false); // only bubbling events :-(
                };
                _browserSpecific = function(ob, eventName, listenerFunction) {
                        ob.addEventListener(eventName, listenerFunction, false); // only bubbling events :-(
                };
@@ -70,14 +71,14 @@ function _build_addListener() {
 }
 
 function _build_removeListener() {
 }
 
 function _build_removeListener() {
-       if (browser.isIE55 || browser.isIE6up) {
+       if (!browser.isDOM2Event) {
                var _ie_removeListener = function(ob, eventName, listenerFunction) {
                        eventName = "on" + eventName;
                        ob.detachEvent(eventName, listenerFunction);
                };
                return _ie_removeListener;
        }
                var _ie_removeListener = function(ob, eventName, listenerFunction) {
                        eventName = "on" + eventName;
                        ob.detachEvent(eventName, listenerFunction);
                };
                return _ie_removeListener;
        }
-       else if (browser.isDOM2Event) {
+       else {
                var _dom2_removeListener = function(ob, eventName, listenerFunction) {
                        ob.removeEventListener(eventName, listenerFunction, false); // only bubbling events :-(
                };
                var _dom2_removeListener = function(ob, eventName, listenerFunction) {
                        ob.removeEventListener(eventName, listenerFunction, false); // only bubbling events :-(
                };
@@ -97,13 +98,13 @@ removeGroupListeners = function(group) {
 };
 
 function  _build_raiseMouseEvent() {
 };
 
 function  _build_raiseMouseEvent() {
-       if (browser.isIE55 || browser.isIE6up) {
+       if (!browser.isDOM2Event) {
                var _ie_raiseMouseEvent = function(ob, eventName) {
                        ob.fireEvent("on" + eventName);
                };
                return _ie_raiseMouseEvent;
        }
                var _ie_raiseMouseEvent = function(ob, eventName) {
                        ob.fireEvent("on" + eventName);
                };
                return _ie_raiseMouseEvent;
        }
-       else if (browser.isDOM2Event) {
+       else {
                var _dom2_raiseMouseEvent = function(ob, eventName) {
                        var event = document.createEvent("MouseEvents");
                        event.initEvent(eventName, true, true);
                var _dom2_raiseMouseEvent = function(ob, eventName) {
                        var event = document.createEvent("MouseEvents");
                        event.initEvent(eventName, true, true);
@@ -114,13 +115,13 @@ function  _build_raiseMouseEvent() {
 }
 
 function _build_getTargetedObject(){
 }
 
 function _build_getTargetedObject(){
-       if (browser.isIE55 || browser.isIE6up) {
+       if (!browser.isDOM2Event) {
                var _ie_getTargetedObject = function() {
                        return window.event.srcElement;
                };
                return _ie_getTargetedObject;
        }
                var _ie_getTargetedObject = function() {
                        return window.event.srcElement;
                };
                return _ie_getTargetedObject;
        }
-       else if (browser.isDOM2Event) {
+       else {
                var _appleWebKit_getTargetedeObject = function(evt) {
                        var target = evt.target;
                        // is it really safe ?...
                var _appleWebKit_getTargetedeObject = function(evt) {
                        var target = evt.target;
                        // is it really safe ?...
@@ -134,13 +135,13 @@ function _build_getTargetedObject(){
 }
 
 function _build_getEventObject(){
 }
 
 function _build_getEventObject(){
-       if (browser.isIE) {
+       if (!browser.isDOM2Event) {
                var _ie_getEventObject = function() {
                        return window.event;
                };
                return _ie_getEventObject;
        }
                var _ie_getEventObject = function() {
                        return window.event;
                };
                return _ie_getEventObject;
        }
-       else if (browser.isDOM2Event) {
+       else {
                var _dom2_getEventObject = function(evt) {
                        return evt;
                };
                var _dom2_getEventObject = function(evt) {
                        return evt;
                };
@@ -150,13 +151,13 @@ function _build_getEventObject(){
 
 
 function _build_disableDefault(){
 
 
 function _build_disableDefault(){
-       if (browser.isIE55 || browser.isIE6up) {
+       if (!browser.isDOM2Event) {
                var _ie_disableDefault = function() {
                        window.event.returnValue = false;
                };
                return _ie_disableDefault;
        }
                var _ie_disableDefault = function() {
                        window.event.returnValue = false;
                };
                return _ie_disableDefault;
        }
-       else if (browser.isDOM2Event) {
+       else {
                var _dom2_disableDefault = function(evt) {
                        evt.preventDefault();
                };
                var _dom2_disableDefault = function(evt) {
                        evt.preventDefault();
                };
@@ -165,13 +166,13 @@ function _build_disableDefault(){
 }
 
 function _build_disablePropagation() {
 }
 
 function _build_disablePropagation() {
-       if (browser.isIE55 || browser.isIE6up) {
+       if (!browser.isDOM2Event) {
                var _ie_disablePropagation = function() {
                        window.event.cancelBubble = true;
                };
                return _ie_disablePropagation;
        }
                var _ie_disablePropagation = function() {
                        window.event.cancelBubble = true;
                };
                return _ie_disablePropagation;
        }
-       else if (browser.isDOM2Event) {
+       else {
                var _dom2_disablePropagation = function(evt) {
                        evt.stopPropagation();
                };
                var _dom2_disablePropagation = function(evt) {
                        evt.stopPropagation();
                };
@@ -297,4 +298,19 @@ else {
        _setAttribute = function(e, name, value) {e.setAttribute(name, value);};
 }
 
        _setAttribute = function(e, name, value) {e.setAttribute(name, value);};
 }
 
+/* 
+* http://www.sitepoint.com/blogs/2006/01/17/javascript-inheritance/
+*/
+
+copyPrototype = function (descendant, parent) { 
+       var sConstructor = parent.toString(); 
+       var aMatch = sConstructor.match( /\s*function (.*)\(/ );
+       if ( aMatch !== null ) { descendant.prototype[aMatch[1]] = parent; }
+       var m;
+       for (m in parent.prototype) {
+               if (parent.prototype.hasOwnProperty(m)) {
+                       descendant.prototype[m] = parent.prototype[m]; }
+       }
+};
+
 }());
 }());