locomotivecms_wagon 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +27 -0
- data/.rspec +2 -0
- data/Gemfile +8 -0
- data/LICENSE.txt +22 -0
- data/README.md +68 -0
- data/Rakefile +57 -0
- data/TODO +57 -0
- data/bin/wagon +9 -0
- data/generators/blank/Gemfile.tt +20 -0
- data/generators/blank/app/content_types/.empty_directory +1 -0
- data/generators/blank/app/views/pages/404.liquid +11 -0
- data/generators/blank/app/views/pages/index.liquid +19 -0
- data/generators/blank/app/views/snippets/.empty_directory +1 -0
- data/generators/blank/config/deploy.yml +12 -0
- data/generators/blank/config/site.yml.tt +16 -0
- data/generators/blank/config/translations.yml +8 -0
- data/generators/blank/config.ru +3 -0
- data/generators/blank/data/.empty_directory +1 -0
- data/generators/blank/public/fonts/.empty_directory +1 -0
- data/generators/blank/public/images/.empty_directory +1 -0
- data/generators/blank/public/javascripts/.empty_directory +1 -0
- data/generators/blank/public/samples/.empty_directory +1 -0
- data/generators/blank/public/stylesheets/.empty_directory +1 -0
- data/generators/bootstrap/Gemfile.tt +20 -0
- data/generators/bootstrap/app/content_types/.empty_directory +1 -0
- data/generators/bootstrap/app/views/pages/404.liquid +13 -0
- data/generators/bootstrap/app/views/pages/404.liquid.haml +10 -0
- data/generators/bootstrap/app/views/pages/index.liquid +89 -0
- data/generators/bootstrap/app/views/pages/index.liquid.haml +72 -0
- data/generators/bootstrap/app/views/snippets/footer.liquid +3 -0
- data/generators/bootstrap/app/views/snippets/footer.liquid.haml +2 -0
- data/generators/bootstrap/config/deploy.yml +12 -0
- data/generators/bootstrap/config/site.yml.tt +16 -0
- data/generators/bootstrap/config/translations.yml +8 -0
- data/generators/bootstrap/config.ru +3 -0
- data/generators/bootstrap/data/.empty_directory +1 -0
- data/generators/bootstrap/public/fonts/FontAwesome.otf +0 -0
- data/generators/bootstrap/public/fonts/font-awesome-ie7.min.css +23 -0
- data/generators/bootstrap/public/fonts/font-awesome.css +469 -0
- data/generators/bootstrap/public/fonts/font-awesome.min.css +34 -0
- data/generators/bootstrap/public/fonts/fontawesome-webfont.eot +0 -0
- data/generators/bootstrap/public/fonts/fontawesome-webfont.ttf +0 -0
- data/generators/bootstrap/public/fonts/fontawesome-webfont.woff +0 -0
- data/generators/bootstrap/public/javascripts/bootstrap.js +2159 -0
- data/generators/bootstrap/public/javascripts/bootstrap.min.js +6 -0
- data/generators/bootstrap/public/samples/.empty_directory +1 -0
- data/generators/bootstrap/public/stylesheets/application.css.scss +39 -0
- data/generators/bootstrap/public/stylesheets/bootstrap-responsive.css +1092 -0
- data/generators/bootstrap/public/stylesheets/bootstrap-responsive.min.css +9 -0
- data/generators/bootstrap/public/stylesheets/bootstrap.css +5652 -0
- data/generators/bootstrap/public/stylesheets/bootstrap.min.css +726 -0
- data/generators/content_type/app/content_types/%name%.yml.tt +58 -0
- data/generators/content_type/data/%name%.yml.tt +24 -0
- data/generators/foundation/Gemfile.tt +20 -0
- data/generators/foundation/app/content_types/.empty_directory +1 -0
- data/generators/foundation/app/views/pages/404.liquid +13 -0
- data/generators/foundation/app/views/pages/404.liquid.haml +10 -0
- data/generators/foundation/app/views/pages/index.liquid +152 -0
- data/generators/foundation/app/views/pages/index.liquid.haml +130 -0
- data/generators/foundation/app/views/snippets/footer.liquid +16 -0
- data/generators/foundation/app/views/snippets/footer.liquid.haml +23 -0
- data/generators/foundation/config/deploy.yml +12 -0
- data/generators/foundation/config/site.yml.tt +16 -0
- data/generators/foundation/config/translations.yml +8 -0
- data/generators/foundation/config.ru +3 -0
- data/generators/foundation/data/.empty_directory +1 -0
- data/generators/foundation/public/fonts/.empty_directory +1 -0
- data/generators/foundation/public/javascripts/foundation/foundation.alerts.js +50 -0
- data/generators/foundation/public/javascripts/foundation/foundation.clearing.js +480 -0
- data/generators/foundation/public/javascripts/foundation/foundation.cookie.js +74 -0
- data/generators/foundation/public/javascripts/foundation/foundation.dropdown.js +130 -0
- data/generators/foundation/public/javascripts/foundation/foundation.forms.js +395 -0
- data/generators/foundation/public/javascripts/foundation/foundation.joyride.js +612 -0
- data/generators/foundation/public/javascripts/foundation/foundation.js +372 -0
- data/generators/foundation/public/javascripts/foundation/foundation.magellan.js +130 -0
- data/generators/foundation/public/javascripts/foundation/foundation.orbit.js +365 -0
- data/generators/foundation/public/javascripts/foundation/foundation.placeholder.js +159 -0
- data/generators/foundation/public/javascripts/foundation/foundation.reveal.js +270 -0
- data/generators/foundation/public/javascripts/foundation/foundation.section.js +272 -0
- data/generators/foundation/public/javascripts/foundation/foundation.tooltips.js +195 -0
- data/generators/foundation/public/javascripts/foundation/foundation.topbar.js +225 -0
- data/generators/foundation/public/javascripts/foundation.min.js +14 -0
- data/generators/foundation/public/javascripts/vendor/custom.modernizr.js +4 -0
- data/generators/foundation/public/javascripts/vendor/jquery.js +9597 -0
- data/generators/foundation/public/javascripts/vendor/zepto.js +1884 -0
- data/generators/foundation/public/samples/.empty_directory +1 -0
- data/generators/foundation/public/stylesheets/foundation.css +3818 -0
- data/generators/foundation/public/stylesheets/foundation.min.css +1 -0
- data/generators/foundation/public/stylesheets/normalize.css +396 -0
- data/generators/page/template.liquid.haml.tt +35 -0
- data/generators/page/template.liquid.tt +1 -0
- data/generators/snippet/template.liquid.haml.tt +4 -0
- data/generators/snippet/template.liquid.tt +4 -0
- data/lib/locomotive/wagon/cli.rb +238 -0
- data/lib/locomotive/wagon/exceptions.rb +35 -0
- data/lib/locomotive/wagon/generators/content_type.rb +47 -0
- data/lib/locomotive/wagon/generators/page.rb +63 -0
- data/lib/locomotive/wagon/generators/site/base.rb +30 -0
- data/lib/locomotive/wagon/generators/site/blank.rb +23 -0
- data/lib/locomotive/wagon/generators/site/bootstrap.rb +35 -0
- data/lib/locomotive/wagon/generators/site/foundation.rb +35 -0
- data/lib/locomotive/wagon/generators/site/unzip.rb +81 -0
- data/lib/locomotive/wagon/generators/site.rb +99 -0
- data/lib/locomotive/wagon/generators/snippet.rb +60 -0
- data/lib/locomotive/wagon/liquid/drops/base.rb +44 -0
- data/lib/locomotive/wagon/liquid/drops/content_entry.rb +48 -0
- data/lib/locomotive/wagon/liquid/drops/content_types.rb +121 -0
- data/lib/locomotive/wagon/liquid/drops/page.rb +36 -0
- data/lib/locomotive/wagon/liquid/drops/site.rb +21 -0
- data/lib/locomotive/wagon/liquid/errors.rb +7 -0
- data/lib/locomotive/wagon/liquid/filters/date.rb +98 -0
- data/lib/locomotive/wagon/liquid/filters/html.rb +154 -0
- data/lib/locomotive/wagon/liquid/filters/misc.rb +28 -0
- data/lib/locomotive/wagon/liquid/filters/resize.rb +18 -0
- data/lib/locomotive/wagon/liquid/filters/text.rb +50 -0
- data/lib/locomotive/wagon/liquid/filters/translate.rb +24 -0
- data/lib/locomotive/wagon/liquid/patches.rb +47 -0
- data/lib/locomotive/wagon/liquid/tags/consume.rb +58 -0
- data/lib/locomotive/wagon/liquid/tags/csrf.rb +34 -0
- data/lib/locomotive/wagon/liquid/tags/editable/base.rb +46 -0
- data/lib/locomotive/wagon/liquid/tags/editable/control.rb +19 -0
- data/lib/locomotive/wagon/liquid/tags/editable/file.rb +15 -0
- data/lib/locomotive/wagon/liquid/tags/editable/long_text.rb +15 -0
- data/lib/locomotive/wagon/liquid/tags/editable/short_text.rb +15 -0
- data/lib/locomotive/wagon/liquid/tags/editable.rb +5 -0
- data/lib/locomotive/wagon/liquid/tags/extends.rb +25 -0
- data/lib/locomotive/wagon/liquid/tags/google_analytics.rb +28 -0
- data/lib/locomotive/wagon/liquid/tags/inline_editor.rb +16 -0
- data/lib/locomotive/wagon/liquid/tags/locale_switcher.rb +106 -0
- data/lib/locomotive/wagon/liquid/tags/nav.rb +167 -0
- data/lib/locomotive/wagon/liquid/tags/paginate.rb +105 -0
- data/lib/locomotive/wagon/liquid/tags/seo.rb +74 -0
- data/lib/locomotive/wagon/liquid/tags/snippet.rb +44 -0
- data/lib/locomotive/wagon/liquid/tags/with_scope.rb +43 -0
- data/lib/locomotive/wagon/liquid.rb +19 -0
- data/lib/locomotive/wagon/listen.rb +57 -0
- data/lib/locomotive/wagon/logger.rb +54 -0
- data/lib/locomotive/wagon/misc/core_ext.rb +29 -0
- data/lib/locomotive/wagon/misc/dragonfly.rb +79 -0
- data/lib/locomotive/wagon/misc/httparty.rb +46 -0
- data/lib/locomotive/wagon/misc/i18n.rb +2 -0
- data/lib/locomotive/wagon/misc/will_paginate.rb +16 -0
- data/lib/locomotive/wagon/misc.rb +5 -0
- data/lib/locomotive/wagon/server/dynamic_assets.rb +31 -0
- data/lib/locomotive/wagon/server/entry_submission.rb +116 -0
- data/lib/locomotive/wagon/server/favicon.rb +17 -0
- data/lib/locomotive/wagon/server/locale.rb +42 -0
- data/lib/locomotive/wagon/server/logging.rb +32 -0
- data/lib/locomotive/wagon/server/middleware.rb +59 -0
- data/lib/locomotive/wagon/server/not_found.rb +19 -0
- data/lib/locomotive/wagon/server/page.rb +61 -0
- data/lib/locomotive/wagon/server/path.rb +34 -0
- data/lib/locomotive/wagon/server/renderer.rb +105 -0
- data/lib/locomotive/wagon/server/templatized_page.rb +32 -0
- data/lib/locomotive/wagon/server.rb +81 -0
- data/lib/locomotive/wagon/standalone_server.rb +28 -0
- data/lib/locomotive/wagon/version.rb +5 -0
- data/lib/locomotive/wagon.rb +163 -0
- data/locales/de.yml +156 -0
- data/locales/en.yml +177 -0
- data/locales/es.yml +132 -0
- data/locales/et.yml +153 -0
- data/locales/fr.yml +146 -0
- data/locales/it.yml +154 -0
- data/locales/nb.yml +190 -0
- data/locales/nl.yml +159 -0
- data/locales/pl.yml +202 -0
- data/locales/pt-BR.yml +138 -0
- data/locales/ru.yml +223 -0
- data/locomotivecms_wagon.gemspec +44 -0
- data/spec/integration/cassettes/pull.yml +590 -0
- data/spec/integration/cassettes/push.yml +810 -0
- data/spec/integration/integration_helper.rb +14 -0
- data/spec/integration/server_spec.rb +38 -0
- data/spec/integration/sites_spec.rb +29 -0
- data/spec/spec_helper.rb +12 -0
- data/spec/support/helpers.rb +13 -0
- metadata +544 -0
@@ -0,0 +1,270 @@
|
|
1
|
+
/*jslint unparam: true, browser: true, indent: 2 */
|
2
|
+
|
3
|
+
;(function ($, window, document, undefined) {
|
4
|
+
'use strict';
|
5
|
+
|
6
|
+
Foundation.libs.reveal = {
|
7
|
+
name: 'reveal',
|
8
|
+
|
9
|
+
version : '4.0.9',
|
10
|
+
|
11
|
+
locked : false,
|
12
|
+
|
13
|
+
settings : {
|
14
|
+
animation: 'fadeAndPop',
|
15
|
+
animationSpeed: 250,
|
16
|
+
closeOnBackgroundClick: true,
|
17
|
+
dismissModalClass: 'close-reveal-modal',
|
18
|
+
bgClass: 'reveal-modal-bg',
|
19
|
+
open: function(){},
|
20
|
+
opened: function(){},
|
21
|
+
close: function(){},
|
22
|
+
closed: function(){},
|
23
|
+
bg : $('.reveal-modal-bg'),
|
24
|
+
css : {
|
25
|
+
open : {
|
26
|
+
'opacity': 0,
|
27
|
+
'visibility': 'visible',
|
28
|
+
'display' : 'block'
|
29
|
+
},
|
30
|
+
close : {
|
31
|
+
'opacity': 1,
|
32
|
+
'visibility': 'hidden',
|
33
|
+
'display': 'none'
|
34
|
+
}
|
35
|
+
}
|
36
|
+
},
|
37
|
+
|
38
|
+
init : function (scope, method, options) {
|
39
|
+
this.scope = scope || this.scope;
|
40
|
+
Foundation.inherit(this, 'data_options delay');
|
41
|
+
|
42
|
+
if (typeof method === 'object') {
|
43
|
+
$.extend(true, this.settings, method);
|
44
|
+
}
|
45
|
+
|
46
|
+
if (typeof method != 'string') {
|
47
|
+
this.events();
|
48
|
+
|
49
|
+
return this.settings.init;
|
50
|
+
} else {
|
51
|
+
return this[method].call(this, options);
|
52
|
+
}
|
53
|
+
},
|
54
|
+
|
55
|
+
events : function () {
|
56
|
+
var self = this;
|
57
|
+
|
58
|
+
$(this.scope)
|
59
|
+
.off('.fndtn.reveal')
|
60
|
+
.on('click.fndtn.reveal', '[data-reveal-id]', function (e) {
|
61
|
+
e.preventDefault();
|
62
|
+
if (!self.locked) {
|
63
|
+
self.locked = true;
|
64
|
+
self.open.call(self, $(this));
|
65
|
+
}
|
66
|
+
})
|
67
|
+
.on('click.fndtn.reveal touchend.click.fndtn.reveal', this.close_targets(), function (e) {
|
68
|
+
e.preventDefault();
|
69
|
+
if (!self.locked) {
|
70
|
+
self.locked = true;
|
71
|
+
self.close.call(self, $(this).closest('.reveal-modal'));
|
72
|
+
}
|
73
|
+
})
|
74
|
+
.on('open.fndtn.reveal', '.reveal-modal', this.settings.open)
|
75
|
+
.on('opened.fndtn.reveal', '.reveal-modal', this.settings.opened)
|
76
|
+
.on('opened.fndtn.reveal', '.reveal-modal', this.open_video)
|
77
|
+
.on('close.fndtn.reveal', '.reveal-modal', this.settings.close)
|
78
|
+
.on('closed.fndtn.reveal', '.reveal-modal', this.settings.closed)
|
79
|
+
.on('closed.fndtn.reveal', '.reveal-modal', this.close_video);
|
80
|
+
|
81
|
+
return true;
|
82
|
+
},
|
83
|
+
|
84
|
+
open : function (target) {
|
85
|
+
if (target) {
|
86
|
+
var modal = $('#' + target.data('reveal-id'));
|
87
|
+
} else {
|
88
|
+
var modal = $(this.scope);
|
89
|
+
}
|
90
|
+
|
91
|
+
if (!modal.hasClass('open')) {
|
92
|
+
var open_modal = $('.reveal-modal.open');
|
93
|
+
|
94
|
+
if (typeof modal.data('css-top') === 'undefined') {
|
95
|
+
modal.data('css-top', parseInt(modal.css('top'), 10))
|
96
|
+
.data('offset', this.cache_offset(modal));
|
97
|
+
}
|
98
|
+
|
99
|
+
modal.trigger('open');
|
100
|
+
|
101
|
+
if (open_modal.length < 1) {
|
102
|
+
this.toggle_bg(modal);
|
103
|
+
}
|
104
|
+
this.hide(open_modal, this.settings.css.open);
|
105
|
+
this.show(modal, this.settings.css.open);
|
106
|
+
}
|
107
|
+
},
|
108
|
+
|
109
|
+
close : function (modal) {
|
110
|
+
|
111
|
+
var modal = modal || $(this.scope),
|
112
|
+
open_modals = $('.reveal-modal.open');
|
113
|
+
|
114
|
+
if (open_modals.length > 0) {
|
115
|
+
this.locked = true;
|
116
|
+
modal.trigger('close');
|
117
|
+
this.toggle_bg(modal);
|
118
|
+
this.hide(open_modals, this.settings.css.close);
|
119
|
+
}
|
120
|
+
},
|
121
|
+
|
122
|
+
close_targets : function () {
|
123
|
+
var base = '.' + this.settings.dismissModalClass;
|
124
|
+
|
125
|
+
if (this.settings.closeOnBackgroundClick) {
|
126
|
+
return base + ', .' + this.settings.bgClass;
|
127
|
+
}
|
128
|
+
|
129
|
+
return base;
|
130
|
+
},
|
131
|
+
|
132
|
+
toggle_bg : function (modal) {
|
133
|
+
if ($('.reveal-modal-bg').length === 0) {
|
134
|
+
this.settings.bg = $('<div />', {'class': this.settings.bgClass})
|
135
|
+
.insertAfter(modal);
|
136
|
+
}
|
137
|
+
|
138
|
+
if (this.settings.bg.filter(':visible').length > 0) {
|
139
|
+
this.hide(this.settings.bg);
|
140
|
+
} else {
|
141
|
+
this.show(this.settings.bg);
|
142
|
+
}
|
143
|
+
},
|
144
|
+
|
145
|
+
show : function (el, css) {
|
146
|
+
// is modal
|
147
|
+
if (css) {
|
148
|
+
if (/pop/i.test(this.settings.animation)) {
|
149
|
+
css.top = $(window).scrollTop() - el.data('offset') + 'px';
|
150
|
+
var end_css = {
|
151
|
+
top: $(window).scrollTop() + el.data('css-top') + 'px',
|
152
|
+
opacity: 1
|
153
|
+
}
|
154
|
+
|
155
|
+
return this.delay(function () {
|
156
|
+
return el
|
157
|
+
.css(css)
|
158
|
+
.animate(end_css, this.settings.animationSpeed, 'linear', function () {
|
159
|
+
this.locked = false;
|
160
|
+
el.trigger('opened');
|
161
|
+
}.bind(this))
|
162
|
+
.addClass('open');
|
163
|
+
}.bind(this), this.settings.animationSpeed / 2);
|
164
|
+
}
|
165
|
+
|
166
|
+
if (/fade/i.test(this.settings.animation)) {
|
167
|
+
var end_css = {opacity: 1};
|
168
|
+
|
169
|
+
return this.delay(function () {
|
170
|
+
return el
|
171
|
+
.css(css)
|
172
|
+
.animate(end_css, this.settings.animationSpeed, 'linear', function () {
|
173
|
+
this.locked = false;
|
174
|
+
el.trigger('opened');
|
175
|
+
}.bind(this))
|
176
|
+
.addClass('open');
|
177
|
+
}.bind(this), this.settings.animationSpeed / 2);
|
178
|
+
}
|
179
|
+
|
180
|
+
return el.css(css).show().css({opacity: 1}).addClass('open').trigger('opened');
|
181
|
+
}
|
182
|
+
|
183
|
+
// should we animate the background?
|
184
|
+
if (/fade/i.test(this.settings.animation)) {
|
185
|
+
return el.fadeIn(this.settings.animationSpeed / 2);
|
186
|
+
}
|
187
|
+
|
188
|
+
return el.show();
|
189
|
+
},
|
190
|
+
|
191
|
+
hide : function (el, css) {
|
192
|
+
// is modal
|
193
|
+
if (css) {
|
194
|
+
if (/pop/i.test(this.settings.animation)) {
|
195
|
+
var end_css = {
|
196
|
+
top: - $(window).scrollTop() - el.data('offset') + 'px',
|
197
|
+
opacity: 0
|
198
|
+
};
|
199
|
+
|
200
|
+
return this.delay(function () {
|
201
|
+
return el
|
202
|
+
.animate(end_css, this.settings.animationSpeed, 'linear', function () {
|
203
|
+
this.locked = false;
|
204
|
+
el.css(css).trigger('closed');
|
205
|
+
}.bind(this))
|
206
|
+
.removeClass('open');
|
207
|
+
}.bind(this), this.settings.animationSpeed / 2);
|
208
|
+
}
|
209
|
+
|
210
|
+
if (/fade/i.test(this.settings.animation)) {
|
211
|
+
var end_css = {opacity: 0};
|
212
|
+
|
213
|
+
return this.delay(function () {
|
214
|
+
return el
|
215
|
+
.animate(end_css, this.settings.animationSpeed, 'linear', function () {
|
216
|
+
this.locked = false;
|
217
|
+
el.css(css).trigger('closed');
|
218
|
+
}.bind(this))
|
219
|
+
.removeClass('open');
|
220
|
+
}.bind(this), this.settings.animationSpeed / 2);
|
221
|
+
}
|
222
|
+
|
223
|
+
return el.hide().css(css).removeClass('open').trigger('closed');
|
224
|
+
}
|
225
|
+
|
226
|
+
// should we animate the background?
|
227
|
+
if (/fade/i.test(this.settings.animation)) {
|
228
|
+
return el.fadeOut(this.settings.animationSpeed / 2);
|
229
|
+
}
|
230
|
+
|
231
|
+
return el.hide();
|
232
|
+
},
|
233
|
+
|
234
|
+
close_video : function (e) {
|
235
|
+
var video = $(this).find('.flex-video'),
|
236
|
+
iframe = video.find('iframe');
|
237
|
+
|
238
|
+
if (iframe.length > 0) {
|
239
|
+
iframe.attr('data-src', iframe[0].src);
|
240
|
+
iframe.attr('src', 'about:blank');
|
241
|
+
video.fadeOut(100).hide();
|
242
|
+
}
|
243
|
+
},
|
244
|
+
|
245
|
+
open_video : function (e) {
|
246
|
+
var video = $(this).find('.flex-video'),
|
247
|
+
iframe = video.find('iframe');
|
248
|
+
|
249
|
+
if (iframe.length > 0) {
|
250
|
+
var data_src = iframe.attr('data-src');
|
251
|
+
if (typeof data_src === 'string') {
|
252
|
+
iframe[0].src = iframe.attr('data-src');
|
253
|
+
}
|
254
|
+
video.show().fadeIn(100);
|
255
|
+
}
|
256
|
+
},
|
257
|
+
|
258
|
+
cache_offset : function (modal) {
|
259
|
+
var offset = modal.show().height() + parseInt(modal.css('top'), 10);
|
260
|
+
|
261
|
+
modal.hide();
|
262
|
+
|
263
|
+
return offset;
|
264
|
+
},
|
265
|
+
|
266
|
+
off : function () {
|
267
|
+
$(this.scope).off('.fndtn.reveal');
|
268
|
+
}
|
269
|
+
};
|
270
|
+
}(Foundation.zj, this, this.document));
|
@@ -0,0 +1,272 @@
|
|
1
|
+
/*jslint unparam: true, browser: true, indent: 2 */
|
2
|
+
|
3
|
+
;(function ($, window, document, undefined) {
|
4
|
+
'use strict';
|
5
|
+
|
6
|
+
Foundation.libs.section = {
|
7
|
+
name: 'section',
|
8
|
+
|
9
|
+
version : '4.0.9',
|
10
|
+
|
11
|
+
settings : {
|
12
|
+
deep_linking: false,
|
13
|
+
one_up: true,
|
14
|
+
callback: function (){}
|
15
|
+
},
|
16
|
+
|
17
|
+
init : function (scope, method, options) {
|
18
|
+
var self = this;
|
19
|
+
|
20
|
+
this.scope = scope || this.scope;
|
21
|
+
Foundation.inherit(this, 'throttle data_options');
|
22
|
+
|
23
|
+
if (typeof method != 'string') {
|
24
|
+
this.set_active_from_hash();
|
25
|
+
this.events();
|
26
|
+
|
27
|
+
return true;
|
28
|
+
} else {
|
29
|
+
return this[method].call(this, options);
|
30
|
+
}
|
31
|
+
},
|
32
|
+
|
33
|
+
events : function () {
|
34
|
+
var self = this;
|
35
|
+
|
36
|
+
$(this.scope)
|
37
|
+
.on('click.fndtn.section', '[data-section] .title', function (e) {
|
38
|
+
var $this = $(this),
|
39
|
+
section = $this.closest('[data-section]');
|
40
|
+
|
41
|
+
self.toggle_active.call(this, e, self);
|
42
|
+
});
|
43
|
+
|
44
|
+
$(window)
|
45
|
+
.on('resize.fndtn.section', self.throttle(function () {
|
46
|
+
self.resize.call(this);
|
47
|
+
}, 30))
|
48
|
+
.on('hashchange', function () {
|
49
|
+
if (!self.settings.toggled){
|
50
|
+
self.set_active_from_hash();
|
51
|
+
$(this).trigger('resize');
|
52
|
+
}
|
53
|
+
}).trigger('resize');
|
54
|
+
|
55
|
+
$(document)
|
56
|
+
.on('click.fndtn.section', function (e) {
|
57
|
+
if ($(e.target).closest('.title').length < 1) {
|
58
|
+
$('[data-section="vertical-nav"], [data-section="horizontal-nav"]')
|
59
|
+
.find('section, .section')
|
60
|
+
.removeClass('active')
|
61
|
+
.attr('style', '');
|
62
|
+
}
|
63
|
+
});
|
64
|
+
|
65
|
+
},
|
66
|
+
|
67
|
+
toggle_active : function (e, self) {
|
68
|
+
var $this = $(this),
|
69
|
+
section = $this.closest('section, .section'),
|
70
|
+
content = section.find('.content'),
|
71
|
+
parent = section.closest('[data-section]'),
|
72
|
+
self = Foundation.libs.section,
|
73
|
+
settings = $.extend({}, self.settings, self.data_options(parent));
|
74
|
+
|
75
|
+
self.settings.toggled = true;
|
76
|
+
|
77
|
+
if (!settings.deep_linking && content.length > 0) {
|
78
|
+
e.preventDefault();
|
79
|
+
}
|
80
|
+
|
81
|
+
if (section.hasClass('active')) {
|
82
|
+
if (self.small(parent)
|
83
|
+
|| self.is_vertical(parent)
|
84
|
+
|| self.is_horizontal(parent)
|
85
|
+
|| self.is_accordion(parent)) {
|
86
|
+
section
|
87
|
+
.removeClass('active')
|
88
|
+
.attr('style', '');
|
89
|
+
}
|
90
|
+
} else {
|
91
|
+
var prev_active_section = null,
|
92
|
+
title_height = self.outerHeight(section.find('.title'));
|
93
|
+
|
94
|
+
if (self.small(parent) || settings.one_up) {
|
95
|
+
prev_active_section = $this.closest('[data-section]').find('section.active, .section.active');
|
96
|
+
|
97
|
+
if (self.small(parent)) {
|
98
|
+
prev_active_section.attr('style', '');
|
99
|
+
} else {
|
100
|
+
prev_active_section.attr('style', 'visibility: hidden; padding-top: '+title_height+'px;');
|
101
|
+
}
|
102
|
+
}
|
103
|
+
|
104
|
+
if (self.small(parent)) {
|
105
|
+
section.attr('style', '');
|
106
|
+
} else {
|
107
|
+
section.css('padding-top', title_height);
|
108
|
+
}
|
109
|
+
|
110
|
+
section.addClass('active');
|
111
|
+
|
112
|
+
if (prev_active_section !== null) {
|
113
|
+
prev_active_section.removeClass('active').attr('style', '');
|
114
|
+
}
|
115
|
+
}
|
116
|
+
|
117
|
+
setTimeout(function () {
|
118
|
+
self.settings.toggled = false;
|
119
|
+
}, 300);
|
120
|
+
|
121
|
+
settings.callback();
|
122
|
+
},
|
123
|
+
|
124
|
+
resize : function () {
|
125
|
+
var sections = $('[data-section]'),
|
126
|
+
self = Foundation.libs.section;
|
127
|
+
|
128
|
+
sections.each(function() {
|
129
|
+
var $this = $(this),
|
130
|
+
active_section = $this.find('section.active, .section.active'),
|
131
|
+
settings = $.extend({}, self.settings, self.data_options($this));
|
132
|
+
|
133
|
+
if (active_section.length > 1) {
|
134
|
+
active_section
|
135
|
+
.not(':first')
|
136
|
+
.removeClass('active')
|
137
|
+
.attr('style', '');
|
138
|
+
} else if (active_section.length < 1
|
139
|
+
&& !self.is_vertical($this)
|
140
|
+
&& !self.is_horizontal($this)
|
141
|
+
&& !self.is_accordion($this)) {
|
142
|
+
|
143
|
+
var first = $this.find('section, .section').first();
|
144
|
+
first.addClass('active');
|
145
|
+
|
146
|
+
if (self.small($this)) {
|
147
|
+
first.attr('style', '');
|
148
|
+
} else {
|
149
|
+
first.css('padding-top', self.outerHeight(first.find('.title')));
|
150
|
+
}
|
151
|
+
}
|
152
|
+
|
153
|
+
if (self.small($this)) {
|
154
|
+
active_section.attr('style', '');
|
155
|
+
} else {
|
156
|
+
active_section.css('padding-top', self.outerHeight(active_section.find('.title')));
|
157
|
+
}
|
158
|
+
|
159
|
+
self.position_titles($this);
|
160
|
+
|
161
|
+
if (self.is_horizontal($this) && !self.small($this)) {
|
162
|
+
self.position_content($this);
|
163
|
+
} else {
|
164
|
+
self.position_content($this, false);
|
165
|
+
}
|
166
|
+
});
|
167
|
+
},
|
168
|
+
|
169
|
+
is_vertical : function (el) {
|
170
|
+
return /vertical-nav/i.test(el.data('section'));
|
171
|
+
},
|
172
|
+
|
173
|
+
is_horizontal : function (el) {
|
174
|
+
return /horizontal-nav/i.test(el.data('section'));
|
175
|
+
},
|
176
|
+
|
177
|
+
is_accordion : function (el) {
|
178
|
+
return /accordion/i.test(el.data('section'));
|
179
|
+
},
|
180
|
+
|
181
|
+
is_tabs : function (el) {
|
182
|
+
return /tabs/i.test(el.data('section'));
|
183
|
+
},
|
184
|
+
|
185
|
+
set_active_from_hash : function () {
|
186
|
+
var hash = window.location.hash.substring(1),
|
187
|
+
sections = $('[data-section]'),
|
188
|
+
self = this;
|
189
|
+
|
190
|
+
sections.each(function () {
|
191
|
+
var section = $(this),
|
192
|
+
settings = $.extend({}, self.settings, self.data_options(section));
|
193
|
+
|
194
|
+
if (hash.length > 0 && settings.deep_linking) {
|
195
|
+
section
|
196
|
+
.find('section, .section')
|
197
|
+
.attr('style', '')
|
198
|
+
.removeClass('active');
|
199
|
+
section
|
200
|
+
.find('.content[data-slug="' + hash + '"]')
|
201
|
+
.closest('section, .section')
|
202
|
+
.addClass('active');
|
203
|
+
}
|
204
|
+
});
|
205
|
+
},
|
206
|
+
|
207
|
+
position_titles : function (section, off) {
|
208
|
+
var titles = section.find('.title'),
|
209
|
+
previous_width = 0,
|
210
|
+
self = this;
|
211
|
+
|
212
|
+
if (typeof off === 'boolean') {
|
213
|
+
titles.attr('style', '');
|
214
|
+
|
215
|
+
} else {
|
216
|
+
titles.each(function () {
|
217
|
+
$(this).css('left', previous_width);
|
218
|
+
previous_width += self.outerWidth($(this));
|
219
|
+
});
|
220
|
+
}
|
221
|
+
},
|
222
|
+
|
223
|
+
position_content : function (section, off) {
|
224
|
+
var titles = section.find('.title'),
|
225
|
+
content = section.find('.content'),
|
226
|
+
self = this;
|
227
|
+
|
228
|
+
if (typeof off === 'boolean') {
|
229
|
+
content.attr('style', '');
|
230
|
+
section.attr('style', '');
|
231
|
+
} else {
|
232
|
+
section.find('section, .section').each(function () {
|
233
|
+
var title = $(this).find('.title'),
|
234
|
+
content = $(this).find('.content');
|
235
|
+
|
236
|
+
content.css({left: title.position().left - 1, top: self.outerHeight(title) - 2});
|
237
|
+
});
|
238
|
+
|
239
|
+
// temporary work around for Zepto outerheight calculation issues.
|
240
|
+
if (typeof Zepto === 'function') {
|
241
|
+
section.height(this.outerHeight(titles.first()));
|
242
|
+
} else {
|
243
|
+
section.height(this.outerHeight(titles.first()) - 2);
|
244
|
+
}
|
245
|
+
}
|
246
|
+
|
247
|
+
},
|
248
|
+
|
249
|
+
small : function (el) {
|
250
|
+
var settings = $.extend({}, this.settings, this.data_options(el));
|
251
|
+
if (this.is_tabs(el)) {
|
252
|
+
return false;
|
253
|
+
}
|
254
|
+
if (el && this.is_accordion(el)) {
|
255
|
+
return true;
|
256
|
+
}
|
257
|
+
if ($('html').hasClass('lt-ie9')) {
|
258
|
+
return true;
|
259
|
+
}
|
260
|
+
if ($('html').hasClass('ie8compat')) {
|
261
|
+
return true;
|
262
|
+
}
|
263
|
+
return $(this.scope).width() < 768;
|
264
|
+
},
|
265
|
+
|
266
|
+
off : function () {
|
267
|
+
$(this.scope).off('.fndtn.section');
|
268
|
+
$(window).off('.fndtn.section');
|
269
|
+
$(document).off('.fndtn.section')
|
270
|
+
}
|
271
|
+
};
|
272
|
+
}(Foundation.zj, this, this.document));
|