fomantic-ui-sass 2.8.7.1 → 2.8.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -0
  3. data/app/assets/javascripts/semantic-ui/calendar.js +9 -11
  4. data/app/assets/javascripts/semantic-ui/dimmer.js +8 -11
  5. data/app/assets/javascripts/semantic-ui/dropdown.js +191 -99
  6. data/app/assets/javascripts/semantic-ui/form.js +98 -60
  7. data/app/assets/javascripts/semantic-ui/modal.js +259 -16
  8. data/app/assets/javascripts/semantic-ui/nag.js +130 -64
  9. data/app/assets/javascripts/semantic-ui/popup.js +4 -4
  10. data/app/assets/javascripts/semantic-ui/progress.js +6 -8
  11. data/app/assets/javascripts/semantic-ui/search.js +14 -12
  12. data/app/assets/javascripts/semantic-ui/slider.js +55 -31
  13. data/app/assets/javascripts/semantic-ui/toast.js +26 -6
  14. data/app/assets/stylesheets/semantic-ui/collections/_breadcrumb.scss +1 -1
  15. data/app/assets/stylesheets/semantic-ui/collections/_form.scss +46 -5
  16. data/app/assets/stylesheets/semantic-ui/collections/_grid.scss +14 -7
  17. data/app/assets/stylesheets/semantic-ui/collections/_menu.scss +6 -4
  18. data/app/assets/stylesheets/semantic-ui/collections/_message.scss +50 -3
  19. data/app/assets/stylesheets/semantic-ui/collections/_table.scss +6 -2
  20. data/app/assets/stylesheets/semantic-ui/elements/_button.scss +29 -2
  21. data/app/assets/stylesheets/semantic-ui/elements/_container.scss +3 -4
  22. data/app/assets/stylesheets/semantic-ui/elements/_divider.scss +1 -1
  23. data/app/assets/stylesheets/semantic-ui/elements/_flag.scss +1 -1
  24. data/app/assets/stylesheets/semantic-ui/elements/_header.scss +10 -5
  25. data/app/assets/stylesheets/semantic-ui/elements/_icon.scss +237 -65
  26. data/app/assets/stylesheets/semantic-ui/elements/_image.scss +1 -1
  27. data/app/assets/stylesheets/semantic-ui/elements/_input.scss +2 -1
  28. data/app/assets/stylesheets/semantic-ui/elements/_label.scss +1 -1
  29. data/app/assets/stylesheets/semantic-ui/elements/_list.scss +1 -1
  30. data/app/assets/stylesheets/semantic-ui/elements/_loader.scss +41 -37
  31. data/app/assets/stylesheets/semantic-ui/elements/_placeholder.scss +1 -1
  32. data/app/assets/stylesheets/semantic-ui/elements/_rail.scss +1 -1
  33. data/app/assets/stylesheets/semantic-ui/elements/_reveal.scss +1 -1
  34. data/app/assets/stylesheets/semantic-ui/elements/_segment.scss +34 -2
  35. data/app/assets/stylesheets/semantic-ui/elements/_step.scss +1 -1
  36. data/app/assets/stylesheets/semantic-ui/elements/_text.scss +1 -1
  37. data/app/assets/stylesheets/semantic-ui/globals/_reset.scss +2 -3
  38. data/app/assets/stylesheets/semantic-ui/globals/_site.scss +2 -2
  39. data/app/assets/stylesheets/semantic-ui/modules/_accordion.scss +1 -1
  40. data/app/assets/stylesheets/semantic-ui/modules/_calendar.scss +3 -3
  41. data/app/assets/stylesheets/semantic-ui/modules/_checkbox.scss +46 -4
  42. data/app/assets/stylesheets/semantic-ui/modules/_dimmer.scss +1 -1
  43. data/app/assets/stylesheets/semantic-ui/modules/_dropdown.scss +72 -3
  44. data/app/assets/stylesheets/semantic-ui/modules/_embed.scss +1 -1
  45. data/app/assets/stylesheets/semantic-ui/modules/_modal.scss +19 -8
  46. data/app/assets/stylesheets/semantic-ui/modules/_nag.scss +168 -16
  47. data/app/assets/stylesheets/semantic-ui/modules/_popup.scss +4 -2
  48. data/app/assets/stylesheets/semantic-ui/modules/_progress.scss +18 -10
  49. data/app/assets/stylesheets/semantic-ui/modules/_rating.scss +18 -33
  50. data/app/assets/stylesheets/semantic-ui/modules/_search.scss +1 -1
  51. data/app/assets/stylesheets/semantic-ui/modules/_shape.scss +1 -1
  52. data/app/assets/stylesheets/semantic-ui/modules/_sidebar.scss +1 -1
  53. data/app/assets/stylesheets/semantic-ui/modules/_slider.scss +3 -1
  54. data/app/assets/stylesheets/semantic-ui/modules/_sticky.scss +1 -2
  55. data/app/assets/stylesheets/semantic-ui/modules/_tab.scss +1 -1
  56. data/app/assets/stylesheets/semantic-ui/modules/_toast.scss +97 -10
  57. data/app/assets/stylesheets/semantic-ui/modules/_transition.scss +1 -1
  58. data/app/assets/stylesheets/semantic-ui/views/_ad.scss +1 -1
  59. data/app/assets/stylesheets/semantic-ui/views/_card.scss +74 -2
  60. data/app/assets/stylesheets/semantic-ui/views/_comment.scss +1 -1
  61. data/app/assets/stylesheets/semantic-ui/views/_feed.scss +1 -1
  62. data/app/assets/stylesheets/semantic-ui/views/_item.scss +1 -1
  63. data/app/assets/stylesheets/semantic-ui/views/_statistic.scss +1 -1
  64. data/lib/fomantic/ui/sass/version.rb +2 -2
  65. metadata +6 -6
