vendor/assets/javascripts/webshims/shims/dom-extend.js in webshims-rails-1.10.3 vs vendor/assets/javascripts/webshims/shims/dom-extend.js in webshims-rails-1.10.6

- old
+ new

@@ -1,18 +1,69 @@ //DOM-Extension helper -jQuery.webshims.register('dom-extend', function($, webshims, window, document, undefined){ +webshims.register('dom-extend', function($, webshims, window, document, undefined){ "use strict"; - webshims.assumeARIA = Modernizr.localstorage || Modernizr.video || Modernizr.boxsizing; + webshims.assumeARIA = $.support.getSetAttribute || Modernizr.canvas || Modernizr.video || Modernizr.boxsizing; if($('<input type="email" />').attr('type') == 'text' || $('<form />').attr('novalidate') === "" || ('required' in $('<input />')[0].attributes)){ webshims.error("IE browser modes are busted in IE10. Please test your HTML/CSS/JS with a real IE version or at least IETester or similiar tools"); } if(!$.parseHTML){ webshims.error("Webshims needs jQuery 1.8+ to work properly. Please update your jQuery version or downgrade webshims."); } + if (!webshims.cfg.no$Switch) { + var switch$ = function(){ + if (window.jQuery && (!window.$ || window.jQuery == window.$) && !window.jQuery.webshims) { + webshims.error("jQuery was included more than once. Make sure to include it only once! Webshims and other Plugins might not work properly."); + if (window.$) { + window.$ = webshims.$; + } + window.jQuery = webshims.$; + } + if(webshims.M != Modernizr){ + webshims.error("Modernizr was included more than once. Make sure to include it only once! Webshims and other scripts might not work properly."); + for(var i in Modernizr){ + if(!(i in webshims.M)){ + webshims.M[i] = Modernizr[i]; + } + } + Modernizr = webshims.M; + } + }; + switch$(); + setTimeout(switch$, 90); + $(switch$); + } +// (function(){ +// var hostNames = { +// 'afarkas.github.io': 1, +// localhost: 1, +// '127.0.0.1': 1 +// }; +// +// if( webshims.debug && (hostNames[location.hostname] || location.protocol == 'file:') ){ +// var list = $('<ul class="webshims-debug-list" />'); +// webshims.errorLog.push = function(message){ +// list.appendTo('body'); +// $('<li style="display: none;">'+ message +'</li>') +// .appendTo(list) +// .slideDown() +// .delay(3000) +// .slideUp(function(){ +// $(this).remove(); +// if(!$('li', list).length){ +// list.detach(); +// } +// }) +// ; +// }; +// $.each(webshims.errorLog, function(i, message){ +// webshims.errorLog.push(message); +// }); +// } +// })(); //shortcus var modules = webshims.modules; var listReg = /\s*,\s*/; @@ -26,10 +77,28 @@ var oldVal = $.fn.val; var singleVal = function(elem, name, val, pass, _argless){ return (_argless) ? oldVal.call($(elem)) : oldVal.call($(elem), val); }; + //jquery mobile and jquery ui + if(!$.widget){ + (function(){ + var _cleanData = $.cleanData; + $.cleanData = function( elems ) { + if(!$.widget){ + for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) { + try { + $( elem ).triggerHandler( "remove" ); + // http://bugs.jquery.com/ticket/8235 + } catch( e ) {} + } + } + _cleanData( elems ); + }; + })(); + } + $.fn.val = function(val){ var elem = this[0]; if(arguments.length && val == null){ val = ''; @@ -59,10 +128,22 @@ }; $.fn.onTrigger = function(evt, fn){ return this.on(evt, fn).each(fn); }; + $.fn.onWSOff = function(evt, fn, trigger, evtDel){ + if(!evtDel){ + evtDel = document; + } + $(evtDel)[trigger ? 'onTrigger' : 'on'](evt, fn); + this.on('remove', function(e){ + if(!e.originalEvent){ + $(evtDel).off(evt, fn); + } + }); + }; + var dataID = '_webshimsLib'+ (Math.round(Math.random() * 1000)); var elementData = function(elem, key, val){ elem = elem.jquery ? elem[0] : elem; if(!elem){return val || {};} var data = $.data(elem, dataID); @@ -420,11 +501,11 @@ }; })(), implement: function(elem, type){ var data = elementData(elem, 'implemented') || elementData(elem, 'implemented', {}); if(data[type]){ - webshims.info(type +' already implemented for element #'+elem.id); + webshims.warn(type +' already implemented for element #'+elem.id); return false; } data[type] = true; return true; }, @@ -563,9 +644,15 @@ if(opts.shadowFocusElement.jquery){ opts.shadowFocusElement = opts.shadowFocusElement[0]; } shadowFocusElementData = $.data(opts.shadowFocusElement, dataID) || $.data(opts.shadowFocusElement, dataID, shadowFocusElementData); } + + $(nativeElem).on('remove', function(e){ + if (!e.originalEvent) { + $(shadowElem).remove(); + } + }); nativeData.hasShadow = shadowElem; shadowFocusElementData.nativeElement = shadowData.nativeElement = nativeElem; shadowFocusElementData.shadowData = shadowData.shadowData = nativeData.shadowData = { nativeElement: nativeElem,