vendor/assets/javascripts/webshims/shims/combos/97.js in webshims-rails-1.14.3 vs vendor/assets/javascripts/webshims/shims/combos/97.js in webshims-rails-1.14.4

- old
+ new

@@ -1,18 +1,21 @@ -webshims.register('jme', function($, webshims, window, doc, undefined){ +webshims.register('jmebase', function($, webshims, window, doc, undefined){ "use strict"; var props = {}; var fns = {}; var slice = Array.prototype.slice; var readyLength = 0; var options = $.extend({selector: '.mediaplayer'}, webshims.cfg.mediaelement.jme); var baseSelector = options.selector; webshims.cfg.mediaelement.jme = options; + if(!$.jme){ + $.jme = {}; + } - $.jme = { + $.extend($.jme, { pluginsClasses: [], pluginsSel: '', plugins: {}, props: props, fns: fns, @@ -54,10 +57,14 @@ } else if(options.i18n && options.i18n[name]){ plugin.text = options.i18n[name]; } this.runPlugin('.'+plugin.className); }, + configmenuPlugins: {}, + addToConfigmenu: function(name, create){ + this.configmenuPlugins[name] = create; + }, defineMethod: function(name, fn){ fns[name] = fn; }, defineProp: function(name, desc){ if(!desc){ @@ -93,20 +100,24 @@ if(setValue != 'noDataSet'){ $.jme.data(elem, name, setValue); } } } - }; + }); $.fn.jmeProp = function(name, value){ return $.access( this, $.jme.prop, name, value, arguments.length > 1 ); }; $.fn.jmeFn = function(fn){ var args = slice.call( arguments, 1 ); var ret; this.each(function(){ + if(!$.jme.data(this).media){ + $(this).closest(baseSelector).jmePlayer(); + webshims.warn('jmeFn called to early or on wrong element!'); + } ret = (fns[fn] || $.prop(this, fn)).apply(this, args); if(ret !== undefined){ return false; } }); @@ -180,15 +191,13 @@ }; $.fn.jmePlayer = function(opts){ return this.each(function(){ - if(opts){ - $.jme.data(this, $.extend(true, {}, opts)); - } - var mediaUpdateFn, canPlay, removeCanPlay, canplayTimer, lastState, stopEmptiedEvent; + + var mediaUpdateFn, canPlay, removeCanPlay, canplayTimer, lastState, stopEmptiedEvent, forceRender; var media = $('audio, video', this).eq(0); var base = $(this); var jmeData = $.jme.data(this); var mediaData = $.jme.data(media[0]); @@ -196,11 +205,13 @@ base.addClass(media.prop('nodeName').toLowerCase()+'player'); mediaData.player = base; mediaData.media = media; if(!jmeData.media){ - + forceRender = function(){ + base[0].className = base[0].className; + }; removeCanPlay = function(){ media.off('canplay', canPlay); clearTimeout(canplayTimer); }; canPlay = function(){ @@ -255,10 +266,11 @@ } if(state){ lastState = state; base.attr('data-state', state); + setTimeout(forceRender); } }; jmeData.media = media; @@ -338,21 +350,21 @@ var src = data.media.prop('src'); if(src){ return [{src: src}]; } srces = $.map($('source', data.media).get(), function(source){ + var i, len; var src = { src: $.prop(source, 'src') }; - var tmp = $.attr(source, 'media'); - if(tmp){ - src.media = tmp; + var attributes = source.attributes; + + for(i = 0, len = attributes.length; i < len; i++){ + if(!('specified' in attributes[i]) || attributes[i].specified){ + src[attributes[i].nodeName] = attributes[i].nodeValue; + } } - tmp = $.attr(source, 'type'); - if(tmp){ - src.type = tmp; - } return src; }); return srces; }, set: function(elem, srces){ @@ -419,24 +431,23 @@ $.jme.data(data.player[0], 'controlElements', oldControls.add(controls)); data.player.triggerHandler('controlsadded'); } }); - webshims.isReady('jme', true); - webshims.addReady($.jme.initJME); - webshims._polyfill(['mediaelement']); - webshims.isReady('jme-base', true); - if(webshims.cfg.debug !== false){ - $(function(){ - if(document.getElementsByTagName('video').length && !document.querySelector(baseSelector)){ - webshims.warn("found video element but video wasn't wrapped inside a ."+ baseSelector +" element. Will not add control UI"); - } - }); - } + webshims.ready('DOM mediaelement', function(){ + webshims.isReady('jme', true); + webshims.addReady($.jme.initJME); + webshims.isReady('jme-base', true); + + if(webshims.cfg.debug !== false && document.getElementsByTagName('video').length && !document.querySelector(baseSelector)){ + webshims.warn("found video element but video wasn't wrapped inside a ."+ baseSelector +" element. Will not add control UI"); + } + }); + }); -;webshims.ready('jme DOM', function(){ +;webshims.ready('jme-base DOM', function(){ "use strict"; var webshims = window.webshims; var $ = webshims.$; var jme = $.jme; var listId = 0; @@ -819,10 +830,12 @@ $('track', media).remove(); $.each(item.tracks || [], function(i, track){ $('<track />').attr(track).appendTo(media); }); - + if(!item.srces){ + item.srces = item; + } media.jmeProp('srces', item.srces); }, _getItem: function(item){ if(item && (item.nodeName || item.jquery || typeof item == 'string')){ item = $(item).data('itemData');