foundation_front_end 0.1.0

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.
Files changed (38) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +21 -0
  5. data/README.md +64 -0
  6. data/Rakefile +1 -0
  7. data/bin/console +14 -0
  8. data/bin/setup +7 -0
  9. data/foundation_front_end.gemspec +32 -0
  10. data/lib/foundation_front_end.rb +21 -0
  11. data/lib/foundation_front_end/version.rb +3 -0
  12. data/vendor/assets/javascripts/foundation.min.js +6376 -0
  13. data/vendor/assets/javascripts/foundation/foundation.abide.js +408 -0
  14. data/vendor/assets/javascripts/foundation/foundation.accordion.js +88 -0
  15. data/vendor/assets/javascripts/foundation/foundation.alert.js +43 -0
  16. data/vendor/assets/javascripts/foundation/foundation.clearing.js +586 -0
  17. data/vendor/assets/javascripts/foundation/foundation.dropdown.js +463 -0
  18. data/vendor/assets/javascripts/foundation/foundation.equalizer.js +104 -0
  19. data/vendor/assets/javascripts/foundation/foundation.interchange.js +359 -0
  20. data/vendor/assets/javascripts/foundation/foundation.joyride.js +932 -0
  21. data/vendor/assets/javascripts/foundation/foundation.js +725 -0
  22. data/vendor/assets/javascripts/foundation/foundation.magellan.js +215 -0
  23. data/vendor/assets/javascripts/foundation/foundation.offcanvas.js +152 -0
  24. data/vendor/assets/javascripts/foundation/foundation.orbit.js +476 -0
  25. data/vendor/assets/javascripts/foundation/foundation.reveal.js +498 -0
  26. data/vendor/assets/javascripts/foundation/foundation.slider.js +281 -0
  27. data/vendor/assets/javascripts/foundation/foundation.tab.js +249 -0
  28. data/vendor/assets/javascripts/foundation/foundation.tooltip.js +339 -0
  29. data/vendor/assets/javascripts/foundation/foundation.topbar.js +458 -0
  30. data/vendor/assets/javascripts/vendor/fastclick.js +8 -0
  31. data/vendor/assets/javascripts/vendor/jquery.cookie.js +8 -0
  32. data/vendor/assets/javascripts/vendor/jquery.js +27 -0
  33. data/vendor/assets/javascripts/vendor/modernizr.js +8 -0
  34. data/vendor/assets/javascripts/vendor/placeholder.js +2 -0
  35. data/vendor/assets/stylesheets/foundation.css +6324 -0
  36. data/vendor/assets/stylesheets/foundation.min.css +1 -0
  37. data/vendor/assets/stylesheets/normalize.css +424 -0
  38. metadata +110 -0
