Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Commit

Permalink
refactor(modal): add class to element instead of template expression
Browse files Browse the repository at this point in the history
  • Loading branch information
bekos authored and pkozlowski-opensource committed Apr 19, 2014
1 parent ded352c commit 00829b6
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/modal/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.transition'])
transclude: true,
templateUrl: 'template/modal/window.html',
link: function (scope, element, attrs) {
scope.windowClass = attrs.windowClass || '';
element.addClass(attrs.windowClass || '');

$timeout(function () {
// trigger CSS transitions
Expand Down
3 changes: 2 additions & 1 deletion src/modal/test/modalWindow.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ describe('modal window', function () {
}));

it('should support custom CSS classes as string', function () {
var windowEl = $compile('<div modal-window window-class="test">content</div>')($rootScope);
var windowEl = $compile('<div modal-window window-class="test foo">content</div>')($rootScope);
$rootScope.$digest();

expect(windowEl).toHaveClass('test');
expect(windowEl).toHaveClass('foo');
});
});
2 changes: 1 addition & 1 deletion template/modal/window.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<div tabindex="-1" class="modal fade {{ windowClass }}" ng-class="{in: animate}" ng-style="{'z-index': 1050 + index*10, display: 'block'}" ng-click="close($event)">
<div tabindex="-1" class="modal fade" ng-class="{in: animate}" ng-style="{'z-index': 1050 + index*10, display: 'block'}" ng-click="close($event)">
<div class="modal-dialog"><div class="modal-content" ng-transclude></div></div>
</div>

1 comment on commit 00829b6

@codeberg30
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bekos Why was this removed from the scope? I had wrapped the {{ windowClass }} expression in another element, for a custom template, but now this option is too rigid to be of much value. Why force the class to only be added to the root element, instead of just making it available on the scope?

Please sign in to comment.