diff options
Diffstat (limited to 'lib/scripts/compatibility.js')
-rw-r--r-- | lib/scripts/compatibility.js | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/lib/scripts/compatibility.js b/lib/scripts/compatibility.js index 39f703c71..ea52153c5 100644 --- a/lib/scripts/compatibility.js +++ b/lib/scripts/compatibility.js @@ -38,7 +38,7 @@ function DEPRECATED_WRAP(func, context) { return function () { DEPRECATED(); return func.apply(context || this, arguments); - } + }; } /** @@ -98,6 +98,15 @@ var linkwiz = { toggle: DEPRECATED_WRAP(dw_linkwiz.toggle, dw_linkwiz) }; +var locktimer = { + init: DEPRECATED_WRAP(dw_locktimer.init, dw_locktimer), + reset: DEPRECATED_WRAP(dw_locktimer.reset, dw_locktimer), + warning: DEPRECATED_WRAP(dw_locktimer.warning, dw_locktimer), + clear: DEPRECATED_WRAP(dw_locktimer.clear, dw_locktimer), + refresh: DEPRECATED_WRAP(dw_locktimer.refresh, dw_locktimer), + refreshed: DEPRECATED_WRAP(dw_locktimer.refreshed, dw_locktimer) +}; + var media_manager = { // treeattach, selectorattach, confirmattach are munched together into // dw_mediamanager.init @@ -178,8 +187,29 @@ function prependChild(parent,element) { } function addEvent(element, type, handler) { - DEPRECATED('Use jQuery.bind() instead.'); - jQuery(element).bind(type,{},handler); + DEPRECATED('Use jQuery.bind() instead. Note that jQuery’s behaviour' + + ' when a handler returns false differs from addEvent’s'); + jQuery(element).bind(type,{},function (e) { + // returning false in an addEvent event handler did not prevent + // bubbling but just canceled handlers on this node and prevented + // default behavior, so wrap the handler call and mimic that behavior. + // + // Refer to jQuery.event.handle(). + var ret = handler.apply(this, Array.prototype.slice.call(arguments, 0)); + if (typeof ret !== 'undefined') { + if ( ret !== false ) { + return ret; + } + // What jQuery does. + e.result = ret; + e.preventDefault(); + // Not what jQuery does. This would be: event.stopPropagation(); + // Hack it so that immediate propagation (other event handlers on + // this element) appears stopped without stopping the actual + // propagation (bubbling) + e.isImmediatePropagationStopped = function () { return true; }; + } + }); } function removeEvent(element, type, handler) { @@ -376,3 +406,9 @@ function gcs(node){ } } +/** + * Until 2011-05-25 "Rincewind", a code intended to fix some Safari issue + * always declared the global _timer. plugin:sortablejs relies on _timer + * being declared. + */ +var _timer; |