Esanders has uploaded a new change for review. https://gerrit.wikimedia.org/r/137913
Change subject: Use this.$ where available ...................................................................... Use this.$ where available For consistency and to avoid performance hits when moving things between documents. Change-Id: I06de6f3f901268ca99a47428173391bea9863524 --- M modules/ve/ce/ve.ce.ResizableNode.js M modules/ve/ce/ve.ce.Surface.js M modules/ve/init/ve.init.DebugBar.js M modules/ve/ui/dialogs/ve.ui.ActionDialog.js M modules/ve/ui/ve.ui.MobileSurface.js M modules/ve/ui/widgets/ve.ui.SurfaceWidget.js 6 files changed, 33 insertions(+), 29 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/VisualEditor/VisualEditor refs/changes/13/137913/1 diff --git a/modules/ve/ce/ve.ce.ResizableNode.js b/modules/ve/ce/ve.ce.ResizableNode.js index e2e76a1..f9ab70b 100644 --- a/modules/ve/ce/ve.ce.ResizableNode.js +++ b/modules/ve/ce/ve.ce.ResizableNode.js @@ -310,7 +310,7 @@ 'left': this.$resizeHandles.position().left, 'height': this.$resizeHandles.height(), 'width': this.$resizeHandles.width(), - 'handle': $( e.target ).data( 'handle' ) + 'handle': this.$( e.target ).data( 'handle' ) }; // Bind resize events diff --git a/modules/ve/ce/ve.ce.Surface.js b/modules/ve/ce/ve.ce.Surface.js index 5e6dc5d..0b80c6a 100644 --- a/modules/ve/ce/ve.ce.Surface.js +++ b/modules/ve/ce/ve.ce.Surface.js @@ -1040,7 +1040,7 @@ // Invalid JSON return; } - $( this ).attr( attrs ); + this.$( this ).attr( attrs ); this.removeAttribute( 'data-ve-attributes' ); } ); @@ -1143,7 +1143,7 @@ // CE destroyed an important span, so revert to using clipboard data htmlDoc = ve.createDocumentFromHtml( beforePasteData.html ); // Remove the pasteProtect class. See #onCopy. - $( htmlDoc ).find( 'span' ).removeClass( 've-pasteProtect' ); + this.$( htmlDoc ).find( 'span' ).removeClass( 've-pasteProtect' ); beforePasteData.context = null; } } diff --git a/modules/ve/init/ve.init.DebugBar.js b/modules/ve/init/ve.init.DebugBar.js index b962bc8..1353eb2 100644 --- a/modules/ve/init/ve.init.DebugBar.js +++ b/modules/ve/init/ve.init.DebugBar.js @@ -9,24 +9,25 @@ * Debug bar * * @class + * @extends OO.ui.Element * * @constructor * @param {Object} [config] Configuration options */ -ve.init.DebugBar = function VeUiDebugBar() { +ve.init.DebugBar = function VeUiDebugBar( config ) { + // Parent constructor + OO.ui.Element.call( this, config ); - this.$element = $( '<div>' ).addClass( 've-init-debugBar' ); - - this.$commands = $( '<div>' ).addClass( 've-init-debugBar-commands' ); - this.$dumpLinmod = $( '<td>' ).addClass( 've-init-debugBar-dump-linmod' ); - this.$dumpView = $( '<td>' ).addClass( 've-init-debugBar-dump-view' ); - this.$dumpModel = $( '<td>' ).addClass( 've-init-debugBar-dump-model' ); + this.$commands = this.$( '<div>' ).addClass( 've-init-debugBar-commands' ); + this.$dumpLinmod = this.$( '<td>' ).addClass( 've-init-debugBar-dump-linmod' ); + this.$dumpView = this.$( '<td>' ).addClass( 've-init-debugBar-dump-view' ); + this.$dumpModel = this.$( '<td>' ).addClass( 've-init-debugBar-dump-model' ); this.$dump = - $( '<table class="ve-init-debugBar-dump"></table>' ).append( - $( '<thead><th>Linear model</th><th>View tree</th><th>Model tree</th></thead>' ), - $( '<tbody>' ).append( - $( '<tr>' ).append( + this.$( '<table class="ve-init-debugBar-dump"></table>' ).append( + this.$( '<thead><th>Linear model</th><th>View tree</th><th>Model tree</th></thead>' ), + this.$( '<tbody>' ).append( + this.$( '<tr>' ).append( this.$dumpLinmod, this.$dumpView, this.$dumpModel ) ) @@ -52,6 +53,7 @@ this.dumpModelButton.on( 'click', ve.bind( this.onDumpModelButtonClick, this ) ); this.dumpModelChangeToggle.on( 'click', ve.bind( this.onDumpModelChangeToggleClick, this ) ); + this.$element.addClass( 've-init-debugBar' ); this.$element.append( this.$commands.append( startLabel.$element, @@ -59,7 +61,7 @@ endLabel.$element, this.endTextInput.$element, this.logRangeButton.$element, - $( this.constructor.static.dividerTemplate ), + this.$( this.constructor.static.dividerTemplate ), this.dumpModelButton.$element, this.dumpModelChangeToggle.$element ), @@ -69,7 +71,9 @@ this.target = null; }; -ve.init.DebugBar.static = {}; +/* Inheritance */ + +OO.inheritClass( ve.init.DebugBar, OO.ui.Element ); /** * Divider HTML template @@ -139,11 +143,11 @@ surface = this.getSurface(), documentModel = surface.getModel().getDocument(), documentView = surface.getView().getDocument(), - $ol = $( '<ol start="0"></ol>' ); + $ol = this.$( '<ol start="0"></ol>' ); for ( i = 0; i < documentModel.data.getLength(); i++ ) { - $li = $( '<li>' ); - $label = $( '<span>' ); + $li = this.$( '<li>' ); + $label = this.$( '<span>' ); element = documentModel.data.getData( i ); if ( element.type ) { $label.addClass( 've-init-debugBar-dump-element' ); @@ -161,7 +165,7 @@ $label.html( ( text.match( /\S/ ) ? text : ' ' ) + ' ' ); if ( annotations ) { $label.append( - $( '<span>' ).text( + this.$( '<span>' ).text( '[' + documentModel.store.values( annotations ).map( function ( ann ) { return JSON.stringify( ann.getComparableObject() ); } ).join( ', ' ) + ']' @@ -182,17 +186,17 @@ */ function generateListFromNode( node ) { var $li, i, - $ol = $( '<ol start="0"></ol>' ); + $ol = this.$( '<ol start="0"></ol>' ); for ( i = 0; i < node.children.length; i++ ) { - $li = $( '<li>' ); - $label = $( '<span>' ).addClass( 've-init-debugBar-dump-element' ); + $li = this.$( '<li>' ); + $label = this.$( '<span>' ).addClass( 've-init-debugBar-dump-element' ); if ( node.children[i].length !== undefined ) { $li.append( $label .text( node.children[i].type ) .append( - $( '<span>' ).text( ' (' + node.children[i].length + ')' ) + this.$( '<span>' ).text( ' (' + node.children[i].length + ')' ) ) ); } else { diff --git a/modules/ve/ui/dialogs/ve.ui.ActionDialog.js b/modules/ve/ui/dialogs/ve.ui.ActionDialog.js index af0824b..b00e9b0 100644 --- a/modules/ve/ui/dialogs/ve.ui.ActionDialog.js +++ b/modules/ve/ui/dialogs/ve.ui.ActionDialog.js @@ -126,7 +126,7 @@ */ ve.ui.ActionDialog.prototype.showErrors = function ( errors ) { var i, len, $errorDiv, - $errors = $( [] ); + $errors = this.$( [] ); for ( i = 0, len = errors.length; i < len; i++ ) { $errorDiv = this.$( '<div>' ).addClass( 've-ui-actionDialog-error' ); diff --git a/modules/ve/ui/ve.ui.MobileSurface.js b/modules/ve/ui/ve.ui.MobileSurface.js index b633715..03b5950 100644 --- a/modules/ve/ui/ve.ui.MobileSurface.js +++ b/modules/ve/ui/ve.ui.MobileSurface.js @@ -56,7 +56,7 @@ ve.ui.MobileSurface.prototype.showGlobalOverlay = function () { this.scrollPos = $( 'body' ).scrollTop(); // overflow: hidden on 'body' alone is not enough for iOS Safari - $( 'html, body' ).addClass( 've-ui-mobileSurface-overlay-global-enabled' ); + this.$( 'html, body' ).addClass( 've-ui-mobileSurface-overlay-global-enabled' ); this.$globalOverlay.addClass( 've-ui-mobileSurface-overlay-global-visible' ); }; @@ -66,6 +66,6 @@ */ ve.ui.MobileSurface.prototype.hideGlobalOverlay = function () { this.$globalOverlay.removeClass( 've-ui-mobileSurface-overlay-global-visible' ); - $( 'html, body' ).removeClass( 've-ui-mobileSurface-overlay-global-enabled' ); - $( 'body' ).scrollTop( this.scrollPos ); + this.$( 'html, body' ).removeClass( 've-ui-mobileSurface-overlay-global-enabled' ); + this.$( 'body' ).scrollTop( this.scrollPos ); }; diff --git a/modules/ve/ui/widgets/ve.ui.SurfaceWidget.js b/modules/ve/ui/widgets/ve.ui.SurfaceWidget.js index 4415bf0..e80fe13 100644 --- a/modules/ve/ui/widgets/ve.ui.SurfaceWidget.js +++ b/modules/ve/ui/widgets/ve.ui.SurfaceWidget.js @@ -47,7 +47,7 @@ } if ( ve.debug ) { - var debugBar = new ve.init.DebugBar(); + var debugBar = new ve.init.DebugBar( { '$': this.$ } ); debugBar.attachToSurface( this.surface ); this.$element.append( debugBar.$element ); } -- To view, visit https://gerrit.wikimedia.org/r/137913 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I06de6f3f901268ca99a47428173391bea9863524 Gerrit-PatchSet: 1 Gerrit-Project: VisualEditor/VisualEditor Gerrit-Branch: master Gerrit-Owner: Esanders <esand...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits