locomotivecms_wagon 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (178) hide show
  1. data/.gitignore +27 -0
  2. data/.rspec +2 -0
  3. data/Gemfile +8 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +68 -0
  6. data/Rakefile +57 -0
  7. data/TODO +57 -0
  8. data/bin/wagon +9 -0
  9. data/generators/blank/Gemfile.tt +20 -0
  10. data/generators/blank/app/content_types/.empty_directory +1 -0
  11. data/generators/blank/app/views/pages/404.liquid +11 -0
  12. data/generators/blank/app/views/pages/index.liquid +19 -0
  13. data/generators/blank/app/views/snippets/.empty_directory +1 -0
  14. data/generators/blank/config/deploy.yml +12 -0
  15. data/generators/blank/config/site.yml.tt +16 -0
  16. data/generators/blank/config/translations.yml +8 -0
  17. data/generators/blank/config.ru +3 -0
  18. data/generators/blank/data/.empty_directory +1 -0
  19. data/generators/blank/public/fonts/.empty_directory +1 -0
  20. data/generators/blank/public/images/.empty_directory +1 -0
  21. data/generators/blank/public/javascripts/.empty_directory +1 -0
  22. data/generators/blank/public/samples/.empty_directory +1 -0
  23. data/generators/blank/public/stylesheets/.empty_directory +1 -0
  24. data/generators/bootstrap/Gemfile.tt +20 -0
  25. data/generators/bootstrap/app/content_types/.empty_directory +1 -0
  26. data/generators/bootstrap/app/views/pages/404.liquid +13 -0
  27. data/generators/bootstrap/app/views/pages/404.liquid.haml +10 -0
  28. data/generators/bootstrap/app/views/pages/index.liquid +89 -0
  29. data/generators/bootstrap/app/views/pages/index.liquid.haml +72 -0
  30. data/generators/bootstrap/app/views/snippets/footer.liquid +3 -0
  31. data/generators/bootstrap/app/views/snippets/footer.liquid.haml +2 -0
  32. data/generators/bootstrap/config/deploy.yml +12 -0
  33. data/generators/bootstrap/config/site.yml.tt +16 -0
  34. data/generators/bootstrap/config/translations.yml +8 -0
  35. data/generators/bootstrap/config.ru +3 -0
  36. data/generators/bootstrap/data/.empty_directory +1 -0
  37. data/generators/bootstrap/public/fonts/FontAwesome.otf +0 -0
  38. data/generators/bootstrap/public/fonts/font-awesome-ie7.min.css +23 -0
  39. data/generators/bootstrap/public/fonts/font-awesome.css +469 -0
  40. data/generators/bootstrap/public/fonts/font-awesome.min.css +34 -0
  41. data/generators/bootstrap/public/fonts/fontawesome-webfont.eot +0 -0
  42. data/generators/bootstrap/public/fonts/fontawesome-webfont.ttf +0 -0
  43. data/generators/bootstrap/public/fonts/fontawesome-webfont.woff +0 -0
  44. data/generators/bootstrap/public/javascripts/bootstrap.js +2159 -0
  45. data/generators/bootstrap/public/javascripts/bootstrap.min.js +6 -0
  46. data/generators/bootstrap/public/samples/.empty_directory +1 -0
  47. data/generators/bootstrap/public/stylesheets/application.css.scss +39 -0
  48. data/generators/bootstrap/public/stylesheets/bootstrap-responsive.css +1092 -0
  49. data/generators/bootstrap/public/stylesheets/bootstrap-responsive.min.css +9 -0
  50. data/generators/bootstrap/public/stylesheets/bootstrap.css +5652 -0
  51. data/generators/bootstrap/public/stylesheets/bootstrap.min.css +726 -0
  52. data/generators/content_type/app/content_types/%name%.yml.tt +58 -0
  53. data/generators/content_type/data/%name%.yml.tt +24 -0
  54. data/generators/foundation/Gemfile.tt +20 -0
  55. data/generators/foundation/app/content_types/.empty_directory +1 -0
  56. data/generators/foundation/app/views/pages/404.liquid +13 -0
  57. data/generators/foundation/app/views/pages/404.liquid.haml +10 -0
  58. data/generators/foundation/app/views/pages/index.liquid +152 -0
  59. data/generators/foundation/app/views/pages/index.liquid.haml +130 -0
  60. data/generators/foundation/app/views/snippets/footer.liquid +16 -0
  61. data/generators/foundation/app/views/snippets/footer.liquid.haml +23 -0
  62. data/generators/foundation/config/deploy.yml +12 -0
  63. data/generators/foundation/config/site.yml.tt +16 -0
  64. data/generators/foundation/config/translations.yml +8 -0
  65. data/generators/foundation/config.ru +3 -0
  66. data/generators/foundation/data/.empty_directory +1 -0
  67. data/generators/foundation/public/fonts/.empty_directory +1 -0
  68. data/generators/foundation/public/javascripts/foundation/foundation.alerts.js +50 -0
  69. data/generators/foundation/public/javascripts/foundation/foundation.clearing.js +480 -0
  70. data/generators/foundation/public/javascripts/foundation/foundation.cookie.js +74 -0
  71. data/generators/foundation/public/javascripts/foundation/foundation.dropdown.js +130 -0
  72. data/generators/foundation/public/javascripts/foundation/foundation.forms.js +395 -0
  73. data/generators/foundation/public/javascripts/foundation/foundation.joyride.js +612 -0
  74. data/generators/foundation/public/javascripts/foundation/foundation.js +372 -0
  75. data/generators/foundation/public/javascripts/foundation/foundation.magellan.js +130 -0
  76. data/generators/foundation/public/javascripts/foundation/foundation.orbit.js +365 -0
  77. data/generators/foundation/public/javascripts/foundation/foundation.placeholder.js +159 -0
  78. data/generators/foundation/public/javascripts/foundation/foundation.reveal.js +270 -0
  79. data/generators/foundation/public/javascripts/foundation/foundation.section.js +272 -0
  80. data/generators/foundation/public/javascripts/foundation/foundation.tooltips.js +195 -0
  81. data/generators/foundation/public/javascripts/foundation/foundation.topbar.js +225 -0
  82. data/generators/foundation/public/javascripts/foundation.min.js +14 -0
  83. data/generators/foundation/public/javascripts/vendor/custom.modernizr.js +4 -0
  84. data/generators/foundation/public/javascripts/vendor/jquery.js +9597 -0
  85. data/generators/foundation/public/javascripts/vendor/zepto.js +1884 -0
  86. data/generators/foundation/public/samples/.empty_directory +1 -0
  87. data/generators/foundation/public/stylesheets/foundation.css +3818 -0
  88. data/generators/foundation/public/stylesheets/foundation.min.css +1 -0
  89. data/generators/foundation/public/stylesheets/normalize.css +396 -0
  90. data/generators/page/template.liquid.haml.tt +35 -0
  91. data/generators/page/template.liquid.tt +1 -0
  92. data/generators/snippet/template.liquid.haml.tt +4 -0
  93. data/generators/snippet/template.liquid.tt +4 -0
  94. data/lib/locomotive/wagon/cli.rb +238 -0
  95. data/lib/locomotive/wagon/exceptions.rb +35 -0
  96. data/lib/locomotive/wagon/generators/content_type.rb +47 -0
  97. data/lib/locomotive/wagon/generators/page.rb +63 -0
  98. data/lib/locomotive/wagon/generators/site/base.rb +30 -0
  99. data/lib/locomotive/wagon/generators/site/blank.rb +23 -0
  100. data/lib/locomotive/wagon/generators/site/bootstrap.rb +35 -0
  101. data/lib/locomotive/wagon/generators/site/foundation.rb +35 -0
  102. data/lib/locomotive/wagon/generators/site/unzip.rb +81 -0
  103. data/lib/locomotive/wagon/generators/site.rb +99 -0
  104. data/lib/locomotive/wagon/generators/snippet.rb +60 -0
  105. data/lib/locomotive/wagon/liquid/drops/base.rb +44 -0
  106. data/lib/locomotive/wagon/liquid/drops/content_entry.rb +48 -0
  107. data/lib/locomotive/wagon/liquid/drops/content_types.rb +121 -0
  108. data/lib/locomotive/wagon/liquid/drops/page.rb +36 -0
  109. data/lib/locomotive/wagon/liquid/drops/site.rb +21 -0
  110. data/lib/locomotive/wagon/liquid/errors.rb +7 -0
  111. data/lib/locomotive/wagon/liquid/filters/date.rb +98 -0
  112. data/lib/locomotive/wagon/liquid/filters/html.rb +154 -0
  113. data/lib/locomotive/wagon/liquid/filters/misc.rb +28 -0
  114. data/lib/locomotive/wagon/liquid/filters/resize.rb +18 -0
  115. data/lib/locomotive/wagon/liquid/filters/text.rb +50 -0
  116. data/lib/locomotive/wagon/liquid/filters/translate.rb +24 -0
  117. data/lib/locomotive/wagon/liquid/patches.rb +47 -0
  118. data/lib/locomotive/wagon/liquid/tags/consume.rb +58 -0
  119. data/lib/locomotive/wagon/liquid/tags/csrf.rb +34 -0
  120. data/lib/locomotive/wagon/liquid/tags/editable/base.rb +46 -0
  121. data/lib/locomotive/wagon/liquid/tags/editable/control.rb +19 -0
  122. data/lib/locomotive/wagon/liquid/tags/editable/file.rb +15 -0
  123. data/lib/locomotive/wagon/liquid/tags/editable/long_text.rb +15 -0
  124. data/lib/locomotive/wagon/liquid/tags/editable/short_text.rb +15 -0
  125. data/lib/locomotive/wagon/liquid/tags/editable.rb +5 -0
  126. data/lib/locomotive/wagon/liquid/tags/extends.rb +25 -0
  127. data/lib/locomotive/wagon/liquid/tags/google_analytics.rb +28 -0
  128. data/lib/locomotive/wagon/liquid/tags/inline_editor.rb +16 -0
  129. data/lib/locomotive/wagon/liquid/tags/locale_switcher.rb +106 -0
  130. data/lib/locomotive/wagon/liquid/tags/nav.rb +167 -0
  131. data/lib/locomotive/wagon/liquid/tags/paginate.rb +105 -0
  132. data/lib/locomotive/wagon/liquid/tags/seo.rb +74 -0
  133. data/lib/locomotive/wagon/liquid/tags/snippet.rb +44 -0
  134. data/lib/locomotive/wagon/liquid/tags/with_scope.rb +43 -0
  135. data/lib/locomotive/wagon/liquid.rb +19 -0
  136. data/lib/locomotive/wagon/listen.rb +57 -0
  137. data/lib/locomotive/wagon/logger.rb +54 -0
  138. data/lib/locomotive/wagon/misc/core_ext.rb +29 -0
  139. data/lib/locomotive/wagon/misc/dragonfly.rb +79 -0
  140. data/lib/locomotive/wagon/misc/httparty.rb +46 -0
  141. data/lib/locomotive/wagon/misc/i18n.rb +2 -0
  142. data/lib/locomotive/wagon/misc/will_paginate.rb +16 -0
  143. data/lib/locomotive/wagon/misc.rb +5 -0
  144. data/lib/locomotive/wagon/server/dynamic_assets.rb +31 -0
  145. data/lib/locomotive/wagon/server/entry_submission.rb +116 -0
  146. data/lib/locomotive/wagon/server/favicon.rb +17 -0
  147. data/lib/locomotive/wagon/server/locale.rb +42 -0
  148. data/lib/locomotive/wagon/server/logging.rb +32 -0
  149. data/lib/locomotive/wagon/server/middleware.rb +59 -0
  150. data/lib/locomotive/wagon/server/not_found.rb +19 -0
  151. data/lib/locomotive/wagon/server/page.rb +61 -0
  152. data/lib/locomotive/wagon/server/path.rb +34 -0
  153. data/lib/locomotive/wagon/server/renderer.rb +105 -0
  154. data/lib/locomotive/wagon/server/templatized_page.rb +32 -0
  155. data/lib/locomotive/wagon/server.rb +81 -0
  156. data/lib/locomotive/wagon/standalone_server.rb +28 -0
  157. data/lib/locomotive/wagon/version.rb +5 -0
  158. data/lib/locomotive/wagon.rb +163 -0
  159. data/locales/de.yml +156 -0
  160. data/locales/en.yml +177 -0
  161. data/locales/es.yml +132 -0
  162. data/locales/et.yml +153 -0
  163. data/locales/fr.yml +146 -0
  164. data/locales/it.yml +154 -0
  165. data/locales/nb.yml +190 -0
  166. data/locales/nl.yml +159 -0
  167. data/locales/pl.yml +202 -0
  168. data/locales/pt-BR.yml +138 -0
  169. data/locales/ru.yml +223 -0
  170. data/locomotivecms_wagon.gemspec +44 -0
  171. data/spec/integration/cassettes/pull.yml +590 -0
  172. data/spec/integration/cassettes/push.yml +810 -0
  173. data/spec/integration/integration_helper.rb +14 -0
  174. data/spec/integration/server_spec.rb +38 -0
  175. data/spec/integration/sites_spec.rb +29 -0
  176. data/spec/spec_helper.rb +12 -0
  177. data/spec/support/helpers.rb +13 -0
  178. metadata +544 -0
@@ -0,0 +1,372 @@
1
+ /*
2
+ * Foundation Responsive Library
3
+ * http://foundation.zurb.com
4
+ * Copyright 2013, ZURB
5
+ * Free to use under the MIT license.
6
+ * http://www.opensource.org/licenses/mit-license.php
7
+ */
8
+
9
+ /*jslint unparam: true, browser: true, indent: 2 */
10
+
11
+ // Accommodate running jQuery or Zepto in noConflict() mode by
12
+ // using an anonymous function to redefine the $ shorthand name.
13
+ // See http://docs.jquery.com/Using_jQuery_with_Other_Libraries
14
+ // and http://zeptojs.com/
15
+ var libFuncName = null;
16
+ if (typeof jQuery === "undefined" &&
17
+ typeof Zepto === "undefined" &&
18
+ typeof $ === "function") {
19
+ libFuncName = $;
20
+ } else if (typeof jQuery === "function") {
21
+ libFuncName = jQuery;
22
+ } else if (typeof Zepto === "function") {
23
+ libFuncName = Zepto;
24
+ } else {
25
+ throw new TypeError();
26
+ }
27
+
28
+ (function ($) {
29
+
30
+ (function () {
31
+ // add dusty browser stuff
32
+ if (!Array.prototype.filter) {
33
+ Array.prototype.filter = function(fun /*, thisp */) {
34
+ "use strict";
35
+
36
+ if (this == null) {
37
+ throw new TypeError();
38
+ }
39
+
40
+ var t = Object(this),
41
+ len = t.length >>> 0;
42
+ if (typeof fun != "function") {
43
+ try {
44
+ throw new TypeError();
45
+ } catch (e) {
46
+ return;
47
+ }
48
+ }
49
+
50
+ var res = [],
51
+ thisp = arguments[1];
52
+ for (var i = 0; i < len; i++) {
53
+ if (i in t) {
54
+ var val = t[i]; // in case fun mutates this
55
+ if (fun && fun.call(thisp, val, i, t)) {
56
+ res.push(val);
57
+ }
58
+ }
59
+ }
60
+
61
+ return res;
62
+ };
63
+
64
+ if (!Function.prototype.bind) {
65
+ Function.prototype.bind = function (oThis) {
66
+ if (typeof this !== "function") {
67
+ // closest thing possible to the ECMAScript 5 internal IsCallable function
68
+ throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
69
+ }
70
+
71
+ var aArgs = Array.prototype.slice.call(arguments, 1),
72
+ fToBind = this,
73
+ fNOP = function () {},
74
+ fBound = function () {
75
+ return fToBind.apply(this instanceof fNOP && oThis
76
+ ? this
77
+ : oThis,
78
+ aArgs.concat(Array.prototype.slice.call(arguments)));
79
+ };
80
+
81
+ fNOP.prototype = this.prototype;
82
+ fBound.prototype = new fNOP();
83
+
84
+ return fBound;
85
+ };
86
+ }
87
+ }
88
+
89
+ // fake stop() for zepto.
90
+ $.fn.stop = $.fn.stop || function() {
91
+ return this;
92
+ };
93
+ }());
94
+
95
+ ;(function (window, document, undefined) {
96
+ 'use strict';
97
+
98
+ window.Foundation = {
99
+ name : 'Foundation',
100
+
101
+ version : '4.0.8',
102
+
103
+ // global Foundation cache object
104
+ cache : {},
105
+
106
+ init : function (scope, libraries, method, options, response, /* internal */ nc) {
107
+ var library_arr,
108
+ args = [scope, method, options, response],
109
+ responses = [],
110
+ nc = nc || false;
111
+
112
+ // disable library error catching,
113
+ // used for development only
114
+ if (nc) this.nc = nc;
115
+
116
+ // set foundation global scope
117
+ this.scope = scope || this.scope;
118
+
119
+ if (libraries && typeof libraries === 'string') {
120
+ if (/off/i.test(libraries)) return this.off();
121
+
122
+ library_arr = libraries.split(' ');
123
+
124
+ if (library_arr.length > 0) {
125
+ for (var i = library_arr.length - 1; i >= 0; i--) {
126
+ responses.push(this.init_lib(library_arr[i], args));
127
+ }
128
+ }
129
+ } else {
130
+ for (var lib in this.libs) {
131
+ responses.push(this.init_lib(lib, args));
132
+ }
133
+ }
134
+
135
+ // if first argument is callback, add to args
136
+ if (typeof libraries === 'function') {
137
+ args.unshift(libraries);
138
+ }
139
+
140
+ return this.response_obj(responses, args);
141
+ },
142
+
143
+ response_obj : function (response_arr, args) {
144
+ for (var callback in args) {
145
+ if (typeof args[callback] === 'function') {
146
+ return args[callback]({
147
+ errors: response_arr.filter(function (s) {
148
+ if (typeof s === 'string') return s;
149
+ })
150
+ });
151
+ }
152
+ }
153
+
154
+ return response_arr;
155
+ },
156
+
157
+ init_lib : function (lib, args) {
158
+ return this.trap(function () {
159
+ if (this.libs.hasOwnProperty(lib)) {
160
+ this.patch(this.libs[lib]);
161
+ return this.libs[lib].init.apply(this.libs[lib], args);
162
+ }
163
+ }.bind(this), lib);
164
+ },
165
+
166
+ trap : function (fun, lib) {
167
+ if (!this.nc) {
168
+ try {
169
+ return fun();
170
+ } catch (e) {
171
+ return this.error({name: lib, message: 'could not be initialized', more: e.name + ' ' + e.message});
172
+ }
173
+ }
174
+
175
+ return fun();
176
+ },
177
+
178
+ patch : function (lib) {
179
+ this.fix_outer(lib);
180
+ },
181
+
182
+ inherit : function (scope, methods) {
183
+ var methods_arr = methods.split(' ');
184
+
185
+ for (var i = methods_arr.length - 1; i >= 0; i--) {
186
+ if (this.lib_methods.hasOwnProperty(methods_arr[i])) {
187
+ this.libs[scope.name][methods_arr[i]] = this.lib_methods[methods_arr[i]];
188
+ }
189
+ }
190
+ },
191
+
192
+ random_str : function (length) {
193
+ var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz'.split('');
194
+
195
+ if (!length) {
196
+ length = Math.floor(Math.random() * chars.length);
197
+ }
198
+
199
+ var str = '';
200
+ for (var i = 0; i < length; i++) {
201
+ str += chars[Math.floor(Math.random() * chars.length)];
202
+ }
203
+ return str;
204
+ },
205
+
206
+ libs : {},
207
+
208
+ // methods that can be inherited in libraries
209
+ lib_methods : {
210
+ set_data : function (node, data) {
211
+ // this.name references the name of the library calling this method
212
+ var id = [this.name,+new Date(),Foundation.random_str(5)].join('-');
213
+
214
+ Foundation.cache[id] = data;
215
+ node.attr('data-' + this.name + '-id', id);
216
+ return data;
217
+ },
218
+
219
+ get_data : function (node) {
220
+ return Foundation.cache[node.attr('data-' + this.name + '-id')];
221
+ },
222
+
223
+ remove_data : function (node) {
224
+ if (node) {
225
+ delete Foundation.cache[node.attr('data-' + this.name + '-id')];
226
+ node.attr('data-' + this.name + '-id', '');
227
+ } else {
228
+ $('[data-' + this.name + '-id]').each(function () {
229
+ delete Foundation.cache[$(this).attr('data-' + this.name + '-id')];
230
+ $(this).attr('data-' + this.name + '-id', '');
231
+ });
232
+ }
233
+ },
234
+
235
+ throttle : function(fun, delay) {
236
+ var timer = null;
237
+ return function () {
238
+ var context = this, args = arguments;
239
+ clearTimeout(timer);
240
+ timer = setTimeout(function () {
241
+ fun.apply(context, args);
242
+ }, delay);
243
+ };
244
+ },
245
+
246
+ // parses data-options attribute on nodes and turns
247
+ // them into an object
248
+ data_options : function (el) {
249
+ var opts = {}, ii, p,
250
+ opts_arr = (el.attr('data-options') || ':').split(';'),
251
+ opts_len = opts_arr.length;
252
+
253
+ function isNumber (o) {
254
+ return ! isNaN (o-0) && o !== null && o !== "" && o !== false && o !== true;
255
+ }
256
+
257
+ function trim(str) {
258
+ if (typeof str === 'string') return $.trim(str);
259
+ return str;
260
+ }
261
+
262
+ // parse options
263
+ for (ii = opts_len - 1; ii >= 0; ii--) {
264
+ p = opts_arr[ii].split(':');
265
+
266
+ if (/true/i.test(p[1])) p[1] = true;
267
+ if (/false/i.test(p[1])) p[1] = false;
268
+ if (isNumber(p[1])) p[1] = parseInt(p[1], 10);
269
+
270
+ if (p.length === 2 && p[0].length > 0) {
271
+ opts[trim(p[0])] = trim(p[1]);
272
+ }
273
+ }
274
+
275
+ return opts;
276
+ },
277
+
278
+ delay : function (fun, delay) {
279
+ return setTimeout(fun, delay);
280
+ },
281
+
282
+ // animated scrolling
283
+ scrollTo : function (el, to, duration) {
284
+ if (duration < 0) return;
285
+ var difference = to - $(window).scrollTop();
286
+ var perTick = difference / duration * 10;
287
+
288
+ this.scrollToTimerCache = setTimeout(function() {
289
+ if (!isNaN(parseInt(perTick, 10))) {
290
+ window.scrollTo(0, $(window).scrollTop() + perTick);
291
+ this.scrollTo(el, to, duration - 10);
292
+ }
293
+ }.bind(this), 10);
294
+ },
295
+
296
+ // not supported in core Zepto
297
+ scrollLeft : function (el) {
298
+ if (!el.length) return;
299
+ return ('scrollLeft' in el[0]) ? el[0].scrollLeft : el[0].pageXOffset;
300
+ },
301
+
302
+ // test for empty object or array
303
+ empty : function (obj) {
304
+ if (obj.length && obj.length > 0) return false;
305
+ if (obj.length && obj.length === 0) return true;
306
+
307
+ for (var key in obj) {
308
+ if (hasOwnProperty.call(obj, key)) return false;
309
+ }
310
+
311
+ return true;
312
+ }
313
+ },
314
+
315
+ fix_outer : function (lib) {
316
+ lib.outerHeight = function (el, bool) {
317
+ if (typeof Zepto === 'function') {
318
+ return el.height();
319
+ }
320
+
321
+ if (typeof bool !== 'undefined') {
322
+ return el.outerHeight(bool);
323
+ }
324
+
325
+ return el.outerHeight();
326
+ };
327
+
328
+ lib.outerWidth = function (el) {
329
+ if (typeof Zepto === 'function') {
330
+ return el.width();
331
+ }
332
+
333
+ if (typeof bool !== 'undefined') {
334
+ return el.outerWidth(bool);
335
+ }
336
+
337
+ return el.outerWidth();
338
+ };
339
+ },
340
+
341
+ error : function (error) {
342
+ return error.name + ' ' + error.message + '; ' + error.more;
343
+ },
344
+
345
+ // remove all foundation events.
346
+ off: function () {
347
+ $(this.scope).off('.fndtn');
348
+ $(window).off('.fndtn');
349
+ return true;
350
+ },
351
+
352
+ zj : function () {
353
+ try {
354
+ return Zepto;
355
+ } catch (e) {
356
+ return jQuery;
357
+ }
358
+ }()
359
+ },
360
+
361
+ $.fn.foundation = function () {
362
+ var args = Array.prototype.slice.call(arguments, 0);
363
+
364
+ return this.each(function () {
365
+ Foundation.init.apply(Foundation, [this].concat(args));
366
+ return this;
367
+ });
368
+ };
369
+
370
+ }(this, this.document));
371
+
372
+ })(libFuncName);
@@ -0,0 +1,130 @@
1
+ /*jslint unparam: true, browser: true, indent: 2 */
2
+
3
+ ;(function ($, window, document, undefined) {
4
+ 'use strict';
5
+
6
+ Foundation.libs.magellan = {
7
+ name : 'magellan',
8
+
9
+ version : '4.0.0',
10
+
11
+ settings : {
12
+ activeClass: 'active'
13
+ },
14
+
15
+ init : function (scope, method, options) {
16
+ this.scope = scope || this.scope;
17
+ Foundation.inherit(this, 'data_options');
18
+
19
+ if (typeof method === 'object') {
20
+ $.extend(true, this.settings, method);
21
+ }
22
+
23
+ if (typeof method != 'string') {
24
+ if (!this.settings.init) {
25
+ this.fixed_magellan = $("[data-magellan-expedition]");
26
+ this.set_threshold();
27
+ this.last_destination = $('[data-magellan-destination]').last();
28
+ this.events();
29
+ }
30
+
31
+ return this.settings.init;
32
+ } else {
33
+ return this[method].call(this, options);
34
+ }
35
+ },
36
+
37
+ events : function () {
38
+ var self = this;
39
+ $(this.scope).on('arrival.fndtn.magellan', '[data-magellan-arrival]', function (e) {
40
+ var $destination = $(this),
41
+ $expedition = $destination.closest('[data-magellan-expedition]'),
42
+ activeClass = $expedition.attr('data-magellan-active-class')
43
+ || self.settings.activeClass;
44
+
45
+ $destination
46
+ .closest('[data-magellan-expedition]')
47
+ .find('[data-magellan-arrival]')
48
+ .not($destination)
49
+ .removeClass(activeClass);
50
+ $destination.addClass(activeClass);
51
+ });
52
+
53
+ this.fixed_magellan
54
+ .on('update-position.fndtn.magellan', function(){
55
+ var $el = $(this);
56
+ // $el.data("magellan-fixed-position","");
57
+ //$el.data("magellan-top-offset", "");
58
+ })
59
+ .trigger('update-position');
60
+
61
+ $(window)
62
+ .on('resize.fndtn.magellan', function() {
63
+ this.fixed_magellan.trigger('update-position');
64
+ }.bind(this))
65
+
66
+ .on('scroll.fndtn.magellan', function() {
67
+ var windowScrollTop = $(window).scrollTop();
68
+ self.fixed_magellan.each(function() {
69
+ var $expedition = $(this);
70
+ if (typeof $expedition.data('magellan-top-offset') === 'undefined') {
71
+ $expedition.data('magellan-top-offset', $expedition.offset().top);
72
+ }
73
+ if (typeof $expedition.data('magellan-fixed-position') === 'undefined') {
74
+ $expedition.data('magellan-fixed-position', false)
75
+ }
76
+ var fixed_position = (windowScrollTop + self.settings.threshold) > $expedition.data("magellan-top-offset");
77
+ var attr = $expedition.attr('data-magellan-top-offset');
78
+
79
+ if ($expedition.data("magellan-fixed-position") != fixed_position) {
80
+ $expedition.data("magellan-fixed-position", fixed_position);
81
+ if (fixed_position) {
82
+ $expedition.css({position:"fixed", top:0});
83
+ } else {
84
+ $expedition.css({position:"", top:""});
85
+ }
86
+ if (fixed_position && typeof attr != 'undefined' && attr != false) {
87
+ $expedition.css({position:"fixed", top:attr + "px"});
88
+ }
89
+ }
90
+ });
91
+ });
92
+
93
+
94
+ if (this.last_destination.length > 0) {
95
+ $(window).on('scroll.fndtn.magellan', function (e) {
96
+ var windowScrollTop = $(window).scrollTop(),
97
+ scrolltopPlusHeight = windowScrollTop + $(window).height(),
98
+ lastDestinationTop = Math.ceil(self.last_destination.offset().top);
99
+
100
+ $('[data-magellan-destination]').each(function () {
101
+ var $destination = $(this),
102
+ destination_name = $destination.attr('data-magellan-destination'),
103
+ topOffset = $destination.offset().top - windowScrollTop;
104
+
105
+ if (topOffset <= self.settings.threshold) {
106
+ $("[data-magellan-arrival='" + destination_name + "']").trigger('arrival');
107
+ }
108
+ // In large screens we may hit the bottom of the page and dont reach the top of the last magellan-destination, so lets force it
109
+ if (scrolltopPlusHeight >= $(self.scope).height() && lastDestinationTop > windowScrollTop && lastDestinationTop < scrolltopPlusHeight) {
110
+ $('[data-magellan-arrival]').last().trigger('arrival');
111
+ }
112
+ });
113
+ });
114
+ }
115
+
116
+ this.settings.init = true;
117
+ },
118
+
119
+ set_threshold : function () {
120
+ if (!this.settings.threshold) {
121
+ this.settings.threshold = (this.fixed_magellan.length > 0) ?
122
+ this.outerHeight(this.fixed_magellan, true) : 0;
123
+ }
124
+ },
125
+
126
+ off : function () {
127
+ $(this.scope).off('.fndtn.magellan');
128
+ }
129
+ };
130
+ }(Foundation.zj, this, this.document));