foundation-rails 5.1.1.0 → 5.2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +52 -7
- data/bower.json +2 -2
- data/lib/foundation/rails/version.rb +1 -1
- data/vendor/assets/javascripts/foundation/foundation.abide.js +3 -6
- data/vendor/assets/javascripts/foundation/foundation.accordion.js +5 -4
- data/vendor/assets/javascripts/foundation/foundation.alert.js +1 -1
- data/vendor/assets/javascripts/foundation/foundation.clearing.js +70 -34
- data/vendor/assets/javascripts/foundation/foundation.dropdown.js +121 -28
- data/vendor/assets/javascripts/foundation/foundation.equalizer.js +6 -6
- data/vendor/assets/javascripts/foundation/foundation.interchange.js +34 -25
- data/vendor/assets/javascripts/foundation/foundation.joyride.js +4 -8
- data/vendor/assets/javascripts/foundation/foundation.js +94 -78
- data/vendor/assets/javascripts/foundation/foundation.magellan.js +3 -4
- data/vendor/assets/javascripts/foundation/foundation.offcanvas.js +19 -1
- data/vendor/assets/javascripts/foundation/foundation.orbit.js +151 -102
- data/vendor/assets/javascripts/foundation/foundation.reveal.js +43 -15
- data/vendor/assets/javascripts/foundation/foundation.slider.js +187 -0
- data/vendor/assets/javascripts/foundation/foundation.tab.js +116 -18
- data/vendor/assets/javascripts/foundation/foundation.tooltip.js +112 -60
- data/vendor/assets/javascripts/foundation/foundation.topbar.js +47 -14
- data/vendor/assets/javascripts/vendor/modernizr.js +3 -3
- data/vendor/assets/stylesheets/foundation.scss +7 -0
- data/vendor/assets/stylesheets/foundation/_functions.scss +4 -0
- data/vendor/assets/stylesheets/foundation/_settings.scss +11 -2
- data/vendor/assets/stylesheets/foundation/components/_accordion.scss +5 -1
- data/vendor/assets/stylesheets/foundation/components/_alert-boxes.scss +4 -0
- data/vendor/assets/stylesheets/foundation/components/_block-grid.scss +44 -12
- data/vendor/assets/stylesheets/foundation/components/_breadcrumbs.scss +4 -0
- data/vendor/assets/stylesheets/foundation/components/_button-groups.scss +4 -0
- data/vendor/assets/stylesheets/foundation/components/_buttons.scss +7 -5
- data/vendor/assets/stylesheets/foundation/components/_clearing.scss +4 -0
- data/vendor/assets/stylesheets/foundation/components/_dropdown-buttons.scss +4 -0
- data/vendor/assets/stylesheets/foundation/components/_dropdown.scss +100 -11
- data/vendor/assets/stylesheets/foundation/components/_flex-video.scss +4 -0
- data/vendor/assets/stylesheets/foundation/components/_forms.scss +25 -21
- data/vendor/assets/stylesheets/foundation/components/_global.scss +79 -44
- data/vendor/assets/stylesheets/foundation/components/_grid.scss +6 -2
- data/vendor/assets/stylesheets/foundation/components/_inline-lists.scss +4 -0
- data/vendor/assets/stylesheets/foundation/components/_joyride.scss +4 -0
- data/vendor/assets/stylesheets/foundation/components/_keystrokes.scss +5 -1
- data/vendor/assets/stylesheets/foundation/components/_labels.scss +4 -0
- data/vendor/assets/stylesheets/foundation/components/_magellan.scss +4 -0
- data/vendor/assets/stylesheets/foundation/components/_offcanvas.scss +51 -59
- data/vendor/assets/stylesheets/foundation/components/_orbit.scss +97 -14
- data/vendor/assets/stylesheets/foundation/components/_pagination.scss +7 -2
- data/vendor/assets/stylesheets/foundation/components/_panels.scss +5 -1
- data/vendor/assets/stylesheets/foundation/components/_pricing-tables.scss +4 -0
- data/vendor/assets/stylesheets/foundation/components/_progress-bars.scss +4 -0
- data/vendor/assets/stylesheets/foundation/components/_range-slider.scss +148 -0
- data/vendor/assets/stylesheets/foundation/components/_reveal.scss +36 -7
- data/vendor/assets/stylesheets/foundation/components/_side-nav.scss +8 -3
- data/vendor/assets/stylesheets/foundation/components/_split-buttons.scss +4 -0
- data/vendor/assets/stylesheets/foundation/components/_sub-nav.scss +6 -2
- data/vendor/assets/stylesheets/foundation/components/_switch.scss +4 -0
- data/vendor/assets/stylesheets/foundation/components/_tables.scss +4 -0
- data/vendor/assets/stylesheets/foundation/components/_tabs.scss +12 -6
- data/vendor/assets/stylesheets/foundation/components/_thumbs.scss +4 -0
- data/vendor/assets/stylesheets/foundation/components/_tooltips.scss +9 -0
- data/vendor/assets/stylesheets/foundation/components/_top-bar.scss +52 -25
- data/vendor/assets/stylesheets/foundation/components/_type.scss +132 -75
- data/vendor/assets/stylesheets/foundation/components/_visibility.scss +198 -538
- data/vendor/assets/stylesheets/normalize.scss +179 -166
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d0565600ca266c755998289b8d77379bd0b31ba3
|
4
|
+
data.tar.gz: 9a4a170972d2b69e39ef97dc7eee314d220777fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23576c610b2b0fee690f757fefb751485a88ea222efc2c4e3403d5b83f322cd27bc2a9d8eb7021232cdf739efed82740e1b09861a7b01adc03b40d9ced67c665
|
7
|
+
data.tar.gz: e265c33f51a99dfbcb1276dd408a1681bbfa4daa63157dcc6f1a29dc369f6116bafb40d47e92f52a819276305956d88172a63ccb70f7a77eacf0a22acc5a43fa
|
data/README.md
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# Foundation::Rails
|
2
2
|
|
3
|
-
|
3
|
+
Foundation::Rails is a gem to make it super easy to use Foundation in your upcoming Rails project. You can start using Foundation::Rails in your projects by following the instructions below.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
7
|
Add this line to your application's Gemfile:
|
8
8
|
|
9
|
-
gem 'foundation-rails'
|
9
|
+
$ gem 'foundation-rails'
|
10
10
|
|
11
11
|
And then execute:
|
12
12
|
|
@@ -16,13 +16,58 @@ Or install it yourself as:
|
|
16
16
|
|
17
17
|
$ gem install foundation-rails
|
18
18
|
|
19
|
+
### Configuring Foundation
|
20
|
+
|
21
|
+
You can run the following command to add Foundation:
|
22
|
+
|
23
|
+
$ rails g foundation:install
|
24
|
+
|
25
|
+
## Manual Installation
|
26
|
+
|
27
|
+
### Add Foundation to your CSS
|
28
|
+
|
29
|
+
Append the following line to your `app/assets/stylesheets/application.css` file:
|
30
|
+
|
31
|
+
/*= require foundation */
|
32
|
+
|
33
|
+
If you're planning on using Sass, then you'll want to rename `application.css` to `application.scss`. That file should then look like:
|
34
|
+
|
35
|
+
@import "foundation_and_overrides";
|
36
|
+
/* Add imports of custom sass/scss files here */
|
37
|
+
|
38
|
+
### Add Foundation to your JS
|
39
|
+
|
40
|
+
Append the following lines to your `app/assets/javascripts/application.js` file:
|
41
|
+
|
42
|
+
//= require foundation
|
43
|
+
$(document).foundation();
|
44
|
+
|
45
|
+
### Add Modernizr
|
46
|
+
|
47
|
+
Make sure that Modernizr is included in the `<head>` of your page layout:
|
48
|
+
|
49
|
+
javascript_include_tag "vendor/modernizr"
|
50
|
+
|
51
|
+
### Set Viewport Width
|
52
|
+
|
53
|
+
Add the following line to the `head` of your page layout:
|
54
|
+
|
55
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
56
|
+
|
19
57
|
## Usage
|
20
58
|
|
21
|
-
|
59
|
+
Run the generator to add foundation to the asset pipeline:
|
22
60
|
|
23
|
-
|
24
|
-
|
25
|
-
|
61
|
+
rails g foundation:install [layout_name] [options]
|
62
|
+
|
63
|
+
Options:
|
64
|
+
[--haml] # Generate HAML layout instead of erb
|
65
|
+
[--slim] # Generate Slim layout instead of erb
|
66
|
+
Runtime options:
|
67
|
+
-f, [--force] # Overwrite files that already exist
|
68
|
+
-p, [--pretend] # Run but do not make any changes
|
69
|
+
-q, [--quiet] # Suppress status output
|
70
|
+
-s, [--skip] # Skip files that already exist
|
26
71
|
|
27
72
|
## Contributing
|
28
73
|
|
@@ -36,4 +81,4 @@ rails g foundation:install
|
|
36
81
|
|
37
82
|
* [Foundation Docs](http://foundation.zurb.com/docs/)
|
38
83
|
* [Foundation Forum](http://foundation.zurb.com/forum)
|
39
|
-
* [Foundation Training](http://foundation.zurb.com/learn/training.html)
|
84
|
+
* [Foundation Training](http://foundation.zurb.com/learn/training.html)
|
data/bower.json
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
Foundation.libs.abide = {
|
5
5
|
name : 'abide',
|
6
6
|
|
7
|
-
version : '5.
|
7
|
+
version : '5.2.0',
|
8
8
|
|
9
9
|
settings : {
|
10
10
|
live_validate : true,
|
@@ -17,9 +17,6 @@
|
|
17
17
|
integer: /^\d+$/,
|
18
18
|
number: /-?(?:\d+|\d{1,3}(?:,\d{3})+)?(?:\.\d+)?/,
|
19
19
|
|
20
|
-
// generic password: upper-case, lower-case, number/special character, and min 8 characters
|
21
|
-
password : /(?=^.{8,}$)((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$/,
|
22
|
-
|
23
20
|
// amex, visa, diners
|
24
21
|
card : /^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11})$/,
|
25
22
|
cvv : /^([0-9]){3,4}$/,
|
@@ -73,7 +70,7 @@
|
|
73
70
|
self.validate([this], e);
|
74
71
|
})
|
75
72
|
.on('keydown.fndtn.abide', function (e) {
|
76
|
-
var settings = $(this).closest('form').data('
|
73
|
+
var settings = $(this).closest('form').data(self.attr_name(true) + '-init');
|
77
74
|
if (settings.live_validate === true) {
|
78
75
|
clearTimeout(self.timer);
|
79
76
|
self.timer = setTimeout(function () {
|
@@ -180,7 +177,7 @@
|
|
180
177
|
} else {
|
181
178
|
|
182
179
|
if (el_patterns[i][1].test(value) && valid_length ||
|
183
|
-
!required && el.value.length < 1) {
|
180
|
+
!required && el.value.length < 1 || $(el).attr('disabled')) {
|
184
181
|
this.S(el).removeAttr(this.invalid_attr);
|
185
182
|
parent.removeClass('error');
|
186
183
|
if (label.length > 0 && this.settings.error_labels) label.removeClass('error');
|
@@ -4,7 +4,7 @@
|
|
4
4
|
Foundation.libs.accordion = {
|
5
5
|
name : 'accordion',
|
6
6
|
|
7
|
-
version : '5.
|
7
|
+
version : '5.2.0',
|
8
8
|
|
9
9
|
settings : {
|
10
10
|
active_class: 'active',
|
@@ -12,7 +12,7 @@
|
|
12
12
|
},
|
13
13
|
|
14
14
|
init : function (scope, method, options) {
|
15
|
-
this.bindings(method, options);
|
15
|
+
this.bindings(method, options);
|
16
16
|
},
|
17
17
|
|
18
18
|
events : function () {
|
@@ -20,7 +20,7 @@
|
|
20
20
|
var S = this.S;
|
21
21
|
S(this.scope)
|
22
22
|
.off('.fndtn.accordion')
|
23
|
-
.on('click.fndtn.accordion', '[' + this.attr_name() + ']
|
23
|
+
.on('click.fndtn.accordion', '[' + this.attr_name() + '] dd > a', function (e) {
|
24
24
|
var accordion = S(this).closest('[' + self.attr_name() + ']'),
|
25
25
|
target = S('#' + this.href.split('#')[1]),
|
26
26
|
siblings = S('dd > .content', accordion),
|
@@ -28,9 +28,10 @@
|
|
28
28
|
settings = accordion.data(self.attr_name(true) + '-init'),
|
29
29
|
active_content = S('dd > .content.' + settings.active_class, accordion),
|
30
30
|
active_parent = S('dd.' + settings.active_class, accordion);
|
31
|
-
|
32
31
|
e.preventDefault();
|
33
32
|
|
33
|
+
if (! S(this).closest('dl').is(accordion)) { return; }
|
34
|
+
|
34
35
|
if (active_content[0] == target[0] && settings.toggleable) {
|
35
36
|
active_parent.toggleClass(settings.active_class, false);
|
36
37
|
return target.toggleClass(settings.active_class, false);
|
@@ -4,7 +4,7 @@
|
|
4
4
|
Foundation.libs.clearing = {
|
5
5
|
name : 'clearing',
|
6
6
|
|
7
|
-
version: '5.
|
7
|
+
version: '5.2.0',
|
8
8
|
|
9
9
|
settings : {
|
10
10
|
templates : {
|
@@ -31,7 +31,7 @@
|
|
31
31
|
|
32
32
|
this.bindings(method, options);
|
33
33
|
|
34
|
-
if (self.S(this.scope).is('[' + this.attr_name() + ']')) {
|
34
|
+
if (self.S(this.scope).is('[' + this.attr_name() + ']')) {
|
35
35
|
this.assemble(self.S('li', this.scope));
|
36
36
|
} else {
|
37
37
|
self.S('[' + this.attr_name() + ']', this.scope).each(function () {
|
@@ -44,6 +44,10 @@
|
|
44
44
|
var self = this,
|
45
45
|
S = self.S;
|
46
46
|
|
47
|
+
if ($('.scroll-container').length > 0) {
|
48
|
+
this.scope = $('.scroll-container');
|
49
|
+
}
|
50
|
+
|
47
51
|
S(this.scope)
|
48
52
|
.off('.clearing')
|
49
53
|
.on('click.fndtn.clearing', 'ul[' + this.attr_name() + '] li',
|
@@ -80,8 +84,9 @@
|
|
80
84
|
.on('click.fndtn.clearing', '.clearing-main-prev',
|
81
85
|
function (e) { self.nav(e, 'prev') })
|
82
86
|
.on('click.fndtn.clearing', this.settings.close_selectors,
|
83
|
-
function (e) { Foundation.libs.clearing.close(e, this) })
|
84
|
-
|
87
|
+
function (e) { Foundation.libs.clearing.close(e, this) });
|
88
|
+
|
89
|
+
$(document).on('keydown.fndtn.clearing',
|
85
90
|
function (e) { self.keydown(e) });
|
86
91
|
|
87
92
|
S(window).off('.clearing').on('resize.fndtn.clearing',
|
@@ -164,11 +169,46 @@
|
|
164
169
|
|
165
170
|
open : function ($image, current, target) {
|
166
171
|
var self = this,
|
172
|
+
body = $(document.body),
|
167
173
|
root = target.closest('.clearing-assembled'),
|
168
|
-
container =
|
169
|
-
visible_image =
|
170
|
-
image =
|
171
|
-
label =
|
174
|
+
container = $('div', root).first(),
|
175
|
+
visible_image = $('.visible-img', container),
|
176
|
+
image = $('img', visible_image).not($image),
|
177
|
+
label = $('.clearing-touch-label', '.clearing-blackout'),
|
178
|
+
error = false;
|
179
|
+
|
180
|
+
image.error(function () {
|
181
|
+
error = true;
|
182
|
+
});
|
183
|
+
|
184
|
+
function startLoad() {
|
185
|
+
setTimeout(function () {
|
186
|
+
this.image_loaded(image, function () {
|
187
|
+
if (image.outerWidth() === 1 && !error) {
|
188
|
+
startLoad.call(this);
|
189
|
+
} else {
|
190
|
+
cb.call(this, image);
|
191
|
+
}
|
192
|
+
}.bind(this));
|
193
|
+
}.bind(this), 50);
|
194
|
+
}
|
195
|
+
|
196
|
+
function cb (image) {
|
197
|
+
var $image = $(image);
|
198
|
+
image.css('visibility', 'visible');
|
199
|
+
// toggle the gallery
|
200
|
+
body.css('overflow', 'hidden');
|
201
|
+
root.addClass('clearing-blackout');
|
202
|
+
container.addClass('clearing-container');
|
203
|
+
visible_image.show();
|
204
|
+
this.fix_height(target)
|
205
|
+
.caption(self.S('.clearing-caption', visible_image), $image)
|
206
|
+
.center_and_label(image, label)
|
207
|
+
.shift(current, target, function () {
|
208
|
+
target.siblings().removeClass('visible');
|
209
|
+
target.addClass('visible');
|
210
|
+
});
|
211
|
+
}
|
172
212
|
|
173
213
|
if (!this.locked()) {
|
174
214
|
// set the image to the selected thumbnail
|
@@ -176,20 +216,8 @@
|
|
176
216
|
.attr('src', this.load($image))
|
177
217
|
.css('visibility', 'hidden');
|
178
218
|
|
179
|
-
|
180
|
-
|
181
|
-
// toggle the gallery
|
182
|
-
root.addClass('clearing-blackout');
|
183
|
-
container.addClass('clearing-container');
|
184
|
-
visible_image.show();
|
185
|
-
this.fix_height(target)
|
186
|
-
.caption(self.S('.clearing-caption', visible_image), $image)
|
187
|
-
.center_and_label(image,label)
|
188
|
-
.shift(current, target, function () {
|
189
|
-
target.siblings().removeClass('visible');
|
190
|
-
target.addClass('visible');
|
191
|
-
});
|
192
|
-
}.bind(this));
|
219
|
+
startLoad.call(this);
|
220
|
+
|
193
221
|
}
|
194
222
|
},
|
195
223
|
|
@@ -202,9 +230,11 @@
|
|
202
230
|
} else {
|
203
231
|
return target.closest('.clearing-blackout');
|
204
232
|
}
|
205
|
-
}($(el))),
|
233
|
+
}($(el))),
|
234
|
+
body = $(document.body), container, visible_image;
|
206
235
|
|
207
236
|
if (el === e.target && root) {
|
237
|
+
body.css('overflow', '');
|
208
238
|
container = $('div', root).first();
|
209
239
|
visible_image = $('.visible-img', container);
|
210
240
|
this.settings.prev_index = 0;
|
@@ -223,7 +253,7 @@
|
|
223
253
|
},
|
224
254
|
|
225
255
|
keydown : function (e) {
|
226
|
-
var clearing = $('ul[' + this.attr_name() + ']'
|
256
|
+
var clearing = $('.clearing-blackout ul[' + this.attr_name() + ']'),
|
227
257
|
NEXT_KEY = this.rtl ? 37 : 39,
|
228
258
|
PREV_KEY = this.rtl ? 39 : 37,
|
229
259
|
ESC_KEY = 27;
|
@@ -296,10 +326,13 @@
|
|
296
326
|
marginLeft : -(target.outerWidth() / 2),
|
297
327
|
marginTop : -(target.outerHeight() / 2)
|
298
328
|
});
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
329
|
+
|
330
|
+
if (label.length > 0) {
|
331
|
+
label.css({
|
332
|
+
marginLeft : -(label.outerWidth() / 2),
|
333
|
+
marginTop : -(target.outerHeight() / 2)-label.outerHeight()-10
|
334
|
+
});
|
335
|
+
}
|
303
336
|
} else {
|
304
337
|
target.css({
|
305
338
|
marginRight : -(target.outerWidth() / 2),
|
@@ -307,12 +340,15 @@
|
|
307
340
|
left: 'auto',
|
308
341
|
right: '50%'
|
309
342
|
});
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
343
|
+
|
344
|
+
if (label.length > 0) {
|
345
|
+
label.css({
|
346
|
+
marginRight : -(label.outerWidth() / 2),
|
347
|
+
marginTop : -(target.outerHeight() / 2)-label.outerHeight()-10,
|
348
|
+
left: 'auto',
|
349
|
+
right: '50%'
|
350
|
+
});
|
351
|
+
}
|
316
352
|
}
|
317
353
|
return this;
|
318
354
|
},
|
@@ -4,10 +4,11 @@
|
|
4
4
|
Foundation.libs.dropdown = {
|
5
5
|
name : 'dropdown',
|
6
6
|
|
7
|
-
version : '5.
|
7
|
+
version : '5.2.0',
|
8
8
|
|
9
9
|
settings : {
|
10
10
|
active_class: 'open',
|
11
|
+
align: 'bottom',
|
11
12
|
is_hover: false,
|
12
13
|
opened: function(){},
|
13
14
|
closed: function(){}
|
@@ -89,7 +90,9 @@
|
|
89
90
|
.off('.dropdown')
|
90
91
|
.on('resize.fndtn.dropdown', self.throttle(function () {
|
91
92
|
self.resize.call(self);
|
92
|
-
}, 50))
|
93
|
+
}, 50));
|
94
|
+
|
95
|
+
this.resize();
|
93
96
|
},
|
94
97
|
|
95
98
|
close: function (dropdown) {
|
@@ -99,7 +102,8 @@
|
|
99
102
|
self.S(this)
|
100
103
|
.css(Foundation.rtl ? 'right':'left', '-99999px')
|
101
104
|
.removeClass(self.settings.active_class);
|
102
|
-
|
105
|
+
|
106
|
+
self.S(this).trigger('closed', [dropdown]);
|
103
107
|
}
|
104
108
|
});
|
105
109
|
},
|
@@ -115,7 +119,7 @@
|
|
115
119
|
this
|
116
120
|
.css(dropdown
|
117
121
|
.addClass(this.settings.active_class), target);
|
118
|
-
dropdown.trigger('opened');
|
122
|
+
dropdown.trigger('opened', [dropdown, target]);
|
119
123
|
},
|
120
124
|
|
121
125
|
data_attr: function () {
|
@@ -153,43 +157,133 @@
|
|
153
157
|
},
|
154
158
|
|
155
159
|
css : function (dropdown, target) {
|
156
|
-
|
157
|
-
position = target.offset();
|
158
|
-
|
159
|
-
position.top -= offset_parent.offset().top;
|
160
|
-
position.left -= offset_parent.offset().left;
|
160
|
+
this.clear_idx();
|
161
161
|
|
162
162
|
if (this.small()) {
|
163
|
-
|
163
|
+
var p = this.dirs.bottom.call(dropdown, target);
|
164
|
+
|
165
|
+
dropdown.attr('style', '').removeClass('drop-left drop-right drop-top').css({
|
164
166
|
position : 'absolute',
|
165
167
|
width: '95%',
|
166
168
|
'max-width': 'none',
|
167
|
-
top:
|
169
|
+
top: p.top
|
168
170
|
});
|
171
|
+
|
169
172
|
dropdown.css(Foundation.rtl ? 'right':'left', '2.5%');
|
170
173
|
} else {
|
171
|
-
|
172
|
-
var left = position.left;
|
173
|
-
if (dropdown.hasClass('right')) {
|
174
|
-
dropdown.removeClass('right');
|
175
|
-
}
|
176
|
-
} else {
|
177
|
-
if (!dropdown.hasClass('right')) {
|
178
|
-
dropdown.addClass('right');
|
179
|
-
}
|
180
|
-
var left = position.left - (dropdown.outerWidth() - target.outerWidth());
|
181
|
-
}
|
174
|
+
var settings = target.data(this.attr_name(true) + '-init') || this.settings;
|
182
175
|
|
183
|
-
|
184
|
-
position : 'absolute',
|
185
|
-
top: position.top + target.outerHeight(),
|
186
|
-
left: left
|
187
|
-
});
|
176
|
+
this.style(dropdown, target, settings);
|
188
177
|
}
|
189
178
|
|
190
179
|
return dropdown;
|
191
180
|
},
|
192
181
|
|
182
|
+
style : function (dropdown, target, settings) {
|
183
|
+
var css = $.extend({position: 'absolute'},
|
184
|
+
this.dirs[settings.align].call(dropdown, target, settings));
|
185
|
+
|
186
|
+
dropdown.attr('style', '').css(css);
|
187
|
+
},
|
188
|
+
|
189
|
+
// return CSS property object
|
190
|
+
// `this` is the dropdown
|
191
|
+
dirs : {
|
192
|
+
// Calculate target offset
|
193
|
+
_base : function (t) {
|
194
|
+
var o_p = this.offsetParent(),
|
195
|
+
o = o_p.offset(),
|
196
|
+
p = t.offset();
|
197
|
+
|
198
|
+
p.top -= o.top;
|
199
|
+
p.left -= o.left;
|
200
|
+
|
201
|
+
return p;
|
202
|
+
},
|
203
|
+
top: function (t, s) {
|
204
|
+
var self = Foundation.libs.dropdown,
|
205
|
+
p = self.dirs._base.call(this, t),
|
206
|
+
pip_offset_base = (t.outerWidth() / 2) - 8;
|
207
|
+
|
208
|
+
this.addClass('drop-top');
|
209
|
+
|
210
|
+
if (t.outerWidth() < this.outerWidth() || self.small()) {
|
211
|
+
self.adjust_pip(pip_offset_base, p);
|
212
|
+
}
|
213
|
+
|
214
|
+
if (Foundation.rtl) {
|
215
|
+
return {left: p.left - this.outerWidth() + t.outerWidth(),
|
216
|
+
top: p.top - this.outerHeight()};
|
217
|
+
}
|
218
|
+
|
219
|
+
return {left: p.left, top: p.top - this.outerHeight()};
|
220
|
+
},
|
221
|
+
bottom: function (t, s) {
|
222
|
+
var self = Foundation.libs.dropdown,
|
223
|
+
p = self.dirs._base.call(this, t),
|
224
|
+
pip_offset_base = (t.outerWidth() / 2) - 8;
|
225
|
+
|
226
|
+
if (t.outerWidth() < this.outerWidth() || self.small()) {
|
227
|
+
self.adjust_pip(pip_offset_base, p);
|
228
|
+
}
|
229
|
+
|
230
|
+
if (self.rtl) {
|
231
|
+
return {left: p.left - this.outerWidth() + t.outerWidth(), top: p.top + t.outerHeight()};
|
232
|
+
}
|
233
|
+
|
234
|
+
return {left: p.left, top: p.top + t.outerHeight()};
|
235
|
+
},
|
236
|
+
left: function (t, s) {
|
237
|
+
var p = Foundation.libs.dropdown.dirs._base.call(this, t);
|
238
|
+
|
239
|
+
this.addClass('drop-left');
|
240
|
+
|
241
|
+
return {left: p.left - this.outerWidth(), top: p.top};
|
242
|
+
},
|
243
|
+
right: function (t, s) {
|
244
|
+
var p = Foundation.libs.dropdown.dirs._base.call(this, t);
|
245
|
+
|
246
|
+
this.addClass('drop-right');
|
247
|
+
|
248
|
+
return {left: p.left + t.outerWidth(), top: p.top};
|
249
|
+
}
|
250
|
+
},
|
251
|
+
|
252
|
+
// Insert rule to style psuedo elements
|
253
|
+
adjust_pip : function (pip_offset_base, p) {
|
254
|
+
var sheet = Foundation.stylesheet;
|
255
|
+
|
256
|
+
if (this.small()) {
|
257
|
+
pip_offset_base += p.left - 8;
|
258
|
+
}
|
259
|
+
|
260
|
+
this.rule_idx = sheet.cssRules.length;
|
261
|
+
|
262
|
+
var sel_before = '.f-dropdown.open:before',
|
263
|
+
sel_after = '.f-dropdown.open:after',
|
264
|
+
css_before = 'left: ' + pip_offset_base + 'px;',
|
265
|
+
css_after = 'left: ' + (pip_offset_base - 1) + 'px;';
|
266
|
+
|
267
|
+
if (sheet.insertRule) {
|
268
|
+
sheet.insertRule([sel_before, '{', css_before, '}'].join(' '), this.rule_idx);
|
269
|
+
sheet.insertRule([sel_after, '{', css_after, '}'].join(' '), this.rule_idx + 1);
|
270
|
+
} else {
|
271
|
+
sheet.addRule(sel_before, css_before, this.rule_idx);
|
272
|
+
sheet.addRule(sel_after, css_after, this.rule_idx + 1);
|
273
|
+
}
|
274
|
+
},
|
275
|
+
|
276
|
+
// Remove old dropdown rule index
|
277
|
+
clear_idx : function () {
|
278
|
+
var sheet = Foundation.stylesheet;
|
279
|
+
|
280
|
+
if (this.rule_idx) {
|
281
|
+
sheet.deleteRule(this.rule_idx);
|
282
|
+
sheet.deleteRule(this.rule_idx);
|
283
|
+
delete this.rule_idx;
|
284
|
+
}
|
285
|
+
},
|
286
|
+
|
193
287
|
small : function () {
|
194
288
|
return matchMedia(Foundation.media_queries.small).matches &&
|
195
289
|
!matchMedia(Foundation.media_queries.medium).matches;
|
@@ -200,7 +294,6 @@
|
|
200
294
|
this.S('html, body').off('.fndtn.dropdown');
|
201
295
|
this.S(window).off('.fndtn.dropdown');
|
202
296
|
this.S('[data-dropdown-content]').off('.fndtn.dropdown');
|
203
|
-
this.settings.init = false;
|
204
297
|
},
|
205
298
|
|
206
299
|
reflow : function () {}
|