foundation-rails 6.1.2.0 → 6.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/.travis.yml +7 -6
- data/README.md +1 -1
- data/Rakefile +5 -1
- data/bower.json +3 -3
- data/foundation-rails.gemspec +1 -0
- data/lib/foundation-rails.rb +1 -0
- data/lib/foundation/rails/version.rb +1 -1
- data/lib/generators/foundation/templates/foundation_and_overrides.scss +2 -2
- data/vendor/assets/js/foundation.abide.js.es6 +462 -0
- data/vendor/assets/js/{foundation.accordion.js → foundation.accordion.js.es6} +55 -47
- data/vendor/assets/js/{foundation.accordionMenu.js → foundation.accordionMenu.js.es6} +46 -35
- data/vendor/assets/js/{foundation.core.js → foundation.core.js.es6} +10 -8
- data/vendor/assets/js/{foundation.drilldown.js → foundation.drilldown.js.es6} +75 -49
- data/vendor/assets/js/{foundation.dropdown.js → foundation.dropdown.js.es6} +100 -88
- data/vendor/assets/js/{foundation.dropdownMenu.js → foundation.dropdownMenu.js.es6} +134 -128
- data/vendor/assets/js/{foundation.equalizer.js → foundation.equalizer.js.es6} +72 -61
- data/vendor/assets/js/{foundation.interchange.js → foundation.interchange.js.es6} +44 -45
- data/vendor/assets/js/{foundation.js → foundation.js.es6} +0 -0
- data/vendor/assets/js/{foundation.magellan.js → foundation.magellan.js.es6} +80 -83
- data/vendor/assets/js/foundation.offcanvas.js.es6 +395 -0
- data/vendor/assets/js/foundation.orbit.js.es6 +445 -0
- data/vendor/assets/js/{foundation.responsiveMenu.js → foundation.responsiveMenu.js.es6} +37 -31
- data/vendor/assets/js/foundation.responsiveToggle.js.es6 +112 -0
- data/vendor/assets/js/foundation.reveal.js.es6 +544 -0
- data/vendor/assets/js/{foundation.slider.js → foundation.slider.js.es6} +235 -184
- data/vendor/assets/js/{foundation.sticky.js → foundation.sticky.js.es6} +177 -166
- data/vendor/assets/js/{foundation.tabs.js → foundation.tabs.js.es6} +138 -118
- data/vendor/assets/js/{foundation.toggler.js → foundation.toggler.js.es6} +34 -37
- data/vendor/assets/js/{foundation.tooltip.js → foundation.tooltip.js.es6} +162 -153
- data/vendor/assets/js/foundation.util.box.js.es6 +183 -0
- data/vendor/assets/js/{foundation.util.keyboard.js → foundation.util.keyboard.js.es6} +54 -54
- data/vendor/assets/js/{foundation.util.mediaQuery.js → foundation.util.mediaQuery.js.es6} +46 -46
- data/vendor/assets/js/{foundation.util.motion.js → foundation.util.motion.js.es6} +58 -48
- data/vendor/assets/js/foundation.util.nest.js.es6 +76 -0
- data/vendor/assets/js/foundation.util.timerAndImageLoader.js.es6 +86 -0
- data/vendor/assets/js/{foundation.util.touch.js → foundation.util.touch.js.es6} +2 -2
- data/vendor/assets/js/foundation.util.triggers.js.es6 +239 -0
- data/vendor/assets/scss/_global.scss +28 -27
- data/vendor/assets/scss/components/_badge.scss +1 -1
- data/vendor/assets/scss/components/_button-group.scss +77 -26
- data/vendor/assets/scss/components/_button.scss +8 -8
- data/vendor/assets/scss/components/_callout.scss +2 -2
- data/vendor/assets/scss/components/_drilldown.scss +4 -0
- data/vendor/assets/scss/components/_dropdown-menu.scss +104 -54
- data/vendor/assets/scss/components/_flex.scss +28 -0
- data/vendor/assets/scss/components/_label.scss +1 -1
- data/vendor/assets/scss/components/_media-object.scss +37 -7
- data/vendor/assets/scss/components/_menu-icon.scss +9 -0
- data/vendor/assets/scss/components/_menu.scss +127 -29
- data/vendor/assets/scss/components/_off-canvas.scss +1 -0
- data/vendor/assets/scss/components/_pagination.scss +3 -3
- data/vendor/assets/scss/components/_progress-bar.scss +1 -25
- data/vendor/assets/scss/components/_reveal.scss +12 -6
- data/vendor/assets/scss/components/_slider.scss +3 -35
- data/vendor/assets/scss/components/_table.scss +8 -0
- data/vendor/assets/scss/components/_tabs.scss +5 -10
- data/vendor/assets/scss/components/_title-bar.scss +27 -10
- data/vendor/assets/scss/components/_tooltip.scss +0 -4
- data/vendor/assets/scss/components/_top-bar.scss +93 -21
- data/vendor/assets/scss/components/_visibility.scss +1 -1
- data/vendor/assets/scss/forms/_checkbox.scss +1 -1
- data/vendor/assets/scss/forms/_error.scss +7 -5
- data/vendor/assets/scss/forms/_forms.scss +3 -0
- data/vendor/assets/scss/forms/_help-text.scss +1 -1
- data/vendor/assets/scss/forms/_input-group.scss +44 -9
- data/vendor/assets/scss/forms/_meter.scss +109 -0
- data/vendor/assets/scss/forms/_progress.scss +85 -0
- data/vendor/assets/scss/forms/_range.scss +144 -0
- data/vendor/assets/scss/forms/_select.scss +1 -1
- data/vendor/assets/scss/forms/_text.scss +10 -1
- data/vendor/assets/scss/foundation.scss +16 -5
- data/vendor/assets/scss/grid/_classes.scss +5 -18
- data/vendor/assets/scss/grid/_column.scss +13 -11
- data/vendor/assets/scss/grid/_flex-grid.scss +54 -80
- data/vendor/assets/scss/grid/_grid.scss +22 -10
- data/vendor/assets/scss/grid/_layout.scss +18 -0
- data/vendor/assets/scss/grid/_row.scss +11 -15
- data/vendor/assets/scss/motion-ui/_classes.scss +10 -3
- data/vendor/assets/scss/motion-ui/effects/_fade.scss +4 -1
- data/vendor/assets/scss/motion-ui/effects/_zoom.scss +1 -1
- data/vendor/assets/scss/motion-ui/transitions/_slide.scss +1 -1
- data/vendor/assets/scss/motion-ui/util/_transition.scss +1 -1
- data/vendor/assets/scss/settings/_settings.scss +64 -47
- data/vendor/assets/scss/typography/_base.scss +4 -0
- data/vendor/assets/scss/typography/_print.scss +9 -5
- data/vendor/assets/scss/util/_breakpoint.scss +31 -25
- data/vendor/assets/scss/util/_color.scss +19 -0
- data/vendor/assets/scss/util/_flex.scss +68 -0
- data/vendor/assets/scss/util/_mixins.scss +13 -7
- data/vendor/assets/scss/util/_util.scss +1 -5
- data/vendor/assets/scss/util/_value.scss +9 -28
- metadata +51 -31
- data/vendor/assets/js/foundation.abide.js +0 -418
- data/vendor/assets/js/foundation.offcanvas.js +0 -376
- data/vendor/assets/js/foundation.orbit.js +0 -421
- data/vendor/assets/js/foundation.responsiveToggle.js +0 -106
- data/vendor/assets/js/foundation.reveal.js +0 -514
- data/vendor/assets/js/foundation.util.box.js +0 -169
- data/vendor/assets/js/foundation.util.nest.js +0 -63
- data/vendor/assets/js/foundation.util.timerAndImageLoader.js +0 -82
- data/vendor/assets/js/foundation.util.triggers.js +0 -224
@@ -0,0 +1,183 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
!function($) {
|
4
|
+
|
5
|
+
Foundation.Box = {
|
6
|
+
ImNotTouchingYou: ImNotTouchingYou,
|
7
|
+
GetDimensions: GetDimensions,
|
8
|
+
GetOffsets: GetOffsets
|
9
|
+
}
|
10
|
+
|
11
|
+
/**
|
12
|
+
* Compares the dimensions of an element to a container and determines collision events with container.
|
13
|
+
* @function
|
14
|
+
* @param {jQuery} element - jQuery object to test for collisions.
|
15
|
+
* @param {jQuery} parent - jQuery object to use as bounding container.
|
16
|
+
* @param {Boolean} lrOnly - set to true to check left and right values only.
|
17
|
+
* @param {Boolean} tbOnly - set to true to check top and bottom values only.
|
18
|
+
* @default if no parent object passed, detects collisions with `window`.
|
19
|
+
* @returns {Boolean} - true if collision free, false if a collision in any direction.
|
20
|
+
*/
|
21
|
+
function ImNotTouchingYou(element, parent, lrOnly, tbOnly) {
|
22
|
+
var eleDims = GetDimensions(element),
|
23
|
+
top, bottom, left, right;
|
24
|
+
|
25
|
+
if (parent) {
|
26
|
+
var parDims = GetDimensions(parent);
|
27
|
+
|
28
|
+
bottom = (eleDims.offset.top + eleDims.height <= parDims.height + parDims.offset.top);
|
29
|
+
top = (eleDims.offset.top >= parDims.offset.top);
|
30
|
+
left = (eleDims.offset.left >= parDims.offset.left);
|
31
|
+
right = (eleDims.offset.left + eleDims.width <= parDims.width);
|
32
|
+
}
|
33
|
+
else {
|
34
|
+
bottom = (eleDims.offset.top + eleDims.height <= eleDims.windowDims.height + eleDims.windowDims.offset.top);
|
35
|
+
top = (eleDims.offset.top >= eleDims.windowDims.offset.top);
|
36
|
+
left = (eleDims.offset.left >= eleDims.windowDims.offset.left);
|
37
|
+
right = (eleDims.offset.left + eleDims.width <= eleDims.windowDims.width);
|
38
|
+
}
|
39
|
+
|
40
|
+
var allDirs = [bottom, top, left, right];
|
41
|
+
|
42
|
+
if (lrOnly) {
|
43
|
+
return left === right === true;
|
44
|
+
}
|
45
|
+
|
46
|
+
if (tbOnly) {
|
47
|
+
return top === bottom === true;
|
48
|
+
}
|
49
|
+
|
50
|
+
return allDirs.indexOf(false) === -1;
|
51
|
+
};
|
52
|
+
|
53
|
+
/**
|
54
|
+
* Uses native methods to return an object of dimension values.
|
55
|
+
* @function
|
56
|
+
* @param {jQuery || HTML} element - jQuery object or DOM element for which to get the dimensions. Can be any element other that document or window.
|
57
|
+
* @returns {Object} - nested object of integer pixel values
|
58
|
+
* TODO - if element is window, return only those values.
|
59
|
+
*/
|
60
|
+
function GetDimensions(elem, test){
|
61
|
+
elem = elem.length ? elem[0] : elem;
|
62
|
+
|
63
|
+
if (elem === window || elem === document) {
|
64
|
+
throw new Error("I'm sorry, Dave. I'm afraid I can't do that.");
|
65
|
+
}
|
66
|
+
|
67
|
+
var rect = elem.getBoundingClientRect(),
|
68
|
+
parRect = elem.parentNode.getBoundingClientRect(),
|
69
|
+
winRect = document.body.getBoundingClientRect(),
|
70
|
+
winY = window.pageYOffset,
|
71
|
+
winX = window.pageXOffset;
|
72
|
+
|
73
|
+
return {
|
74
|
+
width: rect.width,
|
75
|
+
height: rect.height,
|
76
|
+
offset: {
|
77
|
+
top: rect.top + winY,
|
78
|
+
left: rect.left + winX
|
79
|
+
},
|
80
|
+
parentDims: {
|
81
|
+
width: parRect.width,
|
82
|
+
height: parRect.height,
|
83
|
+
offset: {
|
84
|
+
top: parRect.top + winY,
|
85
|
+
left: parRect.left + winX
|
86
|
+
}
|
87
|
+
},
|
88
|
+
windowDims: {
|
89
|
+
width: winRect.width,
|
90
|
+
height: winRect.height,
|
91
|
+
offset: {
|
92
|
+
top: winY,
|
93
|
+
left: winX
|
94
|
+
}
|
95
|
+
}
|
96
|
+
}
|
97
|
+
}
|
98
|
+
|
99
|
+
/**
|
100
|
+
* Returns an object of top and left integer pixel values for dynamically rendered elements,
|
101
|
+
* such as: Tooltip, Reveal, and Dropdown
|
102
|
+
* @function
|
103
|
+
* @param {jQuery} element - jQuery object for the element being positioned.
|
104
|
+
* @param {jQuery} anchor - jQuery object for the element's anchor point.
|
105
|
+
* @param {String} position - a string relating to the desired position of the element, relative to it's anchor
|
106
|
+
* @param {Number} vOffset - integer pixel value of desired vertical separation between anchor and element.
|
107
|
+
* @param {Number} hOffset - integer pixel value of desired horizontal separation between anchor and element.
|
108
|
+
* @param {Boolean} isOverflow - if a collision event is detected, sets to true to default the element to full width - any desired offset.
|
109
|
+
* TODO alter/rewrite to work with `em` values as well/instead of pixels
|
110
|
+
*/
|
111
|
+
function GetOffsets(element, anchor, position, vOffset, hOffset, isOverflow) {
|
112
|
+
var $eleDims = GetDimensions(element),
|
113
|
+
$anchorDims = anchor ? GetDimensions(anchor) : null;
|
114
|
+
|
115
|
+
switch (position) {
|
116
|
+
case 'top':
|
117
|
+
return {
|
118
|
+
left: (Foundation.rtl() ? $anchorDims.offset.left - $eleDims.width + $anchorDims.width : $anchorDims.offset.left),
|
119
|
+
top: $anchorDims.offset.top - ($eleDims.height + vOffset)
|
120
|
+
}
|
121
|
+
break;
|
122
|
+
case 'left':
|
123
|
+
return {
|
124
|
+
left: $anchorDims.offset.left - ($eleDims.width + hOffset),
|
125
|
+
top: $anchorDims.offset.top
|
126
|
+
}
|
127
|
+
break;
|
128
|
+
case 'right':
|
129
|
+
return {
|
130
|
+
left: $anchorDims.offset.left + $anchorDims.width + hOffset,
|
131
|
+
top: $anchorDims.offset.top
|
132
|
+
}
|
133
|
+
break;
|
134
|
+
case 'center top':
|
135
|
+
return {
|
136
|
+
left: ($anchorDims.offset.left + ($anchorDims.width / 2)) - ($eleDims.width / 2),
|
137
|
+
top: $anchorDims.offset.top - ($eleDims.height + vOffset)
|
138
|
+
}
|
139
|
+
break;
|
140
|
+
case 'center bottom':
|
141
|
+
return {
|
142
|
+
left: isOverflow ? hOffset : (($anchorDims.offset.left + ($anchorDims.width / 2)) - ($eleDims.width / 2)),
|
143
|
+
top: $anchorDims.offset.top + $anchorDims.height + vOffset
|
144
|
+
}
|
145
|
+
break;
|
146
|
+
case 'center left':
|
147
|
+
return {
|
148
|
+
left: $anchorDims.offset.left - ($eleDims.width + hOffset),
|
149
|
+
top: ($anchorDims.offset.top + ($anchorDims.height / 2)) - ($eleDims.height / 2)
|
150
|
+
}
|
151
|
+
break;
|
152
|
+
case 'center right':
|
153
|
+
return {
|
154
|
+
left: $anchorDims.offset.left + $anchorDims.width + hOffset + 1,
|
155
|
+
top: ($anchorDims.offset.top + ($anchorDims.height / 2)) - ($eleDims.height / 2)
|
156
|
+
}
|
157
|
+
break;
|
158
|
+
case 'center':
|
159
|
+
return {
|
160
|
+
left: ($eleDims.windowDims.offset.left + ($eleDims.windowDims.width / 2)) - ($eleDims.width / 2),
|
161
|
+
top: ($eleDims.windowDims.offset.top + ($eleDims.windowDims.height / 2)) - ($eleDims.height / 2)
|
162
|
+
}
|
163
|
+
break;
|
164
|
+
case 'reveal':
|
165
|
+
return {
|
166
|
+
left: ($eleDims.windowDims.width - $eleDims.width) / 2,
|
167
|
+
top: $eleDims.windowDims.offset.top + vOffset
|
168
|
+
}
|
169
|
+
case 'reveal full':
|
170
|
+
return {
|
171
|
+
left: $eleDims.windowDims.offset.left,
|
172
|
+
top: $eleDims.windowDims.offset.top
|
173
|
+
}
|
174
|
+
break;
|
175
|
+
default:
|
176
|
+
return {
|
177
|
+
left: (Foundation.rtl() ? $anchorDims.offset.left - $eleDims.width + $anchorDims.width : $anchorDims.offset.left),
|
178
|
+
top: $anchorDims.offset.top + $anchorDims.height + vOffset
|
179
|
+
}
|
180
|
+
}
|
181
|
+
}
|
182
|
+
|
183
|
+
}(jQuery);
|
@@ -5,32 +5,26 @@
|
|
5
5
|
* or the web http://www.mariusolbertz.de/ *
|
6
6
|
* *
|
7
7
|
******************************************/
|
8
|
-
!function($, Foundation){
|
9
|
-
'use strict';
|
10
|
-
Foundation.Keyboard = {};
|
11
|
-
|
12
|
-
var keyCodes = {
|
13
|
-
9: 'TAB',
|
14
|
-
13: 'ENTER',
|
15
|
-
27: 'ESCAPE',
|
16
|
-
32: 'SPACE',
|
17
|
-
37: 'ARROW_LEFT',
|
18
|
-
38: 'ARROW_UP',
|
19
|
-
39: 'ARROW_RIGHT',
|
20
|
-
40: 'ARROW_DOWN'
|
21
|
-
};
|
22
|
-
|
23
|
-
/*
|
24
|
-
* Constants for easier comparing.
|
25
|
-
* Can be used like Foundation.parseKey(event) === Foundation.keys.SPACE
|
26
|
-
*/
|
27
|
-
var keys = (function(kcs) {
|
28
|
-
var k = {};
|
29
|
-
for (var kc in kcs) k[kcs[kc]] = kcs[kc];
|
30
|
-
return k;
|
31
|
-
})(keyCodes);
|
32
8
|
|
33
|
-
|
9
|
+
'use strict';
|
10
|
+
|
11
|
+
!function($) {
|
12
|
+
|
13
|
+
const keyCodes = {
|
14
|
+
9: 'TAB',
|
15
|
+
13: 'ENTER',
|
16
|
+
27: 'ESCAPE',
|
17
|
+
32: 'SPACE',
|
18
|
+
37: 'ARROW_LEFT',
|
19
|
+
38: 'ARROW_UP',
|
20
|
+
39: 'ARROW_RIGHT',
|
21
|
+
40: 'ARROW_DOWN'
|
22
|
+
}
|
23
|
+
|
24
|
+
var commands = {}
|
25
|
+
|
26
|
+
var Keyboard = {
|
27
|
+
keys: getKeyCodes(keyCodes),
|
34
28
|
|
35
29
|
/**
|
36
30
|
* Parses the (keyboard) event and returns a String that represents its key
|
@@ -38,18 +32,13 @@
|
|
38
32
|
* @param {Event} event - the event generated by the event handler
|
39
33
|
* @return String key - String that represents the key pressed
|
40
34
|
*/
|
41
|
-
|
35
|
+
parseKey(event) {
|
42
36
|
var key = keyCodes[event.which || event.keyCode] || String.fromCharCode(event.which).toUpperCase();
|
43
|
-
if (event.shiftKey) key =
|
44
|
-
if (event.ctrlKey) key =
|
45
|
-
if (event.altKey) key =
|
37
|
+
if (event.shiftKey) key = `SHIFT_${key}`;
|
38
|
+
if (event.ctrlKey) key = `CTRL_${key}`;
|
39
|
+
if (event.altKey) key = `ALT_${key}`;
|
46
40
|
return key;
|
47
|
-
}
|
48
|
-
Foundation.Keyboard.parseKey = parseKey;
|
49
|
-
|
50
|
-
|
51
|
-
// plain commands per component go here, ltr and rtl are merged based on orientation
|
52
|
-
var commands = {};
|
41
|
+
},
|
53
42
|
|
54
43
|
/**
|
55
44
|
* Handles the given (keyboard) event
|
@@ -57,12 +46,13 @@
|
|
57
46
|
* @param {String} component - Foundation component's name, e.g. Slider or Reveal
|
58
47
|
* @param {Objects} functions - collection of functions that are to be executed
|
59
48
|
*/
|
60
|
-
|
49
|
+
handleKey(event, component, functions) {
|
61
50
|
var commandList = commands[component],
|
62
|
-
keyCode = parseKey(event),
|
51
|
+
keyCode = this.parseKey(event),
|
63
52
|
cmds,
|
64
53
|
command,
|
65
54
|
fn;
|
55
|
+
|
66
56
|
if (!commandList) return console.warn('Component not defined!');
|
67
57
|
|
68
58
|
if (typeof commandList.ltr === 'undefined') { // this component does not differentiate between ltr and rtl
|
@@ -74,33 +64,30 @@
|
|
74
64
|
}
|
75
65
|
command = cmds[keyCode];
|
76
66
|
|
77
|
-
|
78
67
|
fn = functions[command];
|
79
68
|
if (fn && typeof fn === 'function') { // execute function if exists
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
69
|
+
fn.apply();
|
70
|
+
if (functions.handled || typeof functions.handled === 'function') { // execute function when event was handled
|
71
|
+
functions.handled.apply();
|
72
|
+
}
|
84
73
|
} else {
|
85
|
-
|
86
|
-
|
87
|
-
|
74
|
+
if (functions.unhandled || typeof functions.unhandled === 'function') { // execute function when event was not handled
|
75
|
+
functions.unhandled.apply();
|
76
|
+
}
|
88
77
|
}
|
89
|
-
}
|
90
|
-
Foundation.Keyboard.handleKey = handleKey;
|
78
|
+
},
|
91
79
|
|
92
80
|
/**
|
93
81
|
* Finds all focusable elements within the given `$element`
|
94
82
|
* @param {jQuery} $element - jQuery object to search within
|
95
83
|
* @return {jQuery} $focusable - all focusable elements within `$element`
|
96
84
|
*/
|
97
|
-
|
85
|
+
findFocusable($element) {
|
98
86
|
return $element.find('a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, embed, *[tabindex], *[contenteditable]').filter(function() {
|
99
87
|
if (!$(this).is(':visible') || $(this).attr('tabindex') < 0) { return false; } //only have visible elements and those that have a tabindex greater or equal 0
|
100
88
|
return true;
|
101
89
|
});
|
102
|
-
}
|
103
|
-
Foundation.Keyboard.findFocusable = findFocusable;
|
90
|
+
},
|
104
91
|
|
105
92
|
/**
|
106
93
|
* Returns the component name name
|
@@ -108,8 +95,21 @@
|
|
108
95
|
* @return String componentName
|
109
96
|
*/
|
110
97
|
|
111
|
-
|
98
|
+
register(componentName, cmds) {
|
112
99
|
commands[componentName] = cmds;
|
113
|
-
}
|
114
|
-
|
115
|
-
|
100
|
+
}
|
101
|
+
}
|
102
|
+
|
103
|
+
/*
|
104
|
+
* Constants for easier comparing.
|
105
|
+
* Can be used like Foundation.parseKey(event) === Foundation.keys.SPACE
|
106
|
+
*/
|
107
|
+
function getKeyCodes(kcs) {
|
108
|
+
var k = {};
|
109
|
+
for (var kc in kcs) k[kcs[kc]] = kcs[kc];
|
110
|
+
return k;
|
111
|
+
}
|
112
|
+
|
113
|
+
Foundation.Keyboard = Keyboard;
|
114
|
+
|
115
|
+
}(jQuery);
|
@@ -1,7 +1,9 @@
|
|
1
|
-
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
!function($) {
|
2
4
|
|
3
5
|
// Default set of media queries
|
4
|
-
|
6
|
+
const defaultQueries = {
|
5
7
|
'default' : 'only screen',
|
6
8
|
landscape : 'only screen and (orientation: landscape)',
|
7
9
|
portrait : 'only screen and (orientation: portrait)',
|
@@ -15,15 +17,40 @@ var defaultQueries = {
|
|
15
17
|
|
16
18
|
var MediaQuery = {
|
17
19
|
queries: [],
|
20
|
+
|
18
21
|
current: '',
|
19
22
|
|
23
|
+
/**
|
24
|
+
* Initializes the media query helper, by extracting the breakpoint list from the CSS and activating the breakpoint watcher.
|
25
|
+
* @function
|
26
|
+
* @private
|
27
|
+
*/
|
28
|
+
_init() {
|
29
|
+
var self = this;
|
30
|
+
var extractedStyles = $('.foundation-mq').css('font-family');
|
31
|
+
var namedQueries;
|
32
|
+
|
33
|
+
namedQueries = parseStyleToObject(extractedStyles);
|
34
|
+
|
35
|
+
for (var key in namedQueries) {
|
36
|
+
self.queries.push({
|
37
|
+
name: key,
|
38
|
+
value: `only screen and (min-width: ${namedQueries[key]})`
|
39
|
+
});
|
40
|
+
}
|
41
|
+
|
42
|
+
this.current = this._getCurrentSize();
|
43
|
+
|
44
|
+
this._watcher();
|
45
|
+
},
|
46
|
+
|
20
47
|
/**
|
21
48
|
* Checks if the screen is at least as wide as a breakpoint.
|
22
49
|
* @function
|
23
50
|
* @param {String} size - Name of the breakpoint to check.
|
24
51
|
* @returns {Boolean} `true` if the breakpoint matches, `false` if it's smaller.
|
25
52
|
*/
|
26
|
-
atLeast
|
53
|
+
atLeast(size) {
|
27
54
|
var query = this.get(size);
|
28
55
|
|
29
56
|
if (query) {
|
@@ -39,7 +66,7 @@ var MediaQuery = {
|
|
39
66
|
* @param {String} size - Name of the breakpoint to get.
|
40
67
|
* @returns {String|null} - The media query of the breakpoint, or `null` if the breakpoint doesn't exist.
|
41
68
|
*/
|
42
|
-
get
|
69
|
+
get(size) {
|
43
70
|
for (var i in this.queries) {
|
44
71
|
var query = this.queries[i];
|
45
72
|
if (size === query.name) return query.value;
|
@@ -48,40 +75,13 @@ var MediaQuery = {
|
|
48
75
|
return null;
|
49
76
|
},
|
50
77
|
|
51
|
-
/**
|
52
|
-
* Initializes the media query helper, by extracting the breakpoint list from the CSS and activating the breakpoint watcher.
|
53
|
-
* @function
|
54
|
-
* @private
|
55
|
-
*/
|
56
|
-
_init: function() {
|
57
|
-
var self = this;
|
58
|
-
var extractedStyles = $('.foundation-mq').css('font-family');
|
59
|
-
var namedQueries;
|
60
|
-
|
61
|
-
namedQueries = parseStyleToObject(extractedStyles);
|
62
|
-
|
63
|
-
for (var key in namedQueries) {
|
64
|
-
self.queries.push({
|
65
|
-
name: key,
|
66
|
-
value: 'only screen and (min-width: ' + namedQueries[key] + ')'
|
67
|
-
});
|
68
|
-
}
|
69
|
-
|
70
|
-
this.current = this._getCurrentSize();
|
71
|
-
|
72
|
-
this._watcher();
|
73
|
-
|
74
|
-
// Extend default queries
|
75
|
-
// namedQueries = $.extend(defaultQueries, namedQueries);
|
76
|
-
},
|
77
|
-
|
78
78
|
/**
|
79
79
|
* Gets the current breakpoint name by testing every breakpoint and returning the last one to match (the biggest one).
|
80
80
|
* @function
|
81
81
|
* @private
|
82
82
|
* @returns {String} Name of the current breakpoint.
|
83
83
|
*/
|
84
|
-
_getCurrentSize
|
84
|
+
_getCurrentSize() {
|
85
85
|
var matched;
|
86
86
|
|
87
87
|
for (var i in this.queries) {
|
@@ -92,7 +92,7 @@ var MediaQuery = {
|
|
92
92
|
}
|
93
93
|
}
|
94
94
|
|
95
|
-
if(typeof matched === 'object') {
|
95
|
+
if (typeof matched === 'object') {
|
96
96
|
return matched.name;
|
97
97
|
} else {
|
98
98
|
return matched;
|
@@ -104,18 +104,16 @@ var MediaQuery = {
|
|
104
104
|
* @function
|
105
105
|
* @private
|
106
106
|
*/
|
107
|
-
_watcher
|
108
|
-
|
107
|
+
_watcher() {
|
108
|
+
$(window).on('resize.zf.mediaquery', () => {
|
109
|
+
var newSize = this._getCurrentSize();
|
109
110
|
|
110
|
-
|
111
|
-
var newSize = _this._getCurrentSize();
|
112
|
-
|
113
|
-
if (newSize !== _this.current) {
|
111
|
+
if (newSize !== this.current) {
|
114
112
|
// Broadcast the media query change on the window
|
115
|
-
$(window).trigger('changed.zf.mediaquery', [newSize,
|
113
|
+
$(window).trigger('changed.zf.mediaquery', [newSize, this.current]);
|
116
114
|
|
117
115
|
// Change the current media query
|
118
|
-
|
116
|
+
this.current = newSize;
|
119
117
|
}
|
120
118
|
});
|
121
119
|
}
|
@@ -146,8 +144,8 @@ window.matchMedia || (window.matchMedia = function() {
|
|
146
144
|
info = ('getComputedStyle' in window) && window.getComputedStyle(style, null) || style.currentStyle;
|
147
145
|
|
148
146
|
styleMedia = {
|
149
|
-
matchMedium
|
150
|
-
var text =
|
147
|
+
matchMedium(media) {
|
148
|
+
var text = `@media ${media}{ #matchmediajs-test { width: 1px; } }`;
|
151
149
|
|
152
150
|
// 'style.styleSheet' is used by IE <= 8 and 'style.textContent' for all other browsers
|
153
151
|
if (style.styleSheet) {
|
@@ -159,7 +157,7 @@ window.matchMedia || (window.matchMedia = function() {
|
|
159
157
|
// Test if media query is true or false
|
160
158
|
return info.width === '1px';
|
161
159
|
}
|
162
|
-
}
|
160
|
+
}
|
163
161
|
}
|
164
162
|
|
165
163
|
return function(media) {
|
@@ -167,7 +165,7 @@ window.matchMedia || (window.matchMedia = function() {
|
|
167
165
|
matches: styleMedia.matchMedium(media || 'all'),
|
168
166
|
media: media || 'all'
|
169
167
|
};
|
170
|
-
}
|
168
|
+
}
|
171
169
|
}());
|
172
170
|
|
173
171
|
// Thank you: https://github.com/sindresorhus/query-string
|
@@ -207,4 +205,6 @@ function parseStyleToObject(str) {
|
|
207
205
|
return styleObject;
|
208
206
|
}
|
209
207
|
|
210
|
-
|
208
|
+
Foundation.MediaQuery = MediaQuery;
|
209
|
+
|
210
|
+
}(jQuery);
|