Skip to content

Commit

Permalink
Dialog: Pass through icons and showText (as 'text') options to button…
Browse files Browse the repository at this point in the history
…. Fixes #6830 - Allow Icons to be specified for Dialog buttons.
  • Loading branch information
jzaefferer committed Nov 26, 2012
1 parent d8b98ec commit 9996173
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
10 changes: 8 additions & 2 deletions tests/unit/dialog/dialog_options.js
Expand Up @@ -81,7 +81,7 @@ test("buttons", function() {
});

test("buttons - advanced", function() {
expect(5);
expect( 7 );

var buttons,
el = $("<div></div>").dialog({
Expand All @@ -92,7 +92,11 @@ test("buttons - advanced", function() {
id: "my-button-id",
click: function() {
equal(this, el[0], "correct context");
}
},
icons: {
primary: "ui-icon-cancel"
},
showText: false
}
]
});
Expand All @@ -102,6 +106,8 @@ test("buttons - advanced", function() {
equal(buttons.attr("id"), "my-button-id", "correct id");
equal(buttons.text(), "a button", "correct label");
ok(buttons.hasClass("additional-class"), "additional classes added");
deepEqual( buttons.button("option", "icons"), { primary: "ui-icon-cancel", secondary: null } );
equal( buttons.button( "option", "text" ), false );
buttons.click();

el.remove();
Expand Down
13 changes: 12 additions & 1 deletion tests/visual/dialog/complex-dialogs.html
Expand Up @@ -28,10 +28,21 @@
width: 500,
buttons: [
{
click: $.noop,
icons: {
primary: "ui-icon-check"
},
text: "Ok"
},
{
text: "Cancel"
click: function() {
$( this ).dialog( "close" );
},
icons: {
primary: "ui-icon-cancel"
},
text: "Cancel",
showText: false
}
]
}),
Expand Down
6 changes: 4 additions & 2 deletions ui/jquery.ui.dialog.js
Expand Up @@ -383,8 +383,10 @@ $.widget("ui.dialog", {
click.apply( that.element[0], arguments );
};
$( "<button></button>", props )
// TODO allow passing through button options
.button()
.button({
icons: props.icons,
text: props.showText
})
.appendTo( that.uiButtonSet );
});
this.uiDialog.addClass( "ui-dialog-buttons" );
Expand Down

0 comments on commit 9996173

Please sign in to comment.