helios_aim 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +173 -0
- data/LICENSE +19 -0
- data/README.md +363 -0
- data/Rakefile +10 -0
- data/bin/helios +20 -0
- data/helios_aim.gemspec +47 -0
- data/lib/helios.rb +27 -0
- data/lib/helios/backend.rb +64 -0
- data/lib/helios/backend/data.rb +40 -0
- data/lib/helios/backend/in-app-purchase.rb +43 -0
- data/lib/helios/backend/newsstand.rb +97 -0
- data/lib/helios/backend/passbook.rb +41 -0
- data/lib/helios/backend/push-notification.rb +110 -0
- data/lib/helios/commands.rb +4 -0
- data/lib/helios/commands/console.rb +21 -0
- data/lib/helios/commands/link.rb +19 -0
- data/lib/helios/commands/new.rb +76 -0
- data/lib/helios/commands/server.rb +52 -0
- data/lib/helios/frontend.rb +66 -0
- data/lib/helios/frontend/fonts/icons.eot +0 -0
- data/lib/helios/frontend/fonts/icons.ttf +0 -0
- data/lib/helios/frontend/fonts/icons.woff +0 -0
- data/lib/helios/frontend/images/bg.jpg +0 -0
- data/lib/helios/frontend/images/helios.svg +33 -0
- data/lib/helios/frontend/javascripts/helios.coffee +72 -0
- data/lib/helios/frontend/javascripts/helios/collections.coffee +99 -0
- data/lib/helios/frontend/javascripts/helios/models.coffee +23 -0
- data/lib/helios/frontend/javascripts/helios/router.coffee +50 -0
- data/lib/helios/frontend/javascripts/helios/views.coffee +307 -0
- data/lib/helios/frontend/javascripts/vendor/backbone.datagrid.js +662 -0
- data/lib/helios/frontend/javascripts/vendor/backbone.js +1487 -0
- data/lib/helios/frontend/javascripts/vendor/backbone.paginator.js +1046 -0
- data/lib/helios/frontend/javascripts/vendor/codemirror.javascript.js +411 -0
- data/lib/helios/frontend/javascripts/vendor/codemirror.js +3047 -0
- data/lib/helios/frontend/javascripts/vendor/date.js +104 -0
- data/lib/helios/frontend/javascripts/vendor/foundation.js +331 -0
- data/lib/helios/frontend/javascripts/vendor/foundation/foundation.alerts.js +50 -0
- data/lib/helios/frontend/javascripts/vendor/foundation/foundation.clearing.js +478 -0
- data/lib/helios/frontend/javascripts/vendor/foundation/foundation.cookie.js +74 -0
- data/lib/helios/frontend/javascripts/vendor/foundation/foundation.dropdown.js +122 -0
- data/lib/helios/frontend/javascripts/vendor/foundation/foundation.forms.js +403 -0
- data/lib/helios/frontend/javascripts/vendor/foundation/foundation.joyride.js +613 -0
- data/lib/helios/frontend/javascripts/vendor/foundation/foundation.magellan.js +130 -0
- data/lib/helios/frontend/javascripts/vendor/foundation/foundation.orbit.js +355 -0
- data/lib/helios/frontend/javascripts/vendor/foundation/foundation.placeholder.js +159 -0
- data/lib/helios/frontend/javascripts/vendor/foundation/foundation.reveal.js +272 -0
- data/lib/helios/frontend/javascripts/vendor/foundation/foundation.section.js +183 -0
- data/lib/helios/frontend/javascripts/vendor/foundation/foundation.tooltips.js +195 -0
- data/lib/helios/frontend/javascripts/vendor/foundation/foundation.topbar.js +208 -0
- data/lib/helios/frontend/javascripts/vendor/jquery.js +9597 -0
- data/lib/helios/frontend/javascripts/vendor/jquery/jquery.fileupload-ui.js +807 -0
- data/lib/helios/frontend/javascripts/vendor/jquery/jquery.fileupload.js +1201 -0
- data/lib/helios/frontend/javascripts/vendor/jquery/jquery.ui.widget.js +530 -0
- data/lib/helios/frontend/javascripts/vendor/linkheaders.js +117 -0
- data/lib/helios/frontend/javascripts/vendor/underscore.js +1227 -0
- data/lib/helios/frontend/stylesheets/_codemirror.sass +219 -0
- data/lib/helios/frontend/stylesheets/_fonts.sass +80 -0
- data/lib/helios/frontend/stylesheets/_iphone.sass +141 -0
- data/lib/helios/frontend/stylesheets/_settings.scss +989 -0
- data/lib/helios/frontend/stylesheets/screen.sass +187 -0
- data/lib/helios/frontend/templates/data/entities.jst.tpl +11 -0
- data/lib/helios/frontend/templates/in-app-purchase/receipts.jst.tpl +11 -0
- data/lib/helios/frontend/templates/navigation.jst.tpl +31 -0
- data/lib/helios/frontend/templates/newsstand/issues.jst.tpl +16 -0
- data/lib/helios/frontend/templates/newsstand/new.jst.tpl +28 -0
- data/lib/helios/frontend/templates/passbook/passes.jst.tpl +11 -0
- data/lib/helios/frontend/templates/push-notification/compose.jst.tpl +70 -0
- data/lib/helios/frontend/templates/push-notification/devices.jst.tpl +17 -0
- data/lib/helios/frontend/views/index.haml +22 -0
- data/lib/helios/templates/.env.erb +1 -0
- data/lib/helios/templates/.gitignore +3 -0
- data/lib/helios/templates/Gemfile.erb +10 -0
- data/lib/helios/templates/Procfile.erb +1 -0
- data/lib/helios/templates/README.md.erb +4 -0
- data/lib/helios/templates/config.ru.erb +11 -0
- data/lib/helios/version.rb +3 -0
- metadata +475 -0
@@ -0,0 +1,159 @@
|
|
1
|
+
/*! http://mths.be/placeholder v2.0.7 by @mathias
|
2
|
+
Modified to work with Zepto.js by ZURB
|
3
|
+
*/
|
4
|
+
;(function(window, document, $) {
|
5
|
+
|
6
|
+
var isInputSupported = 'placeholder' in document.createElement('input'),
|
7
|
+
isTextareaSupported = 'placeholder' in document.createElement('textarea'),
|
8
|
+
prototype = $.fn,
|
9
|
+
valHooks = $.valHooks,
|
10
|
+
hooks,
|
11
|
+
placeholder;
|
12
|
+
|
13
|
+
if (isInputSupported && isTextareaSupported) {
|
14
|
+
|
15
|
+
placeholder = prototype.placeholder = function() {
|
16
|
+
return this;
|
17
|
+
};
|
18
|
+
|
19
|
+
placeholder.input = placeholder.textarea = true;
|
20
|
+
|
21
|
+
} else {
|
22
|
+
|
23
|
+
placeholder = prototype.placeholder = function() {
|
24
|
+
var $this = this;
|
25
|
+
$this
|
26
|
+
.filter((isInputSupported ? 'textarea' : ':input') + '[placeholder]')
|
27
|
+
.not('.placeholder')
|
28
|
+
.bind({
|
29
|
+
'focus.placeholder': clearPlaceholder,
|
30
|
+
'blur.placeholder': setPlaceholder
|
31
|
+
})
|
32
|
+
.data('placeholder-enabled', true)
|
33
|
+
.trigger('blur.placeholder');
|
34
|
+
return $this;
|
35
|
+
};
|
36
|
+
|
37
|
+
placeholder.input = isInputSupported;
|
38
|
+
placeholder.textarea = isTextareaSupported;
|
39
|
+
|
40
|
+
hooks = {
|
41
|
+
'get': function(element) {
|
42
|
+
var $element = $(element);
|
43
|
+
return $element.data('placeholder-enabled') && $element.hasClass('placeholder') ? '' : element.value;
|
44
|
+
},
|
45
|
+
'set': function(element, value) {
|
46
|
+
var $element = $(element);
|
47
|
+
if (!$element.data('placeholder-enabled')) {
|
48
|
+
return element.value = value;
|
49
|
+
}
|
50
|
+
if (value == '') {
|
51
|
+
element.value = value;
|
52
|
+
// Issue #56: Setting the placeholder causes problems if the element continues to have focus.
|
53
|
+
if (element != document.activeElement) {
|
54
|
+
// We can't use `triggerHandler` here because of dummy text/password inputs :(
|
55
|
+
setPlaceholder.call(element);
|
56
|
+
}
|
57
|
+
} else if ($element.hasClass('placeholder')) {
|
58
|
+
clearPlaceholder.call(element, true, value) || (element.value = value);
|
59
|
+
} else {
|
60
|
+
element.value = value;
|
61
|
+
}
|
62
|
+
// `set` can not return `undefined`; see http://jsapi.info/jquery/1.7.1/val#L2363
|
63
|
+
return $element;
|
64
|
+
}
|
65
|
+
};
|
66
|
+
|
67
|
+
isInputSupported || (valHooks.input = hooks);
|
68
|
+
isTextareaSupported || (valHooks.textarea = hooks);
|
69
|
+
|
70
|
+
$(function() {
|
71
|
+
// Look for forms
|
72
|
+
$(document).delegate('form', 'submit.placeholder', function() {
|
73
|
+
// Clear the placeholder values so they don't get submitted
|
74
|
+
var $inputs = $('.placeholder', this).each(clearPlaceholder);
|
75
|
+
setTimeout(function() {
|
76
|
+
$inputs.each(setPlaceholder);
|
77
|
+
}, 10);
|
78
|
+
});
|
79
|
+
});
|
80
|
+
|
81
|
+
// Clear placeholder values upon page reload
|
82
|
+
$(window).bind('beforeunload.placeholder', function() {
|
83
|
+
$('.placeholder').each(function() {
|
84
|
+
this.value = '';
|
85
|
+
});
|
86
|
+
});
|
87
|
+
|
88
|
+
}
|
89
|
+
|
90
|
+
function args(elem) {
|
91
|
+
// Return an object of element attributes
|
92
|
+
var newAttrs = {},
|
93
|
+
rinlinejQuery = /^jQuery\d+$/;
|
94
|
+
$.each(elem.attributes, function(i, attr) {
|
95
|
+
if (attr.specified && !rinlinejQuery.test(attr.name)) {
|
96
|
+
newAttrs[attr.name] = attr.value;
|
97
|
+
}
|
98
|
+
});
|
99
|
+
return newAttrs;
|
100
|
+
}
|
101
|
+
|
102
|
+
function clearPlaceholder(event, value) {
|
103
|
+
var input = this,
|
104
|
+
$input = $(input);
|
105
|
+
if (input.value == $input.attr('placeholder') && $input.hasClass('placeholder')) {
|
106
|
+
if ($input.data('placeholder-password')) {
|
107
|
+
$input = $input.hide().next().show().attr('id', $input.removeAttr('id').data('placeholder-id'));
|
108
|
+
// If `clearPlaceholder` was called from `$.valHooks.input.set`
|
109
|
+
if (event === true) {
|
110
|
+
return $input[0].value = value;
|
111
|
+
}
|
112
|
+
$input.focus();
|
113
|
+
} else {
|
114
|
+
input.value = '';
|
115
|
+
$input.removeClass('placeholder');
|
116
|
+
input == document.activeElement && input.select();
|
117
|
+
}
|
118
|
+
}
|
119
|
+
}
|
120
|
+
|
121
|
+
function setPlaceholder() {
|
122
|
+
var $replacement,
|
123
|
+
input = this,
|
124
|
+
$input = $(input),
|
125
|
+
$origInput = $input,
|
126
|
+
id = this.id;
|
127
|
+
if (input.value == '') {
|
128
|
+
if (input.type == 'password') {
|
129
|
+
if (!$input.data('placeholder-textinput')) {
|
130
|
+
try {
|
131
|
+
$replacement = $input.clone().attr({ 'type': 'text' });
|
132
|
+
} catch(e) {
|
133
|
+
$replacement = $('<input>').attr($.extend(args(this), { 'type': 'text' }));
|
134
|
+
}
|
135
|
+
$replacement
|
136
|
+
.removeAttr('name')
|
137
|
+
.data({
|
138
|
+
'placeholder-password': true,
|
139
|
+
'placeholder-id': id
|
140
|
+
})
|
141
|
+
.bind('focus.placeholder', clearPlaceholder);
|
142
|
+
$input
|
143
|
+
.data({
|
144
|
+
'placeholder-textinput': $replacement,
|
145
|
+
'placeholder-id': id
|
146
|
+
})
|
147
|
+
.before($replacement);
|
148
|
+
}
|
149
|
+
$input = $input.removeAttr('id').hide().prev().attr('id', id).show();
|
150
|
+
// Note: `$input[0] != input` now!
|
151
|
+
}
|
152
|
+
$input.addClass('placeholder');
|
153
|
+
$input[0].value = $input.attr('placeholder');
|
154
|
+
} else {
|
155
|
+
$input.removeClass('placeholder');
|
156
|
+
}
|
157
|
+
}
|
158
|
+
|
159
|
+
}(this, document, Foundation.zj));
|
@@ -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.reveal = {
|
7
|
+
name: 'reveal',
|
8
|
+
|
9
|
+
version : '4.0.4',
|
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
|
+
if (!this.settings.init) 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
|
+
.on('click.fndtn.reveal', '[data-reveal-id]', function (e) {
|
60
|
+
e.preventDefault();
|
61
|
+
if (!self.locked) {
|
62
|
+
self.locked = true;
|
63
|
+
self.open.call(self, $(this));
|
64
|
+
}
|
65
|
+
})
|
66
|
+
.on('click.fndtn.reveal touchend.click.fndtn.reveal', this.close_targets(), function (e) {
|
67
|
+
if (!self.locked) {
|
68
|
+
self.locked = true;
|
69
|
+
self.close.call(self, $(this).closest('.reveal-modal'));
|
70
|
+
}
|
71
|
+
})
|
72
|
+
.on('open.fndtn.reveal', '.reveal-modal', this.settings.open)
|
73
|
+
.on('opened.fndtn.reveal', '.reveal-modal', this.settings.opened)
|
74
|
+
.on('opened.fndtn.reveal', '.reveal-modal', this.open_video)
|
75
|
+
.on('close.fndtn.reveal', '.reveal-modal', this.settings.close)
|
76
|
+
.on('closed.fndtn.reveal', '.reveal-modal', this.settings.closed)
|
77
|
+
.on('closed.fndtn.reveal', '.reveal-modal', this.close_video);
|
78
|
+
},
|
79
|
+
|
80
|
+
open : function (target) {
|
81
|
+
if (target) {
|
82
|
+
var modal = $('#' + target.data('reveal-id'));
|
83
|
+
} else {
|
84
|
+
var modal = $(this.scope);
|
85
|
+
}
|
86
|
+
|
87
|
+
var open_modal = $('.reveal-modal.open');
|
88
|
+
|
89
|
+
if (!modal.data('css-top')) {
|
90
|
+
modal.data('css-top', parseInt(modal.css('top'), 10))
|
91
|
+
.data('offset', this.cache_offset(modal));
|
92
|
+
}
|
93
|
+
|
94
|
+
modal.trigger('open');
|
95
|
+
|
96
|
+
if (open_modal.length < 1) {
|
97
|
+
this.toggle_bg(modal);
|
98
|
+
}
|
99
|
+
|
100
|
+
this.toggle_modals(open_modal, modal);
|
101
|
+
},
|
102
|
+
|
103
|
+
close : function (modal) {
|
104
|
+
var modal = modal || $(this.scope);
|
105
|
+
this.locked = true;
|
106
|
+
var open_modal = $('.reveal-modal.open').not(modal);
|
107
|
+
modal.trigger('close');
|
108
|
+
this.toggle_bg(modal);
|
109
|
+
this.toggle_modals(open_modal, modal);
|
110
|
+
},
|
111
|
+
|
112
|
+
close_targets : function () {
|
113
|
+
var base = '.' + this.settings.dismissModalClass;
|
114
|
+
|
115
|
+
if (this.settings.closeOnBackgroundClick) {
|
116
|
+
return base + ', .' + this.settings.bgClass;
|
117
|
+
}
|
118
|
+
|
119
|
+
return base;
|
120
|
+
},
|
121
|
+
|
122
|
+
toggle_modals : function (open_modal, modal) {
|
123
|
+
if (open_modal.length > 0) {
|
124
|
+
this.hide(open_modal, this.settings.css.close);
|
125
|
+
}
|
126
|
+
|
127
|
+
if (modal.filter(':visible').length > 0) {
|
128
|
+
this.hide(modal, this.settings.css.close);
|
129
|
+
} else {
|
130
|
+
this.show(modal, this.settings.css.open);
|
131
|
+
}
|
132
|
+
},
|
133
|
+
|
134
|
+
toggle_bg : function (modal) {
|
135
|
+
if (this.settings.bg.length === 0) {
|
136
|
+
this.settings.bg = $('<div />', {'class': this.settings.bgClass})
|
137
|
+
.insertAfter(modal);
|
138
|
+
}
|
139
|
+
|
140
|
+
if (this.settings.bg.filter(':visible').length > 0) {
|
141
|
+
this.hide(this.settings.bg);
|
142
|
+
} else {
|
143
|
+
this.show(this.settings.bg);
|
144
|
+
}
|
145
|
+
},
|
146
|
+
|
147
|
+
show : function (el, css) {
|
148
|
+
// is modal
|
149
|
+
if (css) {
|
150
|
+
if (/pop/i.test(this.settings.animation)) {
|
151
|
+
css.top = $(window).scrollTop() - el.data('offset') + 'px';
|
152
|
+
var end_css = {
|
153
|
+
top: $(window).scrollTop() + el.data('css-top') + 'px',
|
154
|
+
opacity: 1
|
155
|
+
}
|
156
|
+
|
157
|
+
return this.delay(function () {
|
158
|
+
return el
|
159
|
+
.css(css)
|
160
|
+
.animate(end_css, this.settings.animationSpeed, 'linear', function () {
|
161
|
+
this.locked = false;
|
162
|
+
el.trigger('opened');
|
163
|
+
}.bind(this))
|
164
|
+
.addClass('open');
|
165
|
+
}.bind(this), this.settings.animationSpeed / 2);
|
166
|
+
}
|
167
|
+
|
168
|
+
if (/fade/i.test(this.settings.animation)) {
|
169
|
+
var end_css = {opacity: 1};
|
170
|
+
|
171
|
+
return this.delay(function () {
|
172
|
+
return el
|
173
|
+
.css(css)
|
174
|
+
.animate(end_css, this.settings.animationSpeed, 'linear', function () {
|
175
|
+
this.locked = false;
|
176
|
+
el.trigger('opened');
|
177
|
+
}.bind(this))
|
178
|
+
.addClass('open');
|
179
|
+
}.bind(this), this.settings.animationSpeed / 2);
|
180
|
+
}
|
181
|
+
|
182
|
+
return el.css(css).show().css({opacity: 1}).addClass('open').trigger('opened');
|
183
|
+
}
|
184
|
+
|
185
|
+
// should we animate the background?
|
186
|
+
if (/fade/i.test(this.settings.animation)) {
|
187
|
+
return el.fadeIn(this.settings.animationSpeed / 2);
|
188
|
+
}
|
189
|
+
|
190
|
+
return el.show();
|
191
|
+
},
|
192
|
+
|
193
|
+
hide : function (el, css) {
|
194
|
+
// is modal
|
195
|
+
if (css) {
|
196
|
+
if (/pop/i.test(this.settings.animation)) {
|
197
|
+
var end_css = {
|
198
|
+
top: - $(window).scrollTop() - el.data('offset') + 'px',
|
199
|
+
opacity: 0
|
200
|
+
};
|
201
|
+
|
202
|
+
return this.delay(function () {
|
203
|
+
return el
|
204
|
+
.animate(end_css, this.settings.animationSpeed, 'linear', function () {
|
205
|
+
this.locked = false;
|
206
|
+
el.css(css).trigger('closed');
|
207
|
+
}.bind(this))
|
208
|
+
.removeClass('open');
|
209
|
+
}.bind(this), this.settings.animationSpeed / 2);
|
210
|
+
}
|
211
|
+
|
212
|
+
if (/fade/i.test(this.settings.animation)) {
|
213
|
+
var end_css = {opacity: 0};
|
214
|
+
|
215
|
+
return this.delay(function () {
|
216
|
+
return el
|
217
|
+
.animate(end_css, this.settings.animationSpeed, 'linear', function () {
|
218
|
+
this.locked = false;
|
219
|
+
el.css(css).trigger('closed');
|
220
|
+
}.bind(this))
|
221
|
+
.removeClass('open');
|
222
|
+
}.bind(this), this.settings.animationSpeed / 2);
|
223
|
+
}
|
224
|
+
|
225
|
+
return el.hide().css(css).removeClass('open').trigger('closed');
|
226
|
+
}
|
227
|
+
|
228
|
+
// should we animate the background?
|
229
|
+
if (/fade/i.test(this.settings.animation)) {
|
230
|
+
return el.fadeOut(this.settings.animationSpeed / 2);
|
231
|
+
}
|
232
|
+
|
233
|
+
return el.hide();
|
234
|
+
},
|
235
|
+
|
236
|
+
close_video : function (e) {
|
237
|
+
var video = $(this).find('.flex-video'),
|
238
|
+
iframe = video.find('iframe');
|
239
|
+
|
240
|
+
if (iframe.length > 0) {
|
241
|
+
iframe.attr('data-src', iframe[0].src);
|
242
|
+
iframe.attr('src', 'about:blank');
|
243
|
+
video.fadeOut(100).hide();
|
244
|
+
}
|
245
|
+
},
|
246
|
+
|
247
|
+
open_video : function (e) {
|
248
|
+
var video = $(this).find('.flex-video'),
|
249
|
+
iframe = video.find('iframe');
|
250
|
+
|
251
|
+
if (iframe.length > 0) {
|
252
|
+
var data_src = iframe.attr('data-src');
|
253
|
+
if (typeof data_src === 'string') {
|
254
|
+
iframe[0].src = iframe.attr('data-src');
|
255
|
+
}
|
256
|
+
video.show().fadeIn(100);
|
257
|
+
}
|
258
|
+
},
|
259
|
+
|
260
|
+
cache_offset : function (modal) {
|
261
|
+
var offset = modal.show().height() + parseInt(modal.css('top'), 10);
|
262
|
+
|
263
|
+
modal.hide();
|
264
|
+
|
265
|
+
return offset;
|
266
|
+
},
|
267
|
+
|
268
|
+
off : function () {
|
269
|
+
$(this.scope).off('.fndtn.reveal');
|
270
|
+
}
|
271
|
+
};
|
272
|
+
}(Foundation.zj, this, this.document));
|
@@ -0,0 +1,183 @@
|
|
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.3',
|
10
|
+
|
11
|
+
settings : {
|
12
|
+
deep_linking: false,
|
13
|
+
one_up: true,
|
14
|
+
callback: function (){}
|
15
|
+
},
|
16
|
+
|
17
|
+
init : function (scope, method, options) {
|
18
|
+
this.scope = scope || this.scope;
|
19
|
+
Foundation.inherit(this, 'throttle data_options');
|
20
|
+
|
21
|
+
if (typeof method === 'object') {
|
22
|
+
$.extend(true, this.settings, method);
|
23
|
+
}
|
24
|
+
|
25
|
+
if (typeof method != 'string') {
|
26
|
+
this.set_active_from_hash();
|
27
|
+
if (!this.settings.init) this.events();
|
28
|
+
|
29
|
+
return this.settings.init;
|
30
|
+
} else {
|
31
|
+
return this[method].call(this, options);
|
32
|
+
}
|
33
|
+
},
|
34
|
+
|
35
|
+
events : function () {
|
36
|
+
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
|
+
|
42
|
+
$(window).on('resize.fndtn.section', self.throttle(function () {
|
43
|
+
self.resize.call(this);
|
44
|
+
}, 30)).trigger('resize');
|
45
|
+
|
46
|
+
this.settings.init = true;
|
47
|
+
},
|
48
|
+
|
49
|
+
toggle_active : function (e, self) {
|
50
|
+
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;
|
55
|
+
|
56
|
+
if (!self.settings.deep_linking && content.length > 0) {
|
57
|
+
e.preventDefault();
|
58
|
+
}
|
59
|
+
|
60
|
+
if (section.hasClass('active')) {
|
61
|
+
if (self.small(parent)
|
62
|
+
|| self.is_vertical(parent)
|
63
|
+
|| self.is_accordion(parent)) {
|
64
|
+
section
|
65
|
+
.removeClass('active')
|
66
|
+
.attr('style', '');
|
67
|
+
}
|
68
|
+
} 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', '');
|
75
|
+
|
76
|
+
section.css('padding-top', self.outerHeight(section.find('.title')) - 1);
|
77
|
+
}
|
78
|
+
|
79
|
+
if (self.small(parent)) {
|
80
|
+
section.attr('style', '');
|
81
|
+
}
|
82
|
+
|
83
|
+
section.addClass('active');
|
84
|
+
}
|
85
|
+
|
86
|
+
self.settings.callback();
|
87
|
+
},
|
88
|
+
|
89
|
+
resize : function () {
|
90
|
+
var sections = $('[data-section]'),
|
91
|
+
self = Foundation.libs.section;
|
92
|
+
|
93
|
+
sections.each(function() {
|
94
|
+
var $this = $(this),
|
95
|
+
active_section = $this.find('section.active, .section.active');
|
96
|
+
if (active_section.length > 1) {
|
97
|
+
active_section
|
98
|
+
.not(':first')
|
99
|
+
.removeClass('active')
|
100
|
+
.attr('style', '');
|
101
|
+
} else if (active_section.length < 1
|
102
|
+
&& !self.is_vertical($this)
|
103
|
+
&& !self.is_accordion($this)) {
|
104
|
+
var first = $this.find('section, .section').first();
|
105
|
+
first.addClass('active');
|
106
|
+
|
107
|
+
if (self.small($this)) {
|
108
|
+
first.attr('style', '');
|
109
|
+
} else {
|
110
|
+
first.css('padding-top', self.outerHeight(first.find('.title')) - 1);
|
111
|
+
}
|
112
|
+
}
|
113
|
+
|
114
|
+
if (self.small($this)) {
|
115
|
+
active_section.attr('style', '');
|
116
|
+
} else {
|
117
|
+
active_section.css('padding-top', self.outerHeight(active_section.find('.title')) - 1);
|
118
|
+
}
|
119
|
+
self.position_titles($this);
|
120
|
+
});
|
121
|
+
},
|
122
|
+
|
123
|
+
is_vertical : function (el) {
|
124
|
+
return el.hasClass('vertical-nav');
|
125
|
+
},
|
126
|
+
|
127
|
+
is_accordion : function (el) {
|
128
|
+
return el.hasClass('accordion');
|
129
|
+
},
|
130
|
+
|
131
|
+
set_active_from_hash : function () {
|
132
|
+
var hash = window.location.hash.substring(1),
|
133
|
+
sections = $('[data-section]'),
|
134
|
+
self = this;
|
135
|
+
|
136
|
+
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');
|
145
|
+
}
|
146
|
+
});
|
147
|
+
},
|
148
|
+
|
149
|
+
position_titles : function (section, off) {
|
150
|
+
var titles = section.find('.title'),
|
151
|
+
previous_width = 0,
|
152
|
+
self = this;
|
153
|
+
|
154
|
+
if (typeof off === 'boolean') {
|
155
|
+
titles.attr('style', '');
|
156
|
+
} else {
|
157
|
+
titles.each(function () {
|
158
|
+
$(this).css('left', previous_width);
|
159
|
+
previous_width += self.outerWidth($(this));
|
160
|
+
});
|
161
|
+
}
|
162
|
+
},
|
163
|
+
|
164
|
+
small : function (el) {
|
165
|
+
if (el && this.is_accordion(el)) {
|
166
|
+
return true;
|
167
|
+
}
|
168
|
+
if ($('html').hasClass('lt-ie9')) {
|
169
|
+
return true;
|
170
|
+
}
|
171
|
+
if ($('html').hasClass('ie8compat')) {
|
172
|
+
return true;
|
173
|
+
}
|
174
|
+
return $(this.scope).width() < 768;
|
175
|
+
},
|
176
|
+
|
177
|
+
off : function () {
|
178
|
+
$(this.scope).off('.fndtn.section');
|
179
|
+
$(window).off('.fndtn.section');
|
180
|
+
this.settings.init = false;
|
181
|
+
}
|
182
|
+
};
|
183
|
+
}(Foundation.zj, this, this.document));
|