foundation6-jekyll-base 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +2 -0
- data/_includes/footer.html +1 -0
- data/_includes/head.html +16 -0
- data/_includes/header.html +1 -0
- data/_includes/javascripts.html +4 -0
- data/_layouts/default.html +18 -0
- data/_layouts/home.html +26 -0
- data/_layouts/page.html +15 -0
- data/_layouts/post.html +25 -0
- data/_sass/_vendor/normalize-scss/sass/_normalize.scss +3 -0
- data/_sass/_vendor/normalize-scss/sass/normalize/_import-now.scss +11 -0
- data/_sass/_vendor/normalize-scss/sass/normalize/_normalize-mixin.scss +676 -0
- data/_sass/_vendor/normalize-scss/sass/normalize/_variables.scss +36 -0
- data/_sass/_vendor/normalize-scss/sass/normalize/_vertical-rhythm.scss +61 -0
- data/_sass/_vendor/sassy-lists/stylesheets/functions/_purge.scss +38 -0
- data/_sass/_vendor/sassy-lists/stylesheets/functions/_remove.scss +31 -0
- data/_sass/_vendor/sassy-lists/stylesheets/functions/_replace.scss +46 -0
- data/_sass/_vendor/sassy-lists/stylesheets/functions/_to-list.scss +27 -0
- data/_sass/_vendor/sassy-lists/stylesheets/helpers/_missing-dependencies.scss +25 -0
- data/_sass/_vendor/sassy-lists/stylesheets/helpers/_true.scss +13 -0
- data/_sass/foundation/_global.scss +219 -0
- data/_sass/foundation/components/_accordion-menu.scss +36 -0
- data/_sass/foundation/components/_accordion.scss +150 -0
- data/_sass/foundation/components/_badge.scss +63 -0
- data/_sass/foundation/components/_breadcrumbs.scss +97 -0
- data/_sass/foundation/components/_button-group.scss +249 -0
- data/_sass/foundation/components/_button.scss +303 -0
- data/_sass/foundation/components/_callout.scss +106 -0
- data/_sass/foundation/components/_card.scss +121 -0
- data/_sass/foundation/components/_close-button.scss +102 -0
- data/_sass/foundation/components/_drilldown.scss +93 -0
- data/_sass/foundation/components/_dropdown-menu.scss +226 -0
- data/_sass/foundation/components/_dropdown.scss +72 -0
- data/_sass/foundation/components/_flex-video.scss +1 -0
- data/_sass/foundation/components/_flex.scss +28 -0
- data/_sass/foundation/components/_float.scss +27 -0
- data/_sass/foundation/components/_label.scss +64 -0
- data/_sass/foundation/components/_media-object.scss +114 -0
- data/_sass/foundation/components/_menu-icon.scss +9 -0
- data/_sass/foundation/components/_menu.scss +371 -0
- data/_sass/foundation/components/_off-canvas.scss +329 -0
- data/_sass/foundation/components/_orbit.scss +196 -0
- data/_sass/foundation/components/_pagination.scss +193 -0
- data/_sass/foundation/components/_progress-bar.scss +64 -0
- data/_sass/foundation/components/_responsive-embed.scss +67 -0
- data/_sass/foundation/components/_reveal.scss +178 -0
- data/_sass/foundation/components/_slider.scss +138 -0
- data/_sass/foundation/components/_sticky.scss +38 -0
- data/_sass/foundation/components/_switch.scss +247 -0
- data/_sass/foundation/components/_table.scss +329 -0
- data/_sass/foundation/components/_tabs.scss +196 -0
- data/_sass/foundation/components/_thumbnail.scss +67 -0
- data/_sass/foundation/components/_title-bar.scss +84 -0
- data/_sass/foundation/components/_tooltip.scss +107 -0
- data/_sass/foundation/components/_top-bar.scss +173 -0
- data/_sass/foundation/components/_visibility.scss +132 -0
- data/_sass/foundation/forms/_checkbox.scss +41 -0
- data/_sass/foundation/forms/_error.scss +88 -0
- data/_sass/foundation/forms/_fieldset.scss +54 -0
- data/_sass/foundation/forms/_forms.scss +34 -0
- data/_sass/foundation/forms/_help-text.scss +30 -0
- data/_sass/foundation/forms/_input-group.scss +135 -0
- data/_sass/foundation/forms/_label.scss +50 -0
- data/_sass/foundation/forms/_meter.scss +110 -0
- data/_sass/foundation/forms/_progress.scss +94 -0
- data/_sass/foundation/forms/_range.scss +149 -0
- data/_sass/foundation/forms/_select.scss +85 -0
- data/_sass/foundation/forms/_text.scss +170 -0
- data/_sass/foundation/foundation.scss +118 -0
- data/_sass/foundation/grid/_classes.scss +176 -0
- data/_sass/foundation/grid/_column.scss +112 -0
- data/_sass/foundation/grid/_flex-grid.scss +307 -0
- data/_sass/foundation/grid/_grid.scss +44 -0
- data/_sass/foundation/grid/_gutter.scss +82 -0
- data/_sass/foundation/grid/_layout.scss +76 -0
- data/_sass/foundation/grid/_position.scss +76 -0
- data/_sass/foundation/grid/_row.scss +99 -0
- data/_sass/foundation/grid/_size.scss +24 -0
- data/_sass/foundation/settings/_settings.scss +621 -0
- data/_sass/foundation/typography/_alignment.scss +22 -0
- data/_sass/foundation/typography/_base.scss +509 -0
- data/_sass/foundation/typography/_helpers.scss +78 -0
- data/_sass/foundation/typography/_print.scss +81 -0
- data/_sass/foundation/typography/_typography.scss +26 -0
- data/_sass/foundation/util/_breakpoint.scss +281 -0
- data/_sass/foundation/util/_color.scss +126 -0
- data/_sass/foundation/util/_direction.scss +31 -0
- data/_sass/foundation/util/_flex.scss +85 -0
- data/_sass/foundation/util/_math.scss +72 -0
- data/_sass/foundation/util/_mixins.scss +276 -0
- data/_sass/foundation/util/_selector.scss +41 -0
- data/_sass/foundation/util/_unit.scss +152 -0
- data/_sass/foundation/util/_util.scss +13 -0
- data/_sass/foundation/util/_value.scss +140 -0
- data/assets/js/app.js +1 -0
- data/assets/js/vendor/foundation/foundation.d.ts +496 -0
- data/assets/js/vendor/foundation/foundation.js +10207 -0
- data/assets/js/vendor/foundation/foundation.min.js +4 -0
- data/assets/js/vendor/foundation/plugins/foundation.abide.js +637 -0
- data/assets/js/vendor/foundation/plugins/foundation.abide.min.js +1 -0
- data/assets/js/vendor/foundation/plugins/foundation.accordion.js +252 -0
- data/assets/js/vendor/foundation/plugins/foundation.accordion.min.js +1 -0
- data/assets/js/vendor/foundation/plugins/foundation.accordionMenu.js +318 -0
- data/assets/js/vendor/foundation/plugins/foundation.accordionMenu.min.js +1 -0
- data/assets/js/vendor/foundation/plugins/foundation.core.js +386 -0
- data/assets/js/vendor/foundation/plugins/foundation.core.min.js +1 -0
- data/assets/js/vendor/foundation/plugins/foundation.drilldown.js +565 -0
- data/assets/js/vendor/foundation/plugins/foundation.drilldown.min.js +1 -0
- data/assets/js/vendor/foundation/plugins/foundation.dropdown.js +465 -0
- data/assets/js/vendor/foundation/plugins/foundation.dropdown.min.js +1 -0
- data/assets/js/vendor/foundation/plugins/foundation.dropdownMenu.js +486 -0
- data/assets/js/vendor/foundation/plugins/foundation.dropdownMenu.min.js +1 -0
- data/assets/js/vendor/foundation/plugins/foundation.equalizer.js +374 -0
- data/assets/js/vendor/foundation/plugins/foundation.equalizer.min.js +1 -0
- data/assets/js/vendor/foundation/plugins/foundation.interchange.js +233 -0
- data/assets/js/vendor/foundation/plugins/foundation.interchange.min.js +1 -0
- data/assets/js/vendor/foundation/plugins/foundation.magellan.js +285 -0
- data/assets/js/vendor/foundation/plugins/foundation.magellan.min.js +1 -0
- data/assets/js/vendor/foundation/plugins/foundation.offcanvas.js +474 -0
- data/assets/js/vendor/foundation/plugins/foundation.offcanvas.min.js +1 -0
- data/assets/js/vendor/foundation/plugins/foundation.orbit.js +566 -0
- data/assets/js/vendor/foundation/plugins/foundation.orbit.min.js +1 -0
- data/assets/js/vendor/foundation/plugins/foundation.responsiveMenu.js +169 -0
- data/assets/js/vendor/foundation/plugins/foundation.responsiveMenu.min.js +1 -0
- data/assets/js/vendor/foundation/plugins/foundation.responsiveToggle.js +177 -0
- data/assets/js/vendor/foundation/plugins/foundation.responsiveToggle.min.js +1 -0
- data/assets/js/vendor/foundation/plugins/foundation.reveal.js +633 -0
- data/assets/js/vendor/foundation/plugins/foundation.reveal.min.js +1 -0
- data/assets/js/vendor/foundation/plugins/foundation.slider.js +762 -0
- data/assets/js/vendor/foundation/plugins/foundation.slider.min.js +1 -0
- data/assets/js/vendor/foundation/plugins/foundation.sticky.js +518 -0
- data/assets/js/vendor/foundation/plugins/foundation.sticky.min.js +1 -0
- data/assets/js/vendor/foundation/plugins/foundation.tabs.js +512 -0
- data/assets/js/vendor/foundation/plugins/foundation.tabs.min.js +1 -0
- data/assets/js/vendor/foundation/plugins/foundation.toggler.js +169 -0
- data/assets/js/vendor/foundation/plugins/foundation.toggler.min.js +1 -0
- data/assets/js/vendor/foundation/plugins/foundation.tooltip.js +492 -0
- data/assets/js/vendor/foundation/plugins/foundation.tooltip.min.js +1 -0
- data/assets/js/vendor/foundation/plugins/foundation.util.box.js +196 -0
- data/assets/js/vendor/foundation/plugins/foundation.util.box.min.js +1 -0
- data/assets/js/vendor/foundation/plugins/foundation.util.keyboard.js +163 -0
- data/assets/js/vendor/foundation/plugins/foundation.util.keyboard.min.js +1 -0
- data/assets/js/vendor/foundation/plugins/foundation.util.mediaQuery.js +233 -0
- data/assets/js/vendor/foundation/plugins/foundation.util.mediaQuery.min.js +1 -0
- data/assets/js/vendor/foundation/plugins/foundation.util.motion.js +103 -0
- data/assets/js/vendor/foundation/plugins/foundation.util.motion.min.js +1 -0
- data/assets/js/vendor/foundation/plugins/foundation.util.nest.js +74 -0
- data/assets/js/vendor/foundation/plugins/foundation.util.nest.min.js +1 -0
- data/assets/js/vendor/foundation/plugins/foundation.util.timerAndImageLoader.js +90 -0
- data/assets/js/vendor/foundation/plugins/foundation.util.timerAndImageLoader.min.js +1 -0
- data/assets/js/vendor/foundation/plugins/foundation.util.touch.js +352 -0
- data/assets/js/vendor/foundation/plugins/foundation.util.touch.min.js +1 -0
- data/assets/js/vendor/foundation/plugins/foundation.util.triggers.js +261 -0
- data/assets/js/vendor/foundation/plugins/foundation.util.triggers.min.js +1 -0
- data/assets/js/vendor/foundation/plugins/foundation.zf.responsiveAccordionTabs.js +262 -0
- data/assets/js/vendor/foundation/plugins/foundation.zf.responsiveAccordionTabs.min.js +1 -0
- data/assets/main.scss +6 -0
- metadata +232 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function _classCallCheck(t,i){if(!(t instanceof i))throw new TypeError("Cannot call a class as a function")}var _createClass=function(){function t(t,i){for(var e=0;e<i.length;e++){var s=i[e];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,s.key,s)}}return function(i,e,s){return e&&t(i.prototype,e),s&&t(i,s),i}}();!function(t){var i=function(){function i(e,s){_classCallCheck(this,i),this.$element=e,this.options=t.extend({},i.defaults,this.$element.data(),s),this.isActive=!1,this.isClick=!1,this._init(),Foundation.registerPlugin(this,"Tooltip")}return _createClass(i,[{key:"_init",value:function(){var i=this.$element.attr("aria-describedby")||Foundation.GetYoDigits(6,"tooltip");this.options.positionClass=this.options.positionClass||this._getPositionClass(this.$element),this.options.tipText=this.options.tipText||this.$element.attr("title"),this.template=this.options.template?t(this.options.template):this._buildTemplate(i),this.options.allowHtml?this.template.appendTo(document.body).html(this.options.tipText).hide():this.template.appendTo(document.body).text(this.options.tipText).hide(),this.$element.attr({title:"","aria-describedby":i,"data-yeti-box":i,"data-toggle":i,"data-resize":i}).addClass(this.options.triggerClass),this.usedPositions=[],this.counter=4,this.classChanged=!1,this._events()}},{key:"_getPositionClass",value:function(t){if(!t)return"";var i=t[0].className.match(/\b(top|left|right)\b/g);return i=i?i[0]:""}},{key:"_buildTemplate",value:function(i){var e=(this.options.tooltipClass+" "+this.options.positionClass+" "+this.options.templateClasses).trim(),s=t("<div></div>").addClass(e).attr({role:"tooltip","aria-hidden":!0,"data-is-active":!1,"data-is-focus":!1,id:i});return s}},{key:"_reposition",value:function(t){this.usedPositions.push(t?t:"bottom"),!t&&this.usedPositions.indexOf("top")<0?this.template.addClass("top"):"top"===t&&this.usedPositions.indexOf("bottom")<0?this.template.removeClass(t):"left"===t&&this.usedPositions.indexOf("right")<0?this.template.removeClass(t).addClass("right"):"right"===t&&this.usedPositions.indexOf("left")<0?this.template.removeClass(t).addClass("left"):!t&&this.usedPositions.indexOf("top")>-1&&this.usedPositions.indexOf("left")<0?this.template.addClass("left"):"top"===t&&this.usedPositions.indexOf("bottom")>-1&&this.usedPositions.indexOf("left")<0?this.template.removeClass(t).addClass("left"):"left"===t&&this.usedPositions.indexOf("right")>-1&&this.usedPositions.indexOf("bottom")<0?this.template.removeClass(t):"right"===t&&this.usedPositions.indexOf("left")>-1&&this.usedPositions.indexOf("bottom")<0?this.template.removeClass(t):this.template.removeClass(t),this.classChanged=!0,this.counter--}},{key:"_setPosition",value:function(){var t=this._getPositionClass(this.template),i=Foundation.Box.GetDimensions(this.template),e=Foundation.Box.GetDimensions(this.$element),s="left"===t?"left":"right"===t?"left":"top",o="top"===s?"height":"width";"height"===o?this.options.vOffset:this.options.hOffset;if(i.width>=i.windowDims.width||!this.counter&&!Foundation.Box.ImNotTouchingYou(this.template))return this.template.offset(Foundation.Box.GetOffsets(this.template,this.$element,"center bottom",this.options.vOffset,this.options.hOffset,!0)).css({width:e.windowDims.width-2*this.options.hOffset,height:"auto"}),!1;for(this.template.offset(Foundation.Box.GetOffsets(this.template,this.$element,"center "+(t||"bottom"),this.options.vOffset,this.options.hOffset));!Foundation.Box.ImNotTouchingYou(this.template)&&this.counter;)this._reposition(t),this._setPosition()}},{key:"show",value:function(){if("all"!==this.options.showOn&&!Foundation.MediaQuery.is(this.options.showOn))return!1;var t=this;this.template.css("visibility","hidden").show(),this._setPosition(),this.$element.trigger("closeme.zf.tooltip",this.template.attr("id")),this.template.attr({"data-is-active":!0,"aria-hidden":!1}),t.isActive=!0,this.template.stop().hide().css("visibility","").fadeIn(this.options.fadeInDuration,function(){}),this.$element.trigger("show.zf.tooltip")}},{key:"hide",value:function(){var t=this;this.template.stop().attr({"aria-hidden":!0,"data-is-active":!1}).fadeOut(this.options.fadeOutDuration,function(){t.isActive=!1,t.isClick=!1,t.classChanged&&(t.template.removeClass(t._getPositionClass(t.template)).addClass(t.options.positionClass),t.usedPositions=[],t.counter=4,t.classChanged=!1)}),this.$element.trigger("hide.zf.tooltip")}},{key:"_events",value:function(){var t=this,i=(this.template,!1);this.options.disableHover||this.$element.on("mouseenter.zf.tooltip",function(i){t.isActive||(t.timeout=setTimeout(function(){t.show()},t.options.hoverDelay))}).on("mouseleave.zf.tooltip",function(e){clearTimeout(t.timeout),(!i||t.isClick&&!t.options.clickOpen)&&t.hide()}),this.options.clickOpen?this.$element.on("mousedown.zf.tooltip",function(i){i.stopImmediatePropagation(),t.isClick||(t.isClick=!0,!t.options.disableHover&&t.$element.attr("tabindex")||t.isActive||t.show())}):this.$element.on("mousedown.zf.tooltip",function(i){i.stopImmediatePropagation(),t.isClick=!0}),this.options.disableForTouch||this.$element.on("tap.zf.tooltip touchend.zf.tooltip",function(i){t.isActive?t.hide():t.show()}),this.$element.on({"close.zf.trigger":this.hide.bind(this)}),this.$element.on("focus.zf.tooltip",function(e){return i=!0,t.isClick?(t.options.clickOpen||(i=!1),!1):void t.show()}).on("focusout.zf.tooltip",function(e){i=!1,t.isClick=!1,t.hide()}).on("resizeme.zf.trigger",function(){t.isActive&&t._setPosition()})}},{key:"toggle",value:function(){this.isActive?this.hide():this.show()}},{key:"destroy",value:function(){this.$element.attr("title",this.template.text()).off(".zf.trigger .zf.tooltip").removeClass("has-tip top right left").removeAttr("aria-describedby aria-haspopup data-disable-hover data-resize data-toggle data-tooltip data-yeti-box"),this.template.remove(),Foundation.unregisterPlugin(this)}}]),i}();i.defaults={disableForTouch:!1,hoverDelay:200,fadeInDuration:150,fadeOutDuration:150,disableHover:!1,templateClasses:"",tooltipClass:"tooltip",triggerClass:"has-tip",showOn:"small",template:"",tipText:"",touchCloseText:"Tap to close.",clickOpen:!0,positionClass:"",vOffset:10,hOffset:12,allowHtml:!1},Foundation.plugin(i,"Tooltip")}(jQuery);
|
|
@@ -0,0 +1,196 @@
|
|
|
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,
|
|
24
|
+
bottom,
|
|
25
|
+
left,
|
|
26
|
+
right;
|
|
27
|
+
|
|
28
|
+
if (parent) {
|
|
29
|
+
var parDims = GetDimensions(parent);
|
|
30
|
+
|
|
31
|
+
bottom = eleDims.offset.top + eleDims.height <= parDims.height + parDims.offset.top;
|
|
32
|
+
top = eleDims.offset.top >= parDims.offset.top;
|
|
33
|
+
left = eleDims.offset.left >= parDims.offset.left;
|
|
34
|
+
right = eleDims.offset.left + eleDims.width <= parDims.width + parDims.offset.left;
|
|
35
|
+
} else {
|
|
36
|
+
bottom = eleDims.offset.top + eleDims.height <= eleDims.windowDims.height + eleDims.windowDims.offset.top;
|
|
37
|
+
top = eleDims.offset.top >= eleDims.windowDims.offset.top;
|
|
38
|
+
left = eleDims.offset.left >= eleDims.windowDims.offset.left;
|
|
39
|
+
right = eleDims.offset.left + eleDims.width <= eleDims.windowDims.width;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
var allDirs = [bottom, top, left, right];
|
|
43
|
+
|
|
44
|
+
if (lrOnly) {
|
|
45
|
+
return left === right === true;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (tbOnly) {
|
|
49
|
+
return top === bottom === true;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return allDirs.indexOf(false) === -1;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Uses native methods to return an object of dimension values.
|
|
57
|
+
* @function
|
|
58
|
+
* @param {jQuery || HTML} element - jQuery object or DOM element for which to get the dimensions. Can be any element other that document or window.
|
|
59
|
+
* @returns {Object} - nested object of integer pixel values
|
|
60
|
+
* TODO - if element is window, return only those values.
|
|
61
|
+
*/
|
|
62
|
+
function GetDimensions(elem, test) {
|
|
63
|
+
elem = elem.length ? elem[0] : elem;
|
|
64
|
+
|
|
65
|
+
if (elem === window || elem === document) {
|
|
66
|
+
throw new Error("I'm sorry, Dave. I'm afraid I can't do that.");
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
var rect = elem.getBoundingClientRect(),
|
|
70
|
+
parRect = elem.parentNode.getBoundingClientRect(),
|
|
71
|
+
winRect = document.body.getBoundingClientRect(),
|
|
72
|
+
winY = window.pageYOffset,
|
|
73
|
+
winX = window.pageXOffset;
|
|
74
|
+
|
|
75
|
+
return {
|
|
76
|
+
width: rect.width,
|
|
77
|
+
height: rect.height,
|
|
78
|
+
offset: {
|
|
79
|
+
top: rect.top + winY,
|
|
80
|
+
left: rect.left + winX
|
|
81
|
+
},
|
|
82
|
+
parentDims: {
|
|
83
|
+
width: parRect.width,
|
|
84
|
+
height: parRect.height,
|
|
85
|
+
offset: {
|
|
86
|
+
top: parRect.top + winY,
|
|
87
|
+
left: parRect.left + winX
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
windowDims: {
|
|
91
|
+
width: winRect.width,
|
|
92
|
+
height: winRect.height,
|
|
93
|
+
offset: {
|
|
94
|
+
top: winY,
|
|
95
|
+
left: winX
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Returns an object of top and left integer pixel values for dynamically rendered elements,
|
|
103
|
+
* such as: Tooltip, Reveal, and Dropdown
|
|
104
|
+
* @function
|
|
105
|
+
* @param {jQuery} element - jQuery object for the element being positioned.
|
|
106
|
+
* @param {jQuery} anchor - jQuery object for the element's anchor point.
|
|
107
|
+
* @param {String} position - a string relating to the desired position of the element, relative to it's anchor
|
|
108
|
+
* @param {Number} vOffset - integer pixel value of desired vertical separation between anchor and element.
|
|
109
|
+
* @param {Number} hOffset - integer pixel value of desired horizontal separation between anchor and element.
|
|
110
|
+
* @param {Boolean} isOverflow - if a collision event is detected, sets to true to default the element to full width - any desired offset.
|
|
111
|
+
* TODO alter/rewrite to work with `em` values as well/instead of pixels
|
|
112
|
+
*/
|
|
113
|
+
function GetOffsets(element, anchor, position, vOffset, hOffset, isOverflow) {
|
|
114
|
+
var $eleDims = GetDimensions(element),
|
|
115
|
+
$anchorDims = anchor ? GetDimensions(anchor) : null;
|
|
116
|
+
|
|
117
|
+
switch (position) {
|
|
118
|
+
case 'top':
|
|
119
|
+
return {
|
|
120
|
+
left: Foundation.rtl() ? $anchorDims.offset.left - $eleDims.width + $anchorDims.width : $anchorDims.offset.left,
|
|
121
|
+
top: $anchorDims.offset.top - ($eleDims.height + vOffset)
|
|
122
|
+
};
|
|
123
|
+
break;
|
|
124
|
+
case 'left':
|
|
125
|
+
return {
|
|
126
|
+
left: $anchorDims.offset.left - ($eleDims.width + hOffset),
|
|
127
|
+
top: $anchorDims.offset.top
|
|
128
|
+
};
|
|
129
|
+
break;
|
|
130
|
+
case 'right':
|
|
131
|
+
return {
|
|
132
|
+
left: $anchorDims.offset.left + $anchorDims.width + hOffset,
|
|
133
|
+
top: $anchorDims.offset.top
|
|
134
|
+
};
|
|
135
|
+
break;
|
|
136
|
+
case 'center top':
|
|
137
|
+
return {
|
|
138
|
+
left: $anchorDims.offset.left + $anchorDims.width / 2 - $eleDims.width / 2,
|
|
139
|
+
top: $anchorDims.offset.top - ($eleDims.height + vOffset)
|
|
140
|
+
};
|
|
141
|
+
break;
|
|
142
|
+
case 'center bottom':
|
|
143
|
+
return {
|
|
144
|
+
left: isOverflow ? hOffset : $anchorDims.offset.left + $anchorDims.width / 2 - $eleDims.width / 2,
|
|
145
|
+
top: $anchorDims.offset.top + $anchorDims.height + vOffset
|
|
146
|
+
};
|
|
147
|
+
break;
|
|
148
|
+
case 'center left':
|
|
149
|
+
return {
|
|
150
|
+
left: $anchorDims.offset.left - ($eleDims.width + hOffset),
|
|
151
|
+
top: $anchorDims.offset.top + $anchorDims.height / 2 - $eleDims.height / 2
|
|
152
|
+
};
|
|
153
|
+
break;
|
|
154
|
+
case 'center right':
|
|
155
|
+
return {
|
|
156
|
+
left: $anchorDims.offset.left + $anchorDims.width + hOffset + 1,
|
|
157
|
+
top: $anchorDims.offset.top + $anchorDims.height / 2 - $eleDims.height / 2
|
|
158
|
+
};
|
|
159
|
+
break;
|
|
160
|
+
case 'center':
|
|
161
|
+
return {
|
|
162
|
+
left: $eleDims.windowDims.offset.left + $eleDims.windowDims.width / 2 - $eleDims.width / 2,
|
|
163
|
+
top: $eleDims.windowDims.offset.top + $eleDims.windowDims.height / 2 - $eleDims.height / 2
|
|
164
|
+
};
|
|
165
|
+
break;
|
|
166
|
+
case 'reveal':
|
|
167
|
+
return {
|
|
168
|
+
left: ($eleDims.windowDims.width - $eleDims.width) / 2,
|
|
169
|
+
top: $eleDims.windowDims.offset.top + vOffset
|
|
170
|
+
};
|
|
171
|
+
case 'reveal full':
|
|
172
|
+
return {
|
|
173
|
+
left: $eleDims.windowDims.offset.left,
|
|
174
|
+
top: $eleDims.windowDims.offset.top
|
|
175
|
+
};
|
|
176
|
+
break;
|
|
177
|
+
case 'left bottom':
|
|
178
|
+
return {
|
|
179
|
+
left: $anchorDims.offset.left,
|
|
180
|
+
top: $anchorDims.offset.top + $anchorDims.height + vOffset
|
|
181
|
+
};
|
|
182
|
+
break;
|
|
183
|
+
case 'right bottom':
|
|
184
|
+
return {
|
|
185
|
+
left: $anchorDims.offset.left + $anchorDims.width + hOffset - $eleDims.width,
|
|
186
|
+
top: $anchorDims.offset.top + $anchorDims.height + vOffset
|
|
187
|
+
};
|
|
188
|
+
break;
|
|
189
|
+
default:
|
|
190
|
+
return {
|
|
191
|
+
left: Foundation.rtl() ? $anchorDims.offset.left - $eleDims.width + $anchorDims.width : $anchorDims.offset.left + hOffset,
|
|
192
|
+
top: $anchorDims.offset.top + $anchorDims.height + vOffset
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}(jQuery);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";!function(t){function e(t,e,o,i){var s,h,n,w,d=f(t);if(e){var r=f(e);h=d.offset.top+d.height<=r.height+r.offset.top,s=d.offset.top>=r.offset.top,n=d.offset.left>=r.offset.left,w=d.offset.left+d.width<=r.width+r.offset.left}else h=d.offset.top+d.height<=d.windowDims.height+d.windowDims.offset.top,s=d.offset.top>=d.windowDims.offset.top,n=d.offset.left>=d.windowDims.offset.left,w=d.offset.left+d.width<=d.windowDims.width;var l=[h,s,n,w];return o?n===w==!0:i?s===h==!0:l.indexOf(!1)===-1}function f(t,e){if(t=t.length?t[0]:t,t===window||t===document)throw new Error("I'm sorry, Dave. I'm afraid I can't do that.");var f=t.getBoundingClientRect(),o=t.parentNode.getBoundingClientRect(),i=document.body.getBoundingClientRect(),s=window.pageYOffset,h=window.pageXOffset;return{width:f.width,height:f.height,offset:{top:f.top+s,left:f.left+h},parentDims:{width:o.width,height:o.height,offset:{top:o.top+s,left:o.left+h}},windowDims:{width:i.width,height:i.height,offset:{top:s,left:h}}}}function o(t,e,o,i,s,h){var n=f(t),w=e?f(e):null;switch(o){case"top":return{left:Foundation.rtl()?w.offset.left-n.width+w.width:w.offset.left,top:w.offset.top-(n.height+i)};case"left":return{left:w.offset.left-(n.width+s),top:w.offset.top};case"right":return{left:w.offset.left+w.width+s,top:w.offset.top};case"center top":return{left:w.offset.left+w.width/2-n.width/2,top:w.offset.top-(n.height+i)};case"center bottom":return{left:h?s:w.offset.left+w.width/2-n.width/2,top:w.offset.top+w.height+i};case"center left":return{left:w.offset.left-(n.width+s),top:w.offset.top+w.height/2-n.height/2};case"center right":return{left:w.offset.left+w.width+s+1,top:w.offset.top+w.height/2-n.height/2};case"center":return{left:n.windowDims.offset.left+n.windowDims.width/2-n.width/2,top:n.windowDims.offset.top+n.windowDims.height/2-n.height/2};case"reveal":return{left:(n.windowDims.width-n.width)/2,top:n.windowDims.offset.top+i};case"reveal full":return{left:n.windowDims.offset.left,top:n.windowDims.offset.top};case"left bottom":return{left:w.offset.left,top:w.offset.top+w.height+i};case"right bottom":return{left:w.offset.left+w.width+s-n.width,top:w.offset.top+w.height+i};default:return{left:Foundation.rtl()?w.offset.left-n.width+w.width:w.offset.left+s,top:w.offset.top+w.height+i}}}Foundation.Box={ImNotTouchingYou:e,GetDimensions:f,GetOffsets:o}}(jQuery);
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/*******************************************
|
|
2
|
+
* *
|
|
3
|
+
* This util was created by Marius Olbertz *
|
|
4
|
+
* Please thank Marius on GitHub /owlbertz *
|
|
5
|
+
* or the web http://www.mariusolbertz.de/ *
|
|
6
|
+
* *
|
|
7
|
+
******************************************/
|
|
8
|
+
|
|
9
|
+
'use strict';
|
|
10
|
+
|
|
11
|
+
!function ($) {
|
|
12
|
+
|
|
13
|
+
var 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),
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Parses the (keyboard) event and returns a String that represents its key
|
|
31
|
+
* Can be used like Foundation.parseKey(event) === Foundation.keys.SPACE
|
|
32
|
+
* @param {Event} event - the event generated by the event handler
|
|
33
|
+
* @return String key - String that represents the key pressed
|
|
34
|
+
*/
|
|
35
|
+
parseKey: function (event) {
|
|
36
|
+
var key = keyCodes[event.which || event.keyCode] || String.fromCharCode(event.which).toUpperCase();
|
|
37
|
+
|
|
38
|
+
// Remove un-printable characters, e.g. for `fromCharCode` calls for CTRL only events
|
|
39
|
+
key = key.replace(/\W+/, '');
|
|
40
|
+
|
|
41
|
+
if (event.shiftKey) key = 'SHIFT_' + key;
|
|
42
|
+
if (event.ctrlKey) key = 'CTRL_' + key;
|
|
43
|
+
if (event.altKey) key = 'ALT_' + key;
|
|
44
|
+
|
|
45
|
+
// Remove trailing underscore, in case only modifiers were used (e.g. only `CTRL_ALT`)
|
|
46
|
+
key = key.replace(/_$/, '');
|
|
47
|
+
|
|
48
|
+
return key;
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Handles the given (keyboard) event
|
|
54
|
+
* @param {Event} event - the event generated by the event handler
|
|
55
|
+
* @param {String} component - Foundation component's name, e.g. Slider or Reveal
|
|
56
|
+
* @param {Objects} functions - collection of functions that are to be executed
|
|
57
|
+
*/
|
|
58
|
+
handleKey: function (event, component, functions) {
|
|
59
|
+
var commandList = commands[component],
|
|
60
|
+
keyCode = this.parseKey(event),
|
|
61
|
+
cmds,
|
|
62
|
+
command,
|
|
63
|
+
fn;
|
|
64
|
+
|
|
65
|
+
if (!commandList) return console.warn('Component not defined!');
|
|
66
|
+
|
|
67
|
+
if (typeof commandList.ltr === 'undefined') {
|
|
68
|
+
// this component does not differentiate between ltr and rtl
|
|
69
|
+
cmds = commandList; // use plain list
|
|
70
|
+
} else {
|
|
71
|
+
// merge ltr and rtl: if document is rtl, rtl overwrites ltr and vice versa
|
|
72
|
+
if (Foundation.rtl()) cmds = $.extend({}, commandList.ltr, commandList.rtl);else cmds = $.extend({}, commandList.rtl, commandList.ltr);
|
|
73
|
+
}
|
|
74
|
+
command = cmds[keyCode];
|
|
75
|
+
|
|
76
|
+
fn = functions[command];
|
|
77
|
+
if (fn && typeof fn === 'function') {
|
|
78
|
+
// execute function if exists
|
|
79
|
+
var returnValue = fn.apply();
|
|
80
|
+
if (functions.handled || typeof functions.handled === 'function') {
|
|
81
|
+
// execute function when event was handled
|
|
82
|
+
functions.handled(returnValue);
|
|
83
|
+
}
|
|
84
|
+
} else {
|
|
85
|
+
if (functions.unhandled || typeof functions.unhandled === 'function') {
|
|
86
|
+
// execute function when event was not handled
|
|
87
|
+
functions.unhandled();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Finds all focusable elements within the given `$element`
|
|
95
|
+
* @param {jQuery} $element - jQuery object to search within
|
|
96
|
+
* @return {jQuery} $focusable - all focusable elements within `$element`
|
|
97
|
+
*/
|
|
98
|
+
findFocusable: function ($element) {
|
|
99
|
+
if (!$element) {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
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 () {
|
|
103
|
+
if (!$(this).is(':visible') || $(this).attr('tabindex') < 0) {
|
|
104
|
+
return false;
|
|
105
|
+
} //only have visible elements and those that have a tabindex greater or equal 0
|
|
106
|
+
return true;
|
|
107
|
+
});
|
|
108
|
+
},
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Returns the component name name
|
|
113
|
+
* @param {Object} component - Foundation component, e.g. Slider or Reveal
|
|
114
|
+
* @return String componentName
|
|
115
|
+
*/
|
|
116
|
+
|
|
117
|
+
register: function (componentName, cmds) {
|
|
118
|
+
commands[componentName] = cmds;
|
|
119
|
+
},
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Traps the focus in the given element.
|
|
124
|
+
* @param {jQuery} $element jQuery object to trap the foucs into.
|
|
125
|
+
*/
|
|
126
|
+
trapFocus: function ($element) {
|
|
127
|
+
var $focusable = Foundation.Keyboard.findFocusable($element),
|
|
128
|
+
$firstFocusable = $focusable.eq(0),
|
|
129
|
+
$lastFocusable = $focusable.eq(-1);
|
|
130
|
+
|
|
131
|
+
$element.on('keydown.zf.trapfocus', function (event) {
|
|
132
|
+
if (event.target === $lastFocusable[0] && Foundation.Keyboard.parseKey(event) === 'TAB') {
|
|
133
|
+
event.preventDefault();
|
|
134
|
+
$firstFocusable.focus();
|
|
135
|
+
} else if (event.target === $firstFocusable[0] && Foundation.Keyboard.parseKey(event) === 'SHIFT_TAB') {
|
|
136
|
+
event.preventDefault();
|
|
137
|
+
$lastFocusable.focus();
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
},
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Releases the trapped focus from the given element.
|
|
144
|
+
* @param {jQuery} $element jQuery object to release the focus for.
|
|
145
|
+
*/
|
|
146
|
+
releaseFocus: function ($element) {
|
|
147
|
+
$element.off('keydown.zf.trapfocus');
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
/*
|
|
152
|
+
* Constants for easier comparing.
|
|
153
|
+
* Can be used like Foundation.parseKey(event) === Foundation.keys.SPACE
|
|
154
|
+
*/
|
|
155
|
+
function getKeyCodes(kcs) {
|
|
156
|
+
var k = {};
|
|
157
|
+
for (var kc in kcs) {
|
|
158
|
+
k[kcs[kc]] = kcs[kc];
|
|
159
|
+
}return k;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
Foundation.Keyboard = Keyboard;
|
|
163
|
+
}(jQuery);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";!function(e){function n(e){var n={};for(var t in e)n[e[t]]=e[t];return n}var t={9:"TAB",13:"ENTER",27:"ESCAPE",32:"SPACE",37:"ARROW_LEFT",38:"ARROW_UP",39:"ARROW_RIGHT",40:"ARROW_DOWN"},o={},r={keys:n(t),parseKey:function(e){var n=t[e.which||e.keyCode]||String.fromCharCode(e.which).toUpperCase();return n=n.replace(/\W+/,""),e.shiftKey&&(n="SHIFT_"+n),e.ctrlKey&&(n="CTRL_"+n),e.altKey&&(n="ALT_"+n),n=n.replace(/_$/,"")},handleKey:function(n,t,r){var a,i,d,f=o[t],u=this.parseKey(n);if(!f)return console.warn("Component not defined!");if(a="undefined"==typeof f.ltr?f:Foundation.rtl()?e.extend({},f.ltr,f.rtl):e.extend({},f.rtl,f.ltr),i=a[u],d=r[i],d&&"function"==typeof d){var l=d.apply();(r.handled||"function"==typeof r.handled)&&r.handled(l)}else(r.unhandled||"function"==typeof r.unhandled)&&r.unhandled()},findFocusable:function(n){return!!n&&n.find("a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, embed, *[tabindex], *[contenteditable]").filter(function(){return!(!e(this).is(":visible")||e(this).attr("tabindex")<0)})},register:function(e,n){o[e]=n},trapFocus:function(e){var n=Foundation.Keyboard.findFocusable(e),t=n.eq(0),o=n.eq(-1);e.on("keydown.zf.trapfocus",function(e){e.target===o[0]&&"TAB"===Foundation.Keyboard.parseKey(e)?(e.preventDefault(),t.focus()):e.target===t[0]&&"SHIFT_TAB"===Foundation.Keyboard.parseKey(e)&&(e.preventDefault(),o.focus())})},releaseFocus:function(e){e.off("keydown.zf.trapfocus")}};Foundation.Keyboard=r}(jQuery);
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
!function ($) {
|
|
4
|
+
|
|
5
|
+
// Default set of media queries
|
|
6
|
+
var defaultQueries = {
|
|
7
|
+
'default': 'only screen',
|
|
8
|
+
landscape: 'only screen and (orientation: landscape)',
|
|
9
|
+
portrait: 'only screen and (orientation: portrait)',
|
|
10
|
+
retina: 'only screen and (-webkit-min-device-pixel-ratio: 2),' + 'only screen and (min--moz-device-pixel-ratio: 2),' + 'only screen and (-o-min-device-pixel-ratio: 2/1),' + 'only screen and (min-device-pixel-ratio: 2),' + 'only screen and (min-resolution: 192dpi),' + 'only screen and (min-resolution: 2dppx)'
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
var MediaQuery = {
|
|
14
|
+
queries: [],
|
|
15
|
+
|
|
16
|
+
current: '',
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Initializes the media query helper, by extracting the breakpoint list from the CSS and activating the breakpoint watcher.
|
|
20
|
+
* @function
|
|
21
|
+
* @private
|
|
22
|
+
*/
|
|
23
|
+
_init: function () {
|
|
24
|
+
var self = this;
|
|
25
|
+
var extractedStyles = $('.foundation-mq').css('font-family');
|
|
26
|
+
var namedQueries;
|
|
27
|
+
|
|
28
|
+
namedQueries = parseStyleToObject(extractedStyles);
|
|
29
|
+
|
|
30
|
+
for (var key in namedQueries) {
|
|
31
|
+
if (namedQueries.hasOwnProperty(key)) {
|
|
32
|
+
self.queries.push({
|
|
33
|
+
name: key,
|
|
34
|
+
value: 'only screen and (min-width: ' + namedQueries[key] + ')'
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
this.current = this._getCurrentSize();
|
|
40
|
+
|
|
41
|
+
this._watcher();
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Checks if the screen is at least as wide as a breakpoint.
|
|
47
|
+
* @function
|
|
48
|
+
* @param {String} size - Name of the breakpoint to check.
|
|
49
|
+
* @returns {Boolean} `true` if the breakpoint matches, `false` if it's smaller.
|
|
50
|
+
*/
|
|
51
|
+
atLeast: function (size) {
|
|
52
|
+
var query = this.get(size);
|
|
53
|
+
|
|
54
|
+
if (query) {
|
|
55
|
+
return window.matchMedia(query).matches;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return false;
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Checks if the screen matches to a breakpoint.
|
|
64
|
+
* @function
|
|
65
|
+
* @param {String} size - Name of the breakpoint to check, either 'small only' or 'small'. Omitting 'only' falls back to using atLeast() method.
|
|
66
|
+
* @returns {Boolean} `true` if the breakpoint matches, `false` if it does not.
|
|
67
|
+
*/
|
|
68
|
+
is: function (size) {
|
|
69
|
+
size = size.trim().split(' ');
|
|
70
|
+
if (size.length > 1 && size[1] === 'only') {
|
|
71
|
+
if (size[0] === this._getCurrentSize()) return true;
|
|
72
|
+
} else {
|
|
73
|
+
return this.atLeast(size[0]);
|
|
74
|
+
}
|
|
75
|
+
return false;
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Gets the media query of a breakpoint.
|
|
81
|
+
* @function
|
|
82
|
+
* @param {String} size - Name of the breakpoint to get.
|
|
83
|
+
* @returns {String|null} - The media query of the breakpoint, or `null` if the breakpoint doesn't exist.
|
|
84
|
+
*/
|
|
85
|
+
get: function (size) {
|
|
86
|
+
for (var i in this.queries) {
|
|
87
|
+
if (this.queries.hasOwnProperty(i)) {
|
|
88
|
+
var query = this.queries[i];
|
|
89
|
+
if (size === query.name) return query.value;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return null;
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Gets the current breakpoint name by testing every breakpoint and returning the last one to match (the biggest one).
|
|
99
|
+
* @function
|
|
100
|
+
* @private
|
|
101
|
+
* @returns {String} Name of the current breakpoint.
|
|
102
|
+
*/
|
|
103
|
+
_getCurrentSize: function () {
|
|
104
|
+
var matched;
|
|
105
|
+
|
|
106
|
+
for (var i = 0; i < this.queries.length; i++) {
|
|
107
|
+
var query = this.queries[i];
|
|
108
|
+
|
|
109
|
+
if (window.matchMedia(query.value).matches) {
|
|
110
|
+
matched = query;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (typeof matched === 'object') {
|
|
115
|
+
return matched.name;
|
|
116
|
+
} else {
|
|
117
|
+
return matched;
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Activates the breakpoint watcher, which fires an event on the window whenever the breakpoint changes.
|
|
124
|
+
* @function
|
|
125
|
+
* @private
|
|
126
|
+
*/
|
|
127
|
+
_watcher: function () {
|
|
128
|
+
var _this = this;
|
|
129
|
+
|
|
130
|
+
$(window).on('resize.zf.mediaquery', function () {
|
|
131
|
+
var newSize = _this._getCurrentSize(),
|
|
132
|
+
currentSize = _this.current;
|
|
133
|
+
|
|
134
|
+
if (newSize !== currentSize) {
|
|
135
|
+
// Change the current media query
|
|
136
|
+
_this.current = newSize;
|
|
137
|
+
|
|
138
|
+
// Broadcast the media query change on the window
|
|
139
|
+
$(window).trigger('changed.zf.mediaquery', [newSize, currentSize]);
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
Foundation.MediaQuery = MediaQuery;
|
|
146
|
+
|
|
147
|
+
// matchMedia() polyfill - Test a CSS media type/query in JS.
|
|
148
|
+
// Authors & copyright (c) 2012: Scott Jehl, Paul Irish, Nicholas Zakas, David Knight. Dual MIT/BSD license
|
|
149
|
+
window.matchMedia || (window.matchMedia = function () {
|
|
150
|
+
'use strict';
|
|
151
|
+
|
|
152
|
+
// For browsers that support matchMedium api such as IE 9 and webkit
|
|
153
|
+
|
|
154
|
+
var styleMedia = window.styleMedia || window.media;
|
|
155
|
+
|
|
156
|
+
// For those that don't support matchMedium
|
|
157
|
+
if (!styleMedia) {
|
|
158
|
+
var style = document.createElement('style'),
|
|
159
|
+
script = document.getElementsByTagName('script')[0],
|
|
160
|
+
info = null;
|
|
161
|
+
|
|
162
|
+
style.type = 'text/css';
|
|
163
|
+
style.id = 'matchmediajs-test';
|
|
164
|
+
|
|
165
|
+
script && script.parentNode && script.parentNode.insertBefore(style, script);
|
|
166
|
+
|
|
167
|
+
// 'style.currentStyle' is used by IE <= 8 and 'window.getComputedStyle' for all other browsers
|
|
168
|
+
info = 'getComputedStyle' in window && window.getComputedStyle(style, null) || style.currentStyle;
|
|
169
|
+
|
|
170
|
+
styleMedia = {
|
|
171
|
+
matchMedium: function (media) {
|
|
172
|
+
var text = '@media ' + media + '{ #matchmediajs-test { width: 1px; } }';
|
|
173
|
+
|
|
174
|
+
// 'style.styleSheet' is used by IE <= 8 and 'style.textContent' for all other browsers
|
|
175
|
+
if (style.styleSheet) {
|
|
176
|
+
style.styleSheet.cssText = text;
|
|
177
|
+
} else {
|
|
178
|
+
style.textContent = text;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// Test if media query is true or false
|
|
182
|
+
return info.width === '1px';
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
return function (media) {
|
|
188
|
+
return {
|
|
189
|
+
matches: styleMedia.matchMedium(media || 'all'),
|
|
190
|
+
media: media || 'all'
|
|
191
|
+
};
|
|
192
|
+
};
|
|
193
|
+
}());
|
|
194
|
+
|
|
195
|
+
// Thank you: https://github.com/sindresorhus/query-string
|
|
196
|
+
function parseStyleToObject(str) {
|
|
197
|
+
var styleObject = {};
|
|
198
|
+
|
|
199
|
+
if (typeof str !== 'string') {
|
|
200
|
+
return styleObject;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
str = str.trim().slice(1, -1); // browsers re-quote string style values
|
|
204
|
+
|
|
205
|
+
if (!str) {
|
|
206
|
+
return styleObject;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
styleObject = str.split('&').reduce(function (ret, param) {
|
|
210
|
+
var parts = param.replace(/\+/g, ' ').split('=');
|
|
211
|
+
var key = parts[0];
|
|
212
|
+
var val = parts[1];
|
|
213
|
+
key = decodeURIComponent(key);
|
|
214
|
+
|
|
215
|
+
// missing `=` should be `null`:
|
|
216
|
+
// http://w3.org/TR/2012/WD-url-20120524/#collect-url-parameters
|
|
217
|
+
val = val === undefined ? null : decodeURIComponent(val);
|
|
218
|
+
|
|
219
|
+
if (!ret.hasOwnProperty(key)) {
|
|
220
|
+
ret[key] = val;
|
|
221
|
+
} else if (Array.isArray(ret[key])) {
|
|
222
|
+
ret[key].push(val);
|
|
223
|
+
} else {
|
|
224
|
+
ret[key] = [ret[key], val];
|
|
225
|
+
}
|
|
226
|
+
return ret;
|
|
227
|
+
}, {});
|
|
228
|
+
|
|
229
|
+
return styleObject;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
Foundation.MediaQuery = MediaQuery;
|
|
233
|
+
}(jQuery);
|