Permalink
Browse files

Popup: Implement classes option

Fixes gh-7686
  • Loading branch information...
gabrielschulhof committed Feb 5, 2015
1 parent 597cd5c commit f861daa824025038c037c082620a66668101d33a
Showing with 29 additions and 15 deletions.
  1. +29 −15 js/widgets/popup.js
View
@@ -51,11 +51,27 @@ function getWindowCoordinates( theWindow ) {
$.widget( "mobile.popup", {
options: {
wrapperClass: null,
classes: {
"ui-popup-screen": "ui-overlay-inherit",
"ui-popup-placeholder": null,
"ui-popup": "ui-body-inherit ui-overlay-shadow ui-corner-all",
"ui-popup-container": null,
"ui-popup-hidden": null,
"ui-popup-truncate": null
},
theme: null,
overlayTheme: null,
shadow: true,
corners: true,
// The following style options are DEPRECATED as of 1.5.0 and will be removed in 1.6.0.
// Their default value has been set to null because the effect of the old default value
// is now being achieved via the default value of the new class key(s). Setting the default
// value to null also allows us upon _create() to detect which of the style options has
// been set via deprecated data-attributes or code.
wrapperClass: null,
shadow: null,
corners: null,
transition: "none",
positionTo: "origin",
tolerance: null,
@@ -83,7 +99,8 @@ $.widget( "mobile.popup", {
},
_create: function() {
var theElement = this.element,
var optionsToSet,
theElement = this.element,
myId = theElement.attr( "id" ),
currentOptions = this.options;
@@ -143,11 +160,9 @@ $.widget( "mobile.popup", {
var currentOptions = this.options,
wrapperClass = currentOptions.wrapperClass,
ui = {
screen: $( "<div class='ui-screen-hidden ui-popup-screen " +
this._themeClassFromOption( "ui-overlay-", currentOptions.overlayTheme ) + "'></div>" ),
screen: $( "<div>" ),
placeholder: $( "<div style='display: none;'><!-- placeholder --></div>" ),
container: $( "<div class='ui-popup-container ui-popup-hidden ui-popup-truncate" +
( wrapperClass ? ( " " + wrapperClass ) : "" ) + "'></div>" )
container: $( "<div>" )
},
fragment = this.document[ 0 ].createDocumentFragment();
@@ -162,17 +177,16 @@ $.widget( "mobile.popup", {
.html( "<!-- placeholder for " + myId + " -->" );
}
this._addClass( ui.screen, "ui-popup-screen", "ui-screen-hidden" );
this._addClass( ui.placeholder, "ui-popup-placeholder" );
this._addClass( ui.container, "ui-popup-container ui-popup-hidden ui-popup-truncate" );
this._addClass( this.element, "ui-popup" );
// Apply the proto
this._page[ 0 ].appendChild( fragment );
// Leave a placeholder where the element used to be
ui.placeholder.insertAfter( theElement );
theElement
.detach()
.addClass( "ui-popup " +
this._themeClassFromOption( "ui-body-", currentOptions.theme ) + " " +
( currentOptions.shadow ? "ui-overlay-shadow " : "" ) +
( currentOptions.corners ? "ui-corner-all " : "" ) )
.appendTo( ui.container );
theElement.appendTo( ui.container );
return ui;
},

0 comments on commit f861daa

Please sign in to comment.