@northdata/fomantic-ui 2.8.722 → 2.9.401

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