themepile-abstractio 1.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 (84) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +28 -0
  3. data/.rbenv-version +1 -0
  4. data/CONTRIBUTING.md +53 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE +22 -0
  7. data/README.md +136 -0
  8. data/Rakefile +2 -0
  9. data/abstractio.gemspec +18 -0
  10. data/js/foundation/foundation.alerts.js +50 -0
  11. data/js/foundation/foundation.clearing.js +516 -0
  12. data/js/foundation/foundation.cookie.js +74 -0
  13. data/js/foundation/foundation.dropdown.js +159 -0
  14. data/js/foundation/foundation.forms.js +516 -0
  15. data/js/foundation/foundation.joyride.js +842 -0
  16. data/js/foundation/foundation.js +403 -0
  17. data/js/foundation/foundation.magellan.js +130 -0
  18. data/js/foundation/foundation.orbit.js +373 -0
  19. data/js/foundation/foundation.placeholder.js +159 -0
  20. data/js/foundation/foundation.reveal.js +276 -0
  21. data/js/foundation/foundation.section.js +409 -0
  22. data/js/foundation/foundation.tooltips.js +206 -0
  23. data/js/foundation/foundation.topbar.js +252 -0
  24. data/js/foundation/index.js +16 -0
  25. data/js/vendor/custom.modernizr.js +4 -0
  26. data/js/vendor/jquery.js +9597 -0
  27. data/js/vendor/zepto.js +1884 -0
  28. data/lib/abstractio.rb +17 -0
  29. data/lib/abstractio/engine.rb +20 -0
  30. data/lib/abstractio/generators/USAGE +15 -0
  31. data/lib/abstractio/generators/install_generator.rb +54 -0
  32. data/lib/abstractio/generators/templates/application.html.erb +46 -0
  33. data/lib/abstractio/generators/templates/application.html.haml +31 -0
  34. data/lib/abstractio/generators/templates/application.html.slim +28 -0
  35. data/lib/abstractio/version.rb +3 -0
  36. data/lib/themepile-abstractio.rb +17 -0
  37. data/scss/abstractio.scss +46 -0
  38. data/scss/abstractio/_variables.scss +1224 -0
  39. data/scss/abstractio/components/_alert-boxes.scss +107 -0
  40. data/scss/abstractio/components/_block-grid.scss +68 -0
  41. data/scss/abstractio/components/_breadcrumbs.scss +125 -0
  42. data/scss/abstractio/components/_button-groups.scss +89 -0
  43. data/scss/abstractio/components/_buttons.scss +227 -0
  44. data/scss/abstractio/components/_clearing.scss +224 -0
  45. data/scss/abstractio/components/_custom-forms.scss +263 -0
  46. data/scss/abstractio/components/_dropdown-buttons.scss +115 -0
  47. data/scss/abstractio/components/_dropdown.scss +150 -0
  48. data/scss/abstractio/components/_flex-video.scss +46 -0
  49. data/scss/abstractio/components/_forms.scss +362 -0
  50. data/scss/abstractio/components/_global.scss +280 -0
  51. data/scss/abstractio/components/_grid.scss +186 -0
  52. data/scss/abstractio/components/_inline-lists.scss +53 -0
  53. data/scss/abstractio/components/_joyride.scss +215 -0
  54. data/scss/abstractio/components/_keystrokes.scss +57 -0
  55. data/scss/abstractio/components/_labels.scss +85 -0
  56. data/scss/abstractio/components/_magellan.scss +23 -0
  57. data/scss/abstractio/components/_orbit.scss +213 -0
  58. data/scss/abstractio/components/_pagination.scss +100 -0
  59. data/scss/abstractio/components/_panels.scss +77 -0
  60. data/scss/abstractio/components/_pricing-tables.scss +131 -0
  61. data/scss/abstractio/components/_progress-bars.scss +71 -0
  62. data/scss/abstractio/components/_reveal.scss +132 -0
  63. data/scss/abstractio/components/_section.scss +318 -0
  64. data/scss/abstractio/components/_side-nav.scss +69 -0
  65. data/scss/abstractio/components/_split-buttons.scss +167 -0
  66. data/scss/abstractio/components/_sub-nav.scss +68 -0
  67. data/scss/abstractio/components/_switch.scss +251 -0
  68. data/scss/abstractio/components/_tables.scss +84 -0
  69. data/scss/abstractio/components/_thumbs.scss +48 -0
  70. data/scss/abstractio/components/_tooltips.scss +117 -0
  71. data/scss/abstractio/components/_top-bar.scss +495 -0
  72. data/scss/abstractio/components/_type.scss +426 -0
  73. data/scss/abstractio/components/_visibility.scss +322 -0
  74. data/scss/normalize.scss +402 -0
  75. data/templates/project/.gitignore +44 -0
  76. data/templates/project/MIT-LICENSE.txt +20 -0
  77. data/templates/project/config.rb +26 -0
  78. data/templates/project/humans.txt +8 -0
  79. data/templates/project/index.html +124 -0
  80. data/templates/project/manifest.rb +45 -0
  81. data/templates/project/robots.txt +4 -0
  82. data/templates/project/scss/app.scss +48 -0
  83. data/templates/upgrade/manifest.rb +34 -0
  84. metadata +153 -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,159 @@
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.1.3',
10
+
11
+ settings : {
12
+ activeClass: 'open',
13
+ opened: function(){},
14
+ closed: function(){}
15
+ },
16
+
17
+ init : function (scope, method, options) {
18
+ this.scope = scope || this.scope;
19
+ Foundation.inherit(this, 'throttle scrollLeft');
20
+
21
+ if (typeof method === 'object') {
22
+ $.extend(true, this.settings, method);
23
+ }
24
+
25
+ if (typeof method != 'string') {
26
+
27
+ if (!this.settings.init) {
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
+
40
+ $(this.scope)
41
+ .on('click.fndtn.dropdown', '[data-dropdown]', function (e) {
42
+ e.preventDefault();
43
+ self.toggle($(this));
44
+ })
45
+ .on('opened.fndtn.dropdown', '[data-dropdown-content]', this.settings.opened)
46
+ .on('closed.fndtn.dropdown', '[data-dropdown-content]', this.settings.closed);
47
+
48
+ $('body').on('click.fndtn.dropdown', function (e) {
49
+ var parent = $(e.target).closest('[data-dropdown-content]');
50
+
51
+ if ($(e.target).data('dropdown')) {
52
+ return;
53
+ }
54
+ if (parent.length > 0 && ($(e.target).is('[data-dropdown-content]') || $.contains(parent.first()[0], e.target))) {
55
+ e.stopPropagation();
56
+ return;
57
+ }
58
+
59
+ self.close.call(self, $('[data-dropdown-content]'));
60
+ });
61
+
62
+ $(window).on('resize.fndtn.dropdown', self.throttle(function () {
63
+ self.resize.call(self);
64
+ }, 50)).trigger('resize');
65
+
66
+ this.settings.init = true;
67
+ },
68
+
69
+ close: function (dropdown) {
70
+ var self = this;
71
+ dropdown.each(function () {
72
+ if ($(this).hasClass(self.settings.activeClass)) {
73
+ $(this)
74
+ .css(Foundation.rtl ? 'right':'left', '-99999px')
75
+ .removeClass(self.settings.activeClass);
76
+ $(this).trigger('closed');
77
+ }
78
+ });
79
+ },
80
+
81
+ open: function (dropdown, target) {
82
+ this
83
+ .css(dropdown
84
+ .addClass(this.settings.activeClass), target);
85
+ dropdown.trigger('opened');
86
+ },
87
+
88
+ toggle : function (target) {
89
+ var dropdown = $('#' + target.data('dropdown'));
90
+
91
+ this.close.call(this, $('[data-dropdown-content]').not(dropdown));
92
+
93
+ if (dropdown.hasClass(this.settings.activeClass)) {
94
+ this.close.call(this, dropdown);
95
+ } else {
96
+ this.open.call(this, dropdown, target);
97
+ }
98
+ },
99
+
100
+ resize : function () {
101
+ var dropdown = $('[data-dropdown-content].open'),
102
+ target = $("[data-dropdown='" + dropdown.attr('id') + "']");
103
+
104
+ if (dropdown.length && target.length) {
105
+ this.css(dropdown, target);
106
+ }
107
+ },
108
+
109
+ css : function (dropdown, target) {
110
+ // temporary workaround until 4.2
111
+ if (/body/i.test(dropdown.offsetParent()[0].nodeName)) {
112
+ var position = target.offset();
113
+ position.top -= dropdown.offsetParent().offset().top;
114
+ position.left -= dropdown.offsetParent().offset().left;
115
+ } else {
116
+ var position = target.position();
117
+ }
118
+
119
+ if (this.small()) {
120
+ dropdown.css({
121
+ position : 'absolute',
122
+ width: '95%',
123
+ left: '2.5%',
124
+ 'max-width': 'none',
125
+ top: position.top + this.outerHeight(target)
126
+ });
127
+ } else {
128
+ if (!Foundation.rtl && $(window).width() > this.outerWidth(dropdown) + target.offset().left) {
129
+ var left = position.left;
130
+ } else {
131
+ if (!dropdown.hasClass('right')) {
132
+ dropdown.addClass('right');
133
+ }
134
+ var left = position.left - (this.outerWidth(dropdown) - this.outerWidth(target));
135
+ }
136
+
137
+ dropdown.attr('style', '').css({
138
+ position : 'absolute',
139
+ top: position.top + this.outerHeight(target),
140
+ left: left
141
+ });
142
+ }
143
+
144
+ return dropdown;
145
+ },
146
+
147
+ small : function () {
148
+ return $(window).width() < 768 || $('html').hasClass('lt-ie9');
149
+ },
150
+
151
+ off: function () {
152
+ $(this.scope).off('.fndtn.dropdown');
153
+ $('html, body').off('.fndtn.dropdown');
154
+ $(window).off('.fndtn.dropdown');
155
+ $('[data-dropdown-content]').off('.fndtn.dropdown');
156
+ this.settings.init = false;
157
+ }
158
+ };
159
+ }(Foundation.zj, this, this.document));
@@ -0,0 +1,516 @@
1
+ (function ($, window, document, undefined) {
2
+ 'use strict';
3
+
4
+ Foundation.libs.forms = {
5
+ name: 'forms',
6
+
7
+ version: '4.1.6',
8
+
9
+ cache: {},
10
+
11
+ settings: {
12
+ disable_class: 'no-custom',
13
+ last_combo : null
14
+ },
15
+
16
+ init: function (scope, method, options) {
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"]', $(this.scope)).not('[data-customforms="disabled"]')
37
+ .each(this.append_custom_markup);
38
+ $('form.custom input[type="checkbox"]', $(this.scope)).not('[data-customforms="disabled"]')
39
+ .each(this.append_custom_markup);
40
+ $('form.custom select', $(this.scope))
41
+ .not('[data-customforms="disabled"]')
42
+ .not('[multiple=multiple]')
43
+ .each(this.append_custom_select);
44
+ },
45
+
46
+ events: function () {
47
+ var self = this;
48
+
49
+ $(this.scope)
50
+ .on('click.fndtn.forms', 'form.custom span.custom.checkbox', function (e) {
51
+ e.preventDefault();
52
+ e.stopPropagation();
53
+ self.toggle_checkbox($(this));
54
+ })
55
+ .on('click.fndtn.forms', 'form.custom span.custom.radio', function (e) {
56
+ e.preventDefault();
57
+ e.stopPropagation();
58
+ self.toggle_radio($(this));
59
+ })
60
+ .on('change.fndtn.forms', 'form.custom select:not([data-customforms="disabled"])', function (e, force_refresh) {
61
+ self.refresh_custom_select($(this), force_refresh);
62
+ })
63
+ .on('click.fndtn.forms', 'form.custom label', function (e) {
64
+ if ($(e.target).is('label')) {
65
+ var $associatedElement = $('#' + self.escape($(this).attr('for')) + ':not([data-customforms="disabled"])'),
66
+ $customCheckbox,
67
+ $customRadio;
68
+
69
+ if ($associatedElement.length !== 0) {
70
+ if ($associatedElement.attr('type') === 'checkbox') {
71
+ e.preventDefault();
72
+ $customCheckbox = $(this).find('span.custom.checkbox');
73
+ //the checkbox might be outside after the label or inside of another element
74
+ if ($customCheckbox.length == 0) {
75
+ $customCheckbox = $associatedElement.add(this).siblings('span.custom.checkbox').first();
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 or inside of another element
82
+ if ($customRadio.length == 0) {
83
+ $customRadio = $associatedElement.add(this).siblings('span.custom.radio').first();
84
+ }
85
+ self.toggle_radio($customRadio);
86
+ }
87
+ }
88
+ }
89
+ })
90
+ .on('mousedown.fndtn.forms', 'form.custom div.custom.dropdown', function () {
91
+ return false;
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 = getFirstPrevSibling($dropdown, 'select');
97
+
98
+ // make sure other dropdowns close
99
+ if (!$dropdown.hasClass('open')) $(self.scope).trigger('click');
100
+
101
+ e.preventDefault();
102
+ if (false === $select.is(':disabled')) {
103
+ $dropdown.toggleClass('open');
104
+
105
+ if ($dropdown.hasClass('open')) {
106
+ $(self.scope).on('click.fndtn.forms.customdropdown', function () {
107
+ $dropdown.removeClass('open');
108
+ $(self.scope).off('.fndtn.forms.customdropdown');
109
+ });
110
+ } else {
111
+ $(self.scope).on('.fndtn.forms.customdropdown');
112
+ }
113
+ return false;
114
+ }
115
+ })
116
+ .on('click.fndtn.forms touchend.fndtn.forms', 'form.custom div.custom.dropdown li', function (e) {
117
+ var $this = $(this),
118
+ $customDropdown = $this.closest('div.custom.dropdown'),
119
+ $select = getFirstPrevSibling($customDropdown, 'select'),
120
+ selectedIndex = 0;
121
+
122
+ e.preventDefault();
123
+ e.stopPropagation();
124
+
125
+ if (!$(this).hasClass('disabled')) {
126
+ $('div.dropdown').not($customDropdown).removeClass('open');
127
+
128
+ var $oldThis = $this.closest('ul')
129
+ .find('li.selected');
130
+ $oldThis.removeClass('selected');
131
+
132
+ $this.addClass('selected');
133
+
134
+ $customDropdown.removeClass('open')
135
+ .find('a.current')
136
+ .text($this.text());
137
+
138
+ $this.closest('ul').find('li').each(function (index) {
139
+ if ($this[0] == this) {
140
+ selectedIndex = index;
141
+ }
142
+ });
143
+ $select[0].selectedIndex = selectedIndex;
144
+
145
+ //store the old value in data
146
+ $select.data('prevalue', $oldThis.html());
147
+ $select.trigger('change');
148
+ }
149
+ });
150
+
151
+ $(window).on('keydown', function (e) {
152
+ var focus = document.activeElement,
153
+ self = Foundation.libs.forms,
154
+ dropdown = $('.custom.dropdown.open');
155
+
156
+ if (dropdown.length > 0) {
157
+ e.preventDefault();
158
+
159
+ if (e.which === 13) {
160
+ dropdown.find('li.selected').trigger('click');
161
+ }
162
+
163
+ if (e.which === 27) {
164
+ dropdown.removeClass('open');
165
+ }
166
+
167
+ if (e.which >= 65 && e.which <= 90) {
168
+ var next = self.go_to(dropdown, e.which),
169
+ current = dropdown.find('li.selected');
170
+
171
+ if (next) {
172
+ current.removeClass('selected');
173
+ self.scrollTo(next.addClass('selected'), 300);
174
+ }
175
+ }
176
+
177
+ if (e.which === 38) {
178
+ var current = dropdown.find('li.selected'),
179
+ prev = current.prev(':not(.disabled)');
180
+
181
+ if (prev.length > 0) {
182
+ prev.parent()[0].scrollTop = prev.parent().scrollTop() - self.outerHeight(prev);
183
+ current.removeClass('selected');
184
+ prev.addClass('selected');
185
+ }
186
+ } else if (e.which === 40) {
187
+ var current = dropdown.find('li.selected'),
188
+ next = current.next(':not(.disabled)');
189
+
190
+ if (next.length > 0) {
191
+ next.parent()[0].scrollTop = next.parent().scrollTop() + self.outerHeight(next);
192
+ current.removeClass('selected');
193
+ next.addClass('selected');
194
+ }
195
+ }
196
+ }
197
+ });
198
+
199
+ this.settings.init = true;
200
+ },
201
+
202
+ go_to: function (dropdown, character) {
203
+ var lis = dropdown.find('li'),
204
+ count = lis.length;
205
+
206
+ if (count > 0) {
207
+ for (var i = 0; i < count; i++) {
208
+ var first_letter = lis.eq(i).text().charAt(0).toLowerCase();
209
+ if (first_letter === String.fromCharCode(character).toLowerCase()) return lis.eq(i);
210
+ }
211
+ }
212
+ },
213
+
214
+ scrollTo: function (el, duration) {
215
+ if (duration < 0) return;
216
+ var parent = el.parent();
217
+ var li_height = this.outerHeight(el);
218
+ var difference = (li_height * (el.index())) - parent.scrollTop();
219
+ var perTick = difference / duration * 10;
220
+
221
+ this.scrollToTimerCache = setTimeout(function () {
222
+ if (!isNaN(parseInt(perTick, 10))) {
223
+ parent[0].scrollTop = parent.scrollTop() + perTick;
224
+ this.scrollTo(el, duration - 10);
225
+ }
226
+ }.bind(this), 10);
227
+ },
228
+
229
+ append_custom_markup: function (idx, sel) {
230
+ var $this = $(sel),
231
+ type = $this.attr('type'),
232
+ $span = $this.next('span.custom.' + type);
233
+
234
+ if (!$this.parent().hasClass('switch')) {
235
+ $this.addClass('hidden-field');
236
+ }
237
+
238
+ if ($span.length === 0) {
239
+ $span = $('<span class="custom ' + type + '"></span>').insertAfter($this);
240
+ }
241
+
242
+ $span.toggleClass('checked', $this.is(':checked'));
243
+ $span.toggleClass('disabled', $this.is(':disabled'));
244
+ },
245
+
246
+ append_custom_select: function (idx, sel) {
247
+ var self = Foundation.libs.forms,
248
+ $this = $(sel),
249
+ $customSelect = $this.next('div.custom.dropdown'),
250
+ $customList = $customSelect.find('ul'),
251
+ $selectCurrent = $customSelect.find(".current"),
252
+ $selector = $customSelect.find(".selector"),
253
+ $options = $this.find('option'),
254
+ $selectedOption = $options.filter(':selected'),
255
+ copyClasses = $this.attr('class') ? $this.attr('class').split(' ') : [],
256
+ maxWidth = 0,
257
+ liHtml = '',
258
+ $listItems,
259
+ $currentSelect = false;
260
+
261
+ if ($this.hasClass(self.settings.disable_class)) return;
262
+
263
+ if ($customSelect.length === 0) {
264
+ var customSelectSize = $this.hasClass('small') ? 'small' : $this.hasClass('medium') ? 'medium' : $this.hasClass('large') ? 'large' : $this.hasClass('expand') ? 'expand' : '';
265
+
266
+ $customSelect = $('<div class="' + ['custom', 'dropdown', customSelectSize].concat(copyClasses).filter(function (item, idx, arr) {
267
+ if (item == '') return false;
268
+ return arr.indexOf(item) == idx;
269
+ }).join(' ') + '"><a href="#" class="selector"></a><ul /></div>');
270
+
271
+ $selector = $customSelect.find(".selector");
272
+ $customList = $customSelect.find("ul");
273
+
274
+ liHtml = $options.map(function () {
275
+ return "<li>" + $(this).html() + "</li>";
276
+ }).get().join('');
277
+
278
+ $customList.append(liHtml);
279
+
280
+ $currentSelect = $customSelect
281
+ .prepend('<a href="#" class="current">' + $selectedOption.html() + '</a>')
282
+ .find(".current");
283
+
284
+ $this.after($customSelect)
285
+ .addClass('hidden-field');
286
+ } else {
287
+ liHtml = $options.map(function () {
288
+ return "<li>" + $(this).html() + "</li>";
289
+ })
290
+ .get().join('');
291
+
292
+ $customList.html('')
293
+ .append(liHtml);
294
+
295
+ } // endif $customSelect.length === 0
296
+
297
+ self.assign_id($this, $customSelect);
298
+ $customSelect.toggleClass('disabled', $this.is(':disabled'));
299
+ $listItems = $customList.find('li');
300
+
301
+ // cache list length
302
+ self.cache[$customSelect.data('id')] = $listItems.length;
303
+
304
+ $options.each(function (index) {
305
+ if (this.selected) {
306
+ $listItems.eq(index).addClass('selected');
307
+
308
+ if ($currentSelect) {
309
+ $currentSelect.html($(this).html());
310
+ }
311
+ }
312
+ if ($(this).is(':disabled')) {
313
+ $listItems.eq(index).addClass('disabled');
314
+ }
315
+ });
316
+
317
+ //
318
+ // If we're not specifying a predetermined form size.
319
+ //
320
+ if (!$customSelect.is('.small, .medium, .large, .expand')) {
321
+
322
+ // ------------------------------------------------------------------------------------
323
+ // This is a work-around for when elements are contained within hidden parents.
324
+ // For example, when custom-form elements are inside of a hidden reveal modal.
325
+ //
326
+ // We need to display the current custom list element as well as hidden parent elements
327
+ // in order to properly calculate the list item element's width property.
328
+ // -------------------------------------------------------------------------------------
329
+
330
+ $customSelect.addClass('open');
331
+ //
332
+ // Quickly, display all parent elements.
333
+ // This should help us calcualate the width of the list item's within the drop down.
334
+ //
335
+ var self = Foundation.libs.forms;
336
+ self.hidden_fix.adjust($customList);
337
+
338
+ maxWidth = (self.outerWidth($listItems) > maxWidth) ? self.outerWidth($listItems) : maxWidth;
339
+
340
+ Foundation.libs.forms.hidden_fix.reset();
341
+
342
+ $customSelect.removeClass('open');
343
+
344
+ } // endif
345
+
346
+ },
347
+
348
+ assign_id: function ($select, $customSelect) {
349
+ var id = [+new Date(), Foundation.random_str(5)].join('-');
350
+ $select.attr('data-id', id);
351
+ $customSelect.attr('data-id', id);
352
+ },
353
+
354
+ refresh_custom_select: function ($select, force_refresh) {
355
+ var self = this;
356
+ var maxWidth = 0,
357
+ $customSelect = $select.next(),
358
+ $options = $select.find('option'),
359
+ $listItems = $customSelect.find('li');
360
+
361
+ if ($listItems.length != this.cache[$customSelect.data('id')] || force_refresh) {
362
+ $customSelect.find('ul').html('');
363
+
364
+ $options.each(function () {
365
+ var $li = $('<li>' + $(this).html() + '</li>');
366
+ $customSelect.find('ul').append($li);
367
+ });
368
+
369
+ // re-populate
370
+ $options.each(function (index) {
371
+ if (this.selected) {
372
+ $customSelect.find('li').eq(index).addClass('selected');
373
+ $customSelect.find('.current').html($(this).html());
374
+ }
375
+ if ($(this).is(':disabled')) {
376
+ $customSelect.find('li').eq(index).addClass('disabled');
377
+ }
378
+ });
379
+
380
+ // fix width
381
+ $customSelect.removeAttr('style')
382
+ .find('ul').removeAttr('style');
383
+ $customSelect.find('li').each(function () {
384
+ $customSelect.addClass('open');
385
+ if (self.outerWidth($(this)) > maxWidth) {
386
+ maxWidth = self.outerWidth($(this));
387
+ }
388
+ $customSelect.removeClass('open');
389
+ });
390
+
391
+ $listItems = $customSelect.find('li');
392
+ // cache list length
393
+ this.cache[$customSelect.data('id')] = $listItems.length;
394
+ }
395
+ },
396
+
397
+ toggle_checkbox: function ($element) {
398
+ var $input = $element.prev(),
399
+ input = $input[0];
400
+
401
+ if (false === $input.is(':disabled')) {
402
+ input.checked = ((input.checked) ? false : true);
403
+ $element.toggleClass('checked');
404
+
405
+ $input.trigger('change');
406
+ }
407
+ },
408
+
409
+ toggle_radio: function ($element) {
410
+ var $input = $element.prev(),
411
+ $form = $input.closest('form.custom'),
412
+ input = $input[0];
413
+
414
+ if (false === $input.is(':disabled')) {
415
+ $form.find('input[type="radio"][name="' + this.escape($input.attr('name')) + '"]')
416
+ .next().not($element).removeClass('checked');
417
+
418
+ if (!$element.hasClass('checked')) {
419
+ $element.toggleClass('checked');
420
+ }
421
+
422
+ input.checked = $element.hasClass('checked');
423
+
424
+ $input.trigger('change');
425
+ }
426
+ },
427
+
428
+ escape: function (text) {
429
+ return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
430
+ },
431
+
432
+ hidden_fix: {
433
+ /**
434
+ * Sets all hidden parent elements and self to visibile.
435
+ *
436
+ * @method adjust
437
+ * @param {jQuery Object} $child
438
+ */
439
+
440
+ // We'll use this to temporarily store style properties.
441
+ tmp: [],
442
+
443
+ // We'll use this to set hidden parent elements.
444
+ hidden: null,
445
+
446
+ adjust: function ($child) {
447
+ // Internal reference.
448
+ var _self = this;
449
+
450
+ // Set all hidden parent elements, including this element.
451
+ _self.hidden = $child.parents().addBack().filter(":hidden");
452
+
453
+ // Loop through all hidden elements.
454
+ _self.hidden.each(function () {
455
+
456
+ // Cache the element.
457
+ var $elem = $(this);
458
+
459
+ // Store the style attribute.
460
+ // Undefined if element doesn't have a style attribute.
461
+ _self.tmp.push($elem.attr('style'));
462
+
463
+ // Set the element's display property to block,
464
+ // but ensure it's visibility is hidden.
465
+ $elem.css({
466
+ 'visibility': 'hidden',
467
+ 'display': 'block'
468
+ });
469
+ });
470
+
471
+ }, // end adjust
472
+
473
+ /**
474
+ * Resets the elements previous state.
475
+ *
476
+ * @method reset
477
+ */
478
+ reset: function () {
479
+ // Internal reference.
480
+ var _self = this;
481
+ // Loop through our hidden element collection.
482
+ _self.hidden.each(function (i) {
483
+ // Cache this element.
484
+ var $elem = $(this),
485
+ _tmp = _self.tmp[i]; // Get the stored 'style' value for this element.
486
+
487
+ // If the stored value is undefined.
488
+ if (_tmp === undefined)
489
+ // Remove the style attribute.
490
+ $elem.removeAttr('style');
491
+ else
492
+ // Otherwise, reset the element style attribute.
493
+ $elem.attr('style', _tmp);
494
+ });
495
+ // Reset the tmp array.
496
+ _self.tmp = [];
497
+ // Reset the hidden elements variable.
498
+ _self.hidden = null;
499
+
500
+ } // end reset
501
+ },
502
+
503
+ off: function () {
504
+ $(this.scope).off('.fndtn.forms');
505
+ }
506
+ };
507
+
508
+ var getFirstPrevSibling = function($el, selector) {
509
+ var $el = $el.prev();
510
+ while ($el.length) {
511
+ if ($el.is(selector)) return $el;
512
+ $el = $el.prev();
513
+ }
514
+ return $();
515
+ };
516
+ }(Foundation.zj, this, this.document));