fomantic-ui-sass 2.9.0 → 2.9.1

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