fomantic-ui-sass 2.8.2 → 2.8.7

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 (65) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +24 -0
  3. data/app/assets/fonts/semantic-ui/brand-icons.eot +0 -0
  4. data/app/assets/fonts/semantic-ui/brand-icons.svg +928 -689
  5. data/app/assets/fonts/semantic-ui/brand-icons.ttf +0 -0
  6. data/app/assets/fonts/semantic-ui/brand-icons.woff +0 -0
  7. data/app/assets/fonts/semantic-ui/brand-icons.woff2 +0 -0
  8. data/app/assets/fonts/semantic-ui/icons.eot +0 -0
  9. data/app/assets/fonts/semantic-ui/icons.svg +610 -426
  10. data/app/assets/fonts/semantic-ui/icons.ttf +0 -0
  11. data/app/assets/fonts/semantic-ui/icons.woff +0 -0
  12. data/app/assets/fonts/semantic-ui/icons.woff2 +0 -0
  13. data/app/assets/fonts/semantic-ui/outline-icons.eot +0 -0
  14. data/app/assets/fonts/semantic-ui/outline-icons.svg +22 -18
  15. data/app/assets/fonts/semantic-ui/outline-icons.ttf +0 -0
  16. data/app/assets/fonts/semantic-ui/outline-icons.woff +0 -0
  17. data/app/assets/fonts/semantic-ui/outline-icons.woff2 +0 -0
  18. data/app/assets/javascripts/semantic-ui/calendar.js +249 -60
  19. data/app/assets/javascripts/semantic-ui/checkbox.js +2 -2
  20. data/app/assets/javascripts/semantic-ui/dimmer.js +3 -3
  21. data/app/assets/javascripts/semantic-ui/dropdown.js +98 -62
  22. data/app/assets/javascripts/semantic-ui/form.js +97 -35
  23. data/app/assets/javascripts/semantic-ui/modal.js +9 -1
  24. data/app/assets/javascripts/semantic-ui/popup.js +8 -7
  25. data/app/assets/javascripts/semantic-ui/progress.js +20 -24
  26. data/app/assets/javascripts/semantic-ui/search.js +30 -2
  27. data/app/assets/javascripts/semantic-ui/slider.js +8 -8
  28. data/app/assets/javascripts/semantic-ui/tab.js +3 -2
  29. data/app/assets/javascripts/semantic-ui/toast.js +11 -9
  30. data/app/assets/javascripts/semantic-ui/visibility.js +1 -1
  31. data/app/assets/stylesheets/semantic-ui/collections/_form.scss +86 -93
  32. data/app/assets/stylesheets/semantic-ui/collections/_grid.scss +8 -6
  33. data/app/assets/stylesheets/semantic-ui/collections/_menu.scss +36 -35
  34. data/app/assets/stylesheets/semantic-ui/collections/_message.scss +4 -4
  35. data/app/assets/stylesheets/semantic-ui/collections/_table.scss +39 -23
  36. data/app/assets/stylesheets/semantic-ui/elements/_button.scss +9 -3
  37. data/app/assets/stylesheets/semantic-ui/elements/_emoji.scss +1 -1
  38. data/app/assets/stylesheets/semantic-ui/elements/_header.scss +8 -8
  39. data/app/assets/stylesheets/semantic-ui/elements/_icon.scss +159 -18
  40. data/app/assets/stylesheets/semantic-ui/elements/_image.scss +33 -4
  41. data/app/assets/stylesheets/semantic-ui/elements/_input.scss +68 -68
  42. data/app/assets/stylesheets/semantic-ui/elements/_label.scss +38 -2
  43. data/app/assets/stylesheets/semantic-ui/elements/_list.scss +12 -12
  44. data/app/assets/stylesheets/semantic-ui/elements/_segment.scss +7 -1
  45. data/app/assets/stylesheets/semantic-ui/elements/_step.scss +16 -9
  46. data/app/assets/stylesheets/semantic-ui/elements/_text.scss +15 -0
  47. data/app/assets/stylesheets/semantic-ui/modules/_calendar.scss +16 -9
  48. data/app/assets/stylesheets/semantic-ui/modules/_checkbox.scss +1 -0
  49. data/app/assets/stylesheets/semantic-ui/modules/_dimmer.scss +26 -23
  50. data/app/assets/stylesheets/semantic-ui/modules/_dropdown.scss +123 -32
  51. data/app/assets/stylesheets/semantic-ui/modules/_embed.scss +6 -6
  52. data/app/assets/stylesheets/semantic-ui/modules/_modal.scss +13 -6
  53. data/app/assets/stylesheets/semantic-ui/modules/_popup.scss +36 -7
  54. data/app/assets/stylesheets/semantic-ui/modules/_progress.scss +32 -3
  55. data/app/assets/stylesheets/semantic-ui/modules/_search.scss +90 -0
  56. data/app/assets/stylesheets/semantic-ui/modules/_shape.scss +1 -0
  57. data/app/assets/stylesheets/semantic-ui/modules/_sidebar.scss +2 -1
  58. data/app/assets/stylesheets/semantic-ui/modules/_slider.scss +9 -0
  59. data/app/assets/stylesheets/semantic-ui/modules/_toast.scss +7 -7
  60. data/app/assets/stylesheets/semantic-ui/modules/_transition.scss +34 -34
  61. data/app/assets/stylesheets/semantic-ui/views/_card.scss +1 -1
  62. data/app/assets/stylesheets/semantic-ui/views/_feed.scss +5 -5
  63. data/app/assets/stylesheets/semantic-ui/views/_statistic.scss +4 -4
  64. data/lib/fomantic/ui/sass/version.rb +2 -2
  65. metadata +6 -6
