@ntlab/ntjs-assets 2.0.2 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/js/bootstrap-icons/bootstrap-icons.svg +1 -1
- package/assets/js/bootstrap-icons/folder-plus.svg +2 -2
- package/assets/js/bootstrap-icons/font/bootstrap-icons.css +1981 -0
- package/assets/js/bootstrap-icons/font/bootstrap-icons.json +1955 -0
- package/assets/js/bootstrap-icons/font/bootstrap-icons.min.css +5 -0
- package/assets/js/bootstrap-icons/font/bootstrap-icons.scss +1993 -0
- package/assets/js/bootstrap-icons/font/fonts/bootstrap-icons.woff +0 -0
- package/assets/js/bootstrap-icons/font/fonts/bootstrap-icons.woff2 +0 -0
- package/assets/js/bootstrap-icons/postcard-heart-fill.svg +1 -1
- package/assets/js/bootstrap-icons/trash.svg +2 -2
- package/assets/js/jquery/jquery.js +840 -1045
- package/assets/js/jquery/jquery.min.js +2 -2
- package/assets/js/jquery/jquery.min.map +1 -1
- package/assets/js/jquery/jquery.slim.js +834 -1039
- package/assets/js/jquery/jquery.slim.min.js +2 -2
- package/assets/js/jquery/jquery.slim.min.map +1 -1
- package/assets/js/popper.js/cjs/enums.js +1 -1
- package/assets/js/popper.js/cjs/popper-base.js +12 -170
- package/assets/js/popper.js/cjs/popper-base.js.map +1 -1
- package/assets/js/popper.js/cjs/popper-lite.js +14 -184
- package/assets/js/popper.js/cjs/popper-lite.js.map +1 -1
- package/assets/js/popper.js/cjs/popper.js +14 -197
- package/assets/js/popper.js/cjs/popper.js.map +1 -1
- package/assets/js/popper.js/esm/createPopper.js +6 -66
- package/assets/js/popper.js/esm/modifiers/arrow.js +1 -12
- package/assets/js/popper.js/esm/modifiers/computeStyles.js +2 -14
- package/assets/js/popper.js/esm/utils/computeAutoPlacement.js +0 -4
- package/assets/js/popper.js/esm/utils/userAgent.js +1 -1
- package/assets/js/popper.js/umd/enums.js +1 -1
- package/assets/js/popper.js/umd/enums.min.js +1 -1
- package/assets/js/popper.js/umd/popper-base.js +12 -170
- package/assets/js/popper.js/umd/popper-base.js.map +1 -1
- package/assets/js/popper.js/umd/popper-base.min.js +2 -2
- package/assets/js/popper.js/umd/popper-base.min.js.map +1 -1
- package/assets/js/popper.js/umd/popper-lite.js +14 -184
- package/assets/js/popper.js/umd/popper-lite.js.map +1 -1
- package/assets/js/popper.js/umd/popper-lite.min.js +2 -2
- package/assets/js/popper.js/umd/popper-lite.min.js.map +1 -1
- package/assets/js/popper.js/umd/popper.js +14 -197
- package/assets/js/popper.js/umd/popper.js.map +1 -1
- package/assets/js/popper.js/umd/popper.min.js +2 -2
- package/assets/js/popper.js/umd/popper.min.js.map +1 -1
- package/assets/js/semantic-ui/components/accordion.css +196 -74
- package/assets/js/semantic-ui/components/accordion.js +570 -591
- package/assets/js/semantic-ui/components/accordion.min.css +4 -4
- package/assets/js/semantic-ui/components/accordion.min.js +6 -6
- package/assets/js/semantic-ui/components/ad.css +40 -51
- package/assets/js/semantic-ui/components/ad.min.css +4 -4
- package/assets/js/semantic-ui/components/api.js +1154 -1117
- package/assets/js/semantic-ui/components/api.min.js +6 -6
- package/assets/js/semantic-ui/components/breadcrumb.css +7 -7
- package/assets/js/semantic-ui/components/breadcrumb.min.css +4 -4
- package/assets/js/semantic-ui/components/button.css +895 -1227
- package/assets/js/semantic-ui/components/button.min.css +4 -4
- package/assets/js/semantic-ui/components/calendar.css +60 -33
- package/assets/js/semantic-ui/components/calendar.js +1952 -1575
- package/assets/js/semantic-ui/components/calendar.min.css +4 -4
- package/assets/js/semantic-ui/components/calendar.min.js +6 -6
- package/assets/js/semantic-ui/components/card.css +1004 -441
- package/assets/js/semantic-ui/components/card.min.css +4 -4
- package/assets/js/semantic-ui/components/checkbox.css +275 -303
- package/assets/js/semantic-ui/components/checkbox.js +863 -855
- package/assets/js/semantic-ui/components/checkbox.min.css +4 -4
- package/assets/js/semantic-ui/components/checkbox.min.js +6 -6
- package/assets/js/semantic-ui/components/comment.css +45 -63
- package/assets/js/semantic-ui/components/comment.min.css +4 -4
- package/assets/js/semantic-ui/components/container.css +98 -4
- package/assets/js/semantic-ui/components/container.min.css +4 -4
- package/assets/js/semantic-ui/components/dimmer.css +95 -196
- package/assets/js/semantic-ui/components/dimmer.js +698 -717
- package/assets/js/semantic-ui/components/dimmer.min.css +4 -4
- package/assets/js/semantic-ui/components/dimmer.min.js +6 -6
- package/assets/js/semantic-ui/components/divider.css +75 -93
- package/assets/js/semantic-ui/components/divider.min.css +4 -4
- package/assets/js/semantic-ui/components/dropdown.css +490 -413
- package/assets/js/semantic-ui/components/dropdown.js +4203 -4068
- package/assets/js/semantic-ui/components/dropdown.min.css +4 -4
- package/assets/js/semantic-ui/components/dropdown.min.js +6 -6
- package/assets/js/semantic-ui/components/embed.css +27 -38
- package/assets/js/semantic-ui/components/embed.js +647 -673
- package/assets/js/semantic-ui/components/embed.min.css +4 -4
- package/assets/js/semantic-ui/components/embed.min.js +6 -6
- package/assets/js/semantic-ui/components/emoji.css +11156 -9192
- package/assets/js/semantic-ui/components/emoji.min.css +3 -3
- package/assets/js/semantic-ui/components/feed.css +56 -78
- package/assets/js/semantic-ui/components/feed.min.css +4 -4
- package/assets/js/semantic-ui/components/flag.css +1037 -929
- package/assets/js/semantic-ui/components/flag.min.css +4 -4
- package/assets/js/semantic-ui/components/flyout.css +552 -0
- package/assets/js/semantic-ui/components/flyout.js +1567 -0
- package/assets/js/semantic-ui/components/flyout.min.css +9 -0
- package/assets/js/semantic-ui/components/flyout.min.js +11 -0
- package/assets/js/semantic-ui/components/form.css +536 -530
- package/assets/js/semantic-ui/components/form.js +2037 -1945
- package/assets/js/semantic-ui/components/form.min.css +4 -4
- package/assets/js/semantic-ui/components/form.min.js +6 -6
- package/assets/js/semantic-ui/components/grid.css +218 -345
- package/assets/js/semantic-ui/components/grid.min.css +4 -4
- package/assets/js/semantic-ui/components/header.css +137 -154
- package/assets/js/semantic-ui/components/header.min.css +4 -4
- package/assets/js/semantic-ui/components/icon.css +3000 -2750
- package/assets/js/semantic-ui/components/icon.min.css +4 -4
- package/assets/js/semantic-ui/components/image.css +54 -49
- package/assets/js/semantic-ui/components/image.min.css +4 -4
- package/assets/js/semantic-ui/components/input.css +1081 -227
- package/assets/js/semantic-ui/components/input.min.css +4 -4
- package/assets/js/semantic-ui/components/item.css +91 -138
- package/assets/js/semantic-ui/components/item.min.css +4 -4
- package/assets/js/semantic-ui/components/label.css +470 -481
- package/assets/js/semantic-ui/components/label.min.css +4 -4
- package/assets/js/semantic-ui/components/list.css +93 -114
- package/assets/js/semantic-ui/components/list.min.css +4 -4
- package/assets/js/semantic-ui/components/loader.css +452 -536
- package/assets/js/semantic-ui/components/loader.min.css +4 -4
- package/assets/js/semantic-ui/components/menu.css +408 -510
- package/assets/js/semantic-ui/components/menu.min.css +9 -1
- package/assets/js/semantic-ui/components/message.css +188 -213
- package/assets/js/semantic-ui/components/message.min.css +4 -4
- package/assets/js/semantic-ui/components/modal.css +174 -166
- package/assets/js/semantic-ui/components/modal.js +1558 -1146
- package/assets/js/semantic-ui/components/modal.min.css +4 -4
- package/assets/js/semantic-ui/components/modal.min.js +6 -6
- package/assets/js/semantic-ui/components/nag.css +183 -41
- package/assets/js/semantic-ui/components/nag.js +527 -467
- package/assets/js/semantic-ui/components/nag.min.css +4 -4
- package/assets/js/semantic-ui/components/nag.min.js +6 -6
- package/assets/js/semantic-ui/components/placeholder.css +62 -76
- package/assets/js/semantic-ui/components/placeholder.min.css +4 -4
- package/assets/js/semantic-ui/components/popup.css +681 -312
- package/assets/js/semantic-ui/components/popup.js +1470 -1463
- package/assets/js/semantic-ui/components/popup.min.css +4 -4
- package/assets/js/semantic-ui/components/popup.min.js +6 -6
- package/assets/js/semantic-ui/components/progress.css +149 -217
- package/assets/js/semantic-ui/components/progress.js +945 -1002
- package/assets/js/semantic-ui/components/progress.min.css +4 -4
- package/assets/js/semantic-ui/components/progress.min.js +6 -6
- package/assets/js/semantic-ui/components/rail.css +17 -22
- package/assets/js/semantic-ui/components/rail.min.css +3 -3
- package/assets/js/semantic-ui/components/rating.css +89 -184
- package/assets/js/semantic-ui/components/rating.js +509 -521
- package/assets/js/semantic-ui/components/rating.min.css +4 -4
- package/assets/js/semantic-ui/components/rating.min.js +6 -6
- package/assets/js/semantic-ui/components/reset.css +12 -17
- package/assets/js/semantic-ui/components/reset.min.css +4 -4
- package/assets/js/semantic-ui/components/reveal.css +46 -85
- package/assets/js/semantic-ui/components/reveal.min.css +4 -4
- package/assets/js/semantic-ui/components/search.css +157 -96
- package/assets/js/semantic-ui/components/search.js +1522 -1479
- package/assets/js/semantic-ui/components/search.min.css +4 -4
- package/assets/js/semantic-ui/components/search.min.js +6 -6
- package/assets/js/semantic-ui/components/segment.css +317 -249
- package/assets/js/semantic-ui/components/segment.min.css +4 -4
- package/assets/js/semantic-ui/components/shape.css +16 -32
- package/assets/js/semantic-ui/components/shape.js +763 -812
- package/assets/js/semantic-ui/components/shape.min.css +4 -4
- package/assets/js/semantic-ui/components/shape.min.js +6 -6
- package/assets/js/semantic-ui/components/sidebar.css +128 -216
- package/assets/js/semantic-ui/components/sidebar.js +1042 -1003
- package/assets/js/semantic-ui/components/sidebar.min.css +4 -4
- package/assets/js/semantic-ui/components/sidebar.min.js +6 -6
- package/assets/js/semantic-ui/components/site.css +123 -48
- package/assets/js/semantic-ui/components/site.js +438 -478
- package/assets/js/semantic-ui/components/site.min.css +4 -4
- package/assets/js/semantic-ui/components/site.min.js +6 -6
- package/assets/js/semantic-ui/components/slider.css +133 -141
- package/assets/js/semantic-ui/components/slider.js +1312 -1274
- package/assets/js/semantic-ui/components/slider.min.css +9 -1
- package/assets/js/semantic-ui/components/slider.min.js +6 -6
- package/assets/js/semantic-ui/components/state.js +640 -659
- package/assets/js/semantic-ui/components/state.min.js +6 -6
- package/assets/js/semantic-ui/components/statistic.css +83 -124
- package/assets/js/semantic-ui/components/statistic.min.css +4 -4
- package/assets/js/semantic-ui/components/step.css +118 -184
- package/assets/js/semantic-ui/components/step.min.css +4 -4
- package/assets/js/semantic-ui/components/sticky.css +3 -8
- package/assets/js/semantic-ui/components/sticky.js +849 -892
- package/assets/js/semantic-ui/components/sticky.min.css +4 -4
- package/assets/js/semantic-ui/components/sticky.min.js +6 -6
- package/assets/js/semantic-ui/components/tab.css +16 -20
- package/assets/js/semantic-ui/components/tab.js +896 -941
- package/assets/js/semantic-ui/components/tab.min.css +4 -4
- package/assets/js/semantic-ui/components/tab.min.js +6 -6
- package/assets/js/semantic-ui/components/table.css +2073 -884
- package/assets/js/semantic-ui/components/table.min.css +4 -4
- package/assets/js/semantic-ui/components/text.css +51 -30
- package/assets/js/semantic-ui/components/text.min.css +4 -4
- package/assets/js/semantic-ui/components/toast.css +200 -137
- package/assets/js/semantic-ui/components/toast.js +912 -832
- package/assets/js/semantic-ui/components/toast.min.css +4 -4
- package/assets/js/semantic-ui/components/toast.min.js +6 -6
- package/assets/js/semantic-ui/components/transition.css +371 -1282
- package/assets/js/semantic-ui/components/transition.js +999 -1074
- package/assets/js/semantic-ui/components/transition.min.css +4 -4
- package/assets/js/semantic-ui/components/transition.min.js +6 -6
- package/assets/js/semantic-ui/components/visibility.js +1215 -1247
- package/assets/js/semantic-ui/components/visibility.min.js +6 -6
- package/assets/js/semantic-ui/semantic.css +43777 -37429
- package/assets/js/semantic-ui/semantic.js +29152 -26694
- package/assets/js/semantic-ui/semantic.min.css +6 -399
- package/assets/js/semantic-ui/semantic.min.js +6 -6
- package/assets/js/semantic-ui/themes/basic/assets/fonts/icons.woff2 +0 -0
- package/assets/js/semantic-ui/themes/default/assets/fonts/Lato-Bold.woff +0 -0
- package/assets/js/semantic-ui/themes/default/assets/fonts/Lato-Bold.woff2 +0 -0
- package/assets/js/semantic-ui/themes/default/assets/fonts/Lato-BoldItalic.woff +0 -0
- package/assets/js/semantic-ui/themes/default/assets/fonts/Lato-BoldItalic.woff2 +0 -0
- package/assets/js/semantic-ui/themes/default/assets/fonts/Lato-Italic.woff +0 -0
- package/assets/js/semantic-ui/themes/default/assets/fonts/Lato-Italic.woff2 +0 -0
- package/assets/js/semantic-ui/themes/default/assets/fonts/Lato-Regular.woff +0 -0
- package/assets/js/semantic-ui/themes/default/assets/fonts/Lato-Regular.woff2 +0 -0
- package/assets/js/semantic-ui/themes/default/assets/fonts/LatoLatin-Bold.woff +0 -0
- package/assets/js/semantic-ui/themes/default/assets/fonts/LatoLatin-Bold.woff2 +0 -0
- package/assets/js/semantic-ui/themes/default/assets/fonts/LatoLatin-BoldItalic.woff +0 -0
- package/assets/js/semantic-ui/themes/default/assets/fonts/LatoLatin-BoldItalic.woff2 +0 -0
- package/assets/js/semantic-ui/themes/default/assets/fonts/LatoLatin-Italic.woff +0 -0
- package/assets/js/semantic-ui/themes/default/assets/fonts/LatoLatin-Italic.woff2 +0 -0
- package/assets/js/semantic-ui/themes/default/assets/fonts/LatoLatin-Regular.woff +0 -0
- package/assets/js/semantic-ui/themes/default/assets/fonts/LatoLatin-Regular.woff2 +0 -0
- package/assets/js/semantic-ui/themes/default/assets/fonts/brand-icons.woff +0 -0
- package/assets/js/semantic-ui/themes/default/assets/fonts/brand-icons.woff2 +0 -0
- package/assets/js/semantic-ui/themes/default/assets/fonts/icons.woff +0 -0
- package/assets/js/semantic-ui/themes/default/assets/fonts/icons.woff2 +0 -0
- package/assets/js/semantic-ui/themes/default/assets/fonts/outline-icons.woff +0 -0
- package/assets/js/semantic-ui/themes/default/assets/fonts/outline-icons.woff2 +0 -0
- package/assets/js/semantic-ui/themes/famfamfam/assets/images/flags.png +0 -0
- package/assets/js/semantic-ui/themes/github/assets/fonts/octicons.woff2 +0 -0
- package/assets/js/socket.io/socket.io.esm.min.js +3 -3
- package/assets/js/socket.io/socket.io.esm.min.js.map +1 -1
- package/assets/js/socket.io/socket.io.js +841 -333
- package/assets/js/socket.io/socket.io.js.map +1 -1
- package/assets/js/socket.io/socket.io.min.js +3 -3
- package/assets/js/socket.io/socket.io.min.js.map +1 -1
- package/assets/js/socket.io/socket.io.msgpack.min.js +3 -3
- package/assets/js/socket.io/socket.io.msgpack.min.js.map +1 -1
- package/cdn.json +19 -4
- package/package.json +1 -1
|
@@ -1,876 +1,884 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* # Fomantic-UI - Checkbox
|
|
3
|
-
*
|
|
2
|
+
* # Fomantic-UI 2.9.2 - Checkbox
|
|
3
|
+
* https://github.com/fomantic/Fomantic-UI/
|
|
4
4
|
*
|
|
5
5
|
*
|
|
6
6
|
* Released under the MIT license
|
|
7
|
-
*
|
|
7
|
+
* https://opensource.org/licenses/MIT
|
|
8
8
|
*
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
(function ($, window, document) {
|
|
12
|
+
'use strict';
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
function isFunction(obj) {
|
|
15
|
+
return typeof obj === 'function' && typeof obj.nodeType !== 'number';
|
|
16
|
+
}
|
|
14
17
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
window = window !== undefined && window.Math === Math
|
|
19
|
+
? window
|
|
20
|
+
: globalThis;
|
|
18
21
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
: Function('return this')()
|
|
24
|
-
;
|
|
22
|
+
$.fn.checkbox = function (parameters) {
|
|
23
|
+
var
|
|
24
|
+
$allModules = $(this),
|
|
25
|
+
moduleSelector = $allModules.selector || '',
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
$allModules = $(this),
|
|
29
|
-
moduleSelector = $allModules.selector || '',
|
|
27
|
+
time = Date.now(),
|
|
28
|
+
performance = [],
|
|
30
29
|
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
query = arguments[0],
|
|
31
|
+
methodInvoked = typeof query === 'string',
|
|
32
|
+
queryArguments = [].slice.call(arguments, 1),
|
|
33
|
+
returnedValue
|
|
34
|
+
;
|
|
33
35
|
|
|
34
|
-
|
|
35
|
-
methodInvoked = (typeof query == 'string'),
|
|
36
|
-
queryArguments = [].slice.call(arguments, 1),
|
|
37
|
-
returnedValue
|
|
38
|
-
;
|
|
39
|
-
|
|
40
|
-
$allModules
|
|
41
|
-
.each(function() {
|
|
42
|
-
var
|
|
43
|
-
settings = $.extend(true, {}, $.fn.checkbox.settings, parameters),
|
|
44
|
-
|
|
45
|
-
className = settings.className,
|
|
46
|
-
namespace = settings.namespace,
|
|
47
|
-
selector = settings.selector,
|
|
48
|
-
error = settings.error,
|
|
49
|
-
|
|
50
|
-
eventNamespace = '.' + namespace,
|
|
51
|
-
moduleNamespace = 'module-' + namespace,
|
|
52
|
-
|
|
53
|
-
$module = $(this),
|
|
54
|
-
$label = $(this).children(selector.label),
|
|
55
|
-
$input = $(this).children(selector.input),
|
|
56
|
-
input = $input[0],
|
|
57
|
-
|
|
58
|
-
initialLoad = false,
|
|
59
|
-
shortcutPressed = false,
|
|
60
|
-
instance = $module.data(moduleNamespace),
|
|
61
|
-
|
|
62
|
-
observer,
|
|
63
|
-
element = this,
|
|
64
|
-
module
|
|
65
|
-
;
|
|
66
|
-
|
|
67
|
-
module = {
|
|
68
|
-
|
|
69
|
-
initialize: function() {
|
|
70
|
-
module.verbose('Initializing checkbox', settings);
|
|
71
|
-
|
|
72
|
-
module.create.label();
|
|
73
|
-
module.bind.events();
|
|
74
|
-
|
|
75
|
-
module.set.tabbable();
|
|
76
|
-
module.hide.input();
|
|
77
|
-
|
|
78
|
-
module.observeChanges();
|
|
79
|
-
module.instantiate();
|
|
80
|
-
module.setup();
|
|
81
|
-
},
|
|
82
|
-
|
|
83
|
-
instantiate: function() {
|
|
84
|
-
module.verbose('Storing instance of module', module);
|
|
85
|
-
instance = module;
|
|
86
|
-
$module
|
|
87
|
-
.data(moduleNamespace, module)
|
|
88
|
-
;
|
|
89
|
-
},
|
|
90
|
-
|
|
91
|
-
destroy: function() {
|
|
92
|
-
module.verbose('Destroying module');
|
|
93
|
-
module.unbind.events();
|
|
94
|
-
module.show.input();
|
|
95
|
-
$module.removeData(moduleNamespace);
|
|
96
|
-
},
|
|
97
|
-
|
|
98
|
-
fix: {
|
|
99
|
-
reference: function() {
|
|
100
|
-
if( $module.is(selector.input) ) {
|
|
101
|
-
module.debug('Behavior called on <input> adjusting invoked element');
|
|
102
|
-
$module = $module.closest(selector.checkbox);
|
|
103
|
-
module.refresh();
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
|
-
|
|
108
|
-
setup: function() {
|
|
109
|
-
module.set.initialLoad();
|
|
110
|
-
if( module.is.indeterminate() ) {
|
|
111
|
-
module.debug('Initial value is indeterminate');
|
|
112
|
-
module.indeterminate();
|
|
113
|
-
}
|
|
114
|
-
else if( module.is.checked() ) {
|
|
115
|
-
module.debug('Initial value is checked');
|
|
116
|
-
module.check();
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
module.debug('Initial value is unchecked');
|
|
120
|
-
module.uncheck();
|
|
121
|
-
}
|
|
122
|
-
module.remove.initialLoad();
|
|
123
|
-
},
|
|
124
|
-
|
|
125
|
-
refresh: function() {
|
|
126
|
-
$label = $module.children(selector.label);
|
|
127
|
-
$input = $module.children(selector.input);
|
|
128
|
-
input = $input[0];
|
|
129
|
-
},
|
|
130
|
-
|
|
131
|
-
hide: {
|
|
132
|
-
input: function() {
|
|
133
|
-
module.verbose('Modifying <input> z-index to be unselectable');
|
|
134
|
-
$input.addClass(className.hidden);
|
|
135
|
-
}
|
|
136
|
-
},
|
|
137
|
-
show: {
|
|
138
|
-
input: function() {
|
|
139
|
-
module.verbose('Modifying <input> z-index to be selectable');
|
|
140
|
-
$input.removeClass(className.hidden);
|
|
141
|
-
}
|
|
142
|
-
},
|
|
143
|
-
|
|
144
|
-
observeChanges: function() {
|
|
145
|
-
if('MutationObserver' in window) {
|
|
146
|
-
observer = new MutationObserver(function(mutations) {
|
|
147
|
-
module.debug('DOM tree modified, updating selector cache');
|
|
148
|
-
module.refresh();
|
|
149
|
-
});
|
|
150
|
-
observer.observe(element, {
|
|
151
|
-
childList : true,
|
|
152
|
-
subtree : true
|
|
153
|
-
});
|
|
154
|
-
module.debug('Setting up mutation observer', observer);
|
|
155
|
-
}
|
|
156
|
-
},
|
|
157
|
-
|
|
158
|
-
attachEvents: function(selector, event) {
|
|
159
|
-
var
|
|
160
|
-
$element = $(selector)
|
|
161
|
-
;
|
|
162
|
-
event = $.isFunction(module[event])
|
|
163
|
-
? module[event]
|
|
164
|
-
: module.toggle
|
|
165
|
-
;
|
|
166
|
-
if($element.length > 0) {
|
|
167
|
-
module.debug('Attaching checkbox events to element', selector, event);
|
|
168
|
-
$element
|
|
169
|
-
.on('click' + eventNamespace, event)
|
|
170
|
-
;
|
|
171
|
-
}
|
|
172
|
-
else {
|
|
173
|
-
module.error(error.notFound);
|
|
174
|
-
}
|
|
175
|
-
},
|
|
176
|
-
|
|
177
|
-
preventDefaultOnInputTarget: function() {
|
|
178
|
-
if(typeof event !== 'undefined' && event !== null && $(event.target).is(selector.input)) {
|
|
179
|
-
module.verbose('Preventing default check action after manual check action');
|
|
180
|
-
event.preventDefault();
|
|
181
|
-
}
|
|
182
|
-
},
|
|
183
|
-
|
|
184
|
-
event: {
|
|
185
|
-
change: function(event) {
|
|
186
|
-
if( !module.should.ignoreCallbacks() ) {
|
|
187
|
-
settings.onChange.call(input);
|
|
188
|
-
}
|
|
189
|
-
},
|
|
190
|
-
click: function(event) {
|
|
191
|
-
var
|
|
192
|
-
$target = $(event.target)
|
|
193
|
-
;
|
|
194
|
-
if( $target.is(selector.input) ) {
|
|
195
|
-
module.verbose('Using default check action on initialized checkbox');
|
|
196
|
-
return;
|
|
197
|
-
}
|
|
198
|
-
if( $target.is(selector.link) ) {
|
|
199
|
-
module.debug('Clicking link inside checkbox, skipping toggle');
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
module.toggle();
|
|
203
|
-
$input.focus();
|
|
204
|
-
event.preventDefault();
|
|
205
|
-
},
|
|
206
|
-
keydown: function(event) {
|
|
207
|
-
var
|
|
208
|
-
key = event.which,
|
|
209
|
-
keyCode = {
|
|
210
|
-
enter : 13,
|
|
211
|
-
space : 32,
|
|
212
|
-
escape : 27,
|
|
213
|
-
left : 37,
|
|
214
|
-
up : 38,
|
|
215
|
-
right : 39,
|
|
216
|
-
down : 40
|
|
217
|
-
}
|
|
218
|
-
;
|
|
219
|
-
|
|
220
|
-
var r = module.get.radios(),
|
|
221
|
-
rIndex = r.index($module),
|
|
222
|
-
rLen = r.length,
|
|
223
|
-
checkIndex = false;
|
|
224
|
-
|
|
225
|
-
if(key == keyCode.left || key == keyCode.up) {
|
|
226
|
-
checkIndex = (rIndex === 0 ? rLen : rIndex) - 1;
|
|
227
|
-
} else if(key == keyCode.right || key == keyCode.down) {
|
|
228
|
-
checkIndex = rIndex === rLen-1 ? 0 : rIndex+1;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
if (!module.should.ignoreCallbacks() && checkIndex !== false) {
|
|
232
|
-
if(settings.beforeUnchecked.apply(input)===false) {
|
|
233
|
-
module.verbose('Option not allowed to be unchecked, cancelling key navigation');
|
|
234
|
-
return false;
|
|
235
|
-
}
|
|
236
|
-
if (settings.beforeChecked.apply($(r[checkIndex]).children(selector.input)[0])===false) {
|
|
237
|
-
module.verbose('Next option should not allow check, cancelling key navigation');
|
|
238
|
-
return false;
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
if(key == keyCode.escape) {
|
|
243
|
-
module.verbose('Escape key pressed blurring field');
|
|
244
|
-
$input.blur();
|
|
245
|
-
shortcutPressed = true;
|
|
246
|
-
}
|
|
247
|
-
else if(!event.ctrlKey && ( key == keyCode.space || (key == keyCode.enter && settings.enableEnterKey)) ) {
|
|
248
|
-
module.verbose('Enter/space key pressed, toggling checkbox');
|
|
249
|
-
module.toggle();
|
|
250
|
-
shortcutPressed = true;
|
|
251
|
-
}
|
|
252
|
-
else {
|
|
253
|
-
shortcutPressed = false;
|
|
254
|
-
}
|
|
255
|
-
},
|
|
256
|
-
keyup: function(event) {
|
|
257
|
-
if(shortcutPressed) {
|
|
258
|
-
event.preventDefault();
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
},
|
|
262
|
-
|
|
263
|
-
check: function() {
|
|
264
|
-
if( !module.should.allowCheck() ) {
|
|
265
|
-
return;
|
|
266
|
-
}
|
|
267
|
-
module.debug('Checking checkbox', $input);
|
|
268
|
-
module.set.checked();
|
|
269
|
-
if( !module.should.ignoreCallbacks() ) {
|
|
270
|
-
settings.onChecked.call(input);
|
|
271
|
-
module.trigger.change();
|
|
272
|
-
}
|
|
273
|
-
module.preventDefaultOnInputTarget();
|
|
274
|
-
},
|
|
275
|
-
|
|
276
|
-
uncheck: function() {
|
|
277
|
-
if( !module.should.allowUncheck() ) {
|
|
278
|
-
return;
|
|
279
|
-
}
|
|
280
|
-
module.debug('Unchecking checkbox');
|
|
281
|
-
module.set.unchecked();
|
|
282
|
-
if( !module.should.ignoreCallbacks() ) {
|
|
283
|
-
settings.onUnchecked.call(input);
|
|
284
|
-
module.trigger.change();
|
|
285
|
-
}
|
|
286
|
-
module.preventDefaultOnInputTarget();
|
|
287
|
-
},
|
|
288
|
-
|
|
289
|
-
indeterminate: function() {
|
|
290
|
-
if( module.should.allowIndeterminate() ) {
|
|
291
|
-
module.debug('Checkbox is already indeterminate');
|
|
292
|
-
return;
|
|
293
|
-
}
|
|
294
|
-
module.debug('Making checkbox indeterminate');
|
|
295
|
-
module.set.indeterminate();
|
|
296
|
-
if( !module.should.ignoreCallbacks() ) {
|
|
297
|
-
settings.onIndeterminate.call(input);
|
|
298
|
-
module.trigger.change();
|
|
299
|
-
}
|
|
300
|
-
},
|
|
301
|
-
|
|
302
|
-
determinate: function() {
|
|
303
|
-
if( module.should.allowDeterminate() ) {
|
|
304
|
-
module.debug('Checkbox is already determinate');
|
|
305
|
-
return;
|
|
306
|
-
}
|
|
307
|
-
module.debug('Making checkbox determinate');
|
|
308
|
-
module.set.determinate();
|
|
309
|
-
if( !module.should.ignoreCallbacks() ) {
|
|
310
|
-
settings.onDeterminate.call(input);
|
|
311
|
-
module.trigger.change();
|
|
312
|
-
}
|
|
313
|
-
},
|
|
314
|
-
|
|
315
|
-
enable: function() {
|
|
316
|
-
if( module.is.enabled() ) {
|
|
317
|
-
module.debug('Checkbox is already enabled');
|
|
318
|
-
return;
|
|
319
|
-
}
|
|
320
|
-
module.debug('Enabling checkbox');
|
|
321
|
-
module.set.enabled();
|
|
322
|
-
if( !module.should.ignoreCallbacks() ) {
|
|
323
|
-
settings.onEnable.call(input);
|
|
324
|
-
// preserve legacy callbacks
|
|
325
|
-
settings.onEnabled.call(input);
|
|
326
|
-
module.trigger.change();
|
|
327
|
-
}
|
|
328
|
-
},
|
|
329
|
-
|
|
330
|
-
disable: function() {
|
|
331
|
-
if( module.is.disabled() ) {
|
|
332
|
-
module.debug('Checkbox is already disabled');
|
|
333
|
-
return;
|
|
334
|
-
}
|
|
335
|
-
module.debug('Disabling checkbox');
|
|
336
|
-
module.set.disabled();
|
|
337
|
-
if( !module.should.ignoreCallbacks() ) {
|
|
338
|
-
settings.onDisable.call(input);
|
|
339
|
-
// preserve legacy callbacks
|
|
340
|
-
settings.onDisabled.call(input);
|
|
341
|
-
module.trigger.change();
|
|
342
|
-
}
|
|
343
|
-
},
|
|
344
|
-
|
|
345
|
-
get: {
|
|
346
|
-
radios: function() {
|
|
347
|
-
var
|
|
348
|
-
name = module.get.name()
|
|
349
|
-
;
|
|
350
|
-
return $('input[name="' + name + '"]').closest(selector.checkbox);
|
|
351
|
-
},
|
|
352
|
-
otherRadios: function() {
|
|
353
|
-
return module.get.radios().not($module);
|
|
354
|
-
},
|
|
355
|
-
name: function() {
|
|
356
|
-
return $input.attr('name');
|
|
357
|
-
}
|
|
358
|
-
},
|
|
359
|
-
|
|
360
|
-
is: {
|
|
361
|
-
initialLoad: function() {
|
|
362
|
-
return initialLoad;
|
|
363
|
-
},
|
|
364
|
-
radio: function() {
|
|
365
|
-
return ($input.hasClass(className.radio) || $input.attr('type') == 'radio');
|
|
366
|
-
},
|
|
367
|
-
indeterminate: function() {
|
|
368
|
-
return $input.prop('indeterminate') !== undefined && $input.prop('indeterminate');
|
|
369
|
-
},
|
|
370
|
-
checked: function() {
|
|
371
|
-
return $input.prop('checked') !== undefined && $input.prop('checked');
|
|
372
|
-
},
|
|
373
|
-
disabled: function() {
|
|
374
|
-
return $input.prop('disabled') !== undefined && $input.prop('disabled');
|
|
375
|
-
},
|
|
376
|
-
enabled: function() {
|
|
377
|
-
return !module.is.disabled();
|
|
378
|
-
},
|
|
379
|
-
determinate: function() {
|
|
380
|
-
return !module.is.indeterminate();
|
|
381
|
-
},
|
|
382
|
-
unchecked: function() {
|
|
383
|
-
return !module.is.checked();
|
|
384
|
-
}
|
|
385
|
-
},
|
|
386
|
-
|
|
387
|
-
should: {
|
|
388
|
-
allowCheck: function() {
|
|
389
|
-
if(module.is.determinate() && module.is.checked() && !module.is.initialLoad() ) {
|
|
390
|
-
module.debug('Should not allow check, checkbox is already checked');
|
|
391
|
-
return false;
|
|
392
|
-
}
|
|
393
|
-
if(!module.should.ignoreCallbacks() && settings.beforeChecked.apply(input) === false) {
|
|
394
|
-
module.debug('Should not allow check, beforeChecked cancelled');
|
|
395
|
-
return false;
|
|
396
|
-
}
|
|
397
|
-
return true;
|
|
398
|
-
},
|
|
399
|
-
allowUncheck: function() {
|
|
400
|
-
if(module.is.determinate() && module.is.unchecked() && !module.is.initialLoad() ) {
|
|
401
|
-
module.debug('Should not allow uncheck, checkbox is already unchecked');
|
|
402
|
-
return false;
|
|
403
|
-
}
|
|
404
|
-
if(!module.should.ignoreCallbacks() && settings.beforeUnchecked.apply(input) === false) {
|
|
405
|
-
module.debug('Should not allow uncheck, beforeUnchecked cancelled');
|
|
406
|
-
return false;
|
|
407
|
-
}
|
|
408
|
-
return true;
|
|
409
|
-
},
|
|
410
|
-
allowIndeterminate: function() {
|
|
411
|
-
if(module.is.indeterminate() && !module.is.initialLoad() ) {
|
|
412
|
-
module.debug('Should not allow indeterminate, checkbox is already indeterminate');
|
|
413
|
-
return false;
|
|
414
|
-
}
|
|
415
|
-
if(!module.should.ignoreCallbacks() && settings.beforeIndeterminate.apply(input) === false) {
|
|
416
|
-
module.debug('Should not allow indeterminate, beforeIndeterminate cancelled');
|
|
417
|
-
return false;
|
|
418
|
-
}
|
|
419
|
-
return true;
|
|
420
|
-
},
|
|
421
|
-
allowDeterminate: function() {
|
|
422
|
-
if(module.is.determinate() && !module.is.initialLoad() ) {
|
|
423
|
-
module.debug('Should not allow determinate, checkbox is already determinate');
|
|
424
|
-
return false;
|
|
425
|
-
}
|
|
426
|
-
if(!module.should.ignoreCallbacks() && settings.beforeDeterminate.apply(input) === false) {
|
|
427
|
-
module.debug('Should not allow determinate, beforeDeterminate cancelled');
|
|
428
|
-
return false;
|
|
429
|
-
}
|
|
430
|
-
return true;
|
|
431
|
-
},
|
|
432
|
-
ignoreCallbacks: function() {
|
|
433
|
-
return (initialLoad && !settings.fireOnInit);
|
|
434
|
-
}
|
|
435
|
-
},
|
|
436
|
-
|
|
437
|
-
can: {
|
|
438
|
-
change: function() {
|
|
439
|
-
return !( $module.hasClass(className.disabled) || $module.hasClass(className.readOnly) || $input.prop('disabled') || $input.prop('readonly') );
|
|
440
|
-
},
|
|
441
|
-
uncheck: function() {
|
|
442
|
-
return (typeof settings.uncheckable === 'boolean')
|
|
443
|
-
? settings.uncheckable
|
|
444
|
-
: !module.is.radio()
|
|
445
|
-
;
|
|
446
|
-
}
|
|
447
|
-
},
|
|
448
|
-
|
|
449
|
-
set: {
|
|
450
|
-
initialLoad: function() {
|
|
451
|
-
initialLoad = true;
|
|
452
|
-
},
|
|
453
|
-
checked: function() {
|
|
454
|
-
module.verbose('Setting class to checked');
|
|
455
|
-
$module
|
|
456
|
-
.removeClass(className.indeterminate)
|
|
457
|
-
.addClass(className.checked)
|
|
458
|
-
;
|
|
459
|
-
if( module.is.radio() ) {
|
|
460
|
-
module.uncheckOthers();
|
|
461
|
-
}
|
|
462
|
-
if(!module.is.indeterminate() && module.is.checked()) {
|
|
463
|
-
module.debug('Input is already checked, skipping input property change');
|
|
464
|
-
return;
|
|
465
|
-
}
|
|
466
|
-
module.verbose('Setting state to checked', input);
|
|
467
|
-
$input
|
|
468
|
-
.prop('indeterminate', false)
|
|
469
|
-
.prop('checked', true)
|
|
470
|
-
;
|
|
471
|
-
},
|
|
472
|
-
unchecked: function() {
|
|
473
|
-
module.verbose('Removing checked class');
|
|
474
|
-
$module
|
|
475
|
-
.removeClass(className.indeterminate)
|
|
476
|
-
.removeClass(className.checked)
|
|
477
|
-
;
|
|
478
|
-
if(!module.is.indeterminate() && module.is.unchecked() ) {
|
|
479
|
-
module.debug('Input is already unchecked');
|
|
480
|
-
return;
|
|
481
|
-
}
|
|
482
|
-
module.debug('Setting state to unchecked');
|
|
483
|
-
$input
|
|
484
|
-
.prop('indeterminate', false)
|
|
485
|
-
.prop('checked', false)
|
|
486
|
-
;
|
|
487
|
-
},
|
|
488
|
-
indeterminate: function() {
|
|
489
|
-
module.verbose('Setting class to indeterminate');
|
|
490
|
-
$module
|
|
491
|
-
.addClass(className.indeterminate)
|
|
492
|
-
;
|
|
493
|
-
if( module.is.indeterminate() ) {
|
|
494
|
-
module.debug('Input is already indeterminate, skipping input property change');
|
|
495
|
-
return;
|
|
496
|
-
}
|
|
497
|
-
module.debug('Setting state to indeterminate');
|
|
498
|
-
$input
|
|
499
|
-
.prop('indeterminate', true)
|
|
500
|
-
;
|
|
501
|
-
},
|
|
502
|
-
determinate: function() {
|
|
503
|
-
module.verbose('Removing indeterminate class');
|
|
504
|
-
$module
|
|
505
|
-
.removeClass(className.indeterminate)
|
|
506
|
-
;
|
|
507
|
-
if( module.is.determinate() ) {
|
|
508
|
-
module.debug('Input is already determinate, skipping input property change');
|
|
509
|
-
return;
|
|
510
|
-
}
|
|
511
|
-
module.debug('Setting state to determinate');
|
|
512
|
-
$input
|
|
513
|
-
.prop('indeterminate', false)
|
|
514
|
-
;
|
|
515
|
-
},
|
|
516
|
-
disabled: function() {
|
|
517
|
-
module.verbose('Setting class to disabled');
|
|
518
|
-
$module
|
|
519
|
-
.addClass(className.disabled)
|
|
520
|
-
;
|
|
521
|
-
if( module.is.disabled() ) {
|
|
522
|
-
module.debug('Input is already disabled, skipping input property change');
|
|
523
|
-
return;
|
|
524
|
-
}
|
|
525
|
-
module.debug('Setting state to disabled');
|
|
526
|
-
$input
|
|
527
|
-
.prop('disabled', 'disabled')
|
|
528
|
-
;
|
|
529
|
-
},
|
|
530
|
-
enabled: function() {
|
|
531
|
-
module.verbose('Removing disabled class');
|
|
532
|
-
$module.removeClass(className.disabled);
|
|
533
|
-
if( module.is.enabled() ) {
|
|
534
|
-
module.debug('Input is already enabled, skipping input property change');
|
|
535
|
-
return;
|
|
536
|
-
}
|
|
537
|
-
module.debug('Setting state to enabled');
|
|
538
|
-
$input
|
|
539
|
-
.prop('disabled', false)
|
|
540
|
-
;
|
|
541
|
-
},
|
|
542
|
-
tabbable: function() {
|
|
543
|
-
module.verbose('Adding tabindex to checkbox');
|
|
544
|
-
if( $input.attr('tabindex') === undefined) {
|
|
545
|
-
$input.attr('tabindex', 0);
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
|
-
},
|
|
549
|
-
|
|
550
|
-
remove: {
|
|
551
|
-
initialLoad: function() {
|
|
552
|
-
initialLoad = false;
|
|
553
|
-
}
|
|
554
|
-
},
|
|
555
|
-
|
|
556
|
-
trigger: {
|
|
557
|
-
change: function() {
|
|
36
|
+
$allModules.each(function () {
|
|
558
37
|
var
|
|
559
|
-
|
|
560
|
-
inputElement = $input[0]
|
|
561
|
-
;
|
|
562
|
-
if(inputElement) {
|
|
563
|
-
module.verbose('Triggering native change event');
|
|
564
|
-
events.initEvent('change', true, false);
|
|
565
|
-
inputElement.dispatchEvent(events);
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
},
|
|
38
|
+
settings = $.extend(true, {}, $.fn.checkbox.settings, parameters),
|
|
569
39
|
|
|
40
|
+
className = settings.className,
|
|
41
|
+
namespace = settings.namespace,
|
|
42
|
+
selector = settings.selector,
|
|
43
|
+
error = settings.error,
|
|
570
44
|
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
if($input.prevAll(selector.label).length > 0) {
|
|
574
|
-
$input.prev(selector.label).detach().insertAfter($input);
|
|
575
|
-
module.debug('Moving existing label', $label);
|
|
576
|
-
}
|
|
577
|
-
else if( !module.has.label() ) {
|
|
578
|
-
$label = $('<label>').insertAfter($input);
|
|
579
|
-
module.debug('Creating label', $label);
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
},
|
|
45
|
+
eventNamespace = '.' + namespace,
|
|
46
|
+
moduleNamespace = 'module-' + namespace,
|
|
583
47
|
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
},
|
|
48
|
+
$module = $(this),
|
|
49
|
+
$label = $(this).children(selector.label),
|
|
50
|
+
$input = $(this).children(selector.input),
|
|
51
|
+
input = $input[0],
|
|
589
52
|
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
$module
|
|
594
|
-
.on('click' + eventNamespace, module.event.click)
|
|
595
|
-
.on('change' + eventNamespace, module.event.change)
|
|
596
|
-
.on('keydown' + eventNamespace, selector.input, module.event.keydown)
|
|
597
|
-
.on('keyup' + eventNamespace, selector.input, module.event.keyup)
|
|
598
|
-
;
|
|
599
|
-
}
|
|
600
|
-
},
|
|
53
|
+
initialLoad = false,
|
|
54
|
+
shortcutPressed = false,
|
|
55
|
+
instance = $module.data(moduleNamespace),
|
|
601
56
|
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
$module
|
|
606
|
-
.off(eventNamespace)
|
|
57
|
+
observer,
|
|
58
|
+
element = this,
|
|
59
|
+
module
|
|
607
60
|
;
|
|
608
|
-
}
|
|
609
|
-
},
|
|
610
|
-
|
|
611
|
-
uncheckOthers: function() {
|
|
612
|
-
var
|
|
613
|
-
$radios = module.get.otherRadios()
|
|
614
|
-
;
|
|
615
|
-
module.debug('Unchecking other radios', $radios);
|
|
616
|
-
$radios.removeClass(className.checked);
|
|
617
|
-
},
|
|
618
61
|
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
}
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
}
|
|
62
|
+
module = {
|
|
63
|
+
|
|
64
|
+
initialize: function () {
|
|
65
|
+
module.verbose('Initializing checkbox', settings);
|
|
66
|
+
|
|
67
|
+
module.create.label();
|
|
68
|
+
module.bind.events();
|
|
69
|
+
|
|
70
|
+
module.set.tabbable();
|
|
71
|
+
module.hide.input();
|
|
72
|
+
|
|
73
|
+
module.observeChanges();
|
|
74
|
+
module.instantiate();
|
|
75
|
+
module.setup();
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
instantiate: function () {
|
|
79
|
+
module.verbose('Storing instance of module', module);
|
|
80
|
+
instance = module;
|
|
81
|
+
$module
|
|
82
|
+
.data(moduleNamespace, module)
|
|
83
|
+
;
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
destroy: function () {
|
|
87
|
+
module.verbose('Destroying module');
|
|
88
|
+
module.unbind.events();
|
|
89
|
+
module.show.input();
|
|
90
|
+
$module.removeData(moduleNamespace);
|
|
91
|
+
},
|
|
92
|
+
|
|
93
|
+
fix: {
|
|
94
|
+
reference: function () {
|
|
95
|
+
if ($module.is(selector.input)) {
|
|
96
|
+
module.debug('Behavior called on <input> adjusting invoked element');
|
|
97
|
+
$module = $module.closest(selector.checkbox);
|
|
98
|
+
module.refresh();
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
setup: function () {
|
|
104
|
+
module.set.initialLoad();
|
|
105
|
+
if (module.is.indeterminate()) {
|
|
106
|
+
module.debug('Initial value is indeterminate');
|
|
107
|
+
module.indeterminate();
|
|
108
|
+
} else if (module.is.checked()) {
|
|
109
|
+
module.debug('Initial value is checked');
|
|
110
|
+
module.check();
|
|
111
|
+
} else {
|
|
112
|
+
module.debug('Initial value is unchecked');
|
|
113
|
+
module.uncheck();
|
|
114
|
+
}
|
|
115
|
+
module.remove.initialLoad();
|
|
116
|
+
},
|
|
117
|
+
|
|
118
|
+
refresh: function () {
|
|
119
|
+
$label = $module.children(selector.label);
|
|
120
|
+
$input = $module.children(selector.input);
|
|
121
|
+
input = $input[0];
|
|
122
|
+
},
|
|
123
|
+
|
|
124
|
+
hide: {
|
|
125
|
+
input: function () {
|
|
126
|
+
module.verbose('Modifying <input> z-index to be unselectable');
|
|
127
|
+
$input.addClass(className.hidden);
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
show: {
|
|
131
|
+
input: function () {
|
|
132
|
+
module.verbose('Modifying <input> z-index to be selectable');
|
|
133
|
+
$input.removeClass(className.hidden);
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
|
|
137
|
+
observeChanges: function () {
|
|
138
|
+
if ('MutationObserver' in window) {
|
|
139
|
+
observer = new MutationObserver(function (mutations) {
|
|
140
|
+
module.debug('DOM tree modified, updating selector cache');
|
|
141
|
+
module.refresh();
|
|
142
|
+
});
|
|
143
|
+
observer.observe(element, {
|
|
144
|
+
childList: true,
|
|
145
|
+
subtree: true,
|
|
146
|
+
});
|
|
147
|
+
module.debug('Setting up mutation observer', observer);
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
|
|
151
|
+
attachEvents: function (selector, event) {
|
|
152
|
+
var
|
|
153
|
+
$element = $(selector)
|
|
154
|
+
;
|
|
155
|
+
event = isFunction(module[event])
|
|
156
|
+
? module[event]
|
|
157
|
+
: module.toggle;
|
|
158
|
+
if ($element.length > 0) {
|
|
159
|
+
module.debug('Attaching checkbox events to element', selector, event);
|
|
160
|
+
$element
|
|
161
|
+
.on('click' + eventNamespace, event)
|
|
162
|
+
;
|
|
163
|
+
} else {
|
|
164
|
+
module.error(error.notFound);
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
|
|
168
|
+
preventDefaultOnInputTarget: function () {
|
|
169
|
+
if (event !== undefined && event !== null && $(event.target).is(selector.input)) {
|
|
170
|
+
module.verbose('Preventing default check action after manual check action');
|
|
171
|
+
event.preventDefault();
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
|
|
175
|
+
event: {
|
|
176
|
+
change: function (event) {
|
|
177
|
+
if (!module.should.ignoreCallbacks()) {
|
|
178
|
+
settings.onChange.call(input);
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
click: function (event) {
|
|
182
|
+
var
|
|
183
|
+
$target = $(event.target)
|
|
184
|
+
;
|
|
185
|
+
if ($target.is(selector.input)) {
|
|
186
|
+
module.verbose('Using default check action on initialized checkbox');
|
|
187
|
+
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
if ($target.is(selector.link)) {
|
|
191
|
+
module.debug('Clicking link inside checkbox, skipping toggle');
|
|
192
|
+
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
module.toggle();
|
|
196
|
+
$input.trigger('focus');
|
|
197
|
+
event.preventDefault();
|
|
198
|
+
},
|
|
199
|
+
keydown: function (event) {
|
|
200
|
+
var
|
|
201
|
+
key = event.which,
|
|
202
|
+
keyCode = {
|
|
203
|
+
enter: 13,
|
|
204
|
+
space: 32,
|
|
205
|
+
escape: 27,
|
|
206
|
+
left: 37,
|
|
207
|
+
up: 38,
|
|
208
|
+
right: 39,
|
|
209
|
+
down: 40,
|
|
210
|
+
}
|
|
211
|
+
;
|
|
212
|
+
|
|
213
|
+
var
|
|
214
|
+
r = module.get.radios(),
|
|
215
|
+
rIndex = r.index($module),
|
|
216
|
+
rLen = r.length,
|
|
217
|
+
checkIndex = false
|
|
218
|
+
;
|
|
219
|
+
|
|
220
|
+
if (key === keyCode.left || key === keyCode.up) {
|
|
221
|
+
checkIndex = (rIndex === 0 ? rLen : rIndex) - 1;
|
|
222
|
+
} else if (key === keyCode.right || key === keyCode.down) {
|
|
223
|
+
checkIndex = rIndex === rLen - 1 ? 0 : rIndex + 1;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
if (!module.should.ignoreCallbacks() && checkIndex !== false) {
|
|
227
|
+
if (settings.beforeUnchecked.apply(input) === false) {
|
|
228
|
+
module.verbose('Option not allowed to be unchecked, cancelling key navigation');
|
|
229
|
+
|
|
230
|
+
return false;
|
|
231
|
+
}
|
|
232
|
+
if (settings.beforeChecked.apply($(r[checkIndex]).children(selector.input)[0]) === false) {
|
|
233
|
+
module.verbose('Next option should not allow check, cancelling key navigation');
|
|
234
|
+
|
|
235
|
+
return false;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
shortcutPressed = false;
|
|
240
|
+
if (key === keyCode.escape) {
|
|
241
|
+
module.verbose('Escape key pressed blurring field');
|
|
242
|
+
$input.trigger('blur');
|
|
243
|
+
shortcutPressed = true;
|
|
244
|
+
event.stopPropagation();
|
|
245
|
+
} else if (!event.ctrlKey && module.can.change()) {
|
|
246
|
+
if (key === keyCode.space || (key === keyCode.enter && settings.enableEnterKey)) {
|
|
247
|
+
module.verbose('Enter/space key pressed, toggling checkbox');
|
|
248
|
+
module.toggle();
|
|
249
|
+
shortcutPressed = true;
|
|
250
|
+
} else if ($module.is('.toggle, .slider') && !module.is.radio()) {
|
|
251
|
+
if (key === keyCode.left && module.is.checked()) {
|
|
252
|
+
module.uncheck();
|
|
253
|
+
shortcutPressed = true;
|
|
254
|
+
} else if (key === keyCode.right && module.is.unchecked()) {
|
|
255
|
+
module.check();
|
|
256
|
+
shortcutPressed = true;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
keyup: function (event) {
|
|
262
|
+
if (shortcutPressed) {
|
|
263
|
+
event.preventDefault();
|
|
264
|
+
}
|
|
265
|
+
},
|
|
266
|
+
},
|
|
267
|
+
|
|
268
|
+
check: function () {
|
|
269
|
+
if (!module.should.allowCheck()) {
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
module.debug('Checking checkbox', $input);
|
|
273
|
+
module.set.checked();
|
|
274
|
+
if (!module.should.ignoreCallbacks()) {
|
|
275
|
+
settings.onChecked.call(input);
|
|
276
|
+
module.trigger.change();
|
|
277
|
+
}
|
|
278
|
+
module.preventDefaultOnInputTarget();
|
|
279
|
+
},
|
|
280
|
+
|
|
281
|
+
uncheck: function () {
|
|
282
|
+
if (!module.should.allowUncheck()) {
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
module.debug('Unchecking checkbox');
|
|
286
|
+
module.set.unchecked();
|
|
287
|
+
if (!module.should.ignoreCallbacks()) {
|
|
288
|
+
settings.onUnchecked.call(input);
|
|
289
|
+
module.trigger.change();
|
|
290
|
+
}
|
|
291
|
+
module.preventDefaultOnInputTarget();
|
|
292
|
+
},
|
|
293
|
+
|
|
294
|
+
indeterminate: function () {
|
|
295
|
+
if (module.should.allowIndeterminate()) {
|
|
296
|
+
module.debug('Checkbox is already indeterminate');
|
|
297
|
+
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
module.debug('Making checkbox indeterminate');
|
|
301
|
+
module.set.indeterminate();
|
|
302
|
+
if (!module.should.ignoreCallbacks()) {
|
|
303
|
+
settings.onIndeterminate.call(input);
|
|
304
|
+
module.trigger.change();
|
|
305
|
+
}
|
|
306
|
+
},
|
|
307
|
+
|
|
308
|
+
determinate: function () {
|
|
309
|
+
if (module.should.allowDeterminate()) {
|
|
310
|
+
module.debug('Checkbox is already determinate');
|
|
311
|
+
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
module.debug('Making checkbox determinate');
|
|
315
|
+
module.set.determinate();
|
|
316
|
+
if (!module.should.ignoreCallbacks()) {
|
|
317
|
+
settings.onDeterminate.call(input);
|
|
318
|
+
module.trigger.change();
|
|
319
|
+
}
|
|
320
|
+
},
|
|
321
|
+
|
|
322
|
+
enable: function () {
|
|
323
|
+
if (module.is.enabled()) {
|
|
324
|
+
module.debug('Checkbox is already enabled');
|
|
325
|
+
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
module.debug('Enabling checkbox');
|
|
329
|
+
module.set.enabled();
|
|
330
|
+
if (!module.should.ignoreCallbacks()) {
|
|
331
|
+
settings.onEnable.call(input);
|
|
332
|
+
// preserve legacy callbacks
|
|
333
|
+
settings.onEnabled.call(input);
|
|
334
|
+
}
|
|
335
|
+
},
|
|
336
|
+
|
|
337
|
+
disable: function () {
|
|
338
|
+
if (module.is.disabled()) {
|
|
339
|
+
module.debug('Checkbox is already disabled');
|
|
340
|
+
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
module.debug('Disabling checkbox');
|
|
344
|
+
module.set.disabled();
|
|
345
|
+
if (!module.should.ignoreCallbacks()) {
|
|
346
|
+
settings.onDisable.call(input);
|
|
347
|
+
// preserve legacy callbacks
|
|
348
|
+
settings.onDisabled.call(input);
|
|
349
|
+
}
|
|
350
|
+
},
|
|
351
|
+
|
|
352
|
+
get: {
|
|
353
|
+
radios: function () {
|
|
354
|
+
var
|
|
355
|
+
name = module.get.name()
|
|
356
|
+
;
|
|
357
|
+
|
|
358
|
+
return $('input[name="' + name + '"]').closest(selector.checkbox);
|
|
359
|
+
},
|
|
360
|
+
otherRadios: function () {
|
|
361
|
+
return module.get.radios().not($module);
|
|
362
|
+
},
|
|
363
|
+
name: function () {
|
|
364
|
+
return $input.attr('name');
|
|
365
|
+
},
|
|
366
|
+
},
|
|
367
|
+
|
|
368
|
+
is: {
|
|
369
|
+
initialLoad: function () {
|
|
370
|
+
return initialLoad;
|
|
371
|
+
},
|
|
372
|
+
radio: function () {
|
|
373
|
+
return $input.hasClass(className.radio) || $input.attr('type') === 'radio';
|
|
374
|
+
},
|
|
375
|
+
indeterminate: function () {
|
|
376
|
+
return $input.prop('indeterminate') !== undefined && $input.prop('indeterminate');
|
|
377
|
+
},
|
|
378
|
+
checked: function () {
|
|
379
|
+
return $input.prop('checked') !== undefined && $input.prop('checked');
|
|
380
|
+
},
|
|
381
|
+
disabled: function () {
|
|
382
|
+
return $input.prop('disabled') !== undefined && $input.prop('disabled');
|
|
383
|
+
},
|
|
384
|
+
enabled: function () {
|
|
385
|
+
return !module.is.disabled();
|
|
386
|
+
},
|
|
387
|
+
determinate: function () {
|
|
388
|
+
return !module.is.indeterminate();
|
|
389
|
+
},
|
|
390
|
+
unchecked: function () {
|
|
391
|
+
return !module.is.checked();
|
|
392
|
+
},
|
|
393
|
+
},
|
|
394
|
+
|
|
395
|
+
should: {
|
|
396
|
+
allowCheck: function () {
|
|
397
|
+
if (module.is.determinate() && module.is.checked() && !module.is.initialLoad()) {
|
|
398
|
+
module.debug('Should not allow check, checkbox is already checked');
|
|
399
|
+
|
|
400
|
+
return false;
|
|
401
|
+
}
|
|
402
|
+
if (!module.should.ignoreCallbacks() && settings.beforeChecked.apply(input) === false) {
|
|
403
|
+
module.debug('Should not allow check, beforeChecked cancelled');
|
|
404
|
+
|
|
405
|
+
return false;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
return true;
|
|
409
|
+
},
|
|
410
|
+
allowUncheck: function () {
|
|
411
|
+
if (module.is.determinate() && module.is.unchecked() && !module.is.initialLoad()) {
|
|
412
|
+
module.debug('Should not allow uncheck, checkbox is already unchecked');
|
|
413
|
+
|
|
414
|
+
return false;
|
|
415
|
+
}
|
|
416
|
+
if (!module.should.ignoreCallbacks() && settings.beforeUnchecked.apply(input) === false) {
|
|
417
|
+
module.debug('Should not allow uncheck, beforeUnchecked cancelled');
|
|
418
|
+
|
|
419
|
+
return false;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
return true;
|
|
423
|
+
},
|
|
424
|
+
allowIndeterminate: function () {
|
|
425
|
+
if (module.is.indeterminate() && !module.is.initialLoad()) {
|
|
426
|
+
module.debug('Should not allow indeterminate, checkbox is already indeterminate');
|
|
427
|
+
|
|
428
|
+
return false;
|
|
429
|
+
}
|
|
430
|
+
if (!module.should.ignoreCallbacks() && settings.beforeIndeterminate.apply(input) === false) {
|
|
431
|
+
module.debug('Should not allow indeterminate, beforeIndeterminate cancelled');
|
|
432
|
+
|
|
433
|
+
return false;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
return true;
|
|
437
|
+
},
|
|
438
|
+
allowDeterminate: function () {
|
|
439
|
+
if (module.is.determinate() && !module.is.initialLoad()) {
|
|
440
|
+
module.debug('Should not allow determinate, checkbox is already determinate');
|
|
441
|
+
|
|
442
|
+
return false;
|
|
443
|
+
}
|
|
444
|
+
if (!module.should.ignoreCallbacks() && settings.beforeDeterminate.apply(input) === false) {
|
|
445
|
+
module.debug('Should not allow determinate, beforeDeterminate cancelled');
|
|
446
|
+
|
|
447
|
+
return false;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
return true;
|
|
451
|
+
},
|
|
452
|
+
ignoreCallbacks: function () {
|
|
453
|
+
return initialLoad && !settings.fireOnInit;
|
|
454
|
+
},
|
|
455
|
+
},
|
|
456
|
+
|
|
457
|
+
can: {
|
|
458
|
+
change: function () {
|
|
459
|
+
return !($module.hasClass(className.disabled) || $module.hasClass(className.readOnly) || $input.prop('disabled') || $input.prop('readonly'));
|
|
460
|
+
},
|
|
461
|
+
uncheck: function () {
|
|
462
|
+
return typeof settings.uncheckable === 'boolean'
|
|
463
|
+
? settings.uncheckable
|
|
464
|
+
: !module.is.radio();
|
|
465
|
+
},
|
|
466
|
+
},
|
|
467
|
+
|
|
468
|
+
set: {
|
|
469
|
+
initialLoad: function () {
|
|
470
|
+
initialLoad = true;
|
|
471
|
+
},
|
|
472
|
+
checked: function () {
|
|
473
|
+
module.verbose('Setting class to checked');
|
|
474
|
+
$module
|
|
475
|
+
.removeClass(className.indeterminate)
|
|
476
|
+
.addClass(className.checked)
|
|
477
|
+
;
|
|
478
|
+
if (module.is.radio()) {
|
|
479
|
+
module.uncheckOthers();
|
|
480
|
+
}
|
|
481
|
+
if (!module.is.indeterminate() && module.is.checked()) {
|
|
482
|
+
module.debug('Input is already checked, skipping input property change');
|
|
483
|
+
|
|
484
|
+
return;
|
|
485
|
+
}
|
|
486
|
+
module.verbose('Setting state to checked', input);
|
|
487
|
+
$input
|
|
488
|
+
.prop('indeterminate', false)
|
|
489
|
+
.prop('checked', true)
|
|
490
|
+
;
|
|
491
|
+
},
|
|
492
|
+
unchecked: function () {
|
|
493
|
+
module.verbose('Removing checked class');
|
|
494
|
+
$module
|
|
495
|
+
.removeClass(className.indeterminate)
|
|
496
|
+
.removeClass(className.checked)
|
|
497
|
+
;
|
|
498
|
+
if (!module.is.indeterminate() && module.is.unchecked()) {
|
|
499
|
+
module.debug('Input is already unchecked');
|
|
500
|
+
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
503
|
+
module.debug('Setting state to unchecked');
|
|
504
|
+
$input
|
|
505
|
+
.prop('indeterminate', false)
|
|
506
|
+
.prop('checked', false)
|
|
507
|
+
;
|
|
508
|
+
},
|
|
509
|
+
indeterminate: function () {
|
|
510
|
+
module.verbose('Setting class to indeterminate');
|
|
511
|
+
$module
|
|
512
|
+
.addClass(className.indeterminate)
|
|
513
|
+
;
|
|
514
|
+
if (module.is.indeterminate()) {
|
|
515
|
+
module.debug('Input is already indeterminate, skipping input property change');
|
|
516
|
+
|
|
517
|
+
return;
|
|
518
|
+
}
|
|
519
|
+
module.debug('Setting state to indeterminate');
|
|
520
|
+
$input
|
|
521
|
+
.prop('indeterminate', true)
|
|
522
|
+
;
|
|
523
|
+
},
|
|
524
|
+
determinate: function () {
|
|
525
|
+
module.verbose('Removing indeterminate class');
|
|
526
|
+
$module
|
|
527
|
+
.removeClass(className.indeterminate)
|
|
528
|
+
;
|
|
529
|
+
if (module.is.determinate()) {
|
|
530
|
+
module.debug('Input is already determinate, skipping input property change');
|
|
531
|
+
|
|
532
|
+
return;
|
|
533
|
+
}
|
|
534
|
+
module.debug('Setting state to determinate');
|
|
535
|
+
$input
|
|
536
|
+
.prop('indeterminate', false)
|
|
537
|
+
;
|
|
538
|
+
},
|
|
539
|
+
disabled: function () {
|
|
540
|
+
module.verbose('Setting class to disabled');
|
|
541
|
+
$module
|
|
542
|
+
.addClass(className.disabled)
|
|
543
|
+
;
|
|
544
|
+
if (module.is.disabled()) {
|
|
545
|
+
module.debug('Input is already disabled, skipping input property change');
|
|
546
|
+
|
|
547
|
+
return;
|
|
548
|
+
}
|
|
549
|
+
module.debug('Setting state to disabled');
|
|
550
|
+
$input
|
|
551
|
+
.prop('disabled', 'disabled')
|
|
552
|
+
;
|
|
553
|
+
},
|
|
554
|
+
enabled: function () {
|
|
555
|
+
module.verbose('Removing disabled class');
|
|
556
|
+
$module.removeClass(className.disabled);
|
|
557
|
+
if (module.is.enabled()) {
|
|
558
|
+
module.debug('Input is already enabled, skipping input property change');
|
|
559
|
+
|
|
560
|
+
return;
|
|
561
|
+
}
|
|
562
|
+
module.debug('Setting state to enabled');
|
|
563
|
+
$input
|
|
564
|
+
.prop('disabled', false)
|
|
565
|
+
;
|
|
566
|
+
},
|
|
567
|
+
tabbable: function () {
|
|
568
|
+
module.verbose('Adding tabindex to checkbox');
|
|
569
|
+
if ($input.attr('tabindex') === undefined) {
|
|
570
|
+
$input.attr('tabindex', 0);
|
|
571
|
+
}
|
|
572
|
+
},
|
|
573
|
+
},
|
|
574
|
+
|
|
575
|
+
remove: {
|
|
576
|
+
initialLoad: function () {
|
|
577
|
+
initialLoad = false;
|
|
578
|
+
},
|
|
579
|
+
},
|
|
580
|
+
|
|
581
|
+
trigger: {
|
|
582
|
+
change: function () {
|
|
583
|
+
var
|
|
584
|
+
inputElement = $input[0]
|
|
585
|
+
;
|
|
586
|
+
if (inputElement) {
|
|
587
|
+
var events = document.createEvent('HTMLEvents');
|
|
588
|
+
module.verbose('Triggering native change event');
|
|
589
|
+
events.initEvent('change', true, false);
|
|
590
|
+
inputElement.dispatchEvent(events);
|
|
591
|
+
}
|
|
592
|
+
},
|
|
593
|
+
},
|
|
594
|
+
|
|
595
|
+
create: {
|
|
596
|
+
label: function () {
|
|
597
|
+
if ($input.prevAll(selector.label).length > 0) {
|
|
598
|
+
$input.prev(selector.label).detach().insertAfter($input);
|
|
599
|
+
module.debug('Moving existing label', $label);
|
|
600
|
+
} else if (!module.has.label()) {
|
|
601
|
+
$label = $('<label>').insertAfter($input);
|
|
602
|
+
module.debug('Creating label', $label);
|
|
603
|
+
}
|
|
604
|
+
},
|
|
605
|
+
},
|
|
606
|
+
|
|
607
|
+
has: {
|
|
608
|
+
label: function () {
|
|
609
|
+
return $label.length > 0;
|
|
610
|
+
},
|
|
611
|
+
},
|
|
612
|
+
|
|
613
|
+
bind: {
|
|
614
|
+
events: function () {
|
|
615
|
+
module.verbose('Attaching checkbox events');
|
|
616
|
+
$module
|
|
617
|
+
.on('click' + eventNamespace, module.event.click)
|
|
618
|
+
.on('change' + eventNamespace, module.event.change)
|
|
619
|
+
.on('keydown' + eventNamespace, selector.input, module.event.keydown)
|
|
620
|
+
.on('keyup' + eventNamespace, selector.input, module.event.keyup)
|
|
621
|
+
;
|
|
622
|
+
},
|
|
623
|
+
},
|
|
624
|
+
|
|
625
|
+
unbind: {
|
|
626
|
+
events: function () {
|
|
627
|
+
module.debug('Removing events');
|
|
628
|
+
$module
|
|
629
|
+
.off(eventNamespace)
|
|
630
|
+
;
|
|
631
|
+
},
|
|
632
|
+
},
|
|
633
|
+
|
|
634
|
+
uncheckOthers: function () {
|
|
635
|
+
var
|
|
636
|
+
$radios = module.get.otherRadios()
|
|
637
|
+
;
|
|
638
|
+
module.debug('Unchecking other radios', $radios);
|
|
639
|
+
$radios.removeClass(className.checked);
|
|
640
|
+
},
|
|
641
|
+
|
|
642
|
+
toggle: function () {
|
|
643
|
+
if (!module.can.change()) {
|
|
644
|
+
if (!module.is.radio()) {
|
|
645
|
+
module.debug('Checkbox is read-only or disabled, ignoring toggle');
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
return;
|
|
649
|
+
}
|
|
650
|
+
if (module.is.indeterminate() || module.is.unchecked()) {
|
|
651
|
+
module.debug('Currently unchecked');
|
|
652
|
+
module.check();
|
|
653
|
+
} else if (module.is.checked() && module.can.uncheck()) {
|
|
654
|
+
module.debug('Currently checked');
|
|
655
|
+
module.uncheck();
|
|
656
|
+
}
|
|
657
|
+
},
|
|
658
|
+
setting: function (name, value) {
|
|
659
|
+
module.debug('Changing setting', name, value);
|
|
660
|
+
if ($.isPlainObject(name)) {
|
|
661
|
+
$.extend(true, settings, name);
|
|
662
|
+
} else if (value !== undefined) {
|
|
663
|
+
if ($.isPlainObject(settings[name])) {
|
|
664
|
+
$.extend(true, settings[name], value);
|
|
665
|
+
} else {
|
|
666
|
+
settings[name] = value;
|
|
667
|
+
}
|
|
668
|
+
} else {
|
|
669
|
+
return settings[name];
|
|
670
|
+
}
|
|
671
|
+
},
|
|
672
|
+
internal: function (name, value) {
|
|
673
|
+
if ($.isPlainObject(name)) {
|
|
674
|
+
$.extend(true, module, name);
|
|
675
|
+
} else if (value !== undefined) {
|
|
676
|
+
module[name] = value;
|
|
677
|
+
} else {
|
|
678
|
+
return module[name];
|
|
679
|
+
}
|
|
680
|
+
},
|
|
681
|
+
debug: function () {
|
|
682
|
+
if (!settings.silent && settings.debug) {
|
|
683
|
+
if (settings.performance) {
|
|
684
|
+
module.performance.log(arguments);
|
|
685
|
+
} else {
|
|
686
|
+
module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
|
|
687
|
+
module.debug.apply(console, arguments);
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
},
|
|
691
|
+
verbose: function () {
|
|
692
|
+
if (!settings.silent && settings.verbose && settings.debug) {
|
|
693
|
+
if (settings.performance) {
|
|
694
|
+
module.performance.log(arguments);
|
|
695
|
+
} else {
|
|
696
|
+
module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
|
|
697
|
+
module.verbose.apply(console, arguments);
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
},
|
|
701
|
+
error: function () {
|
|
702
|
+
if (!settings.silent) {
|
|
703
|
+
module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
|
|
704
|
+
module.error.apply(console, arguments);
|
|
705
|
+
}
|
|
706
|
+
},
|
|
707
|
+
performance: {
|
|
708
|
+
log: function (message) {
|
|
709
|
+
var
|
|
710
|
+
currentTime,
|
|
711
|
+
executionTime,
|
|
712
|
+
previousTime
|
|
713
|
+
;
|
|
714
|
+
if (settings.performance) {
|
|
715
|
+
currentTime = Date.now();
|
|
716
|
+
previousTime = time || currentTime;
|
|
717
|
+
executionTime = currentTime - previousTime;
|
|
718
|
+
time = currentTime;
|
|
719
|
+
performance.push({
|
|
720
|
+
Name: message[0],
|
|
721
|
+
Arguments: [].slice.call(message, 1) || '',
|
|
722
|
+
Element: element,
|
|
723
|
+
'Execution Time': executionTime,
|
|
724
|
+
});
|
|
725
|
+
}
|
|
726
|
+
clearTimeout(module.performance.timer);
|
|
727
|
+
module.performance.timer = setTimeout(module.performance.display, 500);
|
|
728
|
+
},
|
|
729
|
+
display: function () {
|
|
730
|
+
var
|
|
731
|
+
title = settings.name + ':',
|
|
732
|
+
totalTime = 0
|
|
733
|
+
;
|
|
734
|
+
time = false;
|
|
735
|
+
clearTimeout(module.performance.timer);
|
|
736
|
+
$.each(performance, function (index, data) {
|
|
737
|
+
totalTime += data['Execution Time'];
|
|
738
|
+
});
|
|
739
|
+
title += ' ' + totalTime + 'ms';
|
|
740
|
+
if (moduleSelector) {
|
|
741
|
+
title += ' \'' + moduleSelector + '\'';
|
|
742
|
+
}
|
|
743
|
+
if (performance.length > 0) {
|
|
744
|
+
console.groupCollapsed(title);
|
|
745
|
+
if (console.table) {
|
|
746
|
+
console.table(performance);
|
|
747
|
+
} else {
|
|
748
|
+
$.each(performance, function (index, data) {
|
|
749
|
+
console.log(data.Name + ': ' + data['Execution Time'] + 'ms');
|
|
750
|
+
});
|
|
751
|
+
}
|
|
752
|
+
console.groupEnd();
|
|
753
|
+
}
|
|
754
|
+
performance = [];
|
|
755
|
+
},
|
|
756
|
+
},
|
|
757
|
+
invoke: function (query, passedArguments, context) {
|
|
758
|
+
var
|
|
759
|
+
object = instance,
|
|
760
|
+
maxDepth,
|
|
761
|
+
found,
|
|
762
|
+
response
|
|
763
|
+
;
|
|
764
|
+
passedArguments = passedArguments || queryArguments;
|
|
765
|
+
context = context || element;
|
|
766
|
+
if (typeof query === 'string' && object !== undefined) {
|
|
767
|
+
query = query.split(/[ .]/);
|
|
768
|
+
maxDepth = query.length - 1;
|
|
769
|
+
$.each(query, function (depth, value) {
|
|
770
|
+
var camelCaseValue = depth !== maxDepth
|
|
771
|
+
? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
|
|
772
|
+
: query
|
|
773
|
+
;
|
|
774
|
+
if ($.isPlainObject(object[camelCaseValue]) && (depth !== maxDepth)) {
|
|
775
|
+
object = object[camelCaseValue];
|
|
776
|
+
} else if (object[camelCaseValue] !== undefined) {
|
|
777
|
+
found = object[camelCaseValue];
|
|
778
|
+
|
|
779
|
+
return false;
|
|
780
|
+
} else if ($.isPlainObject(object[value]) && (depth !== maxDepth)) {
|
|
781
|
+
object = object[value];
|
|
782
|
+
} else if (object[value] !== undefined) {
|
|
783
|
+
found = object[value];
|
|
784
|
+
|
|
785
|
+
return false;
|
|
786
|
+
} else {
|
|
787
|
+
module.error(error.method, query);
|
|
788
|
+
|
|
789
|
+
return false;
|
|
790
|
+
}
|
|
791
|
+
});
|
|
792
|
+
}
|
|
793
|
+
if (isFunction(found)) {
|
|
794
|
+
response = found.apply(context, passedArguments);
|
|
795
|
+
} else if (found !== undefined) {
|
|
796
|
+
response = found;
|
|
797
|
+
}
|
|
798
|
+
if (Array.isArray(returnedValue)) {
|
|
799
|
+
returnedValue.push(response);
|
|
800
|
+
} else if (returnedValue !== undefined) {
|
|
801
|
+
returnedValue = [returnedValue, response];
|
|
802
|
+
} else if (response !== undefined) {
|
|
803
|
+
returnedValue = response;
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
return found;
|
|
807
|
+
},
|
|
808
|
+
};
|
|
809
|
+
|
|
810
|
+
if (methodInvoked) {
|
|
811
|
+
if (instance === undefined) {
|
|
812
|
+
module.initialize();
|
|
813
|
+
}
|
|
814
|
+
module.invoke(query);
|
|
815
|
+
} else {
|
|
816
|
+
if (instance !== undefined) {
|
|
817
|
+
instance.invoke('destroy');
|
|
818
|
+
}
|
|
819
|
+
module.initialize();
|
|
820
|
+
}
|
|
821
|
+
});
|
|
822
|
+
|
|
823
|
+
return returnedValue !== undefined
|
|
824
|
+
? returnedValue
|
|
825
|
+
: this;
|
|
826
|
+
};
|
|
827
|
+
|
|
828
|
+
$.fn.checkbox.settings = {
|
|
829
|
+
|
|
830
|
+
name: 'Checkbox',
|
|
831
|
+
namespace: 'checkbox',
|
|
832
|
+
|
|
833
|
+
silent: false,
|
|
834
|
+
debug: false,
|
|
835
|
+
verbose: false,
|
|
836
|
+
performance: true,
|
|
837
|
+
|
|
838
|
+
// delegated event context
|
|
839
|
+
uncheckable: 'auto',
|
|
840
|
+
fireOnInit: false,
|
|
841
|
+
enableEnterKey: true,
|
|
842
|
+
|
|
843
|
+
onChange: function () {},
|
|
844
|
+
|
|
845
|
+
beforeChecked: function () {},
|
|
846
|
+
beforeUnchecked: function () {},
|
|
847
|
+
beforeDeterminate: function () {},
|
|
848
|
+
beforeIndeterminate: function () {},
|
|
849
|
+
|
|
850
|
+
onChecked: function () {},
|
|
851
|
+
onUnchecked: function () {},
|
|
852
|
+
|
|
853
|
+
onDeterminate: function () {},
|
|
854
|
+
onIndeterminate: function () {},
|
|
855
|
+
|
|
856
|
+
onEnable: function () {},
|
|
857
|
+
onDisable: function () {},
|
|
858
|
+
|
|
859
|
+
// preserve misspelled callbacks (will be removed in 3.0)
|
|
860
|
+
onEnabled: function () {},
|
|
861
|
+
onDisabled: function () {},
|
|
862
|
+
|
|
863
|
+
className: {
|
|
864
|
+
checked: 'checked',
|
|
865
|
+
indeterminate: 'indeterminate',
|
|
866
|
+
disabled: 'disabled',
|
|
867
|
+
hidden: 'hidden',
|
|
868
|
+
radio: 'radio',
|
|
869
|
+
readOnly: 'read-only',
|
|
870
|
+
},
|
|
871
|
+
|
|
872
|
+
error: {
|
|
873
|
+
method: 'The method you called is not defined',
|
|
874
|
+
},
|
|
875
|
+
|
|
876
|
+
selector: {
|
|
877
|
+
checkbox: '.ui.checkbox',
|
|
878
|
+
label: 'label',
|
|
879
|
+
input: 'input[type="checkbox"], input[type="radio"]',
|
|
880
|
+
link: 'a[href]',
|
|
881
|
+
},
|
|
882
|
+
|
|
883
|
+
};
|
|
884
|
+
})(jQuery, window, document);
|