jenkins-bot has submitted this change and it was merged. Change subject: Resize focus highlights on generated content update ......................................................................
Resize focus highlights on generated content update Create a new rerender event. Also added a check to see if the node is actually focused. Change-Id: I9f74e82f72a9ddfd1e4a9ab7d1c0c8289b6525e8 --- M modules/ve/ce/nodes/ve.ce.GeneratedContentNode.js M modules/ve/ce/ve.ce.FocusableNode.js 2 files changed, 50 insertions(+), 9 deletions(-) Approvals: Catrope: Looks good to me, approved jenkins-bot: Verified diff --git a/modules/ve/ce/nodes/ve.ce.GeneratedContentNode.js b/modules/ve/ce/nodes/ve.ce.GeneratedContentNode.js index e49fd62..395b8cb 100644 --- a/modules/ve/ce/nodes/ve.ce.GeneratedContentNode.js +++ b/modules/ve/ce/nodes/ve.ce.GeneratedContentNode.js @@ -25,12 +25,29 @@ this.onUpdate(); }; +/* Events */ + +/** + * @event setup + */ + +/** + * @event teardown + */ + +/** + * @event rerender + */ + /* Methods */ /** * Handle update events. * * @method + * @emits setup + * @emits teardown + * @emits rerender */ ve.ce.GeneratedContentNode.prototype.onUpdate = function () { var doc = this.getElementDocument(), @@ -45,6 +62,7 @@ ); if ( this.live ) { this.emit( 'setup' ); + this.emit( 'rerender' ); } } else { this.startGenerating(); diff --git a/modules/ve/ce/ve.ce.FocusableNode.js b/modules/ve/ce/ve.ce.FocusableNode.js index 2659a74..9b7c7ca 100644 --- a/modules/ve/ce/ve.ce.FocusableNode.js +++ b/modules/ve/ce/ve.ce.FocusableNode.js @@ -16,7 +16,7 @@ * node's DOM rendering. * * If your focusable node changes size and the highlight must be redrawn, call redrawHighlight(). - * ResizableNode 'resize' event is already bound. + * 'resize' and 'rerender' are already bound to call this. * * @class * @abstract @@ -34,7 +34,8 @@ // Events this.connect( this, { 'setup': 'onFocusableSetup', - 'resize': 'redrawHighlight' + 'resize': 'onFocusableResize', + 'rerender': 'onFocusableRerender' } ); }; @@ -60,13 +61,25 @@ }; /** - * Notification of dimension change + * Handle resize event. * * @method */ -ve.ce.FocusableNode.prototype.redrawHighlight = function () { - this.clearHighlight(); - this.createHighlight(); +ve.ce.FocusableNode.prototype.onFocusableResize = function () { + if ( this.isFocused() ) { + this.redrawHighlight(); + } +}; + +/** + * Handle rerender event. + * + * @method + */ +ve.ce.FocusableNode.prototype.onFocusableRerender = function () { + if ( this.isFocused() ) { + this.redrawHighlight(); + } }; /** @@ -104,7 +117,7 @@ }; /** - * Creates highlight + * Creates highlight. * * @method */ @@ -113,7 +126,7 @@ this.$.find( '*' ).add( this.$ ).each( ve.bind( function( i, element ) { - elementOffset = $(element).offset(); + elementOffset = $( element ).offset(); this.$highlights = this.$highlights.add( $( '<div>' ) .css( { @@ -131,7 +144,7 @@ }; /** - * Clears highlight + * Clears highlight. * * @method */ @@ -139,3 +152,13 @@ this.$highlights = $( [] ); this.surface.replaceHighlight( null ); }; + +/** + * Redraws highlight. + * + * @method + */ +ve.ce.FocusableNode.prototype.redrawHighlight = function () { + this.clearHighlight(); + this.createHighlight(); +}; -- To view, visit https://gerrit.wikimedia.org/r/69495 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I9f74e82f72a9ddfd1e4a9ab7d1c0c8289b6525e8 Gerrit-PatchSet: 4 Gerrit-Project: mediawiki/extensions/VisualEditor Gerrit-Branch: master Gerrit-Owner: Esanders <esand...@wikimedia.org> Gerrit-Reviewer: Catrope <roan.katt...@gmail.com> Gerrit-Reviewer: Inez <i...@wikia-inc.com> Gerrit-Reviewer: Trevor Parscal <tpars...@wikimedia.org> Gerrit-Reviewer: jenkins-bot _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits