X-Git-Url: https://scm.cri.mines-paristech.fr/git/Plinn.git/blobdiff_plain/3e0a2c257d49fb162da9c70d2f70194036235166..9e76287b3cab01ba1a2ba970e8da2dbc40bc6a93:/skins/ajax_scripts/javascript_events_api.js diff --git a/skins/ajax_scripts/javascript_events_api.js b/skins/ajax_scripts/javascript_events_api.js index 0eecace..2083018 100644 --- a/skins/ajax_scripts/javascript_events_api.js +++ b/skins/ajax_scripts/javascript_events_api.js @@ -1,12 +1,12 @@ -// (c) Benoît PIN 2006-2009 +// (c) Benoît PIN 2006-2014 // http://plinn.org // Licence GPL -// $Id: javascript_events_api.js 1532 2009-08-13 14:18:16Z pin $ -// $URL: http://svn.cri.ensmp.fr/svn/Plinn/branches/CMF-2.1/skins/ajax_scripts/javascript_events_api.js $ +// +// // Meta functions for events management. var addListener; /* (ob, eventName, listenerFunction, group) add event listener eventName without "on" prefix. - * optionally, listeners can be grouped to make removing convenient. + * optionally, listeners can be grouped to make removing convenient. */ var removeListener; // (ob, eventName, listenerFunction, group) remove event listener. var removeGroupListeners; // (group) remove all listeners in group. @@ -27,6 +27,11 @@ var getCopyOfNode; /* (node) returns a clone of the given node. * to inject HMTL code inside tags where innerHtml is read only (IE) */ +var copyPrototype; // (descendant, parent) lightwheight javascript inheritance +if (!history.pushState) { + history.pushState = function(){}; +} + (function(){ function buildMetaFunctions() { @@ -40,20 +45,22 @@ function buildMetaFunctions() { disablePropagation = _build_disablePropagation(); getWindowWidth = _build_getWindowWidth(); getWindowHeight = _build_getWindowHeight(); + getWindowScrollX = _build_getWindowScrollX(); + getWindowScrollY = _build_getWindowScrollY(); clearSelection = _build_clearSelection(); } -__groupListeners = {}; +var __groupListeners = {}; 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); }; } - else if (browser.isDOM2Event) { + else { _browserSpecific = function(ob, eventName, listenerFunction) { ob.addEventListener(eventName, listenerFunction, false); // only bubbling events :-( }; @@ -61,126 +68,126 @@ function _build_addListener() { var common = function(ob, eventName, listenerFunction, group) { _browserSpecific(ob, eventName, listenerFunction); if (group) { - if(!__groupListeners[group]) - __groupListeners[group] = new Array(); + if(!__groupListeners[group]) { + __groupListeners[group] = [];} __groupListeners[group].push([ob, eventName, listenerFunction]); } - } + }; return common; } 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; } - else if (browser.isDOM2Event) { + else { var _dom2_removeListener = function(ob, eventName, listenerFunction) { ob.removeEventListener(eventName, listenerFunction, false); // only bubbling events :-( - } + }; return _dom2_removeListener; } } removeGroupListeners = function(group) { var listeners = __groupListeners[group]; - var l; - for (var i=0 ; i