foundation-rails 5.4.5.0 → 5.5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. data/bower.json +2 -2
  2. data/foundation-rails.gemspec +1 -1
  3. data/lib/foundation/rails/generators/install_generator.rb +4 -4
  4. data/lib/foundation/rails/templates/application.html.erb +3 -2
  5. data/lib/foundation/rails/templates/application.html.haml +1 -1
  6. data/lib/foundation/rails/templates/application.html.slim +1 -1
  7. data/lib/foundation/rails/version.rb +1 -1
  8. data/vendor/assets/_settings.scss +25 -21
  9. data/vendor/assets/javascripts/foundation/foundation.abide.js +28 -23
  10. data/vendor/assets/javascripts/foundation/foundation.accordion.js +10 -8
  11. data/vendor/assets/javascripts/foundation/foundation.alert.js +4 -4
  12. data/vendor/assets/javascripts/foundation/foundation.clearing.js +3 -3
  13. data/vendor/assets/javascripts/foundation/foundation.dropdown.js +139 -22
  14. data/vendor/assets/javascripts/foundation/foundation.equalizer.js +1 -2
  15. data/vendor/assets/javascripts/foundation/foundation.interchange.js +14 -10
  16. data/vendor/assets/javascripts/foundation/foundation.joyride.js +18 -9
  17. data/vendor/assets/javascripts/foundation/foundation.js +86 -21
  18. data/vendor/assets/javascripts/foundation/foundation.magellan.js +15 -6
  19. data/vendor/assets/javascripts/foundation/foundation.offcanvas.js +14 -14
  20. data/vendor/assets/javascripts/foundation/foundation.orbit.js +3 -3
  21. data/vendor/assets/javascripts/foundation/foundation.reveal.js +16 -11
  22. data/vendor/assets/javascripts/foundation/foundation.slider.js +56 -28
  23. data/vendor/assets/javascripts/foundation/foundation.tab.js +9 -9
  24. data/vendor/assets/javascripts/foundation/foundation.tooltip.js +1 -1
  25. data/vendor/assets/javascripts/foundation/foundation.topbar.js +5 -5
  26. data/vendor/assets/stylesheets/foundation/_functions.scss +57 -12
  27. data/vendor/assets/stylesheets/foundation/_settings.scss +25 -21
  28. data/vendor/assets/stylesheets/foundation/components/_accordion.scss +1 -1
  29. data/vendor/assets/stylesheets/foundation/components/_alert-boxes.scss +2 -0
  30. data/vendor/assets/stylesheets/foundation/components/_button-groups.scss +1 -2
  31. data/vendor/assets/stylesheets/foundation/components/_buttons.scss +4 -5
  32. data/vendor/assets/stylesheets/foundation/components/_dropdown-buttons.scss +11 -10
  33. data/vendor/assets/stylesheets/foundation/components/_dropdown.scss +1 -0
  34. data/vendor/assets/stylesheets/foundation/components/_forms.scss +31 -32
  35. data/vendor/assets/stylesheets/foundation/components/_global.scss +53 -25
  36. data/vendor/assets/stylesheets/foundation/components/_grid.scss +18 -4
  37. data/vendor/assets/stylesheets/foundation/components/_icon-bar.scss +51 -15
  38. data/vendor/assets/stylesheets/foundation/components/_labels.scss +2 -2
  39. data/vendor/assets/stylesheets/foundation/components/_offcanvas.scss +8 -6
  40. data/vendor/assets/stylesheets/foundation/components/_orbit.scss +11 -11
  41. data/vendor/assets/stylesheets/foundation/components/_panels.scss +6 -0
  42. data/vendor/assets/stylesheets/foundation/components/_reveal.scss +6 -3
  43. data/vendor/assets/stylesheets/foundation/components/_sub-nav.scss +1 -3
  44. data/vendor/assets/stylesheets/foundation/components/_switches.scss +25 -13
  45. data/vendor/assets/stylesheets/foundation/components/_tabs.scss +2 -2
  46. data/vendor/assets/stylesheets/foundation/components/_toolbar.scss +3 -3
  47. data/vendor/assets/stylesheets/foundation/components/_top-bar.scss +64 -53
  48. data/vendor/assets/stylesheets/foundation/components/_visibility.scss +7 -7
  49. data/vendor/assets/stylesheets/normalize.scss +5 -3
  50. metadata +8 -8