@@ -95,6 +95,9 @@ $.fn.form = function(parameters) {
95
95
  module.verbose('Initializing form validation', $module, settings);
96
96
  module.bindEvents();
97
97
  module.set.defaults();
98
+ if (settings.autoCheckRequired) {
99
+ module.set.autoCheck();
100
+ }
98
101
  module.instantiate();
99
102
  }
100
103
  },
@@ -216,6 +219,7 @@ $.fn.form = function(parameters) {
216
219
  $field.val('');
217
220
  }
218
221
  });
222
+ module.remove.states();
219
223
  },
220
224
 
221
225
  reset: function() {
@@ -256,8 +260,7 @@ $.fn.form = function(parameters) {
256
260
  $field.val(defaultValue);
257
261
  }
258
262
  });
259
-
260
- module.determine.isDirty();
263
+ module.remove.states();
261
264
  },
262
265
 
263
266
  determine: {
@@ -333,20 +336,20 @@ $.fn.form = function(parameters) {
333
336
  }
334
337
  },
335
338
  blank: function($field) {
336
- return $.trim($field.val()) === '';
339
+ return String($field.val()).trim() === '';
337
340
  },
338
- valid: function(field) {
341
+ valid: function(field, showErrors) {
339
342
  var
340
343
  allValid = true
341
344
  ;
342
345
  if(field) {
343
346
  module.verbose('Checking if field is valid', field);
344
- return module.validate.field(validation[field], field, false);
347
+ return module.validate.field(validation[field], field, !!showErrors);
345
348
  }
346
349
  else {
347
350
  module.verbose('Checking if form is valid');
348
351
  $.each(validation, function(fieldName, field) {
349
- if( !module.is.valid(fieldName) ) {
352
+ if( !module.is.valid(fieldName, showErrors) ) {
350
353
  allValid = false;
351
354
  }
352
355
  });
@@ -363,9 +366,15 @@ $.fn.form = function(parameters) {
363
366
  var initialValue = $el.data(metadata.defaultValue);
364
367
  // Explicitly check for null/undefined here as value may be `false`, so ($el.data(dataInitialValue) || '') would not work
365
368
  if (initialValue == null) { initialValue = ''; }
369
+ else if(Array.isArray(initialValue)) {
370
+ initialValue = initialValue.toString();
371
+ }
366
372
  var currentValue = $el.val();
367
373
  if (currentValue == null) { currentValue = ''; }
368
-
374
+ // multiple select values are returned as arrays which are never equal, so do string conversion first
375
+ else if(Array.isArray(currentValue)) {
376
+ currentValue = currentValue.toString();
377
+ }
369
378
  // Boolean values can be encoded as "true/false" or "True/False" depending on underlying frameworks so we need a case insensitive comparison
370
379
  var boolRegex = /^(true|false)$/i;
371
380
  var isBoolValue = boolRegex.test(initialValue) && boolRegex.test(currentValue);
@@ -458,6 +467,9 @@ $.fn.form = function(parameters) {
458
467
  module.timer = setTimeout(function() {
459
468
  module.debug('Revalidating field', $field, module.get.validation($field));
460
469
  module.validate.field( validationRules );
470
+ if(!settings.inline) {
471
+ module.validate.form(false,true);
472
+ }
461
473
  }, settings.delay);
462
474
  }
463
475
  }
@@ -542,7 +554,7 @@ $.fn.form = function(parameters) {
542
554
  name
543
555
  ;
544
556
  if(requiresValue) {
545
- prompt = prompt.replace('{value}', $field.val());
557
+ prompt = prompt.replace(/\{value\}/g, $field.val());
546
558
  }
547
559
  if(requiresName) {
548
560
  $label = $field.closest(selector.group).find('label').eq(0);
@@ -550,10 +562,10 @@ $.fn.form = function(parameters) {
550
562
  ? $label.text()
551
563
  : $field.prop('placeholder') || settings.text.unspecifiedField
552
564
  ;
553
- prompt = prompt.replace('{name}', name);
565
+ prompt = prompt.replace(/\{name\}/g, name);
554
566
  }
555
- prompt = prompt.replace('{identifier}', field.identifier);
556
- prompt = prompt.replace('{ruleValue}', ancillary);
567
+ prompt = prompt.replace(/\{identifier\}/g, field.identifier);
568
+ prompt = prompt.replace(/\{ruleValue\}/g, ancillary);
557
569
  if(!rule.prompt) {
558
570
  module.verbose('Using default validation prompt for type', prompt, ruleName);
559
571
  }
@@ -703,7 +715,7 @@ $.fn.form = function(parameters) {
703
715
  }
704
716
  else {
705
717
  if(isRadio) {
706
- if(values[name] === undefined || values[name] == false) {
718
+ if(values[name] === undefined || values[name] === false) {
707
719
  values[name] = (isChecked)
708
720
  ? value || true
709
721
  : false
@@ -818,26 +830,36 @@ $.fn.form = function(parameters) {
818
830
  module.add.field(name, rules);
819
831
  },
820
832
  field: function(name, rules) {
833
+ // Validation should have at least a standard format
834
+ if(validation[name] === undefined || validation[name].rules === undefined) {
835
+ validation[name] = {
836
+ rules: []
837
+ };
838
+ }
821
839
  var
822
- newValidation = {}
840
+ newValidation = {
841
+ rules: []
842
+ }
823
843
  ;
824
844
  if(module.is.shorthandRules(rules)) {
825
845
  rules = Array.isArray(rules)
826
846
  ? rules
827
847
  : [rules]
828
848
  ;
829
- newValidation[name] = {
830
- rules: []
831
- };
832
- $.each(rules, function(index, rule) {
833
- newValidation[name].rules.push({ type: rule });
849
+ $.each(rules, function(_index, rule) {
850
+ newValidation.rules.push({ type: rule });
834
851
  });
835
852
  }
836
853
  else {
837
- newValidation[name] = rules;
854
+ newValidation.rules = rules.rules;
838
855
  }
839
- validation = $.extend({}, validation, newValidation);
840
- module.debug('Adding rules', newValidation, validation);
856
+ // For each new rule, check if there's not already one with the same type
857
+ $.each(newValidation.rules, function (_index, rule) {
858
+ if ($.grep(validation[name].rules, function(item){ return item.type == rule.type; }).length == 0) {
859
+ validation[name].rules.push(rule);
860
+ }
861
+ });
862
+ module.debug('Adding rules', newValidation.rules, validation);
841
863
  },
842
864
  fields: function(fields) {
843
865
  var
@@ -905,6 +927,17 @@ $.fn.form = function(parameters) {
905
927
  },
906
928
 
907
929
  remove: {
930
+ errors: function() {
931
+ module.debug('Removing form error messages');
932
+ $message.empty();
933
+ },
934
+ states: function() {
935
+ $module.removeClass(className.error).removeClass(className.success);
936
+ if(!settings.inline) {
937
+ module.remove.errors();
938
+ }
939
+ module.determine.isDirty();
940
+ },
908
941
  rule: function(field, rule) {
909
942
  var
910
943
  rules = Array.isArray(rule)
@@ -1106,6 +1139,32 @@ $.fn.form = function(parameters) {
1106
1139
  asDirty: function() {
1107
1140
  module.set.defaults();
1108
1141
  module.set.dirty();
1142
+ },
1143
+ autoCheck: function() {
1144
+ module.debug('Enabling auto check on required fields');
1145
+ $field.each(function (_index, el) {
1146
+ var
1147
+ $el = $(el),
1148
+ $elGroup = $(el).closest($group),
1149
+ isCheckbox = ($el.filter(selector.checkbox).length > 0),
1150
+ isRequired = $el.prop('required') || $elGroup.hasClass(className.required) || $elGroup.parent().hasClass(className.required),
1151
+ isDisabled = $el.is(':disabled') || $elGroup.hasClass(className.disabled) || $elGroup.parent().hasClass(className.disabled),
1152
+ validation = module.get.validation($el),
1153
+ hasEmptyRule = validation
1154
+ ? $.grep(validation.rules, function(rule) { return rule.type == "empty" }) !== 0
1155
+ : false,
1156
+ identifier = validation.identifier || $el.attr('id') || $el.attr('name') || $el.data(metadata.validate)
1157
+ ;
1158
+ if (isRequired && !isDisabled && !hasEmptyRule && identifier !== undefined) {
1159
+ if (isCheckbox) {
1160
+ module.verbose("Adding 'checked' rule on field", identifier);
1161
+ module.add.rule(identifier, "checked");
1162
+ } else {
1163
+ module.verbose("Adding 'empty' rule on field", identifier);
1164
+ module.add.rule(identifier, "empty");
1165
+ }
1166
+ }
1167
+ });
1109
1168
  }
1110
1169
  },
1111
1170
 
@@ -1124,12 +1183,16 @@ $.fn.form = function(parameters) {
1124
1183
  if( module.determine.isValid() ) {
1125
1184
  module.debug('Form has no validation errors, submitting');
1126
1185
  module.set.success();
1186
+ if(!settings.inline) {
1187
+ module.remove.errors();
1188
+ }
1127
1189
  if(ignoreCallbacks !== true) {
1128
1190
  return settings.onSuccess.call(element, event, values);
1129
1191
  }
1130
1192
  }
1131
1193
  else {
1132
1194
  module.debug('Form has errors');
1195
+ submitting = false;
1133
1196
  module.set.error();
1134
1197
  if(!settings.inline) {
1135
1198
  module.add.errors(formErrors);
@@ -1168,13 +1231,7 @@ $.fn.form = function(parameters) {
1168
1231
  module.debug('Using field name as identifier', identifier);
1169
1232
  field.identifier = identifier;
1170
1233
  }
1171
- var isDisabled = true;
1172
- $.each($field, function(){
1173
- if(!$(this).prop('disabled')) {
1174
- isDisabled = false;
1175
- return false;
1176
- }
1177
- });
1234
+ var isDisabled = !$field.filter(':not(:disabled)').length;
1178
1235
  if(isDisabled) {
1179
1236
  module.debug('Field is disabled. Skipping', identifier);
1180
1237
  }
@@ -1185,7 +1242,9 @@ $.fn.form = function(parameters) {
1185
1242
  module.debug('Field depends on another value that is not present or empty. Skipping', $dependsField);
1186
1243
  }
1187
1244
  else if(field.rules !== undefined) {
1188
- $field.closest($group).removeClass(className.error);
1245
+ if(showErrors) {
1246
+ $field.closest($group).removeClass(className.error);
1247
+ }
1189
1248
  $.each(field.rules, function(index, rule) {
1190
1249
  if( module.has.field(identifier)) {
1191
1250
  var invalidFields = module.validate.rule(field, rule,true) || [];
@@ -1231,7 +1290,7 @@ $.fn.form = function(parameters) {
1231
1290
  // cast to string avoiding encoding special values
1232
1291
  value = (value === undefined || value === '' || value === null)
1233
1292
  ? ''
1234
- : (settings.shouldTrim) ? $.trim(value + '') : String(value + '')
1293
+ : (settings.shouldTrim) ? String(value + '').trim() : String(value + '')
1235
1294
  ;
1236
1295
  return ruleFunction.call(field, value, ancillary, $module);
1237
1296
  }
@@ -1445,6 +1504,7 @@ $.fn.form.settings = {
1445
1504
  transition : 'scale',
1446
1505
  duration : 200,
1447
1506
 
1507
+ autoCheckRequired : false,
1448
1508
  preventLeaving : false,
1449
1509
  dateHandling : 'date', // 'date', 'input', 'formatter'
1450
1510
 
@@ -1511,7 +1571,7 @@ $.fn.form.settings = {
1511
1571
  selector : {
1512
1572
  checkbox : 'input[type="checkbox"], input[type="radio"]',
1513
1573
  clear : '.clear',
1514
- field : 'input, textarea, select',
1574
+ field : 'input:not(.search), textarea, select',
1515
1575
  group : '.field',
1516
1576
  input : 'input',
1517
1577
  message : '.error.message',
@@ -1525,10 +1585,12 @@ $.fn.form.settings = {
1525
1585
  },
1526
1586
 
1527
1587
  className : {
1528
- error : 'error',
1529
- label : 'ui basic red pointing prompt label',
1530
- pressed : 'down',
1531
- success : 'success'
1588
+ error : 'error',
1589
+ label : 'ui basic red pointing prompt label',
1590
+ pressed : 'down',
1591
+ success : 'success',
1592
+ required : 'required',
1593
+ disabled : 'disabled'
1532
1594
  },
1533
1595
 
1534
1596
  error: {
@@ -708,7 +708,15 @@ $.fn.modal = function(parameters) {
708
708
  return module.cache.leftBodyScrollbar;
709
709
  },
710
710
  useFlex: function() {
711
- return settings.useFlex && settings.detachable && !module.is.ie();
711
+ if (settings.useFlex === 'auto') {
712
+ return settings.detachable && !module.is.ie();
713
+ }
714
+ if(settings.useFlex && module.is.ie()) {
715
+ module.debug('useFlex true is not supported in IE');
716
+ } else if(settings.useFlex && !settings.detachable) {
717
+ module.debug('useFlex true in combination with detachable false is not supported');
718
+ }
719
+ return settings.useFlex;
712
720
  },
713
721
  fit: function() {
714
722
  var
@@ -510,9 +510,10 @@ $.fn.popup = function(parameters) {
510
510
  $popupOffsetParent = module.get.offsetParent($popup),
511
511
  targetElement = $target[0],
512
512
  isWindow = ($boundary[0] == window),
513
- targetPosition = (settings.inline || (settings.popup && settings.movePopup))
514
- ? $target.position()
515
- : $target.offset(),
513
+ targetOffset = $target.offset(),
514
+ parentOffset = settings.inline || (settings.popup && settings.movePopup)
515
+ ? $target.offsetParent().offset()
516
+ : { top: 0, left: 0 },
516
517
  screenPosition = (isWindow)
517
518
  ? { top: 0, left: 0 }
518
519
  : $boundary.offset(),
@@ -528,8 +529,8 @@ $.fn.popup = function(parameters) {
528
529
  element : $target[0],
529
530
  width : $target.outerWidth(),
530
531
  height : $target.outerHeight(),
531
- top : targetPosition.top,
532
- left : targetPosition.left,
532
+ top : targetOffset.top - parentOffset.top,
533
+ left : targetOffset.left - parentOffset.left,
533
534
  margin : {}
534
535
  },
535
536
  // popup itself
@@ -1496,10 +1497,9 @@ $.fn.popup.settings = {
1496
1497
  templates: {
1497
1498
  escape: function(string) {
1498
1499
  var
1499
- badChars = /[&<>"'`]/g,
1500
+ badChars = /[<>"'`]/g,
1500
1501
  shouldEscape = /[&<>"'`]/,
1501
1502
  escape = {
1502
- "&": "&amp;",
1503
1503
  "<": "&lt;",
1504
1504
  ">": "&gt;",
1505
1505
  '"': "&quot;",
@@ -1511,6 +1511,7 @@ $.fn.popup.settings = {
1511
1511
  }
1512
1512
  ;
1513
1513
  if(shouldEscape.test(string)) {
1514
+ string = string.replace(/&(?![a-z0-9#]{1,6};)/, "&amp;");
1514
1515
  return string.replace(badChars, escapedChar);
1515
1516
  }
1516
1517
  return string;
@@ -169,7 +169,7 @@ $.fn.progress = function(parameters) {
169
169
  value : module.helper.forceArray($module.data(metadata.value))
170
170
  }
171
171
  ;
172
- if(data.total) {
172
+ if(data.total !== undefined) {
173
173
  module.debug('Total value set from metadata', data.total);
174
174
  module.set.total(data.total);
175
175
  }
@@ -272,18 +272,18 @@ $.fn.progress = function(parameters) {
272
272
  var
273
273
  index_ = index || 0,
274
274
  value = module.get.value(index_),
275
- total = module.total || 0,
275
+ total = module.get.total(),
276
276
  percent = (animating)
277
277
  ? module.get.displayPercent(index_)
278
278
  : module.get.percent(index_),
279
- left = (module.total > 0)
280
- ? (total - value)
279
+ left = (total !== false)
280
+ ? Math.max(0,total - value)
281
281
  : (100 - percent)
282
282
  ;
283
283
  templateText = templateText || '';
284
284
  templateText = templateText
285
285
  .replace('{value}', value)
286
- .replace('{total}', total)
286
+ .replace('{total}', total || 0)
287
287
  .replace('{left}', left)
288
288
  .replace('{percent}', percent)
289
289
  .replace('{bar}', settings.text.bars[index_] || '')
@@ -373,7 +373,7 @@ $.fn.progress = function(parameters) {
373
373
  return module.nextValue || module.value && module.value[index || 0] || 0;
374
374
  },
375
375
  total: function() {
376
- return module.total || false;
376
+ return module.total !== undefined ? module.total : false;
377
377
  }
378
378
  },
379
379
 
@@ -506,23 +506,23 @@ $.fn.progress = function(parameters) {
506
506
  ;
507
507
  });
508
508
  var hasTotal = module.has.total();
509
- var totalPecent = module.helper.sum(percents);
510
- var isMultpleValues = percents.length > 1 && hasTotal;
509
+ var totalPercent = module.helper.sum(percents);
510
+ var isMultipleValues = percents.length > 1 && hasTotal;
511
511
  var sumTotal = module.helper.sum(module.helper.forceArray(module.value));
512
- if (isMultpleValues && sumTotal > module.total) {
512
+ if (isMultipleValues && sumTotal > module.total) {
513
513
  // Sum values instead of pecents to avoid precision issues when summing floats
514
514
  module.error(error.sumExceedsTotal, sumTotal, module.total);
515
- } else if (!isMultpleValues && totalPecent > 100) {
516
- // Sum before rouding since sum of rounded may have error though sum of actual is fine
517
- module.error(error.tooHigh, totalPecent);
518
- } else if (totalPecent < 0) {
519
- module.error(error.tooLow, totalPecent);
515
+ } else if (!isMultipleValues && totalPercent > 100) {
516
+ // Sum before rounding since sum of rounded may have error though sum of actual is fine
517
+ module.error(error.tooHigh, totalPercent);
518
+ } else if (totalPercent < 0) {
519
+ module.error(error.tooLow, totalPercent);
520
520
  } else {
521
521
  var autoPrecision = settings.precision > 0
522
522
  ? settings.precision
523
- : isMultpleValues
523
+ : isMultipleValues
524
524
  ? module.helper.derivePrecision(Math.min.apply(null, module.value), module.total)
525
- : undefined;
525
+ : 0;
526
526
 
527
527
  // round display percentage
528
528
  var roundedPercents = percents.map(function (percent) {
@@ -532,7 +532,7 @@ $.fn.progress = function(parameters) {
532
532
  ;
533
533
  });
534
534
  module.percent = roundedPercents;
535
- if (!hasTotal) {
535
+ if (hasTotal) {
536
536
  module.value = roundedPercents.map(function (percent) {
537
537
  return (autoPrecision > 0)
538
538
  ? Math.round((percent / 100) * module.total * (10 * autoPrecision)) / (10 * autoPrecision)
@@ -541,11 +541,7 @@ $.fn.progress = function(parameters) {
541
541
  });
542
542
  if (settings.limitValues) {
543
543
  module.value = module.value.map(function (value) {
544
- return (value > 100)
545
- ? 100
546
- : (module.value < 0)
547
- ? 0
548
- : module.value;
544
+ return Math.max(0, Math.min(100, value));
549
545
  });
550
546
  }
551
547
  }
@@ -622,7 +618,7 @@ $.fn.progress = function(parameters) {
622
618
  if (text !== undefined) {
623
619
  $progress.text( module.get.text(text, index) );
624
620
  }
625
- else if (settings.label == 'ratio' && module.total) {
621
+ else if (settings.label == 'ratio' && module.has.total()) {
626
622
  module.verbose('Adding ratio to bar label');
627
623
  $progress.text( module.get.text(settings.text.ratio, index) );
628
624
  }
@@ -752,7 +748,7 @@ $.fn.progress = function(parameters) {
752
748
  }
753
749
  value = module.get.normalizedValue(value);
754
750
  if (hasTotal) {
755
- percentComplete = (value / module.total) * 100;
751
+ percentComplete = module.total > 0 ? (value / module.total) * 100 : 100;
756
752
  module.debug('Calculating percent complete from total', percentComplete);
757
753
  }
758
754
  else {