From e93e1bc845aff0c8b4abe6a7976692783411edcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20Laxstr=C3=B6m?= Date: Sat, 15 Dec 2018 13:49:51 +0100 Subject: [PATCH] Remove disabling of max-len rule and fix violations Change-Id: I39ec2e572e569a05c11929dd17241653abf954ef --- .eslintrc.json | 3 - resources/js/ext.uls.displaysettings.js | 26 ++++---- resources/js/ext.uls.interface.js | 80 +++++++++++++------------ 3 files changed, 53 insertions(+), 56 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 9769a95f..e8c5bc83 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -6,8 +6,5 @@ "globals": { "mw": false, "OO": false - }, - "rules": { - "max-len": 0 } } diff --git a/resources/js/ext.uls.displaysettings.js b/resources/js/ext.uls.displaysettings.js index df246162..7b28c7d7 100644 --- a/resources/js/ext.uls.displaysettings.js +++ b/resources/js/ext.uls.displaysettings.js @@ -655,19 +655,17 @@ * modules. */ apply: function () { - var displaySettings = this; - - if ( !displaySettings.dirty ) { + if ( !this.dirty ) { // No changes to save in this module. return; } - displaySettings.$parent.setBusy( true ); + this.$parent.setBusy( true ); // Save the preferences mw.webfonts.preferences.save( function ( result ) { var newWebfontsEnable, oldWebfontsEnable, webfontsEvent, newRegistry = mw.webfonts.preferences.registry, - oldRegistry = displaySettings.savedRegistry.registry, + oldRegistry = this.savedRegistry.registry, newFonts = newRegistry.fonts || {}, oldFonts = oldRegistry.fonts || {}; @@ -684,25 +682,25 @@ mw.hook( webfontsEvent ).fire( 'displaysettings' ); } - if ( newFonts[ displaySettings.uiLanguage ] !== oldFonts[ displaySettings.uiLanguage ] ) { + if ( newFonts[ this.uiLanguage ] !== oldFonts[ this.uiLanguage ] ) { mw.hook( 'mw.uls.font.change' ).fire( - 'interface', displaySettings.uiLanguage, newFonts[ displaySettings.uiLanguage ] + 'interface', this.uiLanguage, newFonts[ this.uiLanguage ] ); } - if ( newFonts[ displaySettings.contentLanguage ] !== oldFonts[ displaySettings.contentLanguage ] ) { + if ( newFonts[ this.contentLanguage ] !== oldFonts[ this.contentLanguage ] ) { mw.hook( 'mw.uls.font.change' ).fire( - 'content', displaySettings.contentLanguage, newFonts[ displaySettings.contentLanguage ] + 'content', this.contentLanguage, newFonts[ this.contentLanguage ] ); } // closure for not losing the scope - displaySettings.onSave( result ); - displaySettings.dirty = false; + this.onSave( result ); + this.dirty = false; // Update the back-up preferences for the case of canceling - displaySettings.savedRegistry = $.extend( true, {}, mw.webfonts.preferences ); - displaySettings.$parent.setBusy( false ); - } ); + this.savedRegistry = $.extend( true, {}, mw.webfonts.preferences ); + this.$parent.setBusy( false ); + }.bind( this ) ); }, /** diff --git a/resources/js/ext.uls.interface.js b/resources/js/ext.uls.interface.js index 666fc66f..f6043623 100644 --- a/resources/js/ext.uls.interface.js +++ b/resources/js/ext.uls.interface.js @@ -272,47 +272,49 @@ if ( !languagesettings.shown ) { mw.hook( 'mw.uls.settings.open' ).fire( eventParams && eventParams.source || 'interlanguage' ); } - } else { - // Initialize the Language settings window - languageSettingsOptions = { - defaultModule: 'display', - onVisible: function () { - var caretRadius, - ulsTriggerHeight = this.$element.height(), - ulsTriggerWidth = this.$element[ 0 ].offsetWidth, - ulsTriggerOffset = this.$element.offset(); - this.$window.addClass( 'callout' ); - - // Same as border width in mixins.less, or near enough - caretRadius = 12; - - if ( ulsTriggerOffset.left > $( window ).width() / 2 ) { - this.left = ulsTriggerOffset.left - this.$window.width() - caretRadius; - this.$window.removeClass( 'selector-left' ).addClass( 'selector-right' ); - - } else { - this.left = ulsTriggerOffset.left + ulsTriggerWidth + caretRadius; - this.$window.removeClass( 'selector-right' ).addClass( 'selector-left' ); - } - - // The top of the dialog is aligned in relation to - // the middle of the trigger, so that middle of the - // caret aligns with it. 16 is trigger icon height in pixels - this.top = ulsTriggerOffset.top + - ( ulsTriggerHeight / 2 ) - - ( caretRadius + 16 ); - - this.position(); - } - }; - - mw.loader.using( mw.uls.languageSettingsModules, function () { - $ulsTrigger.languagesettings( languageSettingsOptions ).click(); - } ); - - e.stopPropagation(); + return; } + + // Initialize the Language settings window + languageSettingsOptions = { + defaultModule: 'display', + onVisible: function () { + var caretRadius, + ulsTriggerHeight = this.$element.height(), + ulsTriggerWidth = this.$element[ 0 ].offsetWidth, + ulsTriggerOffset = this.$element.offset(); + + this.$window.addClass( 'callout' ); + + // Same as border width in mixins.less, or near enough + caretRadius = 12; + + if ( ulsTriggerOffset.left > $( window ).width() / 2 ) { + this.left = ulsTriggerOffset.left - this.$window.width() - caretRadius; + this.$window.removeClass( 'selector-left' ).addClass( 'selector-right' ); + + } else { + this.left = ulsTriggerOffset.left + ulsTriggerWidth + caretRadius; + this.$window.removeClass( 'selector-right' ).addClass( 'selector-left' ); + } + + // The top of the dialog is aligned in relation to + // the middle of the trigger, so that middle of the + // caret aligns with it. 16 is trigger icon height in pixels + this.top = ulsTriggerOffset.top + + ( ulsTriggerHeight / 2 ) - + ( caretRadius + 16 ); + + this.position(); + } + }; + + mw.loader.using( mw.uls.languageSettingsModules, function () { + $ulsTrigger.languagesettings( languageSettingsOptions ).click(); + } ); + + e.stopPropagation(); }; } else if ( anonMode ) { clickHandler = function ( e, eventParams ) {