woyo-server 0.0.1 → 0.0.2

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 (48) hide show
  1. checksums.yaml +4 -4
  2. data/lib/woyo/runner.rb +49 -13
  3. data/lib/woyo/server/server.rb +4 -2
  4. data/lib/woyo/server/version.rb +1 -1
  5. data/public/server/default.html +42 -0
  6. data/public/server/foundation-5.2.2/css/foundation.css +5263 -0
  7. data/public/server/foundation-5.2.2/css/foundation.min.css +1 -0
  8. data/public/server/foundation-5.2.2/css/normalize.css +423 -0
  9. data/public/server/foundation-5.2.2/humans.txt +8 -0
  10. data/public/server/foundation-5.2.2/img/.gitkeep +1 -0
  11. data/public/server/foundation-5.2.2/index.html +166 -0
  12. data/public/server/foundation-5.2.2/js/foundation/foundation.abide.js +299 -0
  13. data/public/server/foundation-5.2.2/js/foundation/foundation.accordion.js +54 -0
  14. data/public/server/foundation-5.2.2/js/foundation/foundation.alert.js +43 -0
  15. data/public/server/foundation-5.2.2/js/foundation/foundation.clearing.js +531 -0
  16. data/public/server/foundation-5.2.2/js/foundation/foundation.dropdown.js +306 -0
  17. data/public/server/foundation-5.2.2/js/foundation/foundation.equalizer.js +68 -0
  18. data/public/server/foundation-5.2.2/js/foundation/foundation.interchange.js +331 -0
  19. data/public/server/foundation-5.2.2/js/foundation/foundation.joyride.js +849 -0
  20. data/public/server/foundation-5.2.2/js/foundation/foundation.js +609 -0
  21. data/public/server/foundation-5.2.2/js/foundation/foundation.magellan.js +173 -0
  22. data/public/server/foundation-5.2.2/js/foundation/foundation.offcanvas.js +50 -0
  23. data/public/server/foundation-5.2.2/js/foundation/foundation.orbit.js +606 -0
  24. data/public/server/foundation-5.2.2/js/foundation/foundation.reveal.js +427 -0
  25. data/public/server/foundation-5.2.2/js/foundation/foundation.slider.js +200 -0
  26. data/public/server/foundation-5.2.2/js/foundation/foundation.tab.js +168 -0
  27. data/public/server/foundation-5.2.2/js/foundation/foundation.tooltip.js +272 -0
  28. data/public/server/foundation-5.2.2/js/foundation/foundation.topbar.js +422 -0
  29. data/public/server/foundation-5.2.2/js/foundation.min.js +10 -0
  30. data/public/server/foundation-5.2.2/js/vendor/fastclick.js +9 -0
  31. data/public/server/foundation-5.2.2/js/vendor/jquery.cookie.js +8 -0
  32. data/public/server/foundation-5.2.2/js/vendor/jquery.js +26 -0
  33. data/public/server/foundation-5.2.2/js/vendor/modernizr.js +8 -0
  34. data/public/server/foundation-5.2.2/js/vendor/placeholder.js +2 -0
  35. data/public/server/foundation-5.2.2/robots.txt +4 -0
  36. data/public/server/jquery-2.1.1/jquery.js +9190 -0
  37. data/public/server/jquery-2.1.1/jquery.min.js +4 -0
  38. data/public/server/jquery-2.1.1/jquery.min.map +1 -0
  39. data/spec/spec_helper.rb +1 -0
  40. data/spec/woyo/server/1_server_spec.rb +30 -6
  41. data/spec/woyo/server/runner_spec.rb +153 -23
  42. data/views/server/layout.haml +17 -0
  43. data/views/{location.haml → server/location.haml} +0 -0
  44. data/woyo-server.gemspec +1 -1
  45. metadata +42 -10
  46. data/public/default.html +0 -15
  47. data/views/layout.haml +0 -6
  48. data/world/default.rb +0 -76
@@ -0,0 +1,422 @@
1
+ ;(function ($, window, document, undefined) {
2
+ 'use strict';
3
+
4
+ Foundation.libs.topbar = {
5
+ name : 'topbar',
6
+
7
+ version: '5.2.2',
8
+
9
+ settings : {
10
+ index : 0,
11
+ sticky_class : 'sticky',
12
+ custom_back_text: true,
13
+ back_text: 'Back',
14
+ is_hover: true,
15
+ mobile_show_parent_link: false,
16
+ scrolltop : true, // jump to top when sticky nav menu toggle is clicked
17
+ sticky_on : 'all'
18
+ },
19
+
20
+ init : function (section, method, options) {
21
+ Foundation.inherit(this, 'add_custom_rule register_media throttle');
22
+ var self = this;
23
+
24
+ self.register_media('topbar', 'foundation-mq-topbar');
25
+
26
+ this.bindings(method, options);
27
+
28
+ self.S('[' + this.attr_name() + ']', this.scope).each(function () {
29
+ var topbar = $(this),
30
+ settings = topbar.data(self.attr_name(true) + '-init'),
31
+ section = self.S('section', this),
32
+ titlebar = topbar.children().filter('ul').first();
33
+ topbar.data('index', 0);
34
+ var topbarContainer = topbar.parent();
35
+ if(topbarContainer.hasClass('fixed') || self.is_sticky(topbar, topbarContainer, settings) ) {
36
+ self.settings.sticky_class = settings.sticky_class;
37
+ self.settings.sticky_topbar = topbar;
38
+ topbar.data('height', topbarContainer.outerHeight());
39
+ topbar.data('stickyoffset', topbarContainer.offset().top);
40
+ } else {
41
+ topbar.data('height', topbar.outerHeight());
42
+ }
43
+
44
+ if (!settings.assembled) self.assemble(topbar);
45
+
46
+ if (settings.is_hover) {
47
+ self.S('.has-dropdown', topbar).addClass('not-click');
48
+ } else {
49
+ self.S('.has-dropdown', topbar).removeClass('not-click');
50
+ }
51
+
52
+ // Pad body when sticky (scrolled) or fixed.
53
+ self.add_custom_rule('.f-topbar-fixed { padding-top: ' + topbar.data('height') + 'px }');
54
+
55
+ if (topbarContainer.hasClass('fixed')) {
56
+ self.S('body').addClass('f-topbar-fixed');
57
+ }
58
+ });
59
+
60
+ },
61
+
62
+ is_sticky: function (topbar, topbarContainer, settings) {
63
+ var sticky = topbarContainer.hasClass(settings.sticky_class);
64
+
65
+ if (sticky && settings.sticky_on === 'all') {
66
+ return true;
67
+ } else if (sticky && this.small() && settings.sticky_on === 'small') {
68
+ return true;
69
+ } else if (sticky && this.medium() && settings.sticky_on === 'medium') {
70
+ return true;
71
+ } else if (sticky && this.large() && settings.sticky_on === 'large') {
72
+ return true;
73
+ }
74
+
75
+ return false;
76
+ },
77
+
78
+ toggle: function (toggleEl) {
79
+ var self = this;
80
+
81
+ if (toggleEl) {
82
+ var topbar = self.S(toggleEl).closest('[' + this.attr_name() + ']');
83
+ } else {
84
+ var topbar = self.S('[' + this.attr_name() + ']');
85
+ }
86
+
87
+ var settings = topbar.data(this.attr_name(true) + '-init');
88
+
89
+ var section = self.S('section, .section', topbar);
90
+
91
+ if (self.breakpoint()) {
92
+ if (!self.rtl) {
93
+ section.css({left: '0%'});
94
+ $('>.name', section).css({left: '100%'});
95
+ } else {
96
+ section.css({right: '0%'});
97
+ $('>.name', section).css({right: '100%'});
98
+ }
99
+
100
+ self.S('li.moved', section).removeClass('moved');
101
+ topbar.data('index', 0);
102
+
103
+ topbar
104
+ .toggleClass('expanded')
105
+ .css('height', '');
106
+ }
107
+
108
+ if (settings.scrolltop) {
109
+ if (!topbar.hasClass('expanded')) {
110
+ if (topbar.hasClass('fixed')) {
111
+ topbar.parent().addClass('fixed');
112
+ topbar.removeClass('fixed');
113
+ self.S('body').addClass('f-topbar-fixed');
114
+ }
115
+ } else if (topbar.parent().hasClass('fixed')) {
116
+ if (settings.scrolltop) {
117
+ topbar.parent().removeClass('fixed');
118
+ topbar.addClass('fixed');
119
+ self.S('body').removeClass('f-topbar-fixed');
120
+
121
+ window.scrollTo(0,0);
122
+ } else {
123
+ topbar.parent().removeClass('expanded');
124
+ }
125
+ }
126
+ } else {
127
+ if(self.is_sticky(topbar, topbar.parent(), settings)) {
128
+ topbar.parent().addClass('fixed');
129
+ }
130
+
131
+ if(topbar.parent().hasClass('fixed')) {
132
+ if (!topbar.hasClass('expanded')) {
133
+ topbar.removeClass('fixed');
134
+ topbar.parent().removeClass('expanded');
135
+ self.update_sticky_positioning();
136
+ } else {
137
+ topbar.addClass('fixed');
138
+ topbar.parent().addClass('expanded');
139
+ self.S('body').addClass('f-topbar-fixed');
140
+ }
141
+ }
142
+ }
143
+ },
144
+
145
+ timer : null,
146
+
147
+ events : function (bar) {
148
+ var self = this,
149
+ S = this.S;
150
+
151
+ S(this.scope)
152
+ .off('.topbar')
153
+ .on('click.fndtn.topbar', '[' + this.attr_name() + '] .toggle-topbar', function (e) {
154
+ e.preventDefault();
155
+ self.toggle(this);
156
+ })
157
+ .on('click.fndtn.topbar','.top-bar .top-bar-section li a[href^="#"],[' + this.attr_name() + '] .top-bar-section li a[href^="#"]',function (e) {
158
+ var li = $(this).closest('li');
159
+ if(self.breakpoint() && !li.hasClass('back') && !li.hasClass('has-dropdown'))
160
+ {
161
+ self.toggle();
162
+ }
163
+ })
164
+ .on('click.fndtn.topbar', '[' + this.attr_name() + '] li.has-dropdown', function (e) {
165
+ var li = S(this),
166
+ target = S(e.target),
167
+ topbar = li.closest('[' + self.attr_name() + ']'),
168
+ settings = topbar.data(self.attr_name(true) + '-init');
169
+
170
+ if(target.data('revealId')) {
171
+ self.toggle();
172
+ return;
173
+ }
174
+
175
+ if (self.breakpoint()) return;
176
+ if (settings.is_hover && !Modernizr.touch) return;
177
+
178
+ e.stopImmediatePropagation();
179
+
180
+ if (li.hasClass('hover')) {
181
+ li
182
+ .removeClass('hover')
183
+ .find('li')
184
+ .removeClass('hover');
185
+
186
+ li.parents('li.hover')
187
+ .removeClass('hover');
188
+ } else {
189
+ li.addClass('hover');
190
+
191
+ $(li).siblings().removeClass('hover');
192
+
193
+ if (target[0].nodeName === 'A' && target.parent().hasClass('has-dropdown')) {
194
+ e.preventDefault();
195
+ }
196
+ }
197
+ })
198
+ .on('click.fndtn.topbar', '[' + this.attr_name() + '] .has-dropdown>a', function (e) {
199
+ if (self.breakpoint()) {
200
+
201
+ e.preventDefault();
202
+
203
+ var $this = S(this),
204
+ topbar = $this.closest('[' + self.attr_name() + ']'),
205
+ section = topbar.find('section, .section'),
206
+ dropdownHeight = $this.next('.dropdown').outerHeight(),
207
+ $selectedLi = $this.closest('li');
208
+
209
+ topbar.data('index', topbar.data('index') + 1);
210
+ $selectedLi.addClass('moved');
211
+
212
+ if (!self.rtl) {
213
+ section.css({left: -(100 * topbar.data('index')) + '%'});
214
+ section.find('>.name').css({left: 100 * topbar.data('index') + '%'});
215
+ } else {
216
+ section.css({right: -(100 * topbar.data('index')) + '%'});
217
+ section.find('>.name').css({right: 100 * topbar.data('index') + '%'});
218
+ }
219
+
220
+ topbar.css('height', $this.siblings('ul').outerHeight(true) + topbar.data('height'));
221
+ }
222
+ });
223
+
224
+ S(window).off('.topbar').on('resize.fndtn.topbar', self.throttle(function () {
225
+ self.resize.call(self);
226
+ }, 50)).trigger('resize');
227
+
228
+ S('body').off('.topbar').on('click.fndtn.topbar touchstart.fndtn.topbar', function (e) {
229
+ var parent = S(e.target).closest('li').closest('li.hover');
230
+
231
+ if (parent.length > 0) {
232
+ return;
233
+ }
234
+
235
+ S('[' + self.attr_name() + '] li.hover').removeClass('hover');
236
+ });
237
+
238
+ // Go up a level on Click
239
+ S(this.scope).on('click.fndtn.topbar', '[' + this.attr_name() + '] .has-dropdown .back', function (e) {
240
+ e.preventDefault();
241
+
242
+ var $this = S(this),
243
+ topbar = $this.closest('[' + self.attr_name() + ']'),
244
+ section = topbar.find('section, .section'),
245
+ settings = topbar.data(self.attr_name(true) + '-init'),
246
+ $movedLi = $this.closest('li.moved'),
247
+ $previousLevelUl = $movedLi.parent();
248
+
249
+ topbar.data('index', topbar.data('index') - 1);
250
+
251
+ if (!self.rtl) {
252
+ section.css({left: -(100 * topbar.data('index')) + '%'});
253
+ section.find('>.name').css({left: 100 * topbar.data('index') + '%'});
254
+ } else {
255
+ section.css({right: -(100 * topbar.data('index')) + '%'});
256
+ section.find('>.name').css({right: 100 * topbar.data('index') + '%'});
257
+ }
258
+
259
+ if (topbar.data('index') === 0) {
260
+ topbar.css('height', '');
261
+ } else {
262
+ topbar.css('height', $previousLevelUl.outerHeight(true) + topbar.data('height'));
263
+ }
264
+
265
+ setTimeout(function () {
266
+ $movedLi.removeClass('moved');
267
+ }, 300);
268
+ });
269
+ },
270
+
271
+ resize : function () {
272
+ var self = this;
273
+ self.S('[' + this.attr_name() + ']').each(function () {
274
+ var topbar = self.S(this),
275
+ settings = topbar.data(self.attr_name(true) + '-init');
276
+
277
+ var stickyContainer = topbar.parent('.' + self.settings.sticky_class);
278
+ var stickyOffset;
279
+
280
+ if (!self.breakpoint()) {
281
+ var doToggle = topbar.hasClass('expanded');
282
+ topbar
283
+ .css('height', '')
284
+ .removeClass('expanded')
285
+ .find('li')
286
+ .removeClass('hover');
287
+
288
+ if(doToggle) {
289
+ self.toggle(topbar);
290
+ }
291
+ }
292
+
293
+ if(self.is_sticky(topbar, stickyContainer, settings)) {
294
+ if(stickyContainer.hasClass('fixed')) {
295
+ // Remove the fixed to allow for correct calculation of the offset.
296
+ stickyContainer.removeClass('fixed');
297
+
298
+ stickyOffset = stickyContainer.offset().top;
299
+ if(self.S(document.body).hasClass('f-topbar-fixed')) {
300
+ stickyOffset -= topbar.data('height');
301
+ }
302
+
303
+ topbar.data('stickyoffset', stickyOffset);
304
+ stickyContainer.addClass('fixed');
305
+ } else {
306
+ stickyOffset = stickyContainer.offset().top;
307
+ topbar.data('stickyoffset', stickyOffset);
308
+ }
309
+ }
310
+
311
+ });
312
+ },
313
+
314
+ breakpoint : function () {
315
+ return !matchMedia(Foundation.media_queries['topbar']).matches;
316
+ },
317
+
318
+ small : function () {
319
+ return matchMedia(Foundation.media_queries['small']).matches;
320
+ },
321
+
322
+ medium : function () {
323
+ return matchMedia(Foundation.media_queries['medium']).matches;
324
+ },
325
+
326
+ large : function () {
327
+ return matchMedia(Foundation.media_queries['large']).matches;
328
+ },
329
+
330
+ assemble : function (topbar) {
331
+ var self = this,
332
+ settings = topbar.data(this.attr_name(true) + '-init'),
333
+ section = self.S('section', topbar),
334
+ titlebar = $(this).children().filter('ul').first();
335
+
336
+ // Pull element out of the DOM for manipulation
337
+ section.detach();
338
+
339
+ self.S('.has-dropdown>a', section).each(function () {
340
+ var $link = self.S(this),
341
+ $dropdown = $link.siblings('.dropdown'),
342
+ url = $link.attr('href');
343
+
344
+ if (!$dropdown.find('.title.back').length) {
345
+ if (settings.mobile_show_parent_link && url && url.length > 1) {
346
+ var $titleLi = $('<li class="title back js-generated"><h5><a href="javascript:void(0)"></a></h5></li><li><a class="parent-link js-generated" href="' + url + '">' + $link.text() +'</a></li>');
347
+ } else {
348
+ var $titleLi = $('<li class="title back js-generated"><h5><a href="javascript:void(0)"></a></h5></li>');
349
+ }
350
+
351
+ // Copy link to subnav
352
+ if (settings.custom_back_text == true) {
353
+ $('h5>a', $titleLi).html(settings.back_text);
354
+ } else {
355
+ $('h5>a', $titleLi).html('&laquo; ' + $link.html());
356
+ }
357
+ $dropdown.prepend($titleLi);
358
+ }
359
+ });
360
+
361
+ // Put element back in the DOM
362
+ section.appendTo(topbar);
363
+
364
+ // check for sticky
365
+ this.sticky();
366
+
367
+ this.assembled(topbar);
368
+ },
369
+
370
+ assembled : function (topbar) {
371
+ topbar.data(this.attr_name(true), $.extend({}, topbar.data(this.attr_name(true)), {assembled: true}));
372
+ },
373
+
374
+ height : function (ul) {
375
+ var total = 0,
376
+ self = this;
377
+
378
+ $('> li', ul).each(function () { total += self.S(this).outerHeight(true); });
379
+
380
+ return total;
381
+ },
382
+
383
+ sticky : function () {
384
+ var $window = this.S(window),
385
+ self = this;
386
+
387
+ this.S(window).on('scroll', function() {
388
+ self.update_sticky_positioning();
389
+ });
390
+ },
391
+
392
+ update_sticky_positioning: function() {
393
+ var klass = '.' + this.settings.sticky_class,
394
+ $window = this.S(window),
395
+ self = this;
396
+
397
+ if (self.settings.sticky_topbar && self.is_sticky(this.settings.sticky_topbar,this.settings.sticky_topbar.parent(), this.settings)) {
398
+ var distance = this.settings.sticky_topbar.data('stickyoffset');
399
+ if (!self.S(klass).hasClass('expanded')) {
400
+ if ($window.scrollTop() > (distance)) {
401
+ if (!self.S(klass).hasClass('fixed')) {
402
+ self.S(klass).addClass('fixed');
403
+ self.S('body').addClass('f-topbar-fixed');
404
+ }
405
+ } else if ($window.scrollTop() <= distance) {
406
+ if (self.S(klass).hasClass('fixed')) {
407
+ self.S(klass).removeClass('fixed');
408
+ self.S('body').removeClass('f-topbar-fixed');
409
+ }
410
+ }
411
+ }
412
+ }
413
+ },
414
+
415
+ off : function () {
416
+ this.S(this.scope).off('.fndtn.topbar');
417
+ this.S(window).off('.fndtn.topbar');
418
+ },
419
+
420
+ reflow : function () {}
421
+ };
422
+ }(jQuery, this, this.document));