Skip to content

Commit

Permalink
chore(*): completely removing usage of $.proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
kdinev committed Oct 3, 2022
1 parent e16b338 commit d4c24fa
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 51 deletions.
15 changes: 7 additions & 8 deletions src/js/modules/infragistics.ui.splitbutton.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
14 changes: 5 additions & 9 deletions src/js/modules/infragistics.ui.toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/js/modules/infragistics.ui.toolbarbutton.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/js/modules/infragistics.ui.upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
22 changes: 11 additions & 11 deletions src/js/modules/infragistics.ui.videoplayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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);
}
},

Expand Down Expand Up @@ -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;
}
Expand All @@ -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) {
Expand Down Expand Up @@ -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 () {
Expand Down Expand Up @@ -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);
}
}
},
Expand All @@ -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
Expand Down Expand Up @@ -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);
}
},
Expand Down Expand Up @@ -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;
Expand All @@ -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);
}
});

Expand Down
33 changes: 16 additions & 17 deletions src/js/modules/infragistics.ui.zoombar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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 () {
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/videoplayer/mockVideo.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
this.play();
}
}
setTimeout($.proxy(this._srcTimer, this), 500);
setTimeout(this._srcTimer.bind(this), 500);
};

div._buffer = function () {
Expand Down

0 comments on commit d4c24fa

Please sign in to comment.