Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Popup: Performance improvements. Fixes #5958. Found with git bisect.

  • Loading branch information...
commit 1d575baa0e2f499975db9375a4034e80b1981a8d 1 parent d0eb1b9
@gabrielschulhof gabrielschulhof authored
Showing with 15 additions and 26 deletions.
  1. +15 −26 js/widgets/popup.js
View
41 js/widgets/popup.js
@@ -206,12 +206,13 @@ define( [
},
thisPage = this.element.closest( ".ui-page" ),
myId = this.element.attr( "id" ),
- self = this;
+ o = this.options,
+ key, value;
// We need to adjust the history option to be false if there's no AJAX nav.
// We can't do it in the option declarations because those are run before
// it is determined whether there shall be AJAX nav.
- this.options.history = this.options.history && $.mobile.ajaxEnabled && $.mobile.hashListeningEnabled;
+ o.history = o.history && $.mobile.ajaxEnabled && $.mobile.hashListeningEnabled;
if ( thisPage.length === 0 ) {
thisPage = $( "body" );
@@ -219,7 +220,7 @@ define( [
// define the container for navigation event bindings
// TODO this would be nice at the the mobile widget level
- this.options.container = this.options.container || $.mobile.pageContainer;
+ o.container = o.container || $.mobile.pageContainer || thisPage;
// Apply the proto
thisPage.append( ui.screen );
@@ -253,12 +254,15 @@ define( [
_orientationchangeInProgress: false
});
- $.each( this.options, function( key, value ) {
- // Cause initial options to be applied by their handler by temporarily setting the option to undefined
- // - the handler then sets it to the initial value
- self.options[ key ] = undefined;
- self._setOption( key, value, true );
- });
+ // This duplicates the code from the various option setters below for
+ // better performance. It must be kept in sync with those setters.
+ this._applyTheme( this.element, o.theme, "body" );
+ this._applyTheme( this._ui.screen, o.overlayTheme, "overlay" );
+ this._applyTransition( o.transition );
+ this.element
+ .toggleClass( "ui-overlay-shadow", o.shadow )
+ .toggleClass( "ui-corner-all", o.corners );
+ this._setTolerance( o.tolerance );
ui.screen.bind( "vclick", $.proxy( this, "_eatEventAndClose" ) );
@@ -386,28 +390,13 @@ define( [
},
_setOption: function( key, value ) {
- var exclusions, setter = "_set" + key.charAt( 0 ).toUpperCase() + key.slice( 1 );
+ var setter = "_set" + key.charAt( 0 ).toUpperCase() + key.slice( 1 );
if ( this[ setter ] !== undefined ) {
this[ setter ]( value );
}
- // TODO REMOVE FOR 1.2.1 by moving them out to a default options object
- exclusions = [
- "initSelector",
- "closeLinkSelector",
- "closeLinkEvents",
- "navigateEvents",
- "closeEvents",
- "history",
- "container"
- ];
-
- $.mobile.widget.prototype._setOption.apply( this, arguments );
- if ( $.inArray( key, exclusions ) === -1 ) {
- // Record the option change in the options and in the DOM data-* attributes
- this.element.attr( "data-" + ( $.mobile.ns || "" ) + ( key.replace( /([A-Z])/, "-$1" ).toLowerCase() ), value );
- }
+ this._super( key, value );
},
// Try and center the overlay over the given coordinates
Please sign in to comment.
Something went wrong with that request. Please try again.