@@ -22,9 +22,13 @@
22
22
 
23
23
  header_helpers([
24
24
  'foundation-mq-small',
25
+ 'foundation-mq-small-only',
25
26
  'foundation-mq-medium',
27
+ 'foundation-mq-medium-only',
26
28
  'foundation-mq-large',
29
+ 'foundation-mq-large-only',
27
30
  'foundation-mq-xlarge',
31
+ 'foundation-mq-xlarge-only',
28
32
  'foundation-mq-xxlarge',
29
33
  'foundation-data-attribute-namespace']);
30
34
 
@@ -98,7 +102,6 @@
98
102
  var self = this,
99
103
  should_bind_events = !S(this).data(this.attr_name(true));
100
104
 
101
-
102
105
  if (S(this.scope).is('[' + this.attr_name() +']')) {
103
106
  S(this.scope).data(this.attr_name(true) + '-init', $.extend({}, this.settings, (options || method), this.data_options(S(this.scope))));
104
107
 
@@ -158,23 +161,23 @@
158
161
 
159
162
  window.matchMedia = window.matchMedia || (function( doc ) {
160
163
 
161
- "use strict";
164
+ 'use strict';
162
165
 
163
166
  var bool,
164
167
  docElem = doc.documentElement,
165
168
  refNode = docElem.firstElementChild || docElem.firstChild,
166
169
  // fakeBody required for <FF4 when executed in <head>
167
- fakeBody = doc.createElement( "body" ),
168
- div = doc.createElement( "div" );
170
+ fakeBody = doc.createElement( 'body' ),
171
+ div = doc.createElement( 'div' );
169
172
 
170
- div.id = "mq-test-1";
171
- div.style.cssText = "position:absolute;top:-100em";
172
- fakeBody.style.background = "none";
173
+ div.id = 'mq-test-1';
174
+ div.style.cssText = 'position:absolute;top:-100em';
175
+ fakeBody.style.background = 'none';
173
176
  fakeBody.appendChild(div);
174
177
 
175
178
  return function (q) {
176
179
 
177
- div.innerHTML = "&shy;<style media=\"" + q + "\"> #mq-test-1 { width: 42px; }</style>";
180
+ div.innerHTML = '&shy;<style media="' + q + '"> #mq-test-1 { width: 42px; }</style>';
178
181
 
179
182
  docElem.insertBefore( fakeBody, refNode );
180
183
  bool = div.offsetWidth === 42;
@@ -213,10 +216,10 @@
213
216
  jqueryFxAvailable = 'undefined' !== typeof jQuery.fx;
214
217
 
215
218
  for (; lastTime < vendors.length && !requestAnimationFrame; lastTime++) {
216
- requestAnimationFrame = window[ vendors[lastTime] + "RequestAnimationFrame" ];
219
+ requestAnimationFrame = window[ vendors[lastTime] + 'RequestAnimationFrame' ];
217
220
  cancelAnimationFrame = cancelAnimationFrame ||
218
- window[ vendors[lastTime] + "CancelAnimationFrame" ] ||
219
- window[ vendors[lastTime] + "CancelRequestAnimationFrame" ];
221
+ window[ vendors[lastTime] + 'CancelAnimationFrame' ] ||
222
+ window[ vendors[lastTime] + 'CancelRequestAnimationFrame' ];
220
223
  }
221
224
 
222
225
  function raf() {
@@ -278,14 +281,18 @@
278
281
  window.Foundation = {
279
282
  name : 'Foundation',
280
283
 
281
- version : '5.4.5',
284
+ version : '5.5.0',
282
285
 
283
286
  media_queries : {
284
- small : S('.foundation-mq-small').css('font-family').replace(/^[\/\\'"]+|(;\s?})+|[\/\\'"]+$/g, ''),
285
- medium : S('.foundation-mq-medium').css('font-family').replace(/^[\/\\'"]+|(;\s?})+|[\/\\'"]+$/g, ''),
286
- large : S('.foundation-mq-large').css('font-family').replace(/^[\/\\'"]+|(;\s?})+|[\/\\'"]+$/g, ''),
287
- xlarge: S('.foundation-mq-xlarge').css('font-family').replace(/^[\/\\'"]+|(;\s?})+|[\/\\'"]+$/g, ''),
288
- xxlarge: S('.foundation-mq-xxlarge').css('font-family').replace(/^[\/\\'"]+|(;\s?})+|[\/\\'"]+$/g, '')
287
+ 'small' : S('.foundation-mq-small').css('font-family').replace(/^[\/\\'"]+|(;\s?})+|[\/\\'"]+$/g, ''),
288
+ 'small-only' : S('.foundation-mq-small-only').css('font-family').replace(/^[\/\\'"]+|(;\s?})+|[\/\\'"]+$/g, ''),
289
+ 'medium' : S('.foundation-mq-medium').css('font-family').replace(/^[\/\\'"]+|(;\s?})+|[\/\\'"]+$/g, ''),
290
+ 'medium-only' : S('.foundation-mq-medium-only').css('font-family').replace(/^[\/\\'"]+|(;\s?})+|[\/\\'"]+$/g, ''),
291
+ 'large' : S('.foundation-mq-large').css('font-family').replace(/^[\/\\'"]+|(;\s?})+|[\/\\'"]+$/g, ''),
292
+ 'large-only' : S('.foundation-mq-large-only').css('font-family').replace(/^[\/\\'"]+|(;\s?})+|[\/\\'"]+$/g, ''),
293
+ 'xlarge' : S('.foundation-mq-xlarge').css('font-family').replace(/^[\/\\'"]+|(;\s?})+|[\/\\'"]+$/g, ''),
294
+ 'xlarge-only' : S('.foundation-mq-xlarge-only').css('font-family').replace(/^[\/\\'"]+|(;\s?})+|[\/\\'"]+$/g, ''),
295
+ 'xxlarge' : S('.foundation-mq-xxlarge').css('font-family').replace(/^[\/\\'"]+|(;\s?})+|[\/\\'"]+$/g, '')
289
296
  },
290
297
 
291
298
  stylesheet : $('<style></style>').appendTo('head')[0].sheet,
@@ -337,15 +344,15 @@
337
344
 
338
345
  if (args && args.hasOwnProperty(lib)) {
339
346
  if (typeof this.libs[lib].settings !== 'undefined') {
340
- $.extend(true, this.libs[lib].settings, args[lib]);
347
+ $.extend(true, this.libs[lib].settings, args[lib]);
341
348
  }
342
349
  else if (typeof this.libs[lib].defaults !== 'undefined') {
343
- $.extend(true, this.libs[lib].defaults, args[lib]);
350
+ $.extend(true, this.libs[lib].defaults, args[lib]);
344
351
  }
345
352
  return this.libs[lib].init.apply(this.libs[lib], [this.scope, args[lib]]);
346
353
  }
347
354
 
348
- args = args instanceof Array ? args : new Array(args); // PATCH: added this line
355
+ args = args instanceof Array ? args : new Array(args);
349
356
  return this.libs[lib].init.apply(this.libs[lib], args);
350
357
  }
351
358
 
@@ -504,7 +511,7 @@
504
511
  ii = opts_arr.length;
505
512
 
506
513
  function isNumber (o) {
507
- return ! isNaN (o-0) && o !== null && o !== "" && o !== false && o !== true;
514
+ return ! isNaN (o-0) && o !== null && o !== '' && o !== false && o !== true;
508
515
  }
509
516
 
510
517
  function trim (str) {
@@ -609,6 +616,64 @@
609
616
  this.prefix = this.prefix || [(this.name || 'F'), (+new Date).toString(36)].join('-');
610
617
 
611
618
  return this.prefix + (this.fidx++).toString(36);
619
+ },
620
+
621
+ // Description:
622
+ // Helper for window.matchMedia
623
+ //
624
+ // Arguments:
625
+ // mq (String): Media query
626
+ //
627
+ // Returns:
628
+ // (Boolean): Whether the media query passes or not
629
+ match : function (mq) {
630
+ return window.matchMedia(mq).matches;
631
+ },
632
+
633
+ // Description:
634
+ // Helpers for checking Foundation default media queries with JS
635
+ //
636
+ // Returns:
637
+ // (Boolean): Whether the media query passes or not
638
+
639
+ is_small_up : function () {
640
+ return this.match(Foundation.media_queries.small);
641
+ },
642
+
643
+ is_medium_up : function () {
644
+ return this.match(Foundation.media_queries.medium);
645
+ },
646
+
647
+ is_large_up : function () {
648
+ return this.match(Foundation.media_queries.large);
649
+ },
650
+
651
+ is_xlarge_up : function () {
652
+ return this.match(Foundation.media_queries.xlarge);
653
+ },
654
+
655
+ is_xxlarge_up : function () {
656
+ return this.match(Foundation.media_queries.xxlarge);
657
+ },
658
+
659
+ is_small_only : function () {
660
+ return !this.is_medium_up() && !this.is_large_up() && !this.is_xlarge_up() && !this.is_xxlarge_up();
661
+ },
662
+
663
+ is_medium_only : function () {
664
+ return this.is_medium_up() && !this.is_large_up() && !this.is_xlarge_up() && !this.is_xxlarge_up();
665
+ },
666
+
667
+ is_large_only : function () {
668
+ return this.is_medium_up() && this.is_large_up() && !this.is_xlarge_up() && !this.is_xxlarge_up();
669
+ },
670
+
671
+ is_xlarge_only : function () {
672
+ return this.is_medium_up() && this.is_large_up() && this.is_xlarge_up() && !this.is_xxlarge_up();
673
+ },
674
+
675
+ is_xxlarge_only : function () {
676
+ return this.is_medium_up() && this.is_large_up() && this.is_xlarge_up() && this.is_xxlarge_up();
612
677
  }
613
678
  }
614
679
  };
@@ -4,14 +4,17 @@
4
4
  Foundation.libs['magellan-expedition'] = {
5
5
  name : 'magellan-expedition',
6
6
 
7
- version : '5.4.5',
7
+ version : '5.5.0',
8
8
 
9
9
  settings : {
10
10
  active_class: 'active',
11
11
  threshold: 0, // pixels from the top of the expedition for it to become fixes
12
12
  destination_threshold: 20, // pixels from the top of destination for it to be considered active
13
13
  throttle_delay: 30, // calculation throttling to increase framerate
14
- fixed_top: 0 // top distance in pixels assigend to the fixed element on scroll
14
+ fixed_top: 0, // top distance in pixels assigend to the fixed element on scroll
15
+ offset_by_height: true, // whether to offset the destination by the expedition height. Usually you want this to be true, unless your expedition is on the side.
16
+ duration: 700, // animation duration time
17
+ easing: 'swing' // animation easing
15
18
  },
16
19
 
17
20
  init : function (scope, method, options) {
@@ -34,7 +37,7 @@
34
37
  var expedition = $(this).closest('[' + self.attr_name() + ']'),
35
38
  settings = expedition.data('magellan-expedition-init'),
36
39
  hash = this.hash.split('#').join(''),
37
- target = $("a[name='"+hash+"']");
40
+ target = $('a[name="'+hash+'"]');
38
41
 
39
42
  if (target.length === 0) {
40
43
  target = $('#'+hash);
@@ -44,11 +47,13 @@
44
47
 
45
48
  // Account for expedition height if fixed position
46
49
  var scroll_top = target.offset().top - settings.destination_threshold + 1;
47
- scroll_top = scroll_top - expedition.outerHeight();
50
+ if (settings.offset_by_height) {
51
+ scroll_top = scroll_top - expedition.outerHeight();
52
+ }
48
53
 
49
54
  $('html, body').stop().animate({
50
55
  'scrollTop': scroll_top
51
- }, 700, 'swing', function () {
56
+ }, settings.duration, settings.easing, function () {
52
57
  if(history.pushState) {
53
58
  history.pushState(null, null, '#'+hash);
54
59
  }
@@ -152,7 +157,11 @@
152
157
  var name = $(this).data(self.data_attr('magellan-arrival')),
153
158
  dest = $('[' + self.add_namespace('data-magellan-destination') + '=' + name + ']');
154
159
  if (dest.length > 0) {
155
- var top_offset = Math.floor(dest.offset().top - settings.destination_threshold - expedition.outerHeight());
160
+ var top_offset = dest.offset().top - settings.destination_threshold;
161
+ if (settings.offset_by_height) {
162
+ top_offset = top_offset - expedition.outerHeight();
163
+ }
164
+ top_offset = Math.floor(top_offset);
156
165
  return {
157
166
  destination : dest,
158
167
  arrival : $(this),
@@ -4,7 +4,7 @@
4
4
  Foundation.libs.offcanvas = {
5
5
  name : 'offcanvas',
6
6
 
7
- version : '5.4.5',
7
+ version : '5.5.0',
8
8
 
9
9
  settings : {
10
10
  open_method: 'move',
@@ -38,7 +38,7 @@
38
38
  .on('click.fndtn.offcanvas', '.left-off-canvas-toggle', function (e) {
39
39
  self.click_toggle_class(e, move_class + right_postfix);
40
40
  if (self.settings.open_method !== 'overlap'){
41
- S(".left-submenu").removeClass(move_class + right_postfix);
41
+ S('.left-submenu').removeClass(move_class + right_postfix);
42
42
  }
43
43
  $('.left-off-canvas-toggle').attr('aria-expanded', 'true');
44
44
  })
@@ -46,13 +46,13 @@
46
46
  var settings = self.get_settings(e);
47
47
  var parent = S(this).parent();
48
48
 
49
- if(settings.close_on_click && !parent.hasClass("has-submenu") && !parent.hasClass("back")){
49
+ if(settings.close_on_click && !parent.hasClass('has-submenu') && !parent.hasClass('back')){
50
50
  self.hide.call(self, move_class + right_postfix, self.get_wrapper(e));
51
51
  parent.parent().removeClass(move_class + right_postfix);
52
- }else if(S(this).parent().hasClass("has-submenu")){
52
+ }else if(S(this).parent().hasClass('has-submenu')){
53
53
  e.preventDefault();
54
- S(this).siblings(".left-submenu").toggleClass(move_class + right_postfix);
55
- }else if(parent.hasClass("back")){
54
+ S(this).siblings('.left-submenu').toggleClass(move_class + right_postfix);
55
+ }else if(parent.hasClass('back')){
56
56
  e.preventDefault();
57
57
  parent.parent().removeClass(move_class + right_postfix);
58
58
  }
@@ -61,7 +61,7 @@
61
61
  .on('click.fndtn.offcanvas', '.right-off-canvas-toggle', function (e) {
62
62
  self.click_toggle_class(e, move_class + left_postfix);
63
63
  if (self.settings.open_method !== 'overlap'){
64
- S(".right-submenu").removeClass(move_class + left_postfix);
64
+ S('.right-submenu').removeClass(move_class + left_postfix);
65
65
  }
66
66
  $('.right-off-canvas-toggle').attr('aria-expanded', 'true');
67
67
  })
@@ -69,13 +69,13 @@
69
69
  var settings = self.get_settings(e);
70
70
  var parent = S(this).parent();
71
71
 
72
- if(settings.close_on_click && !parent.hasClass("has-submenu") && !parent.hasClass("back")){
72
+ if(settings.close_on_click && !parent.hasClass('has-submenu') && !parent.hasClass('back')){
73
73
  self.hide.call(self, move_class + left_postfix, self.get_wrapper(e));
74
74
  parent.parent().removeClass(move_class + left_postfix);
75
- }else if(S(this).parent().hasClass("has-submenu")){
75
+ }else if(S(this).parent().hasClass('has-submenu')){
76
76
  e.preventDefault();
77
- S(this).siblings(".right-submenu").toggleClass(move_class + left_postfix);
78
- }else if(parent.hasClass("back")){
77
+ S(this).siblings('.right-submenu').toggleClass(move_class + left_postfix);
78
+ }else if(parent.hasClass('back')){
79
79
  e.preventDefault();
80
80
  parent.parent().removeClass(move_class + left_postfix);
81
81
  }
@@ -83,10 +83,10 @@
83
83
  })
84
84
  .on('click.fndtn.offcanvas', '.exit-off-canvas', function (e) {
85
85
  self.click_remove_class(e, move_class + left_postfix);
86
- S(".right-submenu").removeClass(move_class + left_postfix);
86
+ S('.right-submenu').removeClass(move_class + left_postfix);
87
87
  if (right_postfix){
88
88
  self.click_remove_class(e, move_class + right_postfix);
89
- S(".left-submenu").removeClass(move_class + left_postfix);
89
+ S('.left-submenu').removeClass(move_class + left_postfix);
90
90
  }
91
91
  $('.right-off-canvas-toggle').attr('aria-expanded', 'true');
92
92
  })
@@ -95,7 +95,7 @@
95
95
  $('.left-off-canvas-toggle').attr('aria-expanded', 'false');
96
96
  if (right_postfix) {
97
97
  self.click_remove_class(e, move_class + right_postfix);
98
- $('.right-off-canvas-toggle').attr('aria-expanded', "false");
98
+ $('.right-off-canvas-toggle').attr('aria-expanded', 'false');
99
99
  }
100
100
  });
101
101
  },
@@ -158,7 +158,7 @@
158
158
  self.link_custom = function(e) {
159
159
  e.preventDefault();
160
160
  var link = $(this).attr('data-orbit-link');
161
- if ((typeof link === 'string') && (link = $.trim(link)) != "") {
161
+ if ((typeof link === 'string') && (link = $.trim(link)) != '') {
162
162
  var slide = container.find('[data-orbit-slide='+link+']');
163
163
  if (slide.index() != -1) {self._goto(slide.index());}
164
164
  }
@@ -166,7 +166,7 @@
166
166
 
167
167
  self.link_bullet = function(e) {
168
168
  var index = $(this).attr('data-orbit-slide');
169
- if ((typeof index === 'string') && (index = $.trim(index)) != "") {
169
+ if ((typeof index === 'string') && (index = $.trim(index)) != '') {
170
170
  if(isNaN(parseInt(index)))
171
171
  {
172
172
  var slide = container.find('[data-orbit-slide='+index+']');
@@ -402,7 +402,7 @@
402
402
  Foundation.libs.orbit = {
403
403
  name: 'orbit',
404
404
 
405
- version: '5.4.5',
405
+ version: '5.5.0',
406
406
 
407
407
  settings: {
408
408
  animation: 'slide',
@@ -4,7 +4,7 @@
4
4
  Foundation.libs.reveal = {
5
5
  name : 'reveal',
6
6
 
7
- version : '5.4.5',
7
+ version : '5.5.0',
8
8
 
9
9
  locked : false,
10
10
 
@@ -15,6 +15,7 @@
15
15
  close_on_esc: true,
16
16
  dismiss_modal_class: 'close-reveal-modal',
17
17
  bg_class: 'reveal-modal-bg',
18
+ bg_root_element: 'body',
18
19
  root_element: 'body',
19
20
  open: function(){},
20
21
  opened: function(){},
@@ -71,7 +72,7 @@
71
72
  e.preventDefault();
72
73
 
73
74
  if (!self.locked) {
74
- var settings = S('[' + self.attr_name() + '].open').data(self.attr_name(true) + '-init'),
75
+ var settings = S('[' + self.attr_name() + '].open').data(self.attr_name(true) + '-init') || self.settings,
75
76
  bg_clicked = S(e.target)[0] === S('.' + settings.bg_class)[0];
76
77
 
77
78
  if (bg_clicked) {
@@ -193,7 +194,8 @@
193
194
  $.extend(ajax_settings, {
194
195
  success: function (data, textStatus, jqXHR) {
195
196
  if ( $.isFunction(old_success) ) {
196
- old_success(data, textStatus, jqXHR);
197
+ var result = old_success(data, textStatus, jqXHR);
198
+ if (typeof result == 'string') data = result;
197
199
  }
198
200
 
199
201
  modal.html(data);
@@ -237,10 +239,13 @@
237
239
  return base;
238
240
  },
239
241
 
240
- toggle_bg : function (modal, state) {
242
+ toggle_bg : function (el, modal, state) {
243
+ var settings = el.data(this.attr_name(true) + '-init') || this.settings,
244
+ bg_root_element = settings.bg_root_element; // Adding option to specify the background root element fixes scrolling issue
245
+
241
246
  if (this.S('.' + this.settings.bg_class).length === 0) {
242
247
  this.settings.bg = $('<div />', {'class': this.settings.bg_class})
243
- .appendTo('body').hide();
248
+ .appendTo(bg_root_element).hide();
244
249
  }
245
250
 
246
251
  var visible = this.settings.bg.filter(':visible').length > 0;
@@ -275,9 +280,9 @@
275
280
  this.locked = false;
276
281
  }
277
282
  if (animData.pop) {
278
- css.top = $(window).scrollTop() - el.data('offset') + 'px';
283
+ css.top = $(root_element).scrollTop() - el.data('offset') + 'px'; //adding root_element instead of window for scrolling offset if modal trigger is below the fold
279
284
  var end_css = {
280
- top: $(window).scrollTop() + el.data('css-top') + 'px',
285
+ top: $(root_element).scrollTop() + el.data('css-top') + 'px', //adding root_element instead of window for scrolling offset if modal trigger is below the fold
281
286
  opacity: 1
282
287
  };
283
288
 
@@ -293,7 +298,7 @@
293
298
  }
294
299
 
295
300
  if (animData.fade) {
296
- css.top = $(window).scrollTop() + el.data('css-top') + 'px';
301
+ css.top = $(root_element).scrollTop() + el.data('css-top') + 'px'; //adding root_element instead of window for scrolling offset if modal trigger is below the fold
297
302
  var end_css = {opacity: 1};
298
303
 
299
304
  return setTimeout(function () {
@@ -325,8 +330,8 @@
325
330
  hide : function (el, css) {
326
331
  // is modal
327
332
  if (css) {
328
- var settings = el.data(this.attr_name(true) + '-init');
329
- settings = settings || this.settings;
333
+ var settings = el.data(this.attr_name(true) + '-init') || this.settings,
334
+ root_element = settings.root_element;
330
335
 
331
336
  var animData = getAnimationData(settings.animation);
332
337
  if (!animData.animate) {
@@ -334,7 +339,7 @@
334
339
  }
335
340
  if (animData.pop) {
336
341
  var end_css = {
337
- top: - $(window).scrollTop() - el.data('offset') + 'px',
342
+ top: - $(root_element).scrollTop() - el.data('offset') + 'px', //adding root_element instead of window for scrolling offset if modal trigger is below the fold
338
343
  opacity: 0
339
344
  };
340
345
 
@@ -4,15 +4,17 @@
4
4
  Foundation.libs.slider = {
5
5
  name : 'slider',
6
6
 
7
- version : '5.4.5',
7
+ version : '5.5.0',
8
8
 
9
9
  settings: {
10
10
  start: 0,
11
11
  end: 100,
12
12
  step: 1,
13
+ precision: null,
13
14
  initial: null,
14
15
  display_selector: '',
15
16
  vertical: false,
17
+ trigger_input_change: false,
16
18
  on_change: function(){}
17
19
  },
18
20
 
@@ -44,16 +46,9 @@
44
46
  if (!e.pageY) {
45
47
  scroll_offset = window.scrollY;
46
48
  }
47
- self.calculate_position(self.cache.active, (e.pageY ||
48
- e.originalEvent.clientY ||
49
- e.originalEvent.touches[0].clientY ||
50
- e.currentPoint.y)
51
- + scroll_offset);
49
+ self.calculate_position(self.cache.active, self.get_cursor_position(e, 'y') + scroll_offset);
52
50
  } else {
53
- self.calculate_position(self.cache.active, e.pageX ||
54
- e.originalEvent.clientX ||
55
- e.originalEvent.touches[0].clientX ||
56
- e.currentPoint.x);
51
+ self.calculate_position(self.cache.active, self.get_cursor_position(e, 'x'));
57
52
  }
58
53
  }
59
54
  })
@@ -70,6 +65,26 @@
70
65
  }, 300));
71
66
  },
72
67
 
68
+ get_cursor_position : function(e, xy) {
69
+ var pageXY = 'page' + xy.toUpperCase(),
70
+ clientXY = 'client' + xy.toUpperCase(),
71
+ position;
72
+
73
+ if (typeof e[pageXY] !== 'undefined') {
74
+ position = e[pageXY];
75
+ }
76
+ else if (typeof e.originalEvent[clientXY] !== 'undefined') {
77
+ position = e.originalEvent[clientXY];
78
+ }
79
+ else if (e.originalEvent.touches && e.originalEvent.touches[0] && typeof e.originalEvent.touches[0][clientXY] !== 'undefined') {
80
+ position = e.originalEvent.touches[0][clientXY];
81
+ }
82
+ else if(e.currentPoint && typeof e.currentPoint[xy] !== 'undefined') {
83
+ position = e.currentPoint[xy];
84
+ }
85
+ return position;
86
+ },
87
+
73
88
  set_active_slider : function($handle) {
74
89
  this.cache.active = $handle;
75
90
  },
@@ -97,7 +112,7 @@
97
112
 
98
113
  pct = settings.vertical ? 1-pct : pct;
99
114
 
100
- var norm = self.normalized_value(pct, settings.start, settings.end, settings.step);
115
+ var norm = self.normalized_value(pct, settings.start, settings.end, settings.step, settings.precision);
101
116
 
102
117
  self.set_ui($handle, norm);
103
118
  });
@@ -109,7 +124,9 @@
109
124
  bar_l = $.data($handle[0], 'bar_l'),
110
125
  norm_pct = this.normalized_percentage(value, settings.start, settings.end),
111
126
  handle_offset = norm_pct*(bar_l-handle_l)-1,
112
- progress_bar_length = norm_pct*100;
127
+ progress_bar_length = norm_pct*100,
128
+ $handle_parent = $handle.parent(),
129
+ $hidden_inputs = $handle.parent().children('input[type=hidden]');
113
130
 
114
131
  if (Foundation.rtl && !settings.vertical) {
115
132
  handle_offset = -handle_offset;
@@ -124,27 +141,30 @@
124
141
  $handle.siblings('.range-slider-active-segment').css('width', progress_bar_length + '%');
125
142
  }
126
143
 
127
- $handle.parent().attr(this.attr_name(), value).trigger('change').trigger('change.fndtn.slider');
144
+ $handle_parent.attr(this.attr_name(), value).trigger('change').trigger('change.fndtn.slider');
128
145
 
129
- $handle.parent().children('input[type=hidden]').val(value);
146
+ $hidden_inputs.val(value);
147
+ if (settings.trigger_input_change) {
148
+ $hidden_inputs.trigger('change');
149
+ }
130
150
 
131
151
  if (!$handle[0].hasAttribute('aria-valuemin')) {
132
152
  $handle.attr({
133
153
  'aria-valuemin': settings.start,
134
- 'aria-valuemax': settings.end,
154
+ 'aria-valuemax': settings.end
135
155
  });
136
156
  }
137
157
  $handle.attr('aria-valuenow', value);
138
158
 
139
- // if (settings.input_id != '') {
140
- // $(settings.display_selector).each(function(){
141
- // if (this.hasOwnProperty('value')) {
142
- // $(this).val(value);
143
- // } else {
144
- // $(this).text(value);
145
- // }
146
- // });
147
- // }
159
+ if (settings.display_selector != '') {
160
+ $(settings.display_selector).each(function(){
161
+ if (this.hasOwnProperty('value')) {
162
+ $(this).val(value);
163
+ } else {
164
+ $(this).text(value);
165
+ }
166
+ });
167
+ }
148
168
 
149
169
  },
150
170
 
@@ -152,13 +172,13 @@
152
172
  return Math.min(1, (val - start)/(end - start));
153
173
  },
154
174
 
155
- normalized_value : function(val, start, end, step) {
175
+ normalized_value : function(val, start, end, step, precision) {
156
176
  var range = end - start,
157
177
  point = val*range,
158
178
  mod = (point-(point%step)) / step,
159
179
  rem = point % step,
160
180
  round = ( rem >= step*0.5 ? step : 0);
161
- return (mod*step + round) + start;
181
+ return ((mod*step + round) + start).toFixed(precision);
162
182
  },
163
183
 
164
184
  set_translate : function(ele, offset, vertical) {
@@ -183,8 +203,16 @@
183
203
  return Math.min(Math.max(val, min), max);
184
204
  },
185
205
 
206
+
207
+
186
208
  initialize_settings : function(handle) {
187
- var settings = $.extend({}, this.settings, this.data_options($(handle).parent()));
209
+ var settings = $.extend({}, this.settings, this.data_options($(handle).parent())),
210
+ decimal_places_match_result;
211
+
212
+ if (settings.precision === null) {
213
+ decimal_places_match_result = ('' + settings.step).match(/\.([\d]*)/);
214
+ settings.precision = decimal_places_match_result && decimal_places_match_result[1] ? decimal_places_match_result[1].length : 0;
215
+ }
188
216
 
189
217
  if (settings.vertical) {
190
218
  $.data(handle, 'bar_o', $(handle).parent().offset().top);
@@ -204,7 +232,7 @@
204
232
 
205
233
  set_initial_position : function($ele) {
206
234
  var settings = $.data($ele.children('.range-slider-handle')[0], 'settings'),
207
- initial = (!!settings.initial ? settings.initial : Math.floor((settings.end-settings.start)*0.5/settings.step)*settings.step+settings.start),
235
+ initial = ((typeof settings.initial == 'number' && !isNaN(settings.initial)) ? settings.initial : Math.floor((settings.end-settings.start)*0.5/settings.step)*settings.step+settings.start),
208
236
  $handle = $ele.children('.range-slider-handle');
209
237
  this.set_ui($handle, initial);
210
238
  },