aml 0.1.3.2 → 0.1.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/aml-kit +3 -0
- data/lib/aml-kit.rb +11 -0
- data/lib/aml-kit/Build.rb +55 -0
- data/lib/aml-kit/core/bootstrap/3.2.0/css/bootstrap-theme.min.css +6 -0
- data/lib/aml-kit/core/bootstrap/3.2.0/css/bootstrap.min.css +5 -0
- data/lib/aml-kit/core/bootstrap/3.2.0/css/font-awesome.min.css +4 -0
- data/lib/aml-kit/core/bootstrap/3.2.0/fonts/FontAwesome.otf +0 -0
- data/lib/aml-kit/core/bootstrap/3.2.0/fonts/fontawesome-webfont.eot +0 -0
- data/lib/aml-kit/core/bootstrap/3.2.0/fonts/fontawesome-webfont.svg +520 -0
- data/lib/aml-kit/core/bootstrap/3.2.0/fonts/fontawesome-webfont.ttf +0 -0
- data/lib/aml-kit/core/bootstrap/3.2.0/fonts/fontawesome-webfont.woff +0 -0
- data/lib/aml-kit/core/bootstrap/3.2.0/fonts/glyphicons-halflings-regular.eot +0 -0
- data/lib/aml-kit/core/bootstrap/3.2.0/fonts/glyphicons-halflings-regular.svg +229 -0
- data/lib/aml-kit/core/bootstrap/3.2.0/fonts/glyphicons-halflings-regular.ttf +0 -0
- data/lib/aml-kit/core/bootstrap/3.2.0/fonts/glyphicons-halflings-regular.woff +0 -0
- data/lib/aml-kit/core/bootstrap/3.2.0/index.aml +16 -0
- data/lib/aml-kit/core/bootstrap/3.2.0/js/bootstrap.min.js +6 -0
- data/lib/aml-kit/core/bootstrap/3.2.0/js/html5shiv.min.js +4 -0
- data/lib/aml-kit/core/bootstrap/3.2.0/js/jquery.min.js +4 -0
- data/lib/aml-kit/core/bootstrap/3.2.0/js/respond.min.js +5 -0
- data/lib/aml-kit/core/bootstrap/3.2.0/mixin.aml +11 -0
- data/lib/aml-kit/core/bootstrap/3.2.0/partial/footer.aml +17 -0
- data/lib/aml-kit/core/bootstrap/3.2.0/partial/header.aml +20 -0
- data/lib/aml-kit/core/bootstrap/3.2.0/partial/navigation-top.aml +17 -0
- data/lib/aml-kit/core/foundation/5.3.1/css/foundation.min.css +1 -0
- data/lib/aml-kit/core/foundation/5.3.1/css/normalize.css +425 -0
- data/lib/aml-kit/core/foundation/5.3.1/index.aml +14 -0
- data/lib/aml-kit/core/foundation/5.3.1/js/foundation.min.js +10 -0
- data/lib/aml-kit/core/foundation/5.3.1/js/foundation/foundation.abide.js +299 -0
- data/lib/aml-kit/core/foundation/5.3.1/js/foundation/foundation.accordion.js +65 -0
- data/lib/aml-kit/core/foundation/5.3.1/js/foundation/foundation.alert.js +43 -0
- data/lib/aml-kit/core/foundation/5.3.1/js/foundation/foundation.clearing.js +542 -0
- data/lib/aml-kit/core/foundation/5.3.1/js/foundation/foundation.dropdown.js +313 -0
- data/lib/aml-kit/core/foundation/5.3.1/js/foundation/foundation.equalizer.js +74 -0
- data/lib/aml-kit/core/foundation/5.3.1/js/foundation/foundation.interchange.js +344 -0
- data/lib/aml-kit/core/foundation/5.3.1/js/foundation/foundation.joyride.js +846 -0
- data/lib/aml-kit/core/foundation/5.3.1/js/foundation/foundation.js +613 -0
- data/lib/aml-kit/core/foundation/5.3.1/js/foundation/foundation.magellan.js +180 -0
- data/lib/aml-kit/core/foundation/5.3.1/js/foundation/foundation.offcanvas.js +108 -0
- data/lib/aml-kit/core/foundation/5.3.1/js/foundation/foundation.orbit.js +472 -0
- data/lib/aml-kit/core/foundation/5.3.1/js/foundation/foundation.reveal.js +437 -0
- data/lib/aml-kit/core/foundation/5.3.1/js/foundation/foundation.slider.js +226 -0
- data/lib/aml-kit/core/foundation/5.3.1/js/foundation/foundation.tab.js +167 -0
- data/lib/aml-kit/core/foundation/5.3.1/js/foundation/foundation.tooltip.js +298 -0
- data/lib/aml-kit/core/foundation/5.3.1/js/foundation/foundation.topbar.js +426 -0
- data/lib/aml-kit/core/foundation/5.3.1/js/vendor/fastclick.js +9 -0
- data/lib/aml-kit/core/foundation/5.3.1/js/vendor/jquery.cookie.js +8 -0
- data/lib/aml-kit/core/foundation/5.3.1/js/vendor/jquery.js +26 -0
- data/lib/aml-kit/core/foundation/5.3.1/js/vendor/modernizr.js +8 -0
- data/lib/aml-kit/core/foundation/5.3.1/js/vendor/placeholder.js +2 -0
- data/lib/aml-kit/core/foundation/5.3.1/partial/footer.aml +4 -0
- data/lib/aml-kit/core/foundation/5.3.1/partial/header.aml +9 -0
- data/lib/aml.rb +1 -1
- data/lib/aml/Compile.rb +15 -19
- data/lib/aml/Definition.rb +0 -1
- data/lib/aml/Line.rb +1 -1
- data/lib/aml/Prepare.rb +1 -2
- data/lib/aml/core/method.rb +42 -19
- metadata +59 -6
@@ -0,0 +1,313 @@
|
|
1
|
+
;(function ($, window, document, undefined) {
|
2
|
+
'use strict';
|
3
|
+
|
4
|
+
Foundation.libs.dropdown = {
|
5
|
+
name : 'dropdown',
|
6
|
+
|
7
|
+
version : '5.3.0',
|
8
|
+
|
9
|
+
settings : {
|
10
|
+
active_class: 'open',
|
11
|
+
align: 'bottom',
|
12
|
+
is_hover: false,
|
13
|
+
opened: function(){},
|
14
|
+
closed: function(){}
|
15
|
+
},
|
16
|
+
|
17
|
+
init : function (scope, method, options) {
|
18
|
+
Foundation.inherit(this, 'throttle');
|
19
|
+
|
20
|
+
this.bindings(method, options);
|
21
|
+
},
|
22
|
+
|
23
|
+
events : function (scope) {
|
24
|
+
var self = this,
|
25
|
+
S = self.S;
|
26
|
+
|
27
|
+
S(this.scope)
|
28
|
+
.off('.dropdown')
|
29
|
+
.on('click.fndtn.dropdown', '[' + this.attr_name() + ']', function (e) {
|
30
|
+
var settings = S(this).data(self.attr_name(true) + '-init') || self.settings;
|
31
|
+
if (!settings.is_hover || Modernizr.touch) {
|
32
|
+
e.preventDefault();
|
33
|
+
self.toggle($(this));
|
34
|
+
}
|
35
|
+
})
|
36
|
+
.on('mouseenter.fndtn.dropdown', '[' + this.attr_name() + '], [' + this.attr_name() + '-content]', function (e) {
|
37
|
+
var $this = S(this),
|
38
|
+
dropdown,
|
39
|
+
target;
|
40
|
+
|
41
|
+
clearTimeout(self.timeout);
|
42
|
+
|
43
|
+
if ($this.data(self.data_attr())) {
|
44
|
+
dropdown = S('#' + $this.data(self.data_attr()));
|
45
|
+
target = $this;
|
46
|
+
} else {
|
47
|
+
dropdown = $this;
|
48
|
+
target = S("[" + self.attr_name() + "='" + dropdown.attr('id') + "']");
|
49
|
+
}
|
50
|
+
|
51
|
+
var settings = target.data(self.attr_name(true) + '-init') || self.settings;
|
52
|
+
|
53
|
+
if(S(e.target).data(self.data_attr()) && settings.is_hover) {
|
54
|
+
self.closeall.call(self);
|
55
|
+
}
|
56
|
+
|
57
|
+
if (settings.is_hover) self.open.apply(self, [dropdown, target]);
|
58
|
+
})
|
59
|
+
.on('mouseleave.fndtn.dropdown', '[' + this.attr_name() + '], [' + this.attr_name() + '-content]', function (e) {
|
60
|
+
var $this = S(this);
|
61
|
+
self.timeout = setTimeout(function () {
|
62
|
+
if ($this.data(self.data_attr())) {
|
63
|
+
var settings = $this.data(self.data_attr(true) + '-init') || self.settings;
|
64
|
+
if (settings.is_hover) self.close.call(self, S('#' + $this.data(self.data_attr())));
|
65
|
+
} else {
|
66
|
+
var target = S('[' + self.attr_name() + '="' + S(this).attr('id') + '"]'),
|
67
|
+
settings = target.data(self.attr_name(true) + '-init') || self.settings;
|
68
|
+
if (settings.is_hover) self.close.call(self, $this);
|
69
|
+
}
|
70
|
+
}.bind(this), 150);
|
71
|
+
})
|
72
|
+
.on('click.fndtn.dropdown', function (e) {
|
73
|
+
var parent = S(e.target).closest('[' + self.attr_name() + '-content]');
|
74
|
+
|
75
|
+
if (S(e.target).data(self.data_attr()) || S(e.target).parent().data(self.data_attr())) {
|
76
|
+
return;
|
77
|
+
}
|
78
|
+
if (!(S(e.target).data('revealId')) &&
|
79
|
+
(parent.length > 0 && (S(e.target).is('[' + self.attr_name() + '-content]') ||
|
80
|
+
$.contains(parent.first()[0], e.target)))) {
|
81
|
+
e.stopPropagation();
|
82
|
+
return;
|
83
|
+
}
|
84
|
+
|
85
|
+
self.close.call(self, S('[' + self.attr_name() + '-content]'));
|
86
|
+
})
|
87
|
+
.on('opened.fndtn.dropdown', '[' + self.attr_name() + '-content]', function () {
|
88
|
+
self.settings.opened.call(this);
|
89
|
+
})
|
90
|
+
.on('closed.fndtn.dropdown', '[' + self.attr_name() + '-content]', function () {
|
91
|
+
self.settings.closed.call(this);
|
92
|
+
});
|
93
|
+
|
94
|
+
S(window)
|
95
|
+
.off('.dropdown')
|
96
|
+
.on('resize.fndtn.dropdown', self.throttle(function () {
|
97
|
+
self.resize.call(self);
|
98
|
+
}, 50));
|
99
|
+
|
100
|
+
this.resize();
|
101
|
+
},
|
102
|
+
|
103
|
+
close: function (dropdown) {
|
104
|
+
var self = this;
|
105
|
+
dropdown.each(function () {
|
106
|
+
if (self.S(this).hasClass(self.settings.active_class)) {
|
107
|
+
self.S(this)
|
108
|
+
.css(Foundation.rtl ? 'right':'left', '-99999px')
|
109
|
+
.removeClass(self.settings.active_class)
|
110
|
+
.prev('[' + self.attr_name() + ']')
|
111
|
+
.removeClass(self.settings.active_class)
|
112
|
+
.removeData('target');
|
113
|
+
|
114
|
+
self.S(this).trigger('closed').trigger('closed.fndtn.dropdown', [dropdown]);
|
115
|
+
}
|
116
|
+
});
|
117
|
+
},
|
118
|
+
|
119
|
+
closeall: function() {
|
120
|
+
var self = this;
|
121
|
+
$.each(self.S('[' + this.attr_name() + '-content]'), function() {
|
122
|
+
self.close.call(self, self.S(this))
|
123
|
+
});
|
124
|
+
},
|
125
|
+
|
126
|
+
open: function (dropdown, target) {
|
127
|
+
this
|
128
|
+
.css(dropdown
|
129
|
+
.addClass(this.settings.active_class), target);
|
130
|
+
dropdown.prev('[' + this.attr_name() + ']').addClass(this.settings.active_class);
|
131
|
+
dropdown.data('target', target.get(0)).trigger('opened').trigger('opened.fndtn.dropdown', [dropdown, target]);
|
132
|
+
},
|
133
|
+
|
134
|
+
data_attr: function () {
|
135
|
+
if (this.namespace.length > 0) {
|
136
|
+
return this.namespace + '-' + this.name;
|
137
|
+
}
|
138
|
+
|
139
|
+
return this.name;
|
140
|
+
},
|
141
|
+
|
142
|
+
toggle : function (target) {
|
143
|
+
var dropdown = this.S('#' + target.data(this.data_attr()));
|
144
|
+
if (dropdown.length === 0) {
|
145
|
+
// No dropdown found, not continuing
|
146
|
+
return;
|
147
|
+
}
|
148
|
+
|
149
|
+
this.close.call(this, this.S('[' + this.attr_name() + '-content]').not(dropdown));
|
150
|
+
|
151
|
+
if (dropdown.hasClass(this.settings.active_class)) {
|
152
|
+
this.close.call(this, dropdown);
|
153
|
+
if (dropdown.data('target') !== target.get(0))
|
154
|
+
this.open.call(this, dropdown, target);
|
155
|
+
} else {
|
156
|
+
this.open.call(this, dropdown, target);
|
157
|
+
}
|
158
|
+
},
|
159
|
+
|
160
|
+
resize : function () {
|
161
|
+
var dropdown = this.S('[' + this.attr_name() + '-content].open'),
|
162
|
+
target = this.S("[" + this.attr_name() + "='" + dropdown.attr('id') + "']");
|
163
|
+
|
164
|
+
if (dropdown.length && target.length) {
|
165
|
+
this.css(dropdown, target);
|
166
|
+
}
|
167
|
+
},
|
168
|
+
|
169
|
+
css : function (dropdown, target) {
|
170
|
+
var left_offset = Math.max((target.width() - dropdown.width()) / 2, 8);
|
171
|
+
|
172
|
+
this.clear_idx();
|
173
|
+
|
174
|
+
if (this.small()) {
|
175
|
+
var p = this.dirs.bottom.call(dropdown, target);
|
176
|
+
|
177
|
+
dropdown.attr('style', '').removeClass('drop-left drop-right drop-top').css({
|
178
|
+
position : 'absolute',
|
179
|
+
width: '95%',
|
180
|
+
'max-width': 'none',
|
181
|
+
top: p.top
|
182
|
+
});
|
183
|
+
|
184
|
+
dropdown.css(Foundation.rtl ? 'right':'left', left_offset);
|
185
|
+
} else {
|
186
|
+
var settings = target.data(this.attr_name(true) + '-init') || this.settings;
|
187
|
+
|
188
|
+
this.style(dropdown, target, settings);
|
189
|
+
}
|
190
|
+
|
191
|
+
return dropdown;
|
192
|
+
},
|
193
|
+
|
194
|
+
style : function (dropdown, target, settings) {
|
195
|
+
var css = $.extend({position: 'absolute'},
|
196
|
+
this.dirs[settings.align].call(dropdown, target, settings));
|
197
|
+
|
198
|
+
dropdown.attr('style', '').css(css);
|
199
|
+
},
|
200
|
+
|
201
|
+
// return CSS property object
|
202
|
+
// `this` is the dropdown
|
203
|
+
dirs : {
|
204
|
+
// Calculate target offset
|
205
|
+
_base : function (t) {
|
206
|
+
var o_p = this.offsetParent(),
|
207
|
+
o = o_p.offset(),
|
208
|
+
p = t.offset();
|
209
|
+
|
210
|
+
p.top -= o.top;
|
211
|
+
p.left -= o.left;
|
212
|
+
|
213
|
+
return p;
|
214
|
+
},
|
215
|
+
top: function (t, s) {
|
216
|
+
var self = Foundation.libs.dropdown,
|
217
|
+
p = self.dirs._base.call(this, t),
|
218
|
+
pip_offset_base = 8;
|
219
|
+
|
220
|
+
this.addClass('drop-top');
|
221
|
+
|
222
|
+
if (t.outerWidth() < this.outerWidth() || self.small()) {
|
223
|
+
self.adjust_pip(pip_offset_base, p);
|
224
|
+
}
|
225
|
+
|
226
|
+
if (Foundation.rtl) {
|
227
|
+
return {left: p.left - this.outerWidth() + t.outerWidth(),
|
228
|
+
top: p.top - this.outerHeight()};
|
229
|
+
}
|
230
|
+
|
231
|
+
return {left: p.left, top: p.top - this.outerHeight()};
|
232
|
+
},
|
233
|
+
bottom: function (t, s) {
|
234
|
+
var self = Foundation.libs.dropdown,
|
235
|
+
p = self.dirs._base.call(this, t),
|
236
|
+
pip_offset_base = 8;
|
237
|
+
|
238
|
+
if (t.outerWidth() < this.outerWidth() || self.small()) {
|
239
|
+
self.adjust_pip(pip_offset_base, p);
|
240
|
+
}
|
241
|
+
|
242
|
+
if (self.rtl) {
|
243
|
+
return {left: p.left - this.outerWidth() + t.outerWidth(), top: p.top + t.outerHeight()};
|
244
|
+
}
|
245
|
+
|
246
|
+
return {left: p.left, top: p.top + t.outerHeight()};
|
247
|
+
},
|
248
|
+
left: function (t, s) {
|
249
|
+
var p = Foundation.libs.dropdown.dirs._base.call(this, t);
|
250
|
+
|
251
|
+
this.addClass('drop-left');
|
252
|
+
|
253
|
+
return {left: p.left - this.outerWidth(), top: p.top};
|
254
|
+
},
|
255
|
+
right: function (t, s) {
|
256
|
+
var p = Foundation.libs.dropdown.dirs._base.call(this, t);
|
257
|
+
|
258
|
+
this.addClass('drop-right');
|
259
|
+
|
260
|
+
return {left: p.left + t.outerWidth(), top: p.top};
|
261
|
+
}
|
262
|
+
},
|
263
|
+
|
264
|
+
// Insert rule to style psuedo elements
|
265
|
+
adjust_pip : function (pip_offset_base, p) {
|
266
|
+
var sheet = Foundation.stylesheet;
|
267
|
+
|
268
|
+
if (this.small()) {
|
269
|
+
pip_offset_base += p.left - 8;
|
270
|
+
}
|
271
|
+
|
272
|
+
this.rule_idx = sheet.cssRules.length;
|
273
|
+
|
274
|
+
var sel_before = '.f-dropdown.open:before',
|
275
|
+
sel_after = '.f-dropdown.open:after',
|
276
|
+
css_before = 'left: ' + pip_offset_base + 'px;',
|
277
|
+
css_after = 'left: ' + (pip_offset_base - 1) + 'px;';
|
278
|
+
|
279
|
+
if (sheet.insertRule) {
|
280
|
+
sheet.insertRule([sel_before, '{', css_before, '}'].join(' '), this.rule_idx);
|
281
|
+
sheet.insertRule([sel_after, '{', css_after, '}'].join(' '), this.rule_idx + 1);
|
282
|
+
} else {
|
283
|
+
sheet.addRule(sel_before, css_before, this.rule_idx);
|
284
|
+
sheet.addRule(sel_after, css_after, this.rule_idx + 1);
|
285
|
+
}
|
286
|
+
},
|
287
|
+
|
288
|
+
// Remove old dropdown rule index
|
289
|
+
clear_idx : function () {
|
290
|
+
var sheet = Foundation.stylesheet;
|
291
|
+
|
292
|
+
if (this.rule_idx) {
|
293
|
+
sheet.deleteRule(this.rule_idx);
|
294
|
+
sheet.deleteRule(this.rule_idx);
|
295
|
+
delete this.rule_idx;
|
296
|
+
}
|
297
|
+
},
|
298
|
+
|
299
|
+
small : function () {
|
300
|
+
return matchMedia(Foundation.media_queries.small).matches &&
|
301
|
+
!matchMedia(Foundation.media_queries.medium).matches;
|
302
|
+
},
|
303
|
+
|
304
|
+
off: function () {
|
305
|
+
this.S(this.scope).off('.fndtn.dropdown');
|
306
|
+
this.S('html, body').off('.fndtn.dropdown');
|
307
|
+
this.S(window).off('.fndtn.dropdown');
|
308
|
+
this.S('[data-dropdown-content]').off('.fndtn.dropdown');
|
309
|
+
},
|
310
|
+
|
311
|
+
reflow : function () {}
|
312
|
+
};
|
313
|
+
}(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.3.0',
|
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.3.0',
|
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));
|