Skip to content

Commit c77ca67

Browse files
committed
Dialog: Pass through icons and showText (as 'text') options to button. Fixes #6830 - Allow Icons to be specified for Dialog buttons.
1 parent a9d2e3f commit c77ca67

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

tests/unit/dialog/dialog_options.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ test("buttons", function() {
8181
});
8282

8383
test("buttons - advanced", function() {
84-
expect(5);
84+
expect( 7 );
8585

8686
var buttons,
8787
el = $("<div></div>").dialog({
@@ -92,7 +92,11 @@ test("buttons - advanced", function() {
9292
id: "my-button-id",
9393
click: function() {
9494
equal(this, el[0], "correct context");
95-
}
95+
},
96+
icons: {
97+
primary: "ui-icon-cancel"
98+
},
99+
showText: false
96100
}
97101
]
98102
});
@@ -102,6 +106,8 @@ test("buttons - advanced", function() {
102106
equal(buttons.attr("id"), "my-button-id", "correct id");
103107
equal(buttons.text(), "a button", "correct label");
104108
ok(buttons.hasClass("additional-class"), "additional classes added");
109+
deepEqual( buttons.button("option", "icons"), { primary: "ui-icon-cancel", secondary: null } );
110+
equal( buttons.button( "option", "text" ), false );
105111
buttons.click();
106112

107113
el.remove();

tests/visual/dialog/complex-dialogs.html

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,21 @@
2828
width: 500,
2929
buttons: [
3030
{
31+
click: $.noop,
32+
icons: {
33+
primary: "ui-icon-check"
34+
},
3135
text: "Ok"
3236
},
3337
{
34-
text: "Cancel"
38+
click: function() {
39+
$( this ).dialog( "close" );
40+
},
41+
icons: {
42+
primary: "ui-icon-cancel"
43+
},
44+
text: "Cancel",
45+
showText: false
3546
}
3647
]
3748
}),

ui/jquery.ui.dialog.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,10 @@ $.widget("ui.dialog", {
383383
click.apply( that.element[0], arguments );
384384
};
385385
$( "<button></button>", props )
386-
// TODO allow passing through button options
387-
.button()
386+
.button({
387+
icons: props.icons,
388+
text: props.showText
389+
})
388390
.appendTo( that.uiButtonSet );
389391
});
390392
this.uiDialog.addClass( "ui-dialog-buttons" );

0 commit comments

Comments
 (0)