WordPress/wp-includes/js/media-audiovideo.min.js

1 line
12 KiB
JavaScript
Raw Normal View History

!function(i,n,e){var s=wp.media,t={},a="undefined"==typeof _wpMediaViewsL10n?{}:_wpMediaViewsL10n;n.isUndefined(window._wpmejsSettings)||(t.pluginPath=_wpmejsSettings.pluginPath),wp.media.mixin={mejsSettings:t,pauseAllPlayers:function(){if(window.mejs&&window.mejs.players)for(var e in window.mejs.players)window.mejs.players[e].pause()},ua:{is:function(e){var t=!1,i=window.navigator.userAgent;switch(e){case"oldie":t=null!==i.match(/MSIE [6-8]/gi);break;case"ie":t=null!==i.match(/MSIE/gi);break;case"ff":t=null!==i.match(/firefox/gi);break;case"opera":t=null!==i.match(/OPR/);break;case"safari":t=null!==i.match(/safari/gi)&&null===i.match(/chrome/gi);break;case"chrome":t=null!==i.match(/safari/gi)&&null!==i.match(/chrome/gi)}return t}},compat:{opera:{audio:["ogg","wav"],video:["ogg","webm"]},chrome:{audio:["ogg","mpeg"],video:["ogg","webm","mp4","m4v","mpeg"]},ff:{audio:["ogg","mpeg"],video:["ogg","webm"]},safari:{audio:["mpeg","wav"],video:["mp4","m4v","mpeg","x-ms-wmv","quicktime"]},ie:{audio:["mpeg"],video:["mp4","m4v","mpeg"]}},isCompatible:function(e){if(!e.find("source").length)return!1;var t,i=this.ua,s=!1,o=!1;return!i.is("oldIE")&&(t=e.find("source"),n.find(this.compat,function(a,e){return i.is(e)&&(o=!0,n.each(t,function(e){var t=new RegExp("audio/("+a.audio.join("|")+")","gi"),i=new RegExp("video/("+a.video.join("|")+")","gi");null===e.type.match(i)&&null===e.type.match(t)||(s=!0)})),s||o}),s)},removePlayer:function(e){var t,i;for(t in e.options.features)if(e["clean"+(i=e.options.features[t])])try{e["clean"+i](e)}catch(e){}e.isDynamic||e.$node.remove(),"native"!==e.media.pluginType&&e.media.remove(),delete window.mejs.players[e.id],e.container.remove(),e.globalUnbind(),delete e.node.player},unsetPlayers:function(){this.players&&this.players.length&&(wp.media.mixin.pauseAllPlayers(),n.each(this.players,function(e){wp.media.mixin.removePlayer(e)}),this.players=[])}},wp.media.playlist=new wp.media.collection({tag:"playlist",editTitle:a.editPlaylistTitle,defaults:{id:wp.media.view.settings.post.id,style:"light",tracklist:!0,tracknumbers:!0,images:!0,artists:!0,type:"audio"}}),wp.media.audio={coerce:wp.media.coerce,defaults:{id:wp.media.view.settings.post.id,src:"",loop:!1,autoplay:!1,preload:"none",width:400},edit:function(e){e=wp.shortcode.next("audio",e).shortcode;return wp.media({frame:"audio",state:"audio-details",metadata:n.defaults(e.attrs.named,this.defaults)})},shortcode:function(i){var e,a=this;return n.each(this.defaults,function(e,t){i[t]=a.coerce(i,t),e===i[t]&&delete i[t]}),e=i.content,delete i.content,new wp.shortcode({tag:"audio",attrs:i,content:e})}},wp.media.video={coerce:wp.media.coerce,defaults:{id:wp.media.view.settings.post.id,src:"",poster:"",loop:!1,autoplay:!1,preload:"metadata",content:"",width:640,height:360},edit:function(e){var t=wp.shortcode.next("video",e).shortcode,e=t.attrs.named;return e.content=t.content,wp.media({frame:"video",state:"video-details",metadata:n.defaults(e,this.defaults)})},shortcode:function(i){var e,a=this;return n.each(this.defaults,function(e,t){i[t]=a.coerce(i,t),e===i[t]&&delete i[t]}),e=i.content,delete i.content,new wp.shortcode({tag:"video",attrs:i,content:e})}},s.model.PostMedia=e.Model.extend({initialize:function(){this.attachment=!1},setSource:function(e){this.attachment=e,this.extension=e.get("filename").split(".").pop(),this.get("src")&&this.extension===this.get("src").split(".").pop()&&this.unset("src"),n.contains(wp.media.view.settings.embedExts,this.extension)?this.set(this.extension,this.attachment.get("url")):this.unset(this.extension)},changeAttachment:function(e){var t=this;this.setSource(e),this.unset("src"),n.each(n.without(wp.media.view.settings.embedExts,this.extension),function(e){t.unset(e)})}}),s.controller.AudioDetails=s.controller.State.extend({defaults:{id:"audio-details",toolbar:"audio-details",title:a.audioDetailsTitle,content:"audio-details",menu:"audio-details",router:!1,priority:60},initialize:function(e){this.media=e.media,s.controller.State.prototype.initialize.apply(this,arguments)}}),s.controller.VideoDetails=s.controller.State.e