Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 23 additions & 23 deletions js/widgets/panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
// Browser globals
factory( jQuery );
}
})( function( $ ) {
} )( function( $ ) {

return $.widget( "mobile.panel", {
version: "@VERSION",
Expand Down Expand Up @@ -77,8 +77,8 @@ return $.widget( "mobile.panel", {
_page: this._getPage,
_panelInner: this._getPanelInner(),
_fixedToolbars: this._getFixedToolbars
});
if ( this.options.display !== "overlay" ){
} );
if ( this.options.display !== "overlay" ) {
this._getWrapper();
}
this._addPanelClasses();
Expand Down Expand Up @@ -117,7 +117,7 @@ return $.widget( "mobile.panel", {
self._modal = $( "<div class='" + self.options.classes.modal + "'></div>" )
.on( "mousedown", function() {
self.close();
})
} )
.appendTo( target );
},

Expand Down Expand Up @@ -176,11 +176,11 @@ return $.widget( "mobile.panel", {
_bindCloseEvents: function() {
this._on( this._closeLink, {
"click": "_handleCloseClick"
});
} );

this._on({
this._on( {
"click a:jqmData(ajax='false')": "_handleCloseClick"
});
} );
},

_positionPanel: function( scrollToTop ) {
Expand Down Expand Up @@ -212,7 +212,7 @@ return $.widget( "mobile.panel", {
},

_bindFixListener: function() {
this._on( $( window ), { "throttledresize": "_positionPanel" });
this._on( $( window ), { "throttledresize": "_positionPanel" } );
},

_unbindFixListener: function() {
Expand All @@ -234,17 +234,17 @@ return $.widget( "mobile.panel", {
_bindUpdateLayout: function() {
var self = this;

self.element.on( "updatelayout", function(/* e */) {
self.element.on( "updatelayout", function( /* e */ ) {
if ( self._open ) {
self._positionPanel();
}
});
} );
},

_bindLinkListeners: function() {
this._on( "body", {
"click a": "_handleClick"
});
} );

},

Expand All @@ -260,7 +260,7 @@ return $.widget( "mobile.panel", {
link.addClass( $.mobile.activeBtnClass );
this.element.one( "panelopen panelclose", function() {
link.removeClass( $.mobile.activeBtnClass );
});
} );
}
this.toggle();
}
Expand Down Expand Up @@ -291,34 +291,34 @@ return $.widget( "mobile.panel", {
if ( self._open && e.target !== self.element[ 0 ] ) {
self.close();
}
})
} )
// On escape, close? might need to have a target check too...
.on( "keyup.panel", function( e ) {
if ( e.keyCode === 27 && self._open ) {
self.close();
}
});
} );
if ( !this._parentPage && this.options.display !== "overlay" ) {
this._on( this.document, {
"pageshow": function() {
this._openedPage = null;
this._getWrapper();
}
});
} );
}
// Clean up open panels after page hide
if ( self._parentPage ) {
this.document.on( "pagehide", ":jqmData(role='page')", function() {
if ( self._open ) {
self.close( true );
}
});
} );
} else {
this.document.on( "pagebeforehide", function() {
if ( self._open ) {
self.close( true );
}
});
} );
}
},

Expand All @@ -333,7 +333,7 @@ return $.widget( "mobile.panel", {
o = self.options,

_openPanel = function() {
self._off( self.document , "panelclose" );
self._off( self.document, "panelclose" );
self._page().jqmData( "panel", "open" );

if ( $.support.cssTransform3d && !!o.animate && o.display !== "overlay" ) {
Expand Down Expand Up @@ -398,7 +398,7 @@ return $.widget( "mobile.panel", {
if ( self._page().jqmData( "panel" ) === "open" ) {
self._on( self.document, {
"panelclose": _openPanel
});
} );
} else {
_openPanel();
}
Expand Down Expand Up @@ -485,8 +485,8 @@ return $.widget( "mobile.panel", {

_destroy: function() {
var otherPanels,
o = this.options,
multiplePanels = ( $( "body > :mobile-panel" ).length + $.mobile.activePage.find( ":mobile-panel" ).length ) > 1;
o = this.options,
multiplePanels = ( $( "body > :mobile-panel" ).length + $.mobile.activePage.find( ":mobile-panel" ).length ) > 1;

if ( o.display !== "overlay" ) {

Expand Down Expand Up @@ -535,6 +535,6 @@ return $.widget( "mobile.panel", {
this._modal.remove();
}
}
});
} );

});
} );
176 changes: 88 additions & 88 deletions tests/integration/panel/external_panel_core.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,101 +2,101 @@ var panel = $( "#wrapper-test-panel" ).panel(),
stretchTestPanel = $( "#panel-stretch-test" ).panel();

asyncTest( "External panel updates wrapper correctly", function() {
var otherPageChildren,
thisPage = $( "#start-page" ),
otherPage = $( "#other-page" ),
otherPageLink = $( "#go-to-other-page" );
var otherPageChildren,
thisPage = $( "#start-page" ),
otherPage = $( "#other-page" ),
otherPageLink = $( "#go-to-other-page" );

expect( 7 );
expect( 7 );

$.testHelper.detailedEventCascade([
function() {
panel.panel( "open" );
},
{
panelopen: { src: panel, event: "panelopen.externalPanelUpdatesWrapperCorrectly1" }
},
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();
},
{
panelclose: { src: panel, event: "panelclose.externalPanelUpdatesWrapperCorrectly2" },
pagecontainerchange: {
src: $( window ),
event: "pagecontainerchange.externalPanelUpdatesWrapperCorrectly2"
}
},
function( result ) {
otherPageChildren = otherPage.children();
deepEqual( result.panelclose.timedOut, false, "Panel did close upon link click" );
deepEqual( result.pagecontainerchange.timedOut, false,
"pagecontainerchange event received" );
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();
},
{
pagecontainerchange: {
src: $( window ),
event: "pagecontainerchange.externalPanelUpdatesWrapperCorrectly2"
}
},
start
]);
});
$.testHelper.detailedEventCascade( [
function() {
panel.panel( "open" );
},
{
panelopen: { src: panel, event: "panelopen.externalPanelUpdatesWrapperCorrectly1" }
},
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();
},
{
panelclose: { src: panel, event: "panelclose.externalPanelUpdatesWrapperCorrectly2" },
pagecontainerchange: {
src: $( window ),
event: "pagecontainerchange.externalPanelUpdatesWrapperCorrectly2"
}
},
function( result ) {
otherPageChildren = otherPage.children();
deepEqual( result.panelclose.timedOut, false, "Panel did close upon link click" );
deepEqual( result.pagecontainerchange.timedOut, false,
"pagecontainerchange event received" );
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();
},
{
pagecontainerchange: {
src: $( window ),
event: "pagecontainerchange.externalPanelUpdatesWrapperCorrectly2"
}
},
start
] );
} );

asyncTest( "External panel stretches to acommodate page height", function( assert ) {
expect( 4 );
expect( 4 );

var eventNs = ".externalPanelStretches";
var eventNs = ".externalPanelStretches";

$.testHelper.detailedEventCascade( [
function() {
$( "body" ).pagecontainer( "change", "#panel-stretch-page" );
},
{
pagecontainerchange: { src: $( window ), event: "pagecontainerchange" + eventNs + "1" }
},
function( result ) {
assert.deepEqual( result.pagecontainerchange.timedOut, false,
"Successfully changed to page '#panel-stretch-page'" );
$.testHelper.detailedEventCascade( [
function() {
$( "body" ).pagecontainer( "change", "#panel-stretch-page" );
},
{
pagecontainerchange: { src: $( window ), event: "pagecontainerchange" + eventNs + "1" }
},
function( result ) {
assert.deepEqual( result.pagecontainerchange.timedOut, false,
"Successfully changed to page '#panel-stretch-page'" );

// Make the page scroll
$( "#panel-stretch-page .ui-content" ).height( $.mobile.getScreenHeight() * 3 );
// Make the page scroll
$( "#panel-stretch-page .ui-content" ).height( $.mobile.getScreenHeight() * 3 );

stretchTestPanel.panel( "open" );
},
{
panelopen: { src: stretchTestPanel, event: "panelopen" + eventNs + "2" }
},
function( result ) {
stretchTestPanel.panel( "open" );
},
{
panelopen: { src: stretchTestPanel, event: "panelopen" + eventNs + "2" }
},
function( result ) {

// Making assertions about the document height has to happen immediately after the
// operation that modifies the document height takes place, because the act of
// recording the assertion itself may modify the document height, because QUnit will
// insert new DOM elements to visually record the assertion, and the addition of such
// DOM elements may affect the document height.
assert.deepEqual( stretchTestPanel.outerHeight( true ), $( document ).height(),
"Panel is as tall as the document" );
assert.deepEqual( result.panelopen.timedOut, false, "Panel opened successfully" );
stretchTestPanel.panel( "close" );
},
{
panelclose: { src: stretchTestPanel, event: "panelclose" + eventNs + "3" }
},
function( result ) {
assert.deepEqual( result.panelclose.timedOut, false, "Panel closedsuccessfully" );
$.mobile.back();
},
{
pagecontainerchange: { src: $( window ), event: "pagecontainerchange" + eventNs + "4" }
},
start
] );
// Making assertions about the document height has to happen immediately after the
// operation that modifies the document height takes place, because the act of
// recording the assertion itself may modify the document height, because QUnit will
// insert new DOM elements to visually record the assertion, and the addition of such
// DOM elements may affect the document height.
assert.deepEqual( stretchTestPanel.outerHeight( true ), $( document ).height(),
"Panel is as tall as the document" );
assert.deepEqual( result.panelopen.timedOut, false, "Panel opened successfully" );
stretchTestPanel.panel( "close" );
},
{
panelclose: { src: stretchTestPanel, event: "panelclose" + eventNs + "3" }
},
function( result ) {
assert.deepEqual( result.panelclose.timedOut, false, "Panel closedsuccessfully" );
$.mobile.back();
},
{
pagecontainerchange: { src: $( window ), event: "pagecontainerchange" + eventNs + "4" }
},
start
] );
} );
Loading