define([ 'jquery', 'Magento_Ui/js/modal/modal' ], function ($, modal) { 'use strict'; $.widget('diweb.miniquotecart', { options: { countUrl: 'cotizacion/index/count' }, _create: function (config, element) { this._bind(); this._validate(); }, _bind: function () { var self = this; $(this.element).on("updateQuote", function () { self._validate(); }); }, _validate: function () { var self = this; var $element = $(self.element); var $element_mobile = $('.quote-icon-box.quote-icon-mobile'); $.ajax({ url: self.options.baseUrl + self.options.countUrl, type: 'get', dataType: 'json', beforeSend: function () { //$('body').trigger('processStart'); }, success: function (res) { if (res && res.count > 0) { $element.removeClass('d-none'); $element.find('.quote-qty .counter-number').text(res.count); if($element_mobile.length){ $element_mobile.removeClass('d-none'); $element_mobile.find('.quote-qty .counter-number').text(res.count); } } else { $element.addClass('d-none'); if($element_mobile.length){ $element_mobile.addClass('d-none'); } } }, error: function () { }, complete: function() { //$('body').trigger('processStop'); } }); } }); return $.diweb.miniquotecart; });