Skip to content
This repository
Browse code

prevent adding to a non jquery object in fixedToolBar Fixes #3675

  • Loading branch information...
commit b9e8de5fa4fd2f9a1c59f8d9cef50f886c2a8a9d 1 parent 48e7fd6
John Bender authored March 05, 2012
5  js/jquery.mobile.fixedToolbar.js
@@ -159,16 +159,17 @@ define( [ "jquery", "./jquery.mobile.widget", "./jquery.mobile.core", "./jquery.
159 159
 							nextFooter = thisFooter.length && ui.nextPage && $( ".ui-footer-fixed:jqmData(id='" + thisFooter.jqmData( "id" ) + "')", ui.nextPage ),
160 160
 							nextHeader = thisHeader.length && ui.nextPage && $( ".ui-header-fixed:jqmData(id='" + thisHeader.jqmData( "id" ) + "')", ui.nextPage );
161 161
 
  162
+						nextFooter = nextFooter || $();
  163
+
162 164
 							if( nextFooter.length || nextHeader.length ){
163 165
 
164 166
 								nextFooter.add( nextHeader ).appendTo( $.mobile.pageContainer );
165 167
 
166 168
 								ui.nextPage.one( "pageshow", function(){
167 169
 									nextFooter.add( nextHeader ).appendTo( this );
168  
-								} );
  170
+								});
169 171
 							}
170 172
 					}
171  
-
172 173
 				});
173 174
 		},
174 175
 
72  tests/unit/fixedToolbar/fixedToolbar.js
@@ -40,10 +40,10 @@
40 40
 		ok( $('#classes-test-f').hasClass('ui-footer-fullscreen'), 'A footer with data-position=fixed and data-fullscreen should have ui-footer-fullscreen class');
41 41
 
42 42
 		//parent
43  
-		ok( $('#classes-test-b').closest( ".ui-page" ).hasClass( "ui-page-header-fixed" ), "Parent page of a fixed header has class ui-page-header-fixed" )
44  
-		ok( $('#classes-test-e').closest( ".ui-page" ).hasClass( "ui-page-footer-fixed" ), "Parent page of a fixed footer has class ui-page-header-fixed" )
45  
-		ok( $('#classes-test-c').closest( ".ui-page" ).hasClass( "ui-page-header-fullscreen" ), "Parent page of a fullscreen header has class ui-page-header-fullscreen" )
46  
-		ok( $('#classes-test-f').closest( ".ui-page" ).hasClass( "ui-page-footer-fullscreen" ), "Parent page of a fullscreen footer has class ui-page-header-fullscreen" )
  43
+		ok( $('#classes-test-b').closest( ".ui-page" ).hasClass( "ui-page-header-fixed" ), "Parent page of a fixed header has class ui-page-header-fixed" );
  44
+		ok( $('#classes-test-e').closest( ".ui-page" ).hasClass( "ui-page-footer-fixed" ), "Parent page of a fixed footer has class ui-page-header-fixed" );
  45
+		ok( $('#classes-test-c').closest( ".ui-page" ).hasClass( "ui-page-header-fullscreen" ), "Parent page of a fullscreen header has class ui-page-header-fullscreen" );
  46
+		ok( $('#classes-test-f').closest( ".ui-page" ).hasClass( "ui-page-footer-fullscreen" ), "Parent page of a fullscreen footer has class ui-page-header-fullscreen" );
47 47
 
48 48
 
49 49
 	});
@@ -256,4 +256,68 @@
256 256
 			start
257 257
 		]);
258 258
 	});
  259
+
  260
+	asyncTest( "The persistent headers should work without a footer", function() {
  261
+
  262
+		expect( 3 );
  263
+
  264
+		$( "#persist-test-c, #persist-test-d" ).page();
  265
+
  266
+		var nextpageheader =  $( "#persist-test-d .ui-header-fixed" );
  267
+
  268
+		$.testHelper.pageSequence([
  269
+			function(){
  270
+				ok( nextpageheader.length, "next page has fixed header and fixed footer" );
  271
+				$.mobile.changePage( "#persist-test-c" );
  272
+			},
  273
+
  274
+			function(){
  275
+				$( "#persist-test-d" )
  276
+					.one( "pagebeforeshow", function(){
  277
+						same( nextpageheader.parent()[0], $.mobile.pageContainer[0], "fixed header is now a child of page container" );
  278
+					});
  279
+
  280
+				$.mobile.changePage( "#persist-test-d" );
  281
+			},
  282
+
  283
+			function() {
  284
+				same( nextpageheader.parent()[0], $.mobile.activePage[0], "fixed header is now a child of page again" );
  285
+				$.mobile.changePage( "#default" );
  286
+			},
  287
+
  288
+			start
  289
+		]);
  290
+	});
  291
+
  292
+	asyncTest( "The persistent footers should work without a header", function() {
  293
+
  294
+		expect( 3 );
  295
+
  296
+		$( "#persist-test-e, #persist-test-f" ).page();
  297
+
  298
+		var nextpagefooter =  $( "#persist-test-f .ui-footer-fixed" );
  299
+
  300
+		$.testHelper.pageSequence([
  301
+			function(){
  302
+				ok( nextpagefooter.length, "next page has fixed footer and fixed footer" );
  303
+				$.mobile.changePage( "#persist-test-e" );
  304
+			},
  305
+
  306
+			function(){
  307
+				$( "#persist-test-f" )
  308
+					.one( "pagebeforeshow", function(){
  309
+						same( nextpagefooter.parent()[0], $.mobile.pageContainer[0], "fixed footer is now a child of page container" );
  310
+					});
  311
+
  312
+				$.mobile.changePage( "#persist-test-f" );
  313
+			},
  314
+
  315
+			function() {
  316
+				same( nextpagefooter.parent()[0], $.mobile.activePage[0], "fixed footer is now a child of page again" );
  317
+				$.mobile.changePage( "#default" );
  318
+			},
  319
+
  320
+			start
  321
+		]);
  322
+	});
259 323
 })(jQuery);
22  tests/unit/fixedToolbar/index.html
@@ -12,13 +12,9 @@
12 12
 	<script src="../../../external/qunit.js"></script>
13 13
 	<script>
14 14
 		$.testHelper.asyncLoad([
15  
-			[
16  
-				"jquery.mobile.fixedToolbar"
17  
-			],
  15
+			[ "jquery.mobile.fixedToolbar" ],
18 16
 			[ "jquery.mobile.init" ],
19  
-			[
20  
-				"./fixedToolbar.js"
21  
-			]
  17
+			[	"./fixedToolbar.js"	]
22 18
 		]);
23 19
 	</script>
24 20
 
@@ -64,6 +60,20 @@ <h2 id="qunit-userAgent"></h2>
64 60
 	<div data-nstest-role="footer" data-nstest-position="fixed" data-nstest-id="b"></div>
65 61
 </div>
66 62
 
  63
+<div data-nstest-role="page" id="persist-test-c">
  64
+	<div data-nstest-role="header" data-nstest-position="fixed" data-nstest-id="c"></div>
  65
+</div>
  66
+
  67
+<div data-nstest-role="page" id="persist-test-d">
  68
+	<div data-nstest-role="header" data-nstest-position="fixed" data-nstest-id="c"></div>
  69
+</div>
67 70
 
  71
+<div data-nstest-role="page" id="persist-test-e">
  72
+	<div data-nstest-role="footer" data-nstest-position="fixed" data-nstest-id="d"></div>
  73
+</div>
  74
+
  75
+<div data-nstest-role="page" id="persist-test-f">
  76
+	<div data-nstest-role="footer" data-nstest-position="fixed" data-nstest-id="d"></div>
  77
+</div>
68 78
 </body>
69 79
 </html>

0 notes on commit b9e8de5

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