volt-foundation 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +22 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +29 -0
  6. data/Rakefile +2 -0
  7. data/VERSION +1 -0
  8. data/app/foundation/assets/css/foundation.css +6196 -0
  9. data/app/foundation/assets/css/foundation.min.css +1 -0
  10. data/app/foundation/assets/css/normalize.css +425 -0
  11. data/app/foundation/assets/js/foundation/foundation.abide.js +313 -0
  12. data/app/foundation/assets/js/foundation/foundation.accordion.js +65 -0
  13. data/app/foundation/assets/js/foundation/foundation.alert.js +43 -0
  14. data/app/foundation/assets/js/foundation/foundation.clearing.js +558 -0
  15. data/app/foundation/assets/js/foundation/foundation.dropdown.js +326 -0
  16. data/app/foundation/assets/js/foundation/foundation.equalizer.js +74 -0
  17. data/app/foundation/assets/js/foundation/foundation.interchange.js +344 -0
  18. data/app/foundation/assets/js/foundation/foundation.joyride.js +917 -0
  19. data/app/foundation/assets/js/foundation/foundation.js +625 -0
  20. data/app/foundation/assets/js/foundation/foundation.magellan.js +189 -0
  21. data/app/foundation/assets/js/foundation/foundation.offcanvas.js +152 -0
  22. data/app/foundation/assets/js/foundation/foundation.orbit.js +472 -0
  23. data/app/foundation/assets/js/foundation/foundation.reveal.js +444 -0
  24. data/app/foundation/assets/js/foundation/foundation.slider.js +239 -0
  25. data/app/foundation/assets/js/foundation/foundation.tab.js +217 -0
  26. data/app/foundation/assets/js/foundation/foundation.tooltip.js +300 -0
  27. data/app/foundation/assets/js/foundation/foundation.topbar.js +445 -0
  28. data/app/foundation/assets/js/foundation.min.js +5723 -0
  29. data/app/foundation/assets/js/vendor/fastclick.js +9 -0
  30. data/app/foundation/assets/js/vendor/jquery.cookie.js +8 -0
  31. data/app/foundation/assets/js/vendor/jquery.js +26 -0
  32. data/app/foundation/assets/js/vendor/modernizr.js +8 -0
  33. data/app/foundation/assets/js/vendor/placeholder.js +2 -0
  34. data/lib/volt/foundation/version.rb +5 -0
  35. data/lib/volt/foundation.rb +7 -0
  36. data/volt-foundation.gemspec +24 -0
  37. metadata +107 -0
