vendor/assets/javascripts/webshims/shims/combos/12.js in webshims-rails-1.14.3 vs vendor/assets/javascripts/webshims/shims/combos/12.js in webshims-rails-1.14.4
- old
+ new
@@ -156,11 +156,11 @@
return true;
} :
webshims.$.noop
;
- if(!Modernizr.video){
+ if(!webshims.support.mediaelement){
loadEmbed();
} else {
webshims.ready('WINDOWLOAD', loadEmbed);
}
@@ -219,13 +219,14 @@
expressInstallCallback: wasRemoved
};
}();
webshims.isReady('swfmini', true);
-;(function(Modernizr, webshims){
+;(function(webshims){
"use strict";
- var hasNative = Modernizr.audio && Modernizr.video;
+ var support = webshims.support;
+ var hasNative = support.mediaelement;
var supportsLoop = false;
var bugs = webshims.bugs;
var swfType = 'mediaelement-jaris';
var loadSwf = function(){
webshims.ready(swfType, function(){
@@ -244,26 +245,26 @@
return;
}
if(hasNative){
var videoElem = document.createElement('video');
- Modernizr.videoBuffered = ('buffered' in videoElem);
- Modernizr.mediaDefaultMuted = ('defaultMuted' in videoElem);
+ support.videoBuffered = ('buffered' in videoElem);
+ support.mediaDefaultMuted = ('defaultMuted' in videoElem);
supportsLoop = ('loop' in videoElem);
- Modernizr.mediaLoop = supportsLoop;
+ support.mediaLoop = supportsLoop;
webshims.capturingEvents(['play', 'playing', 'waiting', 'paused', 'ended', 'durationchange', 'loadedmetadata', 'canplay', 'volumechange']);
- if( !Modernizr.videoBuffered || !supportsLoop || (!Modernizr.mediaDefaultMuted && isIE && 'ActiveXObject' in window) ){
+ if( !support.videoBuffered || !supportsLoop || (!support.mediaDefaultMuted && isIE && 'ActiveXObject' in window) ){
webshims.addPolyfill('mediaelement-native-fix', {
d: ['dom-support']
});
webshims.loader.loadList(['mediaelement-native-fix']);
}
}
- if(Modernizr.track && !bugs.track){
+ if(support.track && !bugs.track){
(function(){
if(!bugs.track){
if(window.VTTCue && !window.TextTrackCue){
window.TextTrackCue = window.VTTCue;
@@ -591,23 +592,11 @@
if(data && data.isActive == 'third') {
mediaelement.setActive(elem, 'html5', data);
}
}
};
- var allowedPreload = {'metadata': 1, 'auto': 1, '': 1};
- var fixPreload = function(elem){
- var preload, img;
- if(elem.getAttribute('preload') == 'none'){
- if(allowedPreload[(preload = $.attr(elem, 'data-preload'))]){
- $.attr(elem, 'preload', preload);
- } else if(hasNative && (preload = elem.getAttribute('poster'))){
- img = document.createElement('img');
- img.src = preload;
- }
- }
- };
- var stopParent = /^(?:embed|object|datalist)$/i;
+ var stopParent = /^(?:embed|object|datalist|picture)$/i;
var selectSource = function(elem, data){
var baseData = webshims.data(elem, 'mediaelementBase') || webshims.data(elem, 'mediaelementBase', {});
var _srces = mediaelement.srces(elem);
var parent = elem.parentNode;
@@ -618,11 +607,10 @@
if(!_srces.length || !parent || parent.nodeType != 1 || stopParent.test(parent.nodeName || '')){return;}
data = data || webshims.data(elem, 'mediaelement');
if(mediaelement.sortMedia){
_srces.sort(mediaelement.sortMedia);
}
- fixPreload(elem);
stepSources(elem, data, _srces);
};
mediaelement.selectSource = selectSource;
@@ -642,11 +630,11 @@
var initMediaElements = function(){
var testFixMedia = function(){
if(webshims.implement(this, 'mediaelement')){
selectSource(this);
- if(!Modernizr.mediaDefaultMuted && $.attr(this, 'muted') != null){
+ if(!support.mediaDefaultMuted && $.attr(this, 'muted') != null){
$.prop(this, 'muted', true);
}
}
};
@@ -667,11 +655,11 @@
selectSource(this, data);
if(hasNative && (!data || data.isActive == 'html5') && supLoad.prop._supvalue){
supLoad.prop._supvalue.apply(this, arguments);
}
- if(!loadTrackUi.loaded && $('track', this).length){
+ if(!loadTrackUi.loaded && this.querySelector('track')){
loadTrackUi();
}
$(this).triggerHandler('wsmediareload');
}
}
@@ -766,19 +754,20 @@
webshims.ready(swfType, initMediaElements);
}
webshims.ready('track', loadTrackUi);
});
-})(Modernizr, webshims);
+})(webshims);
;webshims.register('track', function($, webshims, window, document, undefined){
"use strict";
var mediaelement = webshims.mediaelement;
var id = new Date().getTime();
//descriptions are not really shown, but they are inserted into the dom
var showTracks = {subtitles: 1, captions: 1, descriptions: 1};
var dummyTrack = $('<track />');
- var supportTrackMod = Modernizr.ES5 && Modernizr.objectAccessor;
+ var support = webshims.support;
+ var supportTrackMod = support.ES5 && support.objectAccessor;
var createEventTarget = function(obj){
var eventList = {};
obj.addEventListener = function(name, fn){
if(eventList[name]){
webshims.error('always use $.on to the shimed event: '+ name +' already bound fn was: '+ eventList[name] +' your fn was: '+ fn);
@@ -1083,38 +1072,44 @@
};
var ttmlTextToVTT = function(ttml){
ttml = $.parseXML(ttml) || [];
return $(ttml).find('[begin][end]').map(mapTtmlToVtt).get().join('\n\n') || '';
};
-
+ var loadingTracks = 0;
+
mediaelement.loadTextTrack = function(mediaelem, track, trackData, _default){
- var loadEvents = 'play playing';
+ var loadEvents = 'play playing loadedmetadata loadstart';
var obj = trackData.track;
var load = function(){
var error, ajax, createAjax;
- var src = obj.mode != 'disabled' && ($.attr(track, 'src') && $.prop(track, 'src'));
+ var isDisabled = obj.mode == 'disabled';
+ var videoState = !!($.prop(mediaelem, 'readyState') > 0 || $.prop(mediaelem, 'networkState') == 2 || !$.prop(mediaelem, 'paused'));
+ var src = (!isDisabled || videoState) && ($.attr(track, 'src') && $.prop(track, 'src'));
if(src){
$(mediaelem).off(loadEvents, load).off('updatetrackdisplay', load);
if(!trackData.readyState){
error = function(){
+ loadingTracks--;
trackData.readyState = 3;
obj.cues = null;
obj.activeCues = obj.shimActiveCues = obj._shimActiveCues = null;
$(track).triggerHandler('error');
};
trackData.readyState = 1;
try {
obj.cues = mediaelement.createCueList();
obj.activeCues = obj.shimActiveCues = obj._shimActiveCues = mediaelement.createCueList();
+ loadingTracks++;
createAjax = function(){
ajax = $.ajax({
dataType: 'text',
url: src,
success: function(text){
- var contentType = ajax.getResponseHeader('content-type');
+ loadingTracks--;
+ var contentType = ajax.getResponseHeader('content-type') || '';
if(!contentType.indexOf('application/xml')){
text = ttmlTextToVTT(text);
} else if(contentType.indexOf('text/vtt')){
webshims.error('set the mime-type of your WebVTT files to text/vtt. see: http://dev.w3.org/html5/webvtt/#text/vtt');
@@ -1126,17 +1121,20 @@
$(mediaelem).triggerHandler('updatetrackdisplay');
} else {
error();
}
});
-
},
error: error
});
};
if($.ajax && $.ajaxSettings.xhr){
- createAjax();
+ if(isDisabled){
+ setTimeout(createAjax, loadingTracks * 2);
+ } else {
+ createAjax();
+ }
} else {
webshims.ready('jajax', createAjax);
webshims.loader.loadList(['jajax']);
}
} catch(er){
@@ -1151,17 +1149,16 @@
obj._shimActiveCues = null;
obj.activeCues = null;
obj.cues = null;
$(mediaelem).on(loadEvents, load);
+
if(_default){
obj.mode = showTracks[obj.kind] ? 'showing' : 'hidden';
- webshims.ready('WINDOWLOAD', load);
+ load();
} else {
- webshims.ready('WINDOWLOAD', function(){
- $(mediaelem).on('updatetrackdisplay', load);
- });
+ $(mediaelem).on('updatetrackdisplay', load);
}
};
mediaelement.createTextTrack = function(mediaelem, track){
var obj, trackData;
@@ -1429,11 +1426,11 @@
}
return baseData.textTracks;
};
- if(!Modernizr.track){
+ if(!support.track){
webshims.defineNodeNamesBooleanProperty(['track'], 'default');
webshims.reflectProperties(['track'], ['srclang', 'label']);
webshims.defineNodeNameProperties('track', {
src: {
@@ -1444,11 +1441,11 @@
});
}
webshims.defineNodeNameProperties('track', {
kind: {
- attr: Modernizr.track ? {
+ attr: support.track ? {
set: function(value){
var trackData = webshims.data(this, 'trackData');
this.setAttribute('data-kind', value);
if(trackData){
trackData.attrKind = value;
@@ -1499,11 +1496,10 @@
}
});
//
-
webshims.defineNodeNamesProperties(['track'], {
ERROR: {
value: 3
},
LOADED: {
@@ -1609,11 +1605,11 @@
.each(function(){
updateMediaTrackList.call(this);
})
.on('emptied updatetracklist wsmediareload', thUpdateList)
.each(function(){
- if(Modernizr.track){
+ if(support.track){
var shimedTextTracks = $.prop(this, 'textTracks');
var origTextTracks = this.textTracks;
if(shimedTextTracks.length != origTextTracks.length){
webshims.warn("textTracks couldn't be copied");
@@ -1634,9 +1630,9 @@
}, 9);
}
});
});
- if(Modernizr.texttrackapi){
+ if(support.texttrackapi){
$('video, audio').trigger('trackapichange');
}
});