truncate.js 1.18 KB
Newer Older
Ketan's avatar
Ketan committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

/**
 * JQuery UI Widget declaration: 'mage.truncateOptions'
 *
 * @deprecated since version 2.2.0
 */
define([
    'jquery',
    'jquery/ui'
], function ($) {
    'use strict';

    $.widget('mage.truncateOptions', {
        options: {
            detailsLink: 'a.details',
            mouseEvents: 'mouseover mouseout',
            truncatedFullValue: 'div.truncated.full.value'
        },

        /**
         * Establish the event handler for mouse events on the appropriate elements.
         *
         * @private
         */
        _create: function () {
            this.element.on(this.options.mouseEvents, $.proxy(this._toggleShow, this))
                .find(this.options.detailsLink).on(this.options.mouseEvents, $.proxy(this._toggleShow, this));
        },

        /**
         * Toggle the "show" class on the associated element.
         *
         * @private
         * @param {jQuery.Event} event - Mouse over/out event.
         */
        _toggleShow: function (event) {
            $(event.currentTarget).find(this.options.truncatedFullValue).toggleClass('show');
        }
    });
});