Skip to content

Commit ffc62d9

Browse files
committed
MC-41897: Fix jQuery.fn.bind
- Change deprecated functions bind and unbind
1 parent ef323dc commit ffc62d9

File tree

12 files changed

+28
-28
lines changed

12 files changed

+28
-28
lines changed

app/code/Magento/CatalogInventory/Block/Adminhtml/Form/Field/Stock.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,8 @@ protected function _getJs($quantityFieldId, $inStockFieldId)
256256
};
257257
$.each(fieldsAssociations, function(generalTabField, advancedTabField) {
258258
$('#' + generalTabField + ', #' + advancedTabField)
259-
.bind('focus blur change keyup click', filler)
260-
.bind('keyup change blur', disabler)
259+
.on('focus blur change keyup click', filler)
260+
.on('keyup change blur', disabler)
261261
.trigger('change');
262262
});
263263

app/code/Magento/Theme/view/adminhtml/templates/tabs/css.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ require([
3434
add: function (e, data) {
3535
var uploadButton = $('#css_uploader_button');
3636
/** Unbind click event on file change */
37-
uploadButton.unbind('click');
37+
uploadButton.off('click');
3838
uploadButton.removeAttr('disabled');
3939
4040
uploadButton.click(function () {

app/code/Magento/Theme/view/adminhtml/templates/tabs/js.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ require([
124124
$('#js_files_uploader').click(function () {
125125
/** Unbind click event on file change */
126126
$('#js-file-uploader').html('');
127-
$('#js_uploader_button').unbind('click');
127+
$('#js_uploader_button').off('click');
128128
});
129129
130130

app/code/Magento/Ui/view/base/web/js/dynamic-rows/dnd.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ define([
109109
* @param {Object} data - element data
110110
*/
111111
initListeners: function (elem, data) {
112-
$(elem).on('mousedown touchstart', this.mousedownHandler.bind(this, data, elem));
112+
$(elem).on('mousedown touchstart', this.mousedownHandler.on(this, data, elem));
113113
},
114114

115115
/**
@@ -138,8 +138,8 @@ define([
138138
$table.offset().top - originRecord.offset().top + $table.children('thead').outerHeight();
139139
drEl.maxYpos = drEl.minYpos + $table.children('tbody').outerHeight() - originRecord.outerHeight();
140140
$tableWrapper.append(recordNode);
141-
this.body.bind('mousemove touchmove', this.mousemoveHandler);
142-
this.body.bind('mouseup touchend', this.mouseupHandler);
141+
this.body.on('mousemove touchmove', this.mousemoveHandler);
142+
this.body.on('mouseup touchend', this.mouseupHandler);
143143
},
144144

145145
/**
@@ -199,8 +199,8 @@ define([
199199

200200
drEl.originRow.removeClass(this.draggableElementClass);
201201

202-
this.body.unbind('mousemove touchmove', this.mousemoveHandler);
203-
this.body.unbind('mouseup touchend', this.mouseupHandler);
202+
this.body.off('mousemove touchmove', this.mousemoveHandler);
203+
this.body.off('mouseup touchend', this.mouseupHandler);
204204

205205
this.draggableElement = {};
206206
},

app/code/Magento/Ui/view/base/web/js/modal/alert.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ define([
4444
*/
4545
closeModal: function () {
4646
this.options.actions.always();
47-
this.element.bind('alertclosed', _.bind(this._remove, this));
47+
this.element.on('alertclosed', _.bind(this._remove, this));
4848

4949
return this._super();
5050
}

app/code/Magento/Ui/view/base/web/js/modal/confirm.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ define([
9595
this.options.actions.cancel(event);
9696
}
9797
this.options.actions.always(event);
98-
this.element.bind('confirmclosed', _.bind(this._remove, this));
98+
this.element.on('confirmclosed', _.bind(this._remove, this));
9999

100100
return this._super();
101101
}

app/code/Magento/Ui/view/base/web/js/modal/modal.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -276,18 +276,18 @@ define([
276276
* Set events listener when modal is opened.
277277
*/
278278
_setKeyListener: function () {
279-
this.modal.find(this.options.focusableStart).bind('focusin', this._tabSwitcher);
280-
this.modal.find(this.options.focusableEnd).bind('focusin', this._tabSwitcher);
281-
this.modal.bind('keydown', this.keyEventSwitcher);
279+
this.modal.find(this.options.focusableStart).on('focusin', this._tabSwitcher);
280+
this.modal.find(this.options.focusableEnd).on('focusin', this._tabSwitcher);
281+
this.modal.on('keydown', this.keyEventSwitcher);
282282
},
283283

284284
/**
285285
* Remove events listener when modal is closed.
286286
*/
287287
_removeKeyListener: function () {
288-
this.modal.find(this.options.focusableStart).unbind('focusin', this._tabSwitcher);
289-
this.modal.find(this.options.focusableEnd).unbind('focusin', this._tabSwitcher);
290-
this.modal.unbind('keydown', this.keyEventSwitcher);
288+
this.modal.find(this.options.focusableStart).off('focusin', this._tabSwitcher);
289+
this.modal.find(this.options.focusableEnd).off('focusin', this._tabSwitcher);
290+
this.modal.off('keydown', this.keyEventSwitcher);
291291
},
292292

293293
/**
@@ -441,15 +441,15 @@ define([
441441
}
442442
events = $._data(this.overlay.get(0), 'events');
443443
events ? this.prevOverlayHandler = events.click[0].handler : false;
444-
this.options.clickableOverlay ? this.overlay.unbind().on('click', outerClickHandler) : false;
444+
this.options.clickableOverlay ? this.overlay.off().on('click', outerClickHandler) : false;
445445
},
446446

447447
/**
448448
* Destroy overlay.
449449
*/
450450
_destroyOverlay: function () {
451451
if (this._getVisibleCount()) {
452-
this.overlay.unbind().on('click', this.prevOverlayHandler);
452+
this.overlay.off().on('click', this.prevOverlayHandler);
453453
} else {
454454
$(this.options.appendTo).removeClass(this.options.parentModalClass);
455455
this.overlay.remove();

app/code/Magento/Ui/view/base/web/js/modal/prompt.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ define([
206206
}
207207

208208
this.options.actions.always();
209-
this.element.bind('promptclosed', _.bind(this._remove, this));
209+
this.element.on('promptclosed', _.bind(this._remove, this));
210210

211211
return this._super();
212212
}

lib/web/mage/backend/menu.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ define([
4949
})
5050
// need to catch all clicks on disabled menu
5151
// not possible through _on
52-
.bind('click' + this.eventNamespace, $.proxy(function (event) {
52+
.on('click' + this.eventNamespace, $.proxy(function (event) {
5353
if (this.options.disabled) {
5454
event.preventDefault();
5555
}

lib/web/mage/gallery/gallery.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,8 @@ define([
192192
settings.closeIcon.show();
193193
settings.focusableStart.attr('tabindex', '0');
194194
settings.focusableEnd.attr('tabindex', '0');
195-
settings.focusableStart.bind('focusin', self._focusSwitcher);
196-
settings.focusableEnd.bind('focusin', self._focusSwitcher);
195+
settings.focusableStart.on('focusin', self._focusSwitcher);
196+
settings.focusableEnd.on('focusin', self._focusSwitcher);
197197
settings.api.updateOptions(settings.defaultConfig.options, true);
198198
settings.api.updateOptions(settings.fullscreenConfig, true);
199199

@@ -208,8 +208,8 @@ define([
208208
settings.focusableStart.attr('tabindex', '-1');
209209
settings.focusableEnd.attr('tabindex', '-1');
210210
settings.api.updateOptions(settings.defaultConfig.options, true);
211-
settings.focusableStart.unbind('focusin', this._focusSwitcher);
212-
settings.focusableEnd.unbind('focusin', this._focusSwitcher);
211+
settings.focusableStart.off('focusin', this._focusSwitcher);
212+
settings.focusableEnd.off('focusin', this._focusSwitcher);
213213
settings.closeIcon.hide();
214214

215215
if (!_.isEqual(settings.activeBreakpoint, {}) && settings.breakpoints) {

0 commit comments

Comments
 (0)