semantic-ui-sass 0.19.3.1 → 1.7.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +21 -0
  3. data/README.md +5 -6
  4. data/app/assets/fonts/semantic-ui/icons.eot +0 -0
  5. data/app/assets/fonts/semantic-ui/icons.otf +0 -0
  6. data/app/assets/fonts/semantic-ui/icons.svg +472 -367
  7. data/app/assets/fonts/semantic-ui/icons.ttf +0 -0
  8. data/app/assets/fonts/semantic-ui/icons.woff +0 -0
  9. data/app/assets/images/semantic-ui/flags.png +0 -0
  10. data/app/assets/javascripts/semantic-ui.js +9 -5
  11. data/app/assets/javascripts/semantic-ui/accordion.js +169 -102
  12. data/app/assets/javascripts/semantic-ui/api.js +840 -0
  13. data/app/assets/javascripts/semantic-ui/checkbox.js +203 -46
  14. data/app/assets/javascripts/semantic-ui/{behavior/colorize.js → colorize.js} +4 -2
  15. data/app/assets/javascripts/semantic-ui/dimmer.js +110 -76
  16. data/app/assets/javascripts/semantic-ui/dropdown.js +897 -285
  17. data/app/assets/javascripts/semantic-ui/{behavior/form.js → form.js} +127 -42
  18. data/app/assets/javascripts/semantic-ui/modal.js +294 -219
  19. data/app/assets/javascripts/semantic-ui/nag.js +120 -186
  20. data/app/assets/javascripts/semantic-ui/popup.js +491 -223
  21. data/app/assets/javascripts/semantic-ui/progress.js +779 -0
  22. data/app/assets/javascripts/semantic-ui/rating.js +66 -22
  23. data/app/assets/javascripts/semantic-ui/search.js +219 -99
  24. data/app/assets/javascripts/semantic-ui/shape.js +72 -29
  25. data/app/assets/javascripts/semantic-ui/sidebar.js +678 -142
  26. data/app/assets/javascripts/semantic-ui/site.js +487 -0
  27. data/app/assets/javascripts/semantic-ui/{behavior/state.js → state.js} +116 -151
  28. data/app/assets/javascripts/semantic-ui/sticky.js +771 -0
  29. data/app/assets/javascripts/semantic-ui/tab.js +680 -603
  30. data/app/assets/javascripts/semantic-ui/transition.js +269 -158
  31. data/app/assets/javascripts/semantic-ui/video.js +113 -32
  32. data/app/assets/javascripts/semantic-ui/visibility.js +970 -0
  33. data/app/assets/javascripts/semantic-ui/visit.js +513 -0
  34. data/app/assets/stylesheets/semantic-ui.scss +2 -0
  35. data/app/assets/stylesheets/semantic-ui/collections/_breadcrumb.scss +58 -14
  36. data/app/assets/stylesheets/semantic-ui/collections/_form.scss +464 -372
  37. data/app/assets/stylesheets/semantic-ui/collections/_grid.scss +1385 -533
  38. data/app/assets/stylesheets/semantic-ui/collections/_menu.scss +482 -655
  39. data/app/assets/stylesheets/semantic-ui/collections/_message.scss +238 -139
  40. data/app/assets/stylesheets/semantic-ui/collections/_table.scss +631 -280
  41. data/app/assets/stylesheets/semantic-ui/elements/_all.scss +3 -2
  42. data/app/assets/stylesheets/semantic-ui/elements/_button.scss +1614 -657
  43. data/app/assets/stylesheets/semantic-ui/elements/_divider.scss +143 -80
  44. data/app/assets/stylesheets/semantic-ui/elements/_flag.scss +1018 -0
  45. data/app/assets/stylesheets/semantic-ui/elements/_header.scss +302 -145
  46. data/app/assets/stylesheets/semantic-ui/elements/_icon.scss +1653 -1365
  47. data/app/assets/stylesheets/semantic-ui/elements/_image.scss +160 -59
  48. data/app/assets/stylesheets/semantic-ui/elements/_input.scss +247 -118
  49. data/app/assets/stylesheets/semantic-ui/elements/_label.scss +501 -470
  50. data/app/assets/stylesheets/semantic-ui/elements/_list.scss +888 -0
  51. data/app/assets/stylesheets/semantic-ui/elements/_loader.scss +189 -98
  52. data/app/assets/stylesheets/semantic-ui/elements/_rail.scss +125 -0
  53. data/app/assets/stylesheets/semantic-ui/elements/_reveal.scss +147 -212
  54. data/app/assets/stylesheets/semantic-ui/elements/_segment.scss +328 -190
  55. data/app/assets/stylesheets/semantic-ui/elements/_step.scss +261 -185
  56. data/app/assets/stylesheets/semantic-ui/globals/_all.scss +2 -0
  57. data/app/assets/stylesheets/semantic-ui/globals/_reset.scss +430 -0
  58. data/app/assets/stylesheets/semantic-ui/globals/_site.scss +128 -0
  59. data/app/assets/stylesheets/semantic-ui/modules/_accordion.scss +190 -106
  60. data/app/assets/stylesheets/semantic-ui/modules/_all.scss +2 -1
  61. data/app/assets/stylesheets/semantic-ui/modules/_checkbox.scss +303 -201
  62. data/app/assets/stylesheets/semantic-ui/modules/_dimmer.scss +72 -63
  63. data/app/assets/stylesheets/semantic-ui/modules/_dropdown.scss +711 -331
  64. data/app/assets/stylesheets/semantic-ui/modules/_modal.scss +262 -140
  65. data/app/assets/stylesheets/semantic-ui/modules/_nag.scss +82 -71
  66. data/app/assets/stylesheets/semantic-ui/modules/_popup.scss +163 -119
  67. data/app/assets/stylesheets/semantic-ui/modules/_progress.scss +435 -0
  68. data/app/assets/stylesheets/semantic-ui/modules/_rating.scss +163 -68
  69. data/app/assets/stylesheets/semantic-ui/modules/_search.scss +223 -150
  70. data/app/assets/stylesheets/semantic-ui/modules/_shape.scss +39 -40
  71. data/app/assets/stylesheets/semantic-ui/modules/_sidebar.scss +413 -147
  72. data/app/assets/stylesheets/semantic-ui/modules/_sticky.scss +80 -0
  73. data/app/assets/stylesheets/semantic-ui/modules/_tab.scss +49 -20
  74. data/app/assets/stylesheets/semantic-ui/modules/_transition.scss +542 -568
  75. data/app/assets/stylesheets/semantic-ui/modules/_video.scss +69 -37
  76. data/app/assets/stylesheets/semantic-ui/views/_ad.scss +265 -0
  77. data/app/assets/stylesheets/semantic-ui/views/_all.scss +1 -1
  78. data/app/assets/stylesheets/semantic-ui/views/_card.scss +758 -0
  79. data/app/assets/stylesheets/semantic-ui/views/_comment.scss +133 -92
  80. data/app/assets/stylesheets/semantic-ui/views/_feed.scss +200 -87
  81. data/app/assets/stylesheets/semantic-ui/views/_item.scss +298 -523
  82. data/app/assets/stylesheets/semantic-ui/views/_statistic.scss +390 -12
  83. data/lib/semantic/ui/sass/version.rb +2 -2
  84. data/tasks/converter.rb +99 -216
  85. metadata +22 -27
  86. data/app/assets/fonts/semantic-ui/basic.icons.eot +0 -0
  87. data/app/assets/fonts/semantic-ui/basic.icons.svg +0 -450
  88. data/app/assets/fonts/semantic-ui/basic.icons.ttf +0 -0
  89. data/app/assets/fonts/semantic-ui/basic.icons.woff +0 -0
  90. data/app/assets/images/semantic-ui/loader-large-inverted.gif +0 -0
  91. data/app/assets/images/semantic-ui/loader-large.gif +0 -0
  92. data/app/assets/images/semantic-ui/loader-medium-inverted.gif +0 -0
  93. data/app/assets/images/semantic-ui/loader-medium.gif +0 -0
  94. data/app/assets/images/semantic-ui/loader-mini-inverted.gif +0 -0
  95. data/app/assets/images/semantic-ui/loader-mini.gif +0 -0
  96. data/app/assets/images/semantic-ui/loader-small-inverted.gif +0 -0
  97. data/app/assets/images/semantic-ui/loader-small.gif +0 -0
  98. data/app/assets/javascripts/semantic-ui/behavior/api.js +0 -634
  99. data/app/assets/javascripts/semantic-ui/chatroom.js +0 -772
  100. data/app/assets/stylesheets/semantic-ui/depends/_basic.icon.scss +0 -4
  101. data/app/assets/stylesheets/semantic-ui/depends/_icon.scss +0 -4
  102. data/app/assets/stylesheets/semantic-ui/depends/_loader.scss +0 -8
  103. data/app/assets/stylesheets/semantic-ui/elements/_basic.icon.scss +0 -1124
  104. data/app/assets/stylesheets/semantic-ui/elements/_progress.scss +0 -280
  105. data/app/assets/stylesheets/semantic-ui/modules/_chatroom.scss +0 -299
  106. data/app/assets/stylesheets/semantic-ui/modules/_reveal.scss +0 -322
  107. data/app/assets/stylesheets/semantic-ui/views/_list.scss +0 -700
