diff --git a/wp-includes/js/mce-view.js b/wp-includes/js/mce-view.js index 9dfef40034..feb7607e2a 100644 --- a/wp-includes/js/mce-view.js +++ b/wp-includes/js/mce-view.js @@ -124,10 +124,10 @@ window.wp = window.wp || {}; */ register: function( type, constructor ) { var defaultConstructor = { - shortcode: type, + type: type, View: {}, toView: function( content ) { - var match = wp.shortcode.next( this.shortcode, content ); + var match = wp.shortcode.next( this.type, content ); if ( ! match ) { return; @@ -488,7 +488,7 @@ window.wp = window.wp || {}; * @param {HTMLElement} node */ edit: function( node ) { - var media = wp.media[ this.shortcode ], + var media = wp.media[ this.type ], self = this, frame, data, callback; @@ -501,7 +501,7 @@ window.wp = window.wp || {}; } ); callback = function( selection ) { - var shortcode = wp.media[ self.shortcode ].shortcode( selection ).string(); + var shortcode = wp.media[ self.type ].shortcode( selection ).string(); $( node ).attr( 'data-wpview-text', window.encodeURIComponent( shortcode ) ); wp.mce.views.refreshView( self, shortcode ); frame.detach(); @@ -819,7 +819,7 @@ window.wp = window.wp || {}; self = this, frame, data, - isURL = 'embedURL' === this.shortcode; + isURL = 'embedURL' === this.type; $( document ).trigger( 'media:edit' ); diff --git a/wp-includes/js/mce-view.min.js b/wp-includes/js/mce-view.min.js index f252010a83..ef1a6e57f7 100644 --- a/wp-includes/js/mce-view.min.js +++ b/wp-includes/js/mce-view.min.js @@ -1 +1 @@ -window.wp=window.wp||{},function(a){"use strict";var b={},c={},d=wp.media,e=["encodedText"];wp.mce=wp.mce||{},wp.mce.View=function(a){a=a||{},this.type=a.type,_.extend(this,_.pick(a,e)),this.initialize.apply(this,arguments)},_.extend(wp.mce.View.prototype,{initialize:function(){},getHtml:function(){},render:function(){this.setContent('
'+a+"
"+e.find("source").eq(0).prop("src")+"
"))},getHtml:function(){var a=this.shortcode.attrs.named;return a.content=this.shortcode.content,this.template({model:_.defaults(a,wp.media[this.shortcode.tag].defaults)})},unbind:function(){this.unsetPlayers()}}),edit:function(b){var c,d,e,f=wp.media[this.shortcode],g=this;a(document).trigger("media:edit"),d=window.decodeURIComponent(a(b).attr("data-wpview-text")),c=f.edit(d),c.on("close",function(){c.detach()}),e=function(d){var e=wp.media[g.shortcode].shortcode(d).string();a(b).attr("data-wpview-text",window.encodeURIComponent(e)),wp.mce.views.refreshView(g,e),c.detach()},_.isArray(g.state)?_.each(g.state,function(a){c.state(a).on("update",e)}):c.state(g.state).on("update",e),c.open()}},wp.mce.views.register("video",_.extend({},wp.mce.av,{state:"video-details",View:_.extend({},wp.mce.av.View,{template:d.template("editor-video")})})),wp.mce.views.register("audio",_.extend({},wp.mce.av,{state:"audio-details",View:_.extend({},wp.mce.av.View,{template:d.template("editor-audio")})})),wp.mce.views.register("playlist",_.extend({},wp.mce.av,{state:["playlist-edit","video-playlist-edit"],View:_.extend({},wp.media.mixin,{template:d.template("editor-playlist"),overlay:!0,initialize:function(b){this.players=[],this.data={},this.attachments=[],this.shortcode=b.shortcode,a("body").on("click",".wp-switch-editor",this.pausePlayers),a(document).on("media:edit",this.pausePlayers),this.fetch(),a(this).on("ready",this.setPlaylist)},fetch:function(){this.attachments=wp.media.playlist.attachments(this.shortcode),this.dfd=this.attachments.more().done(_.bind(this.render,this))},setPlaylist:function(b,c,d){this.data.tracks&&this.players.push(new WPPlaylistView({el:a(d).find(".wp-playlist").get(0),metadata:this.data}).player)},getHtml:function(){var a,b,c=this.shortcode.attrs.named,e=wp.media.playlist,f=[];if(!this.dfd||"pending"!==this.dfd.state()||this.attachments.length)return _.each(e.defaults,function(a,b){c[b]=e.coerce(c,b)}),a={type:c.type,style:c.style,tracklist:c.tracklist,tracknumbers:c.tracknumbers,images:c.images,artists:c.artists},this.attachments.length?(b=this.attachments.toJSON(),_.each(b,function(b){var e={},g={},h={src:b.url,type:b.mime,title:b.title,caption:b.caption,description:b.description,meta:b.meta};"video"===c.type?(e.width=b.width,e.height=b.height,d.view.settings.contentWidth?(g.width=d.view.settings.contentWidth-22,g.height=Math.ceil(e.height*g.width/e.width),a.width||(a.width=g.width,a.height=g.height)):a.width||(a.width=b.width,a.height=b.height),h.dimensions={original:e,resized:_.isEmpty(g)?e:g}):a.width=400,h.image=b.image,h.thumb=b.thumb,f.push(h)}),a.tracks=f,this.data=a,this.template(a)):this.template(a)},unbind:function(){this.unsetPlayers()}})})),wp.mce.embedView=_.extend({},wp.media.mixin,{overlay:!0,initialize:function(b){this.players=[],this.content=b.content,this.fetching=!1,this.parsed=!1,this.original=b.url||b.shortcode.string(),this.shortcode=b.url?"[embed]"+b.url+"[/embed]":b.shortcode.string(),_.bindAll(this,"setHtml","setNode","fetch"),a(this).on("ready",this.setNode)},unbind:function(){var a=this;_.each(this.players,function(b){b.pause(),a.removePlayer(b)}),this.players=[]},setNode:function(){this.parsed?(this.setHtml(this.parsed),this.parseMediaShortcodes()):this.fetching||this.fetch()},fetch:function(){var b=this;this.fetching=!0,wp.ajax.send("parse-embed",{data:{post_ID:a("#post_ID").val()||0,shortcode:this.shortcode}}).always(function(){b.fetching=!1}).done(function(a){a&&(b.parsed=a,b.setHtml(a))}).fail(function(a){a&&a.message?"embed"===b.type?b.setError(a.message,"admin-media"):b.setContent(""+b.original+"
",null,!0):a&&a.statusText&&b.setError(a.statusText,"admin-media")})},setHtml:function(b){var c,d,e,f,g=window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver,h=tinymce.DOM;if(-1!==b.indexOf("