@@ -0,0 +1,498 @@
1
+ ;(function ($, window, document, undefined) {
2
+ 'use strict';
3
+
4
+ Foundation.libs.reveal = {
5
+ name : 'reveal',
6
+
7
+ version : '5.5.2',
8
+
9
+ locked : false,
10
+
11
+ settings : {
12
+ animation : 'fadeAndPop',
13
+ animation_speed : 250,
14
+ close_on_background_click : true,
15
+ close_on_esc : true,
16
+ dismiss_modal_class : 'close-reveal-modal',
17
+ multiple_opened : false,
18
+ bg_class : 'reveal-modal-bg',
19
+ root_element : 'body',
20
+ open : function(){},
21
+ opened : function(){},
22
+ close : function(){},
23
+ closed : function(){},
24
+ on_ajax_error: $.noop,
25
+ bg : $('.reveal-modal-bg'),
26
+ css : {
27
+ open : {
28
+ 'opacity' : 0,
29
+ 'visibility' : 'visible',
30
+ 'display' : 'block'
31
+ },
32
+ close : {
33
+ 'opacity' : 1,
34
+ 'visibility' : 'hidden',
35
+ 'display' : 'none'
36
+ }
37
+ }
38
+ },
39
+
40
+ init : function (scope, method, options) {
41
+ $.extend(true, this.settings, method, options);
42
+ this.bindings(method, options);
43
+ },
44
+
45
+ events : function (scope) {
46
+ var self = this,
47
+ S = self.S;
48
+
49
+ S(this.scope)
50
+ .off('.reveal')
51
+ .on('click.fndtn.reveal', '[' + this.add_namespace('data-reveal-id') + ']:not([disabled])', function (e) {
52
+ e.preventDefault();
53
+
54
+ if (!self.locked) {
55
+ var element = S(this),
56
+ ajax = element.data(self.data_attr('reveal-ajax')),
57
+ replaceContentSel = element.data(self.data_attr('reveal-replace-content'));
58
+
59
+ self.locked = true;
60
+
61
+ if (typeof ajax === 'undefined') {
62
+ self.open.call(self, element);
63
+ } else {
64
+ var url = ajax === true ? element.attr('href') : ajax;
65
+ self.open.call(self, element, {url : url}, { replaceContentSel : replaceContentSel });
66
+ }
67
+ }
68
+ });
69
+
70
+ S(document)
71
+ .on('click.fndtn.reveal', this.close_targets(), function (e) {
72
+ e.preventDefault();
73
+ if (!self.locked) {
74
+ var settings = S('[' + self.attr_name() + '].open').data(self.attr_name(true) + '-init') || self.settings,
75
+ bg_clicked = S(e.target)[0] === S('.' + settings.bg_class)[0];
76
+
77
+ if (bg_clicked) {
78
+ if (settings.close_on_background_click) {
79
+ e.stopPropagation();
80
+ } else {
81
+ return;
82
+ }
83
+ }
84
+
85
+ self.locked = true;
86
+ self.close.call(self, bg_clicked ? S('[' + self.attr_name() + '].open:not(.toback)') : S(this).closest('[' + self.attr_name() + ']'));
87
+ }
88
+ });
89
+
90
+ if (S('[' + self.attr_name() + ']', this.scope).length > 0) {
91
+ S(this.scope)
92
+ // .off('.reveal')
93
+ .on('open.fndtn.reveal', this.settings.open)
94
+ .on('opened.fndtn.reveal', this.settings.opened)
95
+ .on('opened.fndtn.reveal', this.open_video)
96
+ .on('close.fndtn.reveal', this.settings.close)
97
+ .on('closed.fndtn.reveal', this.settings.closed)
98
+ .on('closed.fndtn.reveal', this.close_video);
99
+ } else {
100
+ S(this.scope)
101
+ // .off('.reveal')
102
+ .on('open.fndtn.reveal', '[' + self.attr_name() + ']', this.settings.open)
103
+ .on('opened.fndtn.reveal', '[' + self.attr_name() + ']', this.settings.opened)
104
+ .on('opened.fndtn.reveal', '[' + self.attr_name() + ']', this.open_video)
105
+ .on('close.fndtn.reveal', '[' + self.attr_name() + ']', this.settings.close)
106
+ .on('closed.fndtn.reveal', '[' + self.attr_name() + ']', this.settings.closed)
107
+ .on('closed.fndtn.reveal', '[' + self.attr_name() + ']', this.close_video);
108
+ }
109
+
110
+ return true;
111
+ },
112
+
113
+ // PATCH #3: turning on key up capture only when a reveal window is open
114
+ key_up_on : function (scope) {
115
+ var self = this;
116
+
117
+ // PATCH #1: fixing multiple keyup event trigger from single key press
118
+ self.S('body').off('keyup.fndtn.reveal').on('keyup.fndtn.reveal', function ( event ) {
119
+ var open_modal = self.S('[' + self.attr_name() + '].open'),
120
+ settings = open_modal.data(self.attr_name(true) + '-init') || self.settings ;
121
+ // PATCH #2: making sure that the close event can be called only while unlocked,
122
+ // so that multiple keyup.fndtn.reveal events don't prevent clean closing of the reveal window.
123
+ if ( settings && event.which === 27 && settings.close_on_esc && !self.locked) { // 27 is the keycode for the Escape key
124
+ self.close.call(self, open_modal);
125
+ }
126
+ });
127
+
128
+ return true;
129
+ },
130
+
131
+ // PATCH #3: turning on key up capture only when a reveal window is open
132
+ key_up_off : function (scope) {
133
+ this.S('body').off('keyup.fndtn.reveal');
134
+ return true;
135
+ },
136
+
137
+ open : function (target, ajax_settings) {
138
+ var self = this,
139
+ modal;
140
+
141
+ if (target) {
142
+ if (typeof target.selector !== 'undefined') {
143
+ // Find the named node; only use the first one found, since the rest of the code assumes there's only one node
144
+ modal = self.S('#' + target.data(self.data_attr('reveal-id'))).first();
145
+ } else {
146
+ modal = self.S(this.scope);
147
+
148
+ ajax_settings = target;
149
+ }
150
+ } else {
151
+ modal = self.S(this.scope);
152
+ }
153
+
154
+ var settings = modal.data(self.attr_name(true) + '-init');
155
+ settings = settings || this.settings;
156
+
157
+
158
+ if (modal.hasClass('open') && target.attr('data-reveal-id') == modal.attr('id')) {
159
+ return self.close(modal);
160
+ }
161
+
162
+ if (!modal.hasClass('open')) {
163
+ var open_modal = self.S('[' + self.attr_name() + '].open');
164
+
165
+ if (typeof modal.data('css-top') === 'undefined') {
166
+ modal.data('css-top', parseInt(modal.css('top'), 10))
167
+ .data('offset', this.cache_offset(modal));
168
+ }
169
+
170
+ modal.attr('tabindex','0').attr('aria-hidden','false');
171
+
172
+ this.key_up_on(modal); // PATCH #3: turning on key up capture only when a reveal window is open
173
+
174
+ // Prevent namespace event from triggering twice
175
+ modal.on('open.fndtn.reveal', function(e) {
176
+ if (e.namespace !== 'fndtn.reveal') return;
177
+ });
178
+
179
+ modal.on('open.fndtn.reveal').trigger('open.fndtn.reveal');
180
+
181
+ if (open_modal.length < 1) {
182
+ this.toggle_bg(modal, true);
183
+ }
184
+
185
+ if (typeof ajax_settings === 'string') {
186
+ ajax_settings = {
187
+ url : ajax_settings
188
+ };
189
+ }
190
+
191
+ if (typeof ajax_settings === 'undefined' || !ajax_settings.url) {
192
+ if (open_modal.length > 0) {
193
+ if (settings.multiple_opened) {
194
+ self.to_back(open_modal);
195
+ } else {
196
+ self.hide(open_modal, settings.css.close);
197
+ }
198
+ }
199
+
200
+ this.show(modal, settings.css.open);
201
+ } else {
202
+ var old_success = typeof ajax_settings.success !== 'undefined' ? ajax_settings.success : null;
203
+ $.extend(ajax_settings, {
204
+ success : function (data, textStatus, jqXHR) {
205
+ if ( $.isFunction(old_success) ) {
206
+ var result = old_success(data, textStatus, jqXHR);
207
+ if (typeof result == 'string') {
208
+ data = result;
209
+ }
210
+ }
211
+
212
+ if (typeof options !== 'undefined' && typeof options.replaceContentSel !== 'undefined') {
213
+ modal.find(options.replaceContentSel).html(data);
214
+ } else {
215
+ modal.html(data);
216
+ }
217
+
218
+ self.S(modal).foundation('section', 'reflow');
219
+ self.S(modal).children().foundation();
220
+
221
+ if (open_modal.length > 0) {
222
+ if (settings.multiple_opened) {
223
+ self.to_back(open_modal);
224
+ } else {
225
+ self.hide(open_modal, settings.css.close);
226
+ }
227
+ }
228
+ self.show(modal, settings.css.open);
229
+ }
230
+ });
231
+
232
+ // check for if user initalized with error callback
233
+ if (settings.on_ajax_error !== $.noop) {
234
+ $.extend(ajax_settings, {
235
+ error : settings.on_ajax_error
236
+ });
237
+ }
238
+
239
+ $.ajax(ajax_settings);
240
+ }
241
+ }
242
+ self.S(window).trigger('resize');
243
+ },
244
+
245
+ close : function (modal) {
246
+ var modal = modal && modal.length ? modal : this.S(this.scope),
247
+ open_modals = this.S('[' + this.attr_name() + '].open'),
248
+ settings = modal.data(this.attr_name(true) + '-init') || this.settings,
249
+ self = this;
250
+
251
+ if (open_modals.length > 0) {
252
+
253
+ modal.removeAttr('tabindex','0').attr('aria-hidden','true');
254
+
255
+ this.locked = true;
256
+ this.key_up_off(modal); // PATCH #3: turning on key up capture only when a reveal window is open
257
+
258
+ modal.trigger('close.fndtn.reveal');
259
+
260
+ if ((settings.multiple_opened && open_modals.length === 1) || !settings.multiple_opened || modal.length > 1) {
261
+ self.toggle_bg(modal, false);
262
+ self.to_front(modal);
263
+ }
264
+
265
+ if (settings.multiple_opened) {
266
+ self.hide(modal, settings.css.close, settings);
267
+ self.to_front($($.makeArray(open_modals).reverse()[1]));
268
+ } else {
269
+ self.hide(open_modals, settings.css.close, settings);
270
+ }
271
+ }
272
+ },
273
+
274
+ close_targets : function () {
275
+ var base = '.' + this.settings.dismiss_modal_class;
276
+
277
+ if (this.settings.close_on_background_click) {
278
+ return base + ', .' + this.settings.bg_class;
279
+ }
280
+
281
+ return base;
282
+ },
283
+
284
+ toggle_bg : function (modal, state) {
285
+ if (this.S('.' + this.settings.bg_class).length === 0) {
286
+ this.settings.bg = $('<div />', {'class': this.settings.bg_class})
287
+ .appendTo('body').hide();
288
+ }
289
+
290
+ var visible = this.settings.bg.filter(':visible').length > 0;
291
+ if ( state != visible ) {
292
+ if ( state == undefined ? visible : !state ) {
293
+ this.hide(this.settings.bg);
294
+ } else {
295
+ this.show(this.settings.bg);
296
+ }
297
+ }
298
+ },
299
+
300
+ show : function (el, css) {
301
+ // is modal
302
+ if (css) {
303
+ var settings = el.data(this.attr_name(true) + '-init') || this.settings,
304
+ root_element = settings.root_element,
305
+ context = this;
306
+
307
+ if (el.parent(root_element).length === 0) {
308
+ var placeholder = el.wrap('<div style="display: none;" />').parent();
309
+
310
+ el.on('closed.fndtn.reveal.wrapped', function () {
311
+ el.detach().appendTo(placeholder);
312
+ el.unwrap().unbind('closed.fndtn.reveal.wrapped');
313
+ });
314
+
315
+ el.detach().appendTo(root_element);
316
+ }
317
+
318
+ var animData = getAnimationData(settings.animation);
319
+ if (!animData.animate) {
320
+ this.locked = false;
321
+ }
322
+ if (animData.pop) {
323
+ css.top = $(window).scrollTop() - el.data('offset') + 'px';
324
+ var end_css = {
325
+ top: $(window).scrollTop() + el.data('css-top') + 'px',
326
+ opacity: 1
327
+ };
328
+
329
+ return setTimeout(function () {
330
+ return el
331
+ .css(css)
332
+ .animate(end_css, settings.animation_speed, 'linear', function () {
333
+ context.locked = false;
334
+ el.trigger('opened.fndtn.reveal');
335
+ })
336
+ .addClass('open');
337
+ }, settings.animation_speed / 2);
338
+ }
339
+
340
+ if (animData.fade) {
341
+ css.top = $(window).scrollTop() + el.data('css-top') + 'px';
342
+ var end_css = {opacity: 1};
343
+
344
+ return setTimeout(function () {
345
+ return el
346
+ .css(css)
347
+ .animate(end_css, settings.animation_speed, 'linear', function () {
348
+ context.locked = false;
349
+ el.trigger('opened.fndtn.reveal');
350
+ })
351
+ .addClass('open');
352
+ }, settings.animation_speed / 2);
353
+ }
354
+
355
+ return el.css(css).show().css({opacity : 1}).addClass('open').trigger('opened.fndtn.reveal');
356
+ }
357
+
358
+ var settings = this.settings;
359
+
360
+ // should we animate the background?
361
+ if (getAnimationData(settings.animation).fade) {
362
+ return el.fadeIn(settings.animation_speed / 2);
363
+ }
364
+
365
+ this.locked = false;
366
+
367
+ return el.show();
368
+ },
369
+
370
+ to_back : function(el) {
371
+ el.addClass('toback');
372
+ },
373
+
374
+ to_front : function(el) {
375
+ el.removeClass('toback');
376
+ },
377
+
378
+ hide : function (el, css) {
379
+ // is modal
380
+ if (css) {
381
+ var settings = el.data(this.attr_name(true) + '-init'),
382
+ context = this;
383
+ settings = settings || this.settings;
384
+
385
+ var animData = getAnimationData(settings.animation);
386
+ if (!animData.animate) {
387
+ this.locked = false;
388
+ }
389
+ if (animData.pop) {
390
+ var end_css = {
391
+ top: - $(window).scrollTop() - el.data('offset') + 'px',
392
+ opacity: 0
393
+ };
394
+
395
+ return setTimeout(function () {
396
+ return el
397
+ .animate(end_css, settings.animation_speed, 'linear', function () {
398
+ context.locked = false;
399
+ el.css(css).trigger('closed.fndtn.reveal');
400
+ })
401
+ .removeClass('open');
402
+ }, settings.animation_speed / 2);
403
+ }
404
+
405
+ if (animData.fade) {
406
+ var end_css = {opacity : 0};
407
+
408
+ return setTimeout(function () {
409
+ return el
410
+ .animate(end_css, settings.animation_speed, 'linear', function () {
411
+ context.locked = false;
412
+ el.css(css).trigger('closed.fndtn.reveal');
413
+ })
414
+ .removeClass('open');
415
+ }, settings.animation_speed / 2);
416
+ }
417
+
418
+ return el.hide().css(css).removeClass('open').trigger('closed.fndtn.reveal');
419
+ }
420
+
421
+ var settings = this.settings;
422
+
423
+ // should we animate the background?
424
+ if (getAnimationData(settings.animation).fade) {
425
+ return el.fadeOut(settings.animation_speed / 2);
426
+ }
427
+
428
+ return el.hide();
429
+ },
430
+
431
+ close_video : function (e) {
432
+ var video = $('.flex-video', e.target),
433
+ iframe = $('iframe', video);
434
+
435
+ if (iframe.length > 0) {
436
+ iframe.attr('data-src', iframe[0].src);
437
+ iframe.attr('src', iframe.attr('src'));
438
+ video.hide();
439
+ }
440
+ },
441
+
442
+ open_video : function (e) {
443
+ var video = $('.flex-video', e.target),
444
+ iframe = video.find('iframe');
445
+
446
+ if (iframe.length > 0) {
447
+ var data_src = iframe.attr('data-src');
448
+ if (typeof data_src === 'string') {
449
+ iframe[0].src = iframe.attr('data-src');
450
+ } else {
451
+ var src = iframe[0].src;
452
+ iframe[0].src = undefined;
453
+ iframe[0].src = src;
454
+ }
455
+ video.show();
456
+ }
457
+ },
458
+
459
+ data_attr : function (str) {
460
+ if (this.namespace.length > 0) {
461
+ return this.namespace + '-' + str;
462
+ }
463
+
464
+ return str;
465
+ },
466
+
467
+ cache_offset : function (modal) {
468
+ var offset = modal.show().height() + parseInt(modal.css('top'), 10) + modal.scrollY;
469
+
470
+ modal.hide();
471
+
472
+ return offset;
473
+ },
474
+
475
+ off : function () {
476
+ $(this.scope).off('.fndtn.reveal');
477
+ },
478
+
479
+ reflow : function () {}
480
+ };
481
+
482
+ /*
483
+ * getAnimationData('popAndFade') // {animate: true, pop: true, fade: true}
484
+ * getAnimationData('fade') // {animate: true, pop: false, fade: true}
485
+ * getAnimationData('pop') // {animate: true, pop: true, fade: false}
486
+ * getAnimationData('foo') // {animate: false, pop: false, fade: false}
487
+ * getAnimationData(null) // {animate: false, pop: false, fade: false}
488
+ */
489
+ function getAnimationData(str) {
490
+ var fade = /fade/i.test(str);
491
+ var pop = /pop/i.test(str);
492
+ return {
493
+ animate : fade || pop,
494
+ pop : pop,
495
+ fade : fade
496
+ };
497
+ }
498
+ }(jQuery, window, window.document));