semantic-ui-rails 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +26 -0
  6. data/Rakefile +1 -0
  7. data/lib/generators/semantic/install/install_generator.rb +38 -0
  8. data/lib/generators/semantic/install/templates/semantic-ui.js +21 -0
  9. data/lib/generators/semantic/install/templates/semantic-ui/collections.less +6 -0
  10. data/lib/generators/semantic/install/templates/semantic-ui/elements.less +11 -0
  11. data/lib/generators/semantic/install/templates/semantic-ui/modules.less +18 -0
  12. data/lib/generators/semantic/install/templates/semantic-ui/views.less +6 -0
  13. data/lib/semantic/ui/rails.rb +10 -0
  14. data/lib/semantic/ui/rails/engine.rb +8 -0
  15. data/lib/semantic/ui/rails/version.rb +7 -0
  16. data/semantic-ui-rails.gemspec +23 -0
  17. data/vendor/assets/fonts/icons.eot +0 -0
  18. data/vendor/assets/fonts/icons.svg +450 -0
  19. data/vendor/assets/fonts/icons.ttf +0 -0
  20. data/vendor/assets/fonts/icons.woff +0 -0
  21. data/vendor/assets/images/semantic-ui/loader-large-inverted.gif +0 -0
  22. data/vendor/assets/images/semantic-ui/loader-large.gif +0 -0
  23. data/vendor/assets/images/semantic-ui/loader-medium-inverted.gif +0 -0
  24. data/vendor/assets/images/semantic-ui/loader-medium.gif +0 -0
  25. data/vendor/assets/images/semantic-ui/loader-mini-inverted.gif +0 -0
  26. data/vendor/assets/images/semantic-ui/loader-mini.gif +0 -0
  27. data/vendor/assets/images/semantic-ui/loader-small-inverted.gif +0 -0
  28. data/vendor/assets/images/semantic-ui/loader-small.gif +0 -0
  29. data/vendor/assets/javascripts/semantic-ui/accordion.js +411 -0
  30. data/vendor/assets/javascripts/semantic-ui/behavior/api.js +666 -0
  31. data/vendor/assets/javascripts/semantic-ui/behavior/colorize.js +271 -0
  32. data/vendor/assets/javascripts/semantic-ui/behavior/form.js +657 -0
  33. data/vendor/assets/javascripts/semantic-ui/behavior/state.js +752 -0
  34. data/vendor/assets/javascripts/semantic-ui/carousel.js +327 -0
  35. data/vendor/assets/javascripts/semantic-ui/chatroom.js +766 -0
  36. data/vendor/assets/javascripts/semantic-ui/checkbox.js +348 -0
  37. data/vendor/assets/javascripts/semantic-ui/dimmer.js +525 -0
  38. data/vendor/assets/javascripts/semantic-ui/dropdown.js +697 -0
  39. data/vendor/assets/javascripts/semantic-ui/modal.js +478 -0
  40. data/vendor/assets/javascripts/semantic-ui/nag.js +542 -0
  41. data/vendor/assets/javascripts/semantic-ui/popup.js +721 -0
  42. data/vendor/assets/javascripts/semantic-ui/rating.js +358 -0
  43. data/vendor/assets/javascripts/semantic-ui/search.js +770 -0
  44. data/vendor/assets/javascripts/semantic-ui/shape.js +776 -0
  45. data/vendor/assets/javascripts/semantic-ui/sidebar.js +489 -0
  46. data/vendor/assets/javascripts/semantic-ui/tab.js +674 -0
  47. data/vendor/assets/javascripts/semantic-ui/transition.js +645 -0
  48. data/vendor/assets/javascripts/semantic-ui/video.js +459 -0
  49. data/vendor/assets/stylesheets/semantic-ui/collections/breadcrumb.less +79 -0
  50. data/vendor/assets/stylesheets/semantic-ui/collections/form.less +536 -0
  51. data/vendor/assets/stylesheets/semantic-ui/collections/grid.less +655 -0
  52. data/vendor/assets/stylesheets/semantic-ui/collections/menu.less +1736 -0
  53. data/vendor/assets/stylesheets/semantic-ui/collections/message.less +337 -0
  54. data/vendor/assets/stylesheets/semantic-ui/collections/table.less +526 -0
  55. data/vendor/assets/stylesheets/semantic-ui/elements/button.less +1294 -0
  56. data/vendor/assets/stylesheets/semantic-ui/elements/divider.less +200 -0
  57. data/vendor/assets/stylesheets/semantic-ui/elements/header.less +325 -0
  58. data/vendor/assets/stylesheets/semantic-ui/elements/icon.less +449 -0
  59. data/vendor/assets/stylesheets/semantic-ui/elements/image.less +170 -0
  60. data/vendor/assets/stylesheets/semantic-ui/elements/input.less +287 -0
  61. data/vendor/assets/stylesheets/semantic-ui/elements/label.less +805 -0
  62. data/vendor/assets/stylesheets/semantic-ui/elements/loader.less +178 -0
  63. data/vendor/assets/stylesheets/semantic-ui/elements/progress.less +353 -0
  64. data/vendor/assets/stylesheets/semantic-ui/elements/segment.less +465 -0
  65. data/vendor/assets/stylesheets/semantic-ui/elements/step.less +294 -0
  66. data/vendor/assets/stylesheets/semantic-ui/modules/accordion.less +135 -0
  67. data/vendor/assets/stylesheets/semantic-ui/modules/carousel.less +71 -0
  68. data/vendor/assets/stylesheets/semantic-ui/modules/chatroom.less +271 -0
  69. data/vendor/assets/stylesheets/semantic-ui/modules/checkbox.less +378 -0
  70. data/vendor/assets/stylesheets/semantic-ui/modules/dimmer.less +230 -0
  71. data/vendor/assets/stylesheets/semantic-ui/modules/dropdown.less +506 -0
  72. data/vendor/assets/stylesheets/semantic-ui/modules/extra.transition.less +1197 -0
  73. data/vendor/assets/stylesheets/semantic-ui/modules/modal.less +154 -0
  74. data/vendor/assets/stylesheets/semantic-ui/modules/nag.less +175 -0
  75. data/vendor/assets/stylesheets/semantic-ui/modules/popup.less +238 -0
  76. data/vendor/assets/stylesheets/semantic-ui/modules/rating.less +151 -0
  77. data/vendor/assets/stylesheets/semantic-ui/modules/reveal.less +367 -0
  78. data/vendor/assets/stylesheets/semantic-ui/modules/search.less +275 -0
  79. data/vendor/assets/stylesheets/semantic-ui/modules/shape.less +115 -0
  80. data/vendor/assets/stylesheets/semantic-ui/modules/sidebar.less +147 -0
  81. data/vendor/assets/stylesheets/semantic-ui/modules/tab.less +59 -0
  82. data/vendor/assets/stylesheets/semantic-ui/modules/transition.less +839 -0
  83. data/vendor/assets/stylesheets/semantic-ui/modules/video.less +99 -0
  84. data/vendor/assets/stylesheets/semantic-ui/views/comment.less +221 -0
  85. data/vendor/assets/stylesheets/semantic-ui/views/feed.less +151 -0
  86. data/vendor/assets/stylesheets/semantic-ui/views/item.less +641 -0
  87. data/vendor/assets/stylesheets/semantic-ui/views/list.less +491 -0
  88. data/vendor/assets/stylesheets/semantic-ui/views/sitemap.less +47 -0
  89. data/vendor/assets/stylesheets/semantic-ui/views/statistic.less +34 -0
  90. metadata +161 -0
