From 93170e58fa0b17cdd26aa8f589908c87339c0a1f Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Mon, 7 Jul 2014 22:41:15 +0000 Subject: [PATCH] TinyMCE wpView: - Add loadingPlaceholder() that returns some html to use as placeholder while the view is loading. Includes a subtle CSS based loading animation. - Fix setContent(), it should empty the element before appending the new node. - Change getHtml() to always return a string. Fixes #28761. Built from https://develop.svn.wordpress.org/trunk@29019 git-svn-id: http://core.svn.wordpress.org/trunk@28807 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/js/mce-view.js | 24 ++++++--- wp-includes/js/mce-view.min.js | 2 +- .../js/tinymce/skins/wordpress/wp-content.css | 49 ++++++++++++++++++- 3 files changed, 65 insertions(+), 10 deletions(-) diff --git a/wp-includes/js/mce-view.js b/wp-includes/js/mce-view.js index a5bcdc2329..87d96efce4 100644 --- a/wp-includes/js/mce-view.js +++ b/wp-includes/js/mce-view.js @@ -36,8 +36,19 @@ window.wp = window.wp || {}; _.extend( wp.mce.View.prototype, { initialize: function() {}, - getHtml: function() {}, + getHtml: function() { + return ''; + }, + loadingPlaceholder: function() { + return '' + + '
' + + '
' + + '
' + + '
'; + }, render: function() { + var html = this.getHtml() || this.loadingPlaceholder(); + this.setContent( '

\u00a0

