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