fomantic-ui-sass 2.6.4

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