@@ -1,9 +1,9 @@
1
1
  /*
2
2
  * # Semantic - Form Validation
3
- * http://github.com/jlukic/semantic-ui/
3
+ * http://github.com/semantic-org/semantic-ui/
4
4
  *
5
5
  *
6
- * Copyright 2014 Contributors
6
+ * Copyright 2014 Contributor
7
7
  * Released under the MIT license
8
8
  * http://opensource.org/licenses/MIT
9
9
  *
@@ -90,7 +90,18 @@ $.fn.form = function(fields, parameters) {
90
90
  ;
91
91
  },
92
92
 
93
+ attachEvents: function(selector, action) {
94
+ action = action || 'submit';
95
+ $(selector)
96
+ .on('click', function(event) {
97
+ module[action]();
98
+ event.preventDefault();
99
+ })
100
+ ;
101
+ },
102
+
93
103
  bindEvents: function() {
104
+
94
105
  if(settings.keyboardShortcuts) {
95
106
  $field
96
107
  .on('keydown' + eventNamespace, module.event.field.keydown)
@@ -102,9 +113,9 @@ $.fn.form = function(fields, parameters) {
102
113
  $field
103
114
  .on('blur' + eventNamespace, module.event.field.blur)
104
115
  ;
105
- $submit
106
- .on('click' + eventNamespace, module.submit)
107
- ;
116
+ // attach submit events
117
+ module.attachEvents($submit, 'submit');
118
+
108
119
  $field
109
120
  .each(function() {
110
121
  var
@@ -150,7 +161,7 @@ $.fn.form = function(fields, parameters) {
150
161
  .blur()
151
162
  ;
152
163
  }
153
- if(!event.ctrlKey && key == keyCode.enter && $field.is(selector.input) ) {
164
+ if(!event.ctrlKey && key == keyCode.enter && $field.is(selector.input) && $field.not(selector.checkbox).size() > 0 ) {
154
165
  module.debug('Enter key pressed, submitting form');
155
166
  $submit
156
167
  .addClass(className.down)
@@ -158,8 +169,6 @@ $.fn.form = function(fields, parameters) {
158
169
  $field
159
170
  .one('keyup' + eventNamespace, module.event.field.keyup)
160
171
  ;
161
- event.preventDefault();
162
- return false;
163
172
  }
164
173
  },
165
174
  keyup: function() {
@@ -334,11 +343,27 @@ $.fn.form = function(fields, parameters) {
334
343
  }
335
344
  },
336
345
 
346
+ set: {
347
+ success: function() {
348
+ $module
349
+ .removeClass(className.error)
350
+ .addClass(className.success)
351
+ ;
352
+ },
353
+ error: function() {
354
+ $module
355
+ .removeClass(className.success)
356
+ .addClass(className.error)
357
+ ;
358
+ }
359
+ },
360
+
337
361
  validate: {
338
362
 
339
363
  form: function(event) {
340
364
  var
341
- allValid = true
365
+ allValid = true,
366
+ apiRequest
342
367
  ;
343
368
  // reset errors
344
369
  formErrors = [];
@@ -349,19 +374,20 @@ $.fn.form = function(fields, parameters) {
349
374
  });
350
375
  if(allValid) {
351
376
  module.debug('Form has no validation errors, submitting');
352
- $module
353
- .removeClass(className.error)
354
- .addClass(className.success)
355
- ;
356
- return $.proxy(settings.onSuccess, this)(event);
377
+ module.set.success();
378
+ return $.proxy(settings.onSuccess, element)(event);
357
379
  }
358
380
  else {
359
381
  module.debug('Form has errors');
360
- $module.addClass(className.error);
382
+ module.set.error();
361
383
  if(!settings.inline) {
362
384
  module.add.errors(formErrors);
363
385
  }
364
- return $.proxy(settings.onFailure, this)(formErrors);
386
+ // prevent ajax submit
387
+ if($module.data('moduleApi') !== undefined) {
388
+ event.stopImmediatePropagation();
389
+ }
390
+ return $.proxy(settings.onFailure, element)(formErrors);
365
391
  }
366
392
  },
367
393
 
@@ -372,7 +398,15 @@ $.fn.form = function(fields, parameters) {
372
398
  fieldValid = true,
373
399
  fieldErrors = []
374
400
  ;
375
- if(field.rules !== undefined) {
401
+ if($field.prop('disabled')) {
402
+ module.debug('Field is disabled. Skipping', field.identifier);
403
+ fieldValid = true;
404
+ }
405
+ else if(field.optional && $.trim($field.val()) === ''){
406
+ module.debug('Field is optional and empty. Skipping', field.identifier);
407
+ fieldValid = true;
408
+ }
409
+ else if(field.rules !== undefined) {
376
410
  $.each(field.rules, function(index, rule) {
377
411
  if( module.has.field(field.identifier) && !( module.validate.rule(field, rule) ) ) {
378
412
  module.debug('Field is invalid', field.identifier, rule.type);
@@ -411,7 +445,7 @@ $.fn.form = function(fields, parameters) {
411
445
  if(bracket !== undefined && bracket !== null) {
412
446
  ancillary = '' + bracket[1];
413
447
  functionType = type.replace(bracket[0], '');
414
- isValid = $.proxy(settings.rules[functionType], $module)(value, ancillary);
448
+ isValid = $.proxy(settings.rules[functionType], element)(value, ancillary);
415
449
  }
416
450
  // normal notation
417
451
  else {
@@ -482,9 +516,9 @@ $.fn.form = function(fields, parameters) {
482
516
  executionTime = currentTime - previousTime;
483
517
  time = currentTime;
484
518
  performance.push({
485
- 'Element' : element,
486
519
  'Name' : message[0],
487
520
  'Arguments' : [].slice.call(message, 1) || '',
521
+ 'Element' : element,
488
522
  'Execution Time' : executionTime
489
523
  });
490
524
  }
@@ -604,7 +638,7 @@ $.fn.form.settings = {
604
638
  name : 'Form',
605
639
  namespace : 'form',
606
640
 
607
- debug : true,
641
+ debug : false,
608
642
  verbose : true,
609
643
  performance : true,
610
644
 
@@ -617,7 +651,7 @@ $.fn.form.settings = {
617
651
  revalidate : true,
618
652
 
619
653
  transition : 'scale',
620
- duration : 150,
654
+ duration : 200,
621
655
 
622
656
 
623
657
  onValid : function() {},
@@ -633,24 +667,23 @@ $.fn.form.settings = {
633
667
  message : '.error.message',
634
668
  field : 'input, textarea, select',
635
669
  group : '.field',
670
+ checkbox: 'input[type="checkbox"], input[type="radio"]',
636
671
  input : 'input',
637
672
  prompt : '.prompt',
638
- submit : '.submit:not([type="submit"])'
673
+ submit : '.submit'
639
674
  },
640
675
 
641
676
  className : {
642
677
  error : 'error',
643
678
  success : 'success',
644
679
  down : 'down',
645
- label : 'ui label prompt'
680
+ label : 'ui prompt label'
646
681
  },
647
682
 
648
- // errors
649
683
  error: {
650
684
  method : 'The method you called is not defined.'
651
685
  },
652
686
 
653
-
654
687
  templates: {
655
688
  error: function(errors) {
656
689
  var
@@ -671,40 +704,77 @@ $.fn.form.settings = {
671
704
  },
672
705
 
673
706
  rules: {
707
+
708
+ // checkbox checked
674
709
  checked: function() {
675
710
  return ($(this).filter(':checked').size() > 0);
676
711
  },
677
- empty: function(value) {
678
- return !(value === undefined || '' === value);
712
+
713
+ // value contains (text)
714
+ contains: function(value, text) {
715
+ text = text.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
716
+ return (value.search(text) !== -1);
679
717
  },
718
+
719
+ // is most likely an email
680
720
  email: function(value){
681
721
  var
682
722
  emailRegExp = new RegExp("[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", "i")
683
723
  ;
684
724
  return emailRegExp.test(value);
685
725
  },
686
- length: function(value, requiredLength) {
687
- return (value !== undefined)
688
- ? (value.length >= requiredLength)
689
- : false
690
- ;
691
- },
692
- not: function(value, notValue) {
693
- return (value != notValue);
726
+
727
+ // is not empty or blank string
728
+ empty: function(value) {
729
+ return !(value === undefined || '' === value);
694
730
  },
695
- contains: function(value, text) {
696
- text = text.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
697
- return (value.search(text) !== -1);
731
+
732
+ // is valid integer
733
+ integer: function(value, range) {
734
+ var
735
+ intRegExp = /^\-?\d+$/,
736
+ min,
737
+ max,
738
+ parts
739
+ ;
740
+ if (range === undefined || range === '' || range === '..') {
741
+ // do nothing
742
+ }
743
+ else if (range.indexOf('..') == -1) {
744
+ if (intRegExp.test(range)) {
745
+ min = max = range - 0;
746
+ }
747
+ }
748
+ else {
749
+ parts = range.split('..', 2);
750
+ if (intRegExp.test(parts[0])) {
751
+ min = parts[0] - 0;
752
+ }
753
+ if (intRegExp.test(parts[1])) {
754
+ max = parts[1] - 0;
755
+ }
756
+ }
757
+ return (
758
+ intRegExp.test(value) &&
759
+ (min === undefined || value >= min) &&
760
+ (max === undefined || value <= max)
761
+ );
698
762
  },
763
+
764
+ // is exactly value
699
765
  is: function(value, text) {
700
766
  return (value == text);
701
767
  },
702
- maxLength: function(value, maxLength) {
768
+
769
+ // is at least string length
770
+ length: function(value, requiredLength) {
703
771
  return (value !== undefined)
704
- ? (value.length <= maxLength)
772
+ ? (value.length >= requiredLength)
705
773
  : false
706
774
  ;
707
775
  },
776
+
777
+ // matches another field
708
778
  match: function(value, fieldIdentifier) {
709
779
  // use either id or name of field
710
780
  var
@@ -714,8 +784,8 @@ $.fn.form.settings = {
714
784
  if($form.find('#' + fieldIdentifier).size() > 0) {
715
785
  matchingValue = $form.find('#' + fieldIdentifier).val();
716
786
  }
717
- else if($form.find('[name=' + fieldIdentifier +']').size() > 0) {
718
- matchingValue = $form.find('[name=' + fieldIdentifier + ']').val();
787
+ else if($form.find('[name="' + fieldIdentifier +'"]').size() > 0) {
788
+ matchingValue = $form.find('[name="' + fieldIdentifier + '"]').val();
719
789
  }
720
790
  else if( $form.find('[data-validate="'+ fieldIdentifier +'"]').size() > 0 ) {
721
791
  matchingValue = $form.find('[data-validate="'+ fieldIdentifier +'"]').val();
@@ -725,6 +795,21 @@ $.fn.form.settings = {
725
795
  : false
726
796
  ;
727
797
  },
798
+
799
+ // string length is less than max length
800
+ maxLength: function(value, maxLength) {
801
+ return (value !== undefined)
802
+ ? (value.length <= maxLength)
803
+ : false
804
+ ;
805
+ },
806
+
807
+ // value is not exactly notValue
808
+ not: function(value, notValue) {
809
+ return (value != notValue);
810
+ },
811
+
812
+ // value is most likely url
728
813
  url: function(value) {
729
814
  var
730
815
  urlRegExp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/
@@ -3,7 +3,7 @@
3
3
  * http://github.com/semantic-org/semantic-ui/
4
4
  *
5
5
  *
6
- * Copyright 2014 Contributors
6
+ * Copyright 2014 Contributor
7
7
  * Released under the MIT license
8
8
  * http://opensource.org/licenses/MIT
9
9
  *
@@ -11,19 +11,23 @@
11
11
 
12
12
  ;(function ( $, window, document, undefined ) {
13
13
 
14
+ "use strict";
15
+
14
16
  $.fn.modal = function(parameters) {
15
17
  var
16
- $allModules = $(this),
17
- $window = $(window),
18
- $document = $(document),
19
- $body = $('body'),
18
+ $allModules = $(this),
19
+ $window = $(window),
20
+ $document = $(document),
21
+ $body = $('body'),
22
+
23
+ moduleSelector = $allModules.selector || '',
20
24
 
21
- time = new Date().getTime(),
22
- performance = [],
25
+ time = new Date().getTime(),
26
+ performance = [],
23
27
 
24
- query = arguments[0],
25
- methodInvoked = (typeof query == 'string'),
26
- queryArguments = [].slice.call(arguments, 1),
28
+ query = arguments[0],
29
+ methodInvoked = (typeof query == 'string'),
30
+ queryArguments = [].slice.call(arguments, 1),
27
31
 
28
32
  requestAnimationFrame = window.requestAnimationFrame
29
33
  || window.mozRequestAnimationFrame
@@ -34,7 +38,6 @@ $.fn.modal = function(parameters) {
34
38
  returnedValue
35
39
  ;
36
40
 
37
-
38
41
  $allModules
39
42
  .each(function() {
40
43
  var
@@ -49,11 +52,10 @@ $.fn.modal = function(parameters) {
49
52
 
50
53
  eventNamespace = '.' + namespace,
51
54
  moduleNamespace = 'module-' + namespace,
52
- moduleSelector = $allModules.selector || '',
53
55
 
54
- $module = $(this),
55
- $context = $(settings.context),
56
- $close = $module.find(selector.close),
56
+ $module = $(this),
57
+ $context = $(settings.context),
58
+ $close = $module.find(selector.close),
57
59
 
58
60
  $allModals,
59
61
  $otherModals,
@@ -61,48 +63,26 @@ $.fn.modal = function(parameters) {
61
63
  $dimmable,
62
64
  $dimmer,
63
65
 
64
- element = this,
65
- instance = $module.data(moduleNamespace),
66
+ element = this,
67
+ instance = $module.data(moduleNamespace),
68
+
69
+ elementNamespace,
70
+ id,
71
+ observer,
66
72
  module
67
73
  ;
68
-
69
74
  module = {
70
75
 
71
76
  initialize: function() {
72
77
  module.verbose('Initializing dimmer', $context);
73
78
 
74
- if($.fn.dimmer === undefined) {
75
- module.error(error.dimmer);
76
- return;
77
- }
78
- $dimmable = $context
79
- .dimmer({
80
- closable : false,
81
- useCSS : true,
82
- duration : {
83
- show : settings.duration * 0.9,
84
- hide : settings.duration * 1.1
85
- }
86
- })
87
- ;
88
-
89
- if(settings.detachable) {
90
- $dimmable.dimmer('add content', $module);
91
- }
92
-
93
- $dimmer = $dimmable
94
- .dimmer('get dimmer')
95
- ;
96
-
97
- module.refreshSelectors();
79
+ module.create.id();
80
+ module.create.dimmer();
81
+ module.refreshModals();
98
82
 
99
83
  module.verbose('Attaching close events', $close);
100
- $close
101
- .on('click' + eventNamespace, module.event.close)
102
- ;
103
- $window
104
- .on('resize' + eventNamespace, module.event.resize)
105
- ;
84
+ module.bind.events();
85
+ module.observeChanges();
106
86
  module.instantiate();
107
87
  },
108
88
 
@@ -114,18 +94,61 @@ $.fn.modal = function(parameters) {
114
94
  ;
115
95
  },
116
96
 
97
+ create: {
98
+ dimmer: function() {
99
+ var
100
+ defaultSettings = {
101
+ debug : settings.debug,
102
+ dimmerName : 'modals',
103
+ duration : {
104
+ show : settings.duration,
105
+ hide : settings.duration
106
+ }
107
+ },
108
+ dimmerSettings = $.extend(true, defaultSettings, settings.dimmerSettings)
109
+ ;
110
+ if($.fn.dimmer === undefined) {
111
+ module.error(error.dimmer);
112
+ return;
113
+ }
114
+ module.debug('Creating dimmer with settings', dimmerSettings);
115
+ $dimmable = $context.dimmer(dimmerSettings);
116
+ if(settings.detachable) {
117
+ module.verbose('Modal is detachable, moving content into dimmer');
118
+ $dimmable.dimmer('add content', $module);
119
+ }
120
+ $dimmer = $dimmable.dimmer('get dimmer');
121
+ },
122
+ id: function() {
123
+ module.verbose('Creating unique id for element');
124
+ id = module.get.uniqueID();
125
+ elementNamespace = '.' + id;
126
+ }
127
+ },
128
+
117
129
  destroy: function() {
118
130
  module.verbose('Destroying previous modal');
119
131
  $module
120
132
  .removeData(moduleNamespace)
121
133
  .off(eventNamespace)
122
134
  ;
123
- $close
124
- .off(eventNamespace)
125
- ;
126
- $context
127
- .dimmer('destroy')
128
- ;
135
+ $window.off(elementNamespace);
136
+ $close.off(eventNamespace);
137
+ $context.dimmer('destroy');
138
+ },
139
+
140
+ observeChanges: function() {
141
+ if('MutationObserver' in window) {
142
+ observer = new MutationObserver(function(mutations) {
143
+ module.debug('DOM tree modified, refreshing');
144
+ module.refresh();
145
+ });
146
+ observer.observe(element, {
147
+ childList : true,
148
+ subtree : true
149
+ });
150
+ module.debug('Setting up mutation observer', observer);
151
+ }
129
152
  },
130
153
 
131
154
  refresh: function() {
@@ -136,7 +159,7 @@ $.fn.modal = function(parameters) {
136
159
  module.set.position();
137
160
  },
138
161
 
139
- refreshSelectors: function() {
162
+ refreshModals: function() {
140
163
  $otherModals = $module.siblings(selector.modal);
141
164
  $allModals = $otherModals.add($module);
142
165
  },
@@ -157,7 +180,24 @@ $.fn.modal = function(parameters) {
157
180
  ;
158
181
  }
159
182
  else {
160
- module.error(error.notFound);
183
+ module.error(error.notFound, selector);
184
+ }
185
+ },
186
+
187
+ bind: {
188
+ events: function() {
189
+ $close
190
+ .on('click' + eventNamespace, module.event.close)
191
+ ;
192
+ $window
193
+ .on('resize' + elementNamespace, module.event.resize)
194
+ ;
195
+ }
196
+ },
197
+
198
+ get: {
199
+ uniqueID: function() {
200
+ return (Math.random().toString(16) + '000000000').substr(2,8);
161
201
  }
162
202
  },
163
203
 
@@ -185,15 +225,17 @@ $.fn.modal = function(parameters) {
185
225
  }
186
226
  },
187
227
  click: function(event) {
188
- if( $(event.target).closest(selector.modal).size() === 0 ) {
228
+ if( $(event.target).closest($module).size() === 0 ) {
189
229
  module.debug('Dimmer clicked, hiding all modals');
190
- if(settings.allowMultiple) {
191
- module.hide();
192
- }
193
- else {
194
- module.hideAll();
230
+ if( module.is.active() ) {
231
+ module.remove.clickaway();
232
+ if(settings.allowMultiple) {
233
+ module.hide();
234
+ }
235
+ else {
236
+ module.hideAll();
237
+ }
195
238
  }
196
- event.stopImmediatePropagation();
197
239
  }
198
240
  },
199
241
  debounce: function(method, delay) {
@@ -224,7 +266,7 @@ $.fn.modal = function(parameters) {
224
266
  },
225
267
 
226
268
  toggle: function() {
227
- if( module.is.active() ) {
269
+ if( module.is.active() || module.is.animating() ) {
228
270
  module.hide();
229
271
  }
230
272
  else {
@@ -237,146 +279,149 @@ $.fn.modal = function(parameters) {
237
279
  ? callback
238
280
  : function(){}
239
281
  ;
240
- module.showDimmer();
282
+ module.refreshModals();
241
283
  module.showModal(callback);
242
284
  },
243
285
 
244
- onlyVisible: function() {
245
- module.refreshSelectors();
246
- return module.is.active() && $otherModals.filter(':visible').size() === 0;
247
- },
248
-
249
- othersVisible: function() {
250
- module.refreshSelectors();
251
- return $otherModals.filter(':visible').size() > 0;
286
+ hide: function(callback) {
287
+ callback = $.isFunction(callback)
288
+ ? callback
289
+ : function(){}
290
+ ;
291
+ module.refreshModals();
292
+ module.hideModal(callback);
252
293
  },
253
294
 
254
295
  showModal: function(callback) {
255
- if(module.is.active()) {
256
- module.debug('Modal is already visible');
257
- return;
258
- }
259
-
260
296
  callback = $.isFunction(callback)
261
297
  ? callback
262
298
  : function(){}
263
299
  ;
300
+ if( module.is.animating() || !module.is.active() ) {
264
301
 
265
- module.save.focus();
266
- module.add.keyboardShortcuts();
267
-
268
- if(module.cache === undefined) {
302
+ module.showDimmer();
269
303
  module.cacheSizes();
270
- }
271
- module.set.position();
272
- module.set.screenHeight();
273
- module.set.type();
274
-
275
- if(module.othersVisible() && !settings.allowMultiple) {
276
- module.debug('Other modals visible, queueing show animation');
277
- module.hideOthers(module.showModal);
304
+ module.set.position();
305
+ module.set.screenHeight();
306
+ module.set.type();
307
+ module.set.clickaway();
308
+
309
+ if( !settings.allowMultiple && $otherModals.filter(':visible').size() > 0) {
310
+ module.debug('Other modals visible, queueing show animation');
311
+ module.hideOthers(module.showModal);
312
+ }
313
+ else {
314
+ $.proxy(settings.onShow, element)();
315
+ if(settings.transition && $.fn.transition !== undefined && $module.transition('is supported')) {
316
+ module.debug('Showing modal with css animations');
317
+ $module
318
+ .transition({
319
+ debug : settings.debug,
320
+ animation : settings.transition + ' in',
321
+ queue : settings.queue,
322
+ duration : settings.duration,
323
+ useFailSafe : true,
324
+ onComplete : function() {
325
+ $.proxy(settings.onVisible, element)();
326
+ module.add.keyboardShortcuts();
327
+ module.save.focus();
328
+ module.set.active();
329
+ module.set.autofocus();
330
+ callback();
331
+ }
332
+ })
333
+ ;
334
+ }
335
+ else {
336
+ module.debug('Showing modal with javascript');
337
+ $module
338
+ .fadeIn(settings.duration, settings.easing, function() {
339
+ $.proxy(settings.onVisible, element)();
340
+ module.add.keyboardShortcuts();
341
+ module.save.focus();
342
+ module.set.active();
343
+ callback();
344
+ })
345
+ ;
346
+ }
347
+ }
278
348
  }
279
349
  else {
280
- $.proxy(settings.onShow, element)();
350
+ module.debug('Modal is already visible');
351
+ }
352
+ },
281
353
 
282
- var transitionCallback = function() {
283
- module.set.active();
284
- $.proxy(settings.onVisible, element)();
285
- callback();
286
- };
354
+ hideModal: function(callback) {
355
+ callback = $.isFunction(callback)
356
+ ? callback
357
+ : function(){}
358
+ ;
359
+ module.debug('Hiding modal');
360
+ $.proxy(settings.onHide, element)();
287
361
 
362
+ if( module.is.animating() || module.is.active() ) {
288
363
  if(settings.transition && $.fn.transition !== undefined && $module.transition('is supported')) {
289
- module.debug('Showing modal with css animations');
364
+ module.remove.active();
290
365
  $module
291
- .transition(settings.transition + ' in', settings.duration, transitionCallback)
366
+ .transition({
367
+ debug : settings.debug,
368
+ animation : settings.transition + ' out',
369
+ queue : settings.queue,
370
+ duration : settings.duration,
371
+ useFailSafe : true,
372
+ onStart : function() {
373
+ if( !module.othersActive() ) {
374
+ module.hideDimmer();
375
+ }
376
+ module.remove.keyboardShortcuts();
377
+ },
378
+ onComplete : function() {
379
+ $.proxy(settings.onHidden, element)();
380
+ module.restore.focus();
381
+ callback();
382
+ }
383
+ })
292
384
  ;
293
385
  }
294
386
  else {
295
- module.debug('Showing modal with javascript');
387
+ module.remove.active();
388
+ if( !module.othersActive() ) {
389
+ module.hideDimmer();
390
+ }
391
+ module.remove.keyboardShortcuts();
296
392
  $module
297
- .fadeIn(settings.duration, settings.easing, transitionCallback)
393
+ .fadeOut(settings.duration, settings.easing, function() {
394
+ $.proxy(settings.onHidden, element)();
395
+ module.restore.focus();
396
+ callback();
397
+ })
298
398
  ;
299
399
  }
300
400
  }
301
401
  },
302
402
 
303
403
  showDimmer: function() {
304
- if( !$dimmable.dimmer('is active') ) {
404
+ if($dimmable.dimmer('is animating') || !$dimmable.dimmer('is active') ) {
305
405
  module.debug('Showing dimmer');
306
406
  $dimmable.dimmer('show');
307
407
  }
308
408
  else {
309
- module.debug('Dimmer is already visible');
310
- }
311
- },
312
-
313
- hide: function(callback) {
314
- callback = $.isFunction(callback)
315
- ? callback
316
- : function(){}
317
- ;
318
- module.refreshSelectors();
319
- if(module.onlyVisible()) {
320
- module.hideDimmer();
409
+ module.debug('Dimmer already visible');
321
410
  }
322
- module.hideModal(callback);
323
411
  },
324
412
 
325
413
  hideDimmer: function() {
326
- if( !module.is.active() ) {
327
- module.debug('Dimmer is already hidden');
328
- return;
329
- }
330
- module.debug('Hiding dimmer');
331
- if(settings.closable) {
332
- $dimmer
333
- .off('click' + eventNamespace)
334
- ;
335
- }
336
- $dimmable.dimmer('hide', function() {
337
- if(settings.transition && $.fn.transition !== undefined && $module.transition('is supported')) {
338
- $module
339
- .transition('reset')
340
- ;
341
- module.remove.screenHeight();
342
- }
343
- module.remove.active();
344
- });
345
- },
346
-
347
- hideModal: function(callback) {
348
- if(!module.is.active()) {
349
- module.debug('Modal is already hidden');
350
- return;
351
- }
352
-
353
- callback = $.isFunction(callback)
354
- ? callback
355
- : function(){}
356
- ;
357
-
358
- module.restore.focus();
359
- module.remove.keyboardShortcuts();
360
-
361
- $.proxy(settings.onHide, element)();
362
-
363
- var transitionCallback = function() {
364
- module.remove.active();
365
- $.proxy(settings.onHidden, element)();
366
- callback();
367
- };
368
-
369
- if(settings.transition && $.fn.transition !== undefined && $module.transition('is supported')) {
370
- module.debug('Hiding modal with css animations');
371
- $module
372
- .transition(settings.transition + ' out', settings.duration, transitionCallback)
373
- ;
414
+ if( $dimmable.dimmer('is animating') || ($dimmable.dimmer('is active')) ) {
415
+ $dimmable.dimmer('hide', function() {
416
+ if(settings.transition && $.fn.transition !== undefined && $module.transition('is supported')) {
417
+ module.remove.clickaway();
418
+ module.remove.screenHeight();
419
+ }
420
+ });
374
421
  }
375
422
  else {
376
- module.debug('Hiding modal with javascript');
377
- $module
378
- .fadeOut(settings.duration, settings.easing, transitionCallback)
379
- ;
423
+ module.debug('Dimmer is not visible cannot hide');
424
+ return;
380
425
  }
381
426
  },
382
427
 
@@ -385,7 +430,7 @@ $.fn.modal = function(parameters) {
385
430
  ? callback
386
431
  : function(){}
387
432
  ;
388
- if( $module.is(':visible') || module.othersVisible() ) {
433
+ if( $allModals.is(':visible') ) {
389
434
  module.debug('Hiding all visible modals');
390
435
  module.hideDimmer();
391
436
  $allModals
@@ -400,8 +445,8 @@ $.fn.modal = function(parameters) {
400
445
  ? callback
401
446
  : function(){}
402
447
  ;
403
- if( module.othersVisible() ) {
404
- module.debug('Hiding other modals');
448
+ if( $otherModals.is(':visible') ) {
449
+ module.debug('Hiding other modals', $otherModals);
405
450
  $otherModals
406
451
  .filter(':visible')
407
452
  .modal('hide modal', callback)
@@ -409,6 +454,10 @@ $.fn.modal = function(parameters) {
409
454
  }
410
455
  },
411
456
 
457
+ othersActive: function() {
458
+ return ($otherModals.filter('.' + className.active).size() > 0);
459
+ },
460
+
412
461
  add: {
413
462
  keyboardShortcuts: function() {
414
463
  module.verbose('Adding keyboard shortcuts');
@@ -436,6 +485,13 @@ $.fn.modal = function(parameters) {
436
485
  active: function() {
437
486
  $module.removeClass(className.active);
438
487
  },
488
+ clickaway: function() {
489
+ if(settings.closable) {
490
+ $dimmer
491
+ .off('click' + elementNamespace)
492
+ ;
493
+ }
494
+ },
439
495
  screenHeight: function() {
440
496
  if(module.cache.height > module.cache.pageHeight) {
441
497
  module.debug('Removing page height');
@@ -456,12 +512,11 @@ $.fn.modal = function(parameters) {
456
512
  }
457
513
  },
458
514
 
459
-
460
515
  cacheSizes: function() {
461
516
  var
462
517
  modalHeight = $module.outerHeight()
463
518
  ;
464
- if(modalHeight !== 0) {
519
+ if(module.cache === undefined || modalHeight !== 0) {
465
520
  module.cache = {
466
521
  pageHeight : $(document).outerHeight(),
467
522
  height : modalHeight + settings.offset,
@@ -469,11 +524,10 @@ $.fn.modal = function(parameters) {
469
524
  ? $(window).height()
470
525
  : $dimmable.height()
471
526
  };
472
- module.debug('Caching modal and container sizes', module.cache);
473
527
  }
528
+ module.debug('Caching modal and container sizes', module.cache);
474
529
  },
475
530
 
476
-
477
531
  can: {
478
532
  fit: function() {
479
533
  return (module.cache.height < module.cache.contextHeight);
@@ -484,6 +538,15 @@ $.fn.modal = function(parameters) {
484
538
  active: function() {
485
539
  return $module.hasClass(className.active);
486
540
  },
541
+ animating: function() {
542
+ return $module.transition('is supported')
543
+ ? $module.transition('is animating')
544
+ : $module.is(':visible')
545
+ ;
546
+ },
547
+ scrolling: function() {
548
+ return $dimmable.hasClass(className.scrolling);
549
+ },
487
550
  modernBrowser: function() {
488
551
  // appName for IE11 reports 'Netscape' can no longer use
489
552
  return !(window.ActiveXObject || "ActiveXObject" in window);
@@ -491,6 +554,25 @@ $.fn.modal = function(parameters) {
491
554
  },
492
555
 
493
556
  set: {
557
+ autofocus: function() {
558
+ if(settings.autofocus) {
559
+ var
560
+ $inputs = $module.find(':input:visible'),
561
+ $autofocus = $inputs.filter('[autofocus]'),
562
+ $input = ($autofocus.size() > 0)
563
+ ? $autofocus
564
+ : $inputs
565
+ ;
566
+ $input.first().focus();
567
+ }
568
+ },
569
+ clickaway: function() {
570
+ if(settings.closable) {
571
+ $dimmer
572
+ .on('click' + elementNamespace, module.event.click)
573
+ ;
574
+ }
575
+ },
494
576
  screenHeight: function() {
495
577
  if(module.cache.height > module.cache.pageHeight) {
496
578
  module.debug('Modal is taller than page content, resizing page height');
@@ -498,24 +580,12 @@ $.fn.modal = function(parameters) {
498
580
  .css('height', module.cache.height + settings.padding)
499
581
  ;
500
582
  }
583
+ else {
584
+ $body.css('height', '');
585
+ }
501
586
  },
502
587
  active: function() {
503
588
  $module.addClass(className.active);
504
-
505
- if(settings.closable) {
506
- $dimmer
507
- .off('click' + eventNamespace)
508
- .on('click' + eventNamespace, module.event.click)
509
- ;
510
- }
511
-
512
- if(settings.autofocus) {
513
- var $inputs = $module.find(':input:visible');
514
- var $autofocus = $inputs.filter('[autofocus]');
515
- var $input = $autofocus.length ? $autofocus : $inputs;
516
-
517
- $input.first().focus();
518
- }
519
589
  },
520
590
  scrolling: function() {
521
591
  $dimmable.addClass(className.scrolling);
@@ -524,7 +594,9 @@ $.fn.modal = function(parameters) {
524
594
  type: function() {
525
595
  if(module.can.fit()) {
526
596
  module.verbose('Modal fits on screen');
527
- module.remove.scrolling();
597
+ if(!module.othersActive) {
598
+ module.remove.scrolling();
599
+ }
528
600
  }
529
601
  else {
530
602
  module.verbose('Modal cannot fit on screen setting to scrolling');
@@ -544,7 +616,7 @@ $.fn.modal = function(parameters) {
544
616
  else {
545
617
  $module
546
618
  .css({
547
- marginTop : '1em',
619
+ marginTop : '',
548
620
  top : $document.scrollTop()
549
621
  })
550
622
  ;
@@ -614,9 +686,9 @@ $.fn.modal = function(parameters) {
614
686
  executionTime = currentTime - previousTime;
615
687
  time = currentTime;
616
688
  performance.push({
617
- 'Element' : element,
618
689
  'Name' : message[0],
619
690
  'Arguments' : [].slice.call(message, 1) || '',
691
+ 'Element' : element,
620
692
  'Execution Time' : executionTime
621
693
  });
622
694
  }
@@ -730,34 +802,41 @@ $.fn.modal = function(parameters) {
730
802
 
731
803
  $.fn.modal.settings = {
732
804
 
733
- name : 'Modal',
734
- namespace : 'modal',
805
+ name : 'Modal',
806
+ namespace : 'modal',
735
807
 
736
- debug : false,
737
- verbose : true,
738
- performance : true,
808
+ debug : false,
809
+ verbose : true,
810
+ performance : true,
739
811
 
740
- allowMultiple : true,
741
- detachable : true,
742
- closable : true,
743
- autofocus : true,
744
- context : 'body',
812
+ allowMultiple : false,
813
+ detachable : true,
814
+ closable : true,
815
+ autofocus : true,
745
816
 
746
- duration : 500,
747
- easing : 'easeOutQuad',
748
- offset : 0,
749
- transition : 'scale',
817
+ dimmerSettings : {
818
+ closable : false,
819
+ useCSS : true
820
+ },
821
+
822
+ context : 'body',
750
823
 
751
- padding : 30,
824
+ queue : false,
825
+ duration : 500,
826
+ easing : 'easeOutExpo',
827
+ offset : 0,
828
+ transition : 'scale',
752
829
 
753
- onShow : function(){},
754
- onHide : function(){},
830
+ padding : 30,
755
831
 
756
- onVisible : function(){},
757
- onHidden : function(){},
832
+ onShow : function(){},
833
+ onHide : function(){},
758
834
 
759
- onApprove : function(){ return true; },
760
- onDeny : function(){ return true; },
835
+ onVisible : function(){},
836
+ onHidden : function(){},
837
+
838
+ onApprove : function(){ return true; },
839
+ onDeny : function(){ return true; },
761
840
 
762
841
  selector : {
763
842
  close : '.close, .actions .button',
@@ -767,19 +846,15 @@ $.fn.modal.settings = {
767
846
  },
768
847
  error : {
769
848
  dimmer : 'UI Dimmer, a required component is not included in this page',
770
- method : 'The method you called is not defined.'
849
+ method : 'The method you called is not defined.',
850
+ notFound : 'The element you specified could not be found'
771
851
  },
772
852
  className : {
773
853
  active : 'active',
854
+ animating : 'animating',
774
855
  scrolling : 'scrolling'
775
856
  }
776
857
  };
777
858
 
778
- // Adds easing
779
- $.extend( $.easing, {
780
- easeOutQuad: function (x, t, b, c, d) {
781
- return -c *(t/=d)*(t-2) + b;
782
- }
783
- });
784
859
 
785
860
  })( jQuery, window , document );