@@ -91,6 +91,7 @@ $.fn.form = function(parameters) {
91
91
  else {
92
92
  if(instance !== undefined) {
93
93
  instance.invoke('destroy');
94
+ module.refresh();
94
95
  }
95
96
  module.verbose('Initializing form validation', $module, settings);
96
97
  module.bindEvents();
@@ -171,11 +172,9 @@ $.fn.form = function(parameters) {
171
172
  }
172
173
 
173
174
  $field.on('change click keyup keydown blur', function(e) {
174
- $(this).triggerHandler(e.type + ".dirty");
175
+ module.determine.isDirty();
175
176
  });
176
177
 
177
- $field.on('change.dirty click.dirty keyup.dirty keydown.dirty blur.dirty', module.determine.isDirty);
178
-
179
178
  $module.on('dirty' + eventNamespace, function(e) {
180
179
  settings.onDirty.call();
181
180
  });
@@ -302,10 +301,6 @@ $.fn.form = function(parameters) {
302
301
  module.set.clean();
303
302
  }
304
303
 
305
- if (e && e.namespace === 'dirty') {
306
- e.stopImmediatePropagation();
307
- e.preventDefault();
308
- }
309
304
  }
310
305
  },
311
306
 
@@ -313,13 +308,6 @@ $.fn.form = function(parameters) {
313
308
  bracketedRule: function(rule) {
314
309
  return (rule.type && rule.type.match(settings.regExp.bracket));
315
310
  },
316
- shorthandFields: function(fields) {
317
- var
318
- fieldKeys = Object.keys(fields),
319
- firstRule = fields[fieldKeys[0]]
320
- ;
321
- return module.is.shorthandRules(firstRule);
322
- },
323
311
  // duck type rule test
324
312
  shorthandRules: function(rules) {
325
313
  return (typeof rules == 'string' || Array.isArray(rules));
@@ -422,7 +410,7 @@ $.fn.form = function(parameters) {
422
410
  ;
423
411
  if( key == keyCode.escape) {
424
412
  module.verbose('Escape key pressed blurring field');
425
- $field
413
+ $field[0]
426
414
  .blur()
427
415
  ;
428
416
  }
@@ -444,15 +432,11 @@ $.fn.form = function(parameters) {
444
432
  $fieldGroup = $field.closest($group),
445
433
  validationRules = module.get.validation($field)
446
434
  ;
447
- if( $fieldGroup.hasClass(className.error) ) {
435
+ if(validationRules && (settings.on == 'blur' || ( $fieldGroup.hasClass(className.error) && settings.revalidate) )) {
448
436
  module.debug('Revalidating field', $field, validationRules);
449
- if(validationRules) {
450
- module.validate.field( validationRules );
451
- }
452
- }
453
- else if(settings.on == 'blur') {
454
- if(validationRules) {
455
- module.validate.field( validationRules );
437
+ module.validate.field( validationRules );
438
+ if(!settings.inline) {
439
+ module.validate.form(false,true);
456
440
  }
457
441
  }
458
442
  },
@@ -465,7 +449,7 @@ $.fn.form = function(parameters) {
465
449
  if(validationRules && (settings.on == 'change' || ( $fieldGroup.hasClass(className.error) && settings.revalidate) )) {
466
450
  clearTimeout(module.timer);
467
451
  module.timer = setTimeout(function() {
468
- module.debug('Revalidating field', $field, module.get.validation($field));
452
+ module.debug('Revalidating field', $field, validationRules);
469
453
  module.validate.field( validationRules );
470
454
  if(!settings.inline) {
471
455
  module.validate.form(false,true);
@@ -527,15 +511,19 @@ $.fn.form = function(parameters) {
527
511
  fullFields = {}
528
512
  ;
529
513
  $.each(fields, function(name, rules) {
530
- if(typeof rules == 'string') {
531
- rules = [rules];
514
+ if (!Array.isArray(rules) && typeof rules === 'object') {
515
+ fullFields[name] = rules;
516
+ } else {
517
+ if (typeof rules == 'string') {
518
+ rules = [rules];
519
+ }
520
+ fullFields[name] = {
521
+ rules: []
522
+ };
523
+ $.each(rules, function (index, rule) {
524
+ fullFields[name].rules.push({type: rule});
525
+ });
532
526
  }
533
- fullFields[name] = {
534
- rules: []
535
- };
536
- $.each(rules, function(index, rule) {
537
- fullFields[name].rules.push({ type: rule });
538
- });
539
527
  });
540
528
  return fullFields;
541
529
  },
@@ -551,8 +539,23 @@ $.fn.form = function(parameters) {
551
539
  requiresValue = (prompt.search('{value}') !== -1),
552
540
  requiresName = (prompt.search('{name}') !== -1),
553
541
  $label,
554
- name
542
+ name,
543
+ parts,
544
+ suffixPrompt
555
545
  ;
546
+ if(ancillary && ancillary.indexOf('..') >= 0) {
547
+ parts = ancillary.split('..', 2);
548
+ if(!rule.prompt) {
549
+ suffixPrompt = (
550
+ parts[0] === '' ? settings.prompt.maxValue.replace(/\{ruleValue\}/g,'{max}') :
551
+ parts[1] === '' ? settings.prompt.minValue.replace(/\{ruleValue\}/g,'{min}') :
552
+ settings.prompt.range
553
+ );
554
+ prompt += suffixPrompt.replace(/\{name\}/g, ' ' + settings.text.and);
555
+ }
556
+ prompt = prompt.replace(/\{min\}/g, parts[0]);
557
+ prompt = prompt.replace(/\{max\}/g, parts[1]);
558
+ }
556
559
  if(requiresValue) {
557
560
  prompt = prompt.replace(/\{value\}/g, $field.val());
558
561
  }
@@ -588,7 +591,7 @@ $.fn.form = function(parameters) {
588
591
  }
589
592
  else {
590
593
  // 2.x
591
- if(parameters.fields && module.is.shorthandFields(parameters.fields)) {
594
+ if(parameters.fields) {
592
595
  parameters.fields = module.get.fieldsFromShorthand(parameters.fields);
593
596
  }
594
597
  settings = $.extend(true, {}, $.fn.form.settings, parameters);
@@ -616,7 +619,7 @@ $.fn.form = function(parameters) {
616
619
  instance = $module.data(moduleNamespace);
617
620
 
618
621
  // refresh selector cache
619
- module.refresh();
622
+ (instance || module).refresh();
620
623
  },
621
624
  field: function(identifier) {
622
625
  module.verbose('Finding field with identifier', identifier);
@@ -862,16 +865,7 @@ $.fn.form = function(parameters) {
862
865
  module.debug('Adding rules', newValidation.rules, validation);
863
866
  },
864
867
  fields: function(fields) {
865
- var
866
- newValidation
867
- ;
868
- if(fields && module.is.shorthandFields(fields)) {
869
- newValidation = module.get.fieldsFromShorthand(fields);
870
- }
871
- else {
872
- newValidation = fields;
873
- }
874
- validation = $.extend({}, validation, newValidation);
868
+ validation = $.extend({}, validation, module.get.fieldsFromShorthand(fields));
875
869
  },
876
870
  prompt: function(identifier, errors, internal) {
877
871
  var
@@ -1165,6 +1159,14 @@ $.fn.form = function(parameters) {
1165
1159
  }
1166
1160
  }
1167
1161
  });
1162
+ },
1163
+ optional: function(identifier, bool) {
1164
+ bool = (bool !== false);
1165
+ $.each(validation, function(fieldName, field) {
1166
+ if (identifier == fieldName || identifier == field.identifier) {
1167
+ field.optional = bool;
1168
+ }
1169
+ });
1168
1170
  }
1169
1171
  },
1170
1172
 
@@ -1201,6 +1203,24 @@ $.fn.form = function(parameters) {
1201
1203
  if(event && $module.data('moduleApi') !== undefined) {
1202
1204
  event.stopImmediatePropagation();
1203
1205
  }
1206
+ if(settings.errorFocus) {
1207
+ var focusElement, hasTabIndex = true;
1208
+ if (typeof settings.errorFocus === 'string') {
1209
+ focusElement = $(settings.errorFocus);
1210
+ hasTabIndex = focusElement.is('[tabindex]');
1211
+ // to be able to focus/scroll into non input elements we need a tabindex
1212
+ if (!hasTabIndex) {
1213
+ focusElement.attr('tabindex',-1);
1214
+ }
1215
+ } else {
1216
+ focusElement = $group.filter('.' + className.error).first().find(selector.field);
1217
+ }
1218
+ focusElement.focus();
1219
+ // only remove tabindex if it was dynamically created above
1220
+ if (!hasTabIndex){
1221
+ focusElement.removeAttr('tabindex');
1222
+ }
1223
+ }
1204
1224
  if(ignoreCallbacks !== true) {
1205
1225
  return settings.onFailure.call(element, formErrors, values);
1206
1226
  }
@@ -1290,7 +1310,7 @@ $.fn.form = function(parameters) {
1290
1310
  // cast to string avoiding encoding special values
1291
1311
  value = (value === undefined || value === '' || value === null)
1292
1312
  ? ''
1293
- : (settings.shouldTrim) ? String(value + '').trim() : String(value + '')
1313
+ : (settings.shouldTrim && rule.shouldTrim !== false) || rule.shouldTrim ? String(value + '').trim() : String(value + '')
1294
1314
  ;
1295
1315
  return ruleFunction.call(field, value, ancillary, $module);
1296
1316
  }
@@ -1506,6 +1526,7 @@ $.fn.form.settings = {
1506
1526
 
1507
1527
  autoCheckRequired : false,
1508
1528
  preventLeaving : false,
1529
+ errorFocus : false,
1509
1530
  dateHandling : 'date', // 'date', 'input', 'formatter'
1510
1531
 
1511
1532
  onValid : function() {},
@@ -1534,12 +1555,16 @@ $.fn.form.settings = {
1534
1555
  },
1535
1556
 
1536
1557
  text: {
1558
+ and : 'and',
1537
1559
  unspecifiedRule : 'Please enter a valid value',
1538
1560
  unspecifiedField : 'This field',
1539
1561
  leavingMessage : 'There are unsaved changes on this page which will be discarded if you continue.'
1540
1562
  },
1541
1563
 
1542
1564
  prompt: {
1565
+ range : '{name} must be in a range from {min} to {max}',
1566
+ maxValue : '{name} must have a maximum value of {ruleValue}',
1567
+ minValue : '{name} must have a minimum value of {ruleValue}',
1543
1568
  empty : '{name} must have a value',
1544
1569
  checked : '{name} must be checked',
1545
1570
  email : '{name} must be a valid e-mail',
@@ -1571,9 +1596,9 @@ $.fn.form.settings = {
1571
1596
  selector : {
1572
1597
  checkbox : 'input[type="checkbox"], input[type="radio"]',
1573
1598
  clear : '.clear',
1574
- field : 'input:not(.search), textarea, select',
1599
+ field : 'input:not(.search):not([type="file"]), textarea, select',
1575
1600
  group : '.field',
1576
- input : 'input',
1601
+ input : 'input:not([type="file"])',
1577
1602
  message : '.error.message',
1578
1603
  prompt : '.prompt.label',
1579
1604
  radio : 'input[type="radio"]',
@@ -1702,11 +1727,24 @@ $.fn.form.settings = {
1702
1727
  }
1703
1728
  return value.match( new RegExp(regExp, flags) );
1704
1729
  },
1705
-
1730
+ minValue: function(value, range) {
1731
+ return $.fn.form.settings.rules.range(value, range+'..', 'number');
1732
+ },
1733
+ maxValue: function(value, range) {
1734
+ return $.fn.form.settings.rules.range(value, '..'+range, 'number');
1735
+ },
1706
1736
  // is valid integer or matches range
1707
1737
  integer: function(value, range) {
1738
+ return $.fn.form.settings.rules.range(value, range, 'integer');
1739
+ },
1740
+ range: function(value, range, regExp) {
1741
+ if(typeof regExp == "string") {
1742
+ regExp = $.fn.form.settings.regExp[regExp];
1743
+ }
1744
+ if(!(regExp instanceof RegExp)) {
1745
+ regExp = $.fn.form.settings.regExp.integer;
1746
+ }
1708
1747
  var
1709
- intRegExp = $.fn.form.settings.regExp.integer,
1710
1748
  min,
1711
1749
  max,
1712
1750
  parts
@@ -1715,34 +1753,34 @@ $.fn.form.settings = {
1715
1753
  // do nothing
1716
1754
  }
1717
1755
  else if(range.indexOf('..') == -1) {
1718
- if(intRegExp.test(range)) {
1756
+ if(regExp.test(range)) {
1719
1757
  min = max = range - 0;
1720
1758
  }
1721
1759
  }
1722
1760
  else {
1723
1761
  parts = range.split('..', 2);
1724
- if(intRegExp.test(parts[0])) {
1762
+ if(regExp.test(parts[0])) {
1725
1763
  min = parts[0] - 0;
1726
1764
  }
1727
- if(intRegExp.test(parts[1])) {
1765
+ if(regExp.test(parts[1])) {
1728
1766
  max = parts[1] - 0;
1729
1767
  }
1730
1768
  }
1731
1769
  return (
1732
- intRegExp.test(value) &&
1770
+ regExp.test(value) &&
1733
1771
  (min === undefined || value >= min) &&
1734
1772
  (max === undefined || value <= max)
1735
1773
  );
1736
1774
  },
1737
1775
 
1738
1776
  // is valid number (with decimal)
1739
- decimal: function(value) {
1740
- return $.fn.form.settings.regExp.decimal.test(value);
1777
+ decimal: function(value, range) {
1778
+ return $.fn.form.settings.rules.range(value, range, 'decimal');
1741
1779
  },
1742
1780
 
1743
1781
  // is valid number
1744
- number: function(value) {
1745
- return $.fn.form.settings.regExp.number.test(value);
1782
+ number: function(value, range) {
1783
+ return $.fn.form.settings.rules.range(value, range, 'number');
1746
1784
  },
1747
1785
 
1748
1786
  // is value (case insensitive)
@@ -1947,8 +1985,8 @@ $.fn.form.settings = {
1947
1985
  return;
1948
1986
  }
1949
1987
 
1950
- // allow dashes in card
1951
- cardNumber = cardNumber.replace(/[\-]/g, '');
1988
+ // allow dashes and spaces in card
1989
+ cardNumber = cardNumber.replace(/[\s\-]/g, '');
1952
1990
 
1953
1991
  // verify card types
1954
1992
  if(requiredTypes) {