foundation-rails 5.5.3.2 → 6.1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/README.md +2 -8
- data/Rakefile +23 -0
- data/app/views/foundation/rails/styleguide/show.html.erb +2 -5
- data/bower.json +2 -2
- data/lib/foundation/rails/version.rb +1 -1
- data/lib/generators/foundation/install_generator.rb +6 -3
- data/lib/generators/foundation/templates/_settings.scss +546 -0
- data/lib/generators/foundation/templates/application.html.erb +0 -1
- data/lib/generators/foundation/templates/application.html.haml +0 -2
- data/lib/generators/foundation/templates/application.html.slim +0 -2
- data/lib/generators/foundation/templates/foundation_and_overrides.scss +51 -0
- data/vendor/assets/js/foundation.abide.js +418 -0
- data/vendor/assets/js/foundation.accordion.js +229 -0
- data/vendor/assets/js/foundation.accordionMenu.js +262 -0
- data/vendor/assets/js/foundation.core.js +378 -0
- data/vendor/assets/js/foundation.drilldown.js +321 -0
- data/vendor/assets/js/foundation.dropdown.js +390 -0
- data/vendor/assets/js/foundation.dropdownMenu.js +391 -0
- data/vendor/assets/js/foundation.equalizer.js +274 -0
- data/vendor/assets/js/foundation.interchange.js +184 -0
- data/vendor/assets/js/foundation.js +28 -0
- data/vendor/assets/js/foundation.magellan.js +212 -0
- data/vendor/assets/js/foundation.offcanvas.js +371 -0
- data/vendor/assets/js/foundation.orbit.js +419 -0
- data/vendor/assets/js/foundation.responsiveMenu.js +145 -0
- data/vendor/assets/js/foundation.responsiveToggle.js +106 -0
- data/vendor/assets/js/foundation.reveal.js +478 -0
- data/vendor/assets/js/foundation.slider.js +484 -0
- data/vendor/assets/js/foundation.sticky.js +436 -0
- data/vendor/assets/js/foundation.tabs.js +306 -0
- data/vendor/assets/js/foundation.toggler.js +147 -0
- data/vendor/assets/js/foundation.tooltip.js +429 -0
- data/vendor/assets/js/foundation.util.box.js +169 -0
- data/vendor/assets/js/foundation.util.keyboard.js +115 -0
- data/vendor/assets/js/foundation.util.mediaQuery.js +210 -0
- data/vendor/assets/js/foundation.util.motion.js +89 -0
- data/vendor/assets/js/foundation.util.nest.js +64 -0
- data/vendor/assets/js/foundation.util.timerAndImageLoader.js +78 -0
- data/vendor/assets/js/foundation.util.touch.js +339 -0
- data/vendor/assets/js/foundation.util.triggers.js +222 -0
- data/vendor/assets/scss/_global.scss +626 -0
- data/vendor/assets/scss/components/_accordion-menu.scss +32 -0
- data/vendor/assets/scss/components/_accordion.scss +113 -0
- data/vendor/assets/scss/components/_badge.scss +55 -0
- data/vendor/assets/scss/components/_breadcrumbs.scss +94 -0
- data/vendor/assets/scss/components/_button-group.scss +130 -0
- data/vendor/assets/scss/components/_button.scss +265 -0
- data/vendor/assets/scss/components/_callout.scss +105 -0
- data/vendor/assets/scss/components/_close-button.scss +61 -0
- data/vendor/assets/scss/components/_drilldown.scss +75 -0
- data/vendor/assets/scss/components/_dropdown-menu.scss +148 -0
- data/vendor/assets/scss/components/_dropdown.scss +64 -0
- data/vendor/assets/scss/components/_flex-video.scss +63 -0
- data/vendor/assets/scss/components/_float.scss +27 -0
- data/vendor/assets/scss/components/_label.scss +56 -0
- data/vendor/assets/scss/components/_media-object.scss +74 -0
- data/vendor/assets/scss/components/_menu.scss +209 -0
- data/vendor/assets/scss/components/_off-canvas.scss +180 -0
- data/vendor/assets/scss/components/_orbit.scss +193 -0
- data/vendor/assets/scss/components/_pagination.scss +158 -0
- data/vendor/assets/scss/components/_progress-bar.scss +83 -0
- data/vendor/assets/scss/components/_reveal.scss +156 -0
- data/vendor/assets/scss/components/_slider.scss +158 -0
- data/vendor/assets/scss/components/_sticky.scss +38 -0
- data/vendor/assets/scss/components/_switch.scss +232 -0
- data/vendor/assets/scss/components/_table.scss +213 -0
- data/vendor/assets/scss/components/_tabs.scss +170 -0
- data/vendor/assets/scss/components/_thumbnail.scss +54 -0
- data/vendor/assets/scss/components/_title-bar.scss +68 -0
- data/vendor/assets/scss/components/_tooltip.scss +100 -0
- data/vendor/assets/scss/components/_top-bar.scss +89 -0
- data/vendor/assets/scss/components/_visibility.scss +131 -0
- data/vendor/assets/scss/forms/_checkbox.scss +36 -0
- data/vendor/assets/scss/forms/_error.scss +82 -0
- data/vendor/assets/scss/forms/_fieldset.scss +53 -0
- data/vendor/assets/scss/forms/_forms.scss +32 -0
- data/vendor/assets/scss/forms/_help-text.scss +30 -0
- data/vendor/assets/scss/forms/_input-group.scss +91 -0
- data/vendor/assets/scss/forms/_label.scss +48 -0
- data/vendor/assets/scss/forms/_select.scss +63 -0
- data/vendor/assets/scss/forms/_text.scss +154 -0
- data/vendor/assets/scss/foundation.scss +91 -0
- data/vendor/assets/scss/grid/_classes.scss +153 -0
- data/vendor/assets/scss/grid/_column.scss +124 -0
- data/vendor/assets/scss/grid/_flex-grid.scss +281 -0
- data/vendor/assets/scss/grid/_grid.scss +48 -0
- data/vendor/assets/scss/grid/_gutter.scss +34 -0
- data/vendor/assets/scss/grid/_layout.scss +33 -0
- data/vendor/assets/scss/grid/_position.scss +72 -0
- data/vendor/assets/scss/grid/_row.scss +97 -0
- data/vendor/assets/scss/grid/_size.scss +24 -0
- data/vendor/assets/scss/settings/_settings.scss +547 -0
- data/vendor/assets/scss/typography/_alignment.scss +22 -0
- data/vendor/assets/scss/typography/_base.scss +439 -0
- data/vendor/assets/scss/typography/_helpers.scss +77 -0
- data/vendor/assets/scss/typography/_print.scss +73 -0
- data/vendor/assets/scss/typography/_typography.scss +28 -0
- data/vendor/assets/scss/util/_breakpoint.scss +266 -0
- data/vendor/assets/scss/util/_color.scss +41 -0
- data/vendor/assets/scss/util/_mixins.scss +223 -0
- data/vendor/assets/scss/util/_selector.scss +40 -0
- data/vendor/assets/scss/util/_unit.scss +90 -0
- data/vendor/assets/scss/util/_util.scss +15 -0
- data/vendor/assets/scss/util/_value.scss +126 -0
- metadata +97 -64
- data/update-gem.sh +0 -20
- data/vendor/assets/javascripts/foundation.js +0 -17
- data/vendor/assets/javascripts/foundation/foundation.abide.js +0 -426
- data/vendor/assets/javascripts/foundation/foundation.accordion.js +0 -125
- data/vendor/assets/javascripts/foundation/foundation.alert.js +0 -43
- data/vendor/assets/javascripts/foundation/foundation.clearing.js +0 -586
- data/vendor/assets/javascripts/foundation/foundation.dropdown.js +0 -468
- data/vendor/assets/javascripts/foundation/foundation.equalizer.js +0 -104
- data/vendor/assets/javascripts/foundation/foundation.interchange.js +0 -360
- data/vendor/assets/javascripts/foundation/foundation.joyride.js +0 -935
- data/vendor/assets/javascripts/foundation/foundation.js +0 -732
- data/vendor/assets/javascripts/foundation/foundation.magellan.js +0 -214
- data/vendor/assets/javascripts/foundation/foundation.offcanvas.js +0 -225
- data/vendor/assets/javascripts/foundation/foundation.orbit.js +0 -476
- data/vendor/assets/javascripts/foundation/foundation.reveal.js +0 -522
- data/vendor/assets/javascripts/foundation/foundation.slider.js +0 -296
- data/vendor/assets/javascripts/foundation/foundation.tab.js +0 -247
- data/vendor/assets/javascripts/foundation/foundation.tooltip.js +0 -348
- data/vendor/assets/javascripts/foundation/foundation.topbar.js +0 -458
- data/vendor/assets/javascripts/vendor/modernizr.js +0 -1406
- data/vendor/assets/stylesheets/foundation.scss +0 -42
- data/vendor/assets/stylesheets/foundation/_functions.scss +0 -156
- data/vendor/assets/stylesheets/foundation/_settings.scss +0 -1489
- data/vendor/assets/stylesheets/foundation/components/_accordion.scss +0 -161
- data/vendor/assets/stylesheets/foundation/components/_alert-boxes.scss +0 -128
- data/vendor/assets/stylesheets/foundation/components/_block-grid.scss +0 -133
- data/vendor/assets/stylesheets/foundation/components/_breadcrumbs.scss +0 -132
- data/vendor/assets/stylesheets/foundation/components/_button-groups.scss +0 -208
- data/vendor/assets/stylesheets/foundation/components/_buttons.scss +0 -261
- data/vendor/assets/stylesheets/foundation/components/_clearing.scss +0 -260
- data/vendor/assets/stylesheets/foundation/components/_dropdown-buttons.scss +0 -130
- data/vendor/assets/stylesheets/foundation/components/_dropdown.scss +0 -269
- data/vendor/assets/stylesheets/foundation/components/_flex-video.scss +0 -51
- data/vendor/assets/stylesheets/foundation/components/_forms.scss +0 -607
- data/vendor/assets/stylesheets/foundation/components/_global.scss +0 -566
- data/vendor/assets/stylesheets/foundation/components/_grid.scss +0 -292
- data/vendor/assets/stylesheets/foundation/components/_icon-bar.scss +0 -460
- data/vendor/assets/stylesheets/foundation/components/_inline-lists.scss +0 -58
- data/vendor/assets/stylesheets/foundation/components/_joyride.scss +0 -220
- data/vendor/assets/stylesheets/foundation/components/_keystrokes.scss +0 -60
- data/vendor/assets/stylesheets/foundation/components/_labels.scss +0 -106
- data/vendor/assets/stylesheets/foundation/components/_magellan.scss +0 -34
- data/vendor/assets/stylesheets/foundation/components/_offcanvas.scss +0 -606
- data/vendor/assets/stylesheets/foundation/components/_orbit.scss +0 -388
- data/vendor/assets/stylesheets/foundation/components/_pagination.scss +0 -163
- data/vendor/assets/stylesheets/foundation/components/_panels.scss +0 -107
- data/vendor/assets/stylesheets/foundation/components/_pricing-tables.scss +0 -150
- data/vendor/assets/stylesheets/foundation/components/_progress-bars.scss +0 -85
- data/vendor/assets/stylesheets/foundation/components/_range-slider.scss +0 -177
- data/vendor/assets/stylesheets/foundation/components/_reveal.scss +0 -212
- data/vendor/assets/stylesheets/foundation/components/_side-nav.scss +0 -120
- data/vendor/assets/stylesheets/foundation/components/_split-buttons.scss +0 -203
- data/vendor/assets/stylesheets/foundation/components/_sub-nav.scss +0 -125
- data/vendor/assets/stylesheets/foundation/components/_switches.scss +0 -241
- data/vendor/assets/stylesheets/foundation/components/_tables.scss +0 -135
- data/vendor/assets/stylesheets/foundation/components/_tabs.scss +0 -142
- data/vendor/assets/stylesheets/foundation/components/_thumbs.scss +0 -66
- data/vendor/assets/stylesheets/foundation/components/_tooltips.scss +0 -142
- data/vendor/assets/stylesheets/foundation/components/_top-bar.scss +0 -745
- data/vendor/assets/stylesheets/foundation/components/_type.scss +0 -525
- data/vendor/assets/stylesheets/foundation/components/_visibility.scss +0 -425
- data/vendor/assets/stylesheets/normalize.scss +0 -424
@@ -0,0 +1,106 @@
|
|
1
|
+
/**
|
2
|
+
* ResponsiveToggle module.
|
3
|
+
* @module foundation.responsiveToggle
|
4
|
+
* @requires foundation.util.mediaQuery
|
5
|
+
*/
|
6
|
+
!function($, Foundation) {
|
7
|
+
|
8
|
+
'use strict';
|
9
|
+
|
10
|
+
/**
|
11
|
+
* Creates a new instance of Tab Bar.
|
12
|
+
* @class
|
13
|
+
* @fires ResponsiveToggle#init
|
14
|
+
* @param {jQuery} element - jQuery object to attach tab bar functionality to.
|
15
|
+
* @param {Object} options - Overrides to the default plugin settings.
|
16
|
+
*/
|
17
|
+
function ResponsiveToggle(element, options) {
|
18
|
+
this.$element = $(element);
|
19
|
+
this.options = $.extend({}, ResponsiveToggle.defaults, this.$element.data(), options);
|
20
|
+
|
21
|
+
this._init();
|
22
|
+
this._events();
|
23
|
+
|
24
|
+
Foundation.registerPlugin(this, 'ResponsiveToggle');
|
25
|
+
}
|
26
|
+
|
27
|
+
ResponsiveToggle.defaults = {
|
28
|
+
/**
|
29
|
+
* The breakpoint after which the menu is always shown, and the tab bar is hidden.
|
30
|
+
* @option
|
31
|
+
* @example 'medium'
|
32
|
+
*/
|
33
|
+
hideFor: 'medium'
|
34
|
+
};
|
35
|
+
|
36
|
+
/**
|
37
|
+
* Initializes the tab bar by finding the target element, toggling element, and running update().
|
38
|
+
* @function
|
39
|
+
* @private
|
40
|
+
*/
|
41
|
+
ResponsiveToggle.prototype._init = function() {
|
42
|
+
var targetID = this.$element.data('responsive-toggle');
|
43
|
+
if (!targetID) {
|
44
|
+
console.error('Your tab bar needs an ID of a Menu as the value of data-tab-bar.');
|
45
|
+
}
|
46
|
+
|
47
|
+
this.$targetMenu = $('#'+targetID);
|
48
|
+
this.$toggler = this.$element.find('[data-toggle]');
|
49
|
+
|
50
|
+
this._update();
|
51
|
+
};
|
52
|
+
|
53
|
+
/**
|
54
|
+
* Adds necessary event handlers for the tab bar to work.
|
55
|
+
* @function
|
56
|
+
* @private
|
57
|
+
*/
|
58
|
+
ResponsiveToggle.prototype._events = function() {
|
59
|
+
var _this = this;
|
60
|
+
|
61
|
+
$(window).on('changed.zf.mediaquery', this._update.bind(this));
|
62
|
+
|
63
|
+
this.$toggler.on('click.zf.responsiveToggle', this.toggleMenu.bind(this));
|
64
|
+
};
|
65
|
+
|
66
|
+
/**
|
67
|
+
* Checks the current media query to determine if the tab bar should be visible or hidden.
|
68
|
+
* @function
|
69
|
+
* @private
|
70
|
+
*/
|
71
|
+
ResponsiveToggle.prototype._update = function() {
|
72
|
+
// Mobile
|
73
|
+
if (!Foundation.MediaQuery.atLeast(this.options.hideFor)) {
|
74
|
+
this.$element.show();
|
75
|
+
this.$targetMenu.hide();
|
76
|
+
}
|
77
|
+
|
78
|
+
// Desktop
|
79
|
+
else {
|
80
|
+
this.$element.hide();
|
81
|
+
this.$targetMenu.show();
|
82
|
+
}
|
83
|
+
};
|
84
|
+
|
85
|
+
/**
|
86
|
+
* Toggles the element attached to the tab bar. The toggle only happens if the screen is small enough to allow it.
|
87
|
+
* @function
|
88
|
+
* @fires ResponsiveToggle#toggled
|
89
|
+
*/
|
90
|
+
ResponsiveToggle.prototype.toggleMenu = function() {
|
91
|
+
if (!Foundation.MediaQuery.atLeast(this.options.hideFor)) {
|
92
|
+
this.$targetMenu.toggle(0);
|
93
|
+
|
94
|
+
/**
|
95
|
+
* Fires when the element attached to the tab bar toggles.
|
96
|
+
* @event ResponsiveToggle#toggled
|
97
|
+
*/
|
98
|
+
this.$element.trigger('toggled.zf.responsiveToggle');
|
99
|
+
}
|
100
|
+
};
|
101
|
+
ResponsiveToggle.prototype.destroy = function(){
|
102
|
+
//TODO this...
|
103
|
+
};
|
104
|
+
Foundation.plugin(ResponsiveToggle, 'ResponsiveToggle');
|
105
|
+
|
106
|
+
}(jQuery, Foundation);
|
@@ -0,0 +1,478 @@
|
|
1
|
+
/**
|
2
|
+
* Reveal module.
|
3
|
+
* @module foundation.reveal
|
4
|
+
* @requires foundation.util.keyboard
|
5
|
+
* @requires foundation.util.box
|
6
|
+
* @requires foundation.util.triggers
|
7
|
+
* @requires foundation.util.mediaQuery
|
8
|
+
* @requires foundation.util.motion if using animations
|
9
|
+
*/
|
10
|
+
!function(Foundation, $) {
|
11
|
+
'use strict';
|
12
|
+
|
13
|
+
/**
|
14
|
+
* Creates a new instance of Reveal.
|
15
|
+
* @class
|
16
|
+
* @param {jQuery} element - jQuery object to use for the modal.
|
17
|
+
* @param {Object} options - optional parameters.
|
18
|
+
*/
|
19
|
+
|
20
|
+
function Reveal(element, options) {
|
21
|
+
this.$element = element;
|
22
|
+
this.options = $.extend({}, Reveal.defaults, this.$element.data(), options);
|
23
|
+
this._init();
|
24
|
+
|
25
|
+
Foundation.registerPlugin(this, 'Reveal');
|
26
|
+
Foundation.Keyboard.register('Reveal', {
|
27
|
+
'ENTER': 'open',
|
28
|
+
'SPACE': 'open',
|
29
|
+
'ESCAPE': 'close',
|
30
|
+
'TAB': 'tab_forward',
|
31
|
+
'SHIFT_TAB': 'tab_backward'
|
32
|
+
});
|
33
|
+
}
|
34
|
+
|
35
|
+
Reveal.defaults = {
|
36
|
+
/**
|
37
|
+
* Motion-UI class to use for animated elements. If none used, defaults to simple show/hide.
|
38
|
+
* @option
|
39
|
+
* @example 'slide-in-left'
|
40
|
+
*/
|
41
|
+
animationIn: '',
|
42
|
+
/**
|
43
|
+
* Motion-UI class to use for animated elements. If none used, defaults to simple show/hide.
|
44
|
+
* @option
|
45
|
+
* @example 'slide-out-right'
|
46
|
+
*/
|
47
|
+
animationOut: '',
|
48
|
+
/**
|
49
|
+
* Time, in ms, to delay the opening of a modal after a click if no animation used.
|
50
|
+
* @option
|
51
|
+
* @example 10
|
52
|
+
*/
|
53
|
+
showDelay: 0,
|
54
|
+
/**
|
55
|
+
* Time, in ms, to delay the closing of a modal after a click if no animation used.
|
56
|
+
* @option
|
57
|
+
* @example 10
|
58
|
+
*/
|
59
|
+
hideDelay: 0,
|
60
|
+
/**
|
61
|
+
* Allows a click on the body/overlay to close the modal.
|
62
|
+
* @option
|
63
|
+
* @example true
|
64
|
+
*/
|
65
|
+
closeOnClick: true,
|
66
|
+
/**
|
67
|
+
* Allows the modal to close if the user presses the `ESCAPE` key.
|
68
|
+
* @option
|
69
|
+
* @example true
|
70
|
+
*/
|
71
|
+
closeOnEsc: true,
|
72
|
+
/**
|
73
|
+
* If true, allows multiple modals to be displayed at once.
|
74
|
+
* @option
|
75
|
+
* @example false
|
76
|
+
*/
|
77
|
+
multipleOpened: false,
|
78
|
+
/**
|
79
|
+
* Distance, in pixels, the modal should push down from the top of the screen.
|
80
|
+
* @option
|
81
|
+
* @example 100
|
82
|
+
*/
|
83
|
+
vOffset: 100,
|
84
|
+
/**
|
85
|
+
* Distance, in pixels, the modal should push in from the side of the screen.
|
86
|
+
* @option
|
87
|
+
* @example 0
|
88
|
+
*/
|
89
|
+
hOffset: 0,
|
90
|
+
/**
|
91
|
+
* Allows the modal to be fullscreen, completely blocking out the rest of the view. JS checks for this as well.
|
92
|
+
* @option
|
93
|
+
* @example false
|
94
|
+
*/
|
95
|
+
fullScreen: false,
|
96
|
+
/**
|
97
|
+
* Percentage of screen height the modal should push up from the bottom of the view.
|
98
|
+
* @option
|
99
|
+
* @example 10
|
100
|
+
*/
|
101
|
+
btmOffsetPct: 10,
|
102
|
+
/**
|
103
|
+
* Allows the modal to generate an overlay div, which will cover the view when modal opens.
|
104
|
+
* @option
|
105
|
+
* @example true
|
106
|
+
*/
|
107
|
+
overlay: true,
|
108
|
+
/**
|
109
|
+
* Allows the modal to remove and reinject markup on close. Should be true if using video elements w/o using provider's api.
|
110
|
+
* @option
|
111
|
+
* @example false
|
112
|
+
*/
|
113
|
+
resetOnClose: false
|
114
|
+
};
|
115
|
+
|
116
|
+
/**
|
117
|
+
* Initializes the modal by adding the overlay and close buttons, (if selected).
|
118
|
+
* @private
|
119
|
+
*/
|
120
|
+
Reveal.prototype._init = function(){
|
121
|
+
this.id = this.$element.attr('id');
|
122
|
+
this.isActive = false;
|
123
|
+
|
124
|
+
this.$anchor = $('[data-open="' + this.id + '"]').length ? $('[data-open="' + this.id + '"]') : $('[data-toggle="' + this.id + '"]');
|
125
|
+
|
126
|
+
if(this.$anchor.length){
|
127
|
+
var anchorId = this.$anchor[0].id || Foundation.GetYoDigits(6, 'reveal');
|
128
|
+
|
129
|
+
this.$anchor.attr({
|
130
|
+
'aria-controls': this.id,
|
131
|
+
'id': anchorId,
|
132
|
+
'aria-haspopup': true,
|
133
|
+
'tabindex': 0
|
134
|
+
});
|
135
|
+
this.$element.attr({'aria-labelledby': anchorId});
|
136
|
+
}
|
137
|
+
|
138
|
+
// this.options.fullScreen = this.$element.hasClass('full');
|
139
|
+
if(this.options.fullScreen || this.$element.hasClass('full')){
|
140
|
+
this.options.fullScreen = true;
|
141
|
+
this.options.overlay = false;
|
142
|
+
}
|
143
|
+
if(this.options.overlay && !this.$overlay){
|
144
|
+
this.$overlay = this._makeOverlay(this.id);
|
145
|
+
}
|
146
|
+
|
147
|
+
this.$element.attr({
|
148
|
+
'role': 'dialog',
|
149
|
+
'aria-hidden': true,
|
150
|
+
'data-yeti-box': this.id,
|
151
|
+
'data-resize': this.id
|
152
|
+
});
|
153
|
+
|
154
|
+
this._events();
|
155
|
+
};
|
156
|
+
|
157
|
+
/**
|
158
|
+
* Creates an overlay div to display behind the modal.
|
159
|
+
* @private
|
160
|
+
*/
|
161
|
+
Reveal.prototype._makeOverlay = function(id){
|
162
|
+
var $overlay = $('<div></div>')
|
163
|
+
.addClass('reveal-overlay')
|
164
|
+
.attr({'tabindex': -1, 'aria-hidden': true})
|
165
|
+
.appendTo('body');
|
166
|
+
if(this.options.closeOnClick){
|
167
|
+
$overlay.attr({
|
168
|
+
'data-close': id
|
169
|
+
});
|
170
|
+
}
|
171
|
+
return $overlay;
|
172
|
+
};
|
173
|
+
|
174
|
+
/**
|
175
|
+
* Adds event handlers for the modal.
|
176
|
+
* @private
|
177
|
+
*/
|
178
|
+
Reveal.prototype._events = function(){
|
179
|
+
var _this = this;
|
180
|
+
|
181
|
+
this.$element.on({
|
182
|
+
'open.zf.trigger': this.open.bind(this),
|
183
|
+
'close.zf.trigger': this.close.bind(this),
|
184
|
+
'toggle.zf.trigger': this.toggle.bind(this),
|
185
|
+
'resizeme.zf.trigger': function(){
|
186
|
+
if(_this.$element.is(':visible')){
|
187
|
+
_this._setPosition(function(){});
|
188
|
+
}
|
189
|
+
}
|
190
|
+
});
|
191
|
+
|
192
|
+
if(this.$anchor.length){
|
193
|
+
this.$anchor.on('keydown.zf.reveal', function(e){
|
194
|
+
if(e.which === 13 || e.which === 32){
|
195
|
+
e.stopPropagation();
|
196
|
+
e.preventDefault();
|
197
|
+
_this.open();
|
198
|
+
}
|
199
|
+
});
|
200
|
+
}
|
201
|
+
|
202
|
+
|
203
|
+
if(this.options.closeOnClick && this.options.overlay){
|
204
|
+
this.$overlay.off('.zf.reveal').on('click.zf.reveal', this.close.bind(this));
|
205
|
+
}
|
206
|
+
};
|
207
|
+
/**
|
208
|
+
* Sets the position of the modal before opening
|
209
|
+
* @param {Function} cb - a callback function to execute when positioning is complete.
|
210
|
+
* @private
|
211
|
+
*/
|
212
|
+
Reveal.prototype._setPosition = function(cb){
|
213
|
+
var eleDims = Foundation.Box.GetDimensions(this.$element);
|
214
|
+
var elePos = this.options.fullScreen ? 'reveal full' : (eleDims.height >= (0.5 * eleDims.windowDims.height)) ? 'reveal' : 'center';
|
215
|
+
|
216
|
+
if(elePos === 'reveal full'){
|
217
|
+
//set to full height/width
|
218
|
+
this.$element
|
219
|
+
.offset(Foundation.Box.GetOffsets(this.$element, null, elePos, this.options.vOffset))
|
220
|
+
.css({
|
221
|
+
'height': eleDims.windowDims.height,
|
222
|
+
'width': eleDims.windowDims.width
|
223
|
+
});
|
224
|
+
}else if(!Foundation.MediaQuery.atLeast('medium') || !Foundation.Box.ImNotTouchingYou(this.$element, null, true, false)){
|
225
|
+
//if smaller than medium, resize to 100% width minus any custom L/R margin
|
226
|
+
this.$element
|
227
|
+
.css({
|
228
|
+
'width': eleDims.windowDims.width - (this.options.hOffset * 2)
|
229
|
+
})
|
230
|
+
.offset(Foundation.Box.GetOffsets(this.$element, null, 'center', this.options.vOffset, this.options.hOffset));
|
231
|
+
//flag a boolean so we can reset the size after the element is closed.
|
232
|
+
this.changedSize = true;
|
233
|
+
}else{
|
234
|
+
this.$element
|
235
|
+
.css({
|
236
|
+
'max-height': eleDims.windowDims.height - (this.options.vOffset * (this.options.btmOffsetPct / 100 + 1)),
|
237
|
+
'width': ''
|
238
|
+
})
|
239
|
+
.offset(Foundation.Box.GetOffsets(this.$element, null, elePos, this.options.vOffset));
|
240
|
+
//the max height based on a percentage of vertical offset plus vertical offset
|
241
|
+
}
|
242
|
+
|
243
|
+
cb();
|
244
|
+
};
|
245
|
+
|
246
|
+
/**
|
247
|
+
* Opens the modal controlled by `this.$anchor`, and closes all others by default.
|
248
|
+
* @function
|
249
|
+
* @fires Reveal#closeme
|
250
|
+
* @fires Reveal#open
|
251
|
+
*/
|
252
|
+
Reveal.prototype.open = function(){
|
253
|
+
var _this = this;
|
254
|
+
this.isActive = true;
|
255
|
+
//make element invisible, but remove display: none so we can get size and positioning
|
256
|
+
this.$element
|
257
|
+
.css({'visibility': 'hidden'})
|
258
|
+
.show()
|
259
|
+
.scrollTop(0);
|
260
|
+
|
261
|
+
this._setPosition(function(){
|
262
|
+
_this.$element.hide()
|
263
|
+
.css({'visibility': ''});
|
264
|
+
if(!_this.options.multipleOpened){
|
265
|
+
/**
|
266
|
+
* Fires immediately before the modal opens.
|
267
|
+
* Closes any other modals that are currently open
|
268
|
+
* @event Reveal#closeme
|
269
|
+
*/
|
270
|
+
_this.$element.trigger('closeme.zf.reveal', _this.id);
|
271
|
+
}
|
272
|
+
if(_this.options.animationIn){
|
273
|
+
if(_this.options.overlay){
|
274
|
+
Foundation.Motion.animateIn(_this.$overlay, 'fade-in', function(){
|
275
|
+
Foundation.Motion.animateIn(_this.$element, _this.options.animationIn, function(){
|
276
|
+
_this.focusableElements = Foundation.Keyboard.findFocusable(_this.$element);
|
277
|
+
});
|
278
|
+
});
|
279
|
+
}else{
|
280
|
+
Foundation.Motion.animateIn(_this.$element, _this.options.animationIn, function(){
|
281
|
+
_this.focusableElements = Foundation.Keyboard.findFocusable(_this.$element);
|
282
|
+
});
|
283
|
+
}
|
284
|
+
}else{
|
285
|
+
if(_this.options.overlay){
|
286
|
+
_this.$overlay.show(0, function(){
|
287
|
+
_this.$element.show(_this.options.showDelay, function(){
|
288
|
+
});
|
289
|
+
});
|
290
|
+
}else{
|
291
|
+
_this.$element.show(_this.options.showDelay, function(){
|
292
|
+
});
|
293
|
+
}
|
294
|
+
}
|
295
|
+
});
|
296
|
+
|
297
|
+
|
298
|
+
// handle accessibility
|
299
|
+
this.$element.attr({'aria-hidden': false}).attr('tabindex', -1).focus()
|
300
|
+
/**
|
301
|
+
* Fires when the modal has successfully opened.
|
302
|
+
* @event Reveal#open
|
303
|
+
*/
|
304
|
+
.trigger('open.zf.reveal');
|
305
|
+
|
306
|
+
$('body').addClass('is-reveal-open')
|
307
|
+
.attr({'aria-hidden': (this.options.overlay || this.options.fullScreen) ? true : false});
|
308
|
+
setTimeout(function(){
|
309
|
+
_this._extraHandlers();
|
310
|
+
// Foundation.reflow();
|
311
|
+
}, 0);
|
312
|
+
};
|
313
|
+
|
314
|
+
/**
|
315
|
+
* Adds extra event handlers for the body and window if necessary.
|
316
|
+
* @private
|
317
|
+
*/
|
318
|
+
Reveal.prototype._extraHandlers = function(){
|
319
|
+
var _this = this;
|
320
|
+
this.focusableElements = Foundation.Keyboard.findFocusable(this.$element);
|
321
|
+
|
322
|
+
if(!this.options.overlay && this.options.closeOnClick && !this.options.fullScreen){
|
323
|
+
$('body').on('click.zf.reveal', function(e){
|
324
|
+
// if()
|
325
|
+
_this.close();
|
326
|
+
});
|
327
|
+
}
|
328
|
+
if(this.options.closeOnEsc){
|
329
|
+
$(window).on('keydown.zf.reveal', function(e){
|
330
|
+
Foundation.Keyboard.handleKey(e, 'Reveal', {
|
331
|
+
close: function() {
|
332
|
+
if (_this.options.closeOnEsc) {
|
333
|
+
_this.close();
|
334
|
+
_this.$anchor.focus();
|
335
|
+
}
|
336
|
+
}
|
337
|
+
});
|
338
|
+
if (_this.focusableElements.length === 0) { // no focusable elements inside the modal at all, prevent tabbing in general
|
339
|
+
e.preventDefault();
|
340
|
+
}
|
341
|
+
});
|
342
|
+
}
|
343
|
+
|
344
|
+
// lock focus within modal while tabbing
|
345
|
+
this.$element.on('keydown.zf.reveal', function(e) {
|
346
|
+
var $target = $(this);
|
347
|
+
// handle keyboard event with keyboard util
|
348
|
+
Foundation.Keyboard.handleKey(e, 'Reveal', {
|
349
|
+
tab_forward: function() {
|
350
|
+
if (_this.$element.find(':focus').is(_this.focusableElements.eq(-1))) { // left modal downwards, setting focus to first element
|
351
|
+
_this.focusableElements.eq(0).focus();
|
352
|
+
e.preventDefault();
|
353
|
+
}
|
354
|
+
},
|
355
|
+
tab_backward: function() {
|
356
|
+
if (_this.$element.find(':focus').is(_this.focusableElements.eq(0)) || _this.$element.is(':focus')) { // left modal upwards, setting focus to last element
|
357
|
+
_this.focusableElements.eq(-1).focus();
|
358
|
+
e.preventDefault();
|
359
|
+
}
|
360
|
+
},
|
361
|
+
open: function() {
|
362
|
+
if (_this.$element.find(':focus').is(_this.$element.find('[data-close]'))) {
|
363
|
+
setTimeout(function() { // set focus back to anchor if close button has been activated
|
364
|
+
_this.$anchor.focus();
|
365
|
+
}, 1);
|
366
|
+
} else if ($target.is(_this.focusableElements)) { // dont't trigger if acual element has focus (i.e. inputs, links, ...)
|
367
|
+
_this.open();
|
368
|
+
}
|
369
|
+
},
|
370
|
+
close: function() {
|
371
|
+
if (_this.options.closeOnEsc) {
|
372
|
+
_this.close();
|
373
|
+
_this.$anchor.focus();
|
374
|
+
}
|
375
|
+
}
|
376
|
+
});
|
377
|
+
});
|
378
|
+
|
379
|
+
};
|
380
|
+
|
381
|
+
/**
|
382
|
+
* Closes the modal.
|
383
|
+
* @function
|
384
|
+
* @fires Reveal#closed
|
385
|
+
*/
|
386
|
+
Reveal.prototype.close = function(){
|
387
|
+
if(!this.isActive || !this.$element.is(':visible')){
|
388
|
+
return false;
|
389
|
+
}
|
390
|
+
var _this = this;
|
391
|
+
|
392
|
+
if(this.options.animationOut){
|
393
|
+
Foundation.Motion.animateOut(this.$element, this.options.animationOut, function(){
|
394
|
+
if(_this.options.overlay){
|
395
|
+
Foundation.Motion.animateOut(_this.$overlay, 'fade-out', function(){
|
396
|
+
});
|
397
|
+
}
|
398
|
+
});
|
399
|
+
}else{
|
400
|
+
this.$element.hide(_this.options.hideDelay, function(){
|
401
|
+
if(_this.options.overlay){
|
402
|
+
_this.$overlay.hide(0, function(){
|
403
|
+
});
|
404
|
+
}
|
405
|
+
});
|
406
|
+
}
|
407
|
+
//conditionals to remove extra event listeners added on open
|
408
|
+
if(this.options.closeOnEsc){
|
409
|
+
$(window).off('keydown.zf.reveal');
|
410
|
+
}
|
411
|
+
if(!this.options.overlay && this.options.closeOnClick){
|
412
|
+
$('body').off('click.zf.reveal');
|
413
|
+
}
|
414
|
+
this.$element.off('keydown.zf.reveal');
|
415
|
+
|
416
|
+
//if the modal changed size, reset it
|
417
|
+
if(this.changedSize){
|
418
|
+
this.$element.css({
|
419
|
+
'height': '',
|
420
|
+
'width': ''
|
421
|
+
});
|
422
|
+
}
|
423
|
+
|
424
|
+
$('body').removeClass('is-reveal-open').attr({'aria-hidden': false, 'tabindex': ''});
|
425
|
+
|
426
|
+
/**
|
427
|
+
* Resets the modal content
|
428
|
+
* This prevents a running video to keep going in the background
|
429
|
+
*/
|
430
|
+
if(this.options.resetOnClose) {
|
431
|
+
this.$element.html(this.$element.html());
|
432
|
+
}
|
433
|
+
|
434
|
+
this.isActive = false;
|
435
|
+
this.$element.attr({'aria-hidden': true})
|
436
|
+
/**
|
437
|
+
* Fires when the modal is done closing.
|
438
|
+
* @event Reveal#closed
|
439
|
+
*/
|
440
|
+
.trigger('closed.zf.reveal');
|
441
|
+
};
|
442
|
+
/**
|
443
|
+
* Toggles the open/closed state of a modal.
|
444
|
+
* @function
|
445
|
+
*/
|
446
|
+
Reveal.prototype.toggle = function(){
|
447
|
+
if(this.isActive){
|
448
|
+
this.close();
|
449
|
+
}else{
|
450
|
+
this.open();
|
451
|
+
}
|
452
|
+
};
|
453
|
+
|
454
|
+
/**
|
455
|
+
* Destroys an instance of a modal.
|
456
|
+
* @function
|
457
|
+
*/
|
458
|
+
Reveal.prototype.destroy = function() {
|
459
|
+
if(this.options.overlay){
|
460
|
+
this.$overlay.hide().off().remove();
|
461
|
+
}
|
462
|
+
this.$element.hide();
|
463
|
+
this.$anchor.off();
|
464
|
+
|
465
|
+
Foundation.unregisterPlugin(this);
|
466
|
+
};
|
467
|
+
|
468
|
+
Foundation.plugin(Reveal, 'Reveal');
|
469
|
+
|
470
|
+
// Exports for AMD/Browserify
|
471
|
+
if (typeof module !== 'undefined' && typeof module.exports !== 'undefined')
|
472
|
+
module.exports = Reveal;
|
473
|
+
if (typeof define === 'function')
|
474
|
+
define(['foundation'], function() {
|
475
|
+
return Reveal;
|
476
|
+
});
|
477
|
+
|
478
|
+
}(Foundation, jQuery);
|