define([ 'jquery', 'mage/translate', 'jquery-ui-modules/widget', 'jquery-ui-modules/core', ], function ($, $t) { 'use strict'; $.widget('mage.OXExpand', { options: { isMin: true, maxHeight: 90, more: $t('Show more'), less: $t('Show less'), checkCurrentSize: true }, _create: function () { this._create_html(); var $expand = this.element.children('.ox-expand'), $expandInner = $expand.children('.ox-expand__inner'), $expandLink = $expand.children('.ox-expand__link'); $expand.toggleClass('minimized', this.options.isMin).data({ 'max-height': this.options.maxHeight }); $expandInner.attr('aria-expanded', this.options.isMin ? 'false' : 'true') .css('max-height', this.options.isMin ? this.options.maxHeight : '100%'); $expandLink.find('.more').html(this.options.more); $expandLink.find('.less').html(this.options.less); }, _create_html: function () { if (this.element.children('.ox-expand').length || (this.options.checkCurrentSize && this.options.maxHeight > this.element.height())) return; var content = this.element.html(), new_content = $('