diff --git a/src/accordion/accordion.js b/src/accordion/accordion.js index 586314c9c6..eaa5d4b279 100644 --- a/src/accordion/accordion.js +++ b/src/accordion/accordion.js @@ -58,7 +58,7 @@ angular.module('ui.bootstrap.accordion', ['ui.bootstrap.collapse']) return { require: '^uibAccordion', // We need this directive to be inside an accordion transclude: true, // It transcludes the contents of the directive into the template - replace: true, // The element containing the directive will be replaced with the template + restrict: 'A', templateUrl: function(element, attrs) { return attrs.templateUrl || 'uib/template/accordion/accordion-group.html'; }, @@ -74,6 +74,7 @@ angular.module('ui.bootstrap.accordion', ['ui.bootstrap.collapse']) }; }, link: function(scope, element, attrs, accordionCtrl) { + element.addClass('panel'); accordionCtrl.addGroup(scope); scope.openClass = attrs.openClass || 'panel-open'; diff --git a/src/accordion/docs/demo.html b/src/accordion/docs/demo.html index 83f643fff7..2b119b3e5e 100644 --- a/src/accordion/docs/demo.html +++ b/src/accordion/docs/demo.html @@ -1,18 +1,16 @@
@@ -28,35 +26,35 @@

- +
This content is straight in the template. - - +
+
{{group.content}} - - +
+

The body of the uib-accordion group grows to fit the contents

{{item}}
- - +
+
Hello - - +
+
Custom template with custom header template World - - +
+

Please, to delete your account, click the button below

- - +
+
I can have markup, too! This is just some content to illustrate fancy headings. - +
diff --git a/src/accordion/docs/readme.md b/src/accordion/docs/readme.md index a20a951d6e..25f790c3fa 100644 --- a/src/accordion/docs/readme.md +++ b/src/accordion/docs/readme.md @@ -32,11 +32,6 @@ The body of each accordion group is transcluded into the body of the collapsible _(Default: `false`)_ - Whether accordion group is open or closed. -* `panel-class` - - _(Default: `panel-default`)_ - - Add ability to use Bootstrap's contextual panel classes (panel-primary, panel-success, panel-info, etc...) or your own. This must be a string. - * `template-url` _(Default: `uib/template/accordion/accordion-group.html`)_ - Add the ability to override the template used on the component. diff --git a/src/accordion/test/accordion.spec.js b/src/accordion/test/accordion.spec.js index 2cae4bd4da..1879d6f9c4 100644 --- a/src/accordion/test/accordion.spec.js +++ b/src/accordion/test/accordion.spec.js @@ -176,12 +176,12 @@ describe('uib-accordion', function() { var tpl = '' + - '' + + '
' + '
'; element = $compile(tpl)(scope); scope.$digest(); - expect(element.find('[template-url]').html()).toBe('baz'); + expect(element.find('[template-url]').html()).toBe('
baz
'); })); describe('with static panels', function() { @@ -189,8 +189,8 @@ describe('uib-accordion', function() { spyOn(Math, 'random').and.returnValue(0.1); var tpl = '' + - 'Content 1' + - 'Content 2' + + '
Content 1
' + + '
Content 2
' + '
'; element = angular.element(tpl); $compile(element)(scope); @@ -288,8 +288,8 @@ describe('uib-accordion', function() { beforeEach(function() { var tpl = '' + - 'Content 1' + - 'Content 2' + + '
Content 1
' + + '
Content 2
' + '
'; element = angular.element(tpl); $compile(element)(scope); @@ -318,7 +318,7 @@ describe('uib-accordion', function() { beforeEach(function() { var tpl = '' + - '{{group.content}}' + + '
{{group.content}}
' + '
'; element = angular.element(tpl); model = [ @@ -363,8 +363,8 @@ describe('uib-accordion', function() { beforeEach(function() { var tpl = '' + - 'Content 1' + - 'Content 2' + + '
Content 1
' + + '
Content 2
' + '
'; element = angular.element(tpl); scope.open = { first: false, second: true }; @@ -393,8 +393,8 @@ describe('uib-accordion', function() { beforeEach(function() { var tpl = '' + - '
{{item}}
' + - 'Static content' + + '
{{item}}
' + + '
Static content
' + '
'; element = angular.element(tpl); scope.items = ['Item 1', 'Item 2', 'Item 3']; @@ -421,7 +421,7 @@ describe('uib-accordion', function() { beforeEach(function() { var tpl = '' + - '{{group.content}}' + + '
{{group.content}}
' + '
'; element = angular.element(tpl); scope.groups = [ @@ -456,7 +456,7 @@ describe('uib-accordion', function() { beforeEach(function() { var tpl = '' + - '{{group.content}}' + + '
{{group.content}}
' + '
'; element = angular.element(tpl); scope.groups = [ @@ -480,7 +480,7 @@ describe('uib-accordion', function() { beforeEach(function() { var tpl = '' + - 'Content 1' + + '
Content 1
' + '
'; element = angular.element(tpl); scope.disabled = true; @@ -519,10 +519,10 @@ describe('uib-accordion', function() { function isDisabledStyleCheck() { var tpl = '' + - '' + + '
' + 'Heading Element {{x}} ' + 'Body' + - '' + + '
' + '
'; scope.disabled = true; element = $compile(tpl)(scope); @@ -536,10 +536,10 @@ describe('uib-accordion', function() { beforeEach(function() { var tpl = '' + - '' + + '
' + 'Heading Element {{x}} ' + 'Body' + - '' + + '
' + '
'; element = $compile(tpl)(scope); scope.$digest(); @@ -565,10 +565,10 @@ describe('uib-accordion', function() { beforeEach(function() { var tpl = '' + - '' + + '
' + '
Heading Element {{x}}
' + 'Body' + - '' + + '
' + '
'; element = $compile(tpl)(scope); scope.$digest(); @@ -588,7 +588,7 @@ describe('uib-accordion', function() { describe('uib-accordion-heading, with repeating uib-accordion-groups', function() { it('should clone the uib-accordion-heading for each group', function() { - element = $compile('{{x}}')(scope); + element = $compile('
{{x}}
')(scope); scope.$digest(); groups = element.find('.panel'); expect(groups.length).toBe(3); @@ -600,7 +600,7 @@ describe('uib-accordion', function() { describe('uib-accordion-heading attribute, with repeating uib-accordion-groups', function() { it('should clone the uib-accordion-heading for each group', function() { - element = $compile('
{{x}}
')(scope); + element = $compile('
{{x}}
')(scope); scope.$digest(); groups = element.find('.panel'); expect(groups.length).toBe(3); @@ -614,46 +614,11 @@ describe('uib-accordion', function() { it('should transclude heading to a template using data-uib-accordion-header', inject(function($templateCache) { $templateCache.put('foo/bar.html', '
'); - element = $compile('baz')(scope); + element = $compile('
baz
')(scope); scope.$digest(); groups = element.find('.panel'); expect(findGroupLink(0).text()).toBe('baz'); })); }); - - describe('uib-accordion group panel class', function() { - it('should use the default value when panel class is falsy - #3968', function() { - element = $compile('Content')(scope); - scope.$digest(); - groups = element.find('.panel'); - expect(groups.eq(0)).toHaveClass('panel-default'); - - element = $compile('Content')(scope); - scope.$digest(); - groups = element.find('.panel'); - expect(groups.eq(0)).toHaveClass('panel-default'); - }); - - it('should use the specified value when not falsy - #3968', function() { - element = $compile('Content')(scope); - scope.$digest(); - groups = element.find('.panel'); - expect(groups.eq(0)).toHaveClass('custom-class'); - expect(groups.eq(0)).not.toHaveClass('panel-default'); - }); - - it('should change class if panel-class is changed', function() { - element = $compile('Content')(scope); - scope.panelClass = 'custom-class'; - scope.$digest(); - groups = element.find('.panel'); - expect(groups.eq(0)).toHaveClass('custom-class'); - - scope.panelClass = 'different-class'; - scope.$digest(); - expect(groups.eq(0)).toHaveClass('different-class'); - expect(groups.eq(0)).not.toHaveClass('custom-class'); - }); - }); }); }); diff --git a/template/accordion/accordion-group.html b/template/accordion/accordion-group.html index 728c674c1c..8375bd26b1 100644 --- a/template/accordion/accordion-group.html +++ b/template/accordion/accordion-group.html @@ -1,10 +1,8 @@ -
- -
-
-
+ +
+