Skip to content
This repository
Browse code

resolve the screen deferred immediately

  • Loading branch information...
commit 015377ff30411ce48d1d723946eec9f9e2b877f5 1 parent d7f35ef
John Bender authored August 29, 2012
25  js/widgets/popup.js
@@ -410,29 +410,24 @@ define( [ "jquery",
410 410
 		},
411 411
 
412 412
 		_animate: function( args ) {
413  
-			if ( this.options.overlayTheme && args.additionalCondition ) {
414  
-				this._ui.screen
415  
-					.removeClass( args.classToRemove )
416  
-					.addClass( args.screenClassToAdd );
417  
-
418  
-				setTimeout(function() {
419  
-					args.prereqs.screen.resolve();
420  
-				}, 0);
421  
-			} else {
422  
-				args.prereqs.screen.resolve();
423  
-			}
  413
+			// NOTE before removing the default animation of the screen
  414
+			//      this had an animate callback that would relove the deferred
  415
+			//      now the deferred is resolved immediately
  416
+			// TODO remove the dependency on the screen deferred
  417
+			this._ui.screen
  418
+				.removeClass( args.classToRemove )
  419
+				.addClass( args.screenClassToAdd );
  420
+
  421
+			args.prereqs.screen.resolve();
424 422
 
425 423
 			if ( args.transition && args.transition !== "none" ) {
426 424
 				if ( args.applyTransition ) {
427 425
 					this._applyTransition( args.transition );
428 426
 				}
429 427
 				this._ui.container
  428
+					.animationComplete( $.proxy( args.prereqs.container, "resolve" ) )
430 429
 					.addClass( args.containerClassToAdd )
431 430
 					.removeClass( args.classToRemove );
432  
-
433  
-				setTimeout(function() {
434  
-					args.prereqs.container.resolve();
435  
-				}, 0);
436 431
 			} else {
437 432
 				args.prereqs.container.resolve();
438 433
 			}
45  tests/unit/popup/popup_core.js
@@ -182,28 +182,35 @@
182 182
 	});
183 183
 
184 184
 	asyncTest( "Popup opens and closes", function() {
  185
+		var $popup = $( "#test-popup" );
  186
+		expect( 9 );
185 187
 
186  
-		expect( 8 );
187  
-
188  
-		$( "#test-popup" ).popup( "open", { x: -9999, y: -9999 } );
189  
-		setTimeout(function() {
  188
+		$popup.bind( "popupafteropen", function() {
190 189
 			var theOffset = $( "#test-popup p" ).offset();
191  
-			ok( !$( "#test-popup" ).parent().prev().hasClass( "ui-screen-hidden" ), "Open popup screen is not hidden" );
192  
-			ok( $( "#test-popup" ).attr( "class" ).match( /( |^)ui-body-[a-z]( |$)/ ), "Open popup has a valid overlay theme" );
  190
+			ok( !$popup.parent().prev().hasClass( "ui-screen-hidden" ), "Open popup screen is not hidden" );
  191
+			ok( $popup.attr( "class" ).match( /( |^)ui-body-[a-z]( |$)/ ), "Open popup has a valid overlay theme" );
193 192
 			ok( theOffset.left >= 15 && theOffset.top >= 30, "Open popup top left coord is at least (10, 30)" );
194  
-			$( "#test-popup" ).popup( "option", "overlayTheme", "a" );
195  
-			ok( $( "#test-popup" ).parent().prev().hasClass( "ui-overlay-a in" ), "Setting an overlay theme while the popup is open causes the theme to be applied and the screen to be faded in" );
196  
-			ok( $( "#test-popup" ).parent().hasClass( "ui-popup-active" ), "Open popup has the 'ui-popup-active' class" );
197  
-			$( "#test-popup" ).popup( "close" );
198  
-			setTimeout(function() {
199  
-				ok( !$( "#test-popup" ).parent().hasClass( "in" ), "Closed popup container does not have class 'in'" );
200  
-				ok( $( "#test-popup" ).parent().prev().hasClass( "ui-screen-hidden" ), "Closed popup screen is hidden" );
201  
-				ok( !$( "#test-popup" ).parent().hasClass( "ui-popup-active" ), "Open popup dos not have the 'ui-popup-active' class" );
202  
-				setTimeout( function() { start(); }, 300 );
203  
-			}, 1000);
204  
-		}, 1000);
  193
+
  194
+			$popup.popup( "option", "overlayTheme", "a" );
  195
+			ok( $popup.parent().prev().hasClass( "ui-overlay-a" ), "Setting an overlay theme while the popup is open causes the theme to be applied and the screen to be faded in" );
  196
+			ok( $popup.parent().prev().hasClass( "in" ), "Setting an overlay theme while the popup is open causes the theme to be applied and the screen to be faded in" );
  197
+			ok( $popup.parent().hasClass( "ui-popup-active" ), "Open popup has the 'ui-popup-active' class" );
  198
+
  199
+			$popup.popup( "close" );
  200
+		});
  201
+
  202
+		$popup.bind( "popupafterclose", function() {
  203
+			ok( !$popup.parent().hasClass( "in" ), "Closed popup container does not have class 'in'" );
  204
+			ok( $popup.parent().prev().hasClass( "ui-screen-hidden" ), "Closed popup screen is hidden" );
  205
+			ok( !$popup.parent().hasClass( "ui-popup-active" ), "Open popup dos not have the 'ui-popup-active' class" );
  206
+
  207
+			start();
  208
+		});
  209
+
  210
+		$popup.popup( "open" );
205 211
 	});
206 212
 
  213
+
207 214
 	asyncTest( "Link that launches popup is deactivated", function() {
208 215
 
209 216
 		expect( 4 );
@@ -421,8 +428,6 @@
421 428
 
422 429
 		expect( 2 );
423 430
 
424  
-		$popup.popup( "open" );
425  
-
426 431
 		// check that after the popup is closed the focus is correct
427 432
 		$popup.one( "popupafteropen", function() {
428 433
 			ok( true, "afteropen has fired" );
@@ -432,6 +437,8 @@
432 437
 				start();
433 438
 			});
434 439
 		});
  440
+
  441
+		$popup.popup( "open" );
435 442
 	});
436 443
 
437 444
 	test( "Popup doesn't alter the url when the history option is disabled", function() {

0 notes on commit 015377f

Please sign in to comment.
Something went wrong with that request. Please try again.