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

Commit

Permalink
fix(modal): allow replacing object with default options
Browse files Browse the repository at this point in the history
Closes #967
  • Loading branch information
pkozlowski-opensource committed Sep 8, 2013
1 parent 8d153ac commit 8e7fbf0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/modal/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,11 @@ angular.module('ui.bootstrap.modal', [])

.provider('$modal', function () {

var defaultOptions = {
backdrop: true, //can be also false or 'static'
keyboard: true
};

return {
options: defaultOptions,
var $modalProvider = {
options: {
backdrop: true, //can be also false or 'static'
keyboard: true
},
$get: ['$injector', '$rootScope', '$q', '$http', '$templateCache', '$controller', '$modalStack',
function ($injector, $rootScope, $q, $http, $templateCache, $controller, $modalStack) {

Expand Down Expand Up @@ -255,7 +253,7 @@ angular.module('ui.bootstrap.modal', [])
};

//merge and clean up options
modalOptions = angular.extend({}, defaultOptions, modalOptions);
modalOptions = angular.extend({}, $modalProvider.options, modalOptions);
modalOptions.resolve = modalOptions.resolve || {};

//verify options
Expand Down Expand Up @@ -312,4 +310,6 @@ angular.module('ui.bootstrap.modal', [])
return $modal;
}]
};

return $modalProvider;
});
12 changes: 12 additions & 0 deletions src/modal/test/modal.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,18 @@ describe('$modal', function () {
expect($document).toHaveModalOpenWithContent('Content', 'div');
expect($document).not.toHaveBackdrop();
});

it('should accept new objects with default options in a provider', function () {

$modalProvider.options = {
backdrop: false
};
var modal = open({template: '<div>Content</div>'});

expect($document).toHaveModalOpenWithContent('Content', 'div');
expect($document).not.toHaveBackdrop();
});

});

describe('option by option', function () {
Expand Down

0 comments on commit 8e7fbf0

Please sign in to comment.