jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/372445 )
Change subject: Hygiene: Do not use global $ function in classes
......................................................................
Hygiene: Do not use global $ function in classes
Bug: T173539
Change-Id: I5720fe738b092231b99d1eb240f8443478b310fe
---
M resources/mobile.betaoptin/BetaOptinPanel.js
M resources/mobile.categories.overlays/CategoryAddOverlay.js
M resources/mobile.categories.overlays/CategoryLookupInputWidget.js
M resources/mobile.categories.overlays/CategoryOverlay.js
M resources/mobile.editor.overlay/EditorOverlay.js
M resources/mobile.fontchanger/FontChanger.js
M resources/mobile.languages.structured/LanguageOverlay.js
M resources/mobile.mediaViewer/ImageOverlay.js
M resources/mobile.pointerOverlay/PointerOverlay.js
M resources/mobile.references/ReferencesDrawer.js
M resources/mobile.search/SearchOverlay.js
M resources/mobile.startup/Overlay.js
M resources/mobile.startup/Page.js
M resources/mobile.startup/Skin.js
M resources/mobile.talk.overlays/TalkSectionOverlay.js
15 files changed, 39 insertions(+), 27 deletions(-)
Approvals:
Jhernandez: Looks good to me, approved
jenkins-bot: Verified
diff --git a/resources/mobile.betaoptin/BetaOptinPanel.js
b/resources/mobile.betaoptin/BetaOptinPanel.js
index a1d506c..991c5c6 100644
--- a/resources/mobile.betaoptin/BetaOptinPanel.js
+++ b/resources/mobile.betaoptin/BetaOptinPanel.js
@@ -41,7 +41,7 @@
* @param {jQuery.Event} ev
*/
onOptin: function ( ev ) {
- $( ev.currentTarget ).closest( 'form' ).submit();
+ this.$( ev.currentTarget ).closest( 'form' ).submit();
}
} );
diff --git a/resources/mobile.categories.overlays/CategoryAddOverlay.js
b/resources/mobile.categories.overlays/CategoryAddOverlay.js
index 79cf1f7..2bd936c 100644
--- a/resources/mobile.categories.overlays/CategoryAddOverlay.js
+++ b/resources/mobile.categories.overlays/CategoryAddOverlay.js
@@ -86,7 +86,7 @@
* @param {jQuery.Event} ev
*/
onCategoryClick: function ( ev ) {
- $( ev.target ).closest( '.suggestion' ).detach();
+ this.$( ev.target ).closest( '.suggestion' ).detach();
if ( this.$( '.suggestion' ).length > 0 ) {
this.$saveButton.prop( 'disabled', false );
} else {
@@ -106,7 +106,7 @@
this.showHidden( '.saving-header' );
// add wikitext to add to the page
- $( '.suggestion' ).each( function () {
+ this.$( '.suggestion' ).each( function () {
var data = $( this ).data( 'title' );
if ( data ) {
diff --git a/resources/mobile.categories.overlays/CategoryLookupInputWidget.js
b/resources/mobile.categories.overlays/CategoryLookupInputWidget.js
index 54350a4..97c3d18 100644
--- a/resources/mobile.categories.overlays/CategoryLookupInputWidget.js
+++ b/resources/mobile.categories.overlays/CategoryLookupInputWidget.js
@@ -71,11 +71,12 @@
*/
CategoryLookupInputWidget.prototype.getLookupMenuOptionsFromData =
function ( data ) {
var result = [],
+ $el = this.$element,
self = this;
data.results.forEach( function ( value ) {
if (
- !$( 'div[data-title="' + value.title + '"]'
).length &&
+ !$el.find( 'div[data-title="' + value.title +
'"]' ).length &&
$.inArray( value.displayTitle, self.categories
) === -1
) {
result.push(
diff --git a/resources/mobile.categories.overlays/CategoryOverlay.js
b/resources/mobile.categories.overlays/CategoryOverlay.js
index a80ac23..85a0325 100644
--- a/resources/mobile.categories.overlays/CategoryOverlay.js
+++ b/resources/mobile.categories.overlays/CategoryOverlay.js
@@ -135,7 +135,7 @@
onCatlinkClick: function ( ev ) {
ev.preventDefault();
// change view only, if the user clicked another view
- if ( !$( ev.target ).parent().hasClass( 'selected' ) ) {
+ if ( !this.$( ev.target ).parent().hasClass( 'selected'
) ) {
this._changeView();
}
},
diff --git a/resources/mobile.editor.overlay/EditorOverlay.js
b/resources/mobile.editor.overlay/EditorOverlay.js
index 1114fd1..ad106d1 100644
--- a/resources/mobile.editor.overlay/EditorOverlay.js
+++ b/resources/mobile.editor.overlay/EditorOverlay.js
@@ -1,3 +1,4 @@
+/* global $ */
( function ( M, $ ) {
var EditorOverlayBase = M.require(
'mobile.editor.common/EditorOverlayBase' ),
Section = M.require( 'mobile.startup/Section' ),
@@ -114,7 +115,7 @@
*/
onClickContinue: function ( ev ) {
// handle the click on "Edit without logging in"
- if ( this.options.isAnon && $( ev.target ).hasClass(
'anonymous' ) ) {
+ if ( this.options.isAnon && this.$( ev.target
).hasClass( 'anonymous' ) ) {
this._showEditorAfterWarning();
return false;
}
@@ -302,6 +303,8 @@
var scrollTop;
if ( !this.$scrollContainer ) {
+ // FIXME: We are using global jQuery here which
suggests this should be passed as an option to the
+ // View or should make use of an event.
this.$scrollContainer = $(
OO.ui.Element.static.getClosestScrollableContainer( this.$content[ 0 ] ) );
this.$content.css( 'padding-bottom',
this.$scrollContainer.height() * 0.6 );
}
diff --git a/resources/mobile.fontchanger/FontChanger.js
b/resources/mobile.fontchanger/FontChanger.js
index 5112678..bb94378 100644
--- a/resources/mobile.fontchanger/FontChanger.js
+++ b/resources/mobile.fontchanger/FontChanger.js
@@ -71,6 +71,8 @@
self.setPercentage( parseInt(
self.fontchanger.val() ) + 10 );
return false;
} );
+ // FIXME: This should be an event and bound inside
+ //
resources/mobile.special.mobileoptions.scripts.fontchanger/init.js
$( 'form.mw-mf-settings' ).on( 'submit', $.proxy( this,
'save' ) );
},
diff --git a/resources/mobile.languages.structured/LanguageOverlay.js
b/resources/mobile.languages.structured/LanguageOverlay.js
index 4f1a5cd..c345edc 100644
--- a/resources/mobile.languages.structured/LanguageOverlay.js
+++ b/resources/mobile.languages.structured/LanguageOverlay.js
@@ -73,13 +73,14 @@
onLinkClick: function ( ev ) {
var $link = this.$( ev.currentTarget ),
lang = $link.attr( 'lang' ),
+ self = this,
$visibleLanguageLinks =
this.$languageItems.filter( ':visible' );
util.saveLanguageUsageCount( lang,
util.getFrequentlyUsedLanguages() );
// find the index of the clicked language in the list
of visible results
$visibleLanguageLinks.each( function ( i, link ) {
- if ( $( link ).hasClass( lang ) ) {
+ if ( self.$( link ).hasClass( lang ) ) {
return false;
}
} );
@@ -90,7 +91,7 @@
* @param {jQuery.Event} ev Event object.
*/
onSearchInput: function ( ev ) {
- this.filterLanguages( $( ev.target
).val().toLowerCase() );
+ this.filterLanguages( this.$( ev.target
).val().toLowerCase() );
},
/**
diff --git a/resources/mobile.mediaViewer/ImageOverlay.js
b/resources/mobile.mediaViewer/ImageOverlay.js
index e43ea7d..c4f90f8 100644
--- a/resources/mobile.mediaViewer/ImageOverlay.js
+++ b/resources/mobile.mediaViewer/ImageOverlay.js
@@ -75,7 +75,7 @@
*/
onSlide: function ( ev ) {
this.setNewImage(
- $( ev.target ).closest( '.slider-button'
).data( 'thumbnail' )
+ this.$( ev.target ).closest( '.slider-button'
).data( 'thumbnail' )
);
},
/**
@@ -243,7 +243,7 @@
} );
}
}
- $( '.image-wrapper' ).css( 'bottom', detailsHeight );
+ this.$( '.image-wrapper' ).css( 'bottom', detailsHeight
);
},
/**
diff --git a/resources/mobile.pointerOverlay/PointerOverlay.js
b/resources/mobile.pointerOverlay/PointerOverlay.js
index e602ff5..42a887a 100644
--- a/resources/mobile.pointerOverlay/PointerOverlay.js
+++ b/resources/mobile.pointerOverlay/PointerOverlay.js
@@ -75,6 +75,7 @@
}, this.options.timeout );
}
if ( self.options.target ) {
+ // FIXME: this option should be a jQuery object
already. Avoid use of global $.
$target = $( self.options.target );
// Ensure we position the overlay correctly but
do not show the arrow
self._position( $target );
diff --git a/resources/mobile.references/ReferencesDrawer.js
b/resources/mobile.references/ReferencesDrawer.js
index 6732139..afb182e 100644
--- a/resources/mobile.references/ReferencesDrawer.js
+++ b/resources/mobile.references/ReferencesDrawer.js
@@ -118,7 +118,7 @@
* @return {boolean} False to cancel the native event
*/
showNestedReference: function ( ev ) {
- var $dest = $( ev.target );
+ var $dest = this.$( ev.target );
this.showReference( $dest.attr( 'href' ),
this.options.page, $dest.text() );
// Don't hide the already shown drawer via propagation
and stop default scroll behaviour.
diff --git a/resources/mobile.search/SearchOverlay.js
b/resources/mobile.search/SearchOverlay.js
index 3f0b034..c812340 100644
--- a/resources/mobile.search/SearchOverlay.js
+++ b/resources/mobile.search/SearchOverlay.js
@@ -79,6 +79,7 @@
label: mw.msg( 'mobile-frontend-search-content'
)
} ).options,
searchTerm: '',
+ // FIXME: Do not use global $
placeholderMsg: $( '#searchInput' ).attr( 'placeholder'
),
noResultsMsg: mw.msg(
'mobile-frontend-search-no-results' ),
searchContentNoResultsMsg: mw.msg(
'mobile-frontend-search-content-no-results' ),
@@ -213,7 +214,7 @@
* @param {jQuery.Event} ev
*/
onClickResult: function ( ev ) {
- var $link = $( ev.currentTarget ),
+ var $link = this.$( ev.currentTarget ),
$result = $link.closest( 'li' );
/**
diff --git a/resources/mobile.startup/Overlay.js
b/resources/mobile.startup/Overlay.js
index b12bdc5..0883167 100644
--- a/resources/mobile.startup/Overlay.js
+++ b/resources/mobile.startup/Overlay.js
@@ -134,7 +134,7 @@
.on( 'touchmove', $.proxy( this,
'onTouchMove' ) );
// wait for things to render before doing any
calculations
setTimeout( function () {
- self._fixIosHeader( 'textarea, input' );
+ self._fixIosHeader( self.$( 'textarea,
input' ) );
}, 0 );
}
},
@@ -197,6 +197,8 @@
}
if ( this.closeOnContentTap ) {
+ // FIXME: $( '#mw-mf-page-center' ) should be
passed in as an option
+ // for this to work.
$( '#mw-mf-page-center' ).one( 'click',
$.proxy( this, 'hide' ) );
}
@@ -269,15 +271,15 @@
*
* @method
* @private
- * @param {string} el CSS selector for elements that may
trigger virtual
+ * @param {jQuery.Object} $el for elements that may trigger
virtual
* keyboard (usually inputs, textareas, contenteditables).
*/
- _fixIosHeader: function ( el ) {
+ _fixIosHeader: function ( $el ) {
var self = this;
if ( this.isIos ) {
this._resizeContent( $( window ).height() );
- $( el )
+ $el
.on( 'focus', function () {
setTimeout( function () {
var keyboardHeight = 0;
diff --git a/resources/mobile.startup/Page.js b/resources/mobile.startup/Page.js
index ab7ecfa..b99302c 100644
--- a/resources/mobile.startup/Page.js
+++ b/resources/mobile.startup/Page.js
@@ -119,12 +119,12 @@
* </div>
* </div>
*/
- if ( $( '.mf-section-0' ).length ) {
- return $( '.mf-section-0' );
+ if ( this.$( '.mf-section-0' ).length ) {
+ return this.$( '.mf-section-0' );
}
// for cached pages that are still using
mw-mobilefrontend-leadsection
- if ( $( '.mw-mobilefrontend-leadsection' ).length ) {
- return $( '.mw-mobilefrontend-leadsection' );
+ if ( this.$( '.mw-mobilefrontend-leadsection' ).length
) {
+ return this.$( '.mw-mobilefrontend-leadsection'
);
}
// no lead section found
return null;
diff --git a/resources/mobile.startup/Skin.js b/resources/mobile.startup/Skin.js
index 600c774..3aaf7be 100644
--- a/resources/mobile.startup/Skin.js
+++ b/resources/mobile.startup/Skin.js
@@ -2,7 +2,8 @@
var browser = M.require( 'mobile.startup/Browser' ).getSingleton(),
View = M.require( 'mobile.startup/View' ),
- icons = M.require( 'mobile.startup/icons' );
+ icons = M.require( 'mobile.startup/icons' ),
+ spinner = icons.spinner();
/**
* Get the id of the section $el belongs to.
@@ -121,7 +122,7 @@
* @private
*/
_onPageCenterClick: function ( ev ) {
- var $target = $( ev.target );
+ var $target = this.$( ev.target );
// Make sure the menu is open and we are not clicking
on the menu button
if (
@@ -182,7 +183,7 @@
function _loadImages() {
imagePlaceholders = $.grep( imagePlaceholders,
function ( placeholder ) {
- var $placeholder = $( placeholder );
+ var $placeholder = self.$( placeholder
);
if (
mw.viewport.isElementCloseToViewport( placeholder, offset ) &&
@@ -279,7 +280,7 @@
if ( !$content.data( 'are-references-loaded' ) ) {
$content.children().addClass( 'hidden' );
- $spinner = $( icons.spinner().toHtmlString()
).prependTo( $content );
+ $spinner = spinner.$el.prependTo( $content );
// First ensure we retrieve all of the possible
lists
return gateway.getReferencesLists( data.page )
@@ -347,12 +348,12 @@
licensePlural = mw.language.convertNumber(
mfLicense.plural );
if ( mfLicense.link ) {
- if ( $( '#footer-places-terms-use' ).length > 0
) {
+ if ( this.$( '#footer-places-terms-use'
).length > 0 ) {
licenseMsg = mw.msg(
'mobile-frontend-editor-licensing-with-terms',
mw.message(
'mobile-frontend-editor-terms-link',
- $(
'#footer-places-terms-use a' ).attr( 'href' )
+ this.$(
'#footer-places-terms-use a' ).attr( 'href' )
).parse(),
mfLicense.link,
licensePlural
diff --git a/resources/mobile.talk.overlays/TalkSectionOverlay.js
b/resources/mobile.talk.overlays/TalkSectionOverlay.js
index d1c4f49..aa358c6 100644
--- a/resources/mobile.talk.overlays/TalkSectionOverlay.js
+++ b/resources/mobile.talk.overlays/TalkSectionOverlay.js
@@ -54,7 +54,7 @@
*/
postRender: function () {
TalkOverlayBase.prototype.postRender.apply( this );
- this.$saveButton = $( '.save-button' );
+ this.$saveButton = this.$( '.save-button' );
if ( !this.options.section ) {
this.renderFromApi( this.options );
} else {
--
To view, visit https://gerrit.wikimedia.org/r/372445
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I5720fe738b092231b99d1eb240f8443478b310fe
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: Jhernandez <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits