Permalink
Browse files

Panel: Retain current page during closing process

Fixes gh-7814
Closes gh-7877
  • Loading branch information...
gabrielschulhof committed Dec 16, 2014
1 parent 9576b76 commit 827292ededd3b6b0d3fef737fda6b95774760228
View
@@ -377,6 +377,10 @@ $.widget( "mobile.panel", {
close: function( immediate ) {
if ( this._open ) {
var self = this,
// Record what the page is the moment the process of closing begins, because it
// may change by the time the process completes
currentPage = self._page(),
o = this.options,
_closePanel = function() {
@@ -403,13 +407,14 @@ $.widget( "mobile.panel", {
},
complete = function() {
if ( o.theme && o.display !== "overlay" ) {
self._page().parent().removeClass( o.classes.pageContainer + "-themed " + o.classes.pageContainer + "-" + o.theme );
currentPage.parent().removeClass( o.classes.pageContainer + "-themed " +
o.classes.pageContainer + "-" + o.theme );
}
self.element.addClass( o.classes.panelClosed );
if ( o.display !== "overlay" ) {
self._page().parent().removeClass( o.classes.pageContainer );
currentPage.parent().removeClass( o.classes.pageContainer );
self._wrapper.removeClass( o.classes.pageContentPrefix + "-open" );
self._fixedToolbars().removeClass( o.classes.pageContentPrefix + "-open" );
}
@@ -423,7 +428,7 @@ $.widget( "mobile.panel", {
self._unbindFixListener();
$.mobile.resetActivePageHeight();
self._page().jqmRemoveData( "panel" );
currentPage.jqmRemoveData( "panel" );
self._trigger( "close" );
@@ -20,7 +20,7 @@
[ "widgets/page" ],
[ "widgets/panel" ],
[ "init" ],
[ "external_panel_wrapper_update_core.js" ]
[ "external_panel_core.js" ]
]);
</script>
@@ -34,7 +34,7 @@
<a href="#other-page" id="go-to-other-page" data-nstest-transition="none">Go to other page</a>
</div>
<div data-nstest-role="page">
<div data-nstest-role="page" id="start-page">
<div class="ui-content">
<p>Start page</p>
</div>
@@ -2,10 +2,11 @@ var panel = $( "#wrapper-test-panel" ).panel();
asyncTest( "External panel updates wrapper correctly", function() {
var otherPageChildren,
thisPage = $( "#start-page" ),
otherPage = $( "#other-page" ),
otherPageLink = $( "#go-to-other-page" );
expect( 5 );
expect( 7 );
$.testHelper.detailedEventCascade([
function() {
@@ -16,6 +17,8 @@ asyncTest( "External panel updates wrapper correctly", function() {
},
function( result ) {
deepEqual( result.panelopen.timedOut, false, "Panel did open" );
deepEqual( thisPage.data( $.mobile.ns + "panel" ), "open",
"Data at key 'panel' on opening page present" );
otherPageLink.click();
},
{
@@ -33,6 +36,8 @@ asyncTest( "External panel updates wrapper correctly", function() {
deepEqual( otherPageChildren.length, 1, "Other page has exactly one child" );
deepEqual( otherPageChildren.hasClass( "ui-panel-wrapper" ), true,
"Other page child has class 'ui-panel-wrapper'" );
deepEqual( thisPage.data( $.mobile.ns + "panel" ), undefined,
"Data at key 'panel' on opening page absent" );
$.mobile.back();
},
{

0 comments on commit 827292e

Please sign in to comment.