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,708 @@
1
+ /*!
2
+ * # Semantic UI - State
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.state = function(parameters) {
23
+ var
24
+ $allModules = $(this),
25
+
26
+ moduleSelector = $allModules.selector || '',
27
+
28
+ hasTouch = ('ontouchstart' in document.documentElement),
29
+ time = new Date().getTime(),
30
+ performance = [],
31
+
32
+ query = arguments[0],
33
+ methodInvoked = (typeof query == 'string'),
34
+ queryArguments = [].slice.call(arguments, 1),
35
+
36
+ returnedValue
37
+ ;
38
+ $allModules
39
+ .each(function() {
40
+ var
41
+ settings = ( $.isPlainObject(parameters) )
42
+ ? $.extend(true, {}, $.fn.state.settings, parameters)
43
+ : $.extend({}, $.fn.state.settings),
44
+
45
+ error = settings.error,
46
+ metadata = settings.metadata,
47
+ className = settings.className,
48
+ namespace = settings.namespace,
49
+ states = settings.states,
50
+ text = settings.text,
51
+
52
+ eventNamespace = '.' + namespace,
53
+ moduleNamespace = namespace + '-module',
54
+
55
+ $module = $(this),
56
+
57
+ element = this,
58
+ instance = $module.data(moduleNamespace),
59
+
60
+ module
61
+ ;
62
+ module = {
63
+
64
+ initialize: function() {
65
+ module.verbose('Initializing module');
66
+
67
+ // allow module to guess desired state based on element
68
+ if(settings.automatic) {
69
+ module.add.defaults();
70
+ }
71
+
72
+ // bind events with delegated events
73
+ if(settings.context && moduleSelector !== '') {
74
+ $(settings.context)
75
+ .on(moduleSelector, 'mouseenter' + eventNamespace, module.change.text)
76
+ .on(moduleSelector, 'mouseleave' + eventNamespace, module.reset.text)
77
+ .on(moduleSelector, 'click' + eventNamespace, module.toggle.state)
78
+ ;
79
+ }
80
+ else {
81
+ $module
82
+ .on('mouseenter' + eventNamespace, module.change.text)
83
+ .on('mouseleave' + eventNamespace, module.reset.text)
84
+ .on('click' + eventNamespace, module.toggle.state)
85
+ ;
86
+ }
87
+ module.instantiate();
88
+ },
89
+
90
+ instantiate: function() {
91
+ module.verbose('Storing instance of module', module);
92
+ instance = module;
93
+ $module
94
+ .data(moduleNamespace, module)
95
+ ;
96
+ },
97
+
98
+ destroy: function() {
99
+ module.verbose('Destroying previous module', instance);
100
+ $module
101
+ .off(eventNamespace)
102
+ .removeData(moduleNamespace)
103
+ ;
104
+ },
105
+
106
+ refresh: function() {
107
+ module.verbose('Refreshing selector cache');
108
+ $module = $(element);
109
+ },
110
+
111
+ add: {
112
+ defaults: function() {
113
+ var
114
+ userStates = parameters && $.isPlainObject(parameters.states)
115
+ ? parameters.states
116
+ : {}
117
+ ;
118
+ $.each(settings.defaults, function(type, typeStates) {
119
+ if( module.is[type] !== undefined && module.is[type]() ) {
120
+ module.verbose('Adding default states', type, element);
121
+ $.extend(settings.states, typeStates, userStates);
122
+ }
123
+ });
124
+ }
125
+ },
126
+
127
+ is: {
128
+
129
+ active: function() {
130
+ return $module.hasClass(className.active);
131
+ },
132
+ loading: function() {
133
+ return $module.hasClass(className.loading);
134
+ },
135
+ inactive: function() {
136
+ return !( $module.hasClass(className.active) );
137
+ },
138
+ state: function(state) {
139
+ if(className[state] === undefined) {
140
+ return false;
141
+ }
142
+ return $module.hasClass( className[state] );
143
+ },
144
+
145
+ enabled: function() {
146
+ return !( $module.is(settings.filter.active) );
147
+ },
148
+ disabled: function() {
149
+ return ( $module.is(settings.filter.active) );
150
+ },
151
+ textEnabled: function() {
152
+ return !( $module.is(settings.filter.text) );
153
+ },
154
+
155
+ // definitions for automatic type detection
156
+ button: function() {
157
+ return $module.is('.button:not(a, .submit)');
158
+ },
159
+ input: function() {
160
+ return $module.is('input');
161
+ },
162
+ progress: function() {
163
+ return $module.is('.ui.progress');
164
+ }
165
+ },
166
+
167
+ allow: function(state) {
168
+ module.debug('Now allowing state', state);
169
+ states[state] = true;
170
+ },
171
+ disallow: function(state) {
172
+ module.debug('No longer allowing', state);
173
+ states[state] = false;
174
+ },
175
+
176
+ allows: function(state) {
177
+ return states[state] || false;
178
+ },
179
+
180
+ enable: function() {
181
+ $module.removeClass(className.disabled);
182
+ },
183
+
184
+ disable: function() {
185
+ $module.addClass(className.disabled);
186
+ },
187
+
188
+ setState: function(state) {
189
+ if(module.allows(state)) {
190
+ $module.addClass( className[state] );
191
+ }
192
+ },
193
+
194
+ removeState: function(state) {
195
+ if(module.allows(state)) {
196
+ $module.removeClass( className[state] );
197
+ }
198
+ },
199
+
200
+ toggle: {
201
+ state: function() {
202
+ var
203
+ apiRequest,
204
+ requestCancelled
205
+ ;
206
+ if( module.allows('active') && module.is.enabled() ) {
207
+ module.refresh();
208
+ if($.fn.api !== undefined) {
209
+ apiRequest = $module.api('get request');
210
+ requestCancelled = $module.api('was cancelled');
211
+ if( requestCancelled ) {
212
+ module.debug('API Request cancelled by beforesend');
213
+ settings.activateTest = function(){ return false; };
214
+ settings.deactivateTest = function(){ return false; };
215
+ }
216
+ else if(apiRequest) {
217
+ module.listenTo(apiRequest);
218
+ return;
219
+ }
220
+ }
221
+ module.change.state();
222
+ }
223
+ }
224
+ },
225
+
226
+ listenTo: function(apiRequest) {
227
+ module.debug('API request detected, waiting for state signal', apiRequest);
228
+ if(apiRequest) {
229
+ if(text.loading) {
230
+ module.update.text(text.loading);
231
+ }
232
+ $.when(apiRequest)
233
+ .then(function() {
234
+ if(apiRequest.state() == 'resolved') {
235
+ module.debug('API request succeeded');
236
+ settings.activateTest = function(){ return true; };
237
+ settings.deactivateTest = function(){ return true; };
238
+ }
239
+ else {
240
+ module.debug('API request failed');
241
+ settings.activateTest = function(){ return false; };
242
+ settings.deactivateTest = function(){ return false; };
243
+ }
244
+ module.change.state();
245
+ })
246
+ ;
247
+ }
248
+ },
249
+
250
+ // checks whether active/inactive state can be given
251
+ change: {
252
+
253
+ state: function() {
254
+ module.debug('Determining state change direction');
255
+ // inactive to active change
256
+ if( module.is.inactive() ) {
257
+ module.activate();
258
+ }
259
+ else {
260
+ module.deactivate();
261
+ }
262
+ if(settings.sync) {
263
+ module.sync();
264
+ }
265
+ settings.onChange.call(element);
266
+ },
267
+
268
+ text: function() {
269
+ if( module.is.textEnabled() ) {
270
+ if(module.is.disabled() ) {
271
+ module.verbose('Changing text to disabled text', text.hover);
272
+ module.update.text(text.disabled);
273
+ }
274
+ else if( module.is.active() ) {
275
+ if(text.hover) {
276
+ module.verbose('Changing text to hover text', text.hover);
277
+ module.update.text(text.hover);
278
+ }
279
+ else if(text.deactivate) {
280
+ module.verbose('Changing text to deactivating text', text.deactivate);
281
+ module.update.text(text.deactivate);
282
+ }
283
+ }
284
+ else {
285
+ if(text.hover) {
286
+ module.verbose('Changing text to hover text', text.hover);
287
+ module.update.text(text.hover);
288
+ }
289
+ else if(text.activate){
290
+ module.verbose('Changing text to activating text', text.activate);
291
+ module.update.text(text.activate);
292
+ }
293
+ }
294
+ }
295
+ }
296
+
297
+ },
298
+
299
+ activate: function() {
300
+ if( settings.activateTest.call(element) ) {
301
+ module.debug('Setting state to active');
302
+ $module
303
+ .addClass(className.active)
304
+ ;
305
+ module.update.text(text.active);
306
+ settings.onActivate.call(element);
307
+ }
308
+ },
309
+
310
+ deactivate: function() {
311
+ if( settings.deactivateTest.call(element) ) {
312
+ module.debug('Setting state to inactive');
313
+ $module
314
+ .removeClass(className.active)
315
+ ;
316
+ module.update.text(text.inactive);
317
+ settings.onDeactivate.call(element);
318
+ }
319
+ },
320
+
321
+ sync: function() {
322
+ module.verbose('Syncing other buttons to current state');
323
+ if( module.is.active() ) {
324
+ $allModules
325
+ .not($module)
326
+ .state('activate');
327
+ }
328
+ else {
329
+ $allModules
330
+ .not($module)
331
+ .state('deactivate')
332
+ ;
333
+ }
334
+ },
335
+
336
+ get: {
337
+ text: function() {
338
+ return (settings.selector.text)
339
+ ? $module.find(settings.selector.text).text()
340
+ : $module.html()
341
+ ;
342
+ },
343
+ textFor: function(state) {
344
+ return text[state] || false;
345
+ }
346
+ },
347
+
348
+ flash: {
349
+ text: function(text, duration, callback) {
350
+ var
351
+ previousText = module.get.text()
352
+ ;
353
+ module.debug('Flashing text message', text, duration);
354
+ text = text || settings.text.flash;
355
+ duration = duration || settings.flashDuration;
356
+ callback = callback || function() {};
357
+ module.update.text(text);
358
+ setTimeout(function(){
359
+ module.update.text(previousText);
360
+ callback.call(element);
361
+ }, duration);
362
+ }
363
+ },
364
+
365
+ reset: {
366
+ // on mouseout sets text to previous value
367
+ text: function() {
368
+ var
369
+ activeText = text.active || $module.data(metadata.storedText),
370
+ inactiveText = text.inactive || $module.data(metadata.storedText)
371
+ ;
372
+ if( module.is.textEnabled() ) {
373
+ if( module.is.active() && activeText) {
374
+ module.verbose('Resetting active text', activeText);
375
+ module.update.text(activeText);
376
+ }
377
+ else if(inactiveText) {
378
+ module.verbose('Resetting inactive text', activeText);
379
+ module.update.text(inactiveText);
380
+ }
381
+ }
382
+ }
383
+ },
384
+
385
+ update: {
386
+ text: function(text) {
387
+ var
388
+ currentText = module.get.text()
389
+ ;
390
+ if(text && text !== currentText) {
391
+ module.debug('Updating text', text);
392
+ if(settings.selector.text) {
393
+ $module
394
+ .data(metadata.storedText, text)
395
+ .find(settings.selector.text)
396
+ .text(text)
397
+ ;
398
+ }
399
+ else {
400
+ $module
401
+ .data(metadata.storedText, text)
402
+ .html(text)
403
+ ;
404
+ }
405
+ }
406
+ else {
407
+ module.debug('Text is already set, ignoring update', text);
408
+ }
409
+ }
410
+ },
411
+
412
+ setting: function(name, value) {
413
+ module.debug('Changing setting', name, value);
414
+ if( $.isPlainObject(name) ) {
415
+ $.extend(true, settings, name);
416
+ }
417
+ else if(value !== undefined) {
418
+ if($.isPlainObject(settings[name])) {
419
+ $.extend(true, settings[name], value);
420
+ }
421
+ else {
422
+ settings[name] = value;
423
+ }
424
+ }
425
+ else {
426
+ return settings[name];
427
+ }
428
+ },
429
+ internal: function(name, value) {
430
+ if( $.isPlainObject(name) ) {
431
+ $.extend(true, module, name);
432
+ }
433
+ else if(value !== undefined) {
434
+ module[name] = value;
435
+ }
436
+ else {
437
+ return module[name];
438
+ }
439
+ },
440
+ debug: function() {
441
+ if(!settings.silent && settings.debug) {
442
+ if(settings.performance) {
443
+ module.performance.log(arguments);
444
+ }
445
+ else {
446
+ module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
447
+ module.debug.apply(console, arguments);
448
+ }
449
+ }
450
+ },
451
+ verbose: function() {
452
+ if(!settings.silent && settings.verbose && settings.debug) {
453
+ if(settings.performance) {
454
+ module.performance.log(arguments);
455
+ }
456
+ else {
457
+ module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
458
+ module.verbose.apply(console, arguments);
459
+ }
460
+ }
461
+ },
462
+ error: function() {
463
+ if(!settings.silent) {
464
+ module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
465
+ module.error.apply(console, arguments);
466
+ }
467
+ },
468
+ performance: {
469
+ log: function(message) {
470
+ var
471
+ currentTime,
472
+ executionTime,
473
+ previousTime
474
+ ;
475
+ if(settings.performance) {
476
+ currentTime = new Date().getTime();
477
+ previousTime = time || currentTime;
478
+ executionTime = currentTime - previousTime;
479
+ time = currentTime;
480
+ performance.push({
481
+ 'Name' : message[0],
482
+ 'Arguments' : [].slice.call(message, 1) || '',
483
+ 'Element' : element,
484
+ 'Execution Time' : executionTime
485
+ });
486
+ }
487
+ clearTimeout(module.performance.timer);
488
+ module.performance.timer = setTimeout(module.performance.display, 500);
489
+ },
490
+ display: function() {
491
+ var
492
+ title = settings.name + ':',
493
+ totalTime = 0
494
+ ;
495
+ time = false;
496
+ clearTimeout(module.performance.timer);
497
+ $.each(performance, function(index, data) {
498
+ totalTime += data['Execution Time'];
499
+ });
500
+ title += ' ' + totalTime + 'ms';
501
+ if(moduleSelector) {
502
+ title += ' \'' + moduleSelector + '\'';
503
+ }
504
+ if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) {
505
+ console.groupCollapsed(title);
506
+ if(console.table) {
507
+ console.table(performance);
508
+ }
509
+ else {
510
+ $.each(performance, function(index, data) {
511
+ console.log(data['Name'] + ': ' + data['Execution Time']+'ms');
512
+ });
513
+ }
514
+ console.groupEnd();
515
+ }
516
+ performance = [];
517
+ }
518
+ },
519
+ invoke: function(query, passedArguments, context) {
520
+ var
521
+ object = instance,
522
+ maxDepth,
523
+ found,
524
+ response
525
+ ;
526
+ passedArguments = passedArguments || queryArguments;
527
+ context = element || context;
528
+ if(typeof query == 'string' && object !== undefined) {
529
+ query = query.split(/[\. ]/);
530
+ maxDepth = query.length - 1;
531
+ $.each(query, function(depth, value) {
532
+ var camelCaseValue = (depth != maxDepth)
533
+ ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
534
+ : query
535
+ ;
536
+ if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) {
537
+ object = object[camelCaseValue];
538
+ }
539
+ else if( object[camelCaseValue] !== undefined ) {
540
+ found = object[camelCaseValue];
541
+ return false;
542
+ }
543
+ else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) {
544
+ object = object[value];
545
+ }
546
+ else if( object[value] !== undefined ) {
547
+ found = object[value];
548
+ return false;
549
+ }
550
+ else {
551
+ module.error(error.method, query);
552
+ return false;
553
+ }
554
+ });
555
+ }
556
+ if ( $.isFunction( found ) ) {
557
+ response = found.apply(context, passedArguments);
558
+ }
559
+ else if(found !== undefined) {
560
+ response = found;
561
+ }
562
+ if($.isArray(returnedValue)) {
563
+ returnedValue.push(response);
564
+ }
565
+ else if(returnedValue !== undefined) {
566
+ returnedValue = [returnedValue, response];
567
+ }
568
+ else if(response !== undefined) {
569
+ returnedValue = response;
570
+ }
571
+ return found;
572
+ }
573
+ };
574
+
575
+ if(methodInvoked) {
576
+ if(instance === undefined) {
577
+ module.initialize();
578
+ }
579
+ module.invoke(query);
580
+ }
581
+ else {
582
+ if(instance !== undefined) {
583
+ instance.invoke('destroy');
584
+ }
585
+ module.initialize();
586
+ }
587
+ })
588
+ ;
589
+
590
+ return (returnedValue !== undefined)
591
+ ? returnedValue
592
+ : this
593
+ ;
594
+ };
595
+
596
+ $.fn.state.settings = {
597
+
598
+ // module info
599
+ name : 'State',
600
+
601
+ // debug output
602
+ debug : false,
603
+
604
+ // verbose debug output
605
+ verbose : false,
606
+
607
+ // namespace for events
608
+ namespace : 'state',
609
+
610
+ // debug data includes performance
611
+ performance : true,
612
+
613
+ // callback occurs on state change
614
+ onActivate : function() {},
615
+ onDeactivate : function() {},
616
+ onChange : function() {},
617
+
618
+ // state test functions
619
+ activateTest : function() { return true; },
620
+ deactivateTest : function() { return true; },
621
+
622
+ // whether to automatically map default states
623
+ automatic : true,
624
+
625
+ // activate / deactivate changes all elements instantiated at same time
626
+ sync : false,
627
+
628
+ // default flash text duration, used for temporarily changing text of an element
629
+ flashDuration : 1000,
630
+
631
+ // selector filter
632
+ filter : {
633
+ text : '.loading, .disabled',
634
+ active : '.disabled'
635
+ },
636
+
637
+ context : false,
638
+
639
+ // error
640
+ error: {
641
+ beforeSend : 'The before send function has cancelled state change',
642
+ method : 'The method you called is not defined.'
643
+ },
644
+
645
+ // metadata
646
+ metadata: {
647
+ promise : 'promise',
648
+ storedText : 'stored-text'
649
+ },
650
+
651
+ // change class on state
652
+ className: {
653
+ active : 'active',
654
+ disabled : 'disabled',
655
+ error : 'error',
656
+ loading : 'loading',
657
+ success : 'success',
658
+ warning : 'warning'
659
+ },
660
+
661
+ selector: {
662
+ // selector for text node
663
+ text: false
664
+ },
665
+
666
+ defaults : {
667
+ input: {
668
+ disabled : true,
669
+ loading : true,
670
+ active : true
671
+ },
672
+ button: {
673
+ disabled : true,
674
+ loading : true,
675
+ active : true,
676
+ },
677
+ progress: {
678
+ active : true,
679
+ success : true,
680
+ warning : true,
681
+ error : true
682
+ }
683
+ },
684
+
685
+ states : {
686
+ active : true,
687
+ disabled : true,
688
+ error : true,
689
+ loading : true,
690
+ success : true,
691
+ warning : true
692
+ },
693
+
694
+ text : {
695
+ disabled : false,
696
+ flash : false,
697
+ hover : false,
698
+ active : false,
699
+ inactive : false,
700
+ activate : false,
701
+ deactivate : false
702
+ }
703
+
704
+ };
705
+
706
+
707
+
708
+ })( jQuery, window, document );