dialog.jquery-ui.es6.js 846 B

12345678910111213141516171819202122232425262728293031
  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 (opts.buttons[index].primary && opts.buttons[index].primary === true) {
  18. primaryIndex = index;
  19. delete opts.buttons[index].primary;
  20. break;
  21. }
  22. }
  23. this._super();
  24. const $buttons = this.uiButtonSet.children().addClass(opts.buttonClass);
  25. if (typeof primaryIndex !== 'undefined') {
  26. $buttons.eq(index).addClass(opts.buttonPrimaryClass);
  27. }
  28. },
  29. });
  30. }(jQuery));