truncate.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /**
  2. * Copyright © Magento, Inc. All rights reserved.
  3. * See COPYING.txt for license details.
  4. */
  5. /**
  6. * JQuery UI Widget declaration: 'mage.truncateOptions'
  7. *
  8. * @deprecated since version 2.2.0
  9. */
  10. define([
  11. 'jquery',
  12. 'jquery/ui'
  13. ], function ($) {
  14. 'use strict';
  15. $.widget('mage.truncateOptions', {
  16. options: {
  17. detailsLink: 'a.details',
  18. mouseEvents: 'mouseover mouseout',
  19. truncatedFullValue: 'div.truncated.full.value'
  20. },
  21. /**
  22. * Establish the event handler for mouse events on the appropriate elements.
  23. *
  24. * @private
  25. */
  26. _create: function () {
  27. this.element.on(this.options.mouseEvents, $.proxy(this._toggleShow, this))
  28. .find(this.options.detailsLink).on(this.options.mouseEvents, $.proxy(this._toggleShow, this));
  29. },
  30. /**
  31. * Toggle the "show" class on the associated element.
  32. *
  33. * @private
  34. * @param {jQuery.Event} event - Mouse over/out event.
  35. */
  36. _toggleShow: function (event) {
  37. $(event.currentTarget).find(this.options.truncatedFullValue).toggleClass('show');
  38. }
  39. });
  40. });