From 999617343f7b813dc1c8d9c9048489e4d99d0470 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=B6rn=20Zaefferer?= Date: Fri, 16 Nov 2012 19:26:22 +0100 Subject: [PATCH] Dialog: Pass through icons and showText (as 'text') options to button. Fixes #6830 - Allow Icons to be specified for Dialog buttons. --- tests/unit/dialog/dialog_options.js | 10 ++++++++-- tests/visual/dialog/complex-dialogs.html | 13 ++++++++++++- ui/jquery.ui.dialog.js | 6 ++++-- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/tests/unit/dialog/dialog_options.js b/tests/unit/dialog/dialog_options.js index 0be8c2b7f..beb60a642 100644 --- a/tests/unit/dialog/dialog_options.js +++ b/tests/unit/dialog/dialog_options.js @@ -81,7 +81,7 @@ test("buttons", function() { }); test("buttons - advanced", function() { - expect(5); + expect( 7 ); var buttons, el = $("
").dialog({ @@ -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 } ] }); @@ -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(); diff --git a/tests/visual/dialog/complex-dialogs.html b/tests/visual/dialog/complex-dialogs.html index 8e5d84d3d..46d2539c5 100644 --- a/tests/visual/dialog/complex-dialogs.html +++ b/tests/visual/dialog/complex-dialogs.html @@ -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 } ] }), diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index 23c973975..003389823 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -383,8 +383,10 @@ $.widget("ui.dialog", { click.apply( that.element[0], arguments ); }; $( "", props ) - // TODO allow passing through button options - .button() + .button({ + icons: props.icons, + text: props.showText + }) .appendTo( that.uiButtonSet ); }); this.uiDialog.addClass( "ui-dialog-buttons" ); -- 2.39.5