fomantic-ui-sass 2.7.8 → 2.8.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +20 -0
  3. data/app/assets/fonts/semantic-ui/brand-icons.eot +0 -0
  4. data/app/assets/fonts/semantic-ui/brand-icons.svg +83 -29
  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 +59 -41
  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 +3 -3
  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/api.js +1 -1
  19. data/app/assets/javascripts/semantic-ui/calendar.js +103 -27
  20. data/app/assets/javascripts/semantic-ui/checkbox.js +1 -1
  21. data/app/assets/javascripts/semantic-ui/dropdown.js +93 -71
  22. data/app/assets/javascripts/semantic-ui/form.js +69 -22
  23. data/app/assets/javascripts/semantic-ui/modal.js +104 -33
  24. data/app/assets/javascripts/semantic-ui/popup.js +10 -10
  25. data/app/assets/javascripts/semantic-ui/progress.js +10 -8
  26. data/app/assets/javascripts/semantic-ui/rating.js +35 -6
  27. data/app/assets/javascripts/semantic-ui/search.js +2 -2
  28. data/app/assets/javascripts/semantic-ui/sidebar.js +2 -3
  29. data/app/assets/javascripts/semantic-ui/slider.js +78 -29
  30. data/app/assets/javascripts/semantic-ui/tab.js +1 -1
  31. data/app/assets/javascripts/semantic-ui/toast.js +398 -122
  32. data/app/assets/stylesheets/semantic-ui/collections/_breadcrumb.scss +3 -3
  33. data/app/assets/stylesheets/semantic-ui/collections/_form.scss +779 -142
  34. data/app/assets/stylesheets/semantic-ui/collections/_grid.scss +35 -35
  35. data/app/assets/stylesheets/semantic-ui/collections/_menu.scss +101 -145
  36. data/app/assets/stylesheets/semantic-ui/collections/_message.scss +11 -11
  37. data/app/assets/stylesheets/semantic-ui/collections/_table.scss +1009 -208
  38. data/app/assets/stylesheets/semantic-ui/elements/_all.scss +1 -0
  39. data/app/assets/stylesheets/semantic-ui/elements/_button.scss +51 -81
  40. data/app/assets/stylesheets/semantic-ui/elements/_container.scss +12 -12
  41. data/app/assets/stylesheets/semantic-ui/elements/_divider.scss +35 -14
  42. data/app/assets/stylesheets/semantic-ui/elements/_emoji.scss +12309 -0
  43. data/app/assets/stylesheets/semantic-ui/elements/_header.scss +111 -66
  44. data/app/assets/stylesheets/semantic-ui/elements/_icon.scss +105 -34
  45. data/app/assets/stylesheets/semantic-ui/elements/_image.scss +28 -28
  46. data/app/assets/stylesheets/semantic-ui/elements/_input.scss +211 -62
  47. data/app/assets/stylesheets/semantic-ui/elements/_label.scss +20 -20
  48. data/app/assets/stylesheets/semantic-ui/elements/_list.scss +52 -51
  49. data/app/assets/stylesheets/semantic-ui/elements/_loader.scss +85 -91
  50. data/app/assets/stylesheets/semantic-ui/elements/_placeholder.scss +8 -8
  51. data/app/assets/stylesheets/semantic-ui/elements/_rail.scss +11 -11
  52. data/app/assets/stylesheets/semantic-ui/elements/_reveal.scss +31 -10
  53. data/app/assets/stylesheets/semantic-ui/elements/_segment.scss +39 -39
  54. data/app/assets/stylesheets/semantic-ui/elements/_step.scss +16 -17
  55. data/app/assets/stylesheets/semantic-ui/elements/_text.scss +3 -3
  56. data/app/assets/stylesheets/semantic-ui/modules/_accordion.scss +6 -6
  57. data/app/assets/stylesheets/semantic-ui/modules/_calendar.scss +2 -2
  58. data/app/assets/stylesheets/semantic-ui/modules/_checkbox.scss +15 -124
  59. data/app/assets/stylesheets/semantic-ui/modules/_dimmer.scss +30 -30
  60. data/app/assets/stylesheets/semantic-ui/modules/_dropdown.scss +183 -111
  61. data/app/assets/stylesheets/semantic-ui/modules/_embed.scss +12 -12
  62. data/app/assets/stylesheets/semantic-ui/modules/_modal.scss +128 -30
  63. data/app/assets/stylesheets/semantic-ui/modules/_popup.scss +105 -79
  64. data/app/assets/stylesheets/semantic-ui/modules/_progress.scss +44 -26
  65. data/app/assets/stylesheets/semantic-ui/modules/_rating.scss +246 -21
  66. data/app/assets/stylesheets/semantic-ui/modules/_search.scss +16 -13
  67. data/app/assets/stylesheets/semantic-ui/modules/_shape.scss +3 -2
  68. data/app/assets/stylesheets/semantic-ui/modules/_sidebar.scss +12 -14
  69. data/app/assets/stylesheets/semantic-ui/modules/_slider.scss +20 -23
  70. data/app/assets/stylesheets/semantic-ui/modules/_tab.scss +2 -2
  71. data/app/assets/stylesheets/semantic-ui/modules/_toast.scss +542 -155
  72. data/app/assets/stylesheets/semantic-ui/views/_ad.scss +16 -16
  73. data/app/assets/stylesheets/semantic-ui/views/_card.scss +42 -17
  74. data/app/assets/stylesheets/semantic-ui/views/_comment.scss +9 -9
  75. data/app/assets/stylesheets/semantic-ui/views/_feed.scss +20 -5
  76. data/app/assets/stylesheets/semantic-ui/views/_item.scss +33 -12
  77. data/app/assets/stylesheets/semantic-ui/views/_statistic.scss +60 -46
  78. data/fomantic-ui-sass.gemspec +2 -2
  79. data/lib/fomantic-ui-sass.rb +2 -2
  80. data/lib/fomantic/ui/sass/version.rb +2 -2
  81. data/spec/dummy/app/assets/config/manifest.js +0 -0
  82. metadata +12 -9
