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,74 @@
|
|
1
|
+
/*!
|
2
|
+
* jQuery Cookie Plugin v1.3
|
3
|
+
* https://github.com/carhartl/jquery-cookie
|
4
|
+
*
|
5
|
+
* Copyright 2011, Klaus Hartl
|
6
|
+
* Dual licensed under the MIT or GPL Version 2 licenses.
|
7
|
+
* http://www.opensource.org/licenses/mit-license.php
|
8
|
+
* http://www.opensource.org/licenses/GPL-2.0
|
9
|
+
*
|
10
|
+
* Modified to work with Zepto.js by ZURB
|
11
|
+
*/
|
12
|
+
(function ($, document, undefined) {
|
13
|
+
|
14
|
+
var pluses = /\+/g;
|
15
|
+
|
16
|
+
function raw(s) {
|
17
|
+
return s;
|
18
|
+
}
|
19
|
+
|
20
|
+
function decoded(s) {
|
21
|
+
return decodeURIComponent(s.replace(pluses, ' '));
|
22
|
+
}
|
23
|
+
|
24
|
+
var config = $.cookie = function (key, value, options) {
|
25
|
+
|
26
|
+
// write
|
27
|
+
if (value !== undefined) {
|
28
|
+
options = $.extend({}, config.defaults, options);
|
29
|
+
|
30
|
+
if (value === null) {
|
31
|
+
options.expires = -1;
|
32
|
+
}
|
33
|
+
|
34
|
+
if (typeof options.expires === 'number') {
|
35
|
+
var days = options.expires, t = options.expires = new Date();
|
36
|
+
t.setDate(t.getDate() + days);
|
37
|
+
}
|
38
|
+
|
39
|
+
value = config.json ? JSON.stringify(value) : String(value);
|
40
|
+
|
41
|
+
return (document.cookie = [
|
42
|
+
encodeURIComponent(key), '=', config.raw ? value : encodeURIComponent(value),
|
43
|
+
options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
|
44
|
+
options.path ? '; path=' + options.path : '',
|
45
|
+
options.domain ? '; domain=' + options.domain : '',
|
46
|
+
options.secure ? '; secure' : ''
|
47
|
+
].join(''));
|
48
|
+
}
|
49
|
+
|
50
|
+
// read
|
51
|
+
var decode = config.raw ? raw : decoded;
|
52
|
+
var cookies = document.cookie.split('; ');
|
53
|
+
for (var i = 0, l = cookies.length; i < l; i++) {
|
54
|
+
var parts = cookies[i].split('=');
|
55
|
+
if (decode(parts.shift()) === key) {
|
56
|
+
var cookie = decode(parts.join('='));
|
57
|
+
return config.json ? JSON.parse(cookie) : cookie;
|
58
|
+
}
|
59
|
+
}
|
60
|
+
|
61
|
+
return null;
|
62
|
+
};
|
63
|
+
|
64
|
+
config.defaults = {};
|
65
|
+
|
66
|
+
$.removeCookie = function (key, options) {
|
67
|
+
if ($.cookie(key) !== null) {
|
68
|
+
$.cookie(key, null, options);
|
69
|
+
return true;
|
70
|
+
}
|
71
|
+
return false;
|
72
|
+
};
|
73
|
+
|
74
|
+
})(Foundation.zj, document);
|
@@ -0,0 +1,122 @@
|
|
1
|
+
/*jslint unparam: true, browser: true, indent: 2 */
|
2
|
+
|
3
|
+
;(function ($, window, document, undefined) {
|
4
|
+
'use strict';
|
5
|
+
|
6
|
+
Foundation.libs.dropdown = {
|
7
|
+
name : 'dropdown',
|
8
|
+
|
9
|
+
version : '4.0.0',
|
10
|
+
|
11
|
+
settings : {
|
12
|
+
activeClass: 'open'
|
13
|
+
},
|
14
|
+
|
15
|
+
init : function (scope, method, options) {
|
16
|
+
this.scope = scope || this.scope;
|
17
|
+
Foundation.inherit(this, 'throttle');
|
18
|
+
|
19
|
+
if (typeof method === 'object') {
|
20
|
+
$.extend(true, this.settings, method);
|
21
|
+
}
|
22
|
+
|
23
|
+
if (typeof method != 'string') {
|
24
|
+
|
25
|
+
if (!this.settings.init) {
|
26
|
+
this.events();
|
27
|
+
}
|
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
|
+
|
38
|
+
$(this.scope).on('click.fndtn.dropdown', '[data-dropdown]', function (e) {
|
39
|
+
e.preventDefault();
|
40
|
+
e.stopPropagation();
|
41
|
+
self.toggle($(this));
|
42
|
+
});
|
43
|
+
|
44
|
+
$('*, html, body').on('click.fndtn.dropdown', function (e) {
|
45
|
+
if (!$(e.target).data('dropdown')) {
|
46
|
+
$('[data-dropdown-content]')
|
47
|
+
.css('left', '-99999px')
|
48
|
+
.removeClass(self.settings.activeClass);
|
49
|
+
}
|
50
|
+
});
|
51
|
+
|
52
|
+
$('[data-dropdown-content]').on('click.fndtn.dropdown', function (e) {
|
53
|
+
e.stopPropagation();
|
54
|
+
});
|
55
|
+
|
56
|
+
$(window).on('resize.fndtn.dropdown', self.throttle(function () {
|
57
|
+
self.resize.call(self);
|
58
|
+
}, 50)).trigger('resize');
|
59
|
+
|
60
|
+
this.settings.init = true;
|
61
|
+
},
|
62
|
+
|
63
|
+
toggle : function (target, resize) {
|
64
|
+
var dropdown = $('#' + target.data('dropdown'));
|
65
|
+
|
66
|
+
$('[data-dropdown-content]').not(dropdown).css('left', '-99999px');
|
67
|
+
|
68
|
+
if (dropdown.hasClass(this.settings.activeClass)) {
|
69
|
+
dropdown
|
70
|
+
.css('left', '-99999px')
|
71
|
+
.removeClass(this.settings.activeClass);
|
72
|
+
} else {
|
73
|
+
this
|
74
|
+
.css(dropdown
|
75
|
+
.addClass(this.settings.activeClass), target);
|
76
|
+
}
|
77
|
+
},
|
78
|
+
|
79
|
+
resize : function () {
|
80
|
+
var dropdown = $('[data-dropdown-content].open'),
|
81
|
+
target = $("[data-dropdown='" + dropdown.attr('id') + "']");
|
82
|
+
|
83
|
+
if (dropdown.length && target.length) {
|
84
|
+
this.css(dropdown, target);
|
85
|
+
}
|
86
|
+
},
|
87
|
+
|
88
|
+
css : function (dropdown, target) {
|
89
|
+
var offset = target.offset();
|
90
|
+
|
91
|
+
if (this.small()) {
|
92
|
+
dropdown.css({
|
93
|
+
position : 'absolute',
|
94
|
+
width: '95%',
|
95
|
+
left: '2.5%',
|
96
|
+
'max-width': 'none',
|
97
|
+
top: offset.top + this.outerHeight(target)
|
98
|
+
});
|
99
|
+
} else {
|
100
|
+
dropdown.attr('style', '').css({
|
101
|
+
position : 'absolute',
|
102
|
+
top: offset.top + this.outerHeight(target),
|
103
|
+
left: offset.left
|
104
|
+
});
|
105
|
+
}
|
106
|
+
|
107
|
+
return dropdown;
|
108
|
+
},
|
109
|
+
|
110
|
+
small : function () {
|
111
|
+
return $(window).width() < 768 || $('html').hasClass('lt-ie9');
|
112
|
+
},
|
113
|
+
|
114
|
+
off: function () {
|
115
|
+
$(this.scope).off('.fndtn.dropdown');
|
116
|
+
$('html, body').off('.fndtn.dropdown');
|
117
|
+
$(window).off('.fndtn.dropdown');
|
118
|
+
$('[data-dropdown-content]').off('.fndtn.dropdown');
|
119
|
+
this.settings.init = false;
|
120
|
+
}
|
121
|
+
};
|
122
|
+
}(Foundation.zj, this, this.document));
|
@@ -0,0 +1,403 @@
|
|
1
|
+
/*jslint unparam: true, browser: true, indent: 2 */
|
2
|
+
|
3
|
+
;(function ($, window, document, undefined) {
|
4
|
+
'use strict';
|
5
|
+
|
6
|
+
Foundation.libs.forms = {
|
7
|
+
name : 'forms',
|
8
|
+
|
9
|
+
version : '4.0.4',
|
10
|
+
|
11
|
+
settings : {
|
12
|
+
disable_class: 'no-custom'
|
13
|
+
},
|
14
|
+
|
15
|
+
init : function (scope, method, options) {
|
16
|
+
this.scope = scope || this.scope;
|
17
|
+
|
18
|
+
if (typeof method === 'object') {
|
19
|
+
$.extend(true, this.settings, method);
|
20
|
+
}
|
21
|
+
|
22
|
+
if (typeof method != 'string') {
|
23
|
+
if (!this.settings.init) {
|
24
|
+
this.events();
|
25
|
+
}
|
26
|
+
|
27
|
+
this.assemble();
|
28
|
+
|
29
|
+
return this.settings.init;
|
30
|
+
} else {
|
31
|
+
return this[method].call(this, options);
|
32
|
+
}
|
33
|
+
},
|
34
|
+
|
35
|
+
assemble : function () {
|
36
|
+
$('form.custom input[type="radio"]').not('[data-customforms="disabled"]')
|
37
|
+
.each(this.append_custom_markup);
|
38
|
+
$('form.custom input[type="checkbox"]').not('[data-customforms="disabled"]')
|
39
|
+
.each(this.append_custom_markup);
|
40
|
+
$('form.custom select').not('[data-customforms="disabled"]')
|
41
|
+
.each(this.append_custom_select);
|
42
|
+
},
|
43
|
+
|
44
|
+
events : function () {
|
45
|
+
var self = this;
|
46
|
+
|
47
|
+
$(this.scope)
|
48
|
+
.on('click.fndtn.forms', 'form.custom span.custom.checkbox', function (e) {
|
49
|
+
e.preventDefault();
|
50
|
+
e.stopPropagation();
|
51
|
+
self.toggle_checkbox($(this));
|
52
|
+
})
|
53
|
+
.on('click.fndtn.forms', 'form.custom span.custom.radio', function (e) {
|
54
|
+
e.preventDefault();
|
55
|
+
e.stopPropagation();
|
56
|
+
self.toggle_radio($(this));
|
57
|
+
})
|
58
|
+
.on('change.fndtn.forms', 'form.custom select:not([data-customforms="disabled"])', function (e) {
|
59
|
+
self.refresh_custom_select($(this));
|
60
|
+
})
|
61
|
+
.on('click.fndtn.forms', 'form.custom label', function (e) {
|
62
|
+
var $associatedElement = $('#' + self.escape($(this).attr('for')) + ':not([data-customforms="disabled"])'),
|
63
|
+
$customCheckbox,
|
64
|
+
$customRadio;
|
65
|
+
if ($associatedElement.length !== 0) {
|
66
|
+
if ($associatedElement.attr('type') === 'checkbox') {
|
67
|
+
e.preventDefault();
|
68
|
+
$customCheckbox = $(this).find('span.custom.checkbox');
|
69
|
+
//the checkbox might be outside after the label
|
70
|
+
if ($customCheckbox.length == 0) {
|
71
|
+
$customCheckbox = $(this).next('span.custom.checkbox');
|
72
|
+
}
|
73
|
+
//the checkbox might be outside before the label
|
74
|
+
if ($customCheckbox.length == 0) {
|
75
|
+
$customCheckbox = $(this).prev('span.custom.checkbox');
|
76
|
+
}
|
77
|
+
self.toggle_checkbox($customCheckbox);
|
78
|
+
} else if ($associatedElement.attr('type') === 'radio') {
|
79
|
+
e.preventDefault();
|
80
|
+
$customRadio = $(this).find('span.custom.radio');
|
81
|
+
//the radio might be outside after the label
|
82
|
+
if ($customRadio.length == 0) {
|
83
|
+
$customRadio = $(this).next('span.custom.radio');
|
84
|
+
}
|
85
|
+
//the radio might be outside before the label
|
86
|
+
if ($customRadio.length == 0) {
|
87
|
+
$customRadio = $(this).prev('span.custom.radio');
|
88
|
+
}
|
89
|
+
self.toggle_radio($customRadio);
|
90
|
+
}
|
91
|
+
}
|
92
|
+
})
|
93
|
+
.on('click.fndtn.forms', 'form.custom div.custom.dropdown a.current, form.custom div.custom.dropdown a.selector', function (e) {
|
94
|
+
var $this = $(this),
|
95
|
+
$dropdown = $this.closest('div.custom.dropdown'),
|
96
|
+
$select = $dropdown.prev();
|
97
|
+
|
98
|
+
// make sure other dropdowns close
|
99
|
+
if(!$dropdown.hasClass('open'))
|
100
|
+
$(self.scope).trigger('click');
|
101
|
+
|
102
|
+
e.preventDefault();
|
103
|
+
if (false === $select.is(':disabled')) {
|
104
|
+
$dropdown.toggleClass('open');
|
105
|
+
|
106
|
+
if ($dropdown.hasClass('open')) {
|
107
|
+
$(self.scope).on('click.fndtn.forms.customdropdown', function () {
|
108
|
+
$dropdown.removeClass('open');
|
109
|
+
$(self.scope).off('.fndtn.forms.customdropdown');
|
110
|
+
});
|
111
|
+
} else {
|
112
|
+
$(self.scope).on('.fndtn.forms.customdropdown');
|
113
|
+
}
|
114
|
+
return false;
|
115
|
+
}
|
116
|
+
})
|
117
|
+
.on('click.fndtn.forms touchend.fndtn.forms', 'form.custom div.custom.dropdown li', function (e) {
|
118
|
+
var $this = $(this),
|
119
|
+
$customDropdown = $this.closest('div.custom.dropdown'),
|
120
|
+
$select = $customDropdown.prev(),
|
121
|
+
selectedIndex = 0;
|
122
|
+
|
123
|
+
e.preventDefault();
|
124
|
+
e.stopPropagation();
|
125
|
+
|
126
|
+
if ( ! $(this).hasClass('disabled')) {
|
127
|
+
$('div.dropdown').not($customDropdown).removeClass('open');
|
128
|
+
|
129
|
+
var $oldThis= $this
|
130
|
+
.closest('ul')
|
131
|
+
.find('li.selected');
|
132
|
+
$oldThis.removeClass('selected');
|
133
|
+
|
134
|
+
$this.addClass('selected');
|
135
|
+
|
136
|
+
$customDropdown
|
137
|
+
.removeClass('open')
|
138
|
+
.find('a.current')
|
139
|
+
.html($this.html());
|
140
|
+
|
141
|
+
$this.closest('ul').find('li').each(function (index) {
|
142
|
+
if ($this[0] == this) {
|
143
|
+
selectedIndex = index;
|
144
|
+
}
|
145
|
+
|
146
|
+
});
|
147
|
+
$select[0].selectedIndex = selectedIndex;
|
148
|
+
|
149
|
+
//store the old value in data
|
150
|
+
$select.data('prevalue', $oldThis.html());
|
151
|
+
$select.trigger('change');
|
152
|
+
}
|
153
|
+
});
|
154
|
+
|
155
|
+
this.settings.init = true;
|
156
|
+
},
|
157
|
+
|
158
|
+
append_custom_markup : function (idx, sel) {
|
159
|
+
var $this = $(sel).hide(),
|
160
|
+
type = $this.attr('type'),
|
161
|
+
$span = $this.next('span.custom.' + type);
|
162
|
+
|
163
|
+
if ($span.length === 0) {
|
164
|
+
$span = $('<span class="custom ' + type + '"></span>').insertAfter($this);
|
165
|
+
}
|
166
|
+
|
167
|
+
$span.toggleClass('checked', $this.is(':checked'));
|
168
|
+
$span.toggleClass('disabled', $this.is(':disabled'));
|
169
|
+
},
|
170
|
+
|
171
|
+
append_custom_select : function (idx, sel) {
|
172
|
+
var self = Foundation.libs.forms,
|
173
|
+
$this = $( sel ),
|
174
|
+
$customSelect = $this.next( 'div.custom.dropdown' ),
|
175
|
+
$customList = $customSelect.find( 'ul' ),
|
176
|
+
$selectCurrent = $customSelect.find( ".current" ),
|
177
|
+
$selector = $customSelect.find( ".selector" ),
|
178
|
+
$options = $this.find( 'option' ),
|
179
|
+
$selectedOption = $options.filter( ':selected' ),
|
180
|
+
maxWidth = 0,
|
181
|
+
liHtml = '',
|
182
|
+
$listItems,
|
183
|
+
$currentSelect = false;
|
184
|
+
|
185
|
+
if ($this.hasClass(self.settings.disable_class)) return;
|
186
|
+
|
187
|
+
if ($customSelect.length === 0) {
|
188
|
+
var customSelectSize = $this.hasClass( 'small' ) ? 'small' :
|
189
|
+
$this.hasClass( 'medium' ) ? 'medium' :
|
190
|
+
$this.hasClass( 'large' ) ? 'large' :
|
191
|
+
$this.hasClass( 'expand' ) ? 'expand' : '';
|
192
|
+
|
193
|
+
$customSelect = $('<div class="' + ['custom', 'dropdown', customSelectSize ].join( ' ' ) + '"><a href="#" class="selector"></a><ul /></div>');
|
194
|
+
$selector = $customSelect.find(".selector");
|
195
|
+
$customList = $customSelect.find("ul");
|
196
|
+
liHtml = $options.map(function() { return "<li>" + $( this ).html() + "</li>"; } ).get().join( '' );
|
197
|
+
$customList.append(liHtml);
|
198
|
+
$currentSelect = $customSelect.prepend('<a href="#" class="current">' + $selectedOption.html() + '</a>' ).find( ".current" );
|
199
|
+
$this
|
200
|
+
.after( $customSelect )
|
201
|
+
.hide();
|
202
|
+
|
203
|
+
} else {
|
204
|
+
liHtml = $options.map(function() {
|
205
|
+
return "<li>" + $( this ).html() + "</li>";
|
206
|
+
})
|
207
|
+
.get().join('');
|
208
|
+
$customList
|
209
|
+
.html('')
|
210
|
+
.append(liHtml);
|
211
|
+
|
212
|
+
} // endif $customSelect.length === 0
|
213
|
+
$customSelect.toggleClass('disabled', $this.is( ':disabled' ) );
|
214
|
+
$listItems = $customList.find( 'li' );
|
215
|
+
|
216
|
+
$options.each( function ( index ) {
|
217
|
+
if ( this.selected ) {
|
218
|
+
$listItems.eq( index ).addClass( 'selected' );
|
219
|
+
|
220
|
+
if ($currentSelect) {
|
221
|
+
$currentSelect.html( $( this ).html() );
|
222
|
+
}
|
223
|
+
|
224
|
+
}
|
225
|
+
if ($(this).is(':disabled')) {
|
226
|
+
$listItems.eq( index ).addClass( 'disabled' );
|
227
|
+
}
|
228
|
+
});
|
229
|
+
|
230
|
+
//
|
231
|
+
// If we're not specifying a predetermined form size.
|
232
|
+
//
|
233
|
+
if (!$customSelect.is('.small, .medium, .large, .expand')) {
|
234
|
+
|
235
|
+
// ------------------------------------------------------------------------------------
|
236
|
+
// This is a work-around for when elements are contained within hidden parents.
|
237
|
+
// For example, when custom-form elements are inside of a hidden reveal modal.
|
238
|
+
//
|
239
|
+
// We need to display the current custom list element as well as hidden parent elements
|
240
|
+
// in order to properly calculate the list item element's width property.
|
241
|
+
// -------------------------------------------------------------------------------------
|
242
|
+
|
243
|
+
$customSelect.addClass( 'open' );
|
244
|
+
//
|
245
|
+
// Quickly, display all parent elements.
|
246
|
+
// This should help us calcualate the width of the list item's within the drop down.
|
247
|
+
//
|
248
|
+
var self = Foundation.libs.forms;
|
249
|
+
self.hidden_fix.adjust( $customList );
|
250
|
+
|
251
|
+
maxWidth = ( self.outerWidth($listItems) > maxWidth ) ? self.outerWidth($listItems) : maxWidth;
|
252
|
+
|
253
|
+
Foundation.libs.forms.hidden_fix.reset();
|
254
|
+
|
255
|
+
$customSelect.removeClass( 'open' );
|
256
|
+
|
257
|
+
} // endif
|
258
|
+
|
259
|
+
},
|
260
|
+
|
261
|
+
refresh_custom_select : function ($select) {
|
262
|
+
var self = this;
|
263
|
+
var maxWidth = 0,
|
264
|
+
$customSelect = $select.next(),
|
265
|
+
$options = $select.find('option');
|
266
|
+
|
267
|
+
$customSelect.find('ul').html('');
|
268
|
+
|
269
|
+
$options.each(function () {
|
270
|
+
var $li = $('<li>' + $(this).html() + '</li>');
|
271
|
+
$customSelect.find('ul').append($li);
|
272
|
+
});
|
273
|
+
|
274
|
+
// re-populate
|
275
|
+
$options.each(function (index) {
|
276
|
+
if (this.selected) {
|
277
|
+
$customSelect.find('li').eq(index).addClass('selected');
|
278
|
+
$customSelect.find('.current').html($(this).html());
|
279
|
+
}
|
280
|
+
if ($(this).is(':disabled')) {
|
281
|
+
$customSelect.find('li').eq(index).addClass('disabled');
|
282
|
+
}
|
283
|
+
});
|
284
|
+
|
285
|
+
// fix width
|
286
|
+
$customSelect.removeAttr('style')
|
287
|
+
.find('ul').removeAttr('style');
|
288
|
+
$customSelect.find('li').each(function () {
|
289
|
+
$customSelect.addClass('open');
|
290
|
+
if (self.outerWidth($(this)) > maxWidth) {
|
291
|
+
maxWidth = self.outerWidth($(this));
|
292
|
+
}
|
293
|
+
$customSelect.removeClass('open');
|
294
|
+
});
|
295
|
+
},
|
296
|
+
|
297
|
+
toggle_checkbox : function ($element) {
|
298
|
+
var $input = $element.prev(),
|
299
|
+
input = $input[0];
|
300
|
+
|
301
|
+
if (false === $input.is(':disabled')) {
|
302
|
+
input.checked = ((input.checked) ? false : true);
|
303
|
+
$element.toggleClass('checked');
|
304
|
+
|
305
|
+
$input.trigger('change');
|
306
|
+
}
|
307
|
+
},
|
308
|
+
|
309
|
+
toggle_radio : function ($element) {
|
310
|
+
var $input = $element.prev(),
|
311
|
+
$form = $input.closest('form.custom'),
|
312
|
+
input = $input[0];
|
313
|
+
|
314
|
+
if (false === $input.is(':disabled')) {
|
315
|
+
$form.find('input[type="radio"][name="' + this.escape($input.attr('name')) + '"]').next().not($element).removeClass('checked');
|
316
|
+
if ( !$element.hasClass('checked') ) {
|
317
|
+
$element.toggleClass('checked');
|
318
|
+
}
|
319
|
+
input.checked = $element.hasClass('checked');
|
320
|
+
|
321
|
+
$input.trigger('change');
|
322
|
+
}
|
323
|
+
},
|
324
|
+
|
325
|
+
escape : function (text) {
|
326
|
+
return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
327
|
+
},
|
328
|
+
|
329
|
+
hidden_fix : {
|
330
|
+
/**
|
331
|
+
* Sets all hidden parent elements and self to visibile.
|
332
|
+
*
|
333
|
+
* @method adjust
|
334
|
+
* @param {jQuery Object} $child
|
335
|
+
*/
|
336
|
+
|
337
|
+
// We'll use this to temporarily store style properties.
|
338
|
+
tmp : [],
|
339
|
+
|
340
|
+
// We'll use this to set hidden parent elements.
|
341
|
+
hidden : null,
|
342
|
+
|
343
|
+
adjust : function( $child ) {
|
344
|
+
// Internal reference.
|
345
|
+
var _self = this;
|
346
|
+
|
347
|
+
// Set all hidden parent elements, including this element.
|
348
|
+
_self.hidden = $child.parents().andSelf().filter( ":hidden" );
|
349
|
+
|
350
|
+
// Loop through all hidden elements.
|
351
|
+
_self.hidden.each( function() {
|
352
|
+
|
353
|
+
// Cache the element.
|
354
|
+
var $elem = $( this );
|
355
|
+
|
356
|
+
// Store the style attribute.
|
357
|
+
// Undefined if element doesn't have a style attribute.
|
358
|
+
_self.tmp.push( $elem.attr( 'style' ) );
|
359
|
+
|
360
|
+
// Set the element's display property to block,
|
361
|
+
// but ensure it's visibility is hidden.
|
362
|
+
$elem.css( { 'visibility' : 'hidden', 'display' : 'block' } );
|
363
|
+
});
|
364
|
+
|
365
|
+
}, // end adjust
|
366
|
+
|
367
|
+
/**
|
368
|
+
* Resets the elements previous state.
|
369
|
+
*
|
370
|
+
* @method reset
|
371
|
+
*/
|
372
|
+
reset : function() {
|
373
|
+
// Internal reference.
|
374
|
+
var _self = this;
|
375
|
+
// Loop through our hidden element collection.
|
376
|
+
_self.hidden.each( function( i ) {
|
377
|
+
// Cache this element.
|
378
|
+
var $elem = $( this ),
|
379
|
+
_tmp = _self.tmp[ i ]; // Get the stored 'style' value for this element.
|
380
|
+
|
381
|
+
// If the stored value is undefined.
|
382
|
+
if( _tmp === undefined )
|
383
|
+
// Remove the style attribute.
|
384
|
+
$elem.removeAttr( 'style' );
|
385
|
+
else
|
386
|
+
// Otherwise, reset the element style attribute.
|
387
|
+
$elem.attr( 'style', _tmp );
|
388
|
+
|
389
|
+
});
|
390
|
+
// Reset the tmp array.
|
391
|
+
_self.tmp = [];
|
392
|
+
// Reset the hidden elements variable.
|
393
|
+
_self.hidden = null;
|
394
|
+
|
395
|
+
} // end reset
|
396
|
+
|
397
|
+
},
|
398
|
+
|
399
|
+
off : function () {
|
400
|
+
$(this.scope).off('.fndtn.forms');
|
401
|
+
}
|
402
|
+
};
|
403
|
+
}(Foundation.zj, this, this.document));
|