@@ -0,0 +1,752 @@
1
+ /* ******************************
2
+ Module
3
+ State
4
+ Change text based on state context
5
+ Hover/down/Active/Inactive
6
+ Author: Jack Lukic
7
+ Last revision: May 2012
8
+
9
+ State text module is used to apply text to a given node
10
+ depending on the elements "state"
11
+
12
+ State is either defined as "active" or "inactive" depending
13
+ on the returned value of a test function
14
+
15
+ Usage:
16
+
17
+ $button
18
+ .state({
19
+ states: {
20
+ active: true
21
+ },
22
+ text: {
23
+ inactive: 'Follow',
24
+ active : 'Following',
25
+ enable : 'Add',
26
+ disable : 'Remove'
27
+ }
28
+ })
29
+ ;
30
+
31
+ "Follow", turns to "Add" on hover, then "Following" on active
32
+ and finally "Remove" on active hover
33
+
34
+ This plugin works in correlation to API module and will, by default,
35
+ use deffered object accept/reject to determine state.
36
+
37
+ ****************************** */
38
+
39
+ ;(function ( $, window, document, undefined ) {
40
+
41
+ $.fn.state = function(parameters) {
42
+ var
43
+ $allModules = $(this),
44
+ settings = $.extend(true, {}, $.fn.state.settings, parameters),
45
+
46
+ moduleSelector = $allModules.selector || '',
47
+
48
+ time = new Date().getTime(),
49
+ performance = [],
50
+
51
+ query = arguments[0],
52
+ methodInvoked = (typeof query == 'string'),
53
+ queryArguments = [].slice.call(arguments, 1),
54
+
55
+ // shortcuts
56
+ error = settings.error,
57
+ metadata = settings.metadata,
58
+ className = settings.className,
59
+ namespace = settings.namespace,
60
+ states = settings.states,
61
+ text = settings.text,
62
+
63
+ eventNamespace = '.' + namespace,
64
+ moduleNamespace = namespace + '-module',
65
+
66
+
67
+ invokedResponse
68
+ ;
69
+ $allModules
70
+ .each(function() {
71
+ var
72
+ $module = $(this),
73
+
74
+ element = this,
75
+ instance = $module.data(moduleNamespace),
76
+
77
+ module
78
+ ;
79
+ module = {
80
+
81
+ initialize: function() {
82
+ module.verbose('Initializing module');
83
+
84
+ // allow module to guess desired state based on element
85
+ if(settings.automatic) {
86
+ module.add.defaults();
87
+ }
88
+
89
+ // bind events with delegated events
90
+ if(settings.context && moduleSelector !== '') {
91
+ if( module.allows('hover') ) {
92
+ $(element, settings.context)
93
+ .on(moduleSelector, 'mouseenter' + eventNamespace, module.enable.hover)
94
+ .on(moduleSelector, 'mouseleave' + eventNamespace, module.disable.hover)
95
+ ;
96
+ }
97
+ if( module.allows('down') ) {
98
+ $(element, settings.context)
99
+ .on(moduleSelector, 'mousedown' + eventNamespace, module.enable.down)
100
+ .on(moduleSelector, 'mouseup' + eventNamespace, module.disable.down)
101
+ ;
102
+ }
103
+ if( module.allows('focus') ) {
104
+ $(element, settings.context)
105
+ .on(moduleSelector, 'focus' + eventNamespace, module.enable.focus)
106
+ .on(moduleSelector, 'blur' + eventNamespace, module.disable.focus)
107
+ ;
108
+ }
109
+ $(settings.context)
110
+ .on(moduleSelector, 'mouseenter' + eventNamespace, module.change.text)
111
+ .on(moduleSelector, 'mouseleave' + eventNamespace, module.reset.text)
112
+ .on(moduleSelector, 'click' + eventNamespace, module.toggle.state)
113
+ ;
114
+ }
115
+ else {
116
+ if( module.allows('hover') ) {
117
+ $module
118
+ .on('mouseenter' + eventNamespace, module.enable.hover)
119
+ .on('mouseleave' + eventNamespace, module.disable.hover)
120
+ ;
121
+ }
122
+ if( module.allows('down') ) {
123
+ $module
124
+ .on('mousedown' + eventNamespace, module.enable.down)
125
+ .on('mouseup' + eventNamespace, module.disable.down)
126
+ ;
127
+ }
128
+ if( module.allows('focus') ) {
129
+ $module
130
+ .on('focus' + eventNamespace, module.enable.focus)
131
+ .on('blur' + eventNamespace, module.disable.focus)
132
+ ;
133
+ }
134
+ $module
135
+ .on('mouseenter' + eventNamespace, module.change.text)
136
+ .on('mouseleave' + eventNamespace, module.reset.text)
137
+ .on('click' + eventNamespace, module.toggle.state)
138
+ ;
139
+ }
140
+ module.instantiate();
141
+ },
142
+
143
+ instantiate: function() {
144
+ module.verbose('Storing instance of module', module);
145
+ instance = module;
146
+ $module
147
+ .data(moduleNamespace, module)
148
+ ;
149
+ },
150
+
151
+ destroy: function() {
152
+ module.verbose('Destroying previous module', instance);
153
+ $module
154
+ .off(eventNamespace)
155
+ .removeData(moduleNamespace)
156
+ ;
157
+ },
158
+
159
+ refresh: function() {
160
+ module.verbose('Refreshing selector cache');
161
+ $module = $(element);
162
+ },
163
+
164
+ add: {
165
+ defaults: function() {
166
+ var
167
+ userStates = parameters && $.isPlainObject(parameters.states)
168
+ ? parameters.states
169
+ : {}
170
+ ;
171
+ $.each(settings.defaults, function(type, typeStates) {
172
+ if( module.is[type] !== undefined && module.is[type]() ) {
173
+ module.verbose('Adding default states', type, element);
174
+ $.extend(settings.states, typeStates, userStates);
175
+ }
176
+ });
177
+ }
178
+ },
179
+
180
+ is: {
181
+
182
+ active: function() {
183
+ return $module.hasClass(className.active);
184
+ },
185
+ loading: function() {
186
+ return $module.hasClass(className.loading);
187
+ },
188
+ inactive: function() {
189
+ return !( $module.hasClass(className.active) );
190
+ },
191
+
192
+ enabled: function() {
193
+ return !( $module.is(settings.filter.active) );
194
+ },
195
+ disabled: function() {
196
+ return ( $module.is(settings.filter.active) );
197
+ },
198
+ textEnabled: function() {
199
+ return !( $module.is(settings.filter.text) );
200
+ },
201
+
202
+ // definitions for automatic type detection
203
+ button: function() {
204
+ return $module.is('.button:not(a, .submit)');
205
+ },
206
+ input: function() {
207
+ return $module.is('input');
208
+ }
209
+ },
210
+
211
+ allow: function(state) {
212
+ module.debug('Now allowing state', state);
213
+ states[state] = true;
214
+ },
215
+ disallow: function(state) {
216
+ module.debug('No longer allowing', state);
217
+ states[state] = false;
218
+ },
219
+
220
+ allows: function(state) {
221
+ return states[state] || false;
222
+ },
223
+
224
+ enable: {
225
+ state: function(state) {
226
+ if(module.allows(state)) {
227
+ $module.addClass( className[state] );
228
+ }
229
+ },
230
+ // convenience
231
+ focus: function() {
232
+ $module.addClass(className.focus);
233
+ },
234
+ hover: function() {
235
+ $module.addClass(className.hover);
236
+ },
237
+ down: function() {
238
+ $module.addClass(className.down);
239
+ },
240
+ },
241
+
242
+ disable: {
243
+ state: function(state) {
244
+ if(module.allows(state)) {
245
+ $module.removeClass( className[state] );
246
+ }
247
+ },
248
+ // convenience
249
+ focus: function() {
250
+ $module.removeClass(className.focus);
251
+ },
252
+ hover: function() {
253
+ $module.removeClass(className.hover);
254
+ },
255
+ down: function() {
256
+ $module.removeClass(className.down);
257
+ },
258
+ },
259
+
260
+ toggle: {
261
+ state: function() {
262
+ var
263
+ apiRequest = $module.data(metadata.promise)
264
+ ;
265
+ if( module.allows('active') && module.is.enabled() ) {
266
+ module.refresh();
267
+ if(apiRequest !== undefined) {
268
+ module.listenTo(apiRequest);
269
+ }
270
+ else {
271
+ module.change.state();
272
+ }
273
+ }
274
+ }
275
+ },
276
+
277
+ listenTo: function(apiRequest) {
278
+ module.debug('API request detected, waiting for state signal', apiRequest);
279
+ if(apiRequest) {
280
+ if(text.loading) {
281
+ module.update.text(text.loading);
282
+ }
283
+ $.when(apiRequest)
284
+ .then(function() {
285
+ if(apiRequest.state() == 'resolved') {
286
+ module.debug('API request succeeded');
287
+ settings.activateTest = function(){ return true; };
288
+ settings.deactivateTest = function(){ return true; };
289
+ }
290
+ else {
291
+ module.debug('API request failed');
292
+ settings.activateTest = function(){ return false; };
293
+ settings.deactivateTest = function(){ return false; };
294
+ }
295
+ module.change.state();
296
+ })
297
+ ;
298
+ }
299
+ // xhr exists but set to false, beforeSend killed the xhr
300
+ else {
301
+ settings.activateTest = function(){ return false; };
302
+ settings.deactivateTest = function(){ return false; };
303
+ }
304
+ },
305
+
306
+ // checks whether active/inactive state can be given
307
+ change: {
308
+
309
+ state: function() {
310
+ module.debug('Determining state change direction');
311
+ // inactive to active change
312
+ if( module.is.inactive() ) {
313
+ module.activate();
314
+ }
315
+ else {
316
+ module.deactivate();
317
+ }
318
+ if(settings.sync) {
319
+ module.sync();
320
+ }
321
+ $.proxy(settings.onChange, element)();
322
+ },
323
+
324
+ text: function() {
325
+ if( module.is.textEnabled() ) {
326
+ if( module.is.active() ) {
327
+ if(text.hover) {
328
+ module.verbose('Changing text to hover text', text.hover);
329
+ module.update.text(text.hover);
330
+ }
331
+ else if(text.disable) {
332
+ module.verbose('Changing text to disable text', text.disable);
333
+ module.update.text(text.disable);
334
+ }
335
+ }
336
+ else {
337
+ if(text.hover) {
338
+ module.verbose('Changing text to hover text', text.disable);
339
+ module.update.text(text.hover);
340
+ }
341
+ else if(text.enable){
342
+ module.verbose('Changing text to enable text', text.enable);
343
+ module.update.text(text.enable);
344
+ }
345
+ }
346
+ }
347
+ }
348
+
349
+ },
350
+
351
+ activate: function() {
352
+ if( $.proxy(settings.activateTest, element)() ) {
353
+ module.debug('Setting state to active');
354
+ $module
355
+ .addClass(className.active)
356
+ ;
357
+ module.update.text(text.active);
358
+ }
359
+ $.proxy(settings.onActivate, element)();
360
+ },
361
+
362
+ deactivate: function() {
363
+ if($.proxy(settings.deactivateTest, element)() ) {
364
+ module.debug('Setting state to inactive');
365
+ $module
366
+ .removeClass(className.active)
367
+ ;
368
+ module.update.text(text.inactive);
369
+ }
370
+ $.proxy(settings.onDeactivate, element)();
371
+ },
372
+
373
+ sync: function() {
374
+ module.verbose('Syncing other buttons to current state');
375
+ if( module.is.active() ) {
376
+ $allModules
377
+ .not($module)
378
+ .state('activate');
379
+ }
380
+ else {
381
+ $allModules
382
+ .not($module)
383
+ .state('deactivate')
384
+ ;
385
+ }
386
+ },
387
+
388
+ get: {
389
+ text: function() {
390
+ return (settings.selector.text)
391
+ ? $module.find(settings.selector.text).text()
392
+ : $module.html()
393
+ ;
394
+ },
395
+ textFor: function(state) {
396
+ return text[state] || false;
397
+ }
398
+ },
399
+
400
+ flash: {
401
+ text: function(text, duration) {
402
+ var
403
+ previousText = module.get.text()
404
+ ;
405
+ module.debug('Flashing text message', text, duration);
406
+ text = text || settings.text.flash;
407
+ duration = duration || settings.flashDuration;
408
+ module.update.text(text);
409
+ setTimeout(function(){
410
+ module.update.text(previousText);
411
+ }, duration);
412
+ }
413
+ },
414
+
415
+ reset: {
416
+ // on mouseout sets text to previous value
417
+ text: function() {
418
+ var
419
+ activeText = text.active || $module.data(metadata.storedText),
420
+ inactiveText = text.inactive || $module.data(metadata.storedText)
421
+ ;
422
+ if( module.is.textEnabled() ) {
423
+ if( module.is.active() && activeText) {
424
+ module.verbose('Resetting active text', activeText);
425
+ module.update.text(activeText);
426
+ }
427
+ else if(inactiveText) {
428
+ module.verbose('Resetting inactive text', activeText);
429
+ module.update.text(inactiveText);
430
+ }
431
+ }
432
+ }
433
+ },
434
+
435
+ update: {
436
+ text: function(text) {
437
+ var
438
+ currentText = module.get.text()
439
+ ;
440
+ if(text && text !== currentText) {
441
+ module.debug('Updating text', text);
442
+ if(settings.selector.text) {
443
+ $module
444
+ .data(metadata.storedText, text)
445
+ .find(settings.selector.text)
446
+ .text(text)
447
+ ;
448
+ }
449
+ else {
450
+ $module
451
+ .data(metadata.storedText, text)
452
+ .html(text)
453
+ ;
454
+ }
455
+ }
456
+ else {
457
+ module.debug('Text is already sane, ignoring update', text);
458
+ }
459
+ }
460
+ },
461
+
462
+ setting: function(name, value) {
463
+ module.debug('Changing setting', name, value);
464
+ if(value !== undefined) {
465
+ if( $.isPlainObject(name) ) {
466
+ $.extend(true, settings, name);
467
+ }
468
+ else {
469
+ settings[name] = value;
470
+ }
471
+ }
472
+ else {
473
+ return settings[name];
474
+ }
475
+ },
476
+ internal: function(name, value) {
477
+ module.debug('Changing internal', name, value);
478
+ if(value !== undefined) {
479
+ if( $.isPlainObject(name) ) {
480
+ $.extend(true, module, name);
481
+ }
482
+ else {
483
+ module[name] = value;
484
+ }
485
+ }
486
+ else {
487
+ return module[name];
488
+ }
489
+ },
490
+ debug: function() {
491
+ if(settings.debug) {
492
+ if(settings.performance) {
493
+ module.performance.log(arguments);
494
+ }
495
+ else {
496
+ module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
497
+ module.debug.apply(console, arguments);
498
+ }
499
+ }
500
+ },
501
+ verbose: function() {
502
+ if(settings.verbose && settings.debug) {
503
+ if(settings.performance) {
504
+ module.performance.log(arguments);
505
+ }
506
+ else {
507
+ module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
508
+ module.verbose.apply(console, arguments);
509
+ }
510
+ }
511
+ },
512
+ error: function() {
513
+ module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
514
+ module.error.apply(console, arguments);
515
+ },
516
+ performance: {
517
+ log: function(message) {
518
+ var
519
+ currentTime,
520
+ executionTime,
521
+ previousTime
522
+ ;
523
+ if(settings.performance) {
524
+ currentTime = new Date().getTime();
525
+ previousTime = time || currentTime;
526
+ executionTime = currentTime - previousTime;
527
+ time = currentTime;
528
+ performance.push({
529
+ 'Element' : element,
530
+ 'Name' : message[0],
531
+ 'Arguments' : [].slice.call(message, 1) || '',
532
+ 'Execution Time' : executionTime
533
+ });
534
+ }
535
+ clearTimeout(module.performance.timer);
536
+ module.performance.timer = setTimeout(module.performance.display, 100);
537
+ },
538
+ display: function() {
539
+ var
540
+ title = settings.name + ':',
541
+ totalTime = 0
542
+ ;
543
+ time = false;
544
+ clearTimeout(module.performance.timer);
545
+ $.each(performance, function(index, data) {
546
+ totalTime += data['Execution Time'];
547
+ });
548
+ title += ' ' + totalTime + 'ms';
549
+ if(moduleSelector) {
550
+ title += ' \'' + moduleSelector + '\'';
551
+ }
552
+ if($allModules.size() > 1) {
553
+ title += ' ' + '(' + $allModules.size() + ')';
554
+ }
555
+ if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) {
556
+ console.groupCollapsed(title);
557
+ if(console.table) {
558
+ console.table(performance);
559
+ }
560
+ else {
561
+ $.each(performance, function(index, data) {
562
+ console.log(data['Name'] + ': ' + data['Execution Time']+'ms');
563
+ });
564
+ }
565
+ console.groupEnd();
566
+ }
567
+ performance = [];
568
+ }
569
+ },
570
+ invoke: function(query, passedArguments, context) {
571
+ var
572
+ maxDepth,
573
+ found,
574
+ response
575
+ ;
576
+ passedArguments = passedArguments || queryArguments;
577
+ context = element || context;
578
+ if(typeof query == 'string' && instance !== undefined) {
579
+ query = query.split(/[\. ]/);
580
+ maxDepth = query.length - 1;
581
+ $.each(query, function(depth, value) {
582
+ var camelCaseValue = (depth != maxDepth)
583
+ ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
584
+ : query
585
+ ;
586
+ if( $.isPlainObject( instance[value] ) && (depth != maxDepth) ) {
587
+ instance = instance[value];
588
+ }
589
+ else if( $.isPlainObject( instance[camelCaseValue] ) && (depth != maxDepth) ) {
590
+ instance = instance[camelCaseValue];
591
+ }
592
+ else if( instance[value] !== undefined ) {
593
+ found = instance[value];
594
+ return false;
595
+ }
596
+ else if( instance[camelCaseValue] !== undefined ) {
597
+ found = instance[camelCaseValue];
598
+ return false;
599
+ }
600
+ else {
601
+ module.error(error.method);
602
+ return false;
603
+ }
604
+ });
605
+ }
606
+ if ( $.isFunction( found ) ) {
607
+ response = found.apply(context, passedArguments);
608
+ }
609
+ else if(found !== undefined) {
610
+ response = found;
611
+ }
612
+ if($.isArray(invokedResponse)) {
613
+ invokedResponse.push(response);
614
+ }
615
+ else if(typeof invokedResponse == 'string') {
616
+ invokedResponse = [invokedResponse, response];
617
+ }
618
+ else if(response !== undefined) {
619
+ invokedResponse = response;
620
+ }
621
+ return found;
622
+ }
623
+ };
624
+ if(methodInvoked) {
625
+ if(instance === undefined) {
626
+ module.initialize();
627
+ }
628
+ module.invoke(query);
629
+ }
630
+ else {
631
+ if(instance !== undefined) {
632
+ module.destroy();
633
+ }
634
+ module.initialize();
635
+ }
636
+
637
+ })
638
+ ;
639
+
640
+ return (invokedResponse !== undefined)
641
+ ? invokedResponse
642
+ : this
643
+ ;
644
+ };
645
+
646
+ $.fn.state.settings = {
647
+
648
+ // module info
649
+ moduleName : 'State',
650
+
651
+ // debug output
652
+ debug : true,
653
+
654
+ // verbose debug output
655
+ verbose : true,
656
+
657
+ // namespace for events
658
+ namespace : 'state',
659
+
660
+ // debug data includes performance
661
+ performance: true,
662
+
663
+ // callback occurs on state change
664
+ onActivate : function() {},
665
+ onDeactivate : function() {},
666
+ onChange : function() {},
667
+
668
+ // state test functions
669
+ activateTest : function() { return true; },
670
+ deactivateTest : function() { return true; },
671
+
672
+ // whether to automatically map default states
673
+ automatic : true,
674
+
675
+ // activate / deactivate changes all elements instantiated at same time
676
+ sync : false,
677
+
678
+ // default flash text duration, used for temporarily changing text of an element
679
+ flashDuration : 3000,
680
+
681
+ // selector filter
682
+ filter : {
683
+ text : '.loading, .disabled',
684
+ active : '.disabled'
685
+ },
686
+
687
+ context : false,
688
+
689
+ // error
690
+ error: {
691
+ method : 'The method you called is not defined.'
692
+ },
693
+
694
+ // metadata
695
+ metadata: {
696
+ promise : 'promise',
697
+ storedText : 'stored-text'
698
+ },
699
+
700
+ // change class on state
701
+ className: {
702
+ focus : 'focus',
703
+ hover : 'hover',
704
+ down : 'down',
705
+ active : 'active',
706
+ loading : 'loading'
707
+ },
708
+
709
+ selector: {
710
+ // selector for text node
711
+ text: false
712
+ },
713
+
714
+ defaults : {
715
+ input: {
716
+ hover : true,
717
+ focus : true,
718
+ down : true,
719
+ loading : false,
720
+ active : false
721
+ },
722
+ button: {
723
+ hover : true,
724
+ focus : false,
725
+ down : true,
726
+ active : true,
727
+ loading : true
728
+ }
729
+ },
730
+
731
+ states : {
732
+ hover : true,
733
+ focus : true,
734
+ down : true,
735
+ loading : false,
736
+ active : false
737
+ },
738
+
739
+ text : {
740
+ flash : false,
741
+ hover : false,
742
+ active : false,
743
+ inactive : false,
744
+ enable : false,
745
+ disable : false
746
+ }
747
+
748
+ };
749
+
750
+
751
+
752
+ })( jQuery, window , document );