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

Commit

Permalink
Dialog: Make options work on-the-fly.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Schulhof committed Mar 16, 2013
1 parent eb6eddb commit 22384c9
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions js/widgets/dialog.js
Expand Up @@ -29,8 +29,7 @@ $.widget( "mobile.dialog", $.mobile.widget, {
},

_create: function() {
var self = this,
$el = this.element,
var $el = this.element,
cornerClass = !!this.options.corners ? " ui-corner-all" : "",
dialogWrap = $( "<div/>", {
"role" : "dialog",
Expand Down Expand Up @@ -72,6 +71,25 @@ $.widget( "mobile.dialog", $.mobile.widget, {
this._setCloseBtn( this.options.closeBtn );
},

_setCorners: function( value ) {
this.element.children().toggleClass( "ui-corner-all", value );
},

_setOverlayTheme: function( value ) {
this.element
.removeClass( "ui-overlay-" + this.options.overlayTheme )
.addClass( "ui-overlay-" + value );
if ( $.mobile.activePage[ 0 ] === this.element[ 0 ] ) {
this.options.overlayTheme = value;
this._handlePageBeforeShow();
}
},

_setCloseBtnText: function( value ) {
this.options.closeBtnText = value;
this._setCloseBtn( this.options.closeBtn );
},

_setCloseBtn: function( value ) {
var self = this, btn, location;

Expand Down Expand Up @@ -104,9 +122,12 @@ $.widget( "mobile.dialog", $.mobile.widget, {
},

_setOption: function( key, value ) {
if ( key === "closeBtn" ) {
this._setCloseBtn( value );
var setter = "_set" + key.charAt( 0 ).toUpperCase() + key.slice( 1 );

if ( this[ setter ] !== undefined ) {
this[ setter ]( value );
}

this._super( key, value );
},

Expand Down

0 comments on commit 22384c9

Please sign in to comment.