ns-styleguide 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (205) hide show
  1. checksums.yaml +7 -0
  2. data/style-guide/_style-guide.scss +4 -0
  3. data/style-guide/global/_base.scss +33 -0
  4. data/style-guide/global/_colors.scss +24 -0
  5. data/style-guide/global/_extendables.scss +16 -0
  6. data/style-guide/global/_functions.scss +5 -0
  7. data/style-guide/global/_mixins.scss +5 -0
  8. data/style-guide/global/_variables.scss +15 -0
  9. data/templates/project/assets/6.jpg +0 -0
  10. data/templates/project/assets/_nsfont/_comment.svg +8 -0
  11. data/templates/project/assets/_nsfont/_default-user.svg +12 -0
  12. data/templates/project/assets/_nsfont/_home.svg +12 -0
  13. data/templates/project/assets/_nsfont/_notify.svg +13 -0
  14. data/templates/project/assets/_nsfont/_pillbox.svg +27 -0
  15. data/templates/project/assets/_nsfont/_search.svg +12 -0
  16. data/templates/project/assets/_nsfont/bs-circulatory.svg +26 -0
  17. data/templates/project/assets/_nsfont/bs-digestive.svg +28 -0
  18. data/templates/project/assets/_nsfont/bs-endocrine.svg +33 -0
  19. data/templates/project/assets/_nsfont/bs-immune.svg +31 -0
  20. data/templates/project/assets/_nsfont/bs-muscular-skeletal.svg +119 -0
  21. data/templates/project/assets/_nsfont/bs-nervous.svg +31 -0
  22. data/templates/project/assets/_nsfont/bs-reprodutive.svg +29 -0
  23. data/templates/project/assets/_nsfont/bs-respiratory.svg +17 -0
  24. data/templates/project/assets/_nsfont/ls-athletic.svg +17 -0
  25. data/templates/project/assets/_nsfont/ls-diet.svg +21 -0
  26. data/templates/project/assets/_nsfont/ls-energyvitality.svg +14 -0
  27. data/templates/project/assets/_nsfont/ls-mentalacuity.svg +34 -0
  28. data/templates/project/assets/_nsfont/ls-sexual.svg +42 -0
  29. data/templates/project/assets/_nsfont/ls-weightcontrol.svg +17 -0
  30. data/templates/project/assets/_nsfont/nsa-check.svg +7 -0
  31. data/templates/project/assets/_nsfont/nsa-questionmark.svg +15 -0
  32. data/templates/project/assets/_nsfont/nsa-xmark.svg +10 -0
  33. data/templates/project/assets/_nsfont/st-botanical.svg +18 -0
  34. data/templates/project/assets/_nsfont/st-food.svg +24 -0
  35. data/templates/project/assets/_nsfont/st-mineral.svg +15 -0
  36. data/templates/project/assets/_nsfont/st-other.svg +9 -0
  37. data/templates/project/assets/_nsfont/st-vitamin.svg +25 -0
  38. data/templates/project/assets/_nsfont/vote-down.svg +10 -0
  39. data/templates/project/assets/_nsfont/vote-up.svg +10 -0
  40. data/templates/project/assets/_nsfont/yp-age.svg +22 -0
  41. data/templates/project/assets/_nsfont/yp-gender.svg +16 -0
  42. data/templates/project/assets/_nsfont/yp-preventiontherapy.svg +109 -0
  43. data/templates/project/assets/aloe-vera.jpg +0 -0
  44. data/templates/project/assets/alzheimers-brainpuzzle-512.jpg +0 -0
  45. data/templates/project/assets/blurred1.jpg +0 -0
  46. data/templates/project/assets/blurred5.jpg +0 -0
  47. data/templates/project/assets/blurred6.jpg +0 -0
  48. data/templates/project/assets/botanical.svg +18 -0
  49. data/templates/project/assets/capsule.jpg +0 -0
  50. data/templates/project/assets/clouds.jpg +0 -0
  51. data/templates/project/assets/clouds.png +0 -0
  52. data/templates/project/assets/factorfiction-s3d0b80354a.png +0 -0
  53. data/templates/project/assets/factorfiction/factorfiction.png +0 -0
  54. data/templates/project/assets/factorfiction/factorfiction.svg +420 -0
  55. data/templates/project/assets/fff.png +0 -0
  56. data/templates/project/assets/food.svg +24 -0
  57. data/templates/project/assets/foundation/orbit/bullets.jpg +0 -0
  58. data/templates/project/assets/foundation/orbit/left-arrow-small.png +0 -0
  59. data/templates/project/assets/foundation/orbit/left-arrow.png +0 -0
  60. data/templates/project/assets/foundation/orbit/loading.gif +0 -0
  61. data/templates/project/assets/foundation/orbit/mask-black.png +0 -0
  62. data/templates/project/assets/foundation/orbit/pause-black.png +0 -0
  63. data/templates/project/assets/foundation/orbit/right-arrow-small.png +0 -0
  64. data/templates/project/assets/foundation/orbit/right-arrow.png +0 -0
  65. data/templates/project/assets/foundation/orbit/rotator-black.png +0 -0
  66. data/templates/project/assets/foundation/orbit/timer-black.png +0 -0
  67. data/templates/project/assets/glyphicons-halflings-white.png +0 -0
  68. data/templates/project/assets/glyphicons-halflings.png +0 -0
  69. data/templates/project/assets/hero.jpg +0 -0
  70. data/templates/project/assets/hero2.jpg +0 -0
  71. data/templates/project/assets/hero3.jpg +0 -0
  72. data/templates/project/assets/ice.jpg +0 -0
  73. data/templates/project/assets/iceberg.jpg +0 -0
  74. data/templates/project/assets/landing.jpg +0 -0
  75. data/templates/project/assets/mineral.svg +15 -0
  76. data/templates/project/assets/moon.jpg +0 -0
  77. data/templates/project/assets/ns-logo.svg +177 -0
  78. data/templates/project/assets/nslogo-s56b550b473.png +0 -0
  79. data/templates/project/assets/nslogo/nslogo.png +0 -0
  80. data/templates/project/assets/nslogo/nslogo.svg +177 -0
  81. data/templates/project/assets/other.svg +9 -0
  82. data/templates/project/assets/pillbox-hover.svg +33 -0
  83. data/templates/project/assets/pillbox-image.png +0 -0
  84. data/templates/project/assets/pillbox-image.svg +7880 -0
  85. data/templates/project/assets/pillbox.svg +27 -0
  86. data/templates/project/assets/rocket.jpg +0 -0
  87. data/templates/project/assets/shuttle.jpeg +0 -0
  88. data/templates/project/assets/svg/community-clear.svg +82 -0
  89. data/templates/project/assets/svg/community.svg +64 -0
  90. data/templates/project/assets/svg/conditions.svg +18 -0
  91. data/templates/project/assets/svg/experts.svg +32 -0
  92. data/templates/project/assets/svg/fact-or-fiction.svg +420 -0
  93. data/templates/project/assets/svg/lifestyle.svg +22 -0
  94. data/templates/project/assets/svg/perspective.svg +22 -0
  95. data/templates/project/assets/svg/supplements.svg +19 -0
  96. data/templates/project/assets/svgicons-s95620826ea.png +0 -0
  97. data/templates/project/assets/svgicons/community.png +0 -0
  98. data/templates/project/assets/svgicons/community.svg +55 -0
  99. data/templates/project/assets/svgicons/conditions.png +0 -0
  100. data/templates/project/assets/svgicons/conditions.svg +16 -0
  101. data/templates/project/assets/svgicons/experts.png +0 -0
  102. data/templates/project/assets/svgicons/experts.svg +30 -0
  103. data/templates/project/assets/svgicons/lifestyle.png +0 -0
  104. data/templates/project/assets/svgicons/lifestyle.svg +20 -0
  105. data/templates/project/assets/svgicons/supplements.png +0 -0
  106. data/templates/project/assets/svgicons/supplements.svg +17 -0
  107. data/templates/project/assets/svgicons/your-perspective.png +0 -0
  108. data/templates/project/assets/svgicons/your-perspective.svg +20 -0
  109. data/templates/project/assets/users/kp.jpg +0 -0
  110. data/templates/project/assets/video_placeholder.jpg +0 -0
  111. data/templates/project/assets/vitamin.svg +25 -0
  112. data/templates/project/component.json +9 -0
  113. data/templates/project/libs/bootstrap-modal.js +374 -0
  114. data/templates/project/libs/bootstrap/README.md +106 -0
  115. data/templates/project/libs/bootstrap/application.js +156 -0
  116. data/templates/project/libs/bootstrap/bootstrap-affix.js +117 -0
  117. data/templates/project/libs/bootstrap/bootstrap-alert.js +99 -0
  118. data/templates/project/libs/bootstrap/bootstrap-button.js +105 -0
  119. data/templates/project/libs/bootstrap/bootstrap-carousel.js +207 -0
  120. data/templates/project/libs/bootstrap/bootstrap-collapse.js +167 -0
  121. data/templates/project/libs/bootstrap/bootstrap-dropdown.js +165 -0
  122. data/templates/project/libs/bootstrap/bootstrap-modal.js +251 -0
  123. data/templates/project/libs/bootstrap/bootstrap-popover.js +114 -0
  124. data/templates/project/libs/bootstrap/bootstrap-scrollspy.js +162 -0
  125. data/templates/project/libs/bootstrap/bootstrap-tab.js +144 -0
  126. data/templates/project/libs/bootstrap/bootstrap-tooltip.js +361 -0
  127. data/templates/project/libs/bootstrap/bootstrap-transition.js +60 -0
  128. data/templates/project/libs/bootstrap/bootstrap-typeahead.js +335 -0
  129. data/templates/project/libs/bootstrap/bootstrap.js +2280 -0
  130. data/templates/project/libs/bootstrap/bootstrap.min.js +6 -0
  131. data/templates/project/libs/bootstrap/holder/holder.js +401 -0
  132. data/templates/project/libs/bootstrap/html5shiv.js +8 -0
  133. data/templates/project/libs/bootstrap/jquery.js +5 -0
  134. data/templates/project/libs/bootstrap/respond/respond.min.js +6 -0
  135. data/templates/project/libs/equalheights.js +46 -0
  136. data/templates/project/libs/foundation/foundation.alerts.js +50 -0
  137. data/templates/project/libs/foundation/foundation.clearing.js +516 -0
  138. data/templates/project/libs/foundation/foundation.cookie.js +74 -0
  139. data/templates/project/libs/foundation/foundation.dropdown.js +175 -0
  140. data/templates/project/libs/foundation/foundation.forms.js +513 -0
  141. data/templates/project/libs/foundation/foundation.joyride.js +831 -0
  142. data/templates/project/libs/foundation/foundation.js +401 -0
  143. data/templates/project/libs/foundation/foundation.magellan.js +130 -0
  144. data/templates/project/libs/foundation/foundation.orbit.js +373 -0
  145. data/templates/project/libs/foundation/foundation.placeholder.js +159 -0
  146. data/templates/project/libs/foundation/foundation.reveal.js +277 -0
  147. data/templates/project/libs/foundation/foundation.section.js +407 -0
  148. data/templates/project/libs/foundation/foundation.tooltips.js +200 -0
  149. data/templates/project/libs/foundation/foundation.topbar.js +245 -0
  150. data/templates/project/libs/hello.coffee +1 -0
  151. data/templates/project/libs/helper.js +385 -0
  152. data/templates/project/libs/jquery.magnific-popup.js +1783 -0
  153. data/templates/project/libs/jquery.magnific-popup.min.js +4 -0
  154. data/templates/project/libs/jquery.mixitup.min.js +43 -0
  155. data/templates/project/libs/main.js +1 -0
  156. data/templates/project/libs/ns.js +128 -0
  157. data/templates/project/libs/select2-3.4.0/README.md +83 -0
  158. data/templates/project/libs/select2-3.4.0/component.json +8 -0
  159. data/templates/project/libs/select2-3.4.0/release.sh +69 -0
  160. data/templates/project/libs/select2-3.4.0/select2-spinner.gif +0 -0
  161. data/templates/project/libs/select2-3.4.0/select2.css +652 -0
  162. data/templates/project/libs/select2-3.4.0/select2.jquery.json +36 -0
  163. data/templates/project/libs/select2-3.4.0/select2.js +3054 -0
  164. data/templates/project/libs/select2-3.4.0/select2.min.js +22 -0
  165. data/templates/project/libs/select2-3.4.0/select2.png +0 -0
  166. data/templates/project/libs/select2-3.4.0/select2_locale_ca.js +17 -0
  167. data/templates/project/libs/select2-3.4.0/select2_locale_cs.js +49 -0
  168. data/templates/project/libs/select2-3.4.0/select2_locale_da.js +17 -0
  169. data/templates/project/libs/select2-3.4.0/select2_locale_de.js +15 -0
  170. data/templates/project/libs/select2-3.4.0/select2_locale_en.js.template +17 -0
  171. data/templates/project/libs/select2-3.4.0/select2_locale_es.js +15 -0
  172. data/templates/project/libs/select2-3.4.0/select2_locale_et.js +17 -0
  173. data/templates/project/libs/select2-3.4.0/select2_locale_eu.js +43 -0
  174. data/templates/project/libs/select2-3.4.0/select2_locale_fr.js +15 -0
  175. data/templates/project/libs/select2-3.4.0/select2_locale_gl.js +43 -0
  176. data/templates/project/libs/select2-3.4.0/select2_locale_he.js +17 -0
  177. data/templates/project/libs/select2-3.4.0/select2_locale_hr.js +42 -0
  178. data/templates/project/libs/select2-3.4.0/select2_locale_hu.js +15 -0
  179. data/templates/project/libs/select2-3.4.0/select2_locale_is.js +16 -0
  180. data/templates/project/libs/select2-3.4.0/select2_locale_it.js +15 -0
  181. data/templates/project/libs/select2-3.4.0/select2_locale_ja.js +15 -0
  182. data/templates/project/libs/select2-3.4.0/select2_locale_lt.js +29 -0
  183. data/templates/project/libs/select2-3.4.0/select2_locale_lv.js +16 -0
  184. data/templates/project/libs/select2-3.4.0/select2_locale_mk.js +17 -0
  185. data/templates/project/libs/select2-3.4.0/select2_locale_nl.js +15 -0
  186. data/templates/project/libs/select2-3.4.0/select2_locale_no.js +18 -0
  187. data/templates/project/libs/select2-3.4.0/select2_locale_pl.js +37 -0
  188. data/templates/project/libs/select2-3.4.0/select2_locale_pt-BR.js +15 -0
  189. data/templates/project/libs/select2-3.4.0/select2_locale_pt-PT.js +15 -0
  190. data/templates/project/libs/select2-3.4.0/select2_locale_ro.js +15 -0
  191. data/templates/project/libs/select2-3.4.0/select2_locale_ru.js +15 -0
  192. data/templates/project/libs/select2-3.4.0/select2_locale_sk.js +48 -0
  193. data/templates/project/libs/select2-3.4.0/select2_locale_sv.js +17 -0
  194. data/templates/project/libs/select2-3.4.0/select2_locale_tr.js +17 -0
  195. data/templates/project/libs/select2-3.4.0/select2_locale_ua.js +17 -0
  196. data/templates/project/libs/select2-3.4.0/select2_locale_vi.js +18 -0
  197. data/templates/project/libs/select2-3.4.0/select2_locale_zh-CN.js +14 -0
  198. data/templates/project/libs/select2-3.4.0/select2_locale_zh-TW.js +14 -0
  199. data/templates/project/libs/select2-3.4.0/select2x2.png +0 -0
  200. data/templates/project/libs/vendor/modernizr-2.6.2.min.js +4 -0
  201. data/templates/project/libs/vendor/zepto.js +1884 -0
  202. data/templates/project/libs/vendor/zepto.min.js +2 -0
  203. data/templates/project/manifest.rb +9 -0
  204. data/templates/project/style.scss.erb +2 -0
  205. metadata +288 -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,175 @@
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.2.0',
10
+
11
+ settings : {
12
+ activeClass: 'open',
13
+ is_hover: false,
14
+ opened: function(){},
15
+ closed: function(){}
16
+ },
17
+
18
+ init : function (scope, method, options) {
19
+ this.scope = scope || this.scope;
20
+ Foundation.inherit(this, 'throttle scrollLeft data_options');
21
+
22
+ if (typeof method === 'object') {
23
+ $.extend(true, this.settings, method);
24
+ }
25
+
26
+ if (typeof method != 'string') {
27
+
28
+ if (!this.settings.init) {
29
+ this.events();
30
+ }
31
+
32
+ return this.settings.init;
33
+ } else {
34
+ return this[method].call(this, options);
35
+ }
36
+ },
37
+
38
+ events : function () {
39
+ var self = this;
40
+
41
+ $(this.scope)
42
+ .on('click.fndtn.dropdown', '[data-dropdown]', function (e) {
43
+ var settings = $.extend({}, self.settings, self.data_options($(this)));
44
+ e.preventDefault();
45
+
46
+ if (!settings.is_hover) self.toggle($(this));
47
+ })
48
+ .on('mouseenter', '[data-dropdown]', function (e) {
49
+ var settings = $.extend({}, self.settings, self.data_options($(this)));
50
+ if (settings.is_hover) self.toggle($(this));
51
+ })
52
+ .on('mouseleave', '[data-dropdown-content]', function (e) {
53
+ var target = $('[data-dropdown="' + $(this).attr('id') + '"]'),
54
+ settings = $.extend({}, self.settings, self.data_options(target));
55
+ if (settings.is_hover) self.close.call(self, $(this));
56
+ })
57
+ .on('opened.fndtn.dropdown', '[data-dropdown-content]', this.settings.opened)
58
+ .on('closed.fndtn.dropdown', '[data-dropdown-content]', this.settings.closed);
59
+
60
+ $('body').on('click.fndtn.dropdown', function (e) {
61
+ var parent = $(e.target).closest('[data-dropdown-content]');
62
+
63
+ if ($(e.target).data('dropdown')) {
64
+ return;
65
+ }
66
+ if (parent.length > 0 && ($(e.target).is('[data-dropdown-content]') || $.contains(parent.first()[0], e.target))) {
67
+ e.stopPropagation();
68
+ return;
69
+ }
70
+
71
+ self.close.call(self, $('[data-dropdown-content]'));
72
+ });
73
+
74
+ $(window).on('resize.fndtn.dropdown', self.throttle(function () {
75
+ self.resize.call(self);
76
+ }, 50)).trigger('resize');
77
+
78
+ this.settings.init = true;
79
+ },
80
+
81
+ close: function (dropdown) {
82
+ var self = this;
83
+ dropdown.each(function () {
84
+ if ($(this).hasClass(self.settings.activeClass)) {
85
+ $(this)
86
+ .css(Foundation.rtl ? 'right':'left', '-99999px')
87
+ .removeClass(self.settings.activeClass);
88
+ $(this).trigger('closed');
89
+ }
90
+ });
91
+ },
92
+
93
+ open: function (dropdown, target) {
94
+ this
95
+ .css(dropdown
96
+ .addClass(this.settings.activeClass), target);
97
+ dropdown.trigger('opened');
98
+ },
99
+
100
+ toggle : function (target) {
101
+ var dropdown = $('#' + target.data('dropdown'));
102
+
103
+ this.close.call(this, $('[data-dropdown-content]').not(dropdown));
104
+
105
+ if (dropdown.hasClass(this.settings.activeClass)) {
106
+ this.close.call(this, dropdown);
107
+ } else {
108
+ this.close.call(this, $('[data-dropdown-content]'))
109
+ this.open.call(this, dropdown, target);
110
+ }
111
+ },
112
+
113
+ resize : function () {
114
+ var dropdown = $('[data-dropdown-content].open'),
115
+ target = $("[data-dropdown='" + dropdown.attr('id') + "']");
116
+
117
+ if (dropdown.length && target.length) {
118
+ this.css(dropdown, target);
119
+ }
120
+ },
121
+
122
+ css : function (dropdown, target) {
123
+ // temporary workaround until 4.2
124
+ if (/body/i.test(dropdown.offsetParent()[0].nodeName)) {
125
+ var position = target.offset();
126
+ position.top -= dropdown.offsetParent().offset().top;
127
+ position.left -= dropdown.offsetParent().offset().left;
128
+ } else {
129
+ var position = target.position();
130
+ }
131
+
132
+ if (this.small()) {
133
+ dropdown.css({
134
+ position : 'absolute',
135
+ width: '95%',
136
+ left: '2.5%',
137
+ 'max-width': 'none',
138
+ top: position.top + this.outerHeight(target)
139
+ });
140
+ } else {
141
+ if (!Foundation.rtl && $(window).width() > this.outerWidth(dropdown) + target.offset().left) {
142
+ var left = position.left;
143
+ if (dropdown.hasClass('right')) {
144
+ dropdown.removeClass('right');
145
+ }
146
+ } else {
147
+ if (!dropdown.hasClass('right')) {
148
+ dropdown.addClass('right');
149
+ }
150
+ var left = position.left - (this.outerWidth(dropdown) - this.outerWidth(target));
151
+ }
152
+
153
+ dropdown.attr('style', '').css({
154
+ position : 'absolute',
155
+ top: position.top + this.outerHeight(target),
156
+ left: left
157
+ });
158
+ }
159
+
160
+ return dropdown;
161
+ },
162
+
163
+ small : function () {
164
+ return $(window).width() < 768 || $('html').hasClass('lt-ie9');
165
+ },
166
+
167
+ off: function () {
168
+ $(this.scope).off('.fndtn.dropdown');
169
+ $('html, body').off('.fndtn.dropdown');
170
+ $(window).off('.fndtn.dropdown');
171
+ $('[data-dropdown-content]').off('.fndtn.dropdown');
172
+ this.settings.init = false;
173
+ }
174
+ };
175
+ }(Foundation.zj, this, this.document));
@@ -0,0 +1,513 @@
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('click.fndtn.forms', 'form.custom div.custom.dropdown a.current, form.custom div.custom.dropdown a.selector', function (e) {
91
+ var $this = $(this),
92
+ $dropdown = $this.closest('div.custom.dropdown'),
93
+ $select = getFirstPrevSibling($dropdown, 'select');
94
+
95
+ // make sure other dropdowns close
96
+ if (!$dropdown.hasClass('open')) $(self.scope).trigger('click');
97
+
98
+ e.preventDefault();
99
+ if (false === $select.is(':disabled')) {
100
+ $dropdown.toggleClass('open');
101
+
102
+ if ($dropdown.hasClass('open')) {
103
+ $(self.scope).on('click.fndtn.forms.customdropdown', function () {
104
+ $dropdown.removeClass('open');
105
+ $(self.scope).off('.fndtn.forms.customdropdown');
106
+ });
107
+ } else {
108
+ $(self.scope).on('.fndtn.forms.customdropdown');
109
+ }
110
+ return false;
111
+ }
112
+ })
113
+ .on('click.fndtn.forms touchend.fndtn.forms', 'form.custom div.custom.dropdown li', function (e) {
114
+ var $this = $(this),
115
+ $customDropdown = $this.closest('div.custom.dropdown'),
116
+ $select = getFirstPrevSibling($customDropdown, 'select'),
117
+ selectedIndex = 0;
118
+
119
+ e.preventDefault();
120
+ e.stopPropagation();
121
+
122
+ if (!$(this).hasClass('disabled')) {
123
+ $('div.dropdown').not($customDropdown).removeClass('open');
124
+
125
+ var $oldThis = $this.closest('ul')
126
+ .find('li.selected');
127
+ $oldThis.removeClass('selected');
128
+
129
+ $this.addClass('selected');
130
+
131
+ $customDropdown.removeClass('open')
132
+ .find('a.current')
133
+ .text($this.text());
134
+
135
+ $this.closest('ul').find('li').each(function (index) {
136
+ if ($this[0] == this) {
137
+ selectedIndex = index;
138
+ }
139
+ });
140
+ $select[0].selectedIndex = selectedIndex;
141
+
142
+ //store the old value in data
143
+ $select.data('prevalue', $oldThis.html());
144
+ $select.trigger('change');
145
+ }
146
+ });
147
+
148
+ $(window).on('keydown', function (e) {
149
+ var focus = document.activeElement,
150
+ self = Foundation.libs.forms,
151
+ dropdown = $('.custom.dropdown.open');
152
+
153
+ if (dropdown.length > 0) {
154
+ e.preventDefault();
155
+
156
+ if (e.which === 13) {
157
+ dropdown.find('li.selected').trigger('click');
158
+ }
159
+
160
+ if (e.which === 27) {
161
+ dropdown.removeClass('open');
162
+ }
163
+
164
+ if (e.which >= 65 && e.which <= 90) {
165
+ var next = self.go_to(dropdown, e.which),
166
+ current = dropdown.find('li.selected');
167
+
168
+ if (next) {
169
+ current.removeClass('selected');
170
+ self.scrollTo(next.addClass('selected'), 300);
171
+ }
172
+ }
173
+
174
+ if (e.which === 38) {
175
+ var current = dropdown.find('li.selected'),
176
+ prev = current.prev(':not(.disabled)');
177
+
178
+ if (prev.length > 0) {
179
+ prev.parent()[0].scrollTop = prev.parent().scrollTop() - self.outerHeight(prev);
180
+ current.removeClass('selected');
181
+ prev.addClass('selected');
182
+ }
183
+ } else if (e.which === 40) {
184
+ var current = dropdown.find('li.selected'),
185
+ next = current.next(':not(.disabled)');
186
+
187
+ if (next.length > 0) {
188
+ next.parent()[0].scrollTop = next.parent().scrollTop() + self.outerHeight(next);
189
+ current.removeClass('selected');
190
+ next.addClass('selected');
191
+ }
192
+ }
193
+ }
194
+ });
195
+
196
+ this.settings.init = true;
197
+ },
198
+
199
+ go_to: function (dropdown, char) {
200
+ var lis = dropdown.find('li'),
201
+ count = lis.length;
202
+
203
+ if (count > 0) {
204
+ for (var i = 0; i < count; i++) {
205
+ var first_letter = lis.eq(i).text().charAt(0).toLowerCase();
206
+ if (first_letter === String.fromCharCode(char).toLowerCase()) return lis.eq(i);
207
+ }
208
+ }
209
+ },
210
+
211
+ scrollTo: function (el, duration) {
212
+ if (duration < 0) return;
213
+ var parent = el.parent();
214
+ var li_height = this.outerHeight(el);
215
+ var difference = (li_height * (el.index())) - parent.scrollTop();
216
+ var perTick = difference / duration * 10;
217
+
218
+ this.scrollToTimerCache = setTimeout(function () {
219
+ if (!isNaN(parseInt(perTick, 10))) {
220
+ parent[0].scrollTop = parent.scrollTop() + perTick;
221
+ this.scrollTo(el, duration - 10);
222
+ }
223
+ }.bind(this), 10);
224
+ },
225
+
226
+ append_custom_markup: function (idx, sel) {
227
+ var $this = $(sel),
228
+ type = $this.attr('type'),
229
+ $span = $this.next('span.custom.' + type);
230
+
231
+ if (!$this.parent().hasClass('switch')) {
232
+ $this.addClass('hidden-field');
233
+ }
234
+
235
+ if ($span.length === 0) {
236
+ $span = $('<span class="custom ' + type + '"></span>').insertAfter($this);
237
+ }
238
+
239
+ $span.toggleClass('checked', $this.is(':checked'));
240
+ $span.toggleClass('disabled', $this.is(':disabled'));
241
+ },
242
+
243
+ append_custom_select: function (idx, sel) {
244
+ var self = Foundation.libs.forms,
245
+ $this = $(sel),
246
+ $customSelect = $this.next('div.custom.dropdown'),
247
+ $customList = $customSelect.find('ul'),
248
+ $selectCurrent = $customSelect.find(".current"),
249
+ $selector = $customSelect.find(".selector"),
250
+ $options = $this.find('option'),
251
+ $selectedOption = $options.filter(':selected'),
252
+ copyClasses = $this.attr('class') ? $this.attr('class').split(' ') : [],
253
+ maxWidth = 0,
254
+ liHtml = '',
255
+ $listItems,
256
+ $currentSelect = false;
257
+
258
+ if ($this.hasClass(self.settings.disable_class)) return;
259
+
260
+ if ($customSelect.length === 0) {
261
+ var customSelectSize = $this.hasClass('small') ? 'small' : $this.hasClass('medium') ? 'medium' : $this.hasClass('large') ? 'large' : $this.hasClass('expand') ? 'expand' : '';
262
+
263
+ $customSelect = $('<div class="' + ['custom', 'dropdown', customSelectSize].concat(copyClasses).filter(function (item, idx, arr) {
264
+ if (item == '') return false;
265
+ return arr.indexOf(item) == idx;
266
+ }).join(' ') + '"><a href="#" class="selector"></a><ul /></div>');
267
+
268
+ $selector = $customSelect.find(".selector");
269
+ $customList = $customSelect.find("ul");
270
+
271
+ liHtml = $options.map(function () {
272
+ return "<li>" + $(this).html() + "</li>";
273
+ }).get().join('');
274
+
275
+ $customList.append(liHtml);
276
+
277
+ $currentSelect = $customSelect
278
+ .prepend('<a href="#" class="current">' + $selectedOption.html() + '</a>')
279
+ .find(".current");
280
+
281
+ $this.after($customSelect)
282
+ .addClass('hidden-field');
283
+ } else {
284
+ liHtml = $options.map(function () {
285
+ return "<li>" + $(this).html() + "</li>";
286
+ })
287
+ .get().join('');
288
+
289
+ $customList.html('')
290
+ .append(liHtml);
291
+
292
+ } // endif $customSelect.length === 0
293
+
294
+ self.assign_id($this, $customSelect);
295
+ $customSelect.toggleClass('disabled', $this.is(':disabled'));
296
+ $listItems = $customList.find('li');
297
+
298
+ // cache list length
299
+ self.cache[$customSelect.data('id')] = $listItems.length;
300
+
301
+ $options.each(function (index) {
302
+ if (this.selected) {
303
+ $listItems.eq(index).addClass('selected');
304
+
305
+ if ($currentSelect) {
306
+ $currentSelect.html($(this).html());
307
+ }
308
+ }
309
+ if ($(this).is(':disabled')) {
310
+ $listItems.eq(index).addClass('disabled');
311
+ }
312
+ });
313
+
314
+ //
315
+ // If we're not specifying a predetermined form size.
316
+ //
317
+ if (!$customSelect.is('.small, .medium, .large, .expand')) {
318
+
319
+ // ------------------------------------------------------------------------------------
320
+ // This is a work-around for when elements are contained within hidden parents.
321
+ // For example, when custom-form elements are inside of a hidden reveal modal.
322
+ //
323
+ // We need to display the current custom list element as well as hidden parent elements
324
+ // in order to properly calculate the list item element's width property.
325
+ // -------------------------------------------------------------------------------------
326
+
327
+ $customSelect.addClass('open');
328
+ //
329
+ // Quickly, display all parent elements.
330
+ // This should help us calcualate the width of the list item's within the drop down.
331
+ //
332
+ var self = Foundation.libs.forms;
333
+ self.hidden_fix.adjust($customList);
334
+
335
+ maxWidth = (self.outerWidth($listItems) > maxWidth) ? self.outerWidth($listItems) : maxWidth;
336
+
337
+ Foundation.libs.forms.hidden_fix.reset();
338
+
339
+ $customSelect.removeClass('open');
340
+
341
+ } // endif
342
+
343
+ },
344
+
345
+ assign_id: function ($select, $customSelect) {
346
+ var id = [+new Date(), Foundation.random_str(5)].join('-');
347
+ $select.attr('data-id', id);
348
+ $customSelect.attr('data-id', id);
349
+ },
350
+
351
+ refresh_custom_select: function ($select, force_refresh) {
352
+ var self = this;
353
+ var maxWidth = 0,
354
+ $customSelect = $select.next(),
355
+ $options = $select.find('option'),
356
+ $listItems = $customSelect.find('li');
357
+
358
+ if ($listItems.length != this.cache[$customSelect.data('id')] || force_refresh) {
359
+ $customSelect.find('ul').html('');
360
+
361
+ $options.each(function () {
362
+ var $li = $('<li>' + $(this).html() + '</li>');
363
+ $customSelect.find('ul').append($li);
364
+ });
365
+
366
+ // re-populate
367
+ $options.each(function (index) {
368
+ if (this.selected) {
369
+ $customSelect.find('li').eq(index).addClass('selected');
370
+ $customSelect.find('.current').html($(this).html());
371
+ }
372
+ if ($(this).is(':disabled')) {
373
+ $customSelect.find('li').eq(index).addClass('disabled');
374
+ }
375
+ });
376
+
377
+ // fix width
378
+ $customSelect.removeAttr('style')
379
+ .find('ul').removeAttr('style');
380
+ $customSelect.find('li').each(function () {
381
+ $customSelect.addClass('open');
382
+ if (self.outerWidth($(this)) > maxWidth) {
383
+ maxWidth = self.outerWidth($(this));
384
+ }
385
+ $customSelect.removeClass('open');
386
+ });
387
+
388
+ $listItems = $customSelect.find('li');
389
+ // cache list length
390
+ this.cache[$customSelect.data('id')] = $listItems.length;
391
+ }
392
+ },
393
+
394
+ toggle_checkbox: function ($element) {
395
+ var $input = $element.prev(),
396
+ input = $input[0];
397
+
398
+ if (false === $input.is(':disabled')) {
399
+ input.checked = ((input.checked) ? false : true);
400
+ $element.toggleClass('checked');
401
+
402
+ $input.trigger('change');
403
+ }
404
+ },
405
+
406
+ toggle_radio: function ($element) {
407
+ var $input = $element.prev(),
408
+ $form = $input.closest('form.custom'),
409
+ input = $input[0];
410
+
411
+ if (false === $input.is(':disabled')) {
412
+ $form.find('input[type="radio"][name="' + this.escape($input.attr('name')) + '"]')
413
+ .next().not($element).removeClass('checked');
414
+
415
+ if (!$element.hasClass('checked')) {
416
+ $element.toggleClass('checked');
417
+ }
418
+
419
+ input.checked = $element.hasClass('checked');
420
+
421
+ $input.trigger('change');
422
+ }
423
+ },
424
+
425
+ escape: function (text) {
426
+ return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
427
+ },
428
+
429
+ hidden_fix: {
430
+ /**
431
+ * Sets all hidden parent elements and self to visibile.
432
+ *
433
+ * @method adjust
434
+ * @param {jQuery Object} $child
435
+ */
436
+
437
+ // We'll use this to temporarily store style properties.
438
+ tmp: [],
439
+
440
+ // We'll use this to set hidden parent elements.
441
+ hidden: null,
442
+
443
+ adjust: function ($child) {
444
+ // Internal reference.
445
+ var _self = this;
446
+
447
+ // Set all hidden parent elements, including this element.
448
+ _self.hidden = $child.parents().andSelf().filter(":hidden");
449
+
450
+ // Loop through all hidden elements.
451
+ _self.hidden.each(function () {
452
+
453
+ // Cache the element.
454
+ var $elem = $(this);
455
+
456
+ // Store the style attribute.
457
+ // Undefined if element doesn't have a style attribute.
458
+ _self.tmp.push($elem.attr('style'));
459
+
460
+ // Set the element's display property to block,
461
+ // but ensure it's visibility is hidden.
462
+ $elem.css({
463
+ 'visibility': 'hidden',
464
+ 'display': 'block'
465
+ });
466
+ });
467
+
468
+ }, // end adjust
469
+
470
+ /**
471
+ * Resets the elements previous state.
472
+ *
473
+ * @method reset
474
+ */
475
+ reset: function () {
476
+ // Internal reference.
477
+ var _self = this;
478
+ // Loop through our hidden element collection.
479
+ _self.hidden.each(function (i) {
480
+ // Cache this element.
481
+ var $elem = $(this),
482
+ _tmp = _self.tmp[i]; // Get the stored 'style' value for this element.
483
+
484
+ // If the stored value is undefined.
485
+ if (_tmp === undefined)
486
+ // Remove the style attribute.
487
+ $elem.removeAttr('style');
488
+ else
489
+ // Otherwise, reset the element style attribute.
490
+ $elem.attr('style', _tmp);
491
+ });
492
+ // Reset the tmp array.
493
+ _self.tmp = [];
494
+ // Reset the hidden elements variable.
495
+ _self.hidden = null;
496
+
497
+ } // end reset
498
+ },
499
+
500
+ off: function () {
501
+ $(this.scope).off('.fndtn.forms');
502
+ }
503
+ };
504
+
505
+ var getFirstPrevSibling = function($el, selector) {
506
+ var $el = $el.prev();
507
+ while ($el.length) {
508
+ if ($el.is(selector)) return $el;
509
+ $el = $el.prev();
510
+ }
511
+ return $();
512
+ };
513
+ }(Foundation.zj, this, this.document));