foundation_front_end 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +64 -0
- data/Rakefile +1 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/foundation_front_end.gemspec +32 -0
- data/lib/foundation_front_end.rb +21 -0
- data/lib/foundation_front_end/version.rb +3 -0
- data/vendor/assets/javascripts/foundation.min.js +6376 -0
- data/vendor/assets/javascripts/foundation/foundation.abide.js +408 -0
- data/vendor/assets/javascripts/foundation/foundation.accordion.js +88 -0
- data/vendor/assets/javascripts/foundation/foundation.alert.js +43 -0
- data/vendor/assets/javascripts/foundation/foundation.clearing.js +586 -0
- data/vendor/assets/javascripts/foundation/foundation.dropdown.js +463 -0
- data/vendor/assets/javascripts/foundation/foundation.equalizer.js +104 -0
- data/vendor/assets/javascripts/foundation/foundation.interchange.js +359 -0
- data/vendor/assets/javascripts/foundation/foundation.joyride.js +932 -0
- data/vendor/assets/javascripts/foundation/foundation.js +725 -0
- data/vendor/assets/javascripts/foundation/foundation.magellan.js +215 -0
- data/vendor/assets/javascripts/foundation/foundation.offcanvas.js +152 -0
- data/vendor/assets/javascripts/foundation/foundation.orbit.js +476 -0
- data/vendor/assets/javascripts/foundation/foundation.reveal.js +498 -0
- data/vendor/assets/javascripts/foundation/foundation.slider.js +281 -0
- data/vendor/assets/javascripts/foundation/foundation.tab.js +249 -0
- data/vendor/assets/javascripts/foundation/foundation.tooltip.js +339 -0
- data/vendor/assets/javascripts/foundation/foundation.topbar.js +458 -0
- data/vendor/assets/javascripts/vendor/fastclick.js +8 -0
- data/vendor/assets/javascripts/vendor/jquery.cookie.js +8 -0
- data/vendor/assets/javascripts/vendor/jquery.js +27 -0
- data/vendor/assets/javascripts/vendor/modernizr.js +8 -0
- data/vendor/assets/javascripts/vendor/placeholder.js +2 -0
- data/vendor/assets/stylesheets/foundation.css +6324 -0
- data/vendor/assets/stylesheets/foundation.min.css +1 -0
- data/vendor/assets/stylesheets/normalize.css +424 -0
- metadata +110 -0
@@ -0,0 +1,408 @@
|
|
1
|
+
;(function ($, window, document, undefined) {
|
2
|
+
'use strict';
|
3
|
+
|
4
|
+
Foundation.libs.abide = {
|
5
|
+
name : 'abide',
|
6
|
+
|
7
|
+
version : '5.5.2',
|
8
|
+
|
9
|
+
settings : {
|
10
|
+
live_validate : true,
|
11
|
+
validate_on_blur : true,
|
12
|
+
// validate_on: 'tab', // tab (when user tabs between fields), change (input changes), manual (call custom events)
|
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
|
+
// http://blogs.lse.ac.uk/lti/2008/04/23/a-regular-expression-to-match-any-url/
|
31
|
+
url: /^(https?|ftp|file|ssh):\/\/([-;:&=\+\$,\w]+@{1})?([-A-Za-z0-9\.]+)+:?(\d+)?((\/[-\+~%\/\.\w]+)?\??([-\+=&;%@\.\w]+)?#?([\w]+)?)?/,
|
32
|
+
// abc.de
|
33
|
+
domain : /^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,8}$/,
|
34
|
+
|
35
|
+
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))$/,
|
36
|
+
// YYYY-MM-DD
|
37
|
+
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))$/,
|
38
|
+
// HH:MM:SS
|
39
|
+
time : /^(0[0-9]|1[0-9]|2[0-3])(:[0-5][0-9]){2}$/,
|
40
|
+
dateISO : /^\d{4}[\/\-]\d{1,2}[\/\-]\d{1,2}$/,
|
41
|
+
// MM/DD/YYYY
|
42
|
+
month_day_year : /^(0[1-9]|1[012])[- \/.](0[1-9]|[12][0-9]|3[01])[- \/.]\d{4}$/,
|
43
|
+
// DD/MM/YYYY
|
44
|
+
day_month_year : /^(0[1-9]|[12][0-9]|3[01])[- \/.](0[1-9]|1[012])[- \/.]\d{4}$/,
|
45
|
+
|
46
|
+
// #FFF or #FFFFFF
|
47
|
+
color : /^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/
|
48
|
+
},
|
49
|
+
validators : {
|
50
|
+
equalTo : function (el, required, parent) {
|
51
|
+
var from = document.getElementById(el.getAttribute(this.add_namespace('data-equalto'))).value,
|
52
|
+
to = el.value,
|
53
|
+
valid = (from === to);
|
54
|
+
|
55
|
+
return valid;
|
56
|
+
}
|
57
|
+
}
|
58
|
+
},
|
59
|
+
|
60
|
+
timer : null,
|
61
|
+
|
62
|
+
init : function (scope, method, options) {
|
63
|
+
this.bindings(method, options);
|
64
|
+
},
|
65
|
+
|
66
|
+
events : function (scope) {
|
67
|
+
var self = this,
|
68
|
+
form = self.S(scope).attr('novalidate', 'novalidate'),
|
69
|
+
settings = form.data(this.attr_name(true) + '-init') || {};
|
70
|
+
|
71
|
+
this.invalid_attr = this.add_namespace('data-invalid');
|
72
|
+
|
73
|
+
function validate(originalSelf, e) {
|
74
|
+
clearTimeout(self.timer);
|
75
|
+
self.timer = setTimeout(function () {
|
76
|
+
self.validate([originalSelf], e);
|
77
|
+
}.bind(originalSelf), settings.timeout);
|
78
|
+
}
|
79
|
+
|
80
|
+
|
81
|
+
form
|
82
|
+
.off('.abide')
|
83
|
+
.on('submit.fndtn.abide', function (e) {
|
84
|
+
var is_ajax = /ajax/i.test(self.S(this).attr(self.attr_name()));
|
85
|
+
return self.validate(self.S(this).find('input, textarea, select').not(":hidden, [data-abide-ignore]").get(), e, is_ajax);
|
86
|
+
})
|
87
|
+
.on('validate.fndtn.abide', function (e) {
|
88
|
+
if (settings.validate_on === 'manual') {
|
89
|
+
self.validate([e.target], e);
|
90
|
+
}
|
91
|
+
})
|
92
|
+
.on('reset', function (e) {
|
93
|
+
return self.reset($(this), e);
|
94
|
+
})
|
95
|
+
.find('input, textarea, select').not(":hidden, [data-abide-ignore]")
|
96
|
+
.off('.abide')
|
97
|
+
.on('blur.fndtn.abide change.fndtn.abide', function (e) {
|
98
|
+
// old settings fallback
|
99
|
+
// will be deprecated with F6 release
|
100
|
+
if (settings.validate_on_blur && settings.validate_on_blur === true) {
|
101
|
+
validate(this, e);
|
102
|
+
}
|
103
|
+
// new settings combining validate options into one setting
|
104
|
+
if (settings.validate_on === 'change') {
|
105
|
+
validate(this, e);
|
106
|
+
}
|
107
|
+
})
|
108
|
+
.on('keydown.fndtn.abide', function (e) {
|
109
|
+
// old settings fallback
|
110
|
+
// will be deprecated with F6 release
|
111
|
+
if (settings.live_validate && settings.live_validate === true && e.which != 9) {
|
112
|
+
validate(this, e);
|
113
|
+
}
|
114
|
+
// new settings combining validate options into one setting
|
115
|
+
if (settings.validate_on === 'tab' && e.which === 9) {
|
116
|
+
validate(this, e);
|
117
|
+
}
|
118
|
+
else if (settings.validate_on === 'change') {
|
119
|
+
validate(this, e);
|
120
|
+
}
|
121
|
+
})
|
122
|
+
.on('focus', function (e) {
|
123
|
+
if (navigator.userAgent.match(/iPad|iPhone|Android|BlackBerry|Windows Phone|webOS/i)) {
|
124
|
+
$('html, body').animate({
|
125
|
+
scrollTop: $(e.target).offset().top
|
126
|
+
}, 100);
|
127
|
+
}
|
128
|
+
});
|
129
|
+
},
|
130
|
+
|
131
|
+
reset : function (form, e) {
|
132
|
+
var self = this;
|
133
|
+
form.removeAttr(self.invalid_attr);
|
134
|
+
|
135
|
+
$('[' + self.invalid_attr + ']', form).removeAttr(self.invalid_attr);
|
136
|
+
$('.' + self.settings.error_class, form).not('small').removeClass(self.settings.error_class);
|
137
|
+
$(':input', form).not(':button, :submit, :reset, :hidden, [data-abide-ignore]').val('').removeAttr(self.invalid_attr);
|
138
|
+
},
|
139
|
+
|
140
|
+
validate : function (els, e, is_ajax) {
|
141
|
+
var validations = this.parse_patterns(els),
|
142
|
+
validation_count = validations.length,
|
143
|
+
form = this.S(els[0]).closest('form'),
|
144
|
+
submit_event = /submit/.test(e.type);
|
145
|
+
|
146
|
+
// Has to count up to make sure the focus gets applied to the top error
|
147
|
+
for (var i = 0; i < validation_count; i++) {
|
148
|
+
if (!validations[i] && (submit_event || is_ajax)) {
|
149
|
+
if (this.settings.focus_on_invalid) {
|
150
|
+
els[i].focus();
|
151
|
+
}
|
152
|
+
form.trigger('invalid.fndtn.abide');
|
153
|
+
this.S(els[i]).closest('form').attr(this.invalid_attr, '');
|
154
|
+
return false;
|
155
|
+
}
|
156
|
+
}
|
157
|
+
|
158
|
+
if (submit_event || is_ajax) {
|
159
|
+
form.trigger('valid.fndtn.abide');
|
160
|
+
}
|
161
|
+
|
162
|
+
form.removeAttr(this.invalid_attr);
|
163
|
+
|
164
|
+
if (is_ajax) {
|
165
|
+
return false;
|
166
|
+
}
|
167
|
+
|
168
|
+
return true;
|
169
|
+
},
|
170
|
+
|
171
|
+
parse_patterns : function (els) {
|
172
|
+
var i = els.length,
|
173
|
+
el_patterns = [];
|
174
|
+
|
175
|
+
while (i--) {
|
176
|
+
el_patterns.push(this.pattern(els[i]));
|
177
|
+
}
|
178
|
+
|
179
|
+
return this.check_validation_and_apply_styles(el_patterns);
|
180
|
+
},
|
181
|
+
|
182
|
+
pattern : function (el) {
|
183
|
+
var type = el.getAttribute('type'),
|
184
|
+
required = typeof el.getAttribute('required') === 'string';
|
185
|
+
|
186
|
+
var pattern = el.getAttribute('pattern') || '';
|
187
|
+
|
188
|
+
if (this.settings.patterns.hasOwnProperty(pattern) && pattern.length > 0) {
|
189
|
+
return [el, this.settings.patterns[pattern], required];
|
190
|
+
} else if (pattern.length > 0) {
|
191
|
+
return [el, new RegExp(pattern), required];
|
192
|
+
}
|
193
|
+
|
194
|
+
if (this.settings.patterns.hasOwnProperty(type)) {
|
195
|
+
return [el, this.settings.patterns[type], required];
|
196
|
+
}
|
197
|
+
|
198
|
+
pattern = /.*/;
|
199
|
+
|
200
|
+
return [el, pattern, required];
|
201
|
+
},
|
202
|
+
|
203
|
+
// TODO: Break this up into smaller methods, getting hard to read.
|
204
|
+
check_validation_and_apply_styles : function (el_patterns) {
|
205
|
+
var i = el_patterns.length,
|
206
|
+
validations = [],
|
207
|
+
form = this.S(el_patterns[0][0]).closest('[data-' + this.attr_name(true) + ']'),
|
208
|
+
settings = form.data(this.attr_name(true) + '-init') || {};
|
209
|
+
while (i--) {
|
210
|
+
var el = el_patterns[i][0],
|
211
|
+
required = el_patterns[i][2],
|
212
|
+
value = el.value.trim(),
|
213
|
+
direct_parent = this.S(el).parent(),
|
214
|
+
validator = el.getAttribute(this.add_namespace('data-abide-validator')),
|
215
|
+
is_radio = el.type === 'radio',
|
216
|
+
is_checkbox = el.type === 'checkbox',
|
217
|
+
label = this.S('label[for="' + el.getAttribute('id') + '"]'),
|
218
|
+
valid_length = (required) ? (el.value.length > 0) : true,
|
219
|
+
el_validations = [];
|
220
|
+
|
221
|
+
var parent, valid;
|
222
|
+
|
223
|
+
// support old way to do equalTo validations
|
224
|
+
if (el.getAttribute(this.add_namespace('data-equalto'))) { validator = 'equalTo' }
|
225
|
+
|
226
|
+
if (!direct_parent.is('label')) {
|
227
|
+
parent = direct_parent;
|
228
|
+
} else {
|
229
|
+
parent = direct_parent.parent();
|
230
|
+
}
|
231
|
+
|
232
|
+
if (is_radio && required) {
|
233
|
+
el_validations.push(this.valid_radio(el, required));
|
234
|
+
} else if (is_checkbox && required) {
|
235
|
+
el_validations.push(this.valid_checkbox(el, required));
|
236
|
+
|
237
|
+
} else if (validator) {
|
238
|
+
// Validate using each of the specified (space-delimited) validators.
|
239
|
+
var validators = validator.split(' ');
|
240
|
+
var last_valid = true, all_valid = true;
|
241
|
+
for (var iv = 0; iv < validators.length; iv++) {
|
242
|
+
valid = this.settings.validators[validators[iv]].apply(this, [el, required, parent])
|
243
|
+
el_validations.push(valid);
|
244
|
+
all_valid = valid && last_valid;
|
245
|
+
last_valid = valid;
|
246
|
+
}
|
247
|
+
if (all_valid) {
|
248
|
+
this.S(el).removeAttr(this.invalid_attr);
|
249
|
+
parent.removeClass('error');
|
250
|
+
if (label.length > 0 && this.settings.error_labels) {
|
251
|
+
label.removeClass(this.settings.error_class).removeAttr('role');
|
252
|
+
}
|
253
|
+
$(el).triggerHandler('valid');
|
254
|
+
} else {
|
255
|
+
this.S(el).attr(this.invalid_attr, '');
|
256
|
+
parent.addClass('error');
|
257
|
+
if (label.length > 0 && this.settings.error_labels) {
|
258
|
+
label.addClass(this.settings.error_class).attr('role', 'alert');
|
259
|
+
}
|
260
|
+
$(el).triggerHandler('invalid');
|
261
|
+
}
|
262
|
+
} else {
|
263
|
+
|
264
|
+
if (el_patterns[i][1].test(value) && valid_length ||
|
265
|
+
!required && el.value.length < 1 || $(el).attr('disabled')) {
|
266
|
+
el_validations.push(true);
|
267
|
+
} else {
|
268
|
+
el_validations.push(false);
|
269
|
+
}
|
270
|
+
|
271
|
+
el_validations = [el_validations.every(function (valid) {return valid;})];
|
272
|
+
if (el_validations[0]) {
|
273
|
+
this.S(el).removeAttr(this.invalid_attr);
|
274
|
+
el.setAttribute('aria-invalid', 'false');
|
275
|
+
el.removeAttribute('aria-describedby');
|
276
|
+
parent.removeClass(this.settings.error_class);
|
277
|
+
if (label.length > 0 && this.settings.error_labels) {
|
278
|
+
label.removeClass(this.settings.error_class).removeAttr('role');
|
279
|
+
}
|
280
|
+
$(el).triggerHandler('valid');
|
281
|
+
} else {
|
282
|
+
this.S(el).attr(this.invalid_attr, '');
|
283
|
+
el.setAttribute('aria-invalid', 'true');
|
284
|
+
|
285
|
+
// Try to find the error associated with the input
|
286
|
+
var errorElem = parent.find('small.' + this.settings.error_class, 'span.' + this.settings.error_class);
|
287
|
+
var errorID = errorElem.length > 0 ? errorElem[0].id : '';
|
288
|
+
if (errorID.length > 0) {
|
289
|
+
el.setAttribute('aria-describedby', errorID);
|
290
|
+
}
|
291
|
+
|
292
|
+
// el.setAttribute('aria-describedby', $(el).find('.error')[0].id);
|
293
|
+
parent.addClass(this.settings.error_class);
|
294
|
+
if (label.length > 0 && this.settings.error_labels) {
|
295
|
+
label.addClass(this.settings.error_class).attr('role', 'alert');
|
296
|
+
}
|
297
|
+
$(el).triggerHandler('invalid');
|
298
|
+
}
|
299
|
+
}
|
300
|
+
validations = validations.concat(el_validations);
|
301
|
+
}
|
302
|
+
return validations;
|
303
|
+
},
|
304
|
+
|
305
|
+
valid_checkbox : function (el, required) {
|
306
|
+
var el = this.S(el),
|
307
|
+
valid = (el.is(':checked') || !required || el.get(0).getAttribute('disabled'));
|
308
|
+
|
309
|
+
if (valid) {
|
310
|
+
el.removeAttr(this.invalid_attr).parent().removeClass(this.settings.error_class);
|
311
|
+
$(el).triggerHandler('valid');
|
312
|
+
} else {
|
313
|
+
el.attr(this.invalid_attr, '').parent().addClass(this.settings.error_class);
|
314
|
+
$(el).triggerHandler('invalid');
|
315
|
+
}
|
316
|
+
|
317
|
+
return valid;
|
318
|
+
},
|
319
|
+
|
320
|
+
valid_radio : function (el, required) {
|
321
|
+
var name = el.getAttribute('name'),
|
322
|
+
group = this.S(el).closest('[data-' + this.attr_name(true) + ']').find("[name='" + name + "']"),
|
323
|
+
count = group.length,
|
324
|
+
valid = false,
|
325
|
+
disabled = false;
|
326
|
+
|
327
|
+
// Has to count up to make sure the focus gets applied to the top error
|
328
|
+
for (var i=0; i < count; i++) {
|
329
|
+
if( group[i].getAttribute('disabled') ){
|
330
|
+
disabled=true;
|
331
|
+
valid=true;
|
332
|
+
} else {
|
333
|
+
if (group[i].checked){
|
334
|
+
valid = true;
|
335
|
+
} else {
|
336
|
+
if( disabled ){
|
337
|
+
valid = false;
|
338
|
+
}
|
339
|
+
}
|
340
|
+
}
|
341
|
+
}
|
342
|
+
|
343
|
+
// Has to count up to make sure the focus gets applied to the top error
|
344
|
+
for (var i = 0; i < count; i++) {
|
345
|
+
if (valid) {
|
346
|
+
this.S(group[i]).removeAttr(this.invalid_attr).parent().removeClass(this.settings.error_class);
|
347
|
+
$(group[i]).triggerHandler('valid');
|
348
|
+
} else {
|
349
|
+
this.S(group[i]).attr(this.invalid_attr, '').parent().addClass(this.settings.error_class);
|
350
|
+
$(group[i]).triggerHandler('invalid');
|
351
|
+
}
|
352
|
+
}
|
353
|
+
|
354
|
+
return valid;
|
355
|
+
},
|
356
|
+
|
357
|
+
valid_equal : function (el, required, parent) {
|
358
|
+
var from = document.getElementById(el.getAttribute(this.add_namespace('data-equalto'))).value,
|
359
|
+
to = el.value,
|
360
|
+
valid = (from === to);
|
361
|
+
|
362
|
+
if (valid) {
|
363
|
+
this.S(el).removeAttr(this.invalid_attr);
|
364
|
+
parent.removeClass(this.settings.error_class);
|
365
|
+
if (label.length > 0 && settings.error_labels) {
|
366
|
+
label.removeClass(this.settings.error_class);
|
367
|
+
}
|
368
|
+
} else {
|
369
|
+
this.S(el).attr(this.invalid_attr, '');
|
370
|
+
parent.addClass(this.settings.error_class);
|
371
|
+
if (label.length > 0 && settings.error_labels) {
|
372
|
+
label.addClass(this.settings.error_class);
|
373
|
+
}
|
374
|
+
}
|
375
|
+
|
376
|
+
return valid;
|
377
|
+
},
|
378
|
+
|
379
|
+
valid_oneof : function (el, required, parent, doNotValidateOthers) {
|
380
|
+
var el = this.S(el),
|
381
|
+
others = this.S('[' + this.add_namespace('data-oneof') + ']'),
|
382
|
+
valid = others.filter(':checked').length > 0;
|
383
|
+
|
384
|
+
if (valid) {
|
385
|
+
el.removeAttr(this.invalid_attr).parent().removeClass(this.settings.error_class);
|
386
|
+
} else {
|
387
|
+
el.attr(this.invalid_attr, '').parent().addClass(this.settings.error_class);
|
388
|
+
}
|
389
|
+
|
390
|
+
if (!doNotValidateOthers) {
|
391
|
+
var _this = this;
|
392
|
+
others.each(function () {
|
393
|
+
_this.valid_oneof.call(_this, this, null, null, true);
|
394
|
+
});
|
395
|
+
}
|
396
|
+
|
397
|
+
return valid;
|
398
|
+
},
|
399
|
+
|
400
|
+
reflow : function(scope, options) {
|
401
|
+
var self = this,
|
402
|
+
form = self.S('[' + this.attr_name() + ']').attr('novalidate', 'novalidate');
|
403
|
+
self.S(form).each(function (idx, el) {
|
404
|
+
self.events(el);
|
405
|
+
});
|
406
|
+
}
|
407
|
+
};
|
408
|
+
}(jQuery, window, window.document));
|
@@ -0,0 +1,88 @@
|
|
1
|
+
;(function ($, window, document, undefined) {
|
2
|
+
'use strict';
|
3
|
+
|
4
|
+
Foundation.libs.accordion = {
|
5
|
+
name : 'accordion',
|
6
|
+
|
7
|
+
version : '5.5.2',
|
8
|
+
|
9
|
+
settings : {
|
10
|
+
content_class : 'content',
|
11
|
+
active_class : 'active',
|
12
|
+
multi_expand : false,
|
13
|
+
toggleable : true,
|
14
|
+
callback : function () {}
|
15
|
+
},
|
16
|
+
|
17
|
+
init : function (scope, method, options) {
|
18
|
+
this.bindings(method, options);
|
19
|
+
},
|
20
|
+
|
21
|
+
events : function (instance) {
|
22
|
+
var self = this;
|
23
|
+
var S = this.S;
|
24
|
+
self.create(this.S(instance));
|
25
|
+
|
26
|
+
S(this.scope)
|
27
|
+
.off('.fndtn.accordion')
|
28
|
+
.on('click.fndtn.accordion', '[' + this.attr_name() + '] > dd > a, [' + this.attr_name() + '] > li > a', function (e) {
|
29
|
+
var accordion = S(this).closest('[' + self.attr_name() + ']'),
|
30
|
+
groupSelector = self.attr_name() + '=' + accordion.attr(self.attr_name()),
|
31
|
+
settings = accordion.data(self.attr_name(true) + '-init') || self.settings,
|
32
|
+
target = S('#' + this.href.split('#')[1]),
|
33
|
+
aunts = $('> dd, > li', accordion),
|
34
|
+
siblings = aunts.children('.' + settings.content_class),
|
35
|
+
active_content = siblings.filter('.' + settings.active_class);
|
36
|
+
|
37
|
+
e.preventDefault();
|
38
|
+
|
39
|
+
if (accordion.attr(self.attr_name())) {
|
40
|
+
siblings = siblings.add('[' + groupSelector + '] dd > ' + '.' + settings.content_class + ', [' + groupSelector + '] li > ' + '.' + settings.content_class);
|
41
|
+
aunts = aunts.add('[' + groupSelector + '] dd, [' + groupSelector + '] li');
|
42
|
+
}
|
43
|
+
|
44
|
+
if (settings.toggleable && target.is(active_content)) {
|
45
|
+
target.parent('dd, li').toggleClass(settings.active_class, false);
|
46
|
+
target.toggleClass(settings.active_class, false);
|
47
|
+
S(this).attr('aria-expanded', function(i, attr){
|
48
|
+
return attr === 'true' ? 'false' : 'true';
|
49
|
+
});
|
50
|
+
settings.callback(target);
|
51
|
+
target.triggerHandler('toggled', [accordion]);
|
52
|
+
accordion.triggerHandler('toggled', [target]);
|
53
|
+
return;
|
54
|
+
}
|
55
|
+
|
56
|
+
if (!settings.multi_expand) {
|
57
|
+
siblings.removeClass(settings.active_class);
|
58
|
+
aunts.removeClass(settings.active_class);
|
59
|
+
aunts.children('a').attr('aria-expanded','false');
|
60
|
+
}
|
61
|
+
|
62
|
+
target.addClass(settings.active_class).parent().addClass(settings.active_class);
|
63
|
+
settings.callback(target);
|
64
|
+
target.triggerHandler('toggled', [accordion]);
|
65
|
+
accordion.triggerHandler('toggled', [target]);
|
66
|
+
S(this).attr('aria-expanded','true');
|
67
|
+
});
|
68
|
+
},
|
69
|
+
|
70
|
+
create: function($instance) {
|
71
|
+
var self = this,
|
72
|
+
accordion = $instance,
|
73
|
+
aunts = $('> .accordion-navigation', accordion),
|
74
|
+
settings = accordion.data(self.attr_name(true) + '-init') || self.settings;
|
75
|
+
|
76
|
+
aunts.children('a').attr('aria-expanded','false');
|
77
|
+
aunts.has('.' + settings.content_class + '.' + settings.active_class).children('a').attr('aria-expanded','true');
|
78
|
+
|
79
|
+
if (settings.multi_expand) {
|
80
|
+
$instance.attr('aria-multiselectable','true');
|
81
|
+
}
|
82
|
+
},
|
83
|
+
|
84
|
+
off : function () {},
|
85
|
+
|
86
|
+
reflow : function () {}
|
87
|
+
};
|
88
|
+
}(jQuery, window, window.document));
|