diff --git a/dist/jquery.collapsable.js b/dist/jquery.collapsable.js index 8f329d9..a1817d1 100644 --- a/dist/jquery.collapsable.js +++ b/dist/jquery.collapsable.js @@ -6,7 +6,7 @@ * @copyright Copyright (c) 2014-2017 Radek Šerý * @license MIT * - * @version 2.0.5 + * @version 2.0.6 */ ;(function($) { @@ -162,7 +162,7 @@ // max 1 expanded item if (this.opts.accordion) { - defaultExpanded = $items.index($('.' + this.opts.classNames.defaultExpanded)); + defaultExpanded = $items.index( $items.filter('.' + this.opts.classNames.defaultExpanded) ); // max 1, we can return now if (defaultExpanded !== -1) { diff --git a/dist/jquery.collapsable.min.js b/dist/jquery.collapsable.min.js index f832518..2798279 100644 --- a/dist/jquery.collapsable.min.js +++ b/dist/jquery.collapsable.min.js @@ -1,3 +1,3 @@ -/*! jQuery Collapsable 2.0.5 | MIT | Radek Šerý, http://zipper.github.io/jquery.collapsable/ */ +/*! jQuery Collapsable 2.0.6 | MIT | Radek Šerý, http://zipper.github.io/jquery.collapsable/ */ -!function(a){function b(){return"ca-uid-"+l++}function c(b,c){var d=[];this.each(function(){var e=a(this).data("collapsable");if(e){var f=e.parent.uid;-1===d.indexOf(f)&&(d.push(f),e.parent[b](c))}})}function d(){var b=this.opts;(this.$extLinks=a(b.extLinks.selector).filter("a")).length&&this.$extLinks.on("click.collapsable",function(c){b.extLinks.preventDefault&&c.preventDefault();var d=a(a(this).attr("href")).data("collapsable");d&&d.$controlLink.first().trigger(b.event+".collapsable",c)})}function e(){var b=window.location.href,c=b.search(/#/),d=-1,e=-1,f=a(a.map(this.items,function(a){return a.$collapsable.get()}));if(!(-1!==c&&b.length>c+1&&(b=b.substring(c+1),-1!==(e=f.index(a("#"+b)))&&(this.items[e].defaultExpanded=!0,this.opts.accordion)))){if(this.opts.accordion){if(-1!==(d=f.index(a("."+this.opts.classNames.defaultExpanded))))return void(this.items[d].defaultExpanded=!0)}else{var g=this;f.each(function(b){a(this).hasClass(g.opts.classNames.defaultExpanded)&&(d=b,g.items[b].defaultExpanded=!0)})}-1!==e||-1!==d||this.opts.collapsableAll||(this.items[0].defaultExpanded=!0)}}function f(){var b=a.Event("init.collapsable"),c=this.opts,d=this.items,e=c.fx;c.fx&&(c.fx="toggle");for(var f=d.length,g=!c.collapsableAll,h=0;h'),b=e.find("a")),b.addClass("ca-link"),b.attr("aria-controls",d.join(" "))})}function i(b,c,d){var e=this.parent.opts,f=this,g="expanded",h=e.classNames.expanded,i=e.classNames.collapsed;"collapse"===b&&(g="collapsed",h=e.classNames.collapsed,i=e.classNames.expanded);var j=a.Event(g+".collapsable",{customData:d,collapsableEvent:c});return this.isExpanded="expand"===b,this.parent.$extLinks.filter('[href="#'+this.id+'"]')["expand"===b?"addClass":"removeClass"](e.classNames.extLinkActive),this.$controlLink.attr("aria-expanded","expand"===b),this.$box.attr("aria-hidden","expand"!==b),e.fx&&"object"==typeof e.fx?this.$box[e.fx[b]](e.fxDuration,function(){f.$collapsable.trigger(j)}):("toggle"===e.fx&&this.$box["expand"===b?"show":"hide"](),setTimeout(function(){f.$collapsable.trigger(j)},e.fxDuration)),this.$collapsable.removeClass(i).addClass(h),!0}var j={control:".ca-control",box:".ca-box",event:"click",preventDefault:!0,fx:null,fxDuration:0,accordion:!1,collapsableAll:!0,extLinks:{selector:"",preventDefault:!1},classNames:{expanded:"ca-expanded",collapsed:"ca-collapsed",defaultExpanded:"ca-default-expanded",extLinkActive:"ca-ext-active"}},k={init:function(a){return new m(this,a)},expandAll:function(a){c.call(this,"expandAll",a)},collapseAll:function(a){c.call(this,"collapseAll",a)},destroy:function(a){c.call(this,"destroy",a)}},l=0,m=function(c,h){if(0===c.length)return null;this.opts=a.extend(!0,{},a.fn.collapsable.defaults,h),this.items=[];var i=this;return this.uid=b(),this.promiseOpen=!1,d.call(this),g.call(this),c.each(function(){var a=new n(i,this);a.$box.length&&a.$control.length&&i.items.push(a)}),e.call(this),f.call(this),this};m.prototype.getExpanded=function(){for(var a=[],b=this.items.length,c=0;cc+1&&(b=b.substring(c+1),-1!==(e=f.index(a("#"+b)))&&(this.items[e].defaultExpanded=!0,this.opts.accordion)))){if(this.opts.accordion){if(-1!==(d=f.index(f.filter("."+this.opts.classNames.defaultExpanded))))return void(this.items[d].defaultExpanded=!0)}else{var g=this;f.each(function(b){a(this).hasClass(g.opts.classNames.defaultExpanded)&&(d=b,g.items[b].defaultExpanded=!0)})}-1!==e||-1!==d||this.opts.collapsableAll||(this.items[0].defaultExpanded=!0)}}function f(){var b=a.Event("init.collapsable"),c=this.opts,d=this.items,e=c.fx;c.fx&&(c.fx="toggle");for(var f=d.length,g=!c.collapsableAll,h=0;h'),b=e.find("a")),b.addClass("ca-link"),b.attr("aria-controls",d.join(" "))})}function i(b,c,d){var e=this.parent.opts,f=this,g="expanded",h=e.classNames.expanded,i=e.classNames.collapsed;"collapse"===b&&(g="collapsed",h=e.classNames.collapsed,i=e.classNames.expanded);var j=a.Event(g+".collapsable",{customData:d,collapsableEvent:c});return this.isExpanded="expand"===b,this.parent.$extLinks.filter('[href="#'+this.id+'"]')["expand"===b?"addClass":"removeClass"](e.classNames.extLinkActive),this.$controlLink.attr("aria-expanded","expand"===b),this.$box.attr("aria-hidden","expand"!==b),e.fx&&"object"==typeof e.fx?this.$box[e.fx[b]](e.fxDuration,function(){f.$collapsable.trigger(j)}):("toggle"===e.fx&&this.$box["expand"===b?"show":"hide"](),setTimeout(function(){f.$collapsable.trigger(j)},e.fxDuration)),this.$collapsable.removeClass(i).addClass(h),!0}var j={control:".ca-control",box:".ca-box",event:"click",preventDefault:!0,fx:null,fxDuration:0,accordion:!1,collapsableAll:!0,extLinks:{selector:"",preventDefault:!1},classNames:{expanded:"ca-expanded",collapsed:"ca-collapsed",defaultExpanded:"ca-default-expanded",extLinkActive:"ca-ext-active"}},k={init:function(a){return new m(this,a)},expandAll:function(a){c.call(this,"expandAll",a)},collapseAll:function(a){c.call(this,"collapseAll",a)},destroy:function(a){c.call(this,"destroy",a)}},l=0,m=function(c,h){if(0===c.length)return null;this.opts=a.extend(!0,{},a.fn.collapsable.defaults,h),this.items=[];var i=this;return this.uid=b(),this.promiseOpen=!1,d.call(this),g.call(this),c.each(function(){var a=new n(i,this);a.$box.length&&a.$control.length&&i.items.push(a)}),e.call(this),f.call(this),this};m.prototype.getExpanded=function(){for(var a=[],b=this.items.length,c=0;c