dialog.jquery-ui.es6.js 875 B

12345678910111213141516171819202122232425262728293031323334
  1. /**
  2. * @file
  3. * Adds default classes to buttons for styling purposes.
  4. */
  5. (function($) {
  6. $.widget('ui.dialog', $.ui.dialog, {
  7. options: {
  8. buttonClass: 'button',
  9. buttonPrimaryClass: 'button--primary',
  10. },
  11. _createButtons() {
  12. const opts = this.options;
  13. let primaryIndex;
  14. let index;
  15. const il = opts.buttons.length;
  16. for (index = 0; index < il; index++) {
  17. if (
  18. opts.buttons[index].primary &&
  19. opts.buttons[index].primary === true
  20. ) {
  21. primaryIndex = index;
  22. delete opts.buttons[index].primary;
  23. break;
  24. }
  25. }
  26. this._super();
  27. const $buttons = this.uiButtonSet.children().addClass(opts.buttonClass);
  28. if (typeof primaryIndex !== 'undefined') {
  29. $buttons.eq(index).addClass(opts.buttonPrimaryClass);
  30. }
  31. },
  32. });
  33. })(jQuery);