foundation-rails 5.5.3.2 → 6.1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (169) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +1 -1
  3. data/README.md +2 -8
  4. data/Rakefile +23 -0
  5. data/app/views/foundation/rails/styleguide/show.html.erb +2 -5
  6. data/bower.json +2 -2
  7. data/lib/foundation/rails/version.rb +1 -1
  8. data/lib/generators/foundation/install_generator.rb +6 -3
  9. data/lib/generators/foundation/templates/_settings.scss +546 -0
  10. data/lib/generators/foundation/templates/application.html.erb +0 -1
  11. data/lib/generators/foundation/templates/application.html.haml +0 -2
  12. data/lib/generators/foundation/templates/application.html.slim +0 -2
  13. data/lib/generators/foundation/templates/foundation_and_overrides.scss +51 -0
  14. data/vendor/assets/js/foundation.abide.js +418 -0
  15. data/vendor/assets/js/foundation.accordion.js +229 -0
  16. data/vendor/assets/js/foundation.accordionMenu.js +262 -0
  17. data/vendor/assets/js/foundation.core.js +378 -0
  18. data/vendor/assets/js/foundation.drilldown.js +321 -0
  19. data/vendor/assets/js/foundation.dropdown.js +390 -0
  20. data/vendor/assets/js/foundation.dropdownMenu.js +391 -0
  21. data/vendor/assets/js/foundation.equalizer.js +274 -0
  22. data/vendor/assets/js/foundation.interchange.js +184 -0
  23. data/vendor/assets/js/foundation.js +28 -0
  24. data/vendor/assets/js/foundation.magellan.js +212 -0
  25. data/vendor/assets/js/foundation.offcanvas.js +371 -0
  26. data/vendor/assets/js/foundation.orbit.js +419 -0
  27. data/vendor/assets/js/foundation.responsiveMenu.js +145 -0
  28. data/vendor/assets/js/foundation.responsiveToggle.js +106 -0
  29. data/vendor/assets/js/foundation.reveal.js +478 -0
  30. data/vendor/assets/js/foundation.slider.js +484 -0
  31. data/vendor/assets/js/foundation.sticky.js +436 -0
  32. data/vendor/assets/js/foundation.tabs.js +306 -0
  33. data/vendor/assets/js/foundation.toggler.js +147 -0
  34. data/vendor/assets/js/foundation.tooltip.js +429 -0
  35. data/vendor/assets/js/foundation.util.box.js +169 -0
  36. data/vendor/assets/js/foundation.util.keyboard.js +115 -0
  37. data/vendor/assets/js/foundation.util.mediaQuery.js +210 -0
  38. data/vendor/assets/js/foundation.util.motion.js +89 -0
  39. data/vendor/assets/js/foundation.util.nest.js +64 -0
  40. data/vendor/assets/js/foundation.util.timerAndImageLoader.js +78 -0
  41. data/vendor/assets/js/foundation.util.touch.js +339 -0
  42. data/vendor/assets/js/foundation.util.triggers.js +222 -0
  43. data/vendor/assets/scss/_global.scss +626 -0
  44. data/vendor/assets/scss/components/_accordion-menu.scss +32 -0
  45. data/vendor/assets/scss/components/_accordion.scss +113 -0
  46. data/vendor/assets/scss/components/_badge.scss +55 -0
  47. data/vendor/assets/scss/components/_breadcrumbs.scss +94 -0
  48. data/vendor/assets/scss/components/_button-group.scss +130 -0
  49. data/vendor/assets/scss/components/_button.scss +265 -0
  50. data/vendor/assets/scss/components/_callout.scss +105 -0
  51. data/vendor/assets/scss/components/_close-button.scss +61 -0
  52. data/vendor/assets/scss/components/_drilldown.scss +75 -0
  53. data/vendor/assets/scss/components/_dropdown-menu.scss +148 -0
  54. data/vendor/assets/scss/components/_dropdown.scss +64 -0
  55. data/vendor/assets/scss/components/_flex-video.scss +63 -0
  56. data/vendor/assets/scss/components/_float.scss +27 -0
  57. data/vendor/assets/scss/components/_label.scss +56 -0
  58. data/vendor/assets/scss/components/_media-object.scss +74 -0
  59. data/vendor/assets/scss/components/_menu.scss +209 -0
  60. data/vendor/assets/scss/components/_off-canvas.scss +180 -0
  61. data/vendor/assets/scss/components/_orbit.scss +193 -0
  62. data/vendor/assets/scss/components/_pagination.scss +158 -0
  63. data/vendor/assets/scss/components/_progress-bar.scss +83 -0
  64. data/vendor/assets/scss/components/_reveal.scss +156 -0
  65. data/vendor/assets/scss/components/_slider.scss +158 -0
  66. data/vendor/assets/scss/components/_sticky.scss +38 -0
  67. data/vendor/assets/scss/components/_switch.scss +232 -0
  68. data/vendor/assets/scss/components/_table.scss +213 -0
  69. data/vendor/assets/scss/components/_tabs.scss +170 -0
  70. data/vendor/assets/scss/components/_thumbnail.scss +54 -0
  71. data/vendor/assets/scss/components/_title-bar.scss +68 -0
  72. data/vendor/assets/scss/components/_tooltip.scss +100 -0
  73. data/vendor/assets/scss/components/_top-bar.scss +89 -0
  74. data/vendor/assets/scss/components/_visibility.scss +131 -0
  75. data/vendor/assets/scss/forms/_checkbox.scss +36 -0
  76. data/vendor/assets/scss/forms/_error.scss +82 -0
  77. data/vendor/assets/scss/forms/_fieldset.scss +53 -0
  78. data/vendor/assets/scss/forms/_forms.scss +32 -0
  79. data/vendor/assets/scss/forms/_help-text.scss +30 -0
  80. data/vendor/assets/scss/forms/_input-group.scss +91 -0
  81. data/vendor/assets/scss/forms/_label.scss +48 -0
  82. data/vendor/assets/scss/forms/_select.scss +63 -0
  83. data/vendor/assets/scss/forms/_text.scss +154 -0
  84. data/vendor/assets/scss/foundation.scss +91 -0
  85. data/vendor/assets/scss/grid/_classes.scss +153 -0
  86. data/vendor/assets/scss/grid/_column.scss +124 -0
  87. data/vendor/assets/scss/grid/_flex-grid.scss +281 -0
  88. data/vendor/assets/scss/grid/_grid.scss +48 -0
  89. data/vendor/assets/scss/grid/_gutter.scss +34 -0
  90. data/vendor/assets/scss/grid/_layout.scss +33 -0
  91. data/vendor/assets/scss/grid/_position.scss +72 -0
  92. data/vendor/assets/scss/grid/_row.scss +97 -0
  93. data/vendor/assets/scss/grid/_size.scss +24 -0
  94. data/vendor/assets/scss/settings/_settings.scss +547 -0
  95. data/vendor/assets/scss/typography/_alignment.scss +22 -0
  96. data/vendor/assets/scss/typography/_base.scss +439 -0
  97. data/vendor/assets/scss/typography/_helpers.scss +77 -0
  98. data/vendor/assets/scss/typography/_print.scss +73 -0
  99. data/vendor/assets/scss/typography/_typography.scss +28 -0
  100. data/vendor/assets/scss/util/_breakpoint.scss +266 -0
  101. data/vendor/assets/scss/util/_color.scss +41 -0
  102. data/vendor/assets/scss/util/_mixins.scss +223 -0
  103. data/vendor/assets/scss/util/_selector.scss +40 -0
  104. data/vendor/assets/scss/util/_unit.scss +90 -0
  105. data/vendor/assets/scss/util/_util.scss +15 -0
  106. data/vendor/assets/scss/util/_value.scss +126 -0
  107. metadata +97 -64
  108. data/update-gem.sh +0 -20
  109. data/vendor/assets/javascripts/foundation.js +0 -17
  110. data/vendor/assets/javascripts/foundation/foundation.abide.js +0 -426
  111. data/vendor/assets/javascripts/foundation/foundation.accordion.js +0 -125
  112. data/vendor/assets/javascripts/foundation/foundation.alert.js +0 -43
  113. data/vendor/assets/javascripts/foundation/foundation.clearing.js +0 -586
  114. data/vendor/assets/javascripts/foundation/foundation.dropdown.js +0 -468
  115. data/vendor/assets/javascripts/foundation/foundation.equalizer.js +0 -104
  116. data/vendor/assets/javascripts/foundation/foundation.interchange.js +0 -360
  117. data/vendor/assets/javascripts/foundation/foundation.joyride.js +0 -935
  118. data/vendor/assets/javascripts/foundation/foundation.js +0 -732
  119. data/vendor/assets/javascripts/foundation/foundation.magellan.js +0 -214
  120. data/vendor/assets/javascripts/foundation/foundation.offcanvas.js +0 -225
  121. data/vendor/assets/javascripts/foundation/foundation.orbit.js +0 -476
  122. data/vendor/assets/javascripts/foundation/foundation.reveal.js +0 -522
  123. data/vendor/assets/javascripts/foundation/foundation.slider.js +0 -296
  124. data/vendor/assets/javascripts/foundation/foundation.tab.js +0 -247
  125. data/vendor/assets/javascripts/foundation/foundation.tooltip.js +0 -348
  126. data/vendor/assets/javascripts/foundation/foundation.topbar.js +0 -458
  127. data/vendor/assets/javascripts/vendor/modernizr.js +0 -1406
  128. data/vendor/assets/stylesheets/foundation.scss +0 -42
  129. data/vendor/assets/stylesheets/foundation/_functions.scss +0 -156
  130. data/vendor/assets/stylesheets/foundation/_settings.scss +0 -1489
  131. data/vendor/assets/stylesheets/foundation/components/_accordion.scss +0 -161
  132. data/vendor/assets/stylesheets/foundation/components/_alert-boxes.scss +0 -128
  133. data/vendor/assets/stylesheets/foundation/components/_block-grid.scss +0 -133
  134. data/vendor/assets/stylesheets/foundation/components/_breadcrumbs.scss +0 -132
  135. data/vendor/assets/stylesheets/foundation/components/_button-groups.scss +0 -208
  136. data/vendor/assets/stylesheets/foundation/components/_buttons.scss +0 -261
  137. data/vendor/assets/stylesheets/foundation/components/_clearing.scss +0 -260
  138. data/vendor/assets/stylesheets/foundation/components/_dropdown-buttons.scss +0 -130
  139. data/vendor/assets/stylesheets/foundation/components/_dropdown.scss +0 -269
  140. data/vendor/assets/stylesheets/foundation/components/_flex-video.scss +0 -51
  141. data/vendor/assets/stylesheets/foundation/components/_forms.scss +0 -607
  142. data/vendor/assets/stylesheets/foundation/components/_global.scss +0 -566
  143. data/vendor/assets/stylesheets/foundation/components/_grid.scss +0 -292
  144. data/vendor/assets/stylesheets/foundation/components/_icon-bar.scss +0 -460
  145. data/vendor/assets/stylesheets/foundation/components/_inline-lists.scss +0 -58
  146. data/vendor/assets/stylesheets/foundation/components/_joyride.scss +0 -220
  147. data/vendor/assets/stylesheets/foundation/components/_keystrokes.scss +0 -60
  148. data/vendor/assets/stylesheets/foundation/components/_labels.scss +0 -106
  149. data/vendor/assets/stylesheets/foundation/components/_magellan.scss +0 -34
  150. data/vendor/assets/stylesheets/foundation/components/_offcanvas.scss +0 -606
  151. data/vendor/assets/stylesheets/foundation/components/_orbit.scss +0 -388
  152. data/vendor/assets/stylesheets/foundation/components/_pagination.scss +0 -163
  153. data/vendor/assets/stylesheets/foundation/components/_panels.scss +0 -107
  154. data/vendor/assets/stylesheets/foundation/components/_pricing-tables.scss +0 -150
  155. data/vendor/assets/stylesheets/foundation/components/_progress-bars.scss +0 -85
  156. data/vendor/assets/stylesheets/foundation/components/_range-slider.scss +0 -177
  157. data/vendor/assets/stylesheets/foundation/components/_reveal.scss +0 -212
  158. data/vendor/assets/stylesheets/foundation/components/_side-nav.scss +0 -120
  159. data/vendor/assets/stylesheets/foundation/components/_split-buttons.scss +0 -203
  160. data/vendor/assets/stylesheets/foundation/components/_sub-nav.scss +0 -125
  161. data/vendor/assets/stylesheets/foundation/components/_switches.scss +0 -241
  162. data/vendor/assets/stylesheets/foundation/components/_tables.scss +0 -135
  163. data/vendor/assets/stylesheets/foundation/components/_tabs.scss +0 -142
  164. data/vendor/assets/stylesheets/foundation/components/_thumbs.scss +0 -66
  165. data/vendor/assets/stylesheets/foundation/components/_tooltips.scss +0 -142
  166. data/vendor/assets/stylesheets/foundation/components/_top-bar.scss +0 -745
  167. data/vendor/assets/stylesheets/foundation/components/_type.scss +0 -525
  168. data/vendor/assets/stylesheets/foundation/components/_visibility.scss +0 -425
  169. data/vendor/assets/stylesheets/normalize.scss +0 -424
