/
githubmirror
/
magento2
Обзор
Документация
Войти
/
githubmirror
/
magento2
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
2.4-develop
lib/web/mage/deletable-item.js
82 строки
2 KB
Alexandra Zota
ACP2E-4019: CE copyright updates for 2.4.9-beta1
11 ноя 2025, 17:53
11 ноя 2025, 17:53
f22b64f
Код
Авторство
О чём код?
/** * Copyright 2014 Adobe * All Rights Reserved. */ /** * @deprecated since version 2.2.0 */ define([ 'jquery', 'jquery-ui-modules/widget' ], function ($) { 'use strict'; /** * This widget is used to tag a DOM element as deletable. By default, it will use the click event on the item with a * data role of delete to trigger the deletion. */ $.widget('mage.deletableItem', { options: { deleteEvent: 'click', deleteSelector: '[data-role="delete"]', hiddenClass: 'no-display' }, /** * This method binds elements found in this widget. */ _bind: function () { var handlers = {}; // since the first handler is dynamic, generate the object using array notation handlers[this.options.deleteEvent + ' ' + this.options.deleteSelector] = '_onDeleteClicked'; handlers.hideDelete = '_onHideDelete'; handlers.showDelete = '_onShowDelete'; this._on(handlers); }, /** * This method constructs a new widget. */ _create: function () { this._bind(); }, /** * This method is to initialize the control * @private */ _init: function () { this._onHideDelete(); // by default, hide the control }, /** * This method removes the entity from the DOM. * @private */ _onDeleteClicked: function (e) { e.stopPropagation(); this.element.trigger('deleteItem'); }, /** * This method hides the delete capability of this item (i.e. making it not deletable) * @private */ _onHideDelete: function () { this.element.find(this.options.deleteSelector).addClass(this.options.hiddenClass); }, /** * This method shows the delete capability of this item (i.e. making it deletable) * @private */ _onShowDelete: function () { this.element.find(this.options.deleteSelector).removeClass(this.options.hiddenClass); } }); return $.mage.deletableItem; });