docs-cambiocds-com-jekyll-theme 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +21 -21
  3. data/README.md +48 -48
  4. data/_layouts/default.html +96 -100
  5. data/assets/css/asciidoctor.css +397 -397
  6. data/assets/css/coderay.css +89 -89
  7. data/assets/css/custom.css +32 -0
  8. data/assets/css/font-awesome.css +1801 -1801
  9. data/assets/css/font-awesome.min.css +3 -3
  10. data/assets/css/foundation.css +8545 -8545
  11. data/assets/css/foundation.min.css +8331 -8331
  12. data/assets/css/normalize.css +427 -427
  13. data/assets/js/foundation.min.js +6069 -6069
  14. data/assets/js/foundation/foundation.abide.js +325 -325
  15. data/assets/js/foundation/foundation.accordion.js +71 -71
  16. data/assets/js/foundation/foundation.alert.js +46 -46
  17. data/assets/js/foundation/foundation.clearing.js +573 -573
  18. data/assets/js/foundation/foundation.dropdown.js +444 -444
  19. data/assets/js/foundation/foundation.equalizer.js +77 -77
  20. data/assets/js/foundation/foundation.interchange.js +349 -349
  21. data/assets/js/foundation/foundation.joyride.js +939 -939
  22. data/assets/js/foundation/foundation.js +691 -691
  23. data/assets/js/foundation/foundation.magellan.js +199 -199
  24. data/assets/js/foundation/foundation.offcanvas.js +154 -154
  25. data/assets/js/foundation/foundation.orbit.js +512 -512
  26. data/assets/js/foundation/foundation.reveal.js +455 -455
  27. data/assets/js/foundation/foundation.slider.js +268 -268
  28. data/assets/js/foundation/foundation.tab.js +221 -221
  29. data/assets/js/foundation/foundation.tooltip.js +301 -301
  30. data/assets/js/foundation/foundation.topbar.js +444 -444
  31. data/assets/js/toc.js +82 -82
  32. data/assets/js/vendor/fastclick.js +169 -169
  33. data/assets/js/vendor/jquery.cookie.js +57 -57
  34. data/assets/js/vendor/jquery.js +2339 -2339
  35. data/assets/js/vendor/modernizr.js +304 -304
  36. data/assets/js/vendor/placeholder.js +75 -75
  37. metadata +12 -11
