foundation_front_end 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +21 -0
  5. data/README.md +64 -0
  6. data/Rakefile +1 -0
  7. data/bin/console +14 -0
  8. data/bin/setup +7 -0
  9. data/foundation_front_end.gemspec +32 -0
  10. data/lib/foundation_front_end.rb +21 -0
  11. data/lib/foundation_front_end/version.rb +3 -0
  12. data/vendor/assets/javascripts/foundation.min.js +6376 -0
  13. data/vendor/assets/javascripts/foundation/foundation.abide.js +408 -0
  14. data/vendor/assets/javascripts/foundation/foundation.accordion.js +88 -0
  15. data/vendor/assets/javascripts/foundation/foundation.alert.js +43 -0
  16. data/vendor/assets/javascripts/foundation/foundation.clearing.js +586 -0
  17. data/vendor/assets/javascripts/foundation/foundation.dropdown.js +463 -0
  18. data/vendor/assets/javascripts/foundation/foundation.equalizer.js +104 -0
  19. data/vendor/assets/javascripts/foundation/foundation.interchange.js +359 -0
  20. data/vendor/assets/javascripts/foundation/foundation.joyride.js +932 -0
  21. data/vendor/assets/javascripts/foundation/foundation.js +725 -0
  22. data/vendor/assets/javascripts/foundation/foundation.magellan.js +215 -0
  23. data/vendor/assets/javascripts/foundation/foundation.offcanvas.js +152 -0
  24. data/vendor/assets/javascripts/foundation/foundation.orbit.js +476 -0
  25. data/vendor/assets/javascripts/foundation/foundation.reveal.js +498 -0
  26. data/vendor/assets/javascripts/foundation/foundation.slider.js +281 -0
  27. data/vendor/assets/javascripts/foundation/foundation.tab.js +249 -0
  28. data/vendor/assets/javascripts/foundation/foundation.tooltip.js +339 -0
  29. data/vendor/assets/javascripts/foundation/foundation.topbar.js +458 -0
  30. data/vendor/assets/javascripts/vendor/fastclick.js +8 -0
  31. data/vendor/assets/javascripts/vendor/jquery.cookie.js +8 -0
  32. data/vendor/assets/javascripts/vendor/jquery.js +27 -0
  33. data/vendor/assets/javascripts/vendor/modernizr.js +8 -0
  34. data/vendor/assets/javascripts/vendor/placeholder.js +2 -0
  35. data/vendor/assets/stylesheets/foundation.css +6324 -0
  36. data/vendor/assets/stylesheets/foundation.min.css +1 -0
  37. data/vendor/assets/stylesheets/normalize.css +424 -0
  38. metadata +110 -0
