Skip to content
Merged
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
9 changes: 9 additions & 0 deletions bootbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,7 @@
options = sanitize(options);

var dialog = $(templates.dialog);
var innerDialog = dialog.find(".modal-dialog");
var body = dialog.find(".modal-body");
var buttons = options.buttons;
var buttonStr = "";
Expand All @@ -598,6 +599,14 @@
dialog.addClass(options.className);
}

if (options.size === "large") {
innerDialog.addClass("modal-lg");
}

if (options.size === "small") {
innerDialog.addClass("modal-sm");
}

if (options.title) {
body.before(templates.header);
}
Expand Down
35 changes: 35 additions & 0 deletions tests/defaults.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,41 @@ describe("bootbox.setDefaults", function() {
});
});

describe("size", function() {
describe("when set to large", function() {
beforeEach(function() {
bootbox.setDefaults({
size: "large"
});

this.dialog = bootbox.dialog({
message: "test"
});
});

it("adds the large class to the innerDialog", function() {
expect(this.dialog.children(":first").hasClass("modal-dialog")).to.be.true;
expect(this.dialog.children(":first").hasClass("modal-lg")).to.be.true;
});
});
describe("when set to small", function() {
beforeEach(function() {
bootbox.setDefaults({
size: "small"
});

this.dialog = bootbox.dialog({
message: "test"
});
});

it("adds the small class to the innerDialog", function() {
expect(this.dialog.children(":first").hasClass("modal-dialog")).to.be.true;
expect(this.dialog.children(":first").hasClass("modal-sm")).to.be.true;
});
});
});

describe("backdrop", function() {
describe("when set to false", function() {
beforeEach(function() {
Expand Down
19 changes: 19 additions & 0 deletions tests/dialog.test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -313,3 +313,22 @@ describe "bootbox.dialog", ->

it "should not hide the modal", ->
expect(@hidden).not.to.have.been.called

describe "with size option", ->
describe "when the size option is set to large", ->
beforeEach ->
@dialog = bootbox.dialog
message: "test"
size: "large"

it "adds the large class to the innerDialog", ->
expect(@dialog.children(":first").hasClass("modal-lg")).to.be.true

describe "when the size option is set to small", ->
beforeEach ->
@dialog = bootbox.dialog
message: "test"
size: "small"

it "adds the large class to the innerDialog", ->
expect(@dialog.children(":first").hasClass("modal-sm")).to.be.true