rails-active-ui 0.3.0 → 0.3.2

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 (197) hide show
  1. checksums.yaml +4 -4
  2. data/app/javascript/ui/controllers/turbo_modal_controller.js +36 -0
  3. data/config/importmap.rb +1 -0
  4. data/formantic-ui/components/accordion.css +369 -0
  5. data/formantic-ui/components/accordion.js +595 -0
  6. data/formantic-ui/components/accordion.min.css +9 -0
  7. data/formantic-ui/components/accordion.min.js +11 -0
  8. data/formantic-ui/components/ad.css +264 -0
  9. data/formantic-ui/components/ad.min.css +10 -0
  10. data/formantic-ui/components/api.js +1225 -0
  11. data/formantic-ui/components/api.min.js +11 -0
  12. data/formantic-ui/components/breadcrumb.css +135 -0
  13. data/formantic-ui/components/breadcrumb.min.css +9 -0
  14. data/formantic-ui/components/button.css +4058 -0
  15. data/formantic-ui/components/button.min.css +9 -0
  16. data/formantic-ui/components/calendar.css +327 -0
  17. data/formantic-ui/components/calendar.js +2045 -0
  18. data/formantic-ui/components/calendar.min.css +9 -0
  19. data/formantic-ui/components/calendar.min.js +11 -0
  20. data/formantic-ui/components/card.css +1881 -0
  21. data/formantic-ui/components/card.min.css +9 -0
  22. data/formantic-ui/components/checkbox.css +785 -0
  23. data/formantic-ui/components/checkbox.js +888 -0
  24. data/formantic-ui/components/checkbox.min.css +9 -0
  25. data/formantic-ui/components/checkbox.min.js +11 -0
  26. data/formantic-ui/components/comment.css +283 -0
  27. data/formantic-ui/components/comment.min.css +9 -0
  28. data/formantic-ui/components/container.css +300 -0
  29. data/formantic-ui/components/container.min.css +9 -0
  30. data/formantic-ui/components/dimmer.css +367 -0
  31. data/formantic-ui/components/dimmer.js +732 -0
  32. data/formantic-ui/components/dimmer.min.css +9 -0
  33. data/formantic-ui/components/dimmer.min.js +11 -0
  34. data/formantic-ui/components/divider.css +287 -0
  35. data/formantic-ui/components/divider.min.css +9 -0
  36. data/formantic-ui/components/dropdown.css +2087 -0
  37. data/formantic-ui/components/dropdown.js +4432 -0
  38. data/formantic-ui/components/dropdown.min.css +9 -0
  39. data/formantic-ui/components/dropdown.min.js +11 -0
  40. data/formantic-ui/components/embed.css +155 -0
  41. data/formantic-ui/components/embed.js +688 -0
  42. data/formantic-ui/components/embed.min.css +9 -0
  43. data/formantic-ui/components/embed.min.js +11 -0
  44. data/formantic-ui/components/emoji.css +15311 -0
  45. data/formantic-ui/components/emoji.min.css +9 -0
  46. data/formantic-ui/components/feed.css +799 -0
  47. data/formantic-ui/components/feed.min.css +9 -0
  48. data/formantic-ui/components/flag.css +1149 -0
  49. data/formantic-ui/components/flag.min.css +9 -0
  50. data/formantic-ui/components/flyout.css +546 -0
  51. data/formantic-ui/components/flyout.js +1551 -0
  52. data/formantic-ui/components/flyout.min.css +9 -0
  53. data/formantic-ui/components/flyout.min.js +11 -0
  54. data/formantic-ui/components/form.css +1885 -0
  55. data/formantic-ui/components/form.js +2199 -0
  56. data/formantic-ui/components/form.min.css +9 -0
  57. data/formantic-ui/components/form.min.js +11 -0
  58. data/formantic-ui/components/grid.css +1952 -0
  59. data/formantic-ui/components/grid.min.css +9 -0
  60. data/formantic-ui/components/header.css +778 -0
  61. data/formantic-ui/components/header.min.css +9 -0
  62. data/formantic-ui/components/icon.css +7066 -0
  63. data/formantic-ui/components/icon.min.css +9 -0
  64. data/formantic-ui/components/image.css +315 -0
  65. data/formantic-ui/components/image.min.css +9 -0
  66. data/formantic-ui/components/input.css +1566 -0
  67. data/formantic-ui/components/input.min.css +9 -0
  68. data/formantic-ui/components/item.css +534 -0
  69. data/formantic-ui/components/item.min.css +9 -0
  70. data/formantic-ui/components/label.css +2114 -0
  71. data/formantic-ui/components/label.min.css +9 -0
  72. data/formantic-ui/components/list.css +955 -0
  73. data/formantic-ui/components/list.min.css +9 -0
  74. data/formantic-ui/components/loader.css +787 -0
  75. data/formantic-ui/components/loader.min.css +9 -0
  76. data/formantic-ui/components/menu.css +2131 -0
  77. data/formantic-ui/components/menu.min.css +9 -0
  78. data/formantic-ui/components/message.css +619 -0
  79. data/formantic-ui/components/message.min.css +9 -0
  80. data/formantic-ui/components/modal.css +779 -0
  81. data/formantic-ui/components/modal.js +1637 -0
  82. data/formantic-ui/components/modal.min.css +9 -0
  83. data/formantic-ui/components/modal.min.js +11 -0
  84. data/formantic-ui/components/nag.css +290 -0
  85. data/formantic-ui/components/nag.js +566 -0
  86. data/formantic-ui/components/nag.min.css +9 -0
  87. data/formantic-ui/components/nag.min.js +11 -0
  88. data/formantic-ui/components/placeholder.css +228 -0
  89. data/formantic-ui/components/placeholder.min.css +9 -0
  90. data/formantic-ui/components/popup.css +1184 -0
  91. data/formantic-ui/components/popup.js +1561 -0
  92. data/formantic-ui/components/popup.min.css +9 -0
  93. data/formantic-ui/components/popup.min.js +11 -0
  94. data/formantic-ui/components/progress.css +761 -0
  95. data/formantic-ui/components/progress.js +979 -0
  96. data/formantic-ui/components/progress.min.css +9 -0
  97. data/formantic-ui/components/progress.min.js +11 -0
  98. data/formantic-ui/components/rail.css +147 -0
  99. data/formantic-ui/components/rail.min.css +9 -0
  100. data/formantic-ui/components/rating.css +414 -0
  101. data/formantic-ui/components/rating.js +540 -0
  102. data/formantic-ui/components/rating.min.css +9 -0
  103. data/formantic-ui/components/rating.min.js +11 -0
  104. data/formantic-ui/components/reset.css +386 -0
  105. data/formantic-ui/components/reset.min.css +9 -0
  106. data/formantic-ui/components/reveal.css +277 -0
  107. data/formantic-ui/components/reveal.min.css +9 -0
  108. data/formantic-ui/components/search.css +541 -0
  109. data/formantic-ui/components/search.js +1641 -0
  110. data/formantic-ui/components/search.min.css +9 -0
  111. data/formantic-ui/components/search.min.js +11 -0
  112. data/formantic-ui/components/segment.css +1053 -0
  113. data/formantic-ui/components/segment.min.css +9 -0
  114. data/formantic-ui/components/shape.css +144 -0
  115. data/formantic-ui/components/shape.js +797 -0
  116. data/formantic-ui/components/shape.min.css +9 -0
  117. data/formantic-ui/components/shape.min.js +11 -0
  118. data/formantic-ui/components/sidebar.css +539 -0
  119. data/formantic-ui/components/sidebar.js +1054 -0
  120. data/formantic-ui/components/sidebar.min.css +9 -0
  121. data/formantic-ui/components/sidebar.min.js +11 -0
  122. data/formantic-ui/components/site.css +286 -0
  123. data/formantic-ui/components/site.js +455 -0
  124. data/formantic-ui/components/site.min.css +9 -0
  125. data/formantic-ui/components/site.min.js +11 -0
  126. data/formantic-ui/components/slider.css +926 -0
  127. data/formantic-ui/components/slider.js +1546 -0
  128. data/formantic-ui/components/slider.min.css +9 -0
  129. data/formantic-ui/components/slider.min.js +11 -0
  130. data/formantic-ui/components/state.js +697 -0
  131. data/formantic-ui/components/state.min.js +11 -0
  132. data/formantic-ui/components/statistic.css +586 -0
  133. data/formantic-ui/components/statistic.min.css +9 -0
  134. data/formantic-ui/components/step.css +1538 -0
  135. data/formantic-ui/components/step.min.css +9 -0
  136. data/formantic-ui/components/sticky.css +73 -0
  137. data/formantic-ui/components/sticky.js +917 -0
  138. data/formantic-ui/components/sticky.min.css +9 -0
  139. data/formantic-ui/components/sticky.min.js +11 -0
  140. data/formantic-ui/components/tab.css +84 -0
  141. data/formantic-ui/components/tab.js +967 -0
  142. data/formantic-ui/components/tab.min.css +9 -0
  143. data/formantic-ui/components/tab.min.js +11 -0
  144. data/formantic-ui/components/table.css +3473 -0
  145. data/formantic-ui/components/table.min.css +9 -0
  146. data/formantic-ui/components/text.css +155 -0
  147. data/formantic-ui/components/text.min.css +9 -0
  148. data/formantic-ui/components/toast.css +751 -0
  149. data/formantic-ui/components/toast.js +964 -0
  150. data/formantic-ui/components/toast.min.css +9 -0
  151. data/formantic-ui/components/toast.min.js +11 -0
  152. data/formantic-ui/components/transition.css +1148 -0
  153. data/formantic-ui/components/transition.js +1034 -0
  154. data/formantic-ui/components/transition.min.css +9 -0
  155. data/formantic-ui/components/transition.min.js +11 -0
  156. data/formantic-ui/components/visibility.js +1292 -0
  157. data/formantic-ui/components/visibility.min.js +11 -0
  158. data/formantic-ui/semantic.css +78485 -0
  159. data/formantic-ui/semantic.js +31036 -0
  160. data/formantic-ui/semantic.min.css +11 -0
  161. data/formantic-ui/semantic.min.js +11 -0
  162. data/formantic-ui/themes/basic/assets/fonts/LICENSE.txt +91 -0
  163. data/formantic-ui/themes/basic/assets/fonts/icons.woff +0 -0
  164. data/formantic-ui/themes/basic/assets/fonts/icons.woff2 +0 -0
  165. data/formantic-ui/themes/default/assets/fonts/LICENSE_Lato.txt +94 -0
  166. data/formantic-ui/themes/default/assets/fonts/LICENSE_icons.txt +165 -0
  167. data/formantic-ui/themes/default/assets/fonts/Lato-Bold.woff +0 -0
  168. data/formantic-ui/themes/default/assets/fonts/Lato-Bold.woff2 +0 -0
  169. data/formantic-ui/themes/default/assets/fonts/Lato-BoldItalic.woff +0 -0
  170. data/formantic-ui/themes/default/assets/fonts/Lato-BoldItalic.woff2 +0 -0
  171. data/formantic-ui/themes/default/assets/fonts/Lato-Italic.woff +0 -0
  172. data/formantic-ui/themes/default/assets/fonts/Lato-Italic.woff2 +0 -0
  173. data/formantic-ui/themes/default/assets/fonts/Lato-Regular.woff +0 -0
  174. data/formantic-ui/themes/default/assets/fonts/Lato-Regular.woff2 +0 -0
  175. data/formantic-ui/themes/default/assets/fonts/LatoLatin-Bold.woff +0 -0
  176. data/formantic-ui/themes/default/assets/fonts/LatoLatin-Bold.woff2 +0 -0
  177. data/formantic-ui/themes/default/assets/fonts/LatoLatin-BoldItalic.woff +0 -0
  178. data/formantic-ui/themes/default/assets/fonts/LatoLatin-BoldItalic.woff2 +0 -0
  179. data/formantic-ui/themes/default/assets/fonts/LatoLatin-Italic.woff +0 -0
  180. data/formantic-ui/themes/default/assets/fonts/LatoLatin-Italic.woff2 +0 -0
  181. data/formantic-ui/themes/default/assets/fonts/LatoLatin-Regular.woff +0 -0
  182. data/formantic-ui/themes/default/assets/fonts/LatoLatin-Regular.woff2 +0 -0
  183. data/formantic-ui/themes/default/assets/fonts/brand-icons.woff +0 -0
  184. data/formantic-ui/themes/default/assets/fonts/brand-icons.woff2 +0 -0
  185. data/formantic-ui/themes/default/assets/fonts/icons.woff +0 -0
  186. data/formantic-ui/themes/default/assets/fonts/icons.woff2 +0 -0
  187. data/formantic-ui/themes/default/assets/fonts/outline-icons.woff +0 -0
  188. data/formantic-ui/themes/default/assets/fonts/outline-icons.woff2 +0 -0
  189. data/formantic-ui/themes/famfamfam/assets/images/flags.png +0 -0
  190. data/formantic-ui/themes/github/assets/fonts/LICENSE.txt +94 -0
  191. data/formantic-ui/themes/github/assets/fonts/octicons.woff +0 -0
  192. data/formantic-ui/themes/github/assets/fonts/octicons.woff2 +0 -0
  193. data/formantic-ui/themes/material/assets/fonts/LICENSE.txt +202 -0
  194. data/formantic-ui/themes/material/assets/fonts/icons.woff +0 -0
  195. data/formantic-ui/themes/material/assets/fonts/icons.woff2 +0 -0
  196. data/lib/ui/version.rb +1 -1
  197. metadata +194 -1
@@ -0,0 +1,888 @@
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);