@@ -0,0 +1,274 @@
1
+ !function(Foundation, $) {
2
+ 'use strict';
3
+
4
+ /**
5
+ * Creates a new instance of Equalizer.
6
+ * @class
7
+ * @fires Equalizer#init
8
+ * @param {Object} element - jQuery object to add the trigger to.
9
+ * @param {Object} options - Overrides to the default plugin settings.
10
+ */
11
+ function Equalizer(element, options){
12
+ this.$element = element;
13
+ this.options = $.extend({}, Equalizer.defaults, this.$element.data(), options);
14
+
15
+ this._init();
16
+
17
+ Foundation.registerPlugin(this, 'Equalizer');
18
+ }
19
+
20
+ /**
21
+ * Default settings for plugin
22
+ */
23
+ Equalizer.defaults = {
24
+ /**
25
+ * Enable height equalization when stacked on smaller screens.
26
+ * @option
27
+ * @example true
28
+ */
29
+ equalizeOnStack: true,
30
+ /**
31
+ * Enable height equalization row by row.
32
+ * @option
33
+ * @example false
34
+ */
35
+ equalizeByRow: false,
36
+ /**
37
+ * String representing the minimum breakpoint size the plugin should equalize heights on.
38
+ * @option
39
+ * @example 'medium'
40
+ */
41
+ equalizeOn: ''
42
+ };
43
+
44
+ /**
45
+ * Initializes the Equalizer plugin and calls functions to get equalizer functioning on load.
46
+ * @private
47
+ */
48
+ Equalizer.prototype._init = function(){
49
+ var eqId = this.$element.attr('data-equalizer') || '';
50
+ var $watched = this.$element.find('[data-equalizer-watch="' + eqId + '"]');
51
+
52
+ this.$watched = $watched.length ? $watched : this.$element.find('[data-equalizer-watch]');
53
+ this.$element.attr('data-resize', (eqId || Foundation.GetYoDigits(6, 'eq')));
54
+
55
+ this.hasNested = this.$element.find('[data-equalizer]').length > 0;
56
+ this.isNested = this.$element.parentsUntil(document.body, '[data-equalizer]').length > 0;
57
+ this.isOn = false;
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
+ Equalizer.prototype._pauseEvents = function(){
81
+ this.isOn = false;
82
+ this.$element.off('.zf.equalizer resizeme.zf.trigger');
83
+ };
84
+ /**
85
+ * Initializes events for Equalizer.
86
+ * @private
87
+ */
88
+ Equalizer.prototype._events = function(){
89
+ var _this = this;
90
+ this._pauseEvents();
91
+ if(this.hasNested){
92
+ this.$element.on('postequalized.zf.equalizer', function(e){
93
+ if(e.target !== _this.$element[0]){ _this._reflow(); }
94
+ });
95
+ }else{
96
+ this.$element.on('resizeme.zf.trigger', this._reflow.bind(this));
97
+ }
98
+ this.isOn = true;
99
+ };
100
+ /**
101
+ * Checks the current breakpoint to the minimum required size.
102
+ * @private
103
+ */
104
+ Equalizer.prototype._checkMQ = function(){
105
+ var tooSmall = !Foundation.MediaQuery.atLeast(this.options.equalizeOn);
106
+ if(tooSmall){
107
+ if(this.isOn){
108
+ this._pauseEvents();
109
+ this.$watched.css('height', 'auto');
110
+ }
111
+ }else{
112
+ if(!this.isOn){
113
+ this._events();
114
+ }
115
+ }
116
+ return tooSmall;
117
+ }
118
+ /**
119
+ * A noop version for the plugin
120
+ * @private
121
+ */
122
+ Equalizer.prototype._killswitch = function(){
123
+ return;
124
+ };
125
+ /**
126
+ * Calls necessary functions to update Equalizer upon DOM change
127
+ * @private
128
+ */
129
+ Equalizer.prototype._reflow = function(){
130
+ if(!this.options.equalizeOnStack){
131
+ if(this._isStacked()){
132
+ this.$watched.css('height', 'auto');
133
+ return false;
134
+ }
135
+ }
136
+ if (this.options.equalizeByRow) {
137
+ this.getHeightsByRow(this.applyHeightByRow.bind(this));
138
+ }else{
139
+ this.getHeights(this.applyHeight.bind(this));
140
+ }
141
+ };
142
+ /**
143
+ * Manually determines if the first 2 elements are *NOT* stacked.
144
+ * @private
145
+ */
146
+ Equalizer.prototype._isStacked = function(){
147
+ return this.$watched[0].offsetTop !== this.$watched[1].offsetTop;
148
+ };
149
+ /**
150
+ * Finds the outer heights of children contained within an Equalizer parent and returns them in an array
151
+ * @param {Function} cb - A non-optional callback to return the heights array to.
152
+ * @returns {Array} heights - An array of heights of children within Equalizer container
153
+ */
154
+ Equalizer.prototype.getHeights = function(cb){
155
+ var heights = [];
156
+ for(var i = 0, len = this.$watched.length; i < len; i++){
157
+ this.$watched[i].style.height = 'auto';
158
+ heights.push(this.$watched[i].offsetHeight);
159
+ }
160
+ cb(heights);
161
+ };
162
+ /**
163
+ * Finds the outer heights of children contained within an Equalizer parent and returns them in an array
164
+ * @param {Function} cb - A non-optional callback to return the heights array to.
165
+ * @returns {Array} groups - An array of heights of children within Equalizer container grouped by row with element,height and max as last child
166
+ */
167
+ Equalizer.prototype.getHeightsByRow = function(cb) {
168
+ var lastElTopOffset = this.$watched.first().offset().top,
169
+ groups = [],
170
+ group = 0;
171
+ //group by Row
172
+ groups[group] = [];
173
+ for(var i = 0, len = this.$watched.length; i < len; i++){
174
+ this.$watched[i].style.height = 'auto';
175
+ //maybe could use this.$watched[i].offsetTop
176
+ var elOffsetTop = $(this.$watched[i]).offset().top;
177
+ if (elOffsetTop!=lastElTopOffset) {
178
+ group++;
179
+ groups[group] = [];
180
+ lastElTopOffset=elOffsetTop;
181
+ };
182
+ groups[group].push([this.$watched[i],this.$watched[i].offsetHeight]);
183
+ }
184
+
185
+ for (var i = 0, len = groups.length; i < len; i++) {
186
+ var heights = $(groups[i]).map(function () { return this[1]}).get();
187
+ var max = Math.max.apply(null, heights);
188
+ groups[i].push(max);
189
+ }
190
+ cb(groups);
191
+ };
192
+ /**
193
+ * Changes the CSS height property of each child in an Equalizer parent to match the tallest
194
+ * @param {array} heights - An array of heights of children within Equalizer container
195
+ * @fires Equalizer#preequalized
196
+ * @fires Equalizer#postequalized
197
+ */
198
+ Equalizer.prototype.applyHeight = function(heights){
199
+ var max = Math.max.apply(null, heights);
200
+ /**
201
+ * Fires before the heights are applied
202
+ * @event Equalizer#preequalized
203
+ */
204
+ this.$element.trigger('preequalized.zf.equalizer');
205
+
206
+ this.$watched.css('height', max);
207
+
208
+ /**
209
+ * Fires when the heights have been applied
210
+ * @event Equalizer#postequalized
211
+ */
212
+ this.$element.trigger('postequalized.zf.equalizer');
213
+ };
214
+ /**
215
+ * Changes the CSS height property of each child in an Equalizer parent to match the tallest by row
216
+ * @param {array} groups - An array of heights of children within Equalizer container grouped by row with element,height and max as last child
217
+ * @fires Equalizer#preequalized
218
+ * @fires Equalizer#preequalizedRow
219
+ * @fires Equalizer#postequalizedRow
220
+ * @fires Equalizer#postequalized
221
+ */
222
+ Equalizer.prototype.applyHeightByRow = function(groups){
223
+ /**
224
+ * Fires before the heights are applied
225
+ */
226
+ this.$element.trigger('preequalized.zf.equalizer');
227
+ for (var i = 0, len = groups.length; i < len ; i++) {
228
+ var groupsILength = groups[i].length,
229
+ max = groups[i][groupsILength - 1];
230
+ if (groupsILength<=2) {
231
+ $(groups[i][0][0]).css({'height':'auto'});
232
+ continue;
233
+ };
234
+ /**
235
+ * Fires before the heights per row are applied
236
+ * @event Equalizer#preequalizedRow
237
+ */
238
+ this.$element.trigger('preequalizedrow.zf.equalizer');
239
+ for (var j = 0, lenJ = (groupsILength-1); j < lenJ ; j++) {
240
+ $(groups[i][j][0]).css({'height':max});
241
+ }
242
+ /**
243
+ * Fires when the heights per row have been applied
244
+ * @event Equalizer#postequalizedRow
245
+ */
246
+ this.$element.trigger('postequalizedrow.zf.equalizer');
247
+ }
248
+ /**
249
+ * Fires when the heights have been applied
250
+ */
251
+ this.$element.trigger('postequalized.zf.equalizer');
252
+ };
253
+ /**
254
+ * Destroys an instance of Equalizer.
255
+ * @function
256
+ */
257
+ Equalizer.prototype.destroy = function(){
258
+ this._pauseEvents();
259
+ this.$watched.css('height', 'auto');
260
+
261
+ Foundation.unregisterPlugin(this);
262
+ };
263
+
264
+ Foundation.plugin(Equalizer, 'Equalizer');
265
+
266
+ // Exports for AMD/Browserify
267
+ if (typeof module !== 'undefined' && typeof module.exports !== 'undefined')
268
+ module.exports = Equalizer;
269
+ if (typeof define === 'function')
270
+ define(['foundation'], function() {
271
+ return Equalizer;
272
+ });
273
+
274
+ }(Foundation, jQuery);
@@ -0,0 +1,184 @@
1
+ /**
2
+ * Interchange module.
3
+ * @module foundation.interchange
4
+ * @requires foundation.util.mediaQuery
5
+ * @requires foundation.util.timerAndImageLoader
6
+ */
7
+ !function(Foundation, $) {
8
+ 'use strict';
9
+
10
+ /**
11
+ * Creates a new instance of Interchange.
12
+ * @class
13
+ * @fires Interchange#init
14
+ * @param {Object} element - jQuery object to add the trigger to.
15
+ * @param {Object} options - Overrides to the default plugin settings.
16
+ */
17
+ function Interchange(element, options) {
18
+ this.$element = element;
19
+ this.options = $.extend({}, Interchange.defaults, options);
20
+ this.rules = [];
21
+ this.currentPath = '';
22
+
23
+ this._init();
24
+ this._events();
25
+
26
+ Foundation.registerPlugin(this, 'Interchange');
27
+ }
28
+
29
+ /**
30
+ * Default settings for plugin
31
+ */
32
+ Interchange.defaults = {
33
+ /**
34
+ * Rules to be applied to Interchange elements. Set with the `data-interchange` array notation.
35
+ * @option
36
+ */
37
+ rules: null
38
+ };
39
+
40
+ Interchange.SPECIAL_QUERIES = {
41
+ 'landscape': 'screen and (orientation: landscape)',
42
+ 'portrait': 'screen and (orientation: portrait)',
43
+ '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)'
44
+ };
45
+
46
+ /**
47
+ * Initializes the Interchange plugin and calls functions to get interchange functioning on load.
48
+ * @function
49
+ * @private
50
+ */
51
+ Interchange.prototype._init = function() {
52
+ this._addBreakpoints();
53
+ this._generateRules();
54
+ this._reflow();
55
+ };
56
+
57
+ /**
58
+ * Initializes events for Interchange.
59
+ * @function
60
+ * @private
61
+ */
62
+ Interchange.prototype._events = function() {
63
+ $(window).on('resize.zf.interchange', Foundation.util.throttle(this._reflow.bind(this), 50));
64
+ };
65
+
66
+ /**
67
+ * Calls necessary functions to update Interchange upon DOM change
68
+ * @function
69
+ * @private
70
+ */
71
+ Interchange.prototype._reflow = function() {
72
+ var match;
73
+
74
+ // Iterate through each rule, but only save the last match
75
+ for (var i in this.rules) {
76
+ var rule = this.rules[i];
77
+
78
+ if (window.matchMedia(rule.query).matches) {
79
+ match = rule;
80
+ }
81
+ }
82
+
83
+ if (match) {
84
+ this.replace(match.path);
85
+ }
86
+ };
87
+
88
+ /**
89
+ * Gets the Foundation breakpoints and adds them to the Interchange.SPECIAL_QUERIES object.
90
+ * @function
91
+ * @private
92
+ */
93
+ Interchange.prototype._addBreakpoints = function() {
94
+ for (var i in Foundation.MediaQuery.queries) {
95
+ var query = Foundation.MediaQuery.queries[i];
96
+ Interchange.SPECIAL_QUERIES[query.name] = query.value;
97
+ }
98
+ };
99
+
100
+ /**
101
+ * Checks the Interchange element for the provided media query + content pairings
102
+ * @function
103
+ * @private
104
+ * @param {Object} element - jQuery object that is an Interchange instance
105
+ * @returns {Array} scenarios - Array of objects that have 'mq' and 'path' keys with corresponding keys
106
+ */
107
+ Interchange.prototype._generateRules = function() {
108
+ var rulesList = [];
109
+ var rules;
110
+
111
+ if (this.options.rules) {
112
+ rules = this.options.rules;
113
+ }
114
+ else {
115
+ rules = this.$element.data('interchange').match(/\[.*?\]/g);
116
+ }
117
+
118
+ for (var i in rules) {
119
+ var rule = rules[i].slice(1, -1).split(', ');
120
+ var path = rule.slice(0, -1).join('');
121
+ var query = rule[rule.length - 1];
122
+
123
+ if (Interchange.SPECIAL_QUERIES[query]) {
124
+ query = Interchange.SPECIAL_QUERIES[query];
125
+ }
126
+
127
+ rulesList.push({
128
+ path: path,
129
+ query: query
130
+ });
131
+ }
132
+
133
+ this.rules = rulesList;
134
+ };
135
+
136
+ /**
137
+ * Update the `src` property of an image, or change the HTML of a container, to the specified path.
138
+ * @function
139
+ * @param {String} path - Path to the image or HTML partial.
140
+ * @fires Interchange#replaced
141
+ */
142
+ Interchange.prototype.replace = function(path) {
143
+ if (this.currentPath === path) return;
144
+
145
+ var _this = this;
146
+
147
+ // Replacing images
148
+ if (this.$element[0].nodeName === 'IMG') {
149
+ this.$element.attr('src', path).load(function() {
150
+ _this.currentPath = path;
151
+ });
152
+ }
153
+ // Replacing background images
154
+ else if (path.match(/\.(gif|jpg|jpeg|tiff|png)([?#].*)?/i)) {
155
+ this.$element.css({ 'background-image': 'url('+path+')' });
156
+ }
157
+ // Replacing HTML
158
+ else {
159
+ $.get(path, function(response) {
160
+ _this.$element.html(response);
161
+ $(response).foundation();
162
+ _this.currentPath = path;
163
+ });
164
+ }
165
+ this.$element.trigger('replaced.zf.interchange');
166
+ };
167
+ /**
168
+ * Destroys an instance of interchange.
169
+ * @function
170
+ */
171
+ Interchange.prototype.destroy = function(){
172
+ //TODO this.
173
+ };
174
+ Foundation.plugin(Interchange, 'Interchange');
175
+
176
+ // Exports for AMD/Browserify
177
+ if (typeof module !== 'undefined' && typeof module.exports !== 'undefined')
178
+ module.exports = Interchange;
179
+ if (typeof define === 'function')
180
+ define(['foundation'], function() {
181
+ return Interchange;
182
+ });
183
+
184
+ }(Foundation, jQuery);