Skip to content

Commit

Permalink
Merge pull request #20 from magento-lynx/MC-41897
Browse files Browse the repository at this point in the history
MC-41897: Fix jQuery.fn.bind()
  • Loading branch information
sivaschenko authored May 8, 2021
2 parents 2d89aa8 + 553eac2 commit f870442
Show file tree
Hide file tree
Showing 17 changed files with 36 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,8 @@ protected function _getJs($quantityFieldId, $inStockFieldId)
};
$.each(fieldsAssociations, function(generalTabField, advancedTabField) {
$('#' + generalTabField + ', #' + advancedTabField)
.bind('focus blur change keyup click', filler)
.bind('keyup change blur', disabler)
.on('focus blur change keyup click', filler)
.on('keyup change blur', disabler)
.trigger('change');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ define([
}
this.isValid = true;
});
dataForm.bind('invalid-form.validate', function () {
dataForm.on('invalid-form.validate', function () {
$(this).find(':submit').prop('disabled', false);
this.isValid = false;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ define([

if (!this.allowedActions.includes('delete')) {
$.async('.media-gallery-delete-assets', function () {
$('.media-gallery-delete-assets').unbind('click').addClass('action-disabled');
$('.media-gallery-delete-assets').off('click').addClass('action-disabled');
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,10 +431,10 @@ define([
tableBody = $(),
activePanel = $();

$('#frontend_input').bind('change', function () {
$('#frontend_input').on('change', function () {
swatchProductAttributes.bindAttributeInputType();
});
$('#is_filterable').bind('change', function () {
$('#is_filterable').on('change', function () {
swatchProductAttributes.switchIsFilterable();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ require([
add: function (e, data) {
var uploadButton = $('#css_uploader_button');
/** Unbind click event on file change */
uploadButton.unbind('click');
uploadButton.off('click');
uploadButton.removeAttr('disabled');
uploadButton.click(function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ require([
$('#js_files_uploader').click(function () {
/** Unbind click event on file change */
$('#js-file-uploader').html('');
$('#js_uploader_button').unbind('click');
$('#js_uploader_button').off('click');
});
Expand Down
8 changes: 4 additions & 4 deletions app/code/Magento/Ui/view/base/web/js/dynamic-rows/dnd.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ define([
$table.offset().top - originRecord.offset().top + $table.children('thead').outerHeight();
drEl.maxYpos = drEl.minYpos + $table.children('tbody').outerHeight() - originRecord.outerHeight();
$tableWrapper.append(recordNode);
this.body.bind('mousemove touchmove', this.mousemoveHandler);
this.body.bind('mouseup touchend', this.mouseupHandler);
this.body.on('mousemove touchmove', this.mousemoveHandler);
this.body.on('mouseup touchend', this.mouseupHandler);
},

/**
Expand Down Expand Up @@ -199,8 +199,8 @@ define([

drEl.originRow.removeClass(this.draggableElementClass);

this.body.unbind('mousemove touchmove', this.mousemoveHandler);
this.body.unbind('mouseup touchend', this.mouseupHandler);
this.body.off('mousemove touchmove', this.mousemoveHandler);
this.body.off('mouseup touchend', this.mouseupHandler);

this.draggableElement = {};
},
Expand Down
8 changes: 4 additions & 4 deletions app/code/Magento/Ui/view/base/web/js/grid/resize.js
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,8 @@ define([
cfg.curResizeElem.model.width = $(cfg.curResizeElem.elems[0]).outerWidth();
cfg.depResizeElem.model.width = $(cfg.depResizeElem.elems[0]).outerWidth();
body.addClass(this.inResizeClass);
body.bind('mousemove', this.mousemoveHandler);
$(window).bind('mouseup', this.mouseupHandler);
body.on('mousemove', this.mousemoveHandler);
$(window).on('mouseup', this.mouseupHandler);
},

/**
Expand Down Expand Up @@ -528,8 +528,8 @@ define([
this.store('storageColumnsData');

body.removeClass(this.inResizeClass);
body.unbind('mousemove', this.mousemoveHandler);
$(window).unbind('mouseup', this.mouseupHandler);
body.off('mousemove', this.mousemoveHandler);
$(window).off('mouseup', this.mouseupHandler);
},

/**
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Ui/view/base/web/js/modal/alert.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ define([
*/
closeModal: function () {
this.options.actions.always();
this.element.bind('alertclosed', _.bind(this._remove, this));
this.element.on('alertclosed', _.bind(this._remove, this));

return this._super();
}
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Ui/view/base/web/js/modal/confirm.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ define([
this.options.actions.cancel(event);
}
this.options.actions.always(event);
this.element.bind('confirmclosed', _.bind(this._remove, this));
this.element.on('confirmclosed', _.bind(this._remove, this));

return this._super();
}
Expand Down
16 changes: 8 additions & 8 deletions app/code/Magento/Ui/view/base/web/js/modal/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,18 +276,18 @@ define([
* Set events listener when modal is opened.
*/
_setKeyListener: function () {
this.modal.find(this.options.focusableStart).bind('focusin', this._tabSwitcher);
this.modal.find(this.options.focusableEnd).bind('focusin', this._tabSwitcher);
this.modal.bind('keydown', this.keyEventSwitcher);
this.modal.find(this.options.focusableStart).on('focusin', this._tabSwitcher);
this.modal.find(this.options.focusableEnd).on('focusin', this._tabSwitcher);
this.modal.on('keydown', this.keyEventSwitcher);
},

/**
* Remove events listener when modal is closed.
*/
_removeKeyListener: function () {
this.modal.find(this.options.focusableStart).unbind('focusin', this._tabSwitcher);
this.modal.find(this.options.focusableEnd).unbind('focusin', this._tabSwitcher);
this.modal.unbind('keydown', this.keyEventSwitcher);
this.modal.find(this.options.focusableStart).off('focusin', this._tabSwitcher);
this.modal.find(this.options.focusableEnd).off('focusin', this._tabSwitcher);
this.modal.off('keydown', this.keyEventSwitcher);
},

/**
Expand Down Expand Up @@ -441,15 +441,15 @@ define([
}
events = $._data(this.overlay.get(0), 'events');
events ? this.prevOverlayHandler = events.click[0].handler : false;
this.options.clickableOverlay ? this.overlay.unbind().on('click', outerClickHandler) : false;
this.options.clickableOverlay ? this.overlay.off().on('click', outerClickHandler) : false;
},

/**
* Destroy overlay.
*/
_destroyOverlay: function () {
if (this._getVisibleCount()) {
this.overlay.unbind().on('click', this.prevOverlayHandler);
this.overlay.off().on('click', this.prevOverlayHandler);
} else {
$(this.options.appendTo).removeClass(this.options.parentModalClass);
this.overlay.remove();
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Ui/view/base/web/js/modal/prompt.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ define([
}

this.options.actions.always();
this.element.bind('promptclosed', _.bind(this._remove, this));
this.element.on('promptclosed', _.bind(this._remove, this));

return this._super();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
'lib/internal/Magento/Framework/Encryption/Test/Unit/EncryptorTest.php',
'lib/internal/Magento/Framework/Encryption/Test/Unit/CryptTest.php',
'setup/src/Zend/Mvc/Controller/LazyControllerAbstractFactory.php',
'app/code/Magento/CatalogInventory/Block/Adminhtml/Form/Field/Stock.php',
];
2 changes: 1 addition & 1 deletion lib/web/mage/backend/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ define([
})
// need to catch all clicks on disabled menu
// not possible through _on
.bind('click' + this.eventNamespace, $.proxy(function (event) {
.on('click' + this.eventNamespace, $.proxy(function (event) {
if (this.options.disabled) {
event.preventDefault();
}
Expand Down
8 changes: 4 additions & 4 deletions lib/web/mage/gallery/gallery.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ define([
settings.closeIcon.show();
settings.focusableStart.attr('tabindex', '0');
settings.focusableEnd.attr('tabindex', '0');
settings.focusableStart.bind('focusin', self._focusSwitcher);
settings.focusableEnd.bind('focusin', self._focusSwitcher);
settings.focusableStart.on('focusin', self._focusSwitcher);
settings.focusableEnd.on('focusin', self._focusSwitcher);
settings.api.updateOptions(settings.defaultConfig.options, true);
settings.api.updateOptions(settings.fullscreenConfig, true);

Expand All @@ -208,8 +208,8 @@ define([
settings.focusableStart.attr('tabindex', '-1');
settings.focusableEnd.attr('tabindex', '-1');
settings.api.updateOptions(settings.defaultConfig.options, true);
settings.focusableStart.unbind('focusin', this._focusSwitcher);
settings.focusableEnd.unbind('focusin', this._focusSwitcher);
settings.focusableStart.off('focusin', this._focusSwitcher);
settings.focusableEnd.off('focusin', this._focusSwitcher);
settings.closeIcon.hide();

if (!_.isEqual(settings.activeBreakpoint, {}) && settings.breakpoints) {
Expand Down
2 changes: 1 addition & 1 deletion lib/web/mage/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ define([
this.element
.addClass('list-widget');

addButton.bind('click', $.proxy(this.handleAdd, this));
addButton.on('click', $.proxy(this.handleAdd, this));

//handle remove
destination.on('click', this.options.removeButton, $.proxy(this.removeItem, this));
Expand Down
4 changes: 2 additions & 2 deletions lib/web/magnifier/magnify.js
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ define([
}
});
} else {
$image.unbind('dblclick');
$image.off('dblclick');
$image.dblclick(dblClickHandler);
}

Expand Down Expand Up @@ -746,7 +746,7 @@ define([
});

if (keyboardNavigation) {
$(document).unbind('keydown', keyboardNavigation);
$(document).off('keydown', keyboardNavigation);
}

/**
Expand Down

0 comments on commit f870442

Please sign in to comment.