semantic-ui-rails 0.10.3 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/semantic-ui/modules/accordion.js +10 -10
  3. data/app/assets/javascripts/semantic-ui/modules/behavior/api.js +11 -11
  4. data/app/assets/javascripts/semantic-ui/modules/behavior/form.js +10 -10
  5. data/app/assets/javascripts/semantic-ui/modules/behavior/state.js +10 -10
  6. data/app/assets/javascripts/semantic-ui/modules/checkbox.js +10 -10
  7. data/app/assets/javascripts/semantic-ui/modules/dimmer.js +11 -11
  8. data/app/assets/javascripts/semantic-ui/modules/dropdown.js +10 -10
  9. data/app/assets/javascripts/semantic-ui/modules/modal.js +56 -48
  10. data/app/assets/javascripts/semantic-ui/modules/nag.js +10 -10
  11. data/app/assets/javascripts/semantic-ui/modules/popup.js +30 -20
  12. data/app/assets/javascripts/semantic-ui/modules/rating.js +10 -10
  13. data/app/assets/javascripts/semantic-ui/modules/search.js +10 -10
  14. data/app/assets/javascripts/semantic-ui/modules/shape.js +10 -10
  15. data/app/assets/javascripts/semantic-ui/modules/sidebar.js +10 -10
  16. data/app/assets/javascripts/semantic-ui/modules/tab.js +11 -11
  17. data/app/assets/javascripts/semantic-ui/modules/transition.js +233 -110
  18. data/app/assets/javascripts/semantic-ui/modules/video.js +10 -10
  19. data/app/assets/stylesheets/semantic-ui/modules/accordion.less +0 -1
  20. data/app/assets/stylesheets/semantic-ui/modules/dimmer.less +1 -11
  21. data/app/assets/stylesheets/semantic-ui/modules/popup.less +1 -0
  22. data/app/assets/stylesheets/semantic-ui/modules/transition.less +5 -4
  23. data/lib/semantic/ui/rails/version.rb +1 -1
  24. metadata +2 -2
@@ -405,13 +405,14 @@ $.fn.nag = function(parameters) {
405
405
  },
