zurb-foundation 3.2.5 → 4.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -2
- data/CHANGELOG.md +1 -26
- data/CONTRIBUTING.md +18 -0
- data/Gemfile.lock +19 -0
- data/Gruntfile.js +27 -0
- data/README.md +5 -6
- data/{Capfile → docs/Capfile} +0 -1
- data/docs/Gemfile +8 -0
- data/docs/Gemfile.lock +43 -0
- data/docs/Procfile +2 -0
- data/docs/README.md +1 -0
- data/docs/_sidebar-components.html.erb +109 -0
- data/docs/_sidebar.html.erb +109 -0
- data/docs/_zurb-jobs.html.erb +5 -0
- data/docs/changelog.html.erb +185 -0
- data/docs/compile.rb +43 -0
- data/docs/components/alert-boxes.html.erb +202 -0
- data/docs/components/block-grid.html.erb +118 -0
- data/docs/components/breadcrumbs.html.erb +146 -0
- data/docs/components/button-groups.html.erb +174 -0
- data/docs/components/buttons.html.erb +220 -0
- data/docs/components/clearing.html.erb +152 -0
- data/docs/components/custom-forms.html.erb +306 -0
- data/docs/components/dropdown-buttons.html.erb +233 -0
- data/docs/components/dropdown.html.erb +186 -0
- data/docs/components/flex-video.html.erb +93 -0
- data/docs/components/forms.html.erb +468 -0
- data/docs/components/grid.html.erb +355 -0
- data/docs/components/inline-lists.html.erb +89 -0
- data/docs/components/joyride.html.erb +178 -0
- data/docs/components/keystrokes.html.erb +74 -0
- data/docs/components/labels.html.erb +98 -0
- data/docs/components/magellan.html.erb +84 -0
- data/docs/components/orbit.html.erb +262 -0
- data/docs/components/pagination.html.erb +181 -0
- data/docs/components/panels.html.erb +121 -0
- data/docs/components/pricing-tables.html.erb +154 -0
- data/docs/components/progress-bars.html.erb +120 -0
- data/docs/components/reveal.html.erb +147 -0
- data/docs/components/section.html.erb +156 -0
- data/docs/components/side-nav.html.erb +122 -0
- data/docs/components/split-buttons.html.erb +218 -0
- data/docs/components/sub-nav.html.erb +120 -0
- data/docs/components/switch.html.erb +288 -0
- data/docs/components/tables.html.erb +123 -0
- data/docs/components/thumbnails.html.erb +87 -0
- data/docs/components/tooltips.html.erb +73 -0
- data/docs/components/top-bar.html.erb +219 -0
- data/docs/components/type.html.erb +359 -0
- data/docs/components/visibility.html.erb +102 -0
- data/docs/config.ru +12 -0
- data/docs/config/deploy.rb +33 -0
- data/docs/controller.rb +43 -0
- data/docs/css/_coderay.scss +116 -0
- data/docs/css/_settings.scss +1 -0
- data/docs/css/docs.scss +174 -0
- data/docs/css/normalize.scss +396 -0
- data/docs/css/qunit-composite.css +13 -0
- data/docs/css/qunit.css +235 -0
- data/docs/faq.html.erb +61 -0
- data/docs/img/demos/demo1-th.png +0 -0
- data/docs/img/demos/demo1.png +0 -0
- data/docs/img/demos/demo2-th.png +0 -0
- data/docs/img/demos/demo2.png +0 -0
- data/docs/img/demos/demo3-th.png +0 -0
- data/docs/img/demos/demo3.png +0 -0
- data/docs/img/demos/demo4-th.png +0 -0
- data/docs/img/demos/demo4.png +0 -0
- data/docs/img/demos/demo5-th.png +0 -0
- data/docs/img/demos/demo5.png +0 -0
- data/docs/index.html.erb +299 -0
- data/docs/javascript.html.erb +133 -0
- data/docs/js/docs.js +3 -0
- data/docs/js/qunit-composite.js +105 -0
- data/docs/js/qunit.js +1977 -0
- data/docs/js/tests/tabs/simple_tabs.html +57 -0
- data/docs/js/tests/tabs/simple_tabs.js +54 -0
- data/docs/js/tests/tooltips/tooltips.html +39 -0
- data/docs/js/tests/tooltips/tooltips.js +11 -0
- data/docs/layout.html.erb +99 -0
- data/docs/rails.html.erb +66 -0
- data/docs/sass.html.erb +299 -0
- data/docs/support.html.erb +134 -0
- data/foundation.gemspec +2 -4
- data/index.html +3 -23
- data/js/foundation/foundation.alerts.js +50 -0
- data/js/foundation/foundation.clearing.js +478 -0
- data/{vendor/assets/javascripts/foundation/jquery.cookie.js → js/foundation/foundation.cookie.js} +3 -1
- data/js/foundation/foundation.dropdown.js +122 -0
- data/js/foundation/foundation.forms.js +403 -0
- data/js/foundation/foundation.joyride.js +613 -0
- data/js/foundation/foundation.js +331 -0
- data/js/foundation/foundation.magellan.js +130 -0
- data/js/foundation/foundation.orbit.js +355 -0
- data/{vendor/assets/javascripts/foundation/jquery.placeholder.js → js/foundation/foundation.placeholder.js} +4 -2
- data/js/foundation/foundation.reveal.js +264 -0
- data/js/foundation/foundation.section.js +180 -0
- data/js/foundation/foundation.tooltips.js +195 -0
- data/js/foundation/foundation.topbar.js +187 -0
- data/js/foundation/index.js +16 -0
- data/{vendor/assets/javascripts/foundation/modernizr.foundation.js → js/vendor/custom.modernizr.js} +0 -0
- data/js/vendor/jquery.js +9597 -0
- data/js/vendor/zepto.js +1782 -0
- data/lib/foundation/engine.rb +8 -1
- data/lib/foundation/generators/install_generator.rb +24 -1
- data/lib/foundation/generators/templates/application.html.erb +20 -6
- data/lib/foundation/generators/templates/application.html.haml +2 -6
- data/lib/foundation/generators/templates/application.html.slim +2 -5
- data/lib/foundation/version.rb +1 -1
- data/lib/zurb-foundation.rb +7 -9
- data/package.json +9 -0
- data/scss/foundation.scss +42 -15
- data/scss/foundation/_foundation-global.scss +226 -0
- data/scss/foundation/components/_alert-boxes.scss +106 -0
- data/scss/foundation/components/_block-grid.scss +63 -0
- data/scss/foundation/components/_breadcrumbs.scss +117 -0
- data/scss/foundation/components/_button-groups.scss +59 -0
- data/scss/foundation/components/_buttons.scss +217 -0
- data/scss/foundation/components/_clearing.scss +209 -0
- data/scss/foundation/components/_custom-forms.scss +232 -0
- data/scss/foundation/components/_dropdown-buttons.scss +114 -0
- data/scss/foundation/components/_dropdown.scss +137 -0
- data/scss/foundation/components/_flex-video.scss +45 -0
- data/scss/foundation/components/_forms.scss +309 -0
- data/scss/foundation/components/_grid.scss +149 -71
- data/scss/foundation/components/_inline-lists.scss +47 -0
- data/scss/foundation/components/_joyride.scss +193 -0
- data/scss/foundation/components/_keystrokes.scss +56 -0
- data/scss/foundation/components/_labels.scss +81 -0
- data/scss/foundation/components/_magellan.scss +15 -0
- data/scss/foundation/components/_orbit.scss +193 -0
- data/scss/foundation/components/_pagination.scss +99 -0
- data/scss/foundation/components/_panels.scss +76 -0
- data/scss/foundation/components/_pricing-tables.scss +130 -0
- data/scss/foundation/components/_progress-bars.scss +68 -0
- data/scss/foundation/components/_reveal.scss +131 -0
- data/scss/foundation/components/_section.scss +194 -0
- data/scss/foundation/components/_side-nav.scss +68 -0
- data/scss/foundation/components/_split-buttons.scss +159 -0
- data/scss/foundation/components/_sub-nav.scss +67 -0
- data/scss/foundation/components/_switch.scss +242 -0
- data/scss/foundation/components/_tables.scss +80 -0
- data/scss/foundation/components/_thumbs.scss +45 -0
- data/scss/foundation/components/_tooltips.scss +113 -0
- data/scss/foundation/components/_top-bar.scss +443 -0
- data/scss/foundation/components/_type.scss +411 -0
- data/scss/foundation/components/_visibility.scss +117 -0
- data/scss/normalize.scss +396 -0
- data/templates/project/config.rb +26 -0
- data/templates/project/index.html +28 -43
- data/templates/project/manifest.rb +21 -28
- data/templates/project/scss/_settings.scss +4 -243
- data/templates/project/scss/app.scss +37 -44
- data/templates/project/scss/normalize.scss +396 -0
- data/test/stylesheets/styles.css +955 -0
- metadata +144 -153
- data/config/deploy.rb +0 -42
- data/lib/foundation/generators/layout_generator.rb +0 -28
- data/scss/foundation/_settings.scss +0 -281
- data/scss/foundation/common/_base.scss +0 -4
- data/scss/foundation/common/_forms.scss +0 -117
- data/scss/foundation/common/_globals.scss +0 -35
- data/scss/foundation/common/_ratios.scss +0 -19
- data/scss/foundation/common/_typography.scss +0 -104
- data/scss/foundation/components/modules/_all.scss +0 -10
- data/scss/foundation/components/modules/_buttons.scss +0 -178
- data/scss/foundation/components/modules/_clearing.scss +0 -61
- data/scss/foundation/components/modules/_joyride.scss +0 -33
- data/scss/foundation/components/modules/_mqueries.scss +0 -458
- data/scss/foundation/components/modules/_navbar.scss +0 -74
- data/scss/foundation/components/modules/_offcanvas.scss +0 -55
- data/scss/foundation/components/modules/_orbit.scss +0 -90
- data/scss/foundation/components/modules/_reveal.scss +0 -34
- data/scss/foundation/components/modules/_tabs.scss +0 -67
- data/scss/foundation/components/modules/_topbar.scss +0 -167
- data/scss/foundation/components/modules/_ui.scss +0 -292
- data/scss/foundation/functions/_all.scss +0 -2
- data/scss/foundation/functions/_convert-number-to-word.scss +0 -10
- data/scss/foundation/functions/_grid-calc.scss +0 -5
- data/scss/foundation/functions/modular-scale.scss +0 -3
- data/scss/foundation/mixins/_all.scss +0 -5
- data/scss/foundation/mixins/_clearfix.scss +0 -13
- data/scss/foundation/mixins/_css-triangle.scss +0 -22
- data/scss/foundation/mixins/_font-size.scss +0 -13
- data/scss/foundation/mixins/_respond-to.scss +0 -11
- data/scss/foundation/mixins/_semantic-grid.scss +0 -66
- data/test/buttons.html +0 -189
- data/test/clearing.html +0 -85
- data/test/config.rb +0 -11
- data/test/elements.html +0 -490
- data/test/forms.html +0 -371
- data/test/grid.html +0 -543
- data/test/images/orbit-demo/demo1.jpeg +0 -0
- data/test/images/orbit-demo/demo2.jpeg +0 -0
- data/test/images/orbit-demo/demo3.jpeg +0 -0
- data/test/images/orbit-demo/slider-background.jpeg +0 -0
- data/test/index.html +0 -83
- data/test/joyride.html +0 -127
- data/test/magellan.html +0 -112
- data/test/navigation.html +0 -269
- data/test/orbit.html +0 -112
- data/test/reveal.html +0 -91
- data/test/scss/_settings.scss +0 -245
- data/test/scss/styles.scss +0 -50
- data/test/tabs.html +0 -197
- data/test/template.html +0 -52
- data/test/topbar-login.html +0 -194
- data/test/topbar.html +0 -139
- data/test/type.html +0 -188
- data/vendor/assets/images/foundation/orbit/bullets.jpg +0 -0
- data/vendor/assets/images/foundation/orbit/left-arrow-small.png +0 -0
- data/vendor/assets/images/foundation/orbit/left-arrow.png +0 -0
- data/vendor/assets/images/foundation/orbit/loading.gif +0 -0
- data/vendor/assets/images/foundation/orbit/mask-black.png +0 -0
- data/vendor/assets/images/foundation/orbit/pause-black.png +0 -0
- data/vendor/assets/images/foundation/orbit/right-arrow-small.png +0 -0
- data/vendor/assets/images/foundation/orbit/right-arrow.png +0 -0
- data/vendor/assets/images/foundation/orbit/rotator-black.png +0 -0
- data/vendor/assets/images/foundation/orbit/timer-black.png +0 -0
- data/vendor/assets/javascripts/foundation/app.js +0 -41
- data/vendor/assets/javascripts/foundation/index.js +0 -19
- data/vendor/assets/javascripts/foundation/jquery.event.move.js +0 -580
- data/vendor/assets/javascripts/foundation/jquery.event.swipe.js +0 -130
- data/vendor/assets/javascripts/foundation/jquery.foundation.accordion.js +0 -47
- data/vendor/assets/javascripts/foundation/jquery.foundation.alerts.js +0 -20
- data/vendor/assets/javascripts/foundation/jquery.foundation.buttons.js +0 -83
- data/vendor/assets/javascripts/foundation/jquery.foundation.clearing.js +0 -413
- data/vendor/assets/javascripts/foundation/jquery.foundation.forms.js +0 -502
- data/vendor/assets/javascripts/foundation/jquery.foundation.joyride.js +0 -639
- data/vendor/assets/javascripts/foundation/jquery.foundation.magellan.js +0 -96
- data/vendor/assets/javascripts/foundation/jquery.foundation.mediaQueryToggle.js +0 -27
- data/vendor/assets/javascripts/foundation/jquery.foundation.navigation.js +0 -55
- data/vendor/assets/javascripts/foundation/jquery.foundation.orbit.js +0 -919
- data/vendor/assets/javascripts/foundation/jquery.foundation.reveal.js +0 -794
- data/vendor/assets/javascripts/foundation/jquery.foundation.tabs.js +0 -66
- data/vendor/assets/javascripts/foundation/jquery.foundation.tooltips.js +0 -211
- data/vendor/assets/javascripts/foundation/jquery.foundation.topbar.js +0 -174
- data/vendor/assets/javascripts/foundation/jquery.js +0 -9555
- data/vendor/assets/javascripts/foundation/jquery.offcanvas.js +0 -50
data/{vendor/assets/javascripts/foundation/jquery.cookie.js → js/foundation/foundation.cookie.js}
RENAMED
@@ -6,6 +6,8 @@
|
|
6
6
|
* Dual licensed under the MIT or GPL Version 2 licenses.
|
7
7
|
* http://www.opensource.org/licenses/mit-license.php
|
8
8
|
* http://www.opensource.org/licenses/GPL-2.0
|
9
|
+
*
|
10
|
+
* Modified to work with Zepto.js by ZURB
|
9
11
|
*/
|
10
12
|
(function ($, document, undefined) {
|
11
13
|
|
@@ -69,4 +71,4 @@
|
|
69
71
|
return false;
|
70
72
|
};
|
71
73
|
|
72
|
-
})(
|
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.0',
|
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));
|