wpviews: whenever a view is updated or inserted, don't refresh ALL of the views.

Props avryl.
Fixes #28788.

Built from https://develop.svn.wordpress.org/trunk@29530


git-svn-id: http://core.svn.wordpress.org/trunk@29306 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2014-08-18 03:59:17 +00:00
parent 3736e6b3f9
commit 36e4e9917b
5 changed files with 46 additions and 27 deletions

View File

@ -46,7 +46,10 @@ window.wp = window.wp || {};
'<div class="wpview-loading"><ins></ins></div>' +
'</div>';
},
render: function() {
render: function( force ) {
if ( force || ! this.rendered() ) {
this.unbind();
this.setContent(
'<p class="wpview-selection-before">\u00a0</p>' +
'<div class="wpview-body" contenteditable="false">' +
@ -64,6 +67,9 @@ window.wp = window.wp || {};
);
$( this ).trigger( 'ready' );
this.rendered( true );
}
},
unbind: function() {},
getEditors: function( callback ) {
@ -190,6 +196,19 @@ window.wp = window.wp || {};
'<p>' + message + '</p>' +
'</div>'
);
},
rendered: function( value ) {
var notRendered;
this.getNodes( function( editor, node ) {
if ( value != null ) {
$( node ).data( 'rendered', value === true );
} else {
notRendered = notRendered || ! $( node ).data( 'rendered' );
}
} );
return ! notRendered;
}
} );
@ -390,7 +409,7 @@ window.wp = window.wp || {};
instances[ encodedText ] = instance;
}
wp.mce.views.render();
instance.render();
},
getInstance: function( encodedText ) {
@ -406,9 +425,9 @@ window.wp = window.wp || {};
* To generate wrapper elements, pass your content through
* `wp.mce.view.toViews( content )`.
*/
render: function() {
render: function( force ) {
_.each( instances, function( instance ) {
instance.render();
instance.render( force );
} );
},
@ -438,8 +457,12 @@ window.wp = window.wp || {};
},
fetch: function() {
var self = this;
this.attachments = wp.media.gallery.attachments( this.shortcode, this.postID );
this.dfd = this.attachments.more().done( _.bind( this.render, this ) );
this.dfd = this.attachments.more().done( function() {
self.render( true );
} );
},
getHtml: function() {

File diff suppressed because one or more lines are too long

View File

@ -205,10 +205,6 @@ tinymce.PluginManager.add( 'wpview', function( editor ) {
removeView( selected );
}
if ( ! event.initial ) {
wp.mce.views.unbind( editor );
}
node = editor.selection.getNode();
// When a url is pasted, only try to embed it when pasted in an empty paragrapgh.

File diff suppressed because one or more lines are too long