vendor/assets/javascripts/webshims/shims/combos/22.js in webshims-rails-1.11.3.1 vs vendor/assets/javascripts/webshims/shims/combos/22.js in webshims-rails-1.11.6
- old
+ new
@@ -15,11 +15,11 @@
if(oldSummary){
if(oldSummary.hasClass('fallback-summary')){
oldSummary.remove();
} else {
oldSummary
- .unbind('.summaryPolyfill')
+ .off('.summaryPolyfill')
.removeData('detailsElement')
.removeAttr('role')
.removeAttr('tabindex')
.removeAttr('aria-expanded')
.removeClass('summary-button')
@@ -33,11 +33,11 @@
}
};
var getSummary = function(details){
var summary = $.data(details, 'summaryElement');
if(!summary){
- summary = $('> summary:first-child', details);
+ summary = $(details).children('summary:first-child');
if(!summary[0]){
$(details).prependPolyfill('<summary class="fallback-summary">'+ options.text +'</summary>');
summary = $.data(details, 'summaryElement');
} else {
bindDetailsSummary(summary, details);
@@ -465,13 +465,13 @@
mediaelement.loadTextTrack = function(mediaelem, track, trackData, _default){
var loadEvents = 'play playing updatetrackdisplay';
var obj = trackData.track;
var load = function(){
- var error, ajax, src;
+ var error, ajax, src, createAjax;
if(obj.mode != 'disabled' && $.attr(track, 'src') && (src = $.prop(track, 'src'))){
- $(mediaelem).unbind(loadEvents, load);
+ $(mediaelem).off(loadEvents, load);
if(!trackData.readyState){
error = function(){
trackData.readyState = 3;
obj.cues = null;
obj.activeCues = obj.shimActiveCues = obj._shimActiveCues = null;
@@ -479,30 +479,38 @@
};
trackData.readyState = 1;
try {
obj.cues = mediaelement.createCueList();
obj.activeCues = obj.shimActiveCues = obj._shimActiveCues = mediaelement.createCueList();
- ajax = $.ajax({
- dataType: 'text',
- url: src,
- success: function(text){
- if(ajax.getResponseHeader('content-type') != 'text/vtt'){
- webshims.error('set the mime-type of your WebVTT files to text/vtt. see: http://dev.w3.org/html5/webvtt/#text/vtt');
- }
- mediaelement.parseCaptions(text, obj, function(cues){
- if(cues && 'length' in cues){
- trackData.readyState = 2;
- $(track).triggerHandler('load');
- $(mediaelem).triggerHandler('updatetrackdisplay');
- } else {
- error();
+ createAjax = function(){
+ ajax = $.ajax({
+ dataType: 'text',
+ url: src,
+ success: function(text){
+ if(ajax.getResponseHeader('content-type') != 'text/vtt'){
+ webshims.error('set the mime-type of your WebVTT files to text/vtt. see: http://dev.w3.org/html5/webvtt/#text/vtt');
}
- });
-
- },
- error: error
- });
+ mediaelement.parseCaptions(text, obj, function(cues){
+ if(cues && 'length' in cues){
+ trackData.readyState = 2;
+ $(track).triggerHandler('load');
+ $(mediaelem).triggerHandler('updatetrackdisplay');
+ } else {
+ error();
+ }
+ });
+
+ },
+ error: error
+ });
+ };
+ if($.ajax){
+ createAjax();
+ } else {
+ webshims.ready('$ajax', createAjax);
+ webshims.loader.loadList(['$ajax']);
+ }
} catch(er){
error();
webshims.error(er);
}
}
@@ -511,11 +519,11 @@
trackData.readyState = 0;
obj.shimActiveCues = null;
obj._shimActiveCues = null;
obj.activeCues = null;
obj.cues = null;
- $(mediaelem).unbind(loadEvents, load);
+ $(mediaelem).off(loadEvents, load);
$(mediaelem).on(loadEvents, load);
if(_default){
obj.mode = showTracks[obj.kind] ? 'showing' : 'hidden';
load();
}
@@ -930,22 +938,22 @@
return textTrack;
}
}
}, 'prop');
-
- $(document).on('emptied ended updatetracklist', function(e){
+ //wsmediareload
+ var thUpdateList = function(e){
if($(e.target).is('audio, video')){
var baseData = webshims.data(e.target, 'mediaelementBase');
if(baseData){
clearTimeout(baseData.updateTrackListTimer);
baseData.updateTrackListTimer = setTimeout(function(){
updateMediaTrackList.call(e.target, baseData);
}, 0);
}
}
- });
+ };
var getNativeReadyState = function(trackElem, textTrack){
return textTrack.readyState || trackElem.readyState;
};
var stopOriginalEvent = function(e){
@@ -981,9 +989,10 @@
$('video, audio', context)
.add(insertedMedia)
.each(function(){
updateMediaTrackList.call(this);
})
+ .on('emptied updatetracklist wsmediareload', thUpdateList)
.each(function(){
if(Modernizr.track){
var shimedTextTracks = $.prop(this, 'textTracks');
var origTextTracks = this.textTracks;
if(shimedTextTracks.length != origTextTracks.length){
\ No newline at end of file