vendor/assets/javascripts/webshims/shims/combos/25.js in webshims-rails-0.4.6 vs vendor/assets/javascripts/webshims/shims/combos/25.js in webshims-rails-0.4.7

- old
+ new

@@ -14,10 +14,15 @@ var oldVal = $.fn.val; var singleVal = function(elem, name, val, pass, _argless){ return (_argless) ? oldVal.call($(elem)) : oldVal.call($(elem), val); }; + + $.fn.onTrigger = function(evt, fn){ + return this.on(evt, fn).each(fn); + }; + $.fn.val = function(val){ var elem = this[0]; if(arguments.length && val == null){ val = ''; } @@ -208,18 +213,18 @@ }; }); //see also: https://github.com/lojjic/PIE/issues/40 | https://prototype.lighthouseapp.com/projects/8886/tickets/1107-ie8-fatal-crash-when-prototypejs-is-loaded-with-rounded-cornershtc - var isExtendNativeSave = (!$.browser.msie || parseInt($.browser.version, 10) > 8); + var isExtendNativeSave = Modernizr.ES5; var extendNativeValue = (function(){ var UNKNOWN = webshims.getPrototypeOf(document.createElement('foobar')); var has = Object.prototype.hasOwnProperty; return function(nodeName, prop, desc){ - var elem = document.createElement(nodeName); - var elemProto = webshims.getPrototypeOf(elem); - if( isExtendNativeSave && elemProto && UNKNOWN !== elemProto && ( !elem[prop] || !has.call(elem, prop) ) ){ + var elem; + var elemProto; + if( isExtendNativeSave && (elem = document.createElement(nodeName)) && (elemProto = webshims.getPrototypeOf(elem)) && UNKNOWN !== elemProto && ( !elem[prop] || !has.call(elem, prop) ) ){ var sup = elem[prop]; desc._supvalue = function(){ if(sup && sup.apply){ return sup.apply(this, arguments); } @@ -415,11 +420,11 @@ docObserve.height = docObserve.getHeight(); docObserve.width = docObserve.getWidth(); } - $.event.trigger('updateshadowdom'); + $(document).triggerHandler('updateshadowdom'); }, (e.type == 'resize') ? 50 : 9); }, _create: function(){ $.each({ Height: "getHeight", Width: "getWidth" }, function(name, type){ var body = document.body; @@ -459,11 +464,10 @@ } } }; - $.event.customEvent.updateshadowdom = true; webshims.docObserve = function(){ webshims.ready('DOM', function(){ docObserve.start(); }); }; @@ -903,51 +907,51 @@ webshims.isReady('webshimLocalization', true); }); //html5a11y (function($, document){ - var browserVersion = $.webshims.browserVersion; - if($.browser.mozilla && browserVersion > 5){return;} - if (!$.browser.msie || (browserVersion < 12 && browserVersion > 7)) { - var elemMappings = { - article: "article", - aside: "complementary", - section: "region", - nav: "navigation", - address: "contentinfo" - }; - var addRole = function(elem, role){ - var hasRole = elem.getAttribute('role'); - if (!hasRole) { - elem.setAttribute('role', role); + //if we support basic styleing or do not support ARIA (assumed) abort + if(!Modernizr.localstorage || ('hidden' in document.createElement('a'))){return;} + + var elemMappings = { + article: "article", + aside: "complementary", + section: "region", + nav: "navigation", + address: "contentinfo" + }; + var addRole = function(elem, role){ + var hasRole = elem.getAttribute('role'); + if (!hasRole) { + elem.setAttribute('role', role); + } + }; + + $.webshims.addReady(function(context, contextElem){ + $.each(elemMappings, function(name, role){ + var elems = $(name, context).add(contextElem.filter(name)); + for (var i = 0, len = elems.length; i < len; i++) { + addRole(elems[i], role); } - }; - - $.webshims.addReady(function(context, contextElem){ - $.each(elemMappings, function(name, role){ - var elems = $(name, context).add(contextElem.filter(name)); - for (var i = 0, len = elems.length; i < len; i++) { - addRole(elems[i], role); - } - }); - if (context === document) { - var header = document.getElementsByTagName('header')[0]; - var footers = document.getElementsByTagName('footer'); - var footerLen = footers.length; - if (header && !$(header).closest('section, article')[0]) { - addRole(header, 'banner'); - } - if (!footerLen) { - return; - } - var footer = footers[footerLen - 1]; - if (!$(footer).closest('section, article')[0]) { - addRole(footer, 'contentinfo'); - } - } }); - } + if (context === document) { + var header = document.getElementsByTagName('header')[0]; + var footers = document.getElementsByTagName('footer'); + var footerLen = footers.length; + if (header && !$(header).closest('section, article')[0]) { + addRole(header, 'banner'); + } + if (!footerLen) { + return; + } + var footer = footers[footerLen - 1]; + if (!$(footer).closest('section, article')[0]) { + addRole(footer, 'contentinfo'); + } + } + }); + })(jQuery, document); (function($, Modernizr, webshims){ "use strict"; var hasNative = Modernizr.audio && Modernizr.video; @@ -998,11 +1002,13 @@ webshims.ready('WINDOWLOAD '+swfType, function(){ setTimeout(function(){ if(hasSwf && !options.preferFlash && webshims.mediaelement.createSWF && !$(e.target).closest('audio, video').is('.nonnative-api-active')){ options.preferFlash = true; document.removeEventListener('error', switchOptions, true); - $('audio, video').mediaLoad(); + $('audio, video').each(function(){ + webshims.mediaelement.selectSource(this); + }); webshims.info("switching mediaelements option to 'preferFlash', due to an error with native player: "+e.target.src); } else if(!hasSwf){ document.removeEventListener('error', switchOptions, true); } }, 20); @@ -1402,12 +1408,12 @@ if(!_srces.length || !parent || parent.nodeType != 1 || stopParent.test(parent.nodeName || '')){return;} data = data || webshims.data(elem, 'mediaelement'); stepSources(elem, data, options.preferFlash || undefined, _srces); }; + mediaelement.selectSource = selectSource; - $(document).on('ended', function(e){ var data = webshims.data(e.target, 'mediaelement'); if( supportsLoop && (!data || data.isActive == 'html5') && !$.prop(e.target, 'loop')){return;} setTimeout(function(){ if( $.prop(e.target, 'paused') || !$.prop(e.target, 'loop') ){return;} @@ -1468,56 +1474,61 @@ webshims.addReady(function(context, insertedElement){ var media = $('video, audio', context) .add(insertedElement.filter('video, audio')) .each(function(){ - if($.browser.msie && webshims.browserVersion > 8 && $.prop(this, 'paused') && !$.prop(this, 'readyState') && $(this).is('audio[preload="none"][controls]:not([autoplay])')){ + var data = webshims.data(this, 'mediaelement'); + + if(hasNative && $.prop(this, 'paused') && !$.prop(this, 'readyState') && $(this).is('audio[preload="none"][controls]:not([autoplay])') && (!data || data.isActive == 'html5')){ + //IE controls not visible bug $(this).prop('preload', 'metadata').mediaLoad(); } else { - selectSource(this); + selectSource(this, data); } - - if(hasNative){ - var bufferTimer; - var lastBuffered; - var elem = this; - var getBufferedString = function(){ - var buffered = $.prop(elem, 'buffered'); - if(!buffered){return;} - var bufferString = ""; - for(var i = 0, len = buffered.length; i < len;i++){ - bufferString += buffered.end(i); - } - return bufferString; - }; - var testBuffer = function(){ - var buffered = getBufferedString(); - if(buffered != lastBuffered){ - lastBuffered = buffered; - $(elem).triggerHandler('progress'); - } - }; - $(this) - .on({ - 'play loadstart progress': function(e){ - if(e.type == 'progress'){ - lastBuffered = getBufferedString(); - } - clearTimeout(bufferTimer); - bufferTimer = setTimeout(testBuffer, 999); - }, - 'emptied stalled mediaerror abort suspend': function(e){ - if(e.type == 'emptied'){ - lastBuffered = false; - } - clearTimeout(bufferTimer); + //FF progress bug + (function(){ + var bufferTimer; + var lastBuffered; + var elem = this; + var getBufferedString = function(){ + var buffered = $.prop(elem, 'buffered'); + if(!buffered){return;} + var bufferString = ""; + for(var i = 0, len = buffered.length; i < len;i++){ + bufferString += buffered.end(i); } - }) - ; + return bufferString; + }; + var testBuffer = function(){ + var buffered = getBufferedString(); + if(buffered != lastBuffered){ + lastBuffered = buffered; + $(elem).triggerHandler('progress'); + } + }; + + $(this) + .on({ + 'play loadstart progress': function(e){ + if(e.type == 'progress'){ + lastBuffered = getBufferedString(); + } + clearTimeout(bufferTimer); + bufferTimer = setTimeout(testBuffer, 999); + }, + 'emptied stalled mediaerror abort suspend': function(e){ + if(e.type == 'emptied'){ + lastBuffered = false; + } + clearTimeout(bufferTimer); + } + }) + ; + })(); } }) ; if(!loadTrackUi.loaded && $('track', media).length){ @@ -1547,10 +1558,11 @@ })(jQuery, Modernizr, jQuery.webshims); jQuery.webshims.register('track', function($, webshims, window, document, undefined){ "use strict"; var mediaelement = webshims.mediaelement; var id = new Date().getTime(); + var ADDBACK = $.fn.addBack ? 'addBack' : 'andSelf'; //descriptions are not really shown, but they are inserted into the dom var showTracks = {subtitles: 1, captions: 1, descriptions: 1}; var notImplemented = function(){ webshims.error('not implemented yet'); }; @@ -1934,10 +1946,10 @@ }); }); } trackData = webshims.data(track, 'trackData', {track: obj}); - mediaelement.loadTextTrack(mediaelem, track, trackData, ($.prop(track, 'default') && $(track).siblings('track[default]').andSelf()[0] == track)); + mediaelement.loadTextTrack(mediaelem, track, trackData, ($.prop(track, 'default') && $(track).siblings('track[default]')[ADDBACK]()[0] == track)); } else { if(supportTrackMod){ copyProps.forEach(function(copyProp){ webshims.defineProperty(obj, copyName[copyProp] || copyProp, { value: track[copyProp], \ No newline at end of file