' + '
' + @@ -46,7 +57,7 @@ window.wp = window.wp || {}; '
' + '
' + '
' + - this.getHtml() + + html + '
' + ( this.overlay ? '
' : '' ) + '' + @@ -82,7 +93,7 @@ window.wp = window.wp || {}; if ( option === 'replace' ) { element = editor.dom.replace( html, wrap ); } else { - element.appendChild( html ); + $( element ).empty().append( html ); } } @@ -359,7 +370,7 @@ window.wp = window.wp || {}; // Don't render errors while still fetching attachments if ( this.dfd && 'pending' === this.dfd.state() && ! this.attachments.length ) { - return; + return ''; } if ( this.attachments.length ) { @@ -605,7 +616,7 @@ window.wp = window.wp || {}; // Don't render errors while still fetching attachments if ( this.dfd && 'pending' === this.dfd.state() && ! this.attachments.length ) { - return; + return ''; } _.each( model.defaults, function( value, key ) { @@ -813,9 +824,6 @@ window.wp = window.wp || {}; $( '.wp-audio-shortcode, .wp-video-shortcode', this.node ).each( function ( i, element ) { self.players.push( new MediaElementPlayer( element, self.mejsSettings ) ); } ); - }, - getHtml: function() { - return ''; } } ); diff --git a/wp-includes/js/mce-view.min.js b/wp-includes/js/mce-view.min.js index ae849e68da..5c325237b4 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('

 

'+(_.isFunction(b[this.type].edit)?'
':"")+'
'+this.getHtml()+"
"+(this.overlay?'
':"")+'

 

',function(b,c,d){a(b).trigger("ready",[c,d])},"wrap")},unbind:function(){},setContent:function(b,c,d){_.each(tinymce.editors,function(e){var f=this;e.plugins.wpview&&a(e.getBody()).find('[data-wpview-text="'+this.encodedText+'"]').each(function(g,h){var i=a(h).find(".wpview-content"),j=h;i.length&&"wrap"!==d&&(h=i=i[0]),_.isString(b)?"replace"===d?h=e.dom.replace(e.dom.createFragment(b),j):e.dom.setHTML(h,b):"replace"===d?h=e.dom.replace(b,j):h.appendChild(b),_.isFunction(c)&&c(f,e,a(h).find(".wpview-content")[0])})},this)},setError:function(a,b){this.setContent('

'+a+"

")}}),wp.mce.View.extend=Backbone.View.extend,wp.mce.views={register:function(a,c){var d={type:a,View:{},toView:function(a){var b=wp.shortcode.next(this.type,a);if(b)return{index:b.index,content:b.content,options:{shortcode:b.shortcode}}}};c=_.defaults(c,d),c.View=wp.mce.View.extend(c.View),b[a]=c},get:function(a){return b[a]},unregister:function(a){delete b[a]},unbind:function(){_.each(c,function(a){a.unbind()})},toViews:function(a){var c,d=[{content:a}];return _.each(b,function(a,b){c=d.slice(),d=[],_.each(c,function(c){var e,f=c.content;if(c.processed)return void d.push(c);for(;f&&(e=a.toView(f));)e.index&&d.push({content:f.substring(0,e.index)}),d.push({content:wp.mce.views.toView(b,e.content,e.options),processed:!0}),f=f.slice(e.index+e.content.length);f&&d.push({content:f})})}),_.pluck(d,"content").join("")},toView:function(a,b,d){var e,f,g=wp.mce.views.get(a),h=window.encodeURIComponent(b);return g?(wp.mce.views.getInstance(h)||(f=d,f.type=a,f.encodedText=h,e=new g.View(f),c[h]=e),wp.html.string({tag:"div",attrs:{"class":"wpview-wrap","data-wpview-text":h,"data-wpview-type":a},content:" "})):b},refreshView:function(a,b){var d,e,f,g=window.encodeURIComponent(b);f=wp.mce.views.getInstance(g),f||(e=a.toView(b),d=e.options,d.type=a.type,d.encodedText=g,f=new a.View(d),c[g]=f),wp.mce.views.render()},getInstance:function(a){return c[a]},render:function(){_.each(c,function(a){a.render()})},edit:function(b){var c=a(b).data("wpview-type"),d=wp.mce.views.get(c);d&&d.edit(b)}},wp.mce.views.register("gallery",{View:{template:d.template("editor-gallery"),postID:a("#post_ID").val(),initialize:function(a){this.shortcode=a.shortcode,this.fetch()},fetch:function(){this.attachments=wp.media.gallery.attachments(this.shortcode,this.postID),this.dfd=this.attachments.more().done(_.bind(this.render,this))},getHtml:function(){var a,b=this.shortcode.attrs.named,c=!1;if(!this.dfd||"pending"!==this.dfd.state()||this.attachments.length)return this.attachments.length&&(c=this.attachments.toJSON(),_.each(c,function(a){a.sizes&&(a.sizes.thumbnail?a.thumbnail=a.sizes.thumbnail:a.sizes.full&&(a.thumbnail=a.sizes.full))})),a={attachments:c,columns:b.columns?parseInt(b.columns,10):wp.media.galleryDefaults.columns},this.template(a)}},edit:function(b){var c,d,e=wp.media.gallery,f=this;d=window.decodeURIComponent(a(b).attr("data-wpview-text")),c=e.edit(d),c.state("gallery-edit").on("update",function(d){var g=e.shortcode(d).string();a(b).attr("data-wpview-text",window.encodeURIComponent(g)),wp.mce.views.refreshView(f,g),c.detach()})}}),wp.mce.av={loaded:!1,View:_.extend({},wp.media.mixin,{overlay:!0,initialize:function(b){this.players=[],this.shortcode=b.shortcode,_.bindAll(this,"setPlayer","pausePlayers"),a(this).on("ready",this.setPlayer),a(this).on("ready",function(a,b){b.on("hide",this.pausePlayers)}),a(document).on("media:edit",this.pausePlayers)},setPlayer:function(b,c,d){var e,f=this;return e=a(d).find(".wp-"+this.shortcode.tag+"-shortcode"),this.isCompatible(e)?(e.closest(".wpview-wrap").removeClass("wont-play"),this.ua.is("ff")?e.prop("preload","metadata"):e.prop("preload","none"),e=wp.media.view.MediaDetails.prepareSrc(e.get(0)),void setTimeout(function(){wp.mce.av.loaded=!0,f.players.push(new MediaElementPlayer(e,f.mejsSettings))},wp.mce.av.loaded?10:500)):(e.closest(".wpview-wrap").addClass("wont-play"),void e.replaceWith("

"+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.type],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.type].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(this).on("ready",function(a,b){b.on("hide",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?"not-embeddable"===a.type&&"embed"===b.type||"not-ssl"===a.type?b.setError(a.message,"admin-media"):b.setContent("

"+b.original+"

",null,"replace"):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("'+b+""),d.close(),f=function(){a(c).height(a(d).height())},g)new g(_.debounce(function(){f()},100)).observe(d.body,{attributes:!0,childList:!0,subtree:!0});else for(e=1;6>e;e++)setTimeout(f,700*e);else this.setContent(b);this.parseMediaShortcodes()},parseMediaShortcodes:function(){var b=this;a(".wp-audio-shortcode, .wp-video-shortcode",this.node).each(function(a,c){b.players.push(new MediaElementPlayer(c,b.mejsSettings))})},getHtml:function(){return""}}),wp.mce.embedMixin={View:wp.mce.embedView,edit:function(b){var c,e,f=d.embed,g=this,h="embedURL"===this.type;a(document).trigger("media:edit"),e=window.decodeURIComponent(a(b).attr("data-wpview-text")),c=f.edit(e,h),c.on("close",function(){c.detach()}),c.state("embed").props.on("change:url",function(a,b){b&&(c.state("embed").metadata=a.toJSON())}),c.state("embed").on("select",function(){var d;d=h?c.state("embed").metadata.url:f.shortcode(c.state("embed").metadata).string(),a(b).attr("data-wpview-text",window.encodeURIComponent(d)),wp.mce.views.refreshView(g,d),c.detach()}),c.open()}},wp.mce.views.register("embed",_.extend({},wp.mce.embedMixin)),wp.mce.views.register("embedURL",_.extend({},wp.mce.embedMixin,{toView:function(a){var b=/(?:^|

)(https?:\/\/[^\s"]+?)(?:<\/p>\s*|$)/gi,c=b.exec(tinymce.trim(a));if(c)return{index:c.index,content:c[0],options:{url:c[1]}}}}))}(jQuery); \ No newline at end of file +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(){return""},loadingPlaceholder:function(){return'

'},render:function(){var c=this.getHtml()||this.loadingPlaceholder();this.setContent('

 

'+(_.isFunction(b[this.type].edit)?'
':"")+'
'+c+"
"+(this.overlay?'
':"")+'

 

',function(b,c,d){a(b).trigger("ready",[c,d])},"wrap")},unbind:function(){},setContent:function(b,c,d){_.each(tinymce.editors,function(e){var f=this;e.plugins.wpview&&a(e.getBody()).find('[data-wpview-text="'+this.encodedText+'"]').each(function(g,h){var i=a(h).find(".wpview-content"),j=h;i.length&&"wrap"!==d&&(h=i=i[0]),_.isString(b)?"replace"===d?h=e.dom.replace(e.dom.createFragment(b),j):e.dom.setHTML(h,b):"replace"===d?h=e.dom.replace(b,j):a(h).empty().append(b),_.isFunction(c)&&c(f,e,a(h).find(".wpview-content")[0])})},this)},setError:function(a,b){this.setContent('

'+a+"

")}}),wp.mce.View.extend=Backbone.View.extend,wp.mce.views={register:function(a,c){var d={type:a,View:{},toView:function(a){var b=wp.shortcode.next(this.type,a);if(b)return{index:b.index,content:b.content,options:{shortcode:b.shortcode}}}};c=_.defaults(c,d),c.View=wp.mce.View.extend(c.View),b[a]=c},get:function(a){return b[a]},unregister:function(a){delete b[a]},unbind:function(){_.each(c,function(a){a.unbind()})},toViews:function(a){var c,d=[{content:a}];return _.each(b,function(a,b){c=d.slice(),d=[],_.each(c,function(c){var e,f=c.content;if(c.processed)return void d.push(c);for(;f&&(e=a.toView(f));)e.index&&d.push({content:f.substring(0,e.index)}),d.push({content:wp.mce.views.toView(b,e.content,e.options),processed:!0}),f=f.slice(e.index+e.content.length);f&&d.push({content:f})})}),_.pluck(d,"content").join("")},toView:function(a,b,d){var e,f,g=wp.mce.views.get(a),h=window.encodeURIComponent(b);return g?(wp.mce.views.getInstance(h)||(f=d,f.type=a,f.encodedText=h,e=new g.View(f),c[h]=e),wp.html.string({tag:"div",attrs:{"class":"wpview-wrap","data-wpview-text":h,"data-wpview-type":a},content:" "})):b},refreshView:function(a,b){var d,e,f,g=window.encodeURIComponent(b);f=wp.mce.views.getInstance(g),f||(e=a.toView(b),d=e.options,d.type=a.type,d.encodedText=g,f=new a.View(d),c[g]=f),wp.mce.views.render()},getInstance:function(a){return c[a]},render:function(){_.each(c,function(a){a.render()})},edit:function(b){var c=a(b).data("wpview-type"),d=wp.mce.views.get(c);d&&d.edit(b)}},wp.mce.views.register("gallery",{View:{template:d.template("editor-gallery"),postID:a("#post_ID").val(),initialize:function(a){this.shortcode=a.shortcode,this.fetch()},fetch:function(){this.attachments=wp.media.gallery.attachments(this.shortcode,this.postID),this.dfd=this.attachments.more().done(_.bind(this.render,this))},getHtml:function(){var a,b=this.shortcode.attrs.named,c=!1;return this.dfd&&"pending"===this.dfd.state()&&!this.attachments.length?"":(this.attachments.length&&(c=this.attachments.toJSON(),_.each(c,function(a){a.sizes&&(a.sizes.thumbnail?a.thumbnail=a.sizes.thumbnail:a.sizes.full&&(a.thumbnail=a.sizes.full))})),a={attachments:c,columns:b.columns?parseInt(b.columns,10):wp.media.galleryDefaults.columns},this.template(a))}},edit:function(b){var c,d,e=wp.media.gallery,f=this;d=window.decodeURIComponent(a(b).attr("data-wpview-text")),c=e.edit(d),c.state("gallery-edit").on("update",function(d){var g=e.shortcode(d).string();a(b).attr("data-wpview-text",window.encodeURIComponent(g)),wp.mce.views.refreshView(f,g),c.detach()})}}),wp.mce.av={loaded:!1,View:_.extend({},wp.media.mixin,{overlay:!0,initialize:function(b){this.players=[],this.shortcode=b.shortcode,_.bindAll(this,"setPlayer","pausePlayers"),a(this).on("ready",this.setPlayer),a(this).on("ready",function(a,b){b.on("hide",this.pausePlayers)}),a(document).on("media:edit",this.pausePlayers)},setPlayer:function(b,c,d){var e,f=this;return e=a(d).find(".wp-"+this.shortcode.tag+"-shortcode"),this.isCompatible(e)?(e.closest(".wpview-wrap").removeClass("wont-play"),this.ua.is("ff")?e.prop("preload","metadata"):e.prop("preload","none"),e=wp.media.view.MediaDetails.prepareSrc(e.get(0)),void setTimeout(function(){wp.mce.av.loaded=!0,f.players.push(new MediaElementPlayer(e,f.mejsSettings))},wp.mce.av.loaded?10:500)):(e.closest(".wpview-wrap").addClass("wont-play"),void e.replaceWith("

"+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.type],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.type].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(this).on("ready",function(a,b){b.on("hide",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=[];return this.dfd&&"pending"===this.dfd.state()&&!this.attachments.length?"":(_.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?"not-embeddable"===a.type&&"embed"===b.type||"not-ssl"===a.type?b.setError(a.message,"admin-media"):b.setContent("

"+b.original+"

",null,"replace"):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("'+b+""),d.close(),f=function(){a(c).height(a(d).height())},g)new g(_.debounce(function(){f()},100)).observe(d.body,{attributes:!0,childList:!0,subtree:!0});else for(e=1;6>e;e++)setTimeout(f,700*e);else this.setContent(b);this.parseMediaShortcodes()},parseMediaShortcodes:function(){var b=this;a(".wp-audio-shortcode, .wp-video-shortcode",this.node).each(function(a,c){b.players.push(new MediaElementPlayer(c,b.mejsSettings))})}}),wp.mce.embedMixin={View:wp.mce.embedView,edit:function(b){var c,e,f=d.embed,g=this,h="embedURL"===this.type;a(document).trigger("media:edit"),e=window.decodeURIComponent(a(b).attr("data-wpview-text")),c=f.edit(e,h),c.on("close",function(){c.detach()}),c.state("embed").props.on("change:url",function(a,b){b&&(c.state("embed").metadata=a.toJSON())}),c.state("embed").on("select",function(){var d;d=h?c.state("embed").metadata.url:f.shortcode(c.state("embed").metadata).string(),a(b).attr("data-wpview-text",window.encodeURIComponent(d)),wp.mce.views.refreshView(g,d),c.detach()}),c.open()}},wp.mce.views.register("embed",_.extend({},wp.mce.embedMixin)),wp.mce.views.register("embedURL",_.extend({},wp.mce.embedMixin,{toView:function(a){var b=/(?:^|

)(https?:\/\/[^\s"]+?)(?:<\/p>\s*|$)/gi,c=b.exec(tinymce.trim(a));if(c)return{index:c.index,content:c[0],options:{url:c[1]}}}}))}(jQuery); \ No newline at end of file diff --git a/wp-includes/js/tinymce/skins/wordpress/wp-content.css b/wp-includes/js/tinymce/skins/wordpress/wp-content.css index b5aa08d618..54c94dce80 100644 --- a/wp-includes/js/tinymce/skins/wordpress/wp-content.css +++ b/wp-includes/js/tinymce/skins/wordpress/wp-content.css @@ -311,6 +311,52 @@ audio { display: block; } +.wpview-wrap .loading-placeholder { + border: 1px dashed #ccc; + padding: 10px; +} + +.wpview-wrap[data-mce-selected] .loading-placeholder { + border-color: transparent; +} + +/* A little "loading" animation, not showing in IE < 10 */ +.wpview-wrap .wpview-loading { + width: 60px; + height: 5px; + overflow: hidden; + background-color: transparent; + margin: 10px auto 0; +} + +.wpview-wrap .wpview-loading ins { + background-color: #333; + margin: 0 0 0 -60px; + width: 60px; + height: 5px; + display: block; + -webkit-animation: wpview-loading 1.3s infinite 1s linear; + animation: wpview-loading 1.3s infinite 1s linear; +} + +@-webkit-keyframes wpview-loading { + 0% { + margin-left: -60px; + } + 100% { + margin-left: 60px; + } +} + +@keyframes wpview-loading { + 0% { + margin-left: -60px; + } + 100% { + margin-left: 60px; + } +} + #wp-image-toolbar { position: absolute; margin: 0; @@ -360,7 +406,8 @@ audio { border-color: transparent; } -.wpview-error .dashicons { +.wpview-error .dashicons, +.loading-placeholder .dashicons { display: block; margin: 0 auto; width: 32px;