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

feat(modal): Support custom window html #2056

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/modal/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.transition'])
body.append(backdropDomEl);
}

var angularDomEl = angular.element('<div modal-window></div>');
var angularDomEl = angular.element(modal.window || '<div modal-window></div>');
angularDomEl.attr('window-class', modal.windowClass);
angularDomEl.attr('index', openedWindows.length() - 1);
angularDomEl.attr('animate', 'animate');
Expand Down Expand Up @@ -353,6 +353,7 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.transition'])
content: tplAndVars[0],
backdrop: modalOptions.backdrop,
keyboard: modalOptions.keyboard,
window: modalOptions.window,
windowClass: modalOptions.windowClass
});

Expand Down
33 changes: 32 additions & 1 deletion src/modal/test/modal.spec.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@


describe('$modal', function () {
var $rootScope, $document, $compile, $templateCache, $timeout, $q;
var $modal, $modalProvider;
Expand All @@ -23,6 +25,23 @@ describe('$modal', function () {
$modalProvider = _$modalProvider_;
}));

beforeEach(module(function($compileProvider) {
$compileProvider.directive('customModalWindow', [function () {
return {
restrict: 'EA',
scope: {
index: '@',
animate: '='
},
replace: true,
transclude: true,
template: '<div class=\'custom-modal\'></div>',
link: function (scope, element, attrs) {
}
};
}]);
}));

beforeEach(inject(function (_$rootScope_, _$document_, _$compile_, _$templateCache_, _$timeout_, _$q_, _$modal_) {
$rootScope = _$rootScope_;
$document = _$document_;
Expand Down Expand Up @@ -420,6 +439,18 @@ describe('$modal', function () {
});
});

describe('custom window', function () {

it('should support custom window div as string', function () {
open({
template: '<div>With custom window</div>',
window: '<div custom-modal-window></div>'
});

expect($document.find('div.custom-modal')).toHaveClass('custom-modal');
});
});

describe('custom window classes', function () {

it('should support additional window class as string', function () {
Expand Down Expand Up @@ -498,4 +529,4 @@ describe('$modal', function () {
expect(body).not.toHaveClass('modal-open');
});
});
});
});