Initial upload of legacy repository
This commit is contained in:
66
archive/1/js/foundation/foundation.accordion.js
vendored
Normal file
66
archive/1/js/foundation/foundation.accordion.js
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
;(function ($, window, document, undefined) {
|
||||
'use strict';
|
||||
|
||||
Foundation.libs.accordion = {
|
||||
name : 'accordion',
|
||||
|
||||
version : '5.4.7',
|
||||
|
||||
settings : {
|
||||
content_class: 'content',
|
||||
active_class: 'active',
|
||||
multi_expand: false,
|
||||
toggleable: true,
|
||||
callback : function () {}
|
||||
},
|
||||
|
||||
init : function (scope, method, options) {
|
||||
this.bindings(method, options);
|
||||
},
|
||||
|
||||
events : function () {
|
||||
var self = this;
|
||||
var S = this.S;
|
||||
S(this.scope)
|
||||
.off('.fndtn.accordion')
|
||||
.on('click.fndtn.accordion', '[' + this.attr_name() + '] > dd > a', function (e) {
|
||||
var accordion = S(this).closest('[' + self.attr_name() + ']'),
|
||||
groupSelector = self.attr_name() + '=' + accordion.attr(self.attr_name()),
|
||||
settings = accordion.data(self.attr_name(true) + '-init'),
|
||||
target = S('#' + this.href.split('#')[1]),
|
||||
aunts = $('> dd', accordion),
|
||||
siblings = aunts.children('.'+settings.content_class),
|
||||
active_content = siblings.filter('.' + settings.active_class);
|
||||
e.preventDefault();
|
||||
|
||||
if (accordion.attr(self.attr_name())) {
|
||||
siblings = siblings.add('[' + groupSelector + '] dd > .'+settings.content_class);
|
||||
aunts = aunts.add('[' + groupSelector + '] dd');
|
||||
}
|
||||
|
||||
if (settings.toggleable && target.is(active_content)) {
|
||||
target.parent('dd').toggleClass(settings.active_class, false);
|
||||
target.toggleClass(settings.active_class, false);
|
||||
settings.callback(target);
|
||||
target.triggerHandler('toggled', [accordion]);
|
||||
accordion.triggerHandler('toggled', [target]);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!settings.multi_expand) {
|
||||
siblings.removeClass(settings.active_class);
|
||||
aunts.removeClass(settings.active_class);
|
||||
}
|
||||
|
||||
target.addClass(settings.active_class).parent().addClass(settings.active_class);
|
||||
settings.callback(target);
|
||||
target.triggerHandler('toggled', [accordion]);
|
||||
accordion.triggerHandler('toggled', [target]);
|
||||
});
|
||||
},
|
||||
|
||||
off : function () {},
|
||||
|
||||
reflow : function () {}
|
||||
};
|
||||
}(jQuery, window, window.document));
|
Reference in New Issue
Block a user