aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2016-07-25 08:16:13 -0400
committerScott González <scott.gonzalez@gmail.com>2016-07-25 08:38:51 -0400
commit6c754b4b5b19a2a12eae68058458ef9ff7b72a0a (patch)
treeac063a342b9bd84b27d76f5c8398e1ebbd32166f
parentf67f9293ae962dc814e66ac110b4f82404d14f69 (diff)
downloadjquery-ui-6c754b4b5b19a2a12eae68058458ef9ff7b72a0a.tar.gz
jquery-ui-6c754b4b5b19a2a12eae68058458ef9ff7b72a0a.zip
Dialog: Support deprecated button options
Fixes #15016 Closes gh-1723
-rw-r--r--tests/unit/dialog/deprecated.js30
-rw-r--r--ui/widgets/dialog.js12
2 files changed, 41 insertions, 1 deletions
diff --git a/tests/unit/dialog/deprecated.js b/tests/unit/dialog/deprecated.js
index 960bf0dc4..973a90893 100644
--- a/tests/unit/dialog/deprecated.js
+++ b/tests/unit/dialog/deprecated.js
@@ -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();
+} );
} );
diff --git a/ui/widgets/dialog.js b/ui/widgets/dialog.js
index 1bbb3fcd2..c8829331f 100644
--- a/ui/widgets/dialog.js
+++ b/ui/widgets/dialog.js
@@ -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 )