From 9c0c918bab80967ff3289cf33a2d002a26320cac Mon Sep 17 00:00:00 2001 From: petarpetkovic Date: Thu, 24 May 2018 19:09:31 +0200 Subject: [PATCH] Replace jQuery.proxy() with Function.prototype.bind() Also, one immediate invocation of jQuery.proxy() is replaced by Function.prototype.call() Change-Id: Ibbdbe6413793c113d4de1c67cfcb7d95676565b2 --- resources/js/ext.uls.compactlinks.js | 2 +- resources/js/ext.uls.eventlogger.js | 26 ++++++++++++------------ resources/js/ext.uls.languagesettings.js | 12 +++++------ 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/resources/js/ext.uls.compactlinks.js b/resources/js/ext.uls.compactlinks.js index 8bb1f3eb..5d039d97 100644 --- a/resources/js/ext.uls.compactlinks.js +++ b/resources/js/ext.uls.compactlinks.js @@ -295,7 +295,7 @@ // Show common languages quickList: self.getCommonLanguages( languages ), noResultsTemplate: function () { - var $defaultTemplate = $.proxy( $.fn.lcd.defaults.noResultsTemplate, this )(); + var $defaultTemplate = $.fn.lcd.defaults.noResultsTemplate.call( this ); // Customize the message $defaultTemplate .find( '.uls-no-results-found-title' ) diff --git a/resources/js/ext.uls.eventlogger.js b/resources/js/ext.uls.eventlogger.js index 6e0f5511..f87382b1 100644 --- a/resources/js/ext.uls.eventlogger.js +++ b/resources/js/ext.uls.eventlogger.js @@ -76,21 +76,21 @@ */ listen: function () { // Register handlers for event logging triggers - mw.hook( 'mw.uls.settings.open' ).add( $.proxy( this.ulsSettingsOpen, this ) ); - mw.hook( 'mw.uls.language.revert' ).add( $.proxy( this.ulsLanguageRevert, this ) ); - mw.hook( 'mw.uls.ime.enable' ).add( $.proxy( this.enableIME, this ) ); - mw.hook( 'mw.uls.ime.disable' ).add( $.proxy( this.disableIME, this ) ); - mw.hook( 'mw.uls.ime.change' ).add( $.proxy( this.changeIME, this ) ); - mw.hook( 'mw.uls.login.click' ).add( $.proxy( this.loginClick, this ) ); - mw.hook( 'mw.uls.ime.morelanguages' ).add( $.proxy( this.imeMoreLanguages, this ) ); - mw.hook( 'mw.uls.interface.morelanguages' ).add( $.proxy( this.interfaceMoreLanguages, this ) ); - mw.hook( 'mw.uls.interface.language.change' ).add( $.proxy( this.interfaceLanguageChange, this ) ); - mw.hook( 'mw.uls.font.change' ).add( $.proxy( this.fontChange, this ) ); - mw.hook( 'mw.uls.webfonts.enable' ).add( $.proxy( this.enableWebfonts, this ) ); - mw.hook( 'mw.uls.webfonts.disable' ).add( $.proxy( this.disableWebfonts, this ) ); + mw.hook( 'mw.uls.settings.open' ).add( this.ulsSettingsOpen.bind( this ) ); + mw.hook( 'mw.uls.language.revert' ).add( this.ulsLanguageRevert.bind( this ) ); + mw.hook( 'mw.uls.ime.enable' ).add( this.enableIME.bind( this ) ); + mw.hook( 'mw.uls.ime.disable' ).add( this.disableIME.bind( this ) ); + mw.hook( 'mw.uls.ime.change' ).add( this.changeIME.bind( this ) ); + mw.hook( 'mw.uls.login.click' ).add( this.loginClick.bind( this ) ); + mw.hook( 'mw.uls.ime.morelanguages' ).add( this.imeMoreLanguages.bind( this ) ); + mw.hook( 'mw.uls.interface.morelanguages' ).add( this.interfaceMoreLanguages.bind( this ) ); + mw.hook( 'mw.uls.interface.language.change' ).add( this.interfaceLanguageChange.bind( this ) ); + mw.hook( 'mw.uls.font.change' ).add( this.fontChange.bind( this ) ); + mw.hook( 'mw.uls.webfonts.enable' ).add( this.enableWebfonts.bind( this ) ); + mw.hook( 'mw.uls.webfonts.disable' ).add( this.disableWebfonts.bind( this ) ); $( 'body' ).on( 'noresults.uls', '.uls-menu .uls-languagefilter', - $.proxy( this.noSearchResults, this ) + this.noSearchResults.bind( this ) ); }, diff --git a/resources/js/ext.uls.languagesettings.js b/resources/js/ext.uls.languagesettings.js index 12dd92f8..6fd18cf0 100644 --- a/resources/js/ext.uls.languagesettings.js +++ b/resources/js/ext.uls.languagesettings.js @@ -74,14 +74,14 @@ // Register all event listeners to the ULS language settings here. listen: function () { - this.$element.on( 'click', $.proxy( this.click, this ) ); + this.$element.on( 'click', this.click.bind( this ) ); this.$window.find( '#languagesettings-close, button.uls-settings-cancel' ) - .on( 'click', $.proxy( mw.hook( 'mw.uls.settings.cancel' ).fire, this ) ); + .on( 'click', mw.hook( 'mw.uls.settings.cancel' ).fire.bind( this ) ); this.$window.find( 'button.uls-settings-apply' ) - .on( 'click', $.proxy( mw.hook( 'mw.uls.settings.apply' ).fire, this ) ); + .on( 'click', mw.hook( 'mw.uls.settings.apply' ).fire.bind( this ) ); // Hide the window when clicked outside - $( 'html' ).click( $.proxy( this.hide, this ) ); + $( 'html' ).click( this.hide.bind( this ) ); // ... but when clicked on window do not hide. this.$window.on( 'click', function ( event ) { @@ -168,8 +168,8 @@ this.modules[ moduleName ] = module; // Register cancel and apply hooks - mw.hook( 'mw.uls.settings.cancel' ).add( $.proxy( module.cancel, module ) ); - mw.hook( 'mw.uls.settings.apply' ).add( $.proxy( module.apply, module ) ); + mw.hook( 'mw.uls.settings.cancel' ).add( module.cancel.bind( module ) ); + mw.hook( 'mw.uls.settings.apply' ).add( module.apply.bind( module ) ); }, position: function () {