Permalink
Browse files

Toolbar: Remove classes from correct page when destroying fixedtoolbars

Fixes gh-7995
Closes gh-8122
  • Loading branch information...
solymosi authored and arschmitz committed Apr 21, 2015
1 parent e9d0ab6 commit ddf966a942a11200b6a62d7cbef99c36682082e0
@@ -53,7 +53,7 @@ define( [ "jquery", "../widget", "../core", "../animationComplete", "../navigati
this._makeFixed();
}
if ( this.options.position === "fixed" && !this.options.supportBlacklist() ) {
var $page = ( !!this.page )? this.page: ( $(".ui-page-active").length > 0 )? $(".ui-page-active"): $(".ui-page").eq(0);
var $page = ( !!this.page ) ? this.page : ( $( ".ui-page-active" ).length > 0 ) ? $( ".ui-page-active" ) : $( ".ui-page" ).eq( 0 );
if ( o.fullscreen !== undefined) {
if ( o.fullscreen ) {
@@ -260,7 +260,7 @@ define( [ "jquery", "../widget", "../core", "../animationComplete", "../navigati
_destroy: function() {
var pageClasses, toolbarClasses, hasFixed, header, hasFullscreen,
page = this.pagecontainer.pagecontainer( "getActivePage" );
page = ( !!this.page ) ? this.page : ( $( ".ui-page-active" ).length > 0 ) ? $( ".ui-page-active" ) : $( ".ui-page" ).eq( 0 );
this._super();
if ( this.options.position === "fixed" ) {
@@ -372,6 +372,36 @@
start
]);
});
asyncTest( "destroy removes classes from correct page " , function() {
expect( 3 );
$.testHelper.pageSequence([
function() {
$( ":mobile-pagecontainer" ).pagecontainer( "change", "#page-destroy-test-page-1" );
},
function() {
$( ":mobile-pagecontainer" ).pagecontainer( "change", "#page-destroy-test-page-2" );
},
function() {
var first = $("#page-destroy-test-page-1"),
second = $("#page-destroy-test-page-2");
ok( first.hasClass("ui-page-header-fixed") === true , "ui-page-header-fixed class exists on first page before destroy" );
var firstHeader = $("#headerOnFirstPage").toolbar("destroy");
ok( first.hasClass("ui-page-header-fixed") === false , "ui-page-header-fixed class is removed from first page" );
ok( second.hasClass("ui-page-header-fixed") === true , "ui-page-header-fixed class is not removed from second page" );
start();
},
function() {
$( ":mobile-pagecontainer" ).pagecontainer( "change", "#default" );
}
]);
});
// It is insufficient to check the final assortment of classes when ascertaining that the stale
// .animationComplete() handler does not do anything, because in the show/hide case the
@@ -29,13 +29,10 @@
<link rel="stylesheet" href="../../../css/themes/default/jquery.mobile.css"/>
<link rel="stylesheet" href="../../../external/qunit/qunit.css"/>
<link rel="stylesheet" href="../../jqm-tests.css"/>
<script src="../../swarminject.js"></script>
</head>
<body>
<div id="qunit"></div>
<div data-nstest-role="page" id="default">
<!-- structural classes -->
<div data-nstest-role="header" id="classes-test-a"></div>
@@ -44,7 +41,6 @@
<div data-nstest-role="footer" id="classes-test-d"></div>
<div data-nstest-role="footer" data-nstest-position="fixed" id="classes-test-e"></div>
<div data-nstest-role="footer" data-nstest-position="fixed" data-nstest-fullscreen="true" id="classes-test-f"></div>
<!-- transition classes -->
<div data-nstest-role="header" data-nstest-position="fixed" id="classes-test-g"></div>
<div data-nstest-role="header" data-nstest-position="fixed" data-nstest-transition="none" id="classes-test-h"></div>
@@ -117,5 +113,16 @@ <h1>Toolbar</h1>
<div class="ui-content">
</div>
</div>
<div data-nstest-role="page" id="page-destroy-test-page-1">
<div id="headerOnFirstPage" data-nstest-role="header" data-nstest-position="fixed">
<h1>title</h1>
</div>
</div>
<div data-nstest-role="page" id="page-destroy-test-page-2">
<div data-nstest-role="header" data-nstest-position="fixed">
<h1>title</h1>
</div>
</div>
</body>
</html>
@@ -57,4 +57,12 @@
$.mobile.zoom.enable( true );
});
test( "Destroy works properly with external toolbars" , function() {
var unEnhanced = $("#external-header").clone(),
destroyed = $("#external-header").toolbar().toolbar("destroy");
ok( $.testHelper.domEqual( destroyed, unEnhanced ),
"unEnhanced equals destroyed" );
});
})(jQuery);
@@ -95,5 +95,9 @@ <h1>foo</h1>
<div data-nstest-role="header" data-nstest-fullscreen="true" data-nstest-position="fixed"></div>
<div data-nstest-role="footer" data-nstest-fullscreen="true" data-nstest-position="fixed"></div>
</div>
<div id="external-header" data-nstest-position="fixed" data-nstest-fullscreen="true">
<h1>&nbsp;</h1>
</div>
</body>
</html>

0 comments on commit ddf966a

Please sign in to comment.