diff --git a/dist/v-accordion.css b/dist/v-accordion.css index 64be9c8..12bf30e 100644 --- a/dist/v-accordion.css +++ b/dist/v-accordion.css @@ -1,6 +1,6 @@ /** * vAccordion - AngularJS multi-level accordion component - * @version v1.5.1 + * @version v1.5.2 * @link http://lukaszwatroba.github.io/v-accordion * @author Łukasz Wątroba * @license MIT License, http://www.opensource.org/licenses/MIT diff --git a/dist/v-accordion.js b/dist/v-accordion.js index 11a4dc3..9dfbf9a 100644 --- a/dist/v-accordion.js +++ b/dist/v-accordion.js @@ -1,6 +1,6 @@ /** * vAccordion - AngularJS multi-level accordion component - * @version v1.5.1 + * @version v1.5.2 * @link http://lukaszwatroba.github.io/v-accordion * @author Łukasz Wątroba * @license MIT License, http://www.opensource.org/licenses/MIT @@ -90,14 +90,13 @@ function vAccordionDirective ($timeout) { controller: vAccordionController, scope: { control: '=?', - allowMultiple: '=?multiple', expandCb: '&?onexpand', collapseCb: '&?oncollapse', id: '@?' }, link: { pre: function (scope, iElement, iAttrs) { - scope.allowMultiple = (angular.isDefined(iAttrs.multiple) && iAttrs.multiple === ''); + scope.allowMultiple = (angular.isDefined(iAttrs.multiple) && (iAttrs.multiple === '' || iAttrs.multiple === 'true')); }, post: function (scope, iElement, iAttrs, ctrl, transclude) { transclude(scope.$parent.$new(), function (clone, transclusionScope) { diff --git a/dist/v-accordion.min.css b/dist/v-accordion.min.css index f62b4b2..d53a2d2 100644 --- a/dist/v-accordion.min.css +++ b/dist/v-accordion.min.css @@ -1,6 +1,6 @@ /** * vAccordion - AngularJS multi-level accordion component - * @version v1.5.1 + * @version v1.5.2 * @link http://lukaszwatroba.github.io/v-accordion * @author Łukasz Wątroba * @license MIT License, http://www.opensource.org/licenses/MIT diff --git a/dist/v-accordion.min.js b/dist/v-accordion.min.js index 9aefce7..7a8ef5c 100644 --- a/dist/v-accordion.min.js +++ b/dist/v-accordion.min.js @@ -1,9 +1,9 @@ /** * vAccordion - AngularJS multi-level accordion component - * @version v1.5.1 + * @version v1.5.2 * @link http://lukaszwatroba.github.io/v-accordion * @author Łukasz Wątroba * @license MIT License, http://www.opensource.org/licenses/MIT */ -!function(e){"use strict";function n(n){return{restrict:"E",transclude:!0,controller:i,scope:{control:"=?",allowMultiple:"=?multiple",expandCb:"&?onexpand",collapseCb:"&?oncollapse",id:"@?"},link:{pre:function(n,i,t){n.allowMultiple=e.isDefined(t.multiple)&&""===t.multiple},post:function(i,t,a,o,d){function c(){var n=["toggle","expand","collapse","expandAll","collapseAll","hasExpandedPane"];e.forEach(n,function(e){if(i.control[e])throw new Error("The `"+e+"` method can not be overwritten")})}if(d(i.$parent.$new(),function(e,n){n.$accordion=i.internalControl,i.id&&(n.$accordion.id=i.id),t.append(e)}),a.$set("role","tablist"),i.allowMultiple&&a.$set("aria-multiselectable","true"),e.isDefined(i.control)){c();var r=e.extend({},i.internalControl,i.control);i.control=i.internalControl=r}else i.control=i.internalControl;n(function(){var n=e.isDefined(o.getAccordionId())?o.getAccordionId()+":onReady":"vAccordion:onReady";i.$emit(n)},0)}}}}function i(n){var i=this,t=!1;n.panes=[],n.expandCb=e.isFunction(n.expandCb)?n.expandCb:e.noop,n.collapseCb=e.isFunction(n.collapseCb)?n.collapseCb:e.noop,i.hasExpandedPane=function(){for(var e=!1,i=0,t=n.panes.length;t>i;i++){var a=n.panes[i];if(a.isExpanded){e=!0;break}}return e},i.getPaneByIndex=function(i){var t;return e.forEach(n.panes,function(n){n.$parent&&e.isDefined(n.$parent.$index)&&n.$parent.$index===i&&(t=n)}),t?t:n.panes[i]},i.getPaneIndex=function(i){var t;return e.forEach(n.panes,function(n){n.$parent&&e.isDefined(n.$parent.$index)&&n===i&&(t=n.$parent.$index)}),e.isDefined(t)?t:n.panes.indexOf(i)},i.getPaneById=function(i){var t;return e.forEach(n.panes,function(e){e.id&&e.id===i&&(t=e)}),t},i.getPaneId=function(e){return e.id},i.getAccordionId=function(){return n.id},i.disable=function(){t=!0},i.enable=function(){t=!1},i.addPane=function(e){if(!n.allowMultiple&&i.hasExpandedPane()&&e.isExpanded)throw new Error("The `multiple` attribute can't be found");n.panes.push(e),e.isExpanded&&n.expandCb({index:i.getPaneIndex(e),id:e.id,pane:e})},i.focusNext=function(){for(var e=n.panes.length,i=0;e>i;i++){var t=n.panes[i];if(t.isFocused){var a=i+1;a>n.panes.length-1&&(a=0);var o=n.panes[a];o.paneElement.find("v-pane-header")[0].focus();break}}},i.focusPrevious=function(){for(var e=n.panes.length,i=0;e>i;i++){var t=n.panes[i];if(t.isFocused){var a=i-1;0>a&&(a=n.panes.length-1);var o=n.panes[a];o.paneElement.find("v-pane-header")[0].focus();break}}},i.toggle=function(e){!t&&e&&(n.allowMultiple||i.collapseAll(e),e.isExpanded=!e.isExpanded,e.isExpanded?n.expandCb({index:i.getPaneIndex(e),id:e.id,pane:e}):n.collapseCb({index:i.getPaneIndex(e),id:e.id,pane:e}))},i.expand=function(e){!t&&e&&(n.allowMultiple||i.collapseAll(e),e.isExpanded||(e.isExpanded=!0,n.expandCb({index:i.getPaneIndex(e),id:e.id,pane:e})))},i.collapse=function(e){!t&&e&&e.isExpanded&&(e.isExpanded=!1,n.collapseCb({index:i.getPaneIndex(e),id:e.id,pane:e}))},i.expandAll=function(){if(!t){if(!n.allowMultiple)throw new Error("The `multiple` attribute can't be found");e.forEach(n.panes,function(e){i.expand(e)})}},i.collapseAll=function(a){t||e.forEach(n.panes,function(e){e!==a&&i.collapse(e)})},n.internalControl={toggle:function(n){e.isString(n)?i.toggle(i.getPaneById(n)):i.toggle(i.getPaneByIndex(n))},expand:function(n){e.isString(n)?i.expand(i.getPaneById(n)):i.expand(i.getPaneByIndex(n))},collapse:function(n){e.isString(n)?i.collapse(i.getPaneById(n)):i.collapse(i.getPaneByIndex(n))},expandAll:i.expandAll,collapseAll:i.collapseAll,hasExpandedPane:i.hasExpandedPane}}function t(n,i,t){return{restrict:"E",require:"^vAccordion",transclude:!0,controller:a,scope:{isExpanded:"=?expanded",isDisabled:"=?ngDisabled",id:"@?"},link:function(n,a,o,d,c){function r(i){i=e.isDefined(v)?v+":"+i:"vAccordion:"+i,n.$emit(i)}function l(){d.disable(),u.attr({"aria-selected":"true",tabindex:"0"}),r("onExpand"),i.addClass(a,p.expanded).then(function(){d.enable(),r("onExpandAnimationEnd")})}function s(){d.disable(),u.attr({"aria-selected":"false",tabindex:"-1"}),r("onCollapse"),i.removeClass(a,p.expanded).then(function(){d.enable(),r("onCollapseAnimationEnd")})}c(n.$parent.$new(),function(e,i){i.$pane=n.internalControl,n.id&&(i.$pane.id=n.id),a.append(e)}),e.isDefined(n.isExpanded)||(n.isExpanded=e.isDefined(o.expanded)&&""===o.expanded),e.isDefined(o.disabled)&&(n.isDisabled=!0);var p=t.states,u=a.find("v-pane-header"),f=a.find("v-pane-content"),x=f.find("div"),v=d.getAccordionId();if(!u[0])throw new Error("The `v-pane-header` directive can't be found");if(!f[0])throw new Error("The `v-pane-content` directive can't be found");n.paneElement=a,n.paneContentElement=f,n.paneInnerElement=x,n.accordionCtrl=d,d.addPane(n),n.$evalAsync(function(){n.isExpanded?(a.addClass(p.expanded),f.css("max-height","none"),u.attr({"aria-selected":"true",tabindex:"0"})):(f.css("max-height","0px"),u.attr({"aria-selected":"false",tabindex:"-1"}))}),n.$watch("isExpanded",function(e,n){return e===n?!0:(e?l():s(),void 0)})}}}function a(e){var n=this;n.isExpanded=function(){return e.isExpanded},n.toggle=function(){e.isAnimating||e.isDisabled||e.accordionCtrl.toggle(e)},n.expand=function(){e.isAnimating||e.isDisabled||e.accordionCtrl.expand(e)},n.collapse=function(){e.isAnimating||e.isDisabled||e.accordionCtrl.collapse(e)},n.focusPane=function(){e.isFocused=!0},n.blurPane=function(){e.isFocused=!1},e.internalControl={toggle:n.toggle,expand:n.expand,collapse:n.collapse,isExpanded:n.isExpanded}}function o(){return{restrict:"E",require:"^vPane",transclude:!0,template:"
",scope:{},link:function(e,n,i){i.$set("role","tabpanel")}}}function d(){return{restrict:"E",require:["^vPane","^vAccordion"],transclude:!0,template:"
",scope:{},link:function(n,i,t,a){function o(){return p?!1:(n.$apply(function(){l.toggle()}),void 0)}function d(e){32===e.keyCode||13===e.keyCode?(n.$apply(function(){l.toggle()}),e.preventDefault()):39===e.keyCode?(n.$apply(function(){s.focusNext()}),e.preventDefault()):37===e.keyCode&&(n.$apply(function(){s.focusPrevious()}),e.preventDefault())}function c(){l.focusPane()}function r(){l.blurPane()}t.$set("role","tab"),t.$set("tabindex","-1");var l=a[0],s=a[1],p=e.isDefined(t.inactive);i[0].onfocus=c,i[0].onblur=r,i.bind("click",o),i.bind("keydown",d),n.$on("$destroy",function(){i.unbind("click",o),i.unbind("keydown",d),i[0].onfocus=null,i[0].onblur=null})}}}e.module("vAccordion.config",[]).constant("accordionConfig",{states:{expanded:"is-expanded"},expandAnimationDuration:.5}).animation(".is-expanded",["$animateCss","accordionConfig",function(n,i){return{addClass:function(t,a,o){var d=e.element(t[0].querySelector("v-pane-content")),c=e.element(d[0].querySelector("div")),r=c[0].offsetHeight,l=n(d,{easing:"ease",from:{maxHeight:"0px"},to:{maxHeight:r+"px"},duration:i.expandAnimationDuration});return l.start().done(function(){d.css("max-height","none"),o()}),function(e){e&&d.css("max-height","none")}},removeClass:function(t,a,o){var d=e.element(t[0].querySelector("v-pane-content")),c=e.element(d[0].querySelector("div")),r=c[0].offsetHeight,l=n(d,{easing:"ease",from:{maxHeight:r+"px"},to:{maxHeight:"0px"},duration:i.expandAnimationDuration});return l.start().done(o),function(e){e&&d.css("max-height","0px")}}}}]),e.module("vAccordion.directives",[]),e.module("vAccordion",["vAccordion.config","vAccordion.directives"]),e.module("vAccordion.directives").directive("vAccordion",n),n.$inject=["$timeout"],i.$inject=["$scope"],e.module("vAccordion.directives").directive("vPane",t),t.$inject=["$timeout","$animate","accordionConfig"],a.$inject=["$scope"],e.module("vAccordion.directives").directive("vPaneContent",o),e.module("vAccordion.directives").directive("vPaneHeader",d)}(angular); \ No newline at end of file +!function(e){"use strict";function n(n){return{restrict:"E",transclude:!0,controller:i,scope:{control:"=?",expandCb:"&?onexpand",collapseCb:"&?oncollapse",id:"@?"},link:{pre:function(n,i,t){n.allowMultiple=e.isDefined(t.multiple)&&(""===t.multiple||"true"===t.multiple)},post:function(i,t,a,o,d){function c(){var n=["toggle","expand","collapse","expandAll","collapseAll","hasExpandedPane"];e.forEach(n,function(e){if(i.control[e])throw new Error("The `"+e+"` method can not be overwritten")})}if(d(i.$parent.$new(),function(e,n){n.$accordion=i.internalControl,i.id&&(n.$accordion.id=i.id),t.append(e)}),a.$set("role","tablist"),i.allowMultiple&&a.$set("aria-multiselectable","true"),e.isDefined(i.control)){c();var r=e.extend({},i.internalControl,i.control);i.control=i.internalControl=r}else i.control=i.internalControl;n(function(){var n=e.isDefined(o.getAccordionId())?o.getAccordionId()+":onReady":"vAccordion:onReady";i.$emit(n)},0)}}}}function i(n){var i=this,t=!1;n.panes=[],n.expandCb=e.isFunction(n.expandCb)?n.expandCb:e.noop,n.collapseCb=e.isFunction(n.collapseCb)?n.collapseCb:e.noop,i.hasExpandedPane=function(){for(var e=!1,i=0,t=n.panes.length;t>i;i++){var a=n.panes[i];if(a.isExpanded){e=!0;break}}return e},i.getPaneByIndex=function(i){var t;return e.forEach(n.panes,function(n){n.$parent&&e.isDefined(n.$parent.$index)&&n.$parent.$index===i&&(t=n)}),t?t:n.panes[i]},i.getPaneIndex=function(i){var t;return e.forEach(n.panes,function(n){n.$parent&&e.isDefined(n.$parent.$index)&&n===i&&(t=n.$parent.$index)}),e.isDefined(t)?t:n.panes.indexOf(i)},i.getPaneById=function(i){var t;return e.forEach(n.panes,function(e){e.id&&e.id===i&&(t=e)}),t},i.getPaneId=function(e){return e.id},i.getAccordionId=function(){return n.id},i.disable=function(){t=!0},i.enable=function(){t=!1},i.addPane=function(e){if(!n.allowMultiple&&i.hasExpandedPane()&&e.isExpanded)throw new Error("The `multiple` attribute can't be found");n.panes.push(e),e.isExpanded&&n.expandCb({index:i.getPaneIndex(e),id:e.id,pane:e})},i.focusNext=function(){for(var e=n.panes.length,i=0;e>i;i++){var t=n.panes[i];if(t.isFocused){var a=i+1;a>n.panes.length-1&&(a=0);var o=n.panes[a];o.paneElement.find("v-pane-header")[0].focus();break}}},i.focusPrevious=function(){for(var e=n.panes.length,i=0;e>i;i++){var t=n.panes[i];if(t.isFocused){var a=i-1;0>a&&(a=n.panes.length-1);var o=n.panes[a];o.paneElement.find("v-pane-header")[0].focus();break}}},i.toggle=function(e){!t&&e&&(n.allowMultiple||i.collapseAll(e),e.isExpanded=!e.isExpanded,e.isExpanded?n.expandCb({index:i.getPaneIndex(e),id:e.id,pane:e}):n.collapseCb({index:i.getPaneIndex(e),id:e.id,pane:e}))},i.expand=function(e){!t&&e&&(n.allowMultiple||i.collapseAll(e),e.isExpanded||(e.isExpanded=!0,n.expandCb({index:i.getPaneIndex(e),id:e.id,pane:e})))},i.collapse=function(e){!t&&e&&e.isExpanded&&(e.isExpanded=!1,n.collapseCb({index:i.getPaneIndex(e),id:e.id,pane:e}))},i.expandAll=function(){if(!t){if(!n.allowMultiple)throw new Error("The `multiple` attribute can't be found");e.forEach(n.panes,function(e){i.expand(e)})}},i.collapseAll=function(a){t||e.forEach(n.panes,function(e){e!==a&&i.collapse(e)})},n.internalControl={toggle:function(n){e.isString(n)?i.toggle(i.getPaneById(n)):i.toggle(i.getPaneByIndex(n))},expand:function(n){e.isString(n)?i.expand(i.getPaneById(n)):i.expand(i.getPaneByIndex(n))},collapse:function(n){e.isString(n)?i.collapse(i.getPaneById(n)):i.collapse(i.getPaneByIndex(n))},expandAll:i.expandAll,collapseAll:i.collapseAll,hasExpandedPane:i.hasExpandedPane}}function t(n,i,t){return{restrict:"E",require:"^vAccordion",transclude:!0,controller:a,scope:{isExpanded:"=?expanded",isDisabled:"=?ngDisabled",id:"@?"},link:function(n,a,o,d,c){function r(i){i=e.isDefined(v)?v+":"+i:"vAccordion:"+i,n.$emit(i)}function l(){d.disable(),u.attr({"aria-selected":"true",tabindex:"0"}),r("onExpand"),i.addClass(a,p.expanded).then(function(){d.enable(),r("onExpandAnimationEnd")})}function s(){d.disable(),u.attr({"aria-selected":"false",tabindex:"-1"}),r("onCollapse"),i.removeClass(a,p.expanded).then(function(){d.enable(),r("onCollapseAnimationEnd")})}c(n.$parent.$new(),function(e,i){i.$pane=n.internalControl,n.id&&(i.$pane.id=n.id),a.append(e)}),e.isDefined(n.isExpanded)||(n.isExpanded=e.isDefined(o.expanded)&&""===o.expanded),e.isDefined(o.disabled)&&(n.isDisabled=!0);var p=t.states,u=a.find("v-pane-header"),f=a.find("v-pane-content"),x=f.find("div"),v=d.getAccordionId();if(!u[0])throw new Error("The `v-pane-header` directive can't be found");if(!f[0])throw new Error("The `v-pane-content` directive can't be found");n.paneElement=a,n.paneContentElement=f,n.paneInnerElement=x,n.accordionCtrl=d,d.addPane(n),n.$evalAsync(function(){n.isExpanded?(a.addClass(p.expanded),f.css("max-height","none"),u.attr({"aria-selected":"true",tabindex:"0"})):(f.css("max-height","0px"),u.attr({"aria-selected":"false",tabindex:"-1"}))}),n.$watch("isExpanded",function(e,n){return e===n?!0:(e?l():s(),void 0)})}}}function a(e){var n=this;n.isExpanded=function(){return e.isExpanded},n.toggle=function(){e.isAnimating||e.isDisabled||e.accordionCtrl.toggle(e)},n.expand=function(){e.isAnimating||e.isDisabled||e.accordionCtrl.expand(e)},n.collapse=function(){e.isAnimating||e.isDisabled||e.accordionCtrl.collapse(e)},n.focusPane=function(){e.isFocused=!0},n.blurPane=function(){e.isFocused=!1},e.internalControl={toggle:n.toggle,expand:n.expand,collapse:n.collapse,isExpanded:n.isExpanded}}function o(){return{restrict:"E",require:"^vPane",transclude:!0,template:"
",scope:{},link:function(e,n,i){i.$set("role","tabpanel")}}}function d(){return{restrict:"E",require:["^vPane","^vAccordion"],transclude:!0,template:"
",scope:{},link:function(n,i,t,a){function o(){return p?!1:(n.$apply(function(){l.toggle()}),void 0)}function d(e){32===e.keyCode||13===e.keyCode?(n.$apply(function(){l.toggle()}),e.preventDefault()):39===e.keyCode?(n.$apply(function(){s.focusNext()}),e.preventDefault()):37===e.keyCode&&(n.$apply(function(){s.focusPrevious()}),e.preventDefault())}function c(){l.focusPane()}function r(){l.blurPane()}t.$set("role","tab"),t.$set("tabindex","-1");var l=a[0],s=a[1],p=e.isDefined(t.inactive);i[0].onfocus=c,i[0].onblur=r,i.bind("click",o),i.bind("keydown",d),n.$on("$destroy",function(){i.unbind("click",o),i.unbind("keydown",d),i[0].onfocus=null,i[0].onblur=null})}}}e.module("vAccordion.config",[]).constant("accordionConfig",{states:{expanded:"is-expanded"},expandAnimationDuration:.5}).animation(".is-expanded",["$animateCss","accordionConfig",function(n,i){return{addClass:function(t,a,o){var d=e.element(t[0].querySelector("v-pane-content")),c=e.element(d[0].querySelector("div")),r=c[0].offsetHeight,l=n(d,{easing:"ease",from:{maxHeight:"0px"},to:{maxHeight:r+"px"},duration:i.expandAnimationDuration});return l.start().done(function(){d.css("max-height","none"),o()}),function(e){e&&d.css("max-height","none")}},removeClass:function(t,a,o){var d=e.element(t[0].querySelector("v-pane-content")),c=e.element(d[0].querySelector("div")),r=c[0].offsetHeight,l=n(d,{easing:"ease",from:{maxHeight:r+"px"},to:{maxHeight:"0px"},duration:i.expandAnimationDuration});return l.start().done(o),function(e){e&&d.css("max-height","0px")}}}}]),e.module("vAccordion.directives",[]),e.module("vAccordion",["vAccordion.config","vAccordion.directives"]),e.module("vAccordion.directives").directive("vAccordion",n),n.$inject=["$timeout"],i.$inject=["$scope"],e.module("vAccordion.directives").directive("vPane",t),t.$inject=["$timeout","$animate","accordionConfig"],a.$inject=["$scope"],e.module("vAccordion.directives").directive("vPaneContent",o),e.module("vAccordion.directives").directive("vPaneHeader",d)}(angular); \ No newline at end of file diff --git a/package.json b/package.json index 11bcb2e..cae87d2 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "v-accordion", "description": "vAccordion - AngularJS multi-level accordion component", - "version": "1.5.1", + "version": "1.5.2", "author": "Łukasz Wątroba ", "license": "MIT", "keywords": [