@@ -1,325 +1,325 @@
1
- ;
2
- (function ($, window, document, undefined) {
3
- 'use strict';
4
-
5
- Foundation.libs.abide = {
6
- name: 'abide',
7
-
8
- version: '5.5.0',
9
-
10
- settings: {
11
- live_validate: true,
12
- validate_on_blur: true,
13
- focus_on_invalid: true,
14
- error_labels: true, // labels with a for="inputId" will recieve an `error` class
15
- error_class: 'error',
16
- timeout: 1000,
17
- patterns: {
18
- alpha: /^[a-zA-Z]+$/,
19
- alpha_numeric: /^[a-zA-Z0-9]+$/,
20
- integer: /^[-+]?\d+$/,
21
- number: /^[-+]?\d*(?:[\.\,]\d+)?$/,
22
-
23
- // amex, visa, diners
24
- card: /^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11})$/,
25
- cvv: /^([0-9]){3,4}$/,
26
-
27
- // http://www.whatwg.org/specs/web-apps/current-work/multipage/states-of-the-type-attribute.html#valid-e-mail-address
28
- email: /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+$/,
29
-
30
- url: /^(https?|ftp|file|ssh):\/\/(((([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-zA-Z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-zA-Z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-zA-Z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-zA-Z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-zA-Z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-zA-Z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/,
31
- // abc.de
32
- domain: /^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,8}$/,
33
-
34
- datetime: /^([0-2][0-9]{3})\-([0-1][0-9])\-([0-3][0-9])T([0-5][0-9])\:([0-5][0-9])\:([0-5][0-9])(Z|([\-\+]([0-1][0-9])\:00))$/,
35
- // YYYY-MM-DD
36
- date: /(?:19|20)[0-9]{2}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-9])|(?:(?!02)(?:0[1-9]|1[0-2])-(?:30))|(?:(?:0[13578]|1[02])-31))$/,
37
- // HH:MM:SS
38
- time: /^(0[0-9]|1[0-9]|2[0-3])(:[0-5][0-9]){2}$/,
39
- dateISO: /^\d{4}[\/\-]\d{1,2}[\/\-]\d{1,2}$/,
40
- // MM/DD/YYYY
41
- month_day_year: /^(0[1-9]|1[012])[- \/.](0[1-9]|[12][0-9]|3[01])[- \/.]\d{4}$/,
42
- // DD/MM/YYYY
43
- day_month_year: /^(0[1-9]|[12][0-9]|3[01])[- \/.](0[1-9]|1[012])[- \/.]\d{4}$/,
44
-
45
- // #FFF or #FFFFFF
46
- color: /^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/
47
- },
48
- validators: {
49
- equalTo: function (el, required, parent) {
50
- var from = document.getElementById(el.getAttribute(this.add_namespace('data-equalto'))).value,
51
- to = el.value,
52
- valid = (from === to);
53
-
54
- return valid;
55
- }
56
- }
57
- },
58
-
59
- timer: null,
60
-
61
- init: function (scope, method, options) {
62
- this.bindings(method, options);
63
- },
64
-
65
- events: function (scope) {
66
- var self = this,
67
- form = self.S(scope).attr('novalidate', 'novalidate'),
68
- settings = form.data(this.attr_name(true) + '-init') || {};
69
-
70
- this.invalid_attr = this.add_namespace('data-invalid');
71
-
72
- form
73
- .off('.abide')
74
- .on('submit.fndtn.abide validate.fndtn.abide', function (e) {
75
- var is_ajax = /ajax/i.test(self.S(this).attr(self.attr_name()));
76
- return self.validate(self.S(this).find('input, textarea, select').get(), e, is_ajax);
77
- })
78
- .on('reset', function () {
79
- return self.reset($(this));
80
- })
81
- .find('input, textarea, select')
82
- .off('.abide')
83
- .on('blur.fndtn.abide change.fndtn.abide', function (e) {
84
- if (settings.validate_on_blur === true) {
85
- self.validate([this], e);
86
- }
87
- })
88
- .on('keydown.fndtn.abide', function (e) {
89
- if (settings.live_validate === true && e.which != 9) {
90
- clearTimeout(self.timer);
91
- self.timer = setTimeout(function () {
92
- self.validate([this], e);
93
- }.bind(this), settings.timeout);
94
- }
95
- });
96
- },
97
-
98
- reset: function (form) {
99
- form.removeAttr(this.invalid_attr);
100
- $(this.invalid_attr, form).removeAttr(this.invalid_attr);
101
- $('.' + this.settings.error_class, form).not('small').removeClass(this.settings.error_class);
102
- },
103
-
104
- validate: function (els, e, is_ajax) {
105
- var validations = this.parse_patterns(els),
106
- validation_count = validations.length,
107
- form = this.S(els[0]).closest('form'),
108
- submit_event = /submit/.test(e.type);
109
-
110
- // Has to count up to make sure the focus gets applied to the top error
111
- for (var i = 0; i < validation_count; i++) {
112
- if (!validations[i] && (submit_event || is_ajax)) {
113
- if (this.settings.focus_on_invalid) els[i].focus();
114
- form.trigger('invalid').trigger('invalid.fndtn.abide');
115
- this.S(els[i]).closest('form').attr(this.invalid_attr, '');
116
- return false;
117
- }
118
- }
119
-
120
- if (submit_event || is_ajax) {
121
- form.trigger('valid').trigger('valid.fndtn.abide');
122
- }
123
-
124
- form.removeAttr(this.invalid_attr);
125
-
126
- if (is_ajax) return false;
127
-
128
- return true;
129
- },
130
-
131
- parse_patterns: function (els) {
132
- var i = els.length,
133
- el_patterns = [];
134
-
135
- while (i--) {
136
- el_patterns.push(this.pattern(els[i]));
137
- }
138
-
139
- return this.check_validation_and_apply_styles(el_patterns);
140
- },
141
-
142
- pattern: function (el) {
143
- var type = el.getAttribute('type'),
144
- required = typeof el.getAttribute('required') === 'string';
145
-
146
- var pattern = el.getAttribute('pattern') || '';
147
-
148
- if (this.settings.patterns.hasOwnProperty(pattern) && pattern.length > 0) {
149
- return [el, this.settings.patterns[pattern], required];
150
- } else if (pattern.length > 0) {
151
- return [el, new RegExp(pattern), required];
152
- }
153
-
154
- if (this.settings.patterns.hasOwnProperty(type)) {
155
- return [el, this.settings.patterns[type], required];
156
- }
157
-
158
- pattern = /.*/;
159
-
160
- return [el, pattern, required];
161
- },
162
-
163
- // TODO: Break this up into smaller methods, getting hard to read.
164
- check_validation_and_apply_styles: function (el_patterns) {
165
- var i = el_patterns.length,
166
- validations = [],
167
- form = this.S(el_patterns[0][0]).closest('[data-' + this.attr_name(true) + ']'),
168
- settings = form.data(this.attr_name(true) + '-init') || {};
169
- while (i--) {
170
- var el = el_patterns[i][0],
171
- required = el_patterns[i][2],
172
- value = el.value.trim(),
173
- direct_parent = this.S(el).parent(),
174
- validator = el.getAttribute(this.add_namespace('data-abide-validator')),
175
- is_radio = el.type === "radio",
176
- is_checkbox = el.type === "checkbox",
177
- label = this.S('label[for="' + el.getAttribute('id') + '"]'),
178
- valid_length = (required) ? (el.value.length > 0) : true,
179
- el_validations = [];
180
-
181
- var parent, valid;
182
-
183
- // support old way to do equalTo validations
184
- if (el.getAttribute(this.add_namespace('data-equalto'))) {
185
- validator = "equalTo"
186
- }
187
-
188
- if (!direct_parent.is('label')) {
189
- parent = direct_parent;
190
- } else {
191
- parent = direct_parent.parent();
192
- }
193
-
194
- if (validator) {
195
- valid = this.settings.validators[validator].apply(this, [el, required, parent]);
196
- el_validations.push(valid);
197
- }
198
-
199
- if (is_radio && required) {
200
- el_validations.push(this.valid_radio(el, required));
201
- } else if (is_checkbox && required) {
202
- el_validations.push(this.valid_checkbox(el, required));
203
- } else {
204
-
205
- if (el_patterns[i][1].test(value) && valid_length ||
206
- !required && el.value.length < 1 || $(el).attr('disabled')) {
207
- el_validations.push(true);
208
- } else {
209
- el_validations.push(false);
210
- }
211
-
212
- el_validations = [el_validations.every(function (valid) {
213
- return valid;
214
- })];
215
-
216
- if (el_validations[0]) {
217
- this.S(el).removeAttr(this.invalid_attr);
218
- el.setAttribute('aria-invalid', 'false');
219
- el.removeAttribute('aria-describedby');
220
- parent.removeClass(this.settings.error_class);
221
- if (label.length > 0 && this.settings.error_labels) {
222
- label.removeClass(this.settings.error_class).removeAttr('role');
223
- }
224
- $(el).triggerHandler('valid');
225
- } else {
226
- this.S(el).attr(this.invalid_attr, '');
227
- el.setAttribute('aria-invalid', 'true');
228
-
229
- // Try to find the error associated with the input
230
- var errorElem = parent.find('small.' + this.settings.error_class, 'span.' + this.settings.error_class);
231
- var errorID = errorElem.length > 0 ? errorElem[0].id : "";
232
- if (errorID.length > 0) el.setAttribute('aria-describedby', errorID);
233
-
234
- // el.setAttribute('aria-describedby', $(el).find('.error')[0].id);
235
- parent.addClass(this.settings.error_class);
236
- if (label.length > 0 && this.settings.error_labels) {
237
- label.addClass(this.settings.error_class).attr('role', 'alert');
238
- }
239
- $(el).triggerHandler('invalid');
240
- }
241
- }
242
- validations.push(el_validations[0]);
243
- }
244
- validations = [validations.every(function (valid) {
245
- return valid;
246
- })];
247
- return validations;
248
- },
249
-
250
- valid_checkbox: function (el, required) {
251
- var el = this.S(el),
252
- valid = (el.is(':checked') || !required);
253
-
254
- if (valid) {
255
- el.removeAttr(this.invalid_attr).parent().removeClass(this.settings.error_class);
256
- } else {
257
- el.attr(this.invalid_attr, '').parent().addClass(this.settings.error_class);
258
- }
259
-
260
- return valid;
261
- },
262
-
263
- valid_radio: function (el, required) {
264
- var name = el.getAttribute('name'),
265
- group = this.S(el).closest('[data-' + this.attr_name(true) + ']').find("[name='" + name + "']"),
266
- count = group.length,
267
- valid = false;
268
-
269
- // Has to count up to make sure the focus gets applied to the top error
270
- for (var i = 0; i < count; i++) {
271
- if (group[i].checked) valid = true;
272
- }
273
-
274
- // Has to count up to make sure the focus gets applied to the top error
275
- for (var i = 0; i < count; i++) {
276
- if (valid) {
277
- this.S(group[i]).removeAttr(this.invalid_attr).parent().removeClass(this.settings.error_class);
278
- } else {
279
- this.S(group[i]).attr(this.invalid_attr, '').parent().addClass(this.settings.error_class);
280
- }
281
- }
282
-
283
- return valid;
284
- },
285
-
286
- valid_equal: function (el, required, parent) {
287
- var from = document.getElementById(el.getAttribute(this.add_namespace('data-equalto'))).value,
288
- to = el.value,
289
- valid = (from === to);
290
-
291
- if (valid) {
292
- this.S(el).removeAttr(this.invalid_attr);
293
- parent.removeClass(this.settings.error_class);
294
- if (label.length > 0 && settings.error_labels) label.removeClass(this.settings.error_class);
295
- } else {
296
- this.S(el).attr(this.invalid_attr, '');
297
- parent.addClass(this.settings.error_class);
298
- if (label.length > 0 && settings.error_labels) label.addClass(this.settings.error_class);
299
- }
300
-
301
- return valid;
302
- },
303
-
304
- valid_oneof: function (el, required, parent, doNotValidateOthers) {
305
- var el = this.S(el),
306
- others = this.S('[' + this.add_namespace('data-oneof') + ']'),
307
- valid = others.filter(':checked').length > 0;
308
-
309
- if (valid) {
310
- el.removeAttr(this.invalid_attr).parent().removeClass(this.settings.error_class);
311
- } else {
312
- el.attr(this.invalid_attr, '').parent().addClass(this.settings.error_class);
313
- }
314
-
315
- if (!doNotValidateOthers) {
316
- var _this = this;
317
- others.each(function () {
318
- _this.valid_oneof.call(_this, this, null, null, true);
319
- });
320
- }
321
-
322
- return valid;
323
- }
324
- };
325
- }(jQuery, window, window.document));
1
+ ;
2
+ (function ($, window, document, undefined) {
3
+ 'use strict';
4
+
5
+ Foundation.libs.abide = {
6
+ name: 'abide',
7
+
8
+ version: '5.5.0',
9
+
10
+ settings: {
11
+ live_validate: true,
12
+ validate_on_blur: true,
13
+ focus_on_invalid: true,
14
+ error_labels: true, // labels with a for="inputId" will recieve an `error` class
15
+ error_class: 'error',
16
+ timeout: 1000,
17
+ patterns: {
18
+ alpha: /^[a-zA-Z]+$/,
19
+ alpha_numeric: /^[a-zA-Z0-9]+$/,
20
+ integer: /^[-+]?\d+$/,
21
+ number: /^[-+]?\d*(?:[\.\,]\d+)?$/,
22
+
23
+ // amex, visa, diners
24
+ card: /^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11})$/,
25
+ cvv: /^([0-9]){3,4}$/,
26
+
27
+ // http://www.whatwg.org/specs/web-apps/current-work/multipage/states-of-the-type-attribute.html#valid-e-mail-address
28
+ email: /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+$/,
29
+
30
+ url: /^(https?|ftp|file|ssh):\/\/(((([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-zA-Z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-zA-Z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-zA-Z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-zA-Z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-zA-Z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-zA-Z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-zA-Z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/,
31
+ // abc.de
32
+ domain: /^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,8}$/,
33
+
34
+ datetime: /^([0-2][0-9]{3})\-([0-1][0-9])\-([0-3][0-9])T([0-5][0-9])\:([0-5][0-9])\:([0-5][0-9])(Z|([\-\+]([0-1][0-9])\:00))$/,
35
+ // YYYY-MM-DD
36
+ date: /(?:19|20)[0-9]{2}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-9])|(?:(?!02)(?:0[1-9]|1[0-2])-(?:30))|(?:(?:0[13578]|1[02])-31))$/,
37
+ // HH:MM:SS
38
+ time: /^(0[0-9]|1[0-9]|2[0-3])(:[0-5][0-9]){2}$/,
39
+ dateISO: /^\d{4}[\/\-]\d{1,2}[\/\-]\d{1,2}$/,
40
+ // MM/DD/YYYY
41
+ month_day_year: /^(0[1-9]|1[012])[- \/.](0[1-9]|[12][0-9]|3[01])[- \/.]\d{4}$/,
42
+ // DD/MM/YYYY
43
+ day_month_year: /^(0[1-9]|[12][0-9]|3[01])[- \/.](0[1-9]|1[012])[- \/.]\d{4}$/,
44
+
45
+ // #FFF or #FFFFFF
46
+ color: /^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/
47
+ },
48
+ validators: {
49
+ equalTo: function (el, required, parent) {
50
+ var from = document.getElementById(el.getAttribute(this.add_namespace('data-equalto'))).value,
51
+ to = el.value,
52
+ valid = (from === to);
53
+
54
+ return valid;
55
+ }
56
+ }
57
+ },
58
+
59
+ timer: null,
60
+
61
+ init: function (scope, method, options) {
62
+ this.bindings(method, options);
63
+ },
64
+
65
+ events: function (scope) {
66
+ var self = this,
67
+ form = self.S(scope).attr('novalidate', 'novalidate'),
68
+ settings = form.data(this.attr_name(true) + '-init') || {};
69
+
70
+ this.invalid_attr = this.add_namespace('data-invalid');
71
+
72
+ form
73
+ .off('.abide')
74
+ .on('submit.fndtn.abide validate.fndtn.abide', function (e) {
75
+ var is_ajax = /ajax/i.test(self.S(this).attr(self.attr_name()));
76
+ return self.validate(self.S(this).find('input, textarea, select').get(), e, is_ajax);
77
+ })
78
+ .on('reset', function () {
79
+ return self.reset($(this));
80
+ })
81
+ .find('input, textarea, select')
82
+ .off('.abide')
83
+ .on('blur.fndtn.abide change.fndtn.abide', function (e) {
84
+ if (settings.validate_on_blur === true) {
85
+ self.validate([this], e);
86
+ }
87
+ })
88
+ .on('keydown.fndtn.abide', function (e) {
89
+ if (settings.live_validate === true && e.which != 9) {
90
+ clearTimeout(self.timer);
91
+ self.timer = setTimeout(function () {
92
+ self.validate([this], e);
93
+ }.bind(this), settings.timeout);
94
+ }
95
+ });
96
+ },
97
+
98
+ reset: function (form) {
99
+ form.removeAttr(this.invalid_attr);
100
+ $(this.invalid_attr, form).removeAttr(this.invalid_attr);
101
+ $('.' + this.settings.error_class, form).not('small').removeClass(this.settings.error_class);
102
+ },
103
+
104
+ validate: function (els, e, is_ajax) {
105
+ var validations = this.parse_patterns(els),
106
+ validation_count = validations.length,
107
+ form = this.S(els[0]).closest('form'),
108
+ submit_event = /submit/.test(e.type);
109
+
110
+ // Has to count up to make sure the focus gets applied to the top error
111
+ for (var i = 0; i < validation_count; i++) {
112
+ if (!validations[i] && (submit_event || is_ajax)) {
113
+ if (this.settings.focus_on_invalid) els[i].focus();
114
+ form.trigger('invalid').trigger('invalid.fndtn.abide');
115
+ this.S(els[i]).closest('form').attr(this.invalid_attr, '');
116
+ return false;
117
+ }
118
+ }
119
+
120
+ if (submit_event || is_ajax) {
121
+ form.trigger('valid').trigger('valid.fndtn.abide');
122
+ }
123
+
124
+ form.removeAttr(this.invalid_attr);
125
+
126
+ if (is_ajax) return false;
127
+
128
+ return true;
129
+ },
130
+
131
+ parse_patterns: function (els) {
132
+ var i = els.length,
133
+ el_patterns = [];
134
+
135
+ while (i--) {
136
+ el_patterns.push(this.pattern(els[i]));
137
+ }
138
+
139
+ return this.check_validation_and_apply_styles(el_patterns);
140
+ },
141
+
142
+ pattern: function (el) {
143
+ var type = el.getAttribute('type'),
144
+ required = typeof el.getAttribute('required') === 'string';
145
+
146
+ var pattern = el.getAttribute('pattern') || '';
147
+
148
+ if (this.settings.patterns.hasOwnProperty(pattern) && pattern.length > 0) {
149
+ return [el, this.settings.patterns[pattern], required];
150
+ } else if (pattern.length > 0) {
151
+ return [el, new RegExp(pattern), required];
152
+ }
153
+
154
+ if (this.settings.patterns.hasOwnProperty(type)) {
155
+ return [el, this.settings.patterns[type], required];
156
+ }
157
+
158
+ pattern = /.*/;
159
+
160
+ return [el, pattern, required];
161
+ },
162
+
163
+ // TODO: Break this up into smaller methods, getting hard to read.
164
+ check_validation_and_apply_styles: function (el_patterns) {
165
+ var i = el_patterns.length,
166
+ validations = [],
167
+ form = this.S(el_patterns[0][0]).closest('[data-' + this.attr_name(true) + ']'),
168
+ settings = form.data(this.attr_name(true) + '-init') || {};
169
+ while (i--) {
170
+ var el = el_patterns[i][0],
171
+ required = el_patterns[i][2],
172
+ value = el.value.trim(),
173
+ direct_parent = this.S(el).parent(),
174
+ validator = el.getAttribute(this.add_namespace('data-abide-validator')),
175
+ is_radio = el.type === "radio",
176
+ is_checkbox = el.type === "checkbox",
177
+ label = this.S('label[for="' + el.getAttribute('id') + '"]'),
178
+ valid_length = (required) ? (el.value.length > 0) : true,
179
+ el_validations = [];
180
+
181
+ var parent, valid;
182
+
183
+ // support old way to do equalTo validations
184
+ if (el.getAttribute(this.add_namespace('data-equalto'))) {
185
+ validator = "equalTo"
186
+ }
187
+
188
+ if (!direct_parent.is('label')) {
189
+ parent = direct_parent;
190
+ } else {
191
+ parent = direct_parent.parent();
192
+ }
193
+
194
+ if (validator) {
195
+ valid = this.settings.validators[validator].apply(this, [el, required, parent]);
196
+ el_validations.push(valid);
197
+ }
198
+
199
+ if (is_radio && required) {
200
+ el_validations.push(this.valid_radio(el, required));
201
+ } else if (is_checkbox && required) {
202
+ el_validations.push(this.valid_checkbox(el, required));
203
+ } else {
204
+
205
+ if (el_patterns[i][1].test(value) && valid_length ||
206
+ !required && el.value.length < 1 || $(el).attr('disabled')) {
207
+ el_validations.push(true);
208
+ } else {
209
+ el_validations.push(false);
210
+ }
211
+
212
+ el_validations = [el_validations.every(function (valid) {
213
+ return valid;
214
+ })];
215
+
216
+ if (el_validations[0]) {
217
+ this.S(el).removeAttr(this.invalid_attr);
218
+ el.setAttribute('aria-invalid', 'false');
219
+ el.removeAttribute('aria-describedby');
220
+ parent.removeClass(this.settings.error_class);
221
+ if (label.length > 0 && this.settings.error_labels) {
222
+ label.removeClass(this.settings.error_class).removeAttr('role');
223
+ }
224
+ $(el).triggerHandler('valid');
225
+ } else {
226
+ this.S(el).attr(this.invalid_attr, '');
227
+ el.setAttribute('aria-invalid', 'true');
228
+
229
+ // Try to find the error associated with the input
230
+ var errorElem = parent.find('small.' + this.settings.error_class, 'span.' + this.settings.error_class);
231
+ var errorID = errorElem.length > 0 ? errorElem[0].id : "";
232
+ if (errorID.length > 0) el.setAttribute('aria-describedby', errorID);
233
+
234
+ // el.setAttribute('aria-describedby', $(el).find('.error')[0].id);
235
+ parent.addClass(this.settings.error_class);
236
+ if (label.length > 0 && this.settings.error_labels) {
237
+ label.addClass(this.settings.error_class).attr('role', 'alert');
238
+ }
239
+ $(el).triggerHandler('invalid');
240
+ }
241
+ }
242
+ validations.push(el_validations[0]);
243
+ }
244
+ validations = [validations.every(function (valid) {
245
+ return valid;
246
+ })];
247
+ return validations;
248
+ },
249
+
250
+ valid_checkbox: function (el, required) {
251
+ var el = this.S(el),
252
+ valid = (el.is(':checked') || !required);
253
+
254
+ if (valid) {
255
+ el.removeAttr(this.invalid_attr).parent().removeClass(this.settings.error_class);
256
+ } else {
257
+ el.attr(this.invalid_attr, '').parent().addClass(this.settings.error_class);
258
+ }
259
+
260
+ return valid;
261
+ },
262
+
263
+ valid_radio: function (el, required) {
264
+ var name = el.getAttribute('name'),
265
+ group = this.S(el).closest('[data-' + this.attr_name(true) + ']').find("[name='" + name + "']"),
266
+ count = group.length,
267
+ valid = false;
268
+
269
+ // Has to count up to make sure the focus gets applied to the top error
270
+ for (var i = 0; i < count; i++) {
271
+ if (group[i].checked) valid = true;
272
+ }
273
+
274
+ // Has to count up to make sure the focus gets applied to the top error
275
+ for (var i = 0; i < count; i++) {
276
+ if (valid) {
277
+ this.S(group[i]).removeAttr(this.invalid_attr).parent().removeClass(this.settings.error_class);
278
+ } else {
279
+ this.S(group[i]).attr(this.invalid_attr, '').parent().addClass(this.settings.error_class);
280
+ }
281
+ }
282
+
283
+ return valid;
284
+ },
285
+
286
+ valid_equal: function (el, required, parent) {
287
+ var from = document.getElementById(el.getAttribute(this.add_namespace('data-equalto'))).value,
288
+ to = el.value,
289
+ valid = (from === to);
290
+
291
+ if (valid) {
292
+ this.S(el).removeAttr(this.invalid_attr);
293
+ parent.removeClass(this.settings.error_class);
294
+ if (label.length > 0 && settings.error_labels) label.removeClass(this.settings.error_class);
295
+ } else {
296
+ this.S(el).attr(this.invalid_attr, '');
297
+ parent.addClass(this.settings.error_class);
298
+ if (label.length > 0 && settings.error_labels) label.addClass(this.settings.error_class);
299
+ }
300
+
301
+ return valid;
302
+ },
303
+
304
+ valid_oneof: function (el, required, parent, doNotValidateOthers) {
305
+ var el = this.S(el),
306
+ others = this.S('[' + this.add_namespace('data-oneof') + ']'),
307
+ valid = others.filter(':checked').length > 0;
308
+
309
+ if (valid) {
310
+ el.removeAttr(this.invalid_attr).parent().removeClass(this.settings.error_class);
311
+ } else {
312
+ el.attr(this.invalid_attr, '').parent().addClass(this.settings.error_class);
313
+ }
314
+
315
+ if (!doNotValidateOthers) {
316
+ var _this = this;
317
+ others.each(function () {
318
+ _this.valid_oneof.call(_this, this, null, null, true);
319
+ });
320
+ }
321
+
322
+ return valid;
323
+ }
324
+ };
325
+ }(jQuery, window, window.document));