]> source.dussan.org Git - jquery-ui.git/commitdiff
Dialog: Support deprecated button options
authorScott González <scott.gonzalez@gmail.com>
Mon, 25 Jul 2016 12:16:13 +0000 (08:16 -0400)
committerScott González <scott.gonzalez@gmail.com>
Mon, 25 Jul 2016 12:38:51 +0000 (08:38 -0400)
Fixes #15016
Closes gh-1723

tests/unit/dialog/deprecated.js
ui/widgets/dialog.js

index 960bf0dc4e966eac65c376e29e6748607e807c45..973a90893a1f9e47f08090441e5a47e3605b5c99 100644 (file)
@@ -28,4 +28,34 @@ QUnit.test( "dialogClass", function( assert ) {
        element.remove();
 } );
 
+QUnit.test( "buttons - deprecated options", function( assert ) {
+       assert.expect( 7 );
+
+       var buttons,
+               element = $( "<div></div>" ).dialog( {
+                       buttons: [
+                               {
+                                       html: "a button",
+                                       "class": "additional-class",
+                                       id: "my-button-id",
+                                       click: function() {
+                                               assert.equal( this, element[ 0 ], "correct context" );
+                                       },
+                                       icons: { primary: "ui-icon-cancel" },
+                                       text: false
+                               }
+                       ]
+               } );
+
+       buttons = element.dialog( "widget" ).find( ".ui-dialog-buttonpane button" );
+       assert.equal( buttons.length, 1, "correct number of buttons" );
+       assert.equal( buttons.attr( "id" ), "my-button-id", "correct id" );
+       assert.equal( $.trim( buttons.text() ), "a button", "correct label" );
+       assert.hasClasses( buttons, "additional-class" );
+       assert.deepEqual( buttons.button( "option", "icon" ), "ui-icon-cancel" );
+       assert.equal( buttons.button( "option", "showLabel" ), false );
+       buttons.trigger( "click" );
+
+       element.remove();
+} );
 } );
index 1bbb3fcd228aed174c39918dee3b37078ab31edb..c8829331f2a74e2a7029eee5295a09ce1e28b340 100644 (file)
@@ -500,7 +500,11 @@ $.widget( "ui.dialog", {
                        buttonOptions = {
                                icon: props.icon,
                                iconPosition: props.iconPosition,
-                               showLabel: props.showLabel
+                               showLabel: props.showLabel,
+
+                               // Deprecated options
+                               icons: props.icons,
+                               text: props.text
                        };
 
                        delete props.click;
@@ -508,6 +512,12 @@ $.widget( "ui.dialog", {
                        delete props.iconPosition;
                        delete props.showLabel;
 
+                       // Deprecated options
+                       delete props.icons;
+                       if ( typeof props.text === "boolean" ) {
+                               delete props.text;
+                       }
+
                        $( "<button></button>", props )
                                .button( buttonOptions )
                                .appendTo( that.uiButtonSet )