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(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}var _createClass=function(){function e(e,n){for(var t=0;t<n.length;t++){var i=n[t];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(n,t,i){return t&&e(n.prototype,t),i&&e(n,i),n}}();!function(e){var n=function(){function n(t,i){_classCallCheck(this,n),this.$element=t,this.options=e.extend({},n.defaults,this.$element.data(),i),Foundation.Nest.Feather(this.$element,"dropdown"),this._init(),Foundation.registerPlugin(this,"DropdownMenu"),Foundation.Keyboard.register("DropdownMenu",{ENTER:"open",SPACE:"open",ARROW_RIGHT:"next",ARROW_UP:"up",ARROW_DOWN:"down",ARROW_LEFT:"previous",ESCAPE:"close"})}return _createClass(n,[{key:"_init",value:function(){var e=this.$element.find("li.is-dropdown-submenu-parent");this.$element.children(".is-dropdown-submenu-parent").children(".is-dropdown-submenu").addClass("first-sub"),this.$menuItems=this.$element.find('[role="menuitem"]'),this.$tabs=this.$element.children('[role="menuitem"]'),this.$tabs.find("ul.is-dropdown-submenu").addClass(this.options.verticalClass),this.$element.hasClass(this.options.rightClass)||"right"===this.options.alignment||Foundation.rtl()||this.$element.parents(".top-bar-right").is("*")?(this.options.alignment="right",e.addClass("opens-left")):e.addClass("opens-right"),this.changed=!1,this._events()}},{key:"_isVertical",value:function(){return"block"===this.$tabs.css("display")}},{key:"_events",value:function(){var n=this,t="ontouchstart"in window||"undefined"!=typeof window.ontouchstart,i="is-dropdown-submenu-parent",o=function(o){var s=e(o.target).parentsUntil("ul","."+i),a=s.hasClass(i),r="true"===s.attr("data-is-click"),d=s.children(".is-dropdown-submenu");if(a)if(r){if(!n.options.closeOnClick||!n.options.clickOpen&&!t||n.options.forceFollow&&t)return;o.stopImmediatePropagation(),o.preventDefault(),n._hide(s)}else o.preventDefault(),o.stopImmediatePropagation(),n._show(d),s.add(s.parentsUntil(n.$element,"."+i)).attr("data-is-click",!0)};(this.options.clickOpen||t)&&this.$menuItems.on("click.zf.dropdownmenu touchstart.zf.dropdownmenu",o),n.options.closeOnClickInside&&this.$menuItems.on("click.zf.dropdownmenu",function(t){var o=e(this),s=o.hasClass(i);s||n._hide()}),this.options.disableHover||this.$menuItems.on("mouseenter.zf.dropdownmenu",function(t){var o=e(this),s=o.hasClass(i);s&&(clearTimeout(o.data("_delay")),o.data("_delay",setTimeout(function(){n._show(o.children(".is-dropdown-submenu"))},n.options.hoverDelay)))}).on("mouseleave.zf.dropdownmenu",function(t){var o=e(this),s=o.hasClass(i);if(s&&n.options.autoclose){if("true"===o.attr("data-is-click")&&n.options.clickOpen)return!1;clearTimeout(o.data("_delay")),o.data("_delay",setTimeout(function(){n._hide(o)},n.options.closingTime))}}),this.$menuItems.on("keydown.zf.dropdownmenu",function(t){var i,o,s=e(t.target).parentsUntil("ul",'[role="menuitem"]'),a=n.$tabs.index(s)>-1,r=a?n.$tabs:s.siblings("li").add(s);r.each(function(n){if(e(this).is(s))return i=r.eq(n-1),void(o=r.eq(n+1))});var d=function(){s.is(":last-child")||(o.children("a:first").focus(),t.preventDefault())},l=function(){i.children("a:first").focus(),t.preventDefault()},u=function(){var e=s.children("ul.is-dropdown-submenu");e.length&&(n._show(e),s.find("li > a:first").focus(),t.preventDefault())},p=function(){var e=s.parent("ul").parent("li");e.children("a:first").focus(),n._hide(e),t.preventDefault()},c={open:u,close:function(){n._hide(n.$element),n.$menuItems.find("a:first").focus(),t.preventDefault()},handled:function(){t.stopImmediatePropagation()}};a?n._isVertical()?Foundation.rtl()?e.extend(c,{down:d,up:l,next:p,previous:u}):e.extend(c,{down:d,up:l,next:u,previous:p}):Foundation.rtl()?e.extend(c,{next:l,previous:d,down:u,up:p}):e.extend(c,{next:d,previous:l,down:u,up:p}):Foundation.rtl()?e.extend(c,{next:p,previous:u,down:d,up:l}):e.extend(c,{next:u,previous:p,down:d,up:l}),Foundation.Keyboard.handleKey(t,"DropdownMenu",c)})}},{key:"_addBodyHandler",value:function(){var n=e(document.body),t=this;n.off("mouseup.zf.dropdownmenu touchend.zf.dropdownmenu").on("mouseup.zf.dropdownmenu touchend.zf.dropdownmenu",function(e){var i=t.$element.find(e.target);i.length||(t._hide(),n.off("mouseup.zf.dropdownmenu touchend.zf.dropdownmenu"))})}},{key:"_show",value:function(n){var t=this.$tabs.index(this.$tabs.filter(function(t,i){return e(i).find(n).length>0})),i=n.parent("li.is-dropdown-submenu-parent").siblings("li.is-dropdown-submenu-parent");this._hide(i,t),n.css("visibility","hidden").addClass("js-dropdown-active").parent("li.is-dropdown-submenu-parent").addClass("is-active");var o=Foundation.Box.ImNotTouchingYou(n,null,!0);if(!o){var s="left"===this.options.alignment?"-right":"-left",a=n.parent(".is-dropdown-submenu-parent");a.removeClass("opens"+s).addClass("opens-"+this.options.alignment),o=Foundation.Box.ImNotTouchingYou(n,null,!0),o||a.removeClass("opens-"+this.options.alignment).addClass("opens-inner"),this.changed=!0}n.css("visibility",""),this.options.closeOnClick&&this._addBodyHandler(),this.$element.trigger("show.zf.dropdownmenu",[n])}},{key:"_hide",value:function(e,n){var t;t=e&&e.length?e:void 0!==n?this.$tabs.not(function(e,t){return e===n}):this.$element;var i=t.hasClass("is-active")||t.find(".is-active").length>0;if(i){if(t.find("li.is-active").add(t).attr({"data-is-click":!1}).removeClass("is-active"),t.find("ul.js-dropdown-active").removeClass("js-dropdown-active"),this.changed||t.find("opens-inner").length){var o="left"===this.options.alignment?"right":"left";t.find("li.is-dropdown-submenu-parent").add(t).removeClass("opens-inner opens-"+this.options.alignment).addClass("opens-"+o),this.changed=!1}this.$element.trigger("hide.zf.dropdownmenu",[t])}}},{key:"destroy",value:function(){this.$menuItems.off(".zf.dropdownmenu").removeAttr("data-is-click").removeClass("is-right-arrow is-left-arrow is-down-arrow opens-right opens-left opens-inner"),e(document.body).off(".zf.dropdownmenu"),Foundation.Nest.Burn(this.$element,"dropdown"),Foundation.unregisterPlugin(this)}}]),n}();n.defaults={disableHover:!1,autoclose:!0,hoverDelay:50,clickOpen:!1,closingTime:500,alignment:"left",closeOnClick:!0,closeOnClickInside:!0,verticalClass:"vertical",rightClass:"align-right",forceFollow:!0},Foundation.plugin(n,"DropdownMenu")}(jQuery);
|
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
4
|
+
|
|
5
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
6
|
+
|
|
7
|
+
!function ($) {
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Equalizer module.
|
|
11
|
+
* @module foundation.equalizer
|
|
12
|
+
* @requires foundation.util.mediaQuery
|
|
13
|
+
* @requires foundation.util.timerAndImageLoader if equalizer contains images
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
var Equalizer = function () {
|
|
17
|
+
/**
|
|
18
|
+
* Creates a new instance of Equalizer.
|
|
19
|
+
* @class
|
|
20
|
+
* @fires Equalizer#init
|
|
21
|
+
* @param {Object} element - jQuery object to add the trigger to.
|
|
22
|
+
* @param {Object} options - Overrides to the default plugin settings.
|
|
23
|
+
*/
|
|
24
|
+
function Equalizer(element, options) {
|
|
25
|
+
_classCallCheck(this, Equalizer);
|
|
26
|
+
|
|
27
|
+
this.$element = element;
|
|
28
|
+
this.options = $.extend({}, Equalizer.defaults, this.$element.data(), options);
|
|
29
|
+
|
|
30
|
+
this._init();
|
|
31
|
+
|
|
32
|
+
Foundation.registerPlugin(this, 'Equalizer');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Initializes the Equalizer plugin and calls functions to get equalizer functioning on load.
|
|
37
|
+
* @private
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
_createClass(Equalizer, [{
|
|
42
|
+
key: '_init',
|
|
43
|
+
value: function _init() {
|
|
44
|
+
var eqId = this.$element.attr('data-equalizer') || '';
|
|
45
|
+
var $watched = this.$element.find('[data-equalizer-watch="' + eqId + '"]');
|
|
46
|
+
|
|
47
|
+
this.$watched = $watched.length ? $watched : this.$element.find('[data-equalizer-watch]');
|
|
48
|
+
this.$element.attr('data-resize', eqId || Foundation.GetYoDigits(6, 'eq'));
|
|
49
|
+
this.$element.attr('data-mutate', eqId || Foundation.GetYoDigits(6, 'eq'));
|
|
50
|
+
|
|
51
|
+
this.hasNested = this.$element.find('[data-equalizer]').length > 0;
|
|
52
|
+
this.isNested = this.$element.parentsUntil(document.body, '[data-equalizer]').length > 0;
|
|
53
|
+
this.isOn = false;
|
|
54
|
+
this._bindHandler = {
|
|
55
|
+
onResizeMeBound: this._onResizeMe.bind(this),
|
|
56
|
+
onPostEqualizedBound: this._onPostEqualized.bind(this)
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
var imgs = this.$element.find('img');
|
|
60
|
+
var tooSmall;
|
|
61
|
+
if (this.options.equalizeOn) {
|
|
62
|
+
tooSmall = this._checkMQ();
|
|
63
|
+
$(window).on('changed.zf.mediaquery', this._checkMQ.bind(this));
|
|
64
|
+
} else {
|
|
65
|
+
this._events();
|
|
66
|
+
}
|
|
67
|
+
if (tooSmall !== undefined && tooSmall === false || tooSmall === undefined) {
|
|
68
|
+
if (imgs.length) {
|
|
69
|
+
Foundation.onImagesLoaded(imgs, this._reflow.bind(this));
|
|
70
|
+
} else {
|
|
71
|
+
this._reflow();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Removes event listeners if the breakpoint is too small.
|
|
78
|
+
* @private
|
|
79
|
+
*/
|
|
80
|
+
|
|
81
|
+
}, {
|
|
82
|
+
key: '_pauseEvents',
|
|
83
|
+
value: function _pauseEvents() {
|
|
84
|
+
this.isOn = false;
|
|
85
|
+
this.$element.off({
|
|
86
|
+
'.zf.equalizer': this._bindHandler.onPostEqualizedBound,
|
|
87
|
+
'resizeme.zf.trigger': this._bindHandler.onResizeMeBound,
|
|
88
|
+
'mutateme.zf.trigger': this._bindHandler.onResizeMeBound
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* function to handle $elements resizeme.zf.trigger, with bound this on _bindHandler.onResizeMeBound
|
|
94
|
+
* @private
|
|
95
|
+
*/
|
|
96
|
+
|
|
97
|
+
}, {
|
|
98
|
+
key: '_onResizeMe',
|
|
99
|
+
value: function _onResizeMe(e) {
|
|
100
|
+
this._reflow();
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* function to handle $elements postequalized.zf.equalizer, with bound this on _bindHandler.onPostEqualizedBound
|
|
105
|
+
* @private
|
|
106
|
+
*/
|
|
107
|
+
|
|
108
|
+
}, {
|
|
109
|
+
key: '_onPostEqualized',
|
|
110
|
+
value: function _onPostEqualized(e) {
|
|
111
|
+
if (e.target !== this.$element[0]) {
|
|
112
|
+
this._reflow();
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Initializes events for Equalizer.
|
|
118
|
+
* @private
|
|
119
|
+
*/
|
|
120
|
+
|
|
121
|
+
}, {
|
|
122
|
+
key: '_events',
|
|
123
|
+
value: function _events() {
|
|
124
|
+
var _this = this;
|
|
125
|
+
this._pauseEvents();
|
|
126
|
+
if (this.hasNested) {
|
|
127
|
+
this.$element.on('postequalized.zf.equalizer', this._bindHandler.onPostEqualizedBound);
|
|
128
|
+
} else {
|
|
129
|
+
this.$element.on('resizeme.zf.trigger', this._bindHandler.onResizeMeBound);
|
|
130
|
+
this.$element.on('mutateme.zf.trigger', this._bindHandler.onResizeMeBound);
|
|
131
|
+
}
|
|
132
|
+
this.isOn = true;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Checks the current breakpoint to the minimum required size.
|
|
137
|
+
* @private
|
|
138
|
+
*/
|
|
139
|
+
|
|
140
|
+
}, {
|
|
141
|
+
key: '_checkMQ',
|
|
142
|
+
value: function _checkMQ() {
|
|
143
|
+
var tooSmall = !Foundation.MediaQuery.is(this.options.equalizeOn);
|
|
144
|
+
if (tooSmall) {
|
|
145
|
+
if (this.isOn) {
|
|
146
|
+
this._pauseEvents();
|
|
147
|
+
this.$watched.css('height', 'auto');
|
|
148
|
+
}
|
|
149
|
+
} else {
|
|
150
|
+
if (!this.isOn) {
|
|
151
|
+
this._events();
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return tooSmall;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* A noop version for the plugin
|
|
159
|
+
* @private
|
|
160
|
+
*/
|
|
161
|
+
|
|
162
|
+
}, {
|
|
163
|
+
key: '_killswitch',
|
|
164
|
+
value: function _killswitch() {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Calls necessary functions to update Equalizer upon DOM change
|
|
170
|
+
* @private
|
|
171
|
+
*/
|
|
172
|
+
|
|
173
|
+
}, {
|
|
174
|
+
key: '_reflow',
|
|
175
|
+
value: function _reflow() {
|
|
176
|
+
if (!this.options.equalizeOnStack) {
|
|
177
|
+
if (this._isStacked()) {
|
|
178
|
+
this.$watched.css('height', 'auto');
|
|
179
|
+
return false;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
if (this.options.equalizeByRow) {
|
|
183
|
+
this.getHeightsByRow(this.applyHeightByRow.bind(this));
|
|
184
|
+
} else {
|
|
185
|
+
this.getHeights(this.applyHeight.bind(this));
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Manually determines if the first 2 elements are *NOT* stacked.
|
|
191
|
+
* @private
|
|
192
|
+
*/
|
|
193
|
+
|
|
194
|
+
}, {
|
|
195
|
+
key: '_isStacked',
|
|
196
|
+
value: function _isStacked() {
|
|
197
|
+
if (!this.$watched[0] || !this.$watched[1]) {
|
|
198
|
+
return true;
|
|
199
|
+
}
|
|
200
|
+
return this.$watched[0].getBoundingClientRect().top !== this.$watched[1].getBoundingClientRect().top;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Finds the outer heights of children contained within an Equalizer parent and returns them in an array
|
|
205
|
+
* @param {Function} cb - A non-optional callback to return the heights array to.
|
|
206
|
+
* @returns {Array} heights - An array of heights of children within Equalizer container
|
|
207
|
+
*/
|
|
208
|
+
|
|
209
|
+
}, {
|
|
210
|
+
key: 'getHeights',
|
|
211
|
+
value: function getHeights(cb) {
|
|
212
|
+
var heights = [];
|
|
213
|
+
for (var i = 0, len = this.$watched.length; i < len; i++) {
|
|
214
|
+
this.$watched[i].style.height = 'auto';
|
|
215
|
+
heights.push(this.$watched[i].offsetHeight);
|
|
216
|
+
}
|
|
217
|
+
cb(heights);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Finds the outer heights of children contained within an Equalizer parent and returns them in an array
|
|
222
|
+
* @param {Function} cb - A non-optional callback to return the heights array to.
|
|
223
|
+
* @returns {Array} groups - An array of heights of children within Equalizer container grouped by row with element,height and max as last child
|
|
224
|
+
*/
|
|
225
|
+
|
|
226
|
+
}, {
|
|
227
|
+
key: 'getHeightsByRow',
|
|
228
|
+
value: function getHeightsByRow(cb) {
|
|
229
|
+
var lastElTopOffset = this.$watched.length ? this.$watched.first().offset().top : 0,
|
|
230
|
+
groups = [],
|
|
231
|
+
group = 0;
|
|
232
|
+
//group by Row
|
|
233
|
+
groups[group] = [];
|
|
234
|
+
for (var i = 0, len = this.$watched.length; i < len; i++) {
|
|
235
|
+
this.$watched[i].style.height = 'auto';
|
|
236
|
+
//maybe could use this.$watched[i].offsetTop
|
|
237
|
+
var elOffsetTop = $(this.$watched[i]).offset().top;
|
|
238
|
+
if (elOffsetTop != lastElTopOffset) {
|
|
239
|
+
group++;
|
|
240
|
+
groups[group] = [];
|
|
241
|
+
lastElTopOffset = elOffsetTop;
|
|
242
|
+
}
|
|
243
|
+
groups[group].push([this.$watched[i], this.$watched[i].offsetHeight]);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
for (var j = 0, ln = groups.length; j < ln; j++) {
|
|
247
|
+
var heights = $(groups[j]).map(function () {
|
|
248
|
+
return this[1];
|
|
249
|
+
}).get();
|
|
250
|
+
var max = Math.max.apply(null, heights);
|
|
251
|
+
groups[j].push(max);
|
|
252
|
+
}
|
|
253
|
+
cb(groups);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Changes the CSS height property of each child in an Equalizer parent to match the tallest
|
|
258
|
+
* @param {array} heights - An array of heights of children within Equalizer container
|
|
259
|
+
* @fires Equalizer#preequalized
|
|
260
|
+
* @fires Equalizer#postequalized
|
|
261
|
+
*/
|
|
262
|
+
|
|
263
|
+
}, {
|
|
264
|
+
key: 'applyHeight',
|
|
265
|
+
value: function applyHeight(heights) {
|
|
266
|
+
var max = Math.max.apply(null, heights);
|
|
267
|
+
/**
|
|
268
|
+
* Fires before the heights are applied
|
|
269
|
+
* @event Equalizer#preequalized
|
|
270
|
+
*/
|
|
271
|
+
this.$element.trigger('preequalized.zf.equalizer');
|
|
272
|
+
|
|
273
|
+
this.$watched.css('height', max);
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Fires when the heights have been applied
|
|
277
|
+
* @event Equalizer#postequalized
|
|
278
|
+
*/
|
|
279
|
+
this.$element.trigger('postequalized.zf.equalizer');
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Changes the CSS height property of each child in an Equalizer parent to match the tallest by row
|
|
284
|
+
* @param {array} groups - An array of heights of children within Equalizer container grouped by row with element,height and max as last child
|
|
285
|
+
* @fires Equalizer#preequalized
|
|
286
|
+
* @fires Equalizer#preequalizedrow
|
|
287
|
+
* @fires Equalizer#postequalizedrow
|
|
288
|
+
* @fires Equalizer#postequalized
|
|
289
|
+
*/
|
|
290
|
+
|
|
291
|
+
}, {
|
|
292
|
+
key: 'applyHeightByRow',
|
|
293
|
+
value: function applyHeightByRow(groups) {
|
|
294
|
+
/**
|
|
295
|
+
* Fires before the heights are applied
|
|
296
|
+
*/
|
|
297
|
+
this.$element.trigger('preequalized.zf.equalizer');
|
|
298
|
+
for (var i = 0, len = groups.length; i < len; i++) {
|
|
299
|
+
var groupsILength = groups[i].length,
|
|
300
|
+
max = groups[i][groupsILength - 1];
|
|
301
|
+
if (groupsILength <= 2) {
|
|
302
|
+
$(groups[i][0][0]).css({ 'height': 'auto' });
|
|
303
|
+
continue;
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Fires before the heights per row are applied
|
|
307
|
+
* @event Equalizer#preequalizedrow
|
|
308
|
+
*/
|
|
309
|
+
this.$element.trigger('preequalizedrow.zf.equalizer');
|
|
310
|
+
for (var j = 0, lenJ = groupsILength - 1; j < lenJ; j++) {
|
|
311
|
+
$(groups[i][j][0]).css({ 'height': max });
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Fires when the heights per row have been applied
|
|
315
|
+
* @event Equalizer#postequalizedrow
|
|
316
|
+
*/
|
|
317
|
+
this.$element.trigger('postequalizedrow.zf.equalizer');
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Fires when the heights have been applied
|
|
321
|
+
*/
|
|
322
|
+
this.$element.trigger('postequalized.zf.equalizer');
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Destroys an instance of Equalizer.
|
|
327
|
+
* @function
|
|
328
|
+
*/
|
|
329
|
+
|
|
330
|
+
}, {
|
|
331
|
+
key: 'destroy',
|
|
332
|
+
value: function destroy() {
|
|
333
|
+
this._pauseEvents();
|
|
334
|
+
this.$watched.css('height', 'auto');
|
|
335
|
+
|
|
336
|
+
Foundation.unregisterPlugin(this);
|
|
337
|
+
}
|
|
338
|
+
}]);
|
|
339
|
+
|
|
340
|
+
return Equalizer;
|
|
341
|
+
}();
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Default settings for plugin
|
|
345
|
+
*/
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
Equalizer.defaults = {
|
|
349
|
+
/**
|
|
350
|
+
* Enable height equalization when stacked on smaller screens.
|
|
351
|
+
* @option
|
|
352
|
+
* @type {boolean}
|
|
353
|
+
* @default false
|
|
354
|
+
*/
|
|
355
|
+
equalizeOnStack: false,
|
|
356
|
+
/**
|
|
357
|
+
* Enable height equalization row by row.
|
|
358
|
+
* @option
|
|
359
|
+
* @type {boolean}
|
|
360
|
+
* @default false
|
|
361
|
+
*/
|
|
362
|
+
equalizeByRow: false,
|
|
363
|
+
/**
|
|
364
|
+
* String representing the minimum breakpoint size the plugin should equalize heights on.
|
|
365
|
+
* @option
|
|
366
|
+
* @type {string}
|
|
367
|
+
* @default ''
|
|
368
|
+
*/
|
|
369
|
+
equalizeOn: ''
|
|
370
|
+
};
|
|
371
|
+
|
|
372
|
+
// Window exports
|
|
373
|
+
Foundation.plugin(Equalizer, 'Equalizer');
|
|
374
|
+
}(jQuery);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var _createClass=function(){function e(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}();!function(e){var t=function(){function t(i,n){_classCallCheck(this,t),this.$element=i,this.options=e.extend({},t.defaults,this.$element.data(),n),this._init(),Foundation.registerPlugin(this,"Equalizer")}return _createClass(t,[{key:"_init",value:function(){var t=this.$element.attr("data-equalizer")||"",i=this.$element.find('[data-equalizer-watch="'+t+'"]');this.$watched=i.length?i:this.$element.find("[data-equalizer-watch]"),this.$element.attr("data-resize",t||Foundation.GetYoDigits(6,"eq")),this.$element.attr("data-mutate",t||Foundation.GetYoDigits(6,"eq")),this.hasNested=this.$element.find("[data-equalizer]").length>0,this.isNested=this.$element.parentsUntil(document.body,"[data-equalizer]").length>0,this.isOn=!1,this._bindHandler={onResizeMeBound:this._onResizeMe.bind(this),onPostEqualizedBound:this._onPostEqualized.bind(this)};var n,s=this.$element.find("img");this.options.equalizeOn?(n=this._checkMQ(),e(window).on("changed.zf.mediaquery",this._checkMQ.bind(this))):this._events(),(void 0!==n&&n===!1||void 0===n)&&(s.length?Foundation.onImagesLoaded(s,this._reflow.bind(this)):this._reflow())}},{key:"_pauseEvents",value:function(){this.isOn=!1,this.$element.off({".zf.equalizer":this._bindHandler.onPostEqualizedBound,"resizeme.zf.trigger":this._bindHandler.onResizeMeBound,"mutateme.zf.trigger":this._bindHandler.onResizeMeBound})}},{key:"_onResizeMe",value:function(e){this._reflow()}},{key:"_onPostEqualized",value:function(e){e.target!==this.$element[0]&&this._reflow()}},{key:"_events",value:function(){this._pauseEvents(),this.hasNested?this.$element.on("postequalized.zf.equalizer",this._bindHandler.onPostEqualizedBound):(this.$element.on("resizeme.zf.trigger",this._bindHandler.onResizeMeBound),this.$element.on("mutateme.zf.trigger",this._bindHandler.onResizeMeBound)),this.isOn=!0}},{key:"_checkMQ",value:function(){var e=!Foundation.MediaQuery.is(this.options.equalizeOn);return e?this.isOn&&(this._pauseEvents(),this.$watched.css("height","auto")):this.isOn||this._events(),e}},{key:"_killswitch",value:function(){}},{key:"_reflow",value:function(){return!this.options.equalizeOnStack&&this._isStacked()?(this.$watched.css("height","auto"),!1):void(this.options.equalizeByRow?this.getHeightsByRow(this.applyHeightByRow.bind(this)):this.getHeights(this.applyHeight.bind(this)))}},{key:"_isStacked",value:function(){return!this.$watched[0]||!this.$watched[1]||this.$watched[0].getBoundingClientRect().top!==this.$watched[1].getBoundingClientRect().top}},{key:"getHeights",value:function(e){for(var t=[],i=0,n=this.$watched.length;i<n;i++)this.$watched[i].style.height="auto",t.push(this.$watched[i].offsetHeight);e(t)}},{key:"getHeightsByRow",value:function(t){var i=this.$watched.length?this.$watched.first().offset().top:0,n=[],s=0;n[s]=[];for(var a=0,h=this.$watched.length;a<h;a++){this.$watched[a].style.height="auto";var o=e(this.$watched[a]).offset().top;o!=i&&(s++,n[s]=[],i=o),n[s].push([this.$watched[a],this.$watched[a].offsetHeight])}for(var l=0,u=n.length;l<u;l++){var r=e(n[l]).map(function(){return this[1]}).get(),d=Math.max.apply(null,r);n[l].push(d)}t(n)}},{key:"applyHeight",value:function(e){var t=Math.max.apply(null,e);this.$element.trigger("preequalized.zf.equalizer"),this.$watched.css("height",t),this.$element.trigger("postequalized.zf.equalizer")}},{key:"applyHeightByRow",value:function(t){this.$element.trigger("preequalized.zf.equalizer");for(var i=0,n=t.length;i<n;i++){var s=t[i].length,a=t[i][s-1];if(s<=2)e(t[i][0][0]).css({height:"auto"});else{this.$element.trigger("preequalizedrow.zf.equalizer");for(var h=0,o=s-1;h<o;h++)e(t[i][h][0]).css({height:a});this.$element.trigger("postequalizedrow.zf.equalizer")}}this.$element.trigger("postequalized.zf.equalizer")}},{key:"destroy",value:function(){this._pauseEvents(),this.$watched.css("height","auto"),Foundation.unregisterPlugin(this)}}]),t}();t.defaults={equalizeOnStack:!1,equalizeByRow:!1,equalizeOn:""},Foundation.plugin(t,"Equalizer")}(jQuery);
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
4
|
+
|
|
5
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
6
|
+
|
|
7
|
+
!function ($) {
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Interchange module.
|
|
11
|
+
* @module foundation.interchange
|
|
12
|
+
* @requires foundation.util.mediaQuery
|
|
13
|
+
* @requires foundation.util.timerAndImageLoader
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
var Interchange = function () {
|
|
17
|
+
/**
|
|
18
|
+
* Creates a new instance of Interchange.
|
|
19
|
+
* @class
|
|
20
|
+
* @fires Interchange#init
|
|
21
|
+
* @param {Object} element - jQuery object to add the trigger to.
|
|
22
|
+
* @param {Object} options - Overrides to the default plugin settings.
|
|
23
|
+
*/
|
|
24
|
+
function Interchange(element, options) {
|
|
25
|
+
_classCallCheck(this, Interchange);
|
|
26
|
+
|
|
27
|
+
this.$element = element;
|
|
28
|
+
this.options = $.extend({}, Interchange.defaults, options);
|
|
29
|
+
this.rules = [];
|
|
30
|
+
this.currentPath = '';
|
|
31
|
+
|
|
32
|
+
this._init();
|
|
33
|
+
this._events();
|
|
34
|
+
|
|
35
|
+
Foundation.registerPlugin(this, 'Interchange');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Initializes the Interchange plugin and calls functions to get interchange functioning on load.
|
|
40
|
+
* @function
|
|
41
|
+
* @private
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
_createClass(Interchange, [{
|
|
46
|
+
key: '_init',
|
|
47
|
+
value: function _init() {
|
|
48
|
+
this._addBreakpoints();
|
|
49
|
+
this._generateRules();
|
|
50
|
+
this._reflow();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Initializes events for Interchange.
|
|
55
|
+
* @function
|
|
56
|
+
* @private
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
}, {
|
|
60
|
+
key: '_events',
|
|
61
|
+
value: function _events() {
|
|
62
|
+
var _this2 = this;
|
|
63
|
+
|
|
64
|
+
$(window).on('resize.zf.interchange', Foundation.util.throttle(function () {
|
|
65
|
+
_this2._reflow();
|
|
66
|
+
}, 50));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Calls necessary functions to update Interchange upon DOM change
|
|
71
|
+
* @function
|
|
72
|
+
* @private
|
|
73
|
+
*/
|
|
74
|
+
|
|
75
|
+
}, {
|
|
76
|
+
key: '_reflow',
|
|
77
|
+
value: function _reflow() {
|
|
78
|
+
var match;
|
|
79
|
+
|
|
80
|
+
// Iterate through each rule, but only save the last match
|
|
81
|
+
for (var i in this.rules) {
|
|
82
|
+
if (this.rules.hasOwnProperty(i)) {
|
|
83
|
+
var rule = this.rules[i];
|
|
84
|
+
if (window.matchMedia(rule.query).matches) {
|
|
85
|
+
match = rule;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (match) {
|
|
91
|
+
this.replace(match.path);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Gets the Foundation breakpoints and adds them to the Interchange.SPECIAL_QUERIES object.
|
|
97
|
+
* @function
|
|
98
|
+
* @private
|
|
99
|
+
*/
|
|
100
|
+
|
|
101
|
+
}, {
|
|
102
|
+
key: '_addBreakpoints',
|
|
103
|
+
value: function _addBreakpoints() {
|
|
104
|
+
for (var i in Foundation.MediaQuery.queries) {
|
|
105
|
+
if (Foundation.MediaQuery.queries.hasOwnProperty(i)) {
|
|
106
|
+
var query = Foundation.MediaQuery.queries[i];
|
|
107
|
+
Interchange.SPECIAL_QUERIES[query.name] = query.value;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Checks the Interchange element for the provided media query + content pairings
|
|
114
|
+
* @function
|
|
115
|
+
* @private
|
|
116
|
+
* @param {Object} element - jQuery object that is an Interchange instance
|
|
117
|
+
* @returns {Array} scenarios - Array of objects that have 'mq' and 'path' keys with corresponding keys
|
|
118
|
+
*/
|
|
119
|
+
|
|
120
|
+
}, {
|
|
121
|
+
key: '_generateRules',
|
|
122
|
+
value: function _generateRules(element) {
|
|
123
|
+
var rulesList = [];
|
|
124
|
+
var rules;
|
|
125
|
+
|
|
126
|
+
if (this.options.rules) {
|
|
127
|
+
rules = this.options.rules;
|
|
128
|
+
} else {
|
|
129
|
+
rules = this.$element.data('interchange');
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
rules = typeof rules === 'string' ? rules.match(/\[.*?\]/g) : rules;
|
|
133
|
+
|
|
134
|
+
for (var i in rules) {
|
|
135
|
+
if (rules.hasOwnProperty(i)) {
|
|
136
|
+
var rule = rules[i].slice(1, -1).split(', ');
|
|
137
|
+
var path = rule.slice(0, -1).join('');
|
|
138
|
+
var query = rule[rule.length - 1];
|
|
139
|
+
|
|
140
|
+
if (Interchange.SPECIAL_QUERIES[query]) {
|
|
141
|
+
query = Interchange.SPECIAL_QUERIES[query];
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
rulesList.push({
|
|
145
|
+
path: path,
|
|
146
|
+
query: query
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
this.rules = rulesList;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Update the `src` property of an image, or change the HTML of a container, to the specified path.
|
|
156
|
+
* @function
|
|
157
|
+
* @param {String} path - Path to the image or HTML partial.
|
|
158
|
+
* @fires Interchange#replaced
|
|
159
|
+
*/
|
|
160
|
+
|
|
161
|
+
}, {
|
|
162
|
+
key: 'replace',
|
|
163
|
+
value: function replace(path) {
|
|
164
|
+
if (this.currentPath === path) return;
|
|
165
|
+
|
|
166
|
+
var _this = this,
|
|
167
|
+
trigger = 'replaced.zf.interchange';
|
|
168
|
+
|
|
169
|
+
// Replacing images
|
|
170
|
+
if (this.$element[0].nodeName === 'IMG') {
|
|
171
|
+
this.$element.attr('src', path).on('load', function () {
|
|
172
|
+
_this.currentPath = path;
|
|
173
|
+
}).trigger(trigger);
|
|
174
|
+
}
|
|
175
|
+
// Replacing background images
|
|
176
|
+
else if (path.match(/\.(gif|jpg|jpeg|png|svg|tiff)([?#].*)?/i)) {
|
|
177
|
+
this.$element.css({ 'background-image': 'url(' + path + ')' }).trigger(trigger);
|
|
178
|
+
}
|
|
179
|
+
// Replacing HTML
|
|
180
|
+
else {
|
|
181
|
+
$.get(path, function (response) {
|
|
182
|
+
_this.$element.html(response).trigger(trigger);
|
|
183
|
+
$(response).foundation();
|
|
184
|
+
_this.currentPath = path;
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Fires when content in an Interchange element is done being loaded.
|
|
190
|
+
* @event Interchange#replaced
|
|
191
|
+
*/
|
|
192
|
+
// this.$element.trigger('replaced.zf.interchange');
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Destroys an instance of interchange.
|
|
197
|
+
* @function
|
|
198
|
+
*/
|
|
199
|
+
|
|
200
|
+
}, {
|
|
201
|
+
key: 'destroy',
|
|
202
|
+
value: function destroy() {
|
|
203
|
+
//TODO this.
|
|
204
|
+
}
|
|
205
|
+
}]);
|
|
206
|
+
|
|
207
|
+
return Interchange;
|
|
208
|
+
}();
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Default settings for plugin
|
|
212
|
+
*/
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
Interchange.defaults = {
|
|
216
|
+
/**
|
|
217
|
+
* Rules to be applied to Interchange elements. Set with the `data-interchange` array notation.
|
|
218
|
+
* @option
|
|
219
|
+
* @type {?array}
|
|
220
|
+
* @default null
|
|
221
|
+
*/
|
|
222
|
+
rules: null
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
Interchange.SPECIAL_QUERIES = {
|
|
226
|
+
'landscape': 'screen and (orientation: landscape)',
|
|
227
|
+
'portrait': 'screen and (orientation: portrait)',
|
|
228
|
+
'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)'
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
// Window exports
|
|
232
|
+
Foundation.plugin(Interchange, 'Interchange');
|
|
233
|
+
}(jQuery);
|