@@ -0,0 +1,215 @@
1
+ ;(function ($, window, document, undefined) {
2
+ 'use strict';
3
+
4
+ Foundation.libs['magellan-expedition'] = {
5
+ name : 'magellan-expedition',
6
+
7
+ version : '5.5.2',
8
+
9
+ settings : {
10
+ active_class : 'active',
11
+ threshold : 0, // pixels from the top of the expedition for it to become fixes
12
+ destination_threshold : 20, // pixels from the top of destination for it to be considered active
13
+ throttle_delay : 30, // calculation throttling to increase framerate
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
18
+ },
19
+
20
+ init : function (scope, method, options) {
21
+ Foundation.inherit(this, 'throttle');
22
+ this.bindings(method, options);
23
+ },
24
+
25
+ events : function () {
26
+ var self = this,
27
+ S = self.S,
28
+ settings = self.settings;
29
+
30
+ // initialize expedition offset
31
+ self.set_expedition_position();
32
+
33
+ S(self.scope)
34
+ .off('.magellan')
35
+ .on('click.fndtn.magellan', '[' + self.add_namespace('data-magellan-arrival') + '] a[href*=#]', function (e) {
36
+ var sameHost = ((this.hostname === location.hostname) || !this.hostname),
37
+ samePath = self.filterPathname(location.pathname) === self.filterPathname(this.pathname),
38
+ testHash = this.hash.replace(/(:|\.|\/)/g, '\\$1'),
39
+ anchor = this;
40
+
41
+ if (sameHost && samePath && testHash) {
42
+ e.preventDefault();
43
+ var expedition = $(this).closest('[' + self.attr_name() + ']'),
44
+ settings = expedition.data('magellan-expedition-init'),
45
+ hash = this.hash.split('#').join(''),
46
+ target = $('a[name="' + hash + '"]');
47
+
48
+ if (target.length === 0) {
49
+ target = $('#' + hash);
50
+
51
+ }
52
+
53
+ // Account for expedition height if fixed position
54
+ var scroll_top = target.offset().top - settings.destination_threshold + 1;
55
+ if (settings.offset_by_height) {
56
+ scroll_top = scroll_top - expedition.outerHeight();
57
+ }
58
+ $('html, body').stop().animate({
59
+ 'scrollTop' : scroll_top
60
+ }, settings.duration, settings.easing, function () {
61
+ if (history.pushState) {
62
+ history.pushState(null, null, anchor.pathname + '#' + hash);
63
+ }
64
+ else {
65
+ location.hash = anchor.pathname + '#' + hash;
66
+ }
67
+ });
68
+ }
69
+ })
70
+ .on('scroll.fndtn.magellan', self.throttle(this.check_for_arrivals.bind(this), settings.throttle_delay));
71
+ },
72
+
73
+ check_for_arrivals : function () {
74
+ var self = this;
75
+ self.update_arrivals();
76
+ self.update_expedition_positions();
77
+ },
78
+
79
+ set_expedition_position : function () {
80
+ var self = this;
81
+ $('[' + this.attr_name() + '=fixed]', self.scope).each(function (idx, el) {
82
+ var expedition = $(this),
83
+ settings = expedition.data('magellan-expedition-init'),
84
+ styles = expedition.attr('styles'), // save styles
85
+ top_offset, fixed_top;
86
+
87
+ expedition.attr('style', '');
88
+ top_offset = expedition.offset().top + settings.threshold;
89
+
90
+ //set fixed-top by attribute
91
+ fixed_top = parseInt(expedition.data('magellan-fixed-top'));
92
+ if (!isNaN(fixed_top)) {
93
+ self.settings.fixed_top = fixed_top;
94
+ }
95
+
96
+ expedition.data(self.data_attr('magellan-top-offset'), top_offset);
97
+ expedition.attr('style', styles);
98
+ });
99
+ },
100
+
101
+ update_expedition_positions : function () {
102
+ var self = this,
103
+ window_top_offset = $(window).scrollTop();
104
+
105
+ $('[' + this.attr_name() + '=fixed]', self.scope).each(function () {
106
+ var expedition = $(this),
107
+ settings = expedition.data('magellan-expedition-init'),
108
+ styles = expedition.attr('style'), // save styles
109
+ top_offset = expedition.data('magellan-top-offset');
110
+
111
+ //scroll to the top distance
112
+ if (window_top_offset + self.settings.fixed_top >= top_offset) {
113
+ // Placeholder allows height calculations to be consistent even when
114
+ // appearing to switch between fixed/non-fixed placement
115
+ var placeholder = expedition.prev('[' + self.add_namespace('data-magellan-expedition-clone') + ']');
116
+ if (placeholder.length === 0) {
117
+ placeholder = expedition.clone();
118
+ placeholder.removeAttr(self.attr_name());
119
+ placeholder.attr(self.add_namespace('data-magellan-expedition-clone'), '');
120
+ expedition.before(placeholder);
121
+ }
122
+ expedition.css({position :'fixed', top : settings.fixed_top}).addClass('fixed');
123
+ } else {
124
+ expedition.prev('[' + self.add_namespace('data-magellan-expedition-clone') + ']').remove();
125
+ expedition.attr('style', styles).css('position', '').css('top', '').removeClass('fixed');
126
+ }
127
+ });
128
+ },
129
+
130
+ update_arrivals : function () {
131
+ var self = this,
132
+ window_top_offset = $(window).scrollTop();
133
+
134
+ $('[' + this.attr_name() + ']', self.scope).each(function () {
135
+ var expedition = $(this),
136
+ settings = expedition.data(self.attr_name(true) + '-init'),
137
+ offsets = self.offsets(expedition, window_top_offset),
138
+ arrivals = expedition.find('[' + self.add_namespace('data-magellan-arrival') + ']'),
139
+ active_item = false;
140
+ offsets.each(function (idx, item) {
141
+ if (item.viewport_offset >= item.top_offset) {
142
+ var arrivals = expedition.find('[' + self.add_namespace('data-magellan-arrival') + ']');
143
+ arrivals.not(item.arrival).removeClass(settings.active_class);
144
+ item.arrival.addClass(settings.active_class);
145
+ active_item = true;
146
+ return true;
147
+ }
148
+ });
149
+
150
+ if (!active_item) {
151
+ arrivals.removeClass(settings.active_class);
152
+ }
153
+ });
154
+ },
155
+
156
+ offsets : function (expedition, window_offset) {
157
+ var self = this,
158
+ settings = expedition.data(self.attr_name(true) + '-init'),
159
+ viewport_offset = window_offset;
160
+
161
+ return expedition.find('[' + self.add_namespace('data-magellan-arrival') + ']').map(function (idx, el) {
162
+ var name = $(this).data(self.data_attr('magellan-arrival')),
163
+ dest = $('[' + self.add_namespace('data-magellan-destination') + '=' + name + ']');
164
+ if (dest.length > 0) {
165
+ var top_offset = dest.offset().top - settings.destination_threshold;
166
+ if (settings.offset_by_height) {
167
+ top_offset = top_offset - expedition.outerHeight();
168
+ }
169
+ top_offset = Math.floor(top_offset);
170
+ return {
171
+ destination : dest,
172
+ arrival : $(this),
173
+ top_offset : top_offset,
174
+ viewport_offset : viewport_offset
175
+ }
176
+ }
177
+ }).sort(function (a, b) {
178
+ if (a.top_offset < b.top_offset) {
179
+ return -1;
180
+ }
181
+ if (a.top_offset > b.top_offset) {
182
+ return 1;
183
+ }
184
+ return 0;
185
+ });
186
+ },
187
+
188
+ data_attr : function (str) {
189
+ if (this.namespace.length > 0) {
190
+ return this.namespace + '-' + str;
191
+ }
192
+
193
+ return str;
194
+ },
195
+
196
+ off : function () {
197
+ this.S(this.scope).off('.magellan');
198
+ this.S(window).off('.magellan');
199
+ },
200
+
201
+ filterPathname : function (pathname) {
202
+ pathname = pathname || '';
203
+ return pathname
204
+ .replace(/^\//,'')
205
+ .replace(/(?:index|default).[a-zA-Z]{3,4}$/,'')
206
+ .replace(/\/$/,'');
207
+ },
208
+
209
+ reflow : function () {
210
+ var self = this;
211
+ // remove placeholder expeditions used for height calculation purposes
212
+ $('[' + self.add_namespace('data-magellan-expedition-clone') + ']', self.scope).remove();
213
+ }
214
+ };
215
+ }(jQuery, window, window.document));
@@ -0,0 +1,152 @@
1
+ ;(function ($, window, document, undefined) {
2
+ 'use strict';
3
+
4
+ Foundation.libs.offcanvas = {
5
+ name : 'offcanvas',
6
+
7
+ version : '5.5.2',
8
+
9
+ settings : {
10
+ open_method : 'move',
11
+ close_on_click : false
12
+ },
13
+
14
+ init : function (scope, method, options) {
15
+ this.bindings(method, options);
16
+ },
17
+
18
+ events : function () {
19
+ var self = this,
20
+ S = self.S,
21
+ move_class = '',
22
+ right_postfix = '',
23
+ left_postfix = '';
24
+
25
+ if (this.settings.open_method === 'move') {
26
+ move_class = 'move-';
27
+ right_postfix = 'right';
28
+ left_postfix = 'left';
29
+ } else if (this.settings.open_method === 'overlap_single') {
30
+ move_class = 'offcanvas-overlap-';
31
+ right_postfix = 'right';
32
+ left_postfix = 'left';
33
+ } else if (this.settings.open_method === 'overlap') {
34
+ move_class = 'offcanvas-overlap';
35
+ }
36
+
37
+ S(this.scope).off('.offcanvas')
38
+ .on('click.fndtn.offcanvas', '.left-off-canvas-toggle', function (e) {
39
+ self.click_toggle_class(e, move_class + right_postfix);
40
+ if (self.settings.open_method !== 'overlap') {
41
+ S('.left-submenu').removeClass(move_class + right_postfix);
42
+ }
43
+ $('.left-off-canvas-toggle').attr('aria-expanded', 'true');
44
+ })
45
+ .on('click.fndtn.offcanvas', '.left-off-canvas-menu a', function (e) {
46
+ var settings = self.get_settings(e);
47
+ var parent = S(this).parent();
48
+
49
+ if (settings.close_on_click && !parent.hasClass('has-submenu') && !parent.hasClass('back')) {
50
+ self.hide.call(self, move_class + right_postfix, self.get_wrapper(e));
51
+ parent.parent().removeClass(move_class + right_postfix);
52
+ } else if (S(this).parent().hasClass('has-submenu')) {
53
+ e.preventDefault();
54
+ S(this).siblings('.left-submenu').toggleClass(move_class + right_postfix);
55
+ } else if (parent.hasClass('back')) {
56
+ e.preventDefault();
57
+ parent.parent().removeClass(move_class + right_postfix);
58
+ }
59
+ $('.left-off-canvas-toggle').attr('aria-expanded', 'true');
60
+ })
61
+ .on('click.fndtn.offcanvas', '.right-off-canvas-toggle', function (e) {
62
+ self.click_toggle_class(e, move_class + left_postfix);
63
+ if (self.settings.open_method !== 'overlap') {
64
+ S('.right-submenu').removeClass(move_class + left_postfix);
65
+ }
66
+ $('.right-off-canvas-toggle').attr('aria-expanded', 'true');
67
+ })
68
+ .on('click.fndtn.offcanvas', '.right-off-canvas-menu a', function (e) {
69
+ var settings = self.get_settings(e);
70
+ var parent = S(this).parent();
71
+
72
+ if (settings.close_on_click && !parent.hasClass('has-submenu') && !parent.hasClass('back')) {
73
+ self.hide.call(self, move_class + left_postfix, self.get_wrapper(e));
74
+ parent.parent().removeClass(move_class + left_postfix);
75
+ } else if (S(this).parent().hasClass('has-submenu')) {
76
+ e.preventDefault();
77
+ S(this).siblings('.right-submenu').toggleClass(move_class + left_postfix);
78
+ } else if (parent.hasClass('back')) {
79
+ e.preventDefault();
80
+ parent.parent().removeClass(move_class + left_postfix);
81
+ }
82
+ $('.right-off-canvas-toggle').attr('aria-expanded', 'true');
83
+ })
84
+ .on('click.fndtn.offcanvas', '.exit-off-canvas', function (e) {
85
+ self.click_remove_class(e, move_class + left_postfix);
86
+ S('.right-submenu').removeClass(move_class + left_postfix);
87
+ if (right_postfix) {
88
+ self.click_remove_class(e, move_class + right_postfix);
89
+ S('.left-submenu').removeClass(move_class + left_postfix);
90
+ }
91
+ $('.right-off-canvas-toggle').attr('aria-expanded', 'true');
92
+ })
93
+ .on('click.fndtn.offcanvas', '.exit-off-canvas', function (e) {
94
+ self.click_remove_class(e, move_class + left_postfix);
95
+ $('.left-off-canvas-toggle').attr('aria-expanded', 'false');
96
+ if (right_postfix) {
97
+ self.click_remove_class(e, move_class + right_postfix);
98
+ $('.right-off-canvas-toggle').attr('aria-expanded', 'false');
99
+ }
100
+ });
101
+ },
102
+
103
+ toggle : function (class_name, $off_canvas) {
104
+ $off_canvas = $off_canvas || this.get_wrapper();
105
+ if ($off_canvas.is('.' + class_name)) {
106
+ this.hide(class_name, $off_canvas);
107
+ } else {
108
+ this.show(class_name, $off_canvas);
109
+ }
110
+ },
111
+
112
+ show : function (class_name, $off_canvas) {
113
+ $off_canvas = $off_canvas || this.get_wrapper();
114
+ $off_canvas.trigger('open.fndtn.offcanvas');
115
+ $off_canvas.addClass(class_name);
116
+ },
117
+
118
+ hide : function (class_name, $off_canvas) {
119
+ $off_canvas = $off_canvas || this.get_wrapper();
120
+ $off_canvas.trigger('close.fndtn.offcanvas');
121
+ $off_canvas.removeClass(class_name);
122
+ },
123
+
124
+ click_toggle_class : function (e, class_name) {
125
+ e.preventDefault();
126
+ var $off_canvas = this.get_wrapper(e);
127
+ this.toggle(class_name, $off_canvas);
128
+ },
129
+
130
+ click_remove_class : function (e, class_name) {
131
+ e.preventDefault();
132
+ var $off_canvas = this.get_wrapper(e);
133
+ this.hide(class_name, $off_canvas);
134
+ },
135
+
136
+ get_settings : function (e) {
137
+ var offcanvas = this.S(e.target).closest('[' + this.attr_name() + ']');
138
+ return offcanvas.data(this.attr_name(true) + '-init') || this.settings;
139
+ },
140
+
141
+ get_wrapper : function (e) {
142
+ var $off_canvas = this.S(e ? e.target : this.scope).closest('.off-canvas-wrap');
143
+
144
+ if ($off_canvas.length === 0) {
145
+ $off_canvas = this.S('.off-canvas-wrap');
146
+ }
147
+ return $off_canvas;
148
+ },
149
+
150
+ reflow : function () {}
151
+ };
152
+ }(jQuery, window, window.document));
@@ -0,0 +1,476 @@
1
+ ;(function ($, window, document, undefined) {
2
+ 'use strict';
3
+
4
+ var noop = function () {};
5
+
6
+ var Orbit = function (el, settings) {
7
+ // Don't reinitialize plugin
8
+ if (el.hasClass(settings.slides_container_class)) {
9
+ return this;
10
+ }
11
+
12
+ var self = this,
13
+ container,
14
+ slides_container = el,
15
+ number_container,
16
+ bullets_container,
17
+ timer_container,
18
+ idx = 0,
19
+ animate,
20
+ timer,
21
+ locked = false,
22
+ adjust_height_after = false;
23
+
24
+ self.slides = function () {
25
+ return slides_container.children(settings.slide_selector);
26
+ };
27
+
28
+ self.slides().first().addClass(settings.active_slide_class);
29
+
30
+ self.update_slide_number = function (index) {
31
+ if (settings.slide_number) {
32
+ number_container.find('span:first').text(parseInt(index) + 1);
33
+ number_container.find('span:last').text(self.slides().length);
34
+ }
35
+ if (settings.bullets) {
36
+ bullets_container.children().removeClass(settings.bullets_active_class);
37
+ $(bullets_container.children().get(index)).addClass(settings.bullets_active_class);
38
+ }
39
+ };
40
+
41
+ self.update_active_link = function (index) {
42
+ var link = $('[data-orbit-link="' + self.slides().eq(index).attr('data-orbit-slide') + '"]');
43
+ link.siblings().removeClass(settings.bullets_active_class);
44
+ link.addClass(settings.bullets_active_class);
45
+ };
46
+
47
+ self.build_markup = function () {
48
+ slides_container.wrap('<div class="' + settings.container_class + '"></div>');
49
+ container = slides_container.parent();
50
+ slides_container.addClass(settings.slides_container_class);
51
+
52
+ if (settings.stack_on_small) {
53
+ container.addClass(settings.stack_on_small_class);
54
+ }
55
+
56
+ if (settings.navigation_arrows) {
57
+ container.append($('<a href="#"><span></span></a>').addClass(settings.prev_class));
58
+ container.append($('<a href="#"><span></span></a>').addClass(settings.next_class));
59
+ }
60
+
61
+ if (settings.timer) {
62
+ timer_container = $('<div>').addClass(settings.timer_container_class);
63
+ timer_container.append('<span>');
64
+ timer_container.append($('<div>').addClass(settings.timer_progress_class));
65
+ timer_container.addClass(settings.timer_paused_class);
66
+ container.append(timer_container);
67
+ }
68
+
69
+ if (settings.slide_number) {
70
+ number_container = $('<div>').addClass(settings.slide_number_class);
71
+ number_container.append('<span></span> ' + settings.slide_number_text + ' <span></span>');
72
+ container.append(number_container);
73
+ }
74
+
75
+ if (settings.bullets) {
76
+ bullets_container = $('<ol>').addClass(settings.bullets_container_class);
77
+ container.append(bullets_container);
78
+ bullets_container.wrap('<div class="orbit-bullets-container"></div>');
79
+ self.slides().each(function (idx, el) {
80
+ var bullet = $('<li>').attr('data-orbit-slide', idx).on('click', self.link_bullet);;
81
+ bullets_container.append(bullet);
82
+ });
83
+ }
84
+
85
+ };
86
+
87
+ self._goto = function (next_idx, start_timer) {
88
+ // if (locked) {return false;}
89
+ if (next_idx === idx) {return false;}
90
+ if (typeof timer === 'object') {timer.restart();}
91
+ var slides = self.slides();
92
+
93
+ var dir = 'next';
94
+ locked = true;
95
+ if (next_idx < idx) {dir = 'prev';}
96
+ if (next_idx >= slides.length) {
97
+ if (!settings.circular) {
98
+ return false;
99
+ }
100
+ next_idx = 0;
101
+ } else if (next_idx < 0) {
102
+ if (!settings.circular) {
103
+ return false;
104
+ }
105
+ next_idx = slides.length - 1;
106
+ }
107
+
108
+ var current = $(slides.get(idx));
109
+ var next = $(slides.get(next_idx));
110
+
111
+ current.css('zIndex', 2);
112
+ current.removeClass(settings.active_slide_class);
113
+ next.css('zIndex', 4).addClass(settings.active_slide_class);
114
+
115
+ slides_container.trigger('before-slide-change.fndtn.orbit');
116
+ settings.before_slide_change();
117
+ self.update_active_link(next_idx);
118
+
119
+ var callback = function () {
120
+ var unlock = function () {
121
+ idx = next_idx;
122
+ locked = false;
123
+ if (start_timer === true) {timer = self.create_timer(); timer.start();}
124
+ self.update_slide_number(idx);
125
+ slides_container.trigger('after-slide-change.fndtn.orbit', [{slide_number : idx, total_slides : slides.length}]);
126
+ settings.after_slide_change(idx, slides.length);
127
+ };
128
+ if (slides_container.outerHeight() != next.outerHeight() && settings.variable_height) {
129
+ slides_container.animate({'height': next.outerHeight()}, 250, 'linear', unlock);
130
+ } else {
131
+ unlock();
132
+ }
133
+ };
134
+
135
+ if (slides.length === 1) {callback(); return false;}
136
+
137
+ var start_animation = function () {
138
+ if (dir === 'next') {animate.next(current, next, callback);}
139
+ if (dir === 'prev') {animate.prev(current, next, callback);}
140
+ };
141
+
142
+ if (next.outerHeight() > slides_container.outerHeight() && settings.variable_height) {
143
+ slides_container.animate({'height': next.outerHeight()}, 250, 'linear', start_animation);
144
+ } else {
145
+ start_animation();
146
+ }
147
+ };
148
+
149
+ self.next = function (e) {
150
+ e.stopImmediatePropagation();
151
+ e.preventDefault();
152
+ self._goto(idx + 1);
153
+ };
154
+
155
+ self.prev = function (e) {
156
+ e.stopImmediatePropagation();
157
+ e.preventDefault();
158
+ self._goto(idx - 1);
159
+ };
160
+
161
+ self.link_custom = function (e) {
162
+ e.preventDefault();
163
+ var link = $(this).attr('data-orbit-link');
164
+ if ((typeof link === 'string') && (link = $.trim(link)) != '') {
165
+ var slide = container.find('[data-orbit-slide=' + link + ']');
166
+ if (slide.index() != -1) {self._goto(slide.index());}
167
+ }
168
+ };
169
+
170
+ self.link_bullet = function (e) {
171
+ var index = $(this).attr('data-orbit-slide');
172
+ if ((typeof index === 'string') && (index = $.trim(index)) != '') {
173
+ if (isNaN(parseInt(index))) {
174
+ var slide = container.find('[data-orbit-slide=' + index + ']');
175
+ if (slide.index() != -1) {self._goto(slide.index() + 1);}
176
+ } else {
177
+ self._goto(parseInt(index));
178
+ }
179
+ }
180
+
181
+ }
182
+
183
+ self.timer_callback = function () {
184
+ self._goto(idx + 1, true);
185
+ }
186
+
187
+ self.compute_dimensions = function () {
188
+ var current = $(self.slides().get(idx));
189
+ var h = current.outerHeight();
190
+ if (!settings.variable_height) {
191
+ self.slides().each(function(){
192
+ if ($(this).outerHeight() > h) { h = $(this).outerHeight(); }
193
+ });
194
+ }
195
+ slides_container.height(h);
196
+ };
197
+
198
+ self.create_timer = function () {
199
+ var t = new Timer(
200
+ container.find('.' + settings.timer_container_class),
201
+ settings,
202
+ self.timer_callback
203
+ );
204
+ return t;
205
+ };
206
+
207
+ self.stop_timer = function () {
208
+ if (typeof timer === 'object') {
209
+ timer.stop();
210
+ }
211
+ };
212
+
213
+ self.toggle_timer = function () {
214
+ var t = container.find('.' + settings.timer_container_class);
215
+ if (t.hasClass(settings.timer_paused_class)) {
216
+ if (typeof timer === 'undefined') {timer = self.create_timer();}
217
+ timer.start();
218
+ } else {
219
+ if (typeof timer === 'object') {timer.stop();}
220
+ }
221
+ };
222
+
223
+ self.init = function () {
224
+ self.build_markup();
225
+ if (settings.timer) {
226
+ timer = self.create_timer();
227
+ Foundation.utils.image_loaded(this.slides().children('img'), timer.start);
228
+ }
229
+ animate = new FadeAnimation(settings, slides_container);
230
+ if (settings.animation === 'slide') {
231
+ animate = new SlideAnimation(settings, slides_container);
232
+ }
233
+
234
+ container.on('click', '.' + settings.next_class, self.next);
235
+ container.on('click', '.' + settings.prev_class, self.prev);
236
+
237
+ if (settings.next_on_click) {
238
+ container.on('click', '.' + settings.slides_container_class + ' [data-orbit-slide]', self.link_bullet);
239
+ }
240
+
241
+ container.on('click', self.toggle_timer);
242
+ if (settings.swipe) {
243
+ container.on('touchstart.fndtn.orbit', function (e) {
244
+ if (!e.touches) {e = e.originalEvent;}
245
+ var data = {
246
+ start_page_x : e.touches[0].pageX,
247
+ start_page_y : e.touches[0].pageY,
248
+ start_time : (new Date()).getTime(),
249
+ delta_x : 0,
250
+ is_scrolling : undefined
251
+ };
252
+ container.data('swipe-transition', data);
253
+ e.stopPropagation();
254
+ })
255
+ .on('touchmove.fndtn.orbit', function (e) {
256
+ if (!e.touches) {
257
+ e = e.originalEvent;
258
+ }
259
+ // Ignore pinch/zoom events
260
+ if (e.touches.length > 1 || e.scale && e.scale !== 1) {
261
+ return;
262
+ }
263
+
264
+ var data = container.data('swipe-transition');
265
+ if (typeof data === 'undefined') {data = {};}
266
+
267
+ data.delta_x = e.touches[0].pageX - data.start_page_x;
268
+
269
+ if ( typeof data.is_scrolling === 'undefined') {
270
+ data.is_scrolling = !!( data.is_scrolling || Math.abs(data.delta_x) < Math.abs(e.touches[0].pageY - data.start_page_y) );
271
+ }
272
+
273
+ if (!data.is_scrolling && !data.active) {
274
+ e.preventDefault();
275
+ var direction = (data.delta_x < 0) ? (idx + 1) : (idx - 1);
276
+ data.active = true;
277
+ self._goto(direction);
278
+ }
279
+ })
280
+ .on('touchend.fndtn.orbit', function (e) {
281
+ container.data('swipe-transition', {});
282
+ e.stopPropagation();
283
+ })
284
+ }
285
+ container.on('mouseenter.fndtn.orbit', function (e) {
286
+ if (settings.timer && settings.pause_on_hover) {
287
+ self.stop_timer();
288
+ }
289
+ })
290
+ .on('mouseleave.fndtn.orbit', function (e) {
291
+ if (settings.timer && settings.resume_on_mouseout) {
292
+ timer.start();
293
+ }
294
+ });
295
+
296
+ $(document).on('click', '[data-orbit-link]', self.link_custom);
297
+ $(window).on('load resize', self.compute_dimensions);
298
+ Foundation.utils.image_loaded(this.slides().children('img'), self.compute_dimensions);
299
+ Foundation.utils.image_loaded(this.slides().children('img'), function () {
300
+ container.prev('.' + settings.preloader_class).css('display', 'none');
301
+ self.update_slide_number(0);
302
+ self.update_active_link(0);
303
+ slides_container.trigger('ready.fndtn.orbit');
304
+ });
305
+ };
306
+
307
+ self.init();
308
+ };
309
+
310
+ var Timer = function (el, settings, callback) {
311
+ var self = this,
312
+ duration = settings.timer_speed,
313
+ progress = el.find('.' + settings.timer_progress_class),
314
+ start,
315
+ timeout,
316
+ left = -1;
317
+
318
+ this.update_progress = function (w) {
319
+ var new_progress = progress.clone();
320
+ new_progress.attr('style', '');
321
+ new_progress.css('width', w + '%');
322
+ progress.replaceWith(new_progress);
323
+ progress = new_progress;
324
+ };
325
+
326
+ this.restart = function () {
327
+ clearTimeout(timeout);
328
+ el.addClass(settings.timer_paused_class);
329
+ left = -1;
330
+ self.update_progress(0);
331
+ };
332
+
333
+ this.start = function () {
334
+ if (!el.hasClass(settings.timer_paused_class)) {return true;}
335
+ left = (left === -1) ? duration : left;
336
+ el.removeClass(settings.timer_paused_class);
337
+ start = new Date().getTime();
338
+ progress.animate({'width' : '100%'}, left, 'linear');
339
+ timeout = setTimeout(function () {
340
+ self.restart();
341
+ callback();
342
+ }, left);
343
+ el.trigger('timer-started.fndtn.orbit')
344
+ };
345
+
346
+ this.stop = function () {
347
+ if (el.hasClass(settings.timer_paused_class)) {return true;}
348
+ clearTimeout(timeout);
349
+ el.addClass(settings.timer_paused_class);
350
+ var end = new Date().getTime();
351
+ left = left - (end - start);
352
+ var w = 100 - ((left / duration) * 100);
353
+ self.update_progress(w);
354
+ el.trigger('timer-stopped.fndtn.orbit');
355
+ };
356
+ };
357
+
358
+ var SlideAnimation = function (settings, container) {
359
+ var duration = settings.animation_speed;
360
+ var is_rtl = ($('html[dir=rtl]').length === 1);
361
+ var margin = is_rtl ? 'marginRight' : 'marginLeft';
362
+ var animMargin = {};
363
+ animMargin[margin] = '0%';
364
+
365
+ this.next = function (current, next, callback) {
366
+ current.animate({marginLeft : '-100%'}, duration);
367
+ next.animate(animMargin, duration, function () {
368
+ current.css(margin, '100%');
369
+ callback();
370
+ });
371
+ };
372
+
373
+ this.prev = function (current, prev, callback) {
374
+ current.animate({marginLeft : '100%'}, duration);
375
+ prev.css(margin, '-100%');
376
+ prev.animate(animMargin, duration, function () {
377
+ current.css(margin, '100%');
378
+ callback();
379
+ });
380
+ };
381
+ };
382
+
383
+ var FadeAnimation = function (settings, container) {
384
+ var duration = settings.animation_speed;
385
+ var is_rtl = ($('html[dir=rtl]').length === 1);
386
+ var margin = is_rtl ? 'marginRight' : 'marginLeft';
387
+
388
+ this.next = function (current, next, callback) {
389
+ next.css({'margin' : '0%', 'opacity' : '0.01'});
390
+ next.animate({'opacity' :'1'}, duration, 'linear', function () {
391
+ current.css('margin', '100%');
392
+ callback();
393
+ });
394
+ };
395
+
396
+ this.prev = function (current, prev, callback) {
397
+ prev.css({'margin' : '0%', 'opacity' : '0.01'});
398
+ prev.animate({'opacity' : '1'}, duration, 'linear', function () {
399
+ current.css('margin', '100%');
400
+ callback();
401
+ });
402
+ };
403
+ };
404
+
405
+ Foundation.libs = Foundation.libs || {};
406
+
407
+ Foundation.libs.orbit = {
408
+ name : 'orbit',
409
+
410
+ version : '5.5.2',
411
+
412
+ settings : {
413
+ animation : 'slide',
414
+ timer_speed : 10000,
415
+ pause_on_hover : true,
416
+ resume_on_mouseout : false,
417
+ next_on_click : true,
418
+ animation_speed : 500,
419
+ stack_on_small : false,
420
+ navigation_arrows : true,
421
+ slide_number : true,
422
+ slide_number_text : 'of',
423
+ container_class : 'orbit-container',
424
+ stack_on_small_class : 'orbit-stack-on-small',
425
+ next_class : 'orbit-next',
426
+ prev_class : 'orbit-prev',
427
+ timer_container_class : 'orbit-timer',
428
+ timer_paused_class : 'paused',
429
+ timer_progress_class : 'orbit-progress',
430
+ slides_container_class : 'orbit-slides-container',
431
+ preloader_class : 'preloader',
432
+ slide_selector : '*',
433
+ bullets_container_class : 'orbit-bullets',
434
+ bullets_active_class : 'active',
435
+ slide_number_class : 'orbit-slide-number',
436
+ caption_class : 'orbit-caption',
437
+ active_slide_class : 'active',
438
+ orbit_transition_class : 'orbit-transitioning',
439
+ bullets : true,
440
+ circular : true,
441
+ timer : true,
442
+ variable_height : false,
443
+ swipe : true,
444
+ before_slide_change : noop,
445
+ after_slide_change : noop
446
+ },
447
+
448
+ init : function (scope, method, options) {
449
+ var self = this;
450
+ this.bindings(method, options);
451
+ },
452
+
453
+ events : function (instance) {
454
+ var orbit_instance = new Orbit(this.S(instance), this.S(instance).data('orbit-init'));
455
+ this.S(instance).data(this.name + '-instance', orbit_instance);
456
+ },
457
+
458
+ reflow : function () {
459
+ var self = this;
460
+
461
+ if (self.S(self.scope).is('[data-orbit]')) {
462
+ var $el = self.S(self.scope);
463
+ var instance = $el.data(self.name + '-instance');
464
+ instance.compute_dimensions();
465
+ } else {
466
+ self.S('[data-orbit]', self.scope).each(function (idx, el) {
467
+ var $el = self.S(el);
468
+ var opts = self.data_options($el);
469
+ var instance = $el.data(self.name + '-instance');
470
+ instance.compute_dimensions();
471
+ });
472
+ }
473
+ }
474
+ };
475
+
476
+ }(jQuery, window, window.document));