@@ -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
  },
@@ -168,7 +171,7 @@ $.fn.form = function(parameters) {
168
171
  }
169
172
 
170
173
  $field.on('change click keyup keydown blur', function(e) {
171
- $(this).trigger(e.type + ".dirty");
174
+ $(this).triggerHandler(e.type + ".dirty");
172
175
  });
173
176
 
174
177
  $field.on('change.dirty click.dirty keyup.dirty keydown.dirty blur.dirty', module.determine.isDirty);
@@ -203,7 +206,7 @@ $.fn.form = function(parameters) {
203
206
  }
204
207
  if(isDropdown) {
205
208
  module.verbose('Resetting dropdown value', $element, defaultValue);
206
- $element.dropdown('clear');
209
+ $element.dropdown('clear', true);
207
210
  }
208
211
  else if(isCheckbox) {
209
212
  $field.prop('checked', false);
@@ -242,7 +245,7 @@ $.fn.form = function(parameters) {
242
245
  }
243
246
  if(isDropdown) {
244
247
  module.verbose('Resetting dropdown value', $element, defaultValue);
245
- $element.dropdown('restore defaults');
248
+ $element.dropdown('restore defaults', true);
246
249
  }
247
250
  else if(isCheckbox) {
248
251
  module.verbose('Resetting checkbox value', $element, defaultValue);
@@ -542,7 +545,7 @@ $.fn.form = function(parameters) {
542
545
  name
543
546
  ;
544
547
  if(requiresValue) {
545
- prompt = prompt.replace('{value}', $field.val());
548
+ prompt = prompt.replace(/\{value\}/g, $field.val());
546
549
  }
547
550
  if(requiresName) {
548
551
  $label = $field.closest(selector.group).find('label').eq(0);
@@ -550,10 +553,10 @@ $.fn.form = function(parameters) {
550
553
  ? $label.text()
551
554
  : $field.prop('placeholder') || settings.text.unspecifiedField
552
555
  ;
553
- prompt = prompt.replace('{name}', name);
556
+ prompt = prompt.replace(/\{name\}/g, name);
554
557
  }
555
- prompt = prompt.replace('{identifier}', field.identifier);
556
- prompt = prompt.replace('{ruleValue}', ancillary);
558
+ prompt = prompt.replace(/\{identifier\}/g, field.identifier);
559
+ prompt = prompt.replace(/\{ruleValue\}/g, ancillary);
557
560
  if(!rule.prompt) {
558
561
  module.verbose('Using default validation prompt for type', prompt, ruleName);
559
562
  }
@@ -703,7 +706,7 @@ $.fn.form = function(parameters) {
703
706
  }
704
707
  else {
705
708
  if(isRadio) {
706
- if(values[name] === undefined || values[name] == false) {
709
+ if(values[name] === undefined || values[name] === false) {
707
710
  values[name] = (isChecked)
708
711
  ? value || true
709
712
  : false
@@ -818,26 +821,36 @@ $.fn.form = function(parameters) {
818
821
  module.add.field(name, rules);
819
822
  },
820
823
  field: function(name, rules) {
824
+ // Validation should have at least a standard format
825
+ if(validation[name] === undefined || validation[name].rules === undefined) {
826
+ validation[name] = {
827
+ rules: []
828
+ };
829
+ }
821
830
  var
822
- newValidation = {}
831
+ newValidation = {
832
+ rules: []
833
+ }
823
834
  ;
824
835
  if(module.is.shorthandRules(rules)) {
825
836
  rules = Array.isArray(rules)
826
837
  ? rules
827
838
  : [rules]
828
839
  ;
829
- newValidation[name] = {
830
- rules: []
831
- };
832
- $.each(rules, function(index, rule) {
833
- newValidation[name].rules.push({ type: rule });
840
+ $.each(rules, function(_index, rule) {
841
+ newValidation.rules.push({ type: rule });
834
842
  });
835
843
  }
836
844
  else {
837
- newValidation[name] = rules;
845
+ newValidation.rules = rules.rules;
838
846
  }
839
- validation = $.extend({}, validation, newValidation);
840
- module.debug('Adding rules', newValidation, validation);
847
+ // For each new rule, check if there's not already one with the same type
848
+ $.each(newValidation.rules, function (_index, rule) {
849
+ if ($.grep(validation[name].rules, function(item){ return item.type == rule.type; }).length == 0) {
850
+ validation[name].rules.push(rule);
851
+ }
852
+ });
853
+ module.debug('Adding rules', newValidation.rules, validation);
841
854
  },
842
855
  fields: function(fields) {
843
856
  var
@@ -991,6 +1004,8 @@ $.fn.form = function(parameters) {
991
1004
  $parent = $el.parent(),
992
1005
  isCheckbox = ($el.filter(selector.checkbox).length > 0),
993
1006
  isDropdown = $parent.is(selector.uiDropdown) && module.can.useElement('dropdown'),
1007
+ $calendar = $el.closest(selector.uiCalendar),
1008
+ isCalendar = ($calendar.length > 0 && module.can.useElement('calendar')),
994
1009
  value = (isCheckbox)
995
1010
  ? $el.is(':checked')
996
1011
  : $el.val()
@@ -998,6 +1013,9 @@ $.fn.form = function(parameters) {
998
1013
  if (isDropdown) {
999
1014
  $parent.dropdown('save defaults');
1000
1015
  }
1016
+ else if (isCalendar) {
1017
+ $calendar.calendar('refresh');
1018
+ }
1001
1019
  $el.data(metadata.defaultValue, value);
1002
1020
  $el.data(metadata.isDirty, false);
1003
1021
  });
@@ -1053,7 +1071,7 @@ $.fn.form = function(parameters) {
1053
1071
  }
1054
1072
  else if(isCheckbox) {
1055
1073
  module.verbose('Setting checkbox value', value, $element);
1056
- if(value === true) {
1074
+ if(value === true || value === 1) {
1057
1075
  $element.checkbox('check');
1058
1076
  }
1059
1077
  else {
@@ -1101,6 +1119,32 @@ $.fn.form = function(parameters) {
1101
1119
  asDirty: function() {
1102
1120
  module.set.defaults();
1103
1121
  module.set.dirty();
1122
+ },
1123
+ autoCheck: function() {
1124
+ module.debug('Enabling auto check on required fields');
1125
+ $field.each(function (_index, el) {
1126
+ var
1127
+ $el = $(el),
1128
+ $elGroup = $(el).closest($group),
1129
+ isCheckbox = ($el.filter(selector.checkbox).length > 0),
1130
+ isRequired = $el.prop('required') || $elGroup.hasClass(className.required) || $elGroup.parent().hasClass(className.required),
1131
+ isDisabled = $el.prop('disabled') || $elGroup.hasClass(className.disabled) || $elGroup.parent().hasClass(className.disabled),
1132
+ validation = module.get.validation($el),
1133
+ hasEmptyRule = validation
1134
+ ? $.grep(validation.rules, function(rule) { return rule.type == "empty" }) !== 0
1135
+ : false,
1136
+ identifier = validation.identifier || $el.attr('id') || $el.attr('name') || $el.data(metadata.validate)
1137
+ ;
1138
+ if (isRequired && !isDisabled && !hasEmptyRule && identifier !== undefined) {
1139
+ if (isCheckbox) {
1140
+ module.verbose("Adding 'checked' rule on field", identifier);
1141
+ module.add.rule(identifier, "checked");
1142
+ } else {
1143
+ module.verbose("Adding 'empty' rule on field", identifier);
1144
+ module.add.rule(identifier, "empty");
1145
+ }
1146
+ }
1147
+ });
1104
1148
  }
1105
1149
  },
1106
1150
 
@@ -1440,6 +1484,7 @@ $.fn.form.settings = {
1440
1484
  transition : 'scale',
1441
1485
  duration : 200,
1442
1486
 
1487
+ autoCheckRequired : false,
1443
1488
  preventLeaving : false,
1444
1489
  dateHandling : 'date', // 'date', 'input', 'formatter'
1445
1490
 
@@ -1520,10 +1565,12 @@ $.fn.form.settings = {
1520
1565
  },
1521
1566
 
1522
1567
  className : {
1523
- error : 'error',
1524
- label : 'ui basic red pointing prompt label',
1525
- pressed : 'down',
1526
- success : 'success'
1568
+ error : 'error',
1569
+ label : 'ui basic red pointing prompt label',
1570
+ pressed : 'down',
1571
+ success : 'success',
1572
+ required : 'required',
1573
+ disabled : 'disabled'
1527
1574
  },
1528
1575
 
1529
1576
  error: {
@@ -81,6 +81,7 @@ $.fn.modal = function(parameters) {
81
81
  initialMouseDownInModal,
82
82
  initialMouseDownInScrollbar,
83
83
  initialBodyMargin = '',
84
+ tempBodyMargin = '',
84
85
 
85
86
  elementEventNamespace,
86
87
  id,
@@ -90,6 +91,7 @@ $.fn.modal = function(parameters) {
90
91
  module = {
91
92
 
92
93
  initialize: function() {
94
+ module.cache = {};
93
95
  module.verbose('Initializing dimmer', $context);
94
96
 
95
97
  module.create.id();
@@ -279,13 +281,14 @@ $.fn.modal = function(parameters) {
279
281
  },
280
282
  mousedown: function(event) {
281
283
  var
282
- $target = $(event.target)
284
+ $target = $(event.target),
285
+ isRtl = module.is.rtl();
283
286
  ;
284
287
  initialMouseDownInModal = ($target.closest(selector.modal).length > 0);
285
288
  if(initialMouseDownInModal) {
286
289
  module.verbose('Mouse down event registered inside the modal');
287
290
  }
288
- initialMouseDownInScrollbar = module.is.scrolling() && $(window).outerWidth() - settings.scrollbarWidth <= event.clientX;
291
+ initialMouseDownInScrollbar = module.is.scrolling() && ((!isRtl && $(window).outerWidth() - settings.scrollbarWidth <= event.clientX) || (isRtl && settings.scrollbarWidth >= event.clientX));
289
292
  if(initialMouseDownInScrollbar) {
290
293
  module.verbose('Mouse down event registered inside the scrollbar');
291
294
  }
@@ -388,6 +391,7 @@ $.fn.modal = function(parameters) {
388
391
  if( module.is.animating() || !module.is.active() ) {
389
392
  module.showDimmer();
390
393
  module.cacheSizes();
394
+ module.set.bodyMargin();
391
395
  if(module.can.useFlex()) {
392
396
  module.remove.legacy();
393
397
  }
@@ -605,12 +609,10 @@ $.fn.modal = function(parameters) {
605
609
  }
606
610
  },
607
611
  bodyMargin: function() {
608
- initialBodyMargin = $body.css('margin-right');
612
+ initialBodyMargin = $body.css('margin-'+(module.can.leftBodyScrollbar() ? 'left':'right'));
609
613
  var bodyMarginRightPixel = parseInt(initialBodyMargin.replace(/[^\d.]/g, '')),
610
- bodyScrollbarWidth = window.innerWidth - document.documentElement.clientWidth,
611
- diffPos = bodyMarginRightPixel + bodyScrollbarWidth;
612
- $body.css('margin-right', diffPos + 'px');
613
- $body.find(selector.bodyFixed).css('padding-right', diffPos + 'px');
614
+ bodyScrollbarWidth = window.innerWidth - document.documentElement.clientWidth;
615
+ tempBodyMargin = bodyMarginRightPixel + bodyScrollbarWidth;
614
616
  }
615
617
  },
616
618
 
@@ -621,8 +623,9 @@ $.fn.modal = function(parameters) {
621
623
  }
622
624
  },
623
625
  bodyMargin: function() {
624
- $body.css('margin-right', initialBodyMargin);
625
- $body.find(selector.bodyFixed).css('padding-right', initialBodyMargin);
626
+ var position = module.can.leftBodyScrollbar() ? 'left':'right';
627
+ $body.css('margin-'+position, initialBodyMargin);
628
+ $body.find(selector.bodyFixed.replace('right',position)).css('padding-'+position, initialBodyMargin);
626
629
  }
627
630
  },
628
631
 
@@ -634,6 +637,11 @@ $.fn.modal = function(parameters) {
634
637
  $module.removeClass(className.legacy);
635
638
  },
636
639
  clickaway: function() {
640
+ if (!settings.detachable) {
641
+ $module
642
+ .off('mousedown' + elementEventNamespace)
643
+ ;
644
+ }
637
645
  $dimmer
638
646
  .off('mousedown' + elementEventNamespace)
639
647
  ;
@@ -676,8 +684,8 @@ $.fn.modal = function(parameters) {
676
684
  modalWidth = $module.outerWidth(),
677
685
  modalHeight = $module.outerHeight()
678
686
  ;
679
- if(module.cache === undefined || modalHeight !== 0) {
680
- module.cache = {
687
+ if(module.cache.pageHeight === undefined || modalHeight !== 0) {
688
+ $.extend(module.cache, {
681
689
  pageHeight : $(document).outerHeight(),
682
690
  width : modalWidth,
683
691
  height : modalHeight + settings.offset,
@@ -685,7 +693,7 @@ $.fn.modal = function(parameters) {
685
693
  contextHeight : (settings.context == 'body')
686
694
  ? $(window).height()
687
695
  : $dimmable.height(),
688
- };
696
+ });
689
697
  module.cache.topOffset = -(module.cache.height / 2);
690
698
  }
691
699
  $module.removeClass(className.loading);
@@ -693,11 +701,22 @@ $.fn.modal = function(parameters) {
693
701
  },
694
702
 
695
703
  can: {
704
+ leftBodyScrollbar: function(){
705
+ if(module.cache.leftBodyScrollbar === undefined) {
706
+ module.cache.leftBodyScrollbar = module.is.rtl() && ((module.is.iframe && !module.is.firefox()) || module.is.safari() || module.is.edge() || module.is.ie());
707
+ }
708
+ return module.cache.leftBodyScrollbar;
709
+ },
696
710
  useFlex: function() {
697
- return (settings.useFlex == 'auto')
698
- ? settings.detachable && !module.is.ie()
699
- : settings.useFlex
700
- ;
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;
701
720
  },
702
721
  fit: function() {
703
722
  var
@@ -721,11 +740,14 @@ $.fn.modal = function(parameters) {
721
740
  return $module.hasClass(className.active);
722
741
  },
723
742
  ie: function() {
724
- var
725
- isIE11 = (!(window.ActiveXObject) && 'ActiveXObject' in window),
726
- isIE = ('ActiveXObject' in window)
727
- ;
728
- return (isIE11 || isIE);
743
+ if(module.cache.isIE === undefined) {
744
+ var
745
+ isIE11 = (!(window.ActiveXObject) && 'ActiveXObject' in window),
746
+ isIE = ('ActiveXObject' in window)
747
+ ;
748
+ module.cache.isIE = (isIE11 || isIE);
749
+ }
750
+ return module.cache.isIE;
729
751
  },
730
752
  animating: function() {
731
753
  return $module.transition('is supported')
@@ -739,6 +761,33 @@ $.fn.modal = function(parameters) {
739
761
  modernBrowser: function() {
740
762
  // appName for IE11 reports 'Netscape' can no longer use
741
763
  return !(window.ActiveXObject || 'ActiveXObject' in window);
764
+ },
765
+ rtl: function() {
766
+ if(module.cache.isRTL === undefined) {
767
+ module.cache.isRTL = $body.attr('dir') === 'rtl' || $body.css('direction') === 'rtl';
768
+ }
769
+ return module.cache.isRTL;
770
+ },
771
+ safari: function() {
772
+ if(module.cache.isSafari === undefined) {
773
+ module.cache.isSafari = /constructor/i.test(window.HTMLElement) || !!window.ApplePaySession;
774
+ }
775
+ return module.cache.isSafari;
776
+ },
777
+ edge: function(){
778
+ if(module.cache.isEdge === undefined) {
779
+ module.cache.isEdge = !!window.setImmediate && !module.is.ie();
780
+ }
781
+ return module.cache.isEdge;
782
+ },
783
+ firefox: function(){
784
+ if(module.cache.isFirefox === undefined) {
785
+ module.cache.isFirefox = !!window.InstallTrigger;
786
+ }
787
+ return module.cache.isFirefox;
788
+ },
789
+ iframe: function() {
790
+ return !(self === top);
742
791
  }
743
792
  },
744
793
 
@@ -757,7 +806,19 @@ $.fn.modal = function(parameters) {
757
806
  $input.focus();
758
807
  }
759
808
  },
809
+ bodyMargin: function() {
810
+ var position = module.can.leftBodyScrollbar() ? 'left':'right';
811
+ if(settings.detachable || module.can.fit()) {
812
+ $body.css('margin-'+position, tempBodyMargin + 'px');
813
+ }
814
+ $body.find(selector.bodyFixed.replace('right',position)).css('padding-'+position, tempBodyMargin + 'px');
815
+ },
760
816
  clickaway: function() {
817
+ if (!settings.detachable) {
818
+ $module
819
+ .on('mousedown' + elementEventNamespace, module.event.mousedown)
820
+ ;
821
+ }
761
822
  $dimmer
762
823
  .on('mousedown' + elementEventNamespace, module.event.mousedown)
763
824
  ;
@@ -806,18 +867,28 @@ $.fn.modal = function(parameters) {
806
867
  }
807
868
  },
808
869
  modalOffset: function() {
809
- var
810
- width = module.cache.width,
811
- height = module.cache.height
812
- ;
813
- $module
814
- .css({
815
- marginTop: (!$module.hasClass('aligned') && module.can.fit())
816
- ? -(height / 2)
817
- : 0,
818
- marginLeft: -(width / 2)
819
- })
820
- ;
870
+ if (!settings.detachable) {
871
+ var canFit = module.can.fit();
872
+ $module
873
+ .css({
874
+ top: (!$module.hasClass('aligned') && canFit)
875
+ ? $(document).scrollTop() + (module.cache.contextHeight - module.cache.height) / 2
876
+ : !canFit || $module.hasClass('top')
877
+ ? $(document).scrollTop() + settings.padding
878
+ : $(document).scrollTop() + (module.cache.contextHeight - module.cache.height - settings.padding),
879
+ marginLeft: -(module.cache.width / 2)
880
+ })
881
+ ;
882
+ } else {
883
+ $module
884
+ .css({
885
+ marginTop: (!$module.hasClass('aligned') && module.can.fit())
886
+ ? -(module.cache.height / 2)
887
+ : settings.padding / 2,
888
+ marginLeft: -(module.cache.width / 2)
889
+ })
890
+ ;
891
+ }
821
892
  module.verbose('Setting modal offset for legacy mode');
822
893
  },
823
894
  screenHeight: function() {
@@ -286,18 +286,18 @@ $.fn.popup = function(parameters) {
286
286
  }
287
287
  settings.onCreate.call($popup, element);
288
288
  }
289
- else if($target.next(selector.popup).length !== 0) {
290
- module.verbose('Pre-existing popup found');
291
- settings.inline = true;
292
- settings.popup = $target.next(selector.popup).data(metadata.activator, $module);
289
+ else if(settings.popup) {
290
+ $(settings.popup).data(metadata.activator, $module);
291
+ module.verbose('Used popup specified in settings');
293
292
  module.refresh();
294
293
  if(settings.hoverable) {
295
294
  module.bind.popup();
296
295
  }
297
296
  }
298
- else if(settings.popup) {
299
- $(settings.popup).data(metadata.activator, $module);
300
- module.verbose('Used popup specified in settings');
297
+ else if($target.next(selector.popup).length !== 0) {
298
+ module.verbose('Pre-existing popup found');
299
+ settings.inline = true;
300
+ settings.popup = $target.next(selector.popup).data(metadata.activator, $module);
301
301
  module.refresh();
302
302
  if(settings.hoverable) {
303
303
  module.bind.popup();
@@ -1134,7 +1134,7 @@ $.fn.popup = function(parameters) {
1134
1134
  return !module.is.visible();
1135
1135
  },
1136
1136
  rtl: function () {
1137
- return $module.css('direction') == 'rtl';
1137
+ return $module.attr('dir') === 'rtl' || $module.css('direction') === 'rtl';
1138
1138
  }
1139
1139
  },
1140
1140
 
@@ -1496,10 +1496,9 @@ $.fn.popup.settings = {
1496
1496
  templates: {
1497
1497
  escape: function(string) {
1498
1498
  var
1499
- badChars = /[&<>"'`]/g,
1499
+ badChars = /[<>"'`]/g,
1500
1500
  shouldEscape = /[&<>"'`]/,
1501
1501
  escape = {
1502
- "&": "&amp;",
1503
1502
  "<": "&lt;",
1504
1503
  ">": "&gt;",
1505
1504
  '"': "&quot;",
@@ -1511,6 +1510,7 @@ $.fn.popup.settings = {
1511
1510
  }
1512
1511
  ;
1513
1512
  if(shouldEscape.test(string)) {
1513
+ string = string.replace(/&(?![a-z0-9#]{1,6};)/, "&amp;");
1514
1514
  return string.replace(badChars, escapedChar);
1515
1515
  }
1516
1516
  return string;