jenkins-bot has submitted this change and it was merged.
Change subject: Use css class rather than jQuery show/hide
......................................................................
Use css class rather than jQuery show/hide
To decrease computation time, avoid using jQuery's .show() and
.toggle() by using our own hide css class.
Related commit in ooui: Ibf7c99aa4aad1
Bug: T87420
Change-Id: I1d968b25f6d435b5fe68b8cec42b044a5c4f5661
---
M src/ce/nodes/ve.ce.TableNode.js
M src/ce/ve.ce.ResizableNode.js
M src/ui/inspectors/ve.ui.SpecialCharacterInspector.js
M src/ui/ve.ui.Context.js
M src/ui/ve.ui.DesktopContext.js
M src/ui/ve.ui.MobileContext.js
M src/ui/widgets/ve.ui.MediaSizeWidget.js
7 files changed, 23 insertions(+), 20 deletions(-)
Approvals:
Catrope: Looks good to me, approved
jenkins-bot: Verified
diff --git a/src/ce/nodes/ve.ce.TableNode.js b/src/ce/nodes/ve.ce.TableNode.js
index 6d9f430..d1056ec 100644
--- a/src/ce/nodes/ve.ce.TableNode.js
+++ b/src/ce/nodes/ve.ce.TableNode.js
@@ -62,8 +62,7 @@
} );
this.$overlay = this.$( '<div>' )
- .hide()
- .addClass( 've-ce-tableNodeOverlay' )
+ .addClass( 've-ce-tableNodeOverlay oo-ui-element-hidden' )
.append( [
this.$selectionBox,
this.$selectionBoxAnchor,
@@ -306,7 +305,7 @@
if ( active ) {
if ( !this.active ) {
- this.$overlay.show();
+ this.$overlay.removeClass( 'oo-ui-element-hidden' );
// Only register touchstart event after table has
become active to prevent
// accidental focusing of the table while scrolling
this.$element.on( 'touchstart.ve-ce-tableNode',
this.onTableMouseDown.bind( this ) );
@@ -314,7 +313,7 @@
this.surface.setActiveTableNode( this );
this.updateOverlayDebounced();
} else if ( !active && this.active ) {
- this.$overlay.hide();
+ this.$overlay.addClass( 'oo-ui-element-hidden' );
if ( this.editingFragment ) {
this.setEditing( false, true );
}
diff --git a/src/ce/ve.ce.ResizableNode.js b/src/ce/ve.ce.ResizableNode.js
index 5c1349b..d14092d 100644
--- a/src/ce/ve.ce.ResizableNode.js
+++ b/src/ce/ve.ce.ResizableNode.js
@@ -126,7 +126,7 @@
} );
// Actually hide the size label after it's done animating
setTimeout( function () {
- node.$sizeLabel.hide();
+ node.$sizeLabel.addClass( 'oo-ui-element-hidden' );
}, 200 );
};
@@ -153,7 +153,7 @@
height = dimensions.height;
}
this.$sizeLabel
- .show()
+ .removeClass( 'oo-ui-element-hidden' )
.addClass( 've-ce-resizableNode-sizeLabel-resizing' )
.css( {
top: top,
diff --git a/src/ui/inspectors/ve.ui.SpecialCharacterInspector.js
b/src/ui/inspectors/ve.ui.SpecialCharacterInspector.js
index b6b3411..b126553 100644
--- a/src/ui/inspectors/ve.ui.SpecialCharacterInspector.js
+++ b/src/ui/inspectors/ve.ui.SpecialCharacterInspector.js
@@ -75,7 +75,7 @@
this.getFragment().insertContent( ' ' );
// Don't request the character list again if we already
have it
if ( !this.characters ) {
- this.$spinner.show();
+ this.$spinner.removeClass(
'oo-ui-element-hidden' );
this.fetchCharList()
.done( function () {
inspector.buildButtonList();
@@ -83,7 +83,7 @@
// TODO: show error message on
fetchCharList().fail
.always( function () {
// TODO: generalize push/pop
pending, like we do in Dialog
- inspector.$spinner.hide();
+ inspector.$spinner.addClass(
'oo-ui-element-hidden' );
} );
}
}, this );
diff --git a/src/ui/ve.ui.Context.js b/src/ui/ve.ui.Context.js
index 386a1d6..15c8276 100644
--- a/src/ui/ve.ui.Context.js
+++ b/src/ui/ve.ui.Context.js
@@ -38,7 +38,8 @@
// Initialization
// Hide element using a class, not this.toggle, as child implementations
// of toggle may require the instance to be fully constructed before
running.
- this.$element.addClass( 've-ui-context' );
+ this.$element
+ .addClass( 've-ui-context oo-ui-element-hidden' );
this.menu.toggle( false );
this.inspectors.$element.addClass( 've-ui-context-inspectors' );
};
@@ -324,7 +325,7 @@
show = show === undefined ? !this.visible : !!show;
if ( show !== this.visible ) {
this.visible = show;
- this.$element.toggle();
+ this.$element.toggleClass( 'oo-ui-element-hidden',
!this.visible );
}
return $.Deferred().resolve().promise();
};
diff --git a/src/ui/ve.ui.DesktopContext.js b/src/ui/ve.ui.DesktopContext.js
index adfa503..004b58e 100644
--- a/src/ui/ve.ui.DesktopContext.js
+++ b/src/ui/ve.ui.DesktopContext.js
@@ -52,7 +52,9 @@
// HACK: hide the popup with visibility: hidden; rather than display:
none;, because
// the popup contains inspector iframes, and applying display: none; to
those causes them to
// not load in Firefox
- this.popup.$element.css( { visibility: 'hidden', display: '' } );
+ this.popup.$element
+ .css( { visibility: 'hidden' } )
+ .removeClass( 'oo-ui-element-hidden' );
};
/* Inheritance */
@@ -172,10 +174,11 @@
// HACK: make the context and popup visibility: hidden; instead of
display: none; because
// they contain inspector iframes, and applying display: none; to those
causes them to
// not load in Firefox
- this.$element.add( this.popup.$element ).css( {
- visibility: show ? 'visible' : 'hidden',
- display: ''
- } );
+ this.$element.add( this.popup.$element )
+ .removeClass( 'oo-ui-element-hidden' )
+ .css( {
+ visibility: show ? 'visible' : 'hidden'
+ } );
this.transitioning.resolve();
this.transitioning = null;
diff --git a/src/ui/ve.ui.MobileContext.js b/src/ui/ve.ui.MobileContext.js
index 290b10c..3f9cbdf 100644
--- a/src/ui/ve.ui.MobileContext.js
+++ b/src/ui/ve.ui.MobileContext.js
@@ -30,9 +30,8 @@
// Initialization
this.$element
.addClass( 've-ui-mobileContext' )
- .append( this.menu.$element )
- // Mobile context uses a class to toggle visibility
- .show();
+ .append( this.menu.$element );
+ this.toggle( true );
this.menu.$element.addClass( 've-ui-mobileContext-menu' );
this.inspectors.$element.addClass( 've-ui-mobileContext-inspectors' );
this.surface.getGlobalOverlay().$element.append(
this.inspectors.$element );
@@ -72,7 +71,8 @@
show = show === undefined ? !this.visible : !!show;
if ( show !== this.visible ) {
this.visible = show;
- this.$element.toggleClass( 've-ui-mobileContext-visible', show
);
+ this.$element
+ .toggleClass( 'oo-ui-element-hidden', !show );
setTimeout( function () {
deferred.resolve();
}, 300 );
diff --git a/src/ui/widgets/ve.ui.MediaSizeWidget.js
b/src/ui/widgets/ve.ui.MediaSizeWidget.js
index 9ee3e55..c021562 100644
--- a/src/ui/widgets/ve.ui.MediaSizeWidget.js
+++ b/src/ui/widgets/ve.ui.MediaSizeWidget.js
@@ -516,7 +516,7 @@
if ( this.valid !== isValid ) {
this.valid = isValid;
- this.errorLabel.$element.toggle( !isValid );
+ this.errorLabel.toggle( !isValid );
this.$element.toggleClass(
've-ui-mediaSizeWidget-input-hasError', !isValid );
// Emit change event
this.emit( 'valid', this.valid );
--
To view, visit https://gerrit.wikimedia.org/r/187617
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I1d968b25f6d435b5fe68b8cec42b044a5c4f5661
Gerrit-PatchSet: 10
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Mooeypoo <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: Mooeypoo <[email protected]>
Gerrit-Reviewer: Trevor Parscal <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits