equal
deleted
inserted
replaced
1 /*! |
1 /*! |
2 * jQuery UI Checkboxradio 1.13.1 |
2 * jQuery UI Checkboxradio 1.13.3 |
3 * http://jqueryui.com |
3 * https://jqueryui.com |
4 * |
4 * |
5 * Copyright jQuery Foundation and other contributors |
5 * Copyright OpenJS Foundation and other contributors |
6 * Released under the MIT license. |
6 * Released under the MIT license. |
7 * http://jquery.org/license |
7 * https://jquery.org/license |
8 */ |
8 */ |
9 |
9 |
10 //>>label: Checkboxradio |
10 //>>label: Checkboxradio |
11 //>>group: Widgets |
11 //>>group: Widgets |
12 //>>description: Enhances a form with multiple themeable checkboxes or radio buttons. |
12 //>>description: Enhances a form with multiple themeable checkboxes or radio buttons. |
13 //>>docs: http://api.jqueryui.com/checkboxradio/ |
13 //>>docs: https://api.jqueryui.com/checkboxradio/ |
14 //>>demos: http://jqueryui.com/checkboxradio/ |
14 //>>demos: https://jqueryui.com/checkboxradio/ |
15 //>>css.structure: ../../themes/base/core.css |
15 //>>css.structure: ../../themes/base/core.css |
16 //>>css.structure: ../../themes/base/button.css |
16 //>>css.structure: ../../themes/base/button.css |
17 //>>css.structure: ../../themes/base/checkboxradio.css |
17 //>>css.structure: ../../themes/base/checkboxradio.css |
18 //>>css.theme: ../../themes/base/theme.css |
18 //>>css.theme: ../../themes/base/theme.css |
19 |
19 |
23 if ( typeof define === "function" && define.amd ) { |
23 if ( typeof define === "function" && define.amd ) { |
24 |
24 |
25 // AMD. Register as an anonymous module. |
25 // AMD. Register as an anonymous module. |
26 define( [ |
26 define( [ |
27 "jquery", |
27 "jquery", |
28 "./core" |
28 "../form-reset-mixin", |
|
29 "../labels", |
|
30 "../widget" |
29 ], factory ); |
31 ], factory ); |
30 } else { |
32 } else { |
31 |
33 |
32 // Browser globals |
34 // Browser globals |
33 factory( jQuery ); |
35 factory( jQuery ); |
34 } |
36 } |
35 } )( function( $ ) { |
37 } )( function( $ ) { |
36 "use strict"; |
38 "use strict"; |
37 |
39 |
38 $.widget( "ui.checkboxradio", [ $.ui.formResetMixin, { |
40 $.widget( "ui.checkboxradio", [ $.ui.formResetMixin, { |
39 version: "1.13.1", |
41 version: "1.13.3", |
40 options: { |
42 options: { |
41 disabled: null, |
43 disabled: null, |
42 label: null, |
44 label: null, |
43 icon: true, |
45 icon: true, |
44 classes: { |
46 classes: { |
46 "ui-checkboxradio-icon": "ui-corner-all" |
48 "ui-checkboxradio-icon": "ui-corner-all" |
47 } |
49 } |
48 }, |
50 }, |
49 |
51 |
50 _getCreateOptions: function() { |
52 _getCreateOptions: function() { |
51 var disabled, labels; |
53 var disabled, labels, labelContents; |
52 var that = this; |
|
53 var options = this._super() || {}; |
54 var options = this._super() || {}; |
54 |
55 |
55 // We read the type here, because it makes more sense to throw a element type error first, |
56 // We read the type here, because it makes more sense to throw a element type error first, |
56 // rather then the error for lack of a label. Often if its the wrong type, it |
57 // rather then the error for lack of a label. Often if its the wrong type, it |
57 // won't have a label (e.g. calling on a div, btn, etc) |
58 // won't have a label (e.g. calling on a div, btn, etc) |
67 |
68 |
68 this.originalLabel = ""; |
69 this.originalLabel = ""; |
69 |
70 |
70 // We need to get the label text but this may also need to make sure it does not contain the |
71 // We need to get the label text but this may also need to make sure it does not contain the |
71 // input itself. |
72 // input itself. |
72 this.label.contents().not( this.element[ 0 ] ).each( function() { |
73 // The label contents could be text, html, or a mix. We wrap all elements |
73 |
74 // and read the wrapper's `innerHTML` to get a string representation of |
74 // The label contents could be text, html, or a mix. We concat each element to get a |
75 // the label, without the input as part of it. |
75 // string representation of the label, without the input as part of it. |
76 labelContents = this.label.contents().not( this.element[ 0 ] ); |
76 that.originalLabel += this.nodeType === 3 ? $( this ).text() : this.outerHTML; |
77 |
77 } ); |
78 if ( labelContents.length ) { |
|
79 this.originalLabel += labelContents |
|
80 .clone() |
|
81 .wrapAll( "<div></div>" ) |
|
82 .parent() |
|
83 .html(); |
|
84 } |
78 |
85 |
79 // Set the label option if we found label text |
86 // Set the label option if we found label text |
80 if ( this.originalLabel ) { |
87 if ( this.originalLabel ) { |
81 options.label = this.originalLabel; |
88 options.label = this.originalLabel; |
82 } |
89 } |