mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 02:23:58 +00:00
Use css class instead of jquery show/hide
Replace instances of .show() and .hide() with ooui 'hidden' class to make performance better. Related ooui change: Ibf7c99aa4aad Bug: T87420 Bug: T88736 Change-Id: I3af8a322e88b7ba3364f350819d6dbcdc8b13270
This commit is contained in:
parent
a7762b66a5
commit
8a53b2cd07
|
@ -143,8 +143,7 @@ ve.ce.MWBlockImageNode.prototype.updateCaption = function () {
|
|||
}
|
||||
}
|
||||
if ( this.$caption ) {
|
||||
// Don't use show() as it sets display to block, overriding the stylesheet.
|
||||
this.$caption.css( 'display', this.captionVisible ? '' : 'none' );
|
||||
this.$caption.toggleClass( 'oo-ui-element-hidden', !this.captionVisible );
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -1098,17 +1098,17 @@ ve.ui.MWMediaDialog.prototype.switchPanels = function ( panel, stopSearchRequery
|
|||
// The filerepo promise will be sent to the API
|
||||
// only once per session so this will be resolved
|
||||
// every time the search panel reloads
|
||||
this.$spinner.show();
|
||||
this.search.$element.hide();
|
||||
this.$spinner.removeClass( 'oo-ui-element-hidden' );
|
||||
this.search.toggle( false );
|
||||
|
||||
// Get the repos from the API first
|
||||
// The ajax request will only be done once per session
|
||||
dialog.getFileRepos().done( function ( repos ) {
|
||||
dialog.search.setSources( repos );
|
||||
// Done, hide the spinner
|
||||
dialog.$spinner.hide();
|
||||
dialog.$spinner.addClass( 'oo-ui-element-hidden' );
|
||||
// Show the search and query the media sources
|
||||
dialog.search.$element.show();
|
||||
dialog.search.toggle( true );
|
||||
dialog.search.query.setValue( dialog.pageTitle );
|
||||
dialog.search.queryMediaSources();
|
||||
// Initialization
|
||||
|
@ -1168,7 +1168,7 @@ ve.ui.MWMediaDialog.prototype.attachImageModel = function () {
|
|||
);
|
||||
|
||||
// Size widget
|
||||
this.sizeErrorLabel.$element.hide();
|
||||
this.sizeErrorLabel.toggle( false );
|
||||
this.sizeWidget.setScalable( this.imageModel.getScalable() );
|
||||
this.sizeWidget.connect( this, {
|
||||
changeSizeType: 'checkChanged',
|
||||
|
|
|
@ -267,13 +267,13 @@ ve.ui.MWReferenceDialog.prototype.useReference = function ( ref ) {
|
|||
group = this.getFragment().getDocument().getInternalList()
|
||||
.getNodeGroup( this.referenceModel.getListGroup() );
|
||||
if ( group && group.keyedNodes[this.referenceModel.getListKey()].length > 1 ) {
|
||||
this.$reuseWarning.show();
|
||||
this.$reuseWarning.removeClass( 'oo-ui-element-hidden' );
|
||||
this.$reuseWarningText.text( mw.msg(
|
||||
'visualeditor-dialog-reference-editing-reused',
|
||||
group.keyedNodes[this.referenceModel.getListKey()].length
|
||||
) );
|
||||
} else {
|
||||
this.$reuseWarning.hide();
|
||||
this.$reuseWarning.addClass( 'oo-ui-element-hidden' );
|
||||
}
|
||||
|
||||
return this;
|
||||
|
|
|
@ -203,20 +203,22 @@ ve.ui.MWSaveDialog.prototype.swapPanel = function ( panel ) {
|
|||
|
||||
if ( !currentEditSummaryWikitext || currentEditSummaryWikitext.trim() === '' ) {
|
||||
// Don't bother with an API request for an empty summary
|
||||
this.$reviewEditSummary.parent().hide();
|
||||
this.$reviewEditSummary.parent().addClass( 'oo-ui-element-hidden' );
|
||||
} else {
|
||||
this.$reviewEditSummary.parent().show().addClass( 'mw-ajax-loader' );
|
||||
this.$reviewEditSummary.parent()
|
||||
.removeClass( 'oo-ui-element-hidden' )
|
||||
.addClass( 'mw-ajax-loader' );
|
||||
this.editSummaryXhr = new mw.Api().post( {
|
||||
action: 'parse',
|
||||
summary: currentEditSummaryWikitext
|
||||
} ).done( function ( result ) {
|
||||
if ( result.parse.parsedsummary['*'] === '' ) {
|
||||
dialog.$reviewEditSummary.parent().hide();
|
||||
dialog.$reviewEditSummary.parent().addClass( 'oo-ui-element-hidden' );
|
||||
} else {
|
||||
dialog.$reviewEditSummary.html( ve.msg( 'parentheses', result.parse.parsedsummary['*'] ) );
|
||||
}
|
||||
} ).fail( function () {
|
||||
dialog.$reviewEditSummary.parent().hide();
|
||||
dialog.$reviewEditSummary.parent().addClass( 'oo-ui-element-hidden' );
|
||||
} ).always( function () {
|
||||
dialog.$reviewEditSummary.parent().removeClass( 'mw-ajax-loader' );
|
||||
} );
|
||||
|
|
|
@ -48,7 +48,9 @@ ve.ui.MWCategoryPopupWidget = function VeUiMWCategoryPopupWidget( config ) {
|
|||
this.$sortKeyForm.on( 'submit', this.onSortKeySubmit.bind( this ) );
|
||||
|
||||
// Initialization
|
||||
this.$element.addClass( 've-ui-mwCategoryPopupWidget' ).hide();
|
||||
this.$element
|
||||
.addClass( 've-ui-mwCategoryPopupWidget' );
|
||||
this.toggle( false );
|
||||
this.$title
|
||||
.addClass( 've-ui-mwCategoryPopupWidget-title oo-ui-icon-tag' )
|
||||
.text( ve.msg( 'visualeditor-dialog-meta-categories-category' ) );
|
||||
|
|
|
@ -55,7 +55,7 @@ ve.ui.MWMediaResultWidget = function VeUiMWMediaResultWidget( config ) {
|
|||
label: ve.msg( 'visualeditor-dialog-media-searchselect' ),
|
||||
icon: 'check'
|
||||
} );
|
||||
this.selectButton.$element.hide();
|
||||
this.selectButton.toggle( false );
|
||||
this.$element.prepend( this.selectButton.$element );
|
||||
};
|
||||
|
||||
|
|
|
@ -42,9 +42,8 @@ ve.ui.MWMediaSearchWidget = function VeUiMWMediaSearchWidget( config ) {
|
|||
this.rows = [];
|
||||
|
||||
this.$noItemsMessage = this.$( '<div>' )
|
||||
.addClass( 've-ui-mwMediaSearchWidget-noresults' )
|
||||
.addClass( 've-ui-mwMediaSearchWidget-noresults oo-ui-element-hidden' )
|
||||
.text( ve.msg( 'visualeditor-dialog-media-noresults' ) )
|
||||
.hide()
|
||||
.appendTo( this.$query );
|
||||
|
||||
// Events
|
||||
|
@ -168,7 +167,8 @@ ve.ui.MWMediaSearchWidget.prototype.queryMediaSources = function () {
|
|||
}
|
||||
|
||||
// Reset message
|
||||
this.$noItemsMessage.hide();
|
||||
this.$noItemsMessage.addClass( 'oo-ui-element-hidden' );
|
||||
|
||||
// Abort previous promises if they are pending
|
||||
this.resetPromises();
|
||||
|
||||
|
@ -270,9 +270,9 @@ ve.ui.MWMediaSearchWidget.prototype.onAllMediaQueriesDone = function () {
|
|||
this.query.popPending();
|
||||
|
||||
if ( this.results.getItems().length === 0 ) {
|
||||
this.$noItemsMessage.show();
|
||||
this.$noItemsMessage.removeClass( 'oo-ui-element-hidden' );
|
||||
} else {
|
||||
this.$noItemsMessage.hide();
|
||||
this.$noItemsMessage.addClass( 'oo-ui-element-hidden' );
|
||||
this.lazyLoadResults();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -62,6 +62,7 @@ ve.ui.MWTocWidget = function VeUiMWTocWidget( surface, config ) {
|
|||
widget.toggle.$link.text( widget.toggle.hideMsg );
|
||||
widget.toggle.open = true;
|
||||
}
|
||||
// FIXME: We should really use CSS here
|
||||
widget.topics.$group.add( widget.$tempTopics ).slideToggle();
|
||||
} );
|
||||
|
||||
|
@ -136,11 +137,7 @@ ve.ui.MWTocWidget.prototype.initFromMetaList = function () {
|
|||
ve.ui.MWTocWidget.prototype.hideOrShow = function () {
|
||||
// In MediaWiki if __FORCETOC__ is anywhere TOC is always displayed
|
||||
// ... Even if there is a __NOTOC__ in the article
|
||||
if ( !this.mwTOCDisable && ( this.mwTOCForce || this.topics.items.length >= 3 ) ) {
|
||||
this.$element.show();
|
||||
} else {
|
||||
this.$element.hide();
|
||||
}
|
||||
this.toggle( !this.mwTOCDisable && ( this.mwTOCForce || this.topics.items.length >= 3 ) );
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue