helios 0.3.0 → 0.4.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 (27) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +93 -71
  3. data/README.md +150 -127
  4. data/helios.gemspec +5 -4
  5. data/lib/helios/backend/push-notification.rb +1 -0
  6. data/lib/helios/commands/link.rb +2 -0
  7. data/lib/helios/commands/new.rb +1 -0
  8. data/lib/helios/frontend/javascripts/vendor/foundation.js +163 -47
  9. data/lib/helios/frontend/javascripts/vendor/foundation/foundation.alerts.js +6 -4
  10. data/lib/helios/frontend/javascripts/vendor/foundation/foundation.clearing.js +70 -32
  11. data/lib/helios/frontend/javascripts/vendor/foundation/foundation.dropdown.js +87 -31
  12. data/lib/helios/frontend/javascripts/vendor/foundation/foundation.forms.js +360 -238
  13. data/lib/helios/frontend/javascripts/vendor/foundation/foundation.interchange.js +271 -0
  14. data/lib/helios/frontend/javascripts/vendor/foundation/foundation.joyride.js +279 -48
  15. data/lib/helios/frontend/javascripts/vendor/foundation/foundation.magellan.js +8 -4
  16. data/lib/helios/frontend/javascripts/vendor/foundation/foundation.orbit.js +59 -24
  17. data/lib/helios/frontend/javascripts/vendor/foundation/foundation.placeholder.js +21 -1
  18. data/lib/helios/frontend/javascripts/vendor/foundation/foundation.reveal.js +100 -42
  19. data/lib/helios/frontend/javascripts/vendor/foundation/foundation.section.js +299 -60
  20. data/lib/helios/frontend/javascripts/vendor/foundation/foundation.tooltips.js +26 -13
  21. data/lib/helios/frontend/javascripts/vendor/foundation/foundation.topbar.js +154 -59
  22. data/lib/helios/frontend/javascripts/vendor/foundation/index.js +17 -0
  23. data/lib/helios/frontend/stylesheets/screen.sass +0 -1
  24. data/lib/helios/frontend/templates/push-notification/devices.jst.tpl +0 -3
  25. data/lib/helios/templates/.gitignore.erb +32 -0
  26. data/lib/helios/version.rb +1 -1
  27. metadata +31 -14
@@ -6,27 +6,34 @@
6
6
  Foundation.libs.section = {
7
7
  name: 'section',
8
8
 
9
- version : '4.0.3',
9
+ version : '4.2.3',
10
10
 
11
11
  settings : {
12
12
  deep_linking: false,
13
+ small_breakpoint: 768,
13
14
  one_up: true,
15
+ section_selector : '[data-section]',
16
+ region_selector : 'section, .section, [data-section-region]',
17
+ title_selector : '.title, [data-section-title]',
18
+ active_region_selector : 'section.active, .section.active, .active[data-section-region]',
19
+ content_selector : '.content, [data-section-content]',
20
+ nav_selector : '[data-section="vertical-nav"], [data-section="horizontal-nav"]',
14
21
  callback: function (){}
15
22
  },
16
23
 
17
24
  init : function (scope, method, options) {
18
- this.scope = scope || this.scope;
19
- Foundation.inherit(this, 'throttle data_options');
25
+ var self = this;
26
+ Foundation.inherit(this, 'throttle data_options position_right offset_right');
20
27
 
21
28
  if (typeof method === 'object') {
22
- $.extend(true, this.settings, method);
29
+ $.extend(true, self.settings, method);
23
30
  }
24
31
 
25
- if (typeof method != 'string') {
32
+ if (typeof method !== 'string') {
26
33
  this.set_active_from_hash();
27
- if (!this.settings.init) this.events();
34
+ this.events();
28
35
 
29
- return this.settings.init;
36
+ return true;
30
37
  } else {
31
38
  return this[method].call(this, options);
32
39
  }
@@ -34,134 +41,366 @@
34
41
 
35
42
  events : function () {
36
43
  var self = this;
37
- $(this.scope).on('click.fndtn.section', '[data-section] .title', function (e) {
38
- $.extend(true, self.settings, self.data_options($(this).closest('[data-section]')));
39
- self.toggle_active.call(this, e, self);
40
- });
41
44
 
42
- $(window).on('resize.fndtn.section', self.throttle(function () {
43
- self.resize.call(this);
44
- }, 30)).trigger('resize');
45
+ $(this.scope)
46
+ .on('click.fndtn.section', '[data-section] .title, [data-section] [data-section-title]', function (e) {
47
+ var $this = $(this),
48
+ section = $this.closest(self.settings.region_selector);
49
+
50
+ if (section.children(self.settings.content_selector).length > 0) {
51
+ self.toggle_active.call(this, e, self);
52
+ self.reflow();
53
+ }
54
+ });
55
+
56
+ $(window)
57
+ .on('resize.fndtn.section', self.throttle(function () {
58
+ self.resize.call(this);
59
+ }, 30))
60
+ .on('hashchange', function () {
61
+ if (!self.settings.toggled){
62
+ self.set_active_from_hash();
63
+ $(this).trigger('resize');
64
+ }
65
+ }).trigger('resize');
66
+
67
+ $(document)
68
+ .on('click.fndtn.section', function (e) {
69
+ if ($(e.target).closest(self.settings.title_selector).length < 1) {
70
+ $(self.settings.nav_selector)
71
+ .children(self.settings.region_selector)
72
+ .removeClass('active')
73
+ .attr('style', '');
74
+ }
75
+ });
45
76
 
46
- this.settings.init = true;
47
77
  },
48
78
 
49
79
  toggle_active : function (e, self) {
50
80
  var $this = $(this),
51
- section = $this.closest('section, .section'),
52
- content = section.find('.content'),
53
- parent = section.closest('[data-section]'),
54
- self = Foundation.libs.section;
81
+ self = Foundation.libs.section,
82
+ region = $this.closest(self.settings.region_selector),
83
+ content = $this.siblings(self.settings.content_selector),
84
+ parent = region.parent(),
85
+ settings = $.extend({}, self.settings, self.data_options(parent)),
86
+ prev_active_section = parent
87
+ .children(self.settings.active_region_selector);
88
+
89
+ self.settings.toggled = true;
55
90
 
56
- if (!self.settings.deep_linking && content.length > 0) {
91
+ if (!settings.deep_linking && content.length > 0) {
57
92
  e.preventDefault();
58
93
  }
59
94
 
60
- if (section.hasClass('active')) {
95
+ if (region.hasClass('active')) {
96
+ // this is causing the style flash.
61
97
  if (self.small(parent)
62
- || self.is_vertical(parent)
98
+ || self.is_vertical_nav(parent)
99
+ || self.is_horizontal_nav(parent)
63
100
  || self.is_accordion(parent)) {
64
- section
65
- .removeClass('active')
66
- .attr('style', '');
101
+ if (prev_active_section[0] !== region[0]
102
+ || (prev_active_section[0] === region[0] && !settings.one_up)) {
103
+ region
104
+ .removeClass('active')
105
+ .attr('style', '');
106
+ }
67
107
  }
68
108
  } else {
69
- if (self.small(parent) || self.settings.one_up) {
70
- $this
71
- .closest('[data-section]')
72
- .find('section, .section')
73
- .removeClass('active')
74
- .attr('style', '');
109
+ var prev_active_section = parent
110
+ .children(self.settings.active_region_selector),
111
+ title_height = self.outerHeight(region
112
+ .children(self.settings.title_selector));
113
+
114
+ if (self.small(parent) || settings.one_up) {
75
115
 
76
- section.css('padding-top', self.outerHeight(section.find('.title')) - 1);
116
+ if (self.small(parent)) {
117
+ prev_active_section.attr('style', '');
118
+ } else {
119
+ prev_active_section.attr('style',
120
+ 'visibility: hidden; padding-top: '+title_height+'px;');
121
+ }
77
122
  }
78
123
 
79
124
  if (self.small(parent)) {
80
- section.attr('style', '');
125
+ region.attr('style', '');
126
+ } else {
127
+ region.css('padding-top', title_height);
81
128
  }
82
129
 
83
- section.addClass('active');
130
+ region.addClass('active');
131
+
132
+ if (prev_active_section.length > 0) {
133
+ prev_active_section
134
+ .removeClass('active')
135
+ .attr('style', '');
136
+ }
137
+
138
+ // Toggle the content display attribute. This is done to
139
+ // ensure accurate outerWidth measurements that account for
140
+ // the scrollbar.
141
+ if (self.is_vertical_tabs(parent)) {
142
+ content.css('display', 'block');
143
+
144
+ if (prev_active_section !== null) {
145
+ prev_active_section
146
+ .children(self.settings.content_selector)
147
+ .css('display', 'none');
148
+ }
149
+ }
84
150
  }
85
151
 
86
- self.settings.callback();
152
+ setTimeout(function () {
153
+ self.settings.toggled = false;
154
+ }, 300);
155
+
156
+ settings.callback();
87
157
  },
88
158
 
89
159
  resize : function () {
90
- var sections = $('[data-section]'),
91
- self = Foundation.libs.section;
160
+ var self = Foundation.libs.section,
161
+ sections = $(self.settings.section_selector);
92
162
 
93
163
  sections.each(function() {
94
164
  var $this = $(this),
95
- active_section = $this.find('section.active, .section.active');
165
+ active_section = $this
166
+ .children(self.settings.active_region_selector),
167
+ settings = $.extend({}, self.settings, self.data_options($this));
168
+
96
169
  if (active_section.length > 1) {
97
170
  active_section
98
171
  .not(':first')
99
172
  .removeClass('active')
100
173
  .attr('style', '');
101
174
  } else if (active_section.length < 1
102
- && !self.is_vertical($this)
175
+ && !self.is_vertical_nav($this)
176
+ && !self.is_horizontal_nav($this)
103
177
  && !self.is_accordion($this)) {
104
- var first = $this.find('section, .section').first();
105
- first.addClass('active');
178
+
179
+ var first = $this.children(self.settings.region_selector).first();
180
+
181
+ if (settings.one_up || !self.small($this)) {
182
+ first.addClass('active');
183
+ }
106
184
 
107
185
  if (self.small($this)) {
108
186
  first.attr('style', '');
109
187
  } else {
110
- first.css('padding-top', self.outerHeight(first.find('.title')) - 1);
188
+ first.css('padding-top', self.outerHeight(first
189
+ .children(self.settings.title_selector)));
111
190
  }
112
191
  }
113
192
 
114
193
  if (self.small($this)) {
115
194
  active_section.attr('style', '');
116
195
  } else {
117
- active_section.css('padding-top', self.outerHeight(active_section.find('.title')) - 1);
196
+ active_section.css('padding-top', self.outerHeight(active_section
197
+ .children(self.settings.title_selector)));
118
198
  }
199
+
119
200
  self.position_titles($this);
201
+
202
+ if ( (self.is_horizontal_nav($this) && !self.small($this))
203
+ || self.is_vertical_tabs($this) && !self.small($this)) {
204
+ self.position_content($this);
205
+ } else {
206
+ self.position_content($this, false);
207
+ }
120
208
  });
121
209
  },
122
210
 
123
- is_vertical : function (el) {
124
- return el.hasClass('vertical-nav');
211
+ is_vertical_nav : function (el) {
212
+ return /vertical-nav/i.test(el.data('section'));
213
+ },
214
+
215
+ is_horizontal_nav : function (el) {
216
+ return /horizontal-nav/i.test(el.data('section'));
125
217
  },
126
218
 
127
219
  is_accordion : function (el) {
128
- return el.hasClass('accordion');
220
+ return /accordion/i.test(el.data('section'));
221
+ },
222
+
223
+ is_horizontal_tabs : function (el) {
224
+ return /^tabs$/i.test(el.data('section'));
225
+ },
226
+
227
+ is_vertical_tabs : function (el) {
228
+ return /vertical-tabs/i.test(el.data('section'));
129
229
  },
130
230
 
131
231
  set_active_from_hash : function () {
132
232
  var hash = window.location.hash.substring(1),
133
233
  sections = $('[data-section]'),
134
234
  self = this;
135
-
136
235
  sections.each(function () {
137
- var section = $(this);
138
- $.extend(true, self.settings, self.data_options(section));
139
-
140
- if (hash.length > 0 && self.settings.deep_linking) {
141
- section
142
- .find('.content[data-slug="' + hash + '"]')
143
- .closest('section, .section')
144
- .addClass('active');
236
+ var section = $(this),
237
+ settings = $.extend({}, self.settings, self.data_options(section));
238
+
239
+ if (hash.length > 0 && settings.deep_linking) {
240
+ var regions = section
241
+ .children(self.settings.region_selector)
242
+ .attr('style', '')
243
+ .removeClass('active');
244
+
245
+ var hash_regions = regions.map(function () {
246
+ var content = $(self.settings.content_selector, this),
247
+ content_slug = content.data('slug');
248
+
249
+ if (new RegExp(content_slug, 'i').test(hash))
250
+ return content;
251
+ });
252
+
253
+
254
+ var count = hash_regions.length;
255
+
256
+ for (var i = count - 1; i >= 0; i--) {
257
+ $(hash_regions[i]).parent().addClass('active');
258
+ }
145
259
  }
146
260
  });
147
261
  },
148
262
 
149
263
  position_titles : function (section, off) {
150
- var titles = section.find('.title'),
264
+ var self = this,
265
+ titles = section
266
+ .children(this.settings.region_selector)
267
+ .map(function () {
268
+ return $(this).children(self.settings.title_selector);
269
+ }),
151
270
  previous_width = 0,
271
+ previous_height = 0,
152
272
  self = this;
153
273
 
154
274
  if (typeof off === 'boolean') {
155
275
  titles.attr('style', '');
276
+
156
277
  } else {
157
278
  titles.each(function () {
158
- $(this).css('left', previous_width);
159
- previous_width += self.outerWidth($(this));
279
+ if (self.is_vertical_tabs(section)) {
280
+ $(this).css('top', previous_height);
281
+ previous_height += self.outerHeight($(this));
282
+ } else {
283
+ if (!self.rtl) {
284
+ $(this).css('left', previous_width);
285
+ } else {
286
+ $(this).css('right', previous_width);
287
+ }
288
+ previous_width += self.outerWidth($(this));
289
+ }
160
290
  });
161
291
  }
162
292
  },
163
293
 
294
+ position_content : function (section, off) {
295
+ var self = this,
296
+ regions = section.children(self.settings.region_selector),
297
+ titles = regions
298
+ .map(function () {
299
+ return $(this).children(self.settings.title_selector);
300
+ }),
301
+ content = regions
302
+ .map(function () {
303
+ return $(this).children(self.settings.content_selector);
304
+ });
305
+
306
+ if (typeof off === 'boolean') {
307
+ content.attr('style', '');
308
+ section.attr('style', '');
309
+
310
+ // Reset the minHeight and maxWidth values (only applicable to
311
+ // vertical tabs)
312
+ content.css('minHeight', '');
313
+ content.css('maxWidth', '');
314
+ } else {
315
+ if (self.is_vertical_tabs(section)
316
+ && !self.small(section)) {
317
+ var content_min_height = 0,
318
+ content_min_width = Number.MAX_VALUE,
319
+ title_width = null;
320
+
321
+ regions.each(function () {
322
+ var region = $(this),
323
+ title = region.children(self.settings.title_selector),
324
+ content = region.children(self.settings.content_selector),
325
+ content_width = 0;
326
+
327
+ title_width = self.outerWidth(title);
328
+ content_width = self.outerWidth(section) - title_width;
329
+
330
+ if (content_width < content_min_width) {
331
+ content_min_width = content_width;
332
+ }
333
+
334
+ // Increment the minimum height of the content region
335
+ // to align with the height of the titles.
336
+ content_min_height += self.outerHeight(title);
337
+
338
+ // Set all of the inactive tabs to 'display: none'
339
+ // The CSS sets all of the tabs as 'display: block'
340
+ // in order to account for scrollbars when measuring the width
341
+ // of the content regions.
342
+ if (!$(this).hasClass('active')) {
343
+ content.css('display', 'none');
344
+ }
345
+ });
346
+
347
+ regions.each(function () {
348
+ var content = $(this).children(self.settings.content_selector);
349
+ content.css('minHeight', content_min_height);
350
+
351
+ // Remove 2 pixels to account for the right-shift in the CSS
352
+ content.css('maxWidth', content_min_width - 2);
353
+ });
354
+
355
+ } else {
356
+ regions.each(function () {
357
+ var region = $(this),
358
+ title = region.children(self.settings.title_selector),
359
+ content = region.children(self.settings.content_selector);
360
+ if (!self.rtl) {
361
+ content
362
+ .css({left: title.position().left - 1,
363
+ top: self.outerHeight(title) - 2});
364
+ } else {
365
+ content
366
+ .css({right: self.position_right(title) + 1,
367
+ top: self.outerHeight(title) - 2});
368
+ }
369
+ });
370
+
371
+ // temporary work around for Zepto outerheight calculation issues.
372
+ if (typeof Zepto === 'function') {
373
+ section.height(this.outerHeight($(titles[0])));
374
+ } else {
375
+ section.height(this.outerHeight($(titles[0])) - 2);
376
+ }
377
+ }
378
+ }
379
+ },
380
+
381
+ position_right : function (el) {
382
+ var self = this,
383
+ section = el.closest(this.settings.section_selector),
384
+ regions = section.children(this.settings.region_selector),
385
+ section_width = el.closest(this.settings.section_selector).width(),
386
+ offset = regions
387
+ .map(function () {
388
+ return $(this).children(self.settings.title_selector);
389
+ }).length;
390
+ return (section_width - el.position().left - el.width() * (el.index() + 1) - offset);
391
+ },
392
+
393
+ reflow : function (scope) {
394
+ var scope = scope || document;
395
+ $(this.settings.section_selector, scope).trigger('resize');
396
+ },
397
+
164
398
  small : function (el) {
399
+ var settings = $.extend({}, this.settings, this.data_options(el));
400
+
401
+ if (this.is_horizontal_tabs(el)) {
402
+ return false;
403
+ }
165
404
  if (el && this.is_accordion(el)) {
166
405
  return true;
167
406
  }
@@ -171,13 +410,13 @@
171
410
  if ($('html').hasClass('ie8compat')) {
172
411
  return true;
173
412
  }
174
- return $(this.scope).width() < 768;
413
+ return $(this.scope).width() < settings.small_breakpoint;
175
414
  },
176
415
 
177
416
  off : function () {
178
417
  $(this.scope).off('.fndtn.section');
179
418
  $(window).off('.fndtn.section');
180
- this.settings.init = false;
419
+ $(document).off('.fndtn.section')
181
420
  }
182
421
  };
183
422
  }(Foundation.zj, this, this.document));