From d4c24fa0c802832b06c34fa78cabbc1f18d5cb54 Mon Sep 17 00:00:00 2001 From: Konstantin Dinev Date: Mon, 3 Oct 2022 16:08:41 +0300 Subject: [PATCH] chore(*): completely removing usage of $.proxy --- src/js/modules/infragistics.ui.splitbutton.js | 15 ++++----- src/js/modules/infragistics.ui.toolbar.js | 14 +++----- .../modules/infragistics.ui.toolbarbutton.js | 2 +- src/js/modules/infragistics.ui.upload.js | 8 ++--- src/js/modules/infragistics.ui.videoplayer.js | 22 ++++++------- src/js/modules/infragistics.ui.zoombar.js | 33 +++++++++---------- tests/unit/videoplayer/mockVideo.js | 2 +- 7 files changed, 45 insertions(+), 51 deletions(-) diff --git a/src/js/modules/infragistics.ui.splitbutton.js b/src/js/modules/infragistics.ui.splitbutton.js index d9de67fd0..54ddbb955 100644 --- a/src/js/modules/infragistics.ui.splitbutton.js +++ b/src/js/modules/infragistics.ui.splitbutton.js @@ -257,15 +257,14 @@ _attachEvents: function () { var _opt = this._options; - _opt.defaultButton.on("igtoolbarbuttonclick", $.proxy(this._onDefaultBtnClick, this)); - _opt.expandButton.on("focus", $.proxy(this._onExpandBtnFocus, this)); - _opt.expandButton.on("blur", $.proxy(this._onExpandBtnBlur, this)); - _opt.expandButton.on("igtoolbarbuttonclick", $.proxy(this._onExpandBtnClick, this)); - _opt.itemsList.on("igtoolbarbuttonclick", "a", $.proxy(this._onItemClick, this)); + _opt.defaultButton.on("igtoolbarbuttonclick", this._onDefaultBtnClick.bind(this)); + _opt.expandButton.on("focus", this._onExpandBtnFocus.bind(this)); + _opt.expandButton.on("blur", this._onExpandBtnBlur.bind(this)); + _opt.expandButton.on("igtoolbarbuttonclick", this._onExpandBtnClick.bind(this)); + _opt.itemsList.on("igtoolbarbuttonclick", "a", this._onItemClick.bind(this)); - this.element.on("keypress", $.proxy(this._onEnterKeypress, this)); - this.element.hover($.proxy(this._onMouseEnter, this), - $.proxy(this._onMouseLeave, this)); + this.element.on("keypress", this._onEnterKeypress.bind(this)); + this.element.hover(this._onMouseEnter.bind(this), this._onMouseLeave.bind(this)); }, _onDefaultBtnClick: function (e) { var self = this; diff --git a/src/js/modules/infragistics.ui.toolbar.js b/src/js/modules/infragistics.ui.toolbar.js index a06b71b05..487d9e0ad 100644 --- a/src/js/modules/infragistics.ui.toolbar.js +++ b/src/js/modules/infragistics.ui.toolbar.js @@ -1081,25 +1081,21 @@ var toolbarItemsEvents = "igtoolbarbuttonclick igsplitbuttonclick igcolorpickersplitbuttoncolorselected"; - this.element - .delegate(".ui-widget", toolbarItemsEvents, - $.proxy(this._onToolbarItemInteraction, this)); + this.element.on(toolbarItemsEvents, ".ui-widget", this._onToolbarItemInteraction.bind(this)); // Here we bind to igCombo items on click. // D.A. 3 Sep. 2013 Bug#150671 Custom combo handler is not called when clicked on the list item. // Bound to igcomboselectionchanged event instead of click, because // click was not fired when cliking on the list item's text node. this.element - .delegate(":ui-igCombo", "igcomboselectionchanged", - $.proxy(this._onComboListItemClick, this)) - .delegate(":ui-igCombo", "igcombodropdownclosed", - $.proxy(this._onComboDropDownClose, this)); + .on("igcomboselectionchanged", ":ui-igCombo", this._onComboListItemClick.bind(this)) + .on("igcombodropdownclosed", ":ui-igCombo", this._onComboDropDownClose.bind(this)); this.collapseBtn - .bind("igtoolbarbuttonclick", $.proxy(this._onCollapse, this)); + .on("igtoolbarbuttonclick", this._onCollapse.bind(this)); // D.U. 30.04.2014 Implementing resizing functionality on window resize - $(window).on("resize", $.proxy(this._onResize, this)); + $(window).on("resize", this._onResize.bind(this)); }, _onToolbarItemInteraction: function (e, ui) { var selectedItemValue, diff --git a/src/js/modules/infragistics.ui.toolbarbutton.js b/src/js/modules/infragistics.ui.toolbarbutton.js index d7ef08237..e69155d51 100644 --- a/src/js/modules/infragistics.ui.toolbarbutton.js +++ b/src/js/modules/infragistics.ui.toolbarbutton.js @@ -283,7 +283,7 @@ } }); - this.element.on("keypress", $.proxy(this._onEnterKey, this)); + this.element.on("keypress", this._onEnterKey.bind(this)); }, toggle: function () { /* Toggle toolbar button diff --git a/src/js/modules/infragistics.ui.upload.js b/src/js/modules/infragistics.ui.upload.js index bd13da054..df071a0b6 100644 --- a/src/js/modules/infragistics.ui.upload.js +++ b/src/js/modules/infragistics.ui.upload.js @@ -1928,16 +1928,16 @@ this.fileInfoData = data; this._renderStartupBrowseButton(); this.container() - .bind("drop", $.proxy(this._dropFiles, this)) + .on("drop", this._dropFiles.bind(this)) .width(this.options.width) .height(this.options.height); this._attachFakeIframe(); /* M.H. 27 Jul 2011 - fix bug 77162 - analyze file extension icons array */ this._analyzeFileExtensionIcons(); /* M.H. 12 Dec 2012 Fix for bug #129351 */ - $(document).bind("dragenter." + this.element[ 0 ].id, $.proxy(this._docEnter, this)); - $(document).bind("dragover." + this.element[ 0 ].id, $.proxy(this._docOver, this)); - $(document).bind("dragleave." + this.element[ 0 ].id, $.proxy(this._docLeave, this)); + $(document).bind("dragenter." + this.element[ 0 ].id, this._docEnter.bind(this)); + $(document).bind("dragover." + this.element[ 0 ].id, this._docOver.bind(this)); + $(document).bind("dragleave." + this.element[ 0 ].id, this._docLeave.bind(this)); }, _dropFiles: function (e) { var isInit = $("#" + this._id("_ibb")).is(":visible"), diff --git a/src/js/modules/infragistics.ui.videoplayer.js b/src/js/modules/infragistics.ui.videoplayer.js index 6289eccdc..c8bed685a 100644 --- a/src/js/modules/infragistics.ui.videoplayer.js +++ b/src/js/modules/infragistics.ui.videoplayer.js @@ -2440,7 +2440,7 @@ this._attachEvents(video); this._renderSources(o.sources, video); this._analyzeSource(video); - setTimeout($.proxy(this._onVideoStateChange, this), this._const.VIDEO_STATE_TIMEOUT); + setTimeout(this._onVideoStateChange.bind(this), this._const.VIDEO_STATE_TIMEOUT); this._createBigPlayButton(); this._createWaitingIndicator(); @@ -2831,7 +2831,7 @@ var continueScrolling = this._isScrolling && this._rvScrollOnce(); if (continueScrolling) { this._scrollingTimoutId = - setTimeout($.proxy(this._rvDoScroll, this), this._const.SCROLL_TIMEOUT); + setTimeout(this._rvDoScroll.bind(this), this._const.SCROLL_TIMEOUT); } else { this._rvStopScroll(); } @@ -3086,7 +3086,7 @@ } if (msgOpt.autoHide) { - this._adHideTimeout = setTimeout($.proxy(this.hideAdMessage, this), msgOpt.hideDelay); + this._adHideTimeout = setTimeout(this.hideAdMessage.bind(this), msgOpt.hideDelay); } }, @@ -3761,7 +3761,7 @@ this._showCenterPlayButton().removeClass(this.css.centerPlayButtonClass) .addClass(this.css.centerPauseButtonClass); } - setTimeout($.proxy(this._hideCenterPlayButton, this), o.centerButtonHideDelay); + setTimeout(this._hideCenterPlayButton.bind(this), o.centerButtonHideDelay); this._prepareForPlay(); this._lastPausedState = videoElem.paused; } @@ -3771,7 +3771,7 @@ this._refreshDuration(); this._onVideoStateChangeId = - setTimeout($.proxy(this._onVideoStateChange, this), this._const.VIDEO_STATE_TIMEOUT); + setTimeout(this._onVideoStateChange.bind(this), this._const.VIDEO_STATE_TIMEOUT); }, _updateTitleControlsTimeString: function (timeString, title) { @@ -4324,7 +4324,7 @@ .removeClass(css.centerPlayButtonClass) .addClass(css.centerPauseButtonClass); } - setTimeout($.proxy(this._hideCenterPlayButton, this), o.centerButtonHideDelay); + setTimeout(this._hideCenterPlayButton.bind(this), o.centerButtonHideDelay); }, _hideCenterPlayButton: function () { @@ -4568,7 +4568,7 @@ }); if (this.options.height) { this.currentVideo.css("height", this.container.height() - bookmarkArea.height()); - this._resizeBookmarkAreaTimeoutId = setTimeout($.proxy(this._onPlayerResize, this), 500); + this._resizeBookmarkAreaTimeoutId = setTimeout(this._onPlayerResize.bind(this), 500); } } }, @@ -4587,7 +4587,7 @@ this._oldContainerHeight = containerH; this._oldContainerWidth = containerW; } - this._resizeBookmarkAreaTimeoutId = setTimeout($.proxy(this._onPlayerResize, this), 250); + this._resizeBookmarkAreaTimeoutId = setTimeout(this._onPlayerResize.bind(this), 250); }, // S.S. June 24th, 2011 Bug #74601 Before rendering our controls we need to be sure the correct @@ -4799,7 +4799,7 @@ if (!$.contains(event.currentTarget, event.relatedTarget) && event.currentTarget !== event.relatedTarget) { control._volumeSliderTimeoutId = - setTimeout($.proxy(control._hideVolumeSlider, control), + setTimeout(control._hideVolumeSlider.bind(control), control.options.volumeAutohideDelay); } }, @@ -4827,7 +4827,7 @@ mouseout: function () { if (!control._userSlidingVolume) { control._volumeSliderTimeoutId = - setTimeout($.proxy(control._hideVolumeSlider, control), + setTimeout(control._hideVolumeSlider.bind(control), control.options.volumeAutohideDelay); } control._volumeSliderMouseOut = true; @@ -4854,7 +4854,7 @@ $("#" + this._id("_ctrls_vs")).data("igSlider").handle.attr("tabIndex", -1).bind({ blur: function () { control._volumeSliderTimeoutId = - setTimeout($.proxy(control._hideVolumeSlider, control), control.options.volumeAutohideDelay); + setTimeout(control._hideVolumeSlider.bind(control), control.options.volumeAutohideDelay); } }); diff --git a/src/js/modules/infragistics.ui.zoombar.js b/src/js/modules/infragistics.ui.zoombar.js index 2c11d43a7..631fca403 100644 --- a/src/js/modules/infragistics.ui.zoombar.js +++ b/src/js/modules/infragistics.ui.zoombar.js @@ -1165,7 +1165,7 @@ // refreshes the current window based on internal window in percentage var wnd = this._cw, sbtw, lfw, self = this; animate = animate && this.options.windowPanDuration > 0; - func = func ? $.proxy(func, this) : function () { self._sliding = false; }; + func = func ? func.bind(this) : function () { self._sliding = false; }; /* update thumb */ if (animate) { this._sliding = true; @@ -1330,20 +1330,20 @@ this._acc = this._acc + 0.1; }, _createHandlers: function () { - this._leftRightButtonHandler = $.proxy(this._leftRightButtonClicked, this); - this._zoombarMouseWheelHandler = $.proxy(this._mouseWheel, this); - this._zoombarTouchStartHandler = $.proxy(this._touchStart, this); - this._zoombarTouchMoveHandler = $.proxy(this._touchMove, this); - this._zoombarTouchEndHandler = $.proxy(this._touchEnd, this); - this._zoombarMouseDownHandler = $.proxy(this._mouseDown, this); - this._zoombarMouseMoveHandler = $.proxy(this._mouseMove, this); - this._zoombarMouseUpHandler = $.proxy(this._mouseUp, this); - this._targetWindowChangedHandler = $.proxy(this._targetWindowChanged, this); - this._containerResizedHandler = $.proxy(this._containerResized, this); - this._scrollbarThumbMouseEnterHandler = $.proxy(this._scrollBarMouseEnter, this); - this._scrollbarThumbMouseLeaveHandler = $.proxy(this._scrollBarMouseLeave, this); - this._windowKeyDownHandler = $.proxy(this._windowKeyDown, this); - this._windowKeyUpHandler = $.proxy(this._windowKeyUp, this); + this._leftRightButtonHandler = this._leftRightButtonClicked.bind(this); + this._zoombarMouseWheelHandler = this._mouseWheel.bind(this); + this._zoombarTouchStartHandler = this._touchStart.bind(this); + this._zoombarTouchMoveHandler = this._touchMove.bind(this); + this._zoombarTouchEndHandler = this._touchEnd.bind(this); + this._zoombarMouseDownHandler = this._mouseDown.bind(this); + this._zoombarMouseMoveHandler = this._mouseMove.bind(this); + this._zoombarMouseUpHandler = this._mouseUp.bind(this); + this._targetWindowChangedHandler = this._targetWindowChanged.bind(this); + this._containerResizedHandler = this._containerResized.bind(this); + this._scrollbarThumbMouseEnterHandler = this._scrollBarMouseEnter.bind(this); + this._scrollbarThumbMouseLeaveHandler = this._scrollBarMouseLeave.bind(this); + this._windowKeyDownHandler = this._windowKeyDown.bind(this); + this._windowKeyUpHandler = this._windowKeyUp.bind(this); }, _registerEvents: function () { var wnd = $(window), @@ -1596,8 +1596,7 @@ _bind: function () { var t = this.settings.targetObject; if (t && t.element && t.element.length) { - t.element.on("igdatachartwindowrectchanged.zoombar", - $.proxy(this._windowRectChanged, this)); + t.element.on("igdatachartwindowrectchanged.zoombar", this._windowRectChanged.bind(this)); } }, _unbind: function () { diff --git a/tests/unit/videoplayer/mockVideo.js b/tests/unit/videoplayer/mockVideo.js index 9613315dc..b949f279e 100644 --- a/tests/unit/videoplayer/mockVideo.js +++ b/tests/unit/videoplayer/mockVideo.js @@ -84,7 +84,7 @@ this.play(); } } - setTimeout($.proxy(this._srcTimer, this), 500); + setTimeout(this._srcTimer.bind(this), 500); }; div._buffer = function () {