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

Commit

Permalink
prevent adding to a non jquery object in fixedToolBar Fixes #3675
Browse files Browse the repository at this point in the history
  • Loading branch information
johnbender committed Mar 6, 2012
1 parent 48e7fd6 commit b9e8de5
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 12 deletions.
5 changes: 3 additions & 2 deletions js/jquery.mobile.fixedToolbar.js
Expand Up @@ -159,16 +159,17 @@ define( [ "jquery", "./jquery.mobile.widget", "./jquery.mobile.core", "./jquery.
nextFooter = thisFooter.length && ui.nextPage && $( ".ui-footer-fixed:jqmData(id='" + thisFooter.jqmData( "id" ) + "')", ui.nextPage ),
nextHeader = thisHeader.length && ui.nextPage && $( ".ui-header-fixed:jqmData(id='" + thisHeader.jqmData( "id" ) + "')", ui.nextPage );

nextFooter = nextFooter || $();

if( nextFooter.length || nextHeader.length ){

nextFooter.add( nextHeader ).appendTo( $.mobile.pageContainer );

ui.nextPage.one( "pageshow", function(){
nextFooter.add( nextHeader ).appendTo( this );
} );
});
}
}

});
},

Expand Down
72 changes: 68 additions & 4 deletions tests/unit/fixedToolbar/fixedToolbar.js
Expand Up @@ -40,10 +40,10 @@
ok( $('#classes-test-f').hasClass('ui-footer-fullscreen'), 'A footer with data-position=fixed and data-fullscreen should have ui-footer-fullscreen class');

//parent
ok( $('#classes-test-b').closest( ".ui-page" ).hasClass( "ui-page-header-fixed" ), "Parent page of a fixed header has class ui-page-header-fixed" )
ok( $('#classes-test-e').closest( ".ui-page" ).hasClass( "ui-page-footer-fixed" ), "Parent page of a fixed footer has class ui-page-header-fixed" )
ok( $('#classes-test-c').closest( ".ui-page" ).hasClass( "ui-page-header-fullscreen" ), "Parent page of a fullscreen header has class ui-page-header-fullscreen" )
ok( $('#classes-test-f').closest( ".ui-page" ).hasClass( "ui-page-footer-fullscreen" ), "Parent page of a fullscreen footer has class ui-page-header-fullscreen" )
ok( $('#classes-test-b').closest( ".ui-page" ).hasClass( "ui-page-header-fixed" ), "Parent page of a fixed header has class ui-page-header-fixed" );
ok( $('#classes-test-e').closest( ".ui-page" ).hasClass( "ui-page-footer-fixed" ), "Parent page of a fixed footer has class ui-page-header-fixed" );
ok( $('#classes-test-c').closest( ".ui-page" ).hasClass( "ui-page-header-fullscreen" ), "Parent page of a fullscreen header has class ui-page-header-fullscreen" );
ok( $('#classes-test-f').closest( ".ui-page" ).hasClass( "ui-page-footer-fullscreen" ), "Parent page of a fullscreen footer has class ui-page-header-fullscreen" );


});
Expand Down Expand Up @@ -256,4 +256,68 @@
start
]);
});

asyncTest( "The persistent headers should work without a footer", function() {

expect( 3 );

$( "#persist-test-c, #persist-test-d" ).page();

var nextpageheader = $( "#persist-test-d .ui-header-fixed" );

$.testHelper.pageSequence([
function(){
ok( nextpageheader.length, "next page has fixed header and fixed footer" );
$.mobile.changePage( "#persist-test-c" );
},

function(){
$( "#persist-test-d" )
.one( "pagebeforeshow", function(){
same( nextpageheader.parent()[0], $.mobile.pageContainer[0], "fixed header is now a child of page container" );
});

$.mobile.changePage( "#persist-test-d" );
},

function() {
same( nextpageheader.parent()[0], $.mobile.activePage[0], "fixed header is now a child of page again" );
$.mobile.changePage( "#default" );
},

start
]);
});

asyncTest( "The persistent footers should work without a header", function() {

expect( 3 );

$( "#persist-test-e, #persist-test-f" ).page();

var nextpagefooter = $( "#persist-test-f .ui-footer-fixed" );

$.testHelper.pageSequence([
function(){
ok( nextpagefooter.length, "next page has fixed footer and fixed footer" );
$.mobile.changePage( "#persist-test-e" );
},

function(){
$( "#persist-test-f" )
.one( "pagebeforeshow", function(){
same( nextpagefooter.parent()[0], $.mobile.pageContainer[0], "fixed footer is now a child of page container" );
});

$.mobile.changePage( "#persist-test-f" );
},

function() {
same( nextpagefooter.parent()[0], $.mobile.activePage[0], "fixed footer is now a child of page again" );
$.mobile.changePage( "#default" );
},

start
]);
});
})(jQuery);
22 changes: 16 additions & 6 deletions tests/unit/fixedToolbar/index.html
Expand Up @@ -12,13 +12,9 @@
<script src="../../../external/qunit.js"></script>
<script>
$.testHelper.asyncLoad([
[
"jquery.mobile.fixedToolbar"
],
[ "jquery.mobile.fixedToolbar" ],
[ "jquery.mobile.init" ],
[
"./fixedToolbar.js"
]
[ "./fixedToolbar.js" ]
]);
</script>

Expand Down Expand Up @@ -64,6 +60,20 @@ <h2 id="qunit-userAgent"></h2>
<div data-nstest-role="footer" data-nstest-position="fixed" data-nstest-id="b"></div>
</div>

<div data-nstest-role="page" id="persist-test-c">
<div data-nstest-role="header" data-nstest-position="fixed" data-nstest-id="c"></div>
</div>

<div data-nstest-role="page" id="persist-test-d">
<div data-nstest-role="header" data-nstest-position="fixed" data-nstest-id="c"></div>
</div>

<div data-nstest-role="page" id="persist-test-e">
<div data-nstest-role="footer" data-nstest-position="fixed" data-nstest-id="d"></div>
</div>

<div data-nstest-role="page" id="persist-test-f">
<div data-nstest-role="footer" data-nstest-position="fixed" data-nstest-id="d"></div>
</div>
</body>
</html>

0 comments on commit b9e8de5

Please sign in to comment.