406
406
  invoke: function(query, passedArguments, context) {
407
407
  var
408
+ object = instance,
408
409
  maxDepth,
409
410
  found,
410
411
  response
411
412
  ;
412
413
  passedArguments = passedArguments || queryArguments;
413
414
  context = element || context;
414
- if(typeof query == 'string' && instance !== undefined) {
415
+ if(typeof query == 'string' && object !== undefined) {
415
416
  query = query.split(/[\. ]/);
416
417
  maxDepth = query.length - 1;
417
418
  $.each(query, function(depth, value) {
@@ -419,22 +420,21 @@ $.fn.nag = function(parameters) {
419
420
  ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
420
421
  : query
421
422
  ;
422
- if( $.isPlainObject( instance[camelCaseValue] ) && (depth != maxDepth) ) {
423
- instance = instance[camelCaseValue];
423
+ if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) {
424
+ object = object[camelCaseValue];
424
425
  }
425
- else if( instance[camelCaseValue] !== undefined ) {
426
- found = instance[camelCaseValue];
426
+ else if( object[camelCaseValue] !== undefined ) {
427
+ found = object[camelCaseValue];
427
428
  return false;
428
429
  }
429
- else if( $.isPlainObject( instance[value] ) && (depth != maxDepth) ) {
430
- instance = instance[value];
430
+ else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) {
431
+ object = object[value];
431
432
  }
432
- else if( instance[value] !== undefined ) {
433
- found = instance[value];
433
+ else if( object[value] !== undefined ) {
434
+ found = object[value];
434
435
  return false;
435
436
  }
436
437
  else {
437
- module.error(error.method, query);
438
438
  return false;
439
439
  }
440
440
  });
@@ -187,10 +187,13 @@ $.fn.popup = function(parameters) {
187
187
  toggle: function() {
188
188
  module.debug('Toggling pop-up');
189
189
  if( module.is.hidden() ) {
190
+ module.debug('Popup is hidden, showing pop-up');
191
+ module.unbind.close();
190
192
  module.hideAll();
191
193
  module.show();
192
194
  }
193
195
  else {
196
+ module.debug('Popup is visible, hiding pop-up');
194
197
  module.hide();
195
198
  }
196
199
  },
@@ -231,9 +234,13 @@ $.fn.popup = function(parameters) {
231
234
 
232
235
  hideGracefully: function(event) {
233
236
  // don't close on clicks inside popup
234
- if( $(event.target).closest(selector.popup).size() === 0) {
237
+ if(event && $(event.target).closest(selector.popup).size() === 0) {
238
+ module.debug('Click occurred outside popup hiding popup');
235
239
  module.hide();
236
240
  }
241
+ else {
242
+ module.debug('Click was inside popup, keeping popup open');
243
+ }
237
244
  },
238
245
 
239
246
  exists: function() {
@@ -265,11 +272,7 @@ $.fn.popup = function(parameters) {
265
272
  },
266
273
  restore: {
267
274
  conditions: function() {
268
- if(module.cache === undefined) {
269
- module.error(error.cache);
270
- return false;
271
- }
272
- if(module.cache.title) {
275
+ if(module.cache && module.cache.title) {
273
276
  $module.attr('title', module.cache.title);
274
277
  }
275
278
  module.verbose('Restoring original attributes', module.cache.title);
@@ -536,16 +539,16 @@ $.fn.popup = function(parameters) {
536
539
  module.error(error.recursion);
537
540
  searchDepth = 0;
538
541
  module.reset();
542
+ $popup.removeClass(className.loading);
539
543
  return false;
540
544
  }
541
545
  }
542
546
  else {
543
547
  module.debug('Position is on stage', position);
544
548
  searchDepth = 0;
549
+ $popup.removeClass(className.loading);
545
550
  return true;
546
551
  }
547
-
548
- $module.removeClass(className.loading);
549
552
  }
550
553
 
551
554
  },
@@ -555,7 +558,10 @@ $.fn.popup = function(parameters) {
555
558
  if(settings.on == 'click' && settings.closable) {
556
559
  module.verbose('Binding popup close event to document');
557
560
  $document
558
- .on('click' + eventNamespace, module.hideGracefully)
561
+ .on('click' + eventNamespace, function(event) {
562
+ module.verbose('Pop-up clickaway intent detected');
563
+ $.proxy(module.hideGracefully, this)(event);
564
+ })
559
565
  ;
560
566
  }
561
567
  }
@@ -573,6 +579,9 @@ $.fn.popup = function(parameters) {
573
579
  },
574
580
 
575
581
  is: {
582
+ animating: function() {
583
+ return ( $popup.is(':animated') || $popup.hasClass(className.animating) );
584
+ },
576
585
  visible: function() {
577
586
  return $popup.is(':visible');
578
587
  },
@@ -692,13 +701,14 @@ $.fn.popup = function(parameters) {
692
701
  },
693
702
  invoke: function(query, passedArguments, context) {
694
703
  var
704
+ object = instance,
695
705
  maxDepth,
696
706
  found,
697
707
  response
698
708
  ;
699
709
  passedArguments = passedArguments || queryArguments;
700
710
  context = element || context;
701
- if(typeof query == 'string' && instance !== undefined) {
711
+ if(typeof query == 'string' && object !== undefined) {
702
712
  query = query.split(/[\. ]/);
703
713
  maxDepth = query.length - 1;
704
714
  $.each(query, function(depth, value) {
@@ -706,22 +716,21 @@ $.fn.popup = function(parameters) {
706
716
  ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
707
717
  : query
708
718
  ;
709
- if( $.isPlainObject( instance[value] ) && (depth != maxDepth) ) {
710
- instance = instance[value];
719
+ if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) {
720
+ object = object[camelCaseValue];
711
721
  }
712
- else if( $.isPlainObject( instance[camelCaseValue] ) && (depth != maxDepth) ) {
713
- instance = instance[camelCaseValue];
714
- }
715
- else if( instance[value] !== undefined ) {
716
- found = instance[value];
722
+ else if( object[camelCaseValue] !== undefined ) {
723
+ found = object[camelCaseValue];
717
724
  return false;
718
725
  }
719
- else if( instance[camelCaseValue] !== undefined ) {
720
- found = instance[camelCaseValue];
726
+ else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) {
727
+ object = object[value];
728
+ }
729
+ else if( object[value] !== undefined ) {
730
+ found = object[value];
721
731
  return false;
722
732
  }
723
733
  else {
724
- module.error(error.method, query);
725
734
  return false;
726
735
  }
727
736
  });
@@ -817,6 +826,7 @@ $.fn.popup.settings = {
817
826
  },
818
827
 
819
828
  className : {
829
+ animating : 'animating',
820
830
  loading : 'loading',
821
831
  popup : 'ui popup',
822
832
  position : 'top left center bottom right',
@@ -295,13 +295,14 @@ $.fn.rating = function(parameters) {
295
295
  },
296
296
  invoke: function(query, passedArguments, context) {
297
297
  var
298
+ object = instance,
298
299
  maxDepth,
299
300
  found,
300
301
  response
301
302
  ;
302
303
  passedArguments = passedArguments || queryArguments;
303
304
  context = element || context;
304
- if(typeof query == 'string' && instance !== undefined) {
305
+ if(typeof query == 'string' && object !== undefined) {
305
306
  query = query.split(/[\. ]/);
306
307
  maxDepth = query.length - 1;
307
308
  $.each(query, function(depth, value) {
@@ -309,22 +310,21 @@ $.fn.rating = function(parameters) {
309
310
  ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
310
311
  : query
311
312
  ;
312
- if( $.isPlainObject( instance[camelCaseValue] ) && (depth != maxDepth) ) {
313
- instance = instance[camelCaseValue];
313
+ if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) {
314
+ object = object[camelCaseValue];
314
315
  }
315
- else if( instance[camelCaseValue] !== undefined ) {
316
- found = instance[camelCaseValue];
316
+ else if( object[camelCaseValue] !== undefined ) {
317
+ found = object[camelCaseValue];
317
318
  return false;
318
319
  }
319
- else if( $.isPlainObject( instance[value] ) && (depth != maxDepth) ) {
320
- instance = instance[value];
320
+ else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) {
321
+ object = object[value];
321
322
  }
322
- else if( instance[value] !== undefined ) {
323
- found = instance[value];
323
+ else if( object[value] !== undefined ) {
324
+ found = object[value];
324
325
  return false;
325
326
  }
326
327
  else {
327
- module.error(error.method, query);
328
328
  return false;
329
329
  }
330
330
  });
@@ -508,13 +508,14 @@ $.fn.search = function(source, parameters) {
508
508
  },
509
509
  invoke: function(query, passedArguments, context) {
510
510
  var
511
+ object = instance,
511
512
  maxDepth,
512
513
  found,
513
514
  response
514
515
  ;
515
516
  passedArguments = passedArguments || queryArguments;
516
517
  context = element || context;
517
- if(typeof query == 'string' && instance !== undefined) {
518
+ if(typeof query == 'string' && object !== undefined) {
518
519
  query = query.split(/[\. ]/);
519
520
  maxDepth = query.length - 1;
520
521
  $.each(query, function(depth, value) {
@@ -522,22 +523,21 @@ $.fn.search = function(source, parameters) {
522
523
  ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
523
524
  : query
524
525
  ;
525
- if( $.isPlainObject( instance[camelCaseValue] ) && (depth != maxDepth) ) {
526
- instance = instance[camelCaseValue];
526
+ if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) {
527
+ object = object[camelCaseValue];
527
528
  }
528
- else if( instance[camelCaseValue] !== undefined ) {
529
- found = instance[camelCaseValue];
529
+ else if( object[camelCaseValue] !== undefined ) {
530
+ found = object[camelCaseValue];
530
531
  return false;
531
532
  }
532
- else if( $.isPlainObject( instance[value] ) && (depth != maxDepth) ) {
533
- instance = instance[value];
533
+ else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) {
534
+ object = object[value];
534
535
  }
535
- else if( instance[value] !== undefined ) {
536
- found = instance[value];
536
+ else if( object[value] !== undefined ) {
537
+ found = object[value];
537
538
  return false;
538
539
  }
539
540
  else {
540
- module.error(error.method, query);
541
541
  return false;
542
542
  }
543
543
  });
@@ -663,13 +663,14 @@ $.fn.shape = function(parameters) {
663
663
  },
664
664
  invoke: function(query, passedArguments, context) {
665
665
  var
666
+ object = instance,
666
667
  maxDepth,
667
668
  found,
668
669
  response
669
670
  ;
670
671
  passedArguments = passedArguments || queryArguments;
671
672
  context = element || context;
672
- if(typeof query == 'string' && instance !== undefined) {
673
+ if(typeof query == 'string' && object !== undefined) {
673
674
  query = query.split(/[\. ]/);
674
675
  maxDepth = query.length - 1;
675
676
  $.each(query, function(depth, value) {
@@ -677,22 +678,21 @@ $.fn.shape = function(parameters) {
677
678
  ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
678
679
  : query
679
680
  ;
680
- if( $.isPlainObject( instance[camelCaseValue] ) && (depth != maxDepth) ) {
681
- instance = instance[camelCaseValue];
681
+ if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) {
682
+ object = object[camelCaseValue];
682
683
  }
683
- else if( instance[camelCaseValue] !== undefined ) {
684
- found = instance[camelCaseValue];
684
+ else if( object[camelCaseValue] !== undefined ) {
685
+ found = object[camelCaseValue];
685
686
  return false;
686
687
  }
687
- else if( $.isPlainObject( instance[value] ) && (depth != maxDepth) ) {
688
- instance = instance[value];
688
+ else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) {
689
+ object = object[value];
689
690
  }
690
- else if( instance[value] !== undefined ) {
691
- found = instance[value];
691
+ else if( object[value] !== undefined ) {
692
+ found = object[value];
692
693
  return false;
693
694
  }
694
695
  else {
695
- module.error(error.method, query);
696
696
  return false;
697
697
  }
698
698
  });
@@ -402,13 +402,14 @@ $.fn.sidebar = function(parameters) {
402
402
  },
403
403
  invoke: function(query, passedArguments, context) {
404
404
  var
405
+ object = instance,
405
406
  maxDepth,
406
407
  found,
407
408
  response
408
409
  ;
409
410
  passedArguments = passedArguments || queryArguments;
410
411
  context = element || context;
411
- if(typeof query == 'string' && instance !== undefined) {
412
+ if(typeof query == 'string' && object !== undefined) {
412
413
  query = query.split(/[\. ]/);
413
414
  maxDepth = query.length - 1;
414
415
  $.each(query, function(depth, value) {
@@ -416,22 +417,21 @@ $.fn.sidebar = function(parameters) {
416
417
  ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
417
418
  : query
418
419
  ;
419
- if( $.isPlainObject( instance[camelCaseValue] ) && (depth != maxDepth) ) {
420
- instance = instance[camelCaseValue];
420
+ if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) {
421
+ object = object[camelCaseValue];
421
422
  }
422
- else if( instance[camelCaseValue] !== undefined ) {
423
- found = instance[camelCaseValue];
423
+ else if( object[camelCaseValue] !== undefined ) {
424
+ found = object[camelCaseValue];
424
425
  return false;
425
426
  }
426
- else if( $.isPlainObject( instance[value] ) && (depth != maxDepth) ) {
427
- instance = instance[value];
427
+ else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) {
428
+ object = object[value];
428
429
  }
429
- else if( instance[value] !== undefined ) {
430
- found = instance[value];
430
+ else if( object[value] !== undefined ) {
431
+ found = object[value];
431
432
  return false;
432
433
  }
433
434
  else {
434
- module.error(error.method, query);
435
435
  return false;
436
436
  }
437
437
  });
@@ -566,13 +566,14 @@
566
566
  },
567
567
  invoke: function(query, passedArguments, context) {
568
568
  var
569
+ object = instance,
569
570
  maxDepth,
570
571
  found,
571
572
  response
572
573
  ;
573
574
  passedArguments = passedArguments || queryArguments;
574
575
  context = element || context;
575
- if(typeof query == 'string' && instance !== undefined) {
576
+ if(typeof query == 'string' && object !== undefined) {
576
577
  query = query.split(/[\. ]/);
577
578
  maxDepth = query.length - 1;
578
579
  $.each(query, function(depth, value) {
@@ -580,22 +581,21 @@
580
581
  ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
581
582
  : query
582
583
  ;
583
- if( $.isPlainObject( instance[value] ) && (depth != maxDepth) ) {
584
- instance = instance[value];
584
+ if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) {
585
+ object = object[camelCaseValue];
585
586
  }
586
- else if( $.isPlainObject( instance[camelCaseValue] ) && (depth != maxDepth) ) {
587
- instance = instance[camelCaseValue];
588
- }
589
- else if( instance[value] !== undefined ) {
590
- found = instance[value];
587
+ else if( object[camelCaseValue] !== undefined ) {
588
+ found = object[camelCaseValue];
591
589
  return false;
592
590
  }
593
- else if( instance[camelCaseValue] !== undefined ) {
594
- found = instance[camelCaseValue];
591
+ else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) {
592
+ object = object[value];
593
+ }
594
+ else if( object[value] !== undefined ) {
595
+ found = object[value];
595
596
  return false;
596
597
  }
597
598
  else {
598
- module.error(error.method, query);
599
599
  return false;
600
600
  }
601
601
  });
@@ -70,11 +70,8 @@ $.fn.transition = function() {
70
70
  animationEnd = module.get.animationEvent();
71
71
  animationName = module.get.animationName();
72
72
 
73
- instance = $module.data(moduleNamespace);
73
+ instance = $module.data(moduleNamespace) || module;
74
74
 
75
- if(instance === undefined) {
76
- module.instantiate();
77
- }
78
75
  if(methodInvoked) {
79
76
  methodInvoked = module.invoke(query);
80
77
  }
@@ -82,11 +79,11 @@ $.fn.transition = function() {
82
79
  if(methodInvoked === false) {
83
80
  module.animate();
84
81
  }
82
+ module.instantiate();
85
83
  },
86
84
 
87
85
  instantiate: function() {
88
86
  module.verbose('Storing instance of module', module);
89
- instance = module;
90
87
  $module
91
88
  .data(moduleNamespace, instance)
92
89
  ;
@@ -99,6 +96,32 @@ $.fn.transition = function() {
99
96
  ;
100
97
  },
101
98
 
99
+ refresh: function() {
100
+ module.verbose('Refreshing display type on next animation');
101
+ delete instance.displayType;
102
+ },
103
+
104
+ forceRepaint: function() {
105
+ module.verbose('Forcing element repaint');
106
+ var
107
+ $parentElement = $module.parent(),
108
+ $nextElement = $module.next()
109
+ ;
110
+ if($nextElement.size() === 0) {
111
+ $module.detach().appendTo($parentElement);
112
+ }
113
+ else {
114
+ $module.detach().insertBefore($nextElement);
115
+ }
116
+ },
117
+
118
+ repaint: function() {
119
+ module.verbose('Repainting element');
120
+ var
121
+ fakeAssignment = element.offsetWidth
122
+ ;
123
+ },
124
+
102
125
  animate: function(overrideSettings) {
103
126
  settings = overrideSettings || settings;
104
127
  if(!module.is.supported()) {
@@ -106,31 +129,23 @@ $.fn.transition = function() {
106
129
  return false;
107
130
  }
108
131
  module.debug('Preparing animation', settings.animation);
109
- if(module.is.animating()) {
110
- if(settings.queue) {
111
- module.queue(settings.animation);
112
- }
132
+ if(module.is.animating() && settings.queue) {
133
+ module.queue(settings.animation);
113
134
  return false;
114
135
  }
115
- module.save.conditions();
116
- module.set.duration(settings.duration);
117
- module.set.animating();
118
- module.repaint();
119
- $module
120
- .addClass(className.transition)
121
- .addClass(settings.animation)
122
- .one(animationEnd, module.complete)
123
- ;
124
- if(!module.has.direction() && module.can.transition()) {
125
- module.set.direction();
136
+ if(module.can.animate) {
137
+ module.set.animating(settings.animation);
126
138
  }
127
- if( !module.has.transitionAvailable() ) {
128
- module.restore.conditions();
139
+ else {
129
140
  module.error(error.noAnimation, settings.animation);
130
- return false;
131
141
  }
132
- module.show();
133
- module.debug('Starting tween', settings.animation, $module.attr('class'));
142
+ },
143
+
144
+ reset: function() {
145
+ module.debug('Resetting animation to beginning conditions');
146
+ module.restore.conditions();
147
+ module.hide();
148
+ module.remove.animating();
134
149
  },
135
150
 
136
151
  queue: function(animation) {
@@ -147,12 +162,15 @@ $.fn.transition = function() {
147
162
  complete: function () {
148
163
  module.verbose('CSS animation complete', settings.animation);
149
164
  if(!module.is.looping()) {
150
- if($module.hasClass(className.outward)) {
165
+ if( module.is.outward() ) {
166
+ module.verbose('Animation is outward, hiding element');
151
167
  module.restore.conditions();
168
+ module.remove.display();
152
169
  module.hide();
153
170
  $.proxy(settings.onHide, this)();
154
171
  }
155
- else if($module.hasClass(className.inward)) {
172
+ else if( module.is.inward() ) {
173
+ module.verbose('Animation is outward, showing element');
156
174
  module.restore.conditions();
157
175
  module.show();
158
176
  $.proxy(settings.onShow, this)();
@@ -160,67 +178,70 @@ $.fn.transition = function() {
160
178
  else {
161
179
  module.restore.conditions();
162
180
  }
181
+ module.remove.duration();
163
182
  module.remove.animating();
164
183
  }
165
184
  $.proxy(settings.complete, this)();
166
185
  },
167
- forceRepaint: function() {
168
- module.verbose('Forcing element repaint');
169
- var
170
- $parentElement = $module.parent(),
171
- $nextElement = $module.next()
172
- ;
173
- if($nextElement.size() === 0) {
174
- $module.detach().appendTo($parentElement);
175
- }
176
- else {
177
- $module.detach().insertBefore($nextElement);
178
- }
179
- },
180
- repaint: function() {
181
- module.verbose('Repainting element');
182
- var
183
- fakeAssignment = element.offsetWidth
184
- ;
185
- },
186
+
186
187
  has: {
187
188
  direction: function(animation) {
188
189
  animation = animation || settings.animation;
189
- if( $module.hasClass(className.inward) || $module.hasClass(className.outward) ) {
190
+ if( animation.search(className.inward) !== -1 || animation.search(className.outward) !== -1) {
191
+ module.debug('Direction already set in animation');
190
192
  return true;
191
193
  }
192
- },
193
- transitionAvailable: function() {
194
- if($module.css(animationName) !== 'none') {
195
- module.debug('CSS definition found');
196
- return true;
197
- }
198
- else {
199
- module.debug('Unable to find css definition');
200
- return false;
201
- }
194
+ return false;
202
195
  }
203
196
  },
204
197
 
205
198
  set: {
206
199
 
207
- animating: function() {
208
- $module.addClass(className.animating);
200
+ animating: function(animation) {
201
+ animation = animation || settings.animation;
202
+ module.save.conditions();
203
+ if(module.can.transition() && !module.has.direction()) {
204
+ module.set.direction();
205
+ }
206
+ module.remove.hidden();
207
+ module.set.display();
208
+ $module
209
+ .addClass(className.animating)
210
+ .addClass(className.transition)
211
+ .addClass(animation)
212
+ .one(animationEnd, module.complete)
213
+ ;
214
+ module.set.duration(settings.duration);
215
+ module.debug('Starting tween', settings.animation, $module.attr('class'));
216
+ },
217
+
218
+ display: function() {
219
+ var
220
+ displayType = module.get.displayType()
221
+ ;
222
+ if(displayType !== 'block') {
223
+ module.verbose('Setting final visibility to', displayType);
224
+ $module
225
+ .css({
226
+ display: displayType
227
+ })
228
+ ;
229
+ }
209
230
  },
210
231
 
211
232
  direction: function() {
212
233
  if($module.is(':visible')) {
213
234
  module.debug('Automatically determining the direction of animation', 'Outward');
214
235
  $module
215
- .addClass(className.outward)
216
236
  .removeClass(className.inward)
237
+ .addClass(className.outward)
217
238
  ;
218
239
  }
219
240
  else {
220
241
  module.debug('Automatically determining the direction of animation', 'Inward');
221
242
  $module
222
- .addClass(className.inward)
223
243
  .removeClass(className.outward)
244
+ .addClass(className.inward)
224
245
  ;
225
246
  }
226
247
  },
@@ -248,41 +269,63 @@ $.fn.transition = function() {
248
269
  'animation-duration': duration
249
270
  })
250
271
  ;
272
+ },
273
+
274
+ hidden: function() {
275
+ $module
276
+ .addClass(className.transition)
277
+ .addClass(className.hidden)
278
+ ;
279
+ },
280
+
281
+ visible: function() {
282
+ $module
283
+ .addClass(className.transition)
284
+ .addClass(className.visible)
285
+ ;
251
286
  }
252
287
  },
253
288
 
254
289
  save: {
290
+ displayType: function(displayType) {
291
+ instance.displayType = displayType;
292
+ },
293
+ transitionExists: function(animation, exists) {
294
+ $.fn.transition.exists[animation] = exists;
295
+ module.verbose('Saving existence of transition', animation, exists);
296
+ },
255
297
  conditions: function() {
256
- module.cache = {
298
+ instance.cache = {
257
299
  className : $module.attr('class'),
258
300
  style : $module.attr('style')
259
301
  };
260
- module.verbose('Saving original attributes', module.cache);
302
+ module.verbose('Saving original attributes', instance.cache);
261
303
  }
262
304
  },
263
305
 
264
306
  restore: {
265
307
  conditions: function() {
266
- if(typeof module.cache === undefined) {
267
- module.error(error.cache);
308
+ if(instance.cache === undefined) {
268
309
  return false;
269
310
  }
270
- if(module.cache.className) {
271
- $module.attr('class', module.cache.className);
311
+ if(instance.cache.className) {
312
+ $module.attr('class', instance.cache.className);
272
313
  }
273
314
  else {
274
315
  $module.removeAttr('class');
275
316
  }
276
- if(module.cache.style) {
277
- $module.attr('style', module.cache.style);
317
+ if(instance.cache.style) {
318
+ $module.attr('style', instance.cache.style);
278
319
  }
279
320
  else {
280
- $module.removeAttr('style');
321
+ if(module.get.displayType() === 'block') {
322
+ $module.removeAttr('style');
323
+ }
281
324
  }
282
325
  if(module.is.looping()) {
283
326
  module.remove.looping();
284
327
  }
285
- module.verbose('Restoring original attributes', module.cache);
328
+ module.verbose('Restoring original attributes', instance.cache);
286
329
  }
287
330
  },
288
331
 
@@ -292,6 +335,32 @@ $.fn.transition = function() {
292
335
  $module.removeClass(className.animating);
293
336
  },
294
337
 
338
+ display: function() {
339
+ if(instance.displayType !== undefined) {
340
+ $module.css('display', '');
341
+ }
342
+ },
343
+
344
+ duration: function() {
345
+ $module
346
+ .css({
347
+ '-webkit-animation-duration' : '',
348
+ '-moz-animation-duration' : '',
349
+ '-ms-animation-duration' : '',
350
+ '-o-animation-duration' : '',
351
+ 'animation-duration' : ''
352
+ })
353
+ ;
354
+ },
355
+
356
+ hidden: function() {
357
+ $module.removeClass(className.hidden);
358
+ },
359
+
360
+ visible: function() {
361
+ $module.removeClass(className.visible);
362
+ },
363
+
295
364
  looping: function() {
296
365
  module.debug('Transitions are no longer looping');
297
366
  $module
@@ -306,12 +375,12 @@ $.fn.transition = function() {
306
375
 
307
376
  settings: function(animation, duration, complete) {
308
377
  // single settings object
309
- if($.isPlainObject(animation)) {
378
+ if(typeof animation == 'object') {
310
379
  return $.extend(true, {}, $.fn.transition.settings, animation);
311
380
  }
312
381
  // all arguments provided
313
382
  else if(typeof complete == 'function') {
314
- return $.extend(true, {}, $.fn.transition.settings, {
383
+ return $.extend({}, $.fn.transition.settings, {
315
384
  animation : animation,
316
385
  complete : complete,
317
386
  duration : duration
@@ -319,31 +388,43 @@ $.fn.transition = function() {
319
388
  }
320
389
  // only duration provided
321
390
  else if(typeof duration == 'string' || typeof duration == 'number') {
322
- return $.extend(true, {}, $.fn.transition.settings, {
391
+ return $.extend({}, $.fn.transition.settings, {
323
392
  animation : animation,
324
393
  duration : duration
325
394
  });
326
395
  }
327
396
  // duration is actually settings object
328
397
  else if(typeof duration == 'object') {
329
- return $.extend(true, {}, $.fn.transition.settings, duration, {
398
+ return $.extend({}, $.fn.transition.settings, duration, {
330
399
  animation : animation
331
400
  });
332
401
  }
333
402
  // duration is actually callback
334
403
  else if(typeof duration == 'function') {
335
- return $.extend(true, {}, $.fn.transition.settings, {
404
+ return $.extend({}, $.fn.transition.settings, {
336
405
  animation : animation,
337
406
  complete : duration
338
407
  });
339
408
  }
340
409
  // only animation provided
341
410
  else {
342
- return $.extend(true, {}, $.fn.transition.settings, {
411
+ return $.extend({}, $.fn.transition.settings, {
343
412
  animation : animation
344
413
  });
345
414
  }
346
- return $.extend({}, $.fn.transition.settings);
415
+ return $.fn.transition.settings;
416
+ },
417
+
418
+ displayType: function() {
419
+ if(instance.displayType === undefined) {
420
+ // create fake element to determine display state
421
+ module.can.transition();
422
+ }
423
+ return instance.displayType;
424
+ },
425
+
426
+ transitionExists: function(animation) {
427
+ return $.fn.transition.exists[animation];
347
428
  },
348
429
 
349
430
  animationName: function() {
@@ -389,22 +470,60 @@ $.fn.transition = function() {
389
470
  },
390
471
 
391
472
  can: {
392
- transition: function() {
393
- var
394
- $clone = $('<div>').addClass( $module.attr('class') ).appendTo($('body')),
395
- currentAnimation = $clone.css(animationName),
396
- inAnimation = $clone.addClass(className.inward).css(animationName)
397
- ;
398
- if(currentAnimation != inAnimation) {
399
- module.debug('In/out transitions exist');
400
- $clone.remove();
473
+ animate: function() {
474
+ if($module.css(settings.animation) !== 'none') {
475
+ module.debug('CSS definition found', $module.css(settings.animation));
401
476
  return true;
402
477
  }
403
478
  else {
404
- module.debug('Static animation found');
405
- $clone.remove();
479
+ module.debug('Unable to find css definition', $module.attr('class'));
406
480
  return false;
407
481
  }
482
+ },
483
+ transition: function() {
484
+ var
485
+ elementClass = $module.attr('class'),
486
+ animation = settings.animation,
487
+ transitionExists = module.get.transitionExists(settings.animation),
488
+ $clone,
489
+ currentAnimation,
490
+ inAnimation,
491
+ displayType
492
+ ;
493
+ if( transitionExists === undefined || instance.displayType === undefined) {
494
+ module.verbose('Determining whether animation exists');
495
+ $clone = $('<div>').addClass( elementClass ).appendTo($('body'));
496
+ currentAnimation = $clone
497
+ .removeClass(className.inward)
498
+ .removeClass(className.outward)
499
+ .addClass(className.animating)
500
+ .addClass(className.transition)
501
+ .addClass(animation)
502
+ .css(animationName)
503
+ ;
504
+ inAnimation = $clone
505
+ .addClass(className.inward)
506
+ .css(animationName)
507
+ ;
508
+ displayType = $clone
509
+ .attr('class', elementClass)
510
+ .show()
511
+ .css('display')
512
+ ;
513
+ module.verbose('Determining final display state', displayType);
514
+ if(currentAnimation != inAnimation) {
515
+ module.debug('Transition exists for animation', animation);
516
+ transitionExists = true;
517
+ }
518
+ else {
519
+ module.debug('Static animation found', animation, displayType);
520
+ transitionExists = false;
521
+ }
522
+ $clone.remove();
523
+ module.save.displayType(displayType);
524
+ module.save.transitionExists(animation, transitionExists);
525
+ }
526
+ return transitionExists;
408
527
  }
409
528
  },
410
529
 
@@ -412,6 +531,12 @@ $.fn.transition = function() {
412
531
  animating: function() {
413
532
  return $module.hasClass(className.animating);
414
533
  },
534
+ inward: function() {
535
+ return $module.hasClass(className.inward);
536
+ },
537
+ outward: function() {
538
+ return $module.hasClass(className.outward);
539
+ },
415
540
  looping: function() {
416
541
  return $module.hasClass(className.looping);
417
542
  },
@@ -425,20 +550,15 @@ $.fn.transition = function() {
425
550
 
426
551
  hide: function() {
427
552
  module.verbose('Hiding element');
428
- $module
429
- .removeClass(className.visible)
430
- .addClass(className.transition)
431
- .addClass(className.hidden)
432
- ;
553
+ module.remove.visible();
554
+ module.set.hidden();
433
555
  module.repaint();
434
556
  },
435
- show: function() {
436
- module.verbose('Showing element');
437
- $module
438
- .removeClass(className.hidden)
439
- .addClass(className.transition)
440
- .addClass(className.visible)
441
- ;
557
+
558
+ show: function(display) {
559
+ module.verbose('Showing element', display);
560
+ module.remove.hidden();
561
+ module.set.visible();
442
562
  module.repaint();
443
563
  },
444
564
 
@@ -561,13 +681,14 @@ $.fn.transition = function() {
561
681
  },
562
682
  invoke: function(query, passedArguments, context) {
563
683
  var
684
+ object = instance,
564
685
  maxDepth,
565
686
  found,
566
687
  response
567
688
  ;
568
689
  passedArguments = passedArguments || queryArguments;
569
690
  context = element || context;
570
- if(typeof query == 'string' && instance !== undefined) {
691
+ if(typeof query == 'string' && object !== undefined) {
571
692
  query = query.split(/[\. ]/);
572
693
  maxDepth = query.length - 1;
573
694
  $.each(query, function(depth, value) {
@@ -575,18 +696,18 @@ $.fn.transition = function() {
575
696
  ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
576
697
  : query
577
698
  ;
578
- if( $.isPlainObject( instance[camelCaseValue] ) && (depth != maxDepth) ) {
579
- instance = instance[camelCaseValue];
699
+ if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) {
700
+ object = object[camelCaseValue];
580
701
  }
581
- else if( instance[camelCaseValue] !== undefined ) {
582
- found = instance[camelCaseValue];
702
+ else if( object[camelCaseValue] !== undefined ) {
703
+ found = object[camelCaseValue];
583
704
  return false;
584
705
  }
585
- else if( $.isPlainObject( instance[value] ) && (depth != maxDepth) ) {
586
- instance = instance[value];
706
+ else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) {
707
+ object = object[value];
587
708
  }
588
- else if( instance[value] !== undefined ) {
589
- found = instance[value];
709
+ else if( object[value] !== undefined ) {
710
+ found = object[value];
590
711
  return false;
591
712
  }
592
713
  else {
@@ -621,6 +742,8 @@ $.fn.transition = function() {
621
742
  ;
622
743
  };
623
744
 
745
+ $.fn.transition.exists = {};
746
+
624
747
  $.fn.transition.settings = {
625
748
 
626
749
  // module info