Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

Commit 22384c9

Browse files
author
Gabriel Schulhof
committed
Dialog: Make options work on-the-fly.
1 parent eb6eddb commit 22384c9

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

js/widgets/dialog.js

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ $.widget( "mobile.dialog", $.mobile.widget, {
2929
},
3030

3131
_create: function() {
32-
var self = this,
33-
$el = this.element,
32+
var $el = this.element,
3433
cornerClass = !!this.options.corners ? " ui-corner-all" : "",
3534
dialogWrap = $( "<div/>", {
3635
"role" : "dialog",
@@ -72,6 +71,25 @@ $.widget( "mobile.dialog", $.mobile.widget, {
7271
this._setCloseBtn( this.options.closeBtn );
7372
},
7473

74+
_setCorners: function( value ) {
75+
this.element.children().toggleClass( "ui-corner-all", value );
76+
},
77+
78+
_setOverlayTheme: function( value ) {
79+
this.element
80+
.removeClass( "ui-overlay-" + this.options.overlayTheme )
81+
.addClass( "ui-overlay-" + value );
82+
if ( $.mobile.activePage[ 0 ] === this.element[ 0 ] ) {
83+
this.options.overlayTheme = value;
84+
this._handlePageBeforeShow();
85+
}
86+
},
87+
88+
_setCloseBtnText: function( value ) {
89+
this.options.closeBtnText = value;
90+
this._setCloseBtn( this.options.closeBtn );
91+
},
92+
7593
_setCloseBtn: function( value ) {
7694
var self = this, btn, location;
7795

@@ -104,9 +122,12 @@ $.widget( "mobile.dialog", $.mobile.widget, {
104122
},
105123

106124
_setOption: function( key, value ) {
107-
if ( key === "closeBtn" ) {
108-
this._setCloseBtn( value );
125+
var setter = "_set" + key.charAt( 0 ).toUpperCase() + key.slice( 1 );
126+
127+
if ( this[ setter ] !== undefined ) {
128+
this[ setter ]( value );
109129
}
130+
110131
this._super( key, value );
111132
},
112133

0 commit comments

Comments
 (0)