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:
parent
3736e6b3f9
commit
36e4e9917b
|
@ -46,7 +46,10 @@ window.wp = window.wp || {};
|
||||||
'<div class="wpview-loading"><ins></ins></div>' +
|
'<div class="wpview-loading"><ins></ins></div>' +
|
||||||
'</div>';
|
'</div>';
|
||||||
},
|
},
|
||||||
render: function() {
|
render: function( force ) {
|
||||||
|
if ( force || ! this.rendered() ) {
|
||||||
|
this.unbind();
|
||||||
|
|
||||||
this.setContent(
|
this.setContent(
|
||||||
'<p class="wpview-selection-before">\u00a0</p>' +
|
'<p class="wpview-selection-before">\u00a0</p>' +
|
||||||
'<div class="wpview-body" contenteditable="false">' +
|
'<div class="wpview-body" contenteditable="false">' +
|
||||||
|
@ -64,6 +67,9 @@ window.wp = window.wp || {};
|
||||||
);
|
);
|
||||||
|
|
||||||
$( this ).trigger( 'ready' );
|
$( this ).trigger( 'ready' );
|
||||||
|
|
||||||
|
this.rendered( true );
|
||||||
|
}
|
||||||
},
|
},
|
||||||
unbind: function() {},
|
unbind: function() {},
|
||||||
getEditors: function( callback ) {
|
getEditors: function( callback ) {
|
||||||
|
@ -190,6 +196,19 @@ window.wp = window.wp || {};
|
||||||
'<p>' + message + '</p>' +
|
'<p>' + message + '</p>' +
|
||||||
'</div>'
|
'</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;
|
instances[ encodedText ] = instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
wp.mce.views.render();
|
instance.render();
|
||||||
},
|
},
|
||||||
|
|
||||||
getInstance: function( encodedText ) {
|
getInstance: function( encodedText ) {
|
||||||
|
@ -406,9 +425,9 @@ window.wp = window.wp || {};
|
||||||
* To generate wrapper elements, pass your content through
|
* To generate wrapper elements, pass your content through
|
||||||
* `wp.mce.view.toViews( content )`.
|
* `wp.mce.view.toViews( content )`.
|
||||||
*/
|
*/
|
||||||
render: function() {
|
render: function( force ) {
|
||||||
_.each( instances, function( instance ) {
|
_.each( instances, function( instance ) {
|
||||||
instance.render();
|
instance.render( force );
|
||||||
} );
|
} );
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -438,8 +457,12 @@ window.wp = window.wp || {};
|
||||||
},
|
},
|
||||||
|
|
||||||
fetch: function() {
|
fetch: function() {
|
||||||
|
var self = this;
|
||||||
|
|
||||||
this.attachments = wp.media.gallery.attachments( this.shortcode, this.postID );
|
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() {
|
getHtml: function() {
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -205,10 +205,6 @@ tinymce.PluginManager.add( 'wpview', function( editor ) {
|
||||||
removeView( selected );
|
removeView( selected );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! event.initial ) {
|
|
||||||
wp.mce.views.unbind( editor );
|
|
||||||
}
|
|
||||||
|
|
||||||
node = editor.selection.getNode();
|
node = editor.selection.getNode();
|
||||||
|
|
||||||
// When a url is pasted, only try to embed it when pasted in an empty paragrapgh.
|
// 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
Binary file not shown.
Loading…
Reference in New Issue