@@ -0,0 +1,326 @@
1
+ ;(function ($, window, document, undefined) {
2
+ 'use strict';
3
+
4
+ Foundation.libs.dropdown = {
5
+ name : 'dropdown',
6
+
7
+ version : '5.4.6',
8
+
9
+ settings : {
10
+ active_class: 'open',
11
+ disabled_class: 'disabled',
12
+ mega_class: 'mega',
13
+ align: 'bottom',
14
+ is_hover: false,
15
+ opened: function(){},
16
+ closed: function(){}
17
+ },
18
+
19
+ init : function (scope, method, options) {
20
+ Foundation.inherit(this, 'throttle');
21
+
22
+ this.bindings(method, options);
23
+ },
24
+
25
+ events : function (scope) {
26
+ var self = this,
27
+ S = self.S;
28
+
29
+ S(this.scope)
30
+ .off('.dropdown')
31
+ .on('click.fndtn.dropdown', '[' + this.attr_name() + ']', function (e) {
32
+ var settings = S(this).data(self.attr_name(true) + '-init') || self.settings;
33
+ if (!settings.is_hover || Modernizr.touch) {
34
+ e.preventDefault();
35
+ self.toggle($(this));
36
+ }
37
+ })
38
+ .on('mouseenter.fndtn.dropdown', '[' + this.attr_name() + '], [' + this.attr_name() + '-content]', function (e) {
39
+ var $this = S(this),
40
+ dropdown,
41
+ target;
42
+
43
+ clearTimeout(self.timeout);
44
+
45
+ if ($this.data(self.data_attr())) {
46
+ dropdown = S('#' + $this.data(self.data_attr()));
47
+ target = $this;
48
+ } else {
49
+ dropdown = $this;
50
+ target = S("[" + self.attr_name() + "='" + dropdown.attr('id') + "']");
51
+ }
52
+
53
+ var settings = target.data(self.attr_name(true) + '-init') || self.settings;
54
+
55
+ if(S(e.target).data(self.data_attr()) && settings.is_hover) {
56
+ self.closeall.call(self);
57
+ }
58
+
59
+ if (settings.is_hover) self.open.apply(self, [dropdown, target]);
60
+ })
61
+ .on('mouseleave.fndtn.dropdown', '[' + this.attr_name() + '], [' + this.attr_name() + '-content]', function (e) {
62
+ var $this = S(this);
63
+ self.timeout = setTimeout(function () {
64
+ if ($this.data(self.data_attr())) {
65
+ var settings = $this.data(self.data_attr(true) + '-init') || self.settings;
66
+ if (settings.is_hover) self.close.call(self, S('#' + $this.data(self.data_attr())));
67
+ } else {
68
+ var target = S('[' + self.attr_name() + '="' + S(this).attr('id') + '"]'),
69
+ settings = target.data(self.attr_name(true) + '-init') || self.settings;
70
+ if (settings.is_hover) self.close.call(self, $this);
71
+ }
72
+ }.bind(this), 150);
73
+ })
74
+ .on('click.fndtn.dropdown', function (e) {
75
+ var parent = S(e.target).closest('[' + self.attr_name() + '-content]');
76
+
77
+ if (S(e.target).closest('[' + self.attr_name() + ']').length > 0) {
78
+ return;
79
+ }
80
+ if (!(S(e.target).data('revealId')) &&
81
+ (parent.length > 0 && (S(e.target).is('[' + self.attr_name() + '-content]') ||
82
+ $.contains(parent.first()[0], e.target)))) {
83
+ e.stopPropagation();
84
+ return;
85
+ }
86
+
87
+ self.close.call(self, S('[' + self.attr_name() + '-content]'));
88
+ })
89
+ .on('opened.fndtn.dropdown', '[' + self.attr_name() + '-content]', function () {
90
+ self.settings.opened.call(this);
91
+ })
92
+ .on('closed.fndtn.dropdown', '[' + self.attr_name() + '-content]', function () {
93
+ self.settings.closed.call(this);
94
+ });
95
+
96
+ S(window)
97
+ .off('.dropdown')
98
+ .on('resize.fndtn.dropdown', self.throttle(function () {
99
+ self.resize.call(self);
100
+ }, 50));
101
+
102
+ this.resize();
103
+ },
104
+
105
+ close: function (dropdown) {
106
+ var self = this;
107
+ dropdown.each(function () {
108
+ var original_target = $('[' + self.attr_name() + '=' + dropdown[0].id + ']') || $('aria-controls=' + dropdown[0].id+ ']');
109
+ original_target.attr('aria-expanded', "false");
110
+ if (self.S(this).hasClass(self.settings.active_class)) {
111
+ self.S(this)
112
+ .css(Foundation.rtl ? 'right':'left', '-99999px')
113
+ .attr('aria-hidden', "true")
114
+ .removeClass(self.settings.active_class)
115
+ .prev('[' + self.attr_name() + ']')
116
+ .removeClass(self.settings.active_class)
117
+ .removeData('target');
118
+
119
+ self.S(this).trigger('closed').trigger('closed.fndtn.dropdown', [dropdown]);
120
+ }
121
+ });
122
+ },
123
+
124
+ closeall: function() {
125
+ var self = this;
126
+ $.each(self.S('[' + this.attr_name() + '-content]'), function() {
127
+ self.close.call(self, self.S(this));
128
+ });
129
+ },
130
+
131
+ open: function (dropdown, target) {
132
+ this
133
+ .css(dropdown
134
+ .addClass(this.settings.active_class), target);
135
+ dropdown.prev('[' + this.attr_name() + ']').addClass(this.settings.active_class);
136
+ dropdown.data('target', target.get(0)).trigger('opened').trigger('opened.fndtn.dropdown', [dropdown, target]);
137
+ dropdown.attr('aria-hidden', 'false');
138
+ target.attr('aria-expanded', 'true');
139
+ dropdown.focus();
140
+ },
141
+
142
+ data_attr: function () {
143
+ if (this.namespace.length > 0) {
144
+ return this.namespace + '-' + this.name;
145
+ }
146
+
147
+ return this.name;
148
+ },
149
+
150
+ toggle : function (target) {
151
+ if (target.hasClass(this.settings.disabled_class)) {
152
+ return;
153
+ }
154
+ var dropdown = this.S('#' + target.data(this.data_attr()));
155
+ if (dropdown.length === 0) {
156
+ // No dropdown found, not continuing
157
+ return;
158
+ }
159
+
160
+ this.close.call(this, this.S('[' + this.attr_name() + '-content]').not(dropdown));
161
+
162
+ if (dropdown.hasClass(this.settings.active_class)) {
163
+ this.close.call(this, dropdown);
164
+ if (dropdown.data('target') !== target.get(0))
165
+ this.open.call(this, dropdown, target);
166
+ } else {
167
+ this.open.call(this, dropdown, target);
168
+ }
169
+ },
170
+
171
+ resize : function () {
172
+ var dropdown = this.S('[' + this.attr_name() + '-content].open'),
173
+ target = this.S("[" + this.attr_name() + "='" + dropdown.attr('id') + "']");
174
+
175
+ if (dropdown.length && target.length) {
176
+ this.css(dropdown, target);
177
+ }
178
+ },
179
+
180
+ css : function (dropdown, target) {
181
+ var left_offset = Math.max((target.width() - dropdown.width()) / 2, 8),
182
+ settings = target.data(this.attr_name(true) + '-init') || this.settings;
183
+
184
+ this.clear_idx();
185
+
186
+ if (this.small()) {
187
+ var p = this.dirs.bottom.call(dropdown, target, settings);
188
+
189
+ dropdown.attr('style', '').removeClass('drop-left drop-right drop-top').css({
190
+ position : 'absolute',
191
+ width: '95%',
192
+ 'max-width': 'none',
193
+ top: p.top
194
+ });
195
+
196
+ dropdown.css(Foundation.rtl ? 'right':'left', left_offset);
197
+ } else {
198
+
199
+ this.style(dropdown, target, settings);
200
+ }
201
+
202
+ return dropdown;
203
+ },
204
+
205
+ style : function (dropdown, target, settings) {
206
+ var css = $.extend({position: 'absolute'},
207
+ this.dirs[settings.align].call(dropdown, target, settings));
208
+
209
+ dropdown.attr('style', '').css(css);
210
+ },
211
+
212
+ // return CSS property object
213
+ // `this` is the dropdown
214
+ dirs : {
215
+ // Calculate target offset
216
+ _base : function (t) {
217
+ var o_p = this.offsetParent(),
218
+ o = o_p.offset(),
219
+ p = t.offset();
220
+
221
+ p.top -= o.top;
222
+ p.left -= o.left;
223
+
224
+ return p;
225
+ },
226
+ top: function (t, s) {
227
+ var self = Foundation.libs.dropdown,
228
+ p = self.dirs._base.call(this, t);
229
+
230
+ this.addClass('drop-top');
231
+
232
+ if (t.outerWidth() < this.outerWidth() || self.small() || this.hasClass(s.mega_menu)) {
233
+ self.adjust_pip(this,t,s,p);
234
+ }
235
+
236
+ if (Foundation.rtl) {
237
+ return {left: p.left - this.outerWidth() + t.outerWidth(),
238
+ top: p.top - this.outerHeight()};
239
+ }
240
+
241
+ return {left: p.left, top: p.top - this.outerHeight()};
242
+ },
243
+ bottom: function (t,s) {
244
+ var self = Foundation.libs.dropdown,
245
+ p = self.dirs._base.call(this, t);
246
+
247
+ if (t.outerWidth() < this.outerWidth() || self.small() || this.hasClass(s.mega_menu)) {
248
+ self.adjust_pip(this,t,s,p);
249
+ }
250
+
251
+ if (self.rtl) {
252
+ return {left: p.left - this.outerWidth() + t.outerWidth(), top: p.top + t.outerHeight()};
253
+ }
254
+
255
+ return {left: p.left, top: p.top + t.outerHeight()};
256
+ },
257
+ left: function (t, s) {
258
+ var p = Foundation.libs.dropdown.dirs._base.call(this, t);
259
+
260
+ this.addClass('drop-left');
261
+
262
+ return {left: p.left - this.outerWidth(), top: p.top};
263
+ },
264
+ right: function (t, s) {
265
+ var p = Foundation.libs.dropdown.dirs._base.call(this, t);
266
+
267
+ this.addClass('drop-right');
268
+
269
+ return {left: p.left + t.outerWidth(), top: p.top};
270
+ }
271
+ },
272
+
273
+ // Insert rule to style psuedo elements
274
+ adjust_pip : function (dropdown,target,settings,position) {
275
+ var sheet = Foundation.stylesheet,
276
+ pip_offset_base = 8;
277
+
278
+ if (dropdown.hasClass(settings.mega_class)) {
279
+ pip_offset_base = position.left + (target.outerWidth()/2) - 8;
280
+ }
281
+ else if (this.small()) {
282
+ pip_offset_base += position.left - 8;
283
+ }
284
+
285
+ this.rule_idx = sheet.cssRules.length;
286
+
287
+ var sel_before = '.f-dropdown.open:before',
288
+ sel_after = '.f-dropdown.open:after',
289
+ css_before = 'left: ' + pip_offset_base + 'px;',
290
+ css_after = 'left: ' + (pip_offset_base - 1) + 'px;';
291
+
292
+ if (sheet.insertRule) {
293
+ sheet.insertRule([sel_before, '{', css_before, '}'].join(' '), this.rule_idx);
294
+ sheet.insertRule([sel_after, '{', css_after, '}'].join(' '), this.rule_idx + 1);
295
+ } else {
296
+ sheet.addRule(sel_before, css_before, this.rule_idx);
297
+ sheet.addRule(sel_after, css_after, this.rule_idx + 1);
298
+ }
299
+ },
300
+
301
+ // Remove old dropdown rule index
302
+ clear_idx : function () {
303
+ var sheet = Foundation.stylesheet;
304
+
305
+ if (this.rule_idx) {
306
+ sheet.deleteRule(this.rule_idx);
307
+ sheet.deleteRule(this.rule_idx);
308
+ delete this.rule_idx;
309
+ }
310
+ },
311
+
312
+ small : function () {
313
+ return matchMedia(Foundation.media_queries.small).matches &&
314
+ !matchMedia(Foundation.media_queries.medium).matches;
315
+ },
316
+
317
+ off: function () {
318
+ this.S(this.scope).off('.fndtn.dropdown');
319
+ this.S('html, body').off('.fndtn.dropdown');
320
+ this.S(window).off('.fndtn.dropdown');
321
+ this.S('[data-dropdown-content]').off('.fndtn.dropdown');
322
+ },
323
+
324
+ reflow : function () {}
325
+ };
326
+ }(jQuery, window, window.document));
@@ -0,0 +1,74 @@
1
+ ;(function ($, window, document, undefined) {
2
+ 'use strict';
3
+
4
+ Foundation.libs.equalizer = {
5
+ name : 'equalizer',
6
+
7
+ version : '5.4.6',
8
+
9
+ settings : {
10
+ use_tallest: true,
11
+ before_height_change: $.noop,
12
+ after_height_change: $.noop,
13
+ equalize_on_stack: false
14
+ },
15
+
16
+ init : function (scope, method, options) {
17
+ Foundation.inherit(this, 'image_loaded');
18
+ this.bindings(method, options);
19
+ this.reflow();
20
+ },
21
+
22
+ events : function () {
23
+ this.S(window).off('.equalizer').on('resize.fndtn.equalizer', function(e){
24
+ this.reflow();
25
+ }.bind(this));
26
+ },
27
+
28
+ equalize: function(equalizer) {
29
+ var isStacked = false,
30
+ vals = equalizer.find('[' + this.attr_name() + '-watch]:visible'),
31
+ settings = equalizer.data(this.attr_name(true)+'-init');
32
+
33
+ if (vals.length === 0) return;
34
+ var firstTopOffset = vals.first().offset().top;
35
+ settings.before_height_change();
36
+ equalizer.trigger('before-height-change').trigger('before-height-change.fndth.equalizer');
37
+ vals.height('inherit');
38
+ vals.each(function(){
39
+ var el = $(this);
40
+ if (el.offset().top !== firstTopOffset) {
41
+ isStacked = true;
42
+ }
43
+ });
44
+
45
+ if (settings.equalize_on_stack === false) {
46
+ if (isStacked) return;
47
+ };
48
+
49
+ var heights = vals.map(function(){ return $(this).outerHeight(false) }).get();
50
+
51
+ if (settings.use_tallest) {
52
+ var max = Math.max.apply(null, heights);
53
+ vals.css('height', max);
54
+ } else {
55
+ var min = Math.min.apply(null, heights);
56
+ vals.css('height', min);
57
+ }
58
+ settings.after_height_change();
59
+ equalizer.trigger('after-height-change').trigger('after-height-change.fndtn.equalizer');
60
+ },
61
+
62
+ reflow : function () {
63
+ var self = this;
64
+
65
+ this.S('[' + this.attr_name() + ']', this.scope).each(function(){
66
+ var $eq_target = $(this);
67
+ self.image_loaded(self.S('img', this), function(){
68
+ self.equalize($eq_target)
69
+ });
70
+ });
71
+ }
72
+ };
73
+ })(jQuery, window, window.document);
74
+
@@ -0,0 +1,344 @@
1
+ ;(function ($, window, document, undefined) {
2
+ 'use strict';
3
+
4
+ Foundation.libs.interchange = {
5
+ name : 'interchange',
6
+
7
+ version : '5.4.6',
8
+
9
+ cache : {},
10
+
11
+ images_loaded : false,
12
+ nodes_loaded : false,
13
+
14
+ settings : {
15
+ load_attr : 'interchange',
16
+
17
+ named_queries : {
18
+ 'default' : 'only screen',
19
+ small : Foundation.media_queries.small,
20
+ medium : Foundation.media_queries.medium,
21
+ large : Foundation.media_queries.large,
22
+ xlarge : Foundation.media_queries.xlarge,
23
+ xxlarge: Foundation.media_queries.xxlarge,
24
+ landscape : 'only screen and (orientation: landscape)',
25
+ portrait : 'only screen and (orientation: portrait)',
26
+ retina : 'only screen and (-webkit-min-device-pixel-ratio: 2),' +
27
+ 'only screen and (min--moz-device-pixel-ratio: 2),' +
28
+ 'only screen and (-o-min-device-pixel-ratio: 2/1),' +
29
+ 'only screen and (min-device-pixel-ratio: 2),' +
30
+ 'only screen and (min-resolution: 192dpi),' +
31
+ 'only screen and (min-resolution: 2dppx)'
32
+ },
33
+
34
+ directives : {
35
+ replace: function (el, path, trigger) {
36
+ // The trigger argument, if called within the directive, fires
37
+ // an event named after the directive on the element, passing
38
+ // any parameters along to the event that you pass to trigger.
39
+ //
40
+ // ex. trigger(), trigger([a, b, c]), or trigger(a, b, c)
41
+ //
42
+ // This allows you to bind a callback like so:
43
+ // $('#interchangeContainer').on('replace', function (e, a, b, c) {
44
+ // console.log($(this).html(), a, b, c);
45
+ // });
46
+
47
+ if (/IMG/.test(el[0].nodeName)) {
48
+ var orig_path = el[0].src;
49
+
50
+ if (new RegExp(path, 'i').test(orig_path)) return;
51
+
52
+ el[0].src = path;
53
+
54
+ return trigger(el[0].src);
55
+ }
56
+ var last_path = el.data(this.data_attr + '-last-path'),
57
+ self = this;
58
+
59
+ if (last_path == path) return;
60
+
61
+ if (/\.(gif|jpg|jpeg|tiff|png)([?#].*)?/i.test(path)) {
62
+ $(el).css('background-image', 'url('+path+')');
63
+ el.data('interchange-last-path', path);
64
+ return trigger(path);
65
+ }
66
+
67
+ return $.get(path, function (response) {
68
+ el.html(response);
69
+ el.data(self.data_attr + '-last-path', path);
70
+ trigger();
71
+ });
72
+
73
+ }
74
+ }
75
+ },
76
+
77
+ init : function (scope, method, options) {
78
+ Foundation.inherit(this, 'throttle random_str');
79
+
80
+ this.data_attr = this.set_data_attr();
81
+ $.extend(true, this.settings, method, options);
82
+ this.bindings(method, options);
83
+ this.load('images');
84
+ this.load('nodes');
85
+ },
86
+
87
+ get_media_hash : function() {
88
+ var mediaHash='';
89
+ for (var queryName in this.settings.named_queries ) {
90
+ mediaHash += matchMedia(this.settings.named_queries[queryName]).matches.toString();
91
+ }
92
+ return mediaHash;
93
+ },
94
+
95
+ events : function () {
96
+ var self = this, prevMediaHash;
97
+
98
+ $(window)
99
+ .off('.interchange')
100
+ .on('resize.fndtn.interchange', self.throttle(function () {
101
+ var currMediaHash = self.get_media_hash();
102
+ if (currMediaHash !== prevMediaHash) {
103
+ self.resize();
104
+ }
105
+ prevMediaHash = currMediaHash;
106
+ }, 50));
107
+
108
+ return this;
109
+ },
110
+
111
+ resize : function () {
112
+ var cache = this.cache;
113
+
114
+ if(!this.images_loaded || !this.nodes_loaded) {
115
+ setTimeout($.proxy(this.resize, this), 50);
116
+ return;
117
+ }
118
+
119
+ for (var uuid in cache) {
120
+ if (cache.hasOwnProperty(uuid)) {
121
+ var passed = this.results(uuid, cache[uuid]);
122
+
123
+ if (passed) {
124
+ this.settings.directives[passed
125
+ .scenario[1]].call(this, passed.el, passed.scenario[0], function () {
126
+ if (arguments[0] instanceof Array) {
127
+ var args = arguments[0];
128
+ } else {
129
+ var args = Array.prototype.slice.call(arguments, 0);
130
+ }
131
+
132
+ passed.el.trigger(passed.scenario[1], args);
133
+ });
134
+ }
135
+ }
136
+ }
137
+
138
+ },
139
+
140
+ results : function (uuid, scenarios) {
141
+ var count = scenarios.length;
142
+
143
+ if (count > 0) {
144
+ var el = this.S('[' + this.add_namespace('data-uuid') + '="' + uuid + '"]');
145
+
146
+ while (count--) {
147
+ var mq, rule = scenarios[count][2];
148
+ if (this.settings.named_queries.hasOwnProperty(rule)) {
149
+ mq = matchMedia(this.settings.named_queries[rule]);
150
+ } else {
151
+ mq = matchMedia(rule);
152
+ }
153
+ if (mq.matches) {
154
+ return {el: el, scenario: scenarios[count]};
155
+ }
156
+ }
157
+ }
158
+
159
+ return false;
160
+ },
161
+
162
+ load : function (type, force_update) {
163
+ if (typeof this['cached_' + type] === 'undefined' || force_update) {
164
+ this['update_' + type]();
165
+ }
166
+
167
+ return this['cached_' + type];
168
+ },
169
+
170
+ update_images : function () {
171
+ var images = this.S('img[' + this.data_attr + ']'),
172
+ count = images.length,
173
+ i = count,
174
+ loaded_count = 0,
175
+ data_attr = this.data_attr;
176
+
177
+ this.cache = {};
178
+ this.cached_images = [];
179
+ this.images_loaded = (count === 0);
180
+
181
+ while (i--) {
182
+ loaded_count++;
183
+ if (images[i]) {
184
+ var str = images[i].getAttribute(data_attr) || '';
185
+
186
+ if (str.length > 0) {
187
+ this.cached_images.push(images[i]);
188
+ }
189
+ }
190
+
191
+ if (loaded_count === count) {
192
+ this.images_loaded = true;
193
+ this.enhance('images');
194
+ }
195
+ }
196
+
197
+ return this;
198
+ },
199
+
200
+ update_nodes : function () {
201
+ var nodes = this.S('[' + this.data_attr + ']').not('img'),
202
+ count = nodes.length,
203
+ i = count,
204
+ loaded_count = 0,
205
+ data_attr = this.data_attr;
206
+
207
+ this.cached_nodes = [];
208
+ this.nodes_loaded = (count === 0);
209
+
210
+
211
+ while (i--) {
212
+ loaded_count++;
213
+ var str = nodes[i].getAttribute(data_attr) || '';
214
+
215
+ if (str.length > 0) {
216
+ this.cached_nodes.push(nodes[i]);
217
+ }
218
+
219
+ if(loaded_count === count) {
220
+ this.nodes_loaded = true;
221
+ this.enhance('nodes');
222
+ }
223
+ }
224
+
225
+ return this;
226
+ },
227
+
228
+ enhance : function (type) {
229
+ var i = this['cached_' + type].length;
230
+
231
+ while (i--) {
232
+ this.object($(this['cached_' + type][i]));
233
+ }
234
+
235
+ return $(window).trigger('resize').trigger('resize.fndtn.interchange');
236
+ },
237
+
238
+ convert_directive : function (directive) {
239
+
240
+ var trimmed = this.trim(directive);
241
+
242
+ if (trimmed.length > 0) {
243
+ return trimmed;
244
+ }
245
+
246
+ return 'replace';
247
+ },
248
+
249
+ parse_scenario : function (scenario) {
250
+ // This logic had to be made more complex since some users were using commas in the url path
251
+ // So we cannot simply just split on a comma
252
+ var directive_match = scenario[0].match(/(.+),\s*(\w+)\s*$/),
253
+ media_query = scenario[1];
254
+
255
+ if (directive_match) {
256
+ var path = directive_match[1],
257
+ directive = directive_match[2];
258
+ }
259
+ else {
260
+ var cached_split = scenario[0].split(/,\s*$/),
261
+ path = cached_split[0],
262
+ directive = '';
263
+ }
264
+
265
+ return [this.trim(path), this.convert_directive(directive), this.trim(media_query)];
266
+ },
267
+
268
+ object : function(el) {
269
+ var raw_arr = this.parse_data_attr(el),
270
+ scenarios = [],
271
+ i = raw_arr.length;
272
+
273
+ if (i > 0) {
274
+ while (i--) {
275
+ var split = raw_arr[i].split(/\((.*?)(\))$/);
276
+
277
+ if (split.length > 1) {
278
+ var params = this.parse_scenario(split);
279
+ scenarios.push(params);
280
+ }
281
+ }
282
+ }
283
+
284
+ return this.store(el, scenarios);
285
+ },
286
+
287
+ store : function (el, scenarios) {
288
+ var uuid = this.random_str(),
289
+ current_uuid = el.data(this.add_namespace('uuid', true));
290
+
291
+ if (this.cache[current_uuid]) return this.cache[current_uuid];
292
+
293
+ el.attr(this.add_namespace('data-uuid'), uuid);
294
+
295
+ return this.cache[uuid] = scenarios;
296
+ },
297
+
298
+ trim : function(str) {
299
+
300
+ if (typeof str === 'string') {
301
+ return $.trim(str);
302
+ }
303
+
304
+ return str;
305
+ },
306
+
307
+ set_data_attr: function (init) {
308
+ if (init) {
309
+ if (this.namespace.length > 0) {
310
+ return this.namespace + '-' + this.settings.load_attr;
311
+ }
312
+
313
+ return this.settings.load_attr;
314
+ }
315
+
316
+ if (this.namespace.length > 0) {
317
+ return 'data-' + this.namespace + '-' + this.settings.load_attr;
318
+ }
319
+
320
+ return 'data-' + this.settings.load_attr;
321
+ },
322
+
323
+ parse_data_attr : function (el) {
324
+ var raw = el.attr(this.attr_name()).split(/\[(.*?)\]/),
325
+ i = raw.length,
326
+ output = [];
327
+
328
+ while (i--) {
329
+ if (raw[i].replace(/[\W\d]+/, '').length > 4) {
330
+ output.push(raw[i]);
331
+ }
332
+ }
333
+
334
+ return output;
335
+ },
336
+
337
+ reflow : function () {
338
+ this.load('images', true);
339
+ this.load('nodes', true);
340
+ }
341
+
342
+ };
343
+
344
+ }(jQuery, window, window.document));