volt-foundation 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,189 +0,0 @@
1
- ;(function ($, window, document, undefined) {
2
- 'use strict';
3
-
4
- Foundation.libs['magellan-expedition'] = {
5
- name : 'magellan-expedition',
6
-
7
- version : '5.4.6',
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
- },
16
-
17
- init : function (scope, method, options) {
18
- Foundation.inherit(this, 'throttle');
19
- this.bindings(method, options);
20
- },
21
-
22
- events : function () {
23
- var self = this,
24
- S = self.S,
25
- settings = self.settings;
26
-
27
- // initialize expedition offset
28
- self.set_expedition_position();
29
-
30
- S(self.scope)
31
- .off('.magellan')
32
- .on('click.fndtn.magellan', '[' + self.add_namespace('data-magellan-arrival') + '] a[href^="#"]', function (e) {
33
- e.preventDefault();
34
- var expedition = $(this).closest('[' + self.attr_name() + ']'),
35
- settings = expedition.data('magellan-expedition-init'),
36
- hash = this.hash.split('#').join(''),
37
- target = $("a[name='"+hash+"']");
38
-
39
- if (target.length === 0) {
40
- target = $('#'+hash);
41
-
42
- }
43
-
44
-
45
- // Account for expedition height if fixed position
46
- var scroll_top = target.offset().top - settings.destination_threshold + 1;
47
- scroll_top = scroll_top - expedition.outerHeight();
48
-
49
- $('html, body').stop().animate({
50
- 'scrollTop': scroll_top
51
- }, 700, 'swing', function () {
52
- if(history.pushState) {
53
- history.pushState(null, null, '#'+hash);
54
- }
55
- else {
56
- location.hash = '#'+hash;
57
- }
58
- });
59
- })
60
- .on('scroll.fndtn.magellan', self.throttle(this.check_for_arrivals.bind(this), settings.throttle_delay));
61
-
62
- $(window)
63
- .on('resize.fndtn.magellan', self.throttle(this.set_expedition_position.bind(this), settings.throttle_delay));
64
- },
65
-
66
- check_for_arrivals : function() {
67
- var self = this;
68
- self.update_arrivals();
69
- self.update_expedition_positions();
70
- },
71
-
72
- set_expedition_position : function() {
73
- var self = this;
74
- $('[' + this.attr_name() + '=fixed]', self.scope).each(function(idx, el) {
75
- var expedition = $(this),
76
- settings = expedition.data('magellan-expedition-init'),
77
- styles = expedition.attr('styles'), // save styles
78
- top_offset, fixed_top;
79
-
80
- expedition.attr('style', '');
81
- top_offset = expedition.offset().top + settings.threshold;
82
-
83
- //set fixed-top by attribute
84
- fixed_top = parseInt(expedition.data('magellan-fixed-top'));
85
- if(!isNaN(fixed_top))
86
- self.settings.fixed_top = fixed_top;
87
-
88
- expedition.data(self.data_attr('magellan-top-offset'), top_offset);
89
- expedition.attr('style', styles);
90
- });
91
- },
92
-
93
- update_expedition_positions : function() {
94
- var self = this,
95
- window_top_offset = $(window).scrollTop();
96
-
97
- $('[' + this.attr_name() + '=fixed]', self.scope).each(function() {
98
- var expedition = $(this),
99
- settings = expedition.data('magellan-expedition-init'),
100
- styles = expedition.attr('style'), // save styles
101
- top_offset = expedition.data('magellan-top-offset');
102
-
103
- //scroll to the top distance
104
- if (window_top_offset+self.settings.fixed_top >= top_offset) {
105
- // Placeholder allows height calculations to be consistent even when
106
- // appearing to switch between fixed/non-fixed placement
107
- var placeholder = expedition.prev('[' + self.add_namespace('data-magellan-expedition-clone') + ']');
108
- if (placeholder.length === 0) {
109
- placeholder = expedition.clone();
110
- placeholder.removeAttr(self.attr_name());
111
- placeholder.attr(self.add_namespace('data-magellan-expedition-clone'),'');
112
- expedition.before(placeholder);
113
- }
114
- expedition.css({position:'fixed', top: settings.fixed_top}).addClass('fixed');
115
- } else {
116
- expedition.prev('[' + self.add_namespace('data-magellan-expedition-clone') + ']').remove();
117
- expedition.attr('style',styles).css('position','').css('top','').removeClass('fixed');
118
- }
119
- });
120
- },
121
-
122
- update_arrivals : function() {
123
- var self = this,
124
- window_top_offset = $(window).scrollTop();
125
-
126
- $('[' + this.attr_name() + ']', self.scope).each(function() {
127
- var expedition = $(this),
128
- settings = expedition.data(self.attr_name(true) + '-init'),
129
- offsets = self.offsets(expedition, window_top_offset),
130
- arrivals = expedition.find('[' + self.add_namespace('data-magellan-arrival') + ']'),
131
- active_item = false;
132
- offsets.each(function(idx, item) {
133
- if (item.viewport_offset >= item.top_offset) {
134
- var arrivals = expedition.find('[' + self.add_namespace('data-magellan-arrival') + ']');
135
- arrivals.not(item.arrival).removeClass(settings.active_class);
136
- item.arrival.addClass(settings.active_class);
137
- active_item = true;
138
- return true;
139
- }
140
- });
141
-
142
- if (!active_item) arrivals.removeClass(settings.active_class);
143
- });
144
- },
145
-
146
- offsets : function(expedition, window_offset) {
147
- var self = this,
148
- settings = expedition.data(self.attr_name(true) + '-init'),
149
- viewport_offset = window_offset;
150
-
151
- return expedition.find('[' + self.add_namespace('data-magellan-arrival') + ']').map(function(idx, el) {
152
- var name = $(this).data(self.data_attr('magellan-arrival')),
153
- dest = $('[' + self.add_namespace('data-magellan-destination') + '=' + name + ']');
154
- if (dest.length > 0) {
155
- var top_offset = Math.floor(dest.offset().top - settings.destination_threshold - expedition.outerHeight());
156
- return {
157
- destination : dest,
158
- arrival : $(this),
159
- top_offset : top_offset,
160
- viewport_offset : viewport_offset
161
- }
162
- }
163
- }).sort(function(a, b) {
164
- if (a.top_offset < b.top_offset) return -1;
165
- if (a.top_offset > b.top_offset) return 1;
166
- return 0;
167
- });
168
- },
169
-
170
- data_attr: function (str) {
171
- if (this.namespace.length > 0) {
172
- return this.namespace + '-' + str;
173
- }
174
-
175
- return str;
176
- },
177
-
178
- off : function () {
179
- this.S(this.scope).off('.magellan');
180
- this.S(window).off('.magellan');
181
- },
182
-
183
- reflow : function () {
184
- var self = this;
185
- // remove placeholder expeditions used for height calculation purposes
186
- $('[' + self.add_namespace('data-magellan-expedition-clone') + ']', self.scope).remove();
187
- }
188
- };
189
- }(jQuery, window, window.document));
@@ -1,152 +0,0 @@
1
- ;(function ($, window, document, undefined) {
2
- 'use strict';
3
-
4
- Foundation.libs.offcanvas = {
5
- name : 'offcanvas',
6
-
7
- version : '5.4.6',
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').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').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));