]> source.dussan.org Git - jquery-ui.git/commitdiff
Dialog: Pass through icons and showText (as 'text') options to button. Fixes #6830...
authorJörn Zaefferer <joern.zaefferer@gmail.com>
Fri, 16 Nov 2012 18:26:22 +0000 (19:26 +0100)
committerJörn Zaefferer <joern.zaefferer@gmail.com>
Mon, 26 Nov 2012 09:28:23 +0000 (10:28 +0100)
tests/unit/dialog/dialog_options.js
tests/visual/dialog/complex-dialogs.html
ui/jquery.ui.dialog.js

index 0be8c2b7fec688d18e7942dfb9408383be3158db..beb60a642e306ee422ce5f36996eb324328e9989 100644 (file)
@@ -81,7 +81,7 @@ test("buttons", function() {
 });
 
 test("buttons - advanced", function() {
-       expect(5);
+       expect( 7 );
 
        var buttons,
                el = $("<div></div>").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();
index 8e5d84d3d6cd9094fed18c466d3065ba4bc79db7..46d2539c5f0ec9e62b4e94b23d3929b3b2e8e744 100644 (file)
                                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
                                        }
                                ]
                        }),
index 23c973975d850719ff4690a9c348b681d77ed6bc..0033898234a4597bf08d9fffeb45998879b23322 100644 (file)
@@ -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" );