Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'panel-refactor-part2'

  • Loading branch information...
commit 2707936ba1292df5c528365d5a0c16a5ef2248e7 2 parents b671eaf + 8293ac6
@jaspermdegroot jaspermdegroot authored
View
13 css/structure/jquery.mobile.fixedToolbar.css
@@ -53,16 +53,3 @@
.ui-android-2x-fixed .ui-li-has-thumb {
-webkit-transform: translate3d(0,0,0);
}
-.ui-panel-content-wrap.ui-panel-content-wrap-display-push .ui-header-fixed,
-.ui-panel-content-wrap.ui-panel-content-wrap-display-reveal .ui-header-fixed {
- -webkit-transform: translateY(-100%);
- -moz-transform: translateY(-100%);
- -o-transform: translateY(-100%);
- -ms-transform: translateY(-100%);
- transform: translateY(-100%);
- position: absolute;
- top: 0;
-}
-.ui-panel-content-wrap-closed .ui-header-fixed {
- -webkit-transform: none;
-}
View
4 css/structure/jquery.mobile.listview.css
@@ -1,8 +1,8 @@
.ui-listview { margin: 0; }
ol.ui-listview, ol.ui-listview .ui-li-divider { counter-reset: listnumbering; }
-.ui-content .ui-listview { margin: -15px; }
+.ui-content .ui-listview, .ui-panel-inner > .ui-listview { margin: -15px; }
.ui-collapsible-content > .ui-listview { margin: -10px -15px; }
-.ui-content .ui-listview-inset { margin: 1em 0; }
+.ui-content .ui-listview-inset, .ui-panel-inner .ui-listview-inset { margin: 1em 0; }
.ui-collapsible-content .ui-listview-inset { margin: .5em 0; }
.ui-listview, .ui-li { list-style: none; padding: 0; }
.ui-li, .ui-li.ui-field-contain { display: block; margin: 0; position: relative; overflow: visible; text-align: left; border-width: 0; border-top-width: 1px; }
View
281 css/structure/jquery.mobile.panel.css
@@ -1,142 +1,177 @@
+/* panel */
.ui-panel {
+ width: 17em;
min-height: 100%;
- border-width:0;
+ border-width: 0;
+ position: absolute;
top: 0;
display: block;
- width: 17em;
}
.ui-panel-closed {
width: 0;
overflow: hidden;
}
-
-/* animate class is added to panel and wrapper, toggling on transitions */
-.ui-panel-animate {
- -webkit-transition: -webkit-transform 350ms ease;
- -moz-transition: -moz-transform 350ms ease;
- -o-transition: -o-transform 350ms ease;
- -ms-transition: -ms-transform 350ms ease;
- transition: transform 350ms ease;
+.ui-panel-fixed {
+ position: fixed;
+ bottom: -1px; /* fixes gap on Chrome for Android */
+ padding-bottom: 1px;
}
-
-/* a bit of hardware acceleration for iOS 6 blinking */
-.ui-panel-3dtransforms.ui-panel-content-wrap,
-.ui-panel-3dtransforms ~.ui-panel-content-wrap .ui-header {
- -webkit-backface-visibility: hidden;
+.ui-panel-display-overlay {
+ z-index: 1001; /* fixed toolbars have z-index 1000 */
}
-
-/* don't animate reveal - it stays in place */
.ui-panel-display-reveal {
- -webkit-transition: none;
- -moz-transition: none;
- -o-transition: none;
- -ms-transition: none;
- transition: none;
+ z-index: 0;
+}
+.ui-panel-display-push {
+ z-index: 999;
+}
+.ui-panel-inner {
+ padding: 15px;
}
+/* content-wrap */
+.ui-panel-content-wrap {
+ position: relative;
+ left: 0;
+ min-height: inherit;
+ border: none;
+ z-index: 999;
+}
+.ui-panel-content-wrap-display-overlay,
+.ui-panel-animate.ui-panel-content-wrap > .ui-header, /* ios4 fix */
+.ui-panel-content-wrap-closed {
+ position: static;
+}
-/* z stacking */
-.ui-panel-display-overlay,
-.ui-panel-display-push,
-.ui-panel-content-wrap,
+/* dismiss */
.ui-panel-dismiss {
- z-index: 99999;
+ position: absolute;
+ top: 0;
+ left:0;
+ height: 100%;
+ width: 100%;
+ z-index: 1002;
+ display: none;
}
-.ui-panel-display-reveal {
- z-index: 0;
+.ui-panel-dismiss-open {
+ display: block;
}
-.ui-panel,
-.ui-panel.ui-panel-unfixed {
- position: absolute;
+
+/* animate class is added to panel, wrapper and fixed toolbars */
+.ui-panel-animate {
+ -webkit-transition: -webkit-transform 350ms ease;
+ -moz-transition: -moz-transform 350ms ease;
+ transition: transform 350ms ease;
}
-/* display and reveal */
-.ui-panel-3dtransforms {
- position: fixed;
+
+/* hardware acceleration for smoother transitions */
+.ui-panel-animate.ui-panel:not(.ui-panel-display-reveal),
+.ui-panel-animate.ui-panel:not(.ui-panel-display-reveal) > div,
+.ui-panel-animate.ui-panel-content-wrap,
+.ui-panel-animate.ui-panel-content-fixed-toolbar {
+ -webkit-backface-visibility: hidden;
+ -webkit-transform: translate3d(0,0,0);
}
-/* panel default positions */
-.ui-panel-position-left,
-.ui-panel-3dtransforms.ui-panel-position-left.ui-panel-open,
-.ui-panel-3dtransforms.ui-panel-position-left.ui-panel-display-reveal {
+/* positioning: panel */
+/* panel left */
+.ui-panel-position-left {
left: -17em;
}
-.ui-panel-position-right,
-.ui-panel-3dtransforms.ui-panel-position-right.ui-panel-open,
-.ui-panel-3dtransforms.ui-panel-position-right.ui-panel-display-reveal {
- right: -17em;
+/* animated: panel left (for overlay and push) */
+.ui-panel-animate.ui-panel-position-left.ui-panel-display-overlay,
+.ui-panel-animate.ui-panel-position-left.ui-panel-display-push {
+ left: 0;
+ -webkit-transform: translate3d(-17em,0,0);
+ -moz-transform: translate3d(-17em,0,0);
+ transform: translate3d(-17em,0,0);
}
-/* non-3d positioning */
+/* panel left open */
+.ui-panel-position-left.ui-panel-display-reveal, /* negate "panel left" for reveal */
.ui-panel-position-left.ui-panel-open {
left: 0;
}
+/* animated: panel left open (for overlay and push) */
+.ui-panel-animate.ui-panel-position-left.ui-panel-open.ui-panel-display-overlay,
+.ui-panel-animate.ui-panel-position-left.ui-panel-open.ui-panel-display-push {
+ -webkit-transform: translate3d(0,0,0);
+ -moz-transform: translate3d(0,0,0);
+ transform: translate3d(0,0,0);
+}
+/* panel right */
+.ui-panel-position-right {
+ right: -17em;
+}
+/* animated: panel right (for overlay and push) */
+.ui-panel-animate.ui-panel-position-right.ui-panel-display-overlay,
+.ui-panel-animate.ui-panel-position-right.ui-panel-display-push {
+ right: 0;
+ -webkit-transform: translate3d(17em,0,0);
+ -moz-transform: translate3d(17em,0,0);
+ transform: translate3d(17em,0,0);
+}
+/* panel right open */
+.ui-panel-position-right.ui-panel-display-reveal, /* negate "panel right" for reveal */
.ui-panel-position-right.ui-panel-open {
right: 0;
}
-
-/* panel open positions */
-.ui-panel-3dtransforms.ui-panel-open,
-.ui-panel-3dtransforms.ui-panel-position-left.ui-panel-display-reveal {
- -webkit-transform: translateX(17em);
- -moz-transform: translateX(17em);
- -ms-transform: translateX(17em);
- -o-transform: translateX(17em);
- transform: translateX(17em);
-}
-/* this exception is here to keep reveal in place until the closed class is added, which is after hide */
-.ui-panel-3dtransforms.ui-panel-display-reveal.ui-panel-closed {
- -webkit-transform: translateX(0);
- -moz-transform: translateX(0);
- -ms-transform: translateX(0);
- -o-transform: translateX(0);
- transform: translateX(0);
-}
-.ui-panel-3dtransforms.ui-panel-open.ui-panel-position-right,
-.ui-panel-3dtransforms.ui-panel-position-right.ui-panel-display-reveal {
- -webkit-transform: translateX(-17em);
- -moz-transform: translateX(-17em);
- -ms-transform: translateX(-17em);
- -o-transform: translateX(-17em);
- transform: translateX(-17em);
+/* animated: panel right open (for overlay and push) */
+.ui-panel-animate.ui-panel-position-right.ui-panel-open.ui-panel-display-overlay,
+.ui-panel-animate.ui-panel-position-right.ui-panel-open.ui-panel-display-push {
+ -webkit-transform: translate3d(0,0,0);
+ -moz-transform: translate3d(0,0,0);
+ transform: translate3d(0,0,0);
}
-/* dismiss */
-.ui-panel-dismiss{
- position: absolute;
- top: 0;
- left:0;
- height: 100%;
- width: 100%;
- display: none;
-}
-.ui-panel-dismiss-open{
- display: block;
+/* positioning: content wrap, fixed toolbars and dismiss */
+/* panel left open */
+.ui-panel-content-fixed-toolbar-position-left.ui-panel-content-fixed-toolbar-open,
+.ui-panel-content-wrap-position-left.ui-panel-content-wrap-open,
+.ui-panel-dismiss-position-left.ui-panel-dismiss-open {
+ left: 17em;
}
-
-/* content-wrap */
-.ui-panel-content-wrap {
- position: relative;
- background: inherit;
- z-index: 1;
+/* animated: panel left open (for reveal and push) */
+.ui-panel-animate.ui-panel-content-fixed-toolbar-position-left.ui-panel-content-fixed-toolbar-open.ui-panel-content-fixed-toolbar-display-reveal,
+.ui-panel-animate.ui-panel-content-fixed-toolbar-position-left.ui-panel-content-fixed-toolbar-open.ui-panel-content-fixed-toolbar-display-push,
+.ui-panel-animate.ui-panel-content-wrap-position-left.ui-panel-content-wrap-open.ui-panel-content-wrap-display-reveal,
+.ui-panel-animate.ui-panel-content-wrap-position-left.ui-panel-content-wrap-open.ui-panel-content-wrap-display-push {
left: 0;
- min-height: inherit;
+ -webkit-transform: translate3d(17em,0,0);
+ -moz-transform: translate3d(17em,0,0);
+ transform: translate3d(17em,0,0);
+}
+/* panel right open */
+.ui-panel-content-fixed-toolbar-position-right.ui-panel-content-fixed-toolbar-open,
+.ui-panel-content-wrap-position-right.ui-panel-content-wrap-open,
+.ui-panel-dismiss-position-right.ui-panel-dismiss-open {
+ left: -17em;
}
-.ui-panel-content-wrap-display-overlay {
- position: static;
+/* animated: panel right open (for reveal and push) */
+.ui-panel-animate.ui-panel-content-fixed-toolbar-position-right.ui-panel-content-fixed-toolbar-open.ui-panel-content-fixed-toolbar-display-reveal,
+.ui-panel-animate.ui-panel-content-fixed-toolbar-position-right.ui-panel-content-fixed-toolbar-open.ui-panel-content-fixed-toolbar-display-push,
+.ui-panel-animate.ui-panel-content-wrap-position-right.ui-panel-content-wrap-open.ui-panel-content-wrap-display-reveal,
+.ui-panel-animate.ui-panel-content-wrap-position-right.ui-panel-content-wrap-open.ui-panel-content-wrap-display-push {
+ left: 0;
+ -webkit-transform: translate3d(-17em,0,0);
+ -moz-transform: translate3d(-17em,0,0);
+ transform: translate3d(-17em,0,0);
}
-/* a bit of hardware acceleration for iOS 6 blinking */
-.ui-panel-3dtransforms ~.ui-panel-content-wrap ,
-.ui-panel-3dtransforms ~.ui-panel-content-wrap .ui-header-fixed {
- -webkit-backface-visibility: hidden;
+/* negate "panel left/right open" for overlay */
+.ui-panel-content-fixed-toolbar-open.ui-panel-content-fixed-toolbar-display-overlay,
+.ui-panel-content-wrap-open.ui-panel-content-wrap-display-overlay {
+ left: 0;
}
-.ui-panel-3dtransforms ~.ui-panel-content-wrap .ui-header:not(.ui-header-fixed), /* ios4 fix */
-.ui-panel-content-wrap-closed {
- position: static;
+
+/* always disable overflow-x to prevent zoom issue on Android */
+.ui-page-active.ui-page-panel {
+ overflow-x: hidden;
}
/* shadows and borders */
.ui-panel-display-reveal {
-webkit-box-shadow: inset -5px 0 5px rgba(0,0,0,.15);
+ -moz-box-shadow: inset -5px 0 5px rgba(0,0,0,.15);
box-shadow: inset -5px 0 5px rgba(0,0,0,.15);
}
.ui-panel-position-right.ui-panel-display-reveal {
@@ -158,57 +193,29 @@
border-right-width: 1px;
margin-right: -1px;
}
+.ui-panel-animate.ui-panel-content-fixed-toolbar-position-left.ui-panel-content-fixed-toolbar-open.ui-panel-content-fixed-toolbar-display-push {
+ margin-left: 1px;
+}
.ui-panel-display-push.ui-panel-open.ui-panel-position-right {
border-left-width: 1px;
margin-left: -1px;
}
-
-/* dismiss and content wrap open positions */
-.ui-panel-content-wrap-open.ui-panel-content-wrap-display-reveal,
-.ui-panel-dismiss-open.ui-panel-dismiss-display-reveal,
-.ui-panel-content-wrap-open.ui-panel-content-wrap-display-push,
-.ui-panel-dismiss-open.ui-panel-dismiss-display-push,
-.ui-panel-dismiss-open.ui-panel-dismiss-display-overlay {
- left: 17em;
-}
-.ui-panel-3dtransforms.ui-panel-content-wrap-open.ui-panel-content-wrap-display-reveal,
-.ui-panel-3dtransforms.ui-panel-content-wrap-open.ui-panel-content-wrap-display-push {
- -webkit-transform: translateX(17em);
- -moz-transform: translateX(17em);
- -ms-transform: translateX(17em);
- -o-transform: translateX(17em);
- transform: translateX(17em);
- left: 0;
-}
-.ui-panel-content-wrap-open.ui-panel-content-wrap-display-reveal.ui-panel-content-wrap-position-right,
-.ui-panel-dismiss-open.ui-panel-dismiss-display-reveal.ui-panel-dismiss-position-right,
-.ui-panel-content-wrap-open.ui-panel-content-wrap-display-push.ui-panel-content-wrap-position-right,
-.ui-panel-dismiss-open.ui-panel-dismiss-display-push.ui-panel-dismiss-position-right,
-.ui-panel-dismiss-open.ui-panel-dismiss-display-overlay.ui-panel-dismiss-position-right {
- left: -17em;
-}
-.ui-panel-3dtransforms ~.ui-panel-content-wrap-open.ui-panel-content-wrap-display-reveal.ui-panel-content-wrap-position-right,
-.ui-panel-3dtransforms ~.ui-panel-content-wrap-open.ui-panel-content-wrap-display-push.ui-panel-content-wrap-position-right {
- -webkit-transform: translateX(-17em);
- -moz-transform: translateX(-17em);
- -ms-transform: translateX(-17em);
- -o-transform: translateX(-17em);
- transform: translateX(-17em);
- left: 0;
-}
-/* while open, page x overflow is disabled */
-.ui-page-active.ui-panel-page-block {
- overflow-x:hidden;
+.ui-panel-animate.ui-panel-content-fixed-toolbar-position-right.ui-panel-content-fixed-toolbar-open.ui-panel-content-fixed-toolbar-display-push {
+ margin-right: 1px;
}
/* wrap push on wide viewports once open */
@media (min-width:55em){
- .ui-responsive-panel .ui-panel-content-wrap.ui-panel-content-wrap-open-complete.ui-panel-content-wrap-display-push,
- .ui-responsive-panel .ui-panel-content-wrap.ui-panel-content-wrap-open-complete.ui-panel-content-wrap-display-reveal {
+ .ui-responsive-panel.ui-page-panel-open .ui-panel-content-fixed-toolbar-open.ui-panel-content-fixed-toolbar-display-push,
+ .ui-responsive-panel.ui-page-panel-open .ui-panel-content-fixed-toolbar-open.ui-panel-content-fixed-toolbar-display-reveal,
+ .ui-responsive-panel.ui-page-panel-open .ui-panel-content-wrap-open.ui-panel-content-wrap-display-push,
+ .ui-responsive-panel.ui-page-panel-open .ui-panel-content-wrap-open.ui-panel-content-wrap-display-reveal {
margin-right: 17em;
}
- .ui-responsive-panel .ui-panel-content-wrap.ui-panel-content-wrap-open-complete.ui-panel-content-wrap-display-push.ui-panel-content-wrap-position-right,
- .ui-responsive-panel .ui-panel-content-wrap.ui-panel-content-wrap-open-complete.ui-panel-content-wrap-display-reveal.ui-panel-content-wrap-position-right {
+ .ui-responsive-panel.ui-page-panel-open .ui-panel-content-fixed-toolbar-open.ui-panel-content-wrap-display-push.ui-panel-content-fixed-toolbar-position-right,
+ .ui-responsive-panel.ui-page-panel-open .ui-panel-content-fixed-toolbar-open.ui-panel-content-wrap-display-reveal.ui-panel-content-fixed-toolbar-position-right,
+ .ui-responsive-panel.ui-page-panel-open .ui-panel-content-wrap-open.ui-panel-content-wrap-display-push.ui-panel-content-wrap-position-right,
+ .ui-responsive-panel.ui-page-panel-open .ui-panel-content-wrap-open.ui-panel-content-wrap-display-reveal.ui-panel-content-wrap-position-right {
margin: 0 0 0 17em;
}
.ui-responsive-panel .ui-panel-dismiss-display-push {
View
2  docs/demos/panels/panel-nav-form-fixed.html
@@ -48,7 +48,7 @@
<div data-role="panel" data-position="left" data-position-fixed="true" data-display="reveal" id="nav-panel" data-theme="a">
- <ul data-role="listview" data-theme="a" data-divider-theme="a" style="margin-top:-1px;" class="nav-search">
+ <ul data-role="listview" data-theme="a" data-divider-theme="a" style="margin-top:-16px;" class="nav-search">
<li data-icon="delete" style="background-color:#111;">
<a href="#" data-rel="close">Close menu</a>
</li>
View
28 docs/demos/panels/panel-nav-form.html
@@ -35,20 +35,20 @@
</div><!-- /jqm-footer -->
- <style>
- .nav-search .ui-btn-up-a {
- background-image:none;
- background-color:#333333;
- }
- .nav-search .ui-btn-inner {
- border-top: 1px solid #888;
- border-color: rgba(255, 255, 255, .1);
- }
- </style>
+ <style>
+ .nav-search .ui-btn-up-a {
+ background-image:none;
+ background-color:#333333;
+ }
+ .nav-search .ui-btn-inner {
+ border-top: 1px solid #888;
+ border-color: rgba(255, 255, 255, .1);
+ }
+ </style>
<div data-role="panel" data-position="left" data-position-fixed="false" data-display="reveal" id="nav-panel" data-theme="a">
- <ul data-role="listview" data-theme="a" data-divider-theme="a" style="margin-top:-1px;" class="nav-search">
+ <ul data-role="listview" data-theme="a" data-divider-theme="a" style="margin-top:-16px;" class="nav-search">
<li data-icon="delete" style="background-color:#111;">
<a href="#" data-rel="close">Close menu</a>
</li>
@@ -96,17 +96,13 @@
<!-- panel content goes here -->
</div><!-- /panel -->
-
-
<style>
.userform { padding:.8em 1.2em; }
.userform h2 { color:#555; margin:0.3em 0 .8em 0; padding-bottom:.5em; border-bottom:1px solid rgba(0,0,0,.1); }
.userform label { display:block; margin-top:1.2em; }
.switch .ui-slider-switch { width: 6.5em !important }
.ui-grid-a { margin-top:1em; padding-top:.8em; margin-top:1.4em; border-top:1px solid rgba(0,0,0,.1); }
- </style>
-
-
+ </style>
<div data-role="panel" data-position="right" data-position-fixed="false" data-display="overlay" id="add-form" data-theme="b">
View
470 docs/panels/index.html
@@ -1,315 +1,289 @@
<!DOCTYPE html>
<html>
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <title>jQuery Mobile Docs - Slide Panel</title>
- <link rel="stylesheet" href="../../css/themes/default/jquery.mobile.css" />
- <link rel="stylesheet" href="../_assets/css/jqm-docs.css"/>
-
- <script src="../../js/jquery.js"></script>
- <script src="../../docs/_assets/js/jqm-docs.js"></script>
- <script src="../../js/"></script>
- </head>
- <body>
- <div data-role="page" class="ui-responsive-panel">
-
- <style>
- .panel-content { padding:15px; }
- </style>
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>jQuery Mobile Docs - Slide Panel</title>
+ <link rel="stylesheet" href="../../css/themes/default/jquery.mobile.css" />
+ <link rel="stylesheet" href="../_assets/css/jqm-docs.css"/>
+
+ <script src="../../js/jquery.js"></script>
+ <script src="../../docs/_assets/js/jqm-docs.js"></script>
+ <script src="../../js/"></script>
+</head>
+<body>
+ <div data-role="page" class="ui-responsive-panel">
+
+ <!-- defaultpanel -->
+ <div data-role="panel" id="defaultpanel" data-theme="b">
- <!-- defaultpanel -->
- <div data-role="panel" id="defaultpanel" data-theme="b">
-
- <div class="panel-content">
- <h3>Default panel options</h3>
- <p>This panel has all the default options: positioned on the left with the reveal display mode. The panel markup is <em>before</em> the header, content and footer in the source order.</p>
- <p>To close, click off the panel, swipe left or right, hit the Esc key, or use the button below:</p>
- <a href="#demo-links" data-rel="close" data-role="button" data-theme="c" data-icon="delete" data-inline="true">Close panel</a>
- </div><!-- /content wrapper for padding -->
-
- </div><!-- /defaultpanel -->
-
- <!-- Note: all other panels are at the end of the page, scroll down -->
-
-
-
- <div data-role="header" data-theme="f" data-position="fixed">
- <h1>Panels</h1>
- <a href="../../" data-icon="home" data-iconpos="notext" data-direction="reverse">Home</a>
- <a href="../nav.html" data-icon="search" data-iconpos="notext" data-rel="dialog" data-transition="fade">Search</a>
- </div><!-- /header -->
+ <h3>Default panel options</h3>
+ <p>This panel has all the default options: positioned on the left with the reveal display mode. The panel markup is <em>before</em> the header, content and footer in the source order.</p>
+ <p>To close, click off the panel, swipe left or right, hit the Esc key, or use the button below:</p>
+ <a href="#demo-links" data-rel="close" data-role="button" data-theme="c" data-icon="delete" data-inline="true">Close panel</a>
- <div data-role="content">
- <h2 id="demo-links">Panels</h2>
-
- <ul data-role="controlgroup" data-type="horizontal" class="localnav">
- <li><a href="index.html" data-role="button" data-transition="fade" class="ui-btn-active">Basics</a></li>
- <li><a href="options.html" data-role="button" data-transition="fade">Options</a></li>
- <li><a href="methods.html" data-role="button" data-transition="fade">Methods</a></li>
- <li><a href="events.html" data-role="button" data-transition="fade">Events</a></li>
- </ul>
-
-
-
- <p><strong>Left</strong> panel examples</p>
- <a href="#leftpanel3" data-role="button" data-inline="true" data-mini="true">Overlay</a>
- <a href="#leftpanel1" data-role="button" data-inline="true" data-mini="true">Reveal</a>
- <a href="#leftpanel2" data-role="button" data-inline="true" data-mini="true">Push</a>
-
- <p><strong>Right</strong> panel examples</p>
- <a href="#rightpanel3" data-role="button" data-inline="true" data-mini="true">Overlay</a>
- <a href="#rightpanel1" data-role="button" data-inline="true" data-mini="true">Reveal</a>
- <a href="#rightpanel2" data-role="button" data-inline="true" data-mini="true">Push</a>
+ </div><!-- /defaultpanel -->
+
+ <!-- Note: all other panels are at the end of the page, scroll down -->
+
+ <div data-role="header" data-theme="f" data-position="fixed">
+ <h1>Panels</h1>
+ <a href="../../" data-icon="home" data-iconpos="notext" data-direction="reverse">Home</a>
+ <a href="../nav.html" data-icon="search" data-iconpos="notext" data-rel="dialog" data-transition="fade">Search</a>
+ </div><!-- /header -->
+
+ <div data-role="content">
+
+ <h2 id="demo-links">Panels</h2>
+
+ <ul data-role="controlgroup" data-type="horizontal" class="localnav">
+ <li><a href="index.html" data-role="button" data-transition="fade" class="ui-btn-active">Basics</a></li>
+ <li><a href="options.html" data-role="button" data-transition="fade">Options</a></li>
+ <li><a href="methods.html" data-role="button" data-transition="fade">Methods</a></li>
+ <li><a href="events.html" data-role="button" data-transition="fade">Events</a></li>
+ </ul>
+
+ <p><strong>Left</strong> panel examples</p>
+ <a href="#leftpanel3" data-role="button" data-inline="true" data-mini="true">Overlay</a>
+ <a href="#leftpanel1" data-role="button" data-inline="true" data-mini="true">Reveal</a>
+ <a href="#leftpanel2" data-role="button" data-inline="true" data-mini="true">Push</a>
+
+ <p><strong>Right</strong> panel examples</p>
+ <a href="#rightpanel3" data-role="button" data-inline="true" data-mini="true">Overlay</a>
+ <a href="#rightpanel1" data-role="button" data-inline="true" data-mini="true">Reveal</a>
+ <a href="#rightpanel2" data-role="button" data-inline="true" data-mini="true">Push</a>
-
-
- <h2>Where panel markup goes in a page</h2>
+ <h2>Where panel markup goes in a page</h2>
- <p>Panels are designed to be as flexible as possible to make it easy to create menus, collapsible columns, drawers, inspectors panes and more. </p>
+ <p>Panels are designed to be as flexible as possible to make it easy to create menus, collapsible columns, drawers, inspectors panes and more. </p>
- <p>A panel must be a sibling to the header, content and footer elements inside a jQuery Mobile page. You can add the panel markup either <em>before</em> or <em>after</em> these elements, but not in between. A panel cannot be placed outside a page, but this constraint will be removed in a future version.</p>
+ <p>A panel must be a sibling to the header, content and footer elements inside a jQuery Mobile page. You can add the panel markup either <em>before</em> or <em>after</em> these elements, but not in between. A panel cannot be placed outside a page, but this constraint will be removed in a future version.</p>
- <p>Here is an example of the panel before the header, content and footer in the source order:</p>
+ <p>Here is an example of the panel before the header, content and footer in the source order:</p>
- <pre><code>
+ <pre><code>
&lt;div data-role=&quot;page&quot;&gt;
- <strong>&lt;div data-role=&quot;panel&quot; id=&quot;mypanel&quot;&gt;</strong>
- &lt;!-- panel content goes here --&gt;
- <strong>&lt;/div&gt;&lt;!-- /panel --&gt;</strong>
+ <strong>&lt;div data-role=&quot;panel&quot; id=&quot;mypanel&quot;&gt;</strong>
+ &lt;!-- panel content goes here --&gt;
+ <strong>&lt;/div&gt;&lt;!-- /panel --&gt;</strong>
- &lt;!-- header --&gt;
- &lt;!-- content --&gt;
- &lt;!-- footer --&gt;
+ &lt;!-- header --&gt;
+ &lt;!-- content --&gt;
+ &lt;!-- footer --&gt;
&lt;/div&gt;&lt;!-- page --&gt;
- </code></pre>
+ </code></pre>
- <p>Alternately, it's possible to add the panel markup <em>after</em> the header, content and footer in the source order, just before the end of the page container. Where in the source order you place the panel markup will depend on how you want to page content to read for people experiencing the page in a C-grade device (HTML only) or for a screen reader.</p>
+ <p>Alternately, it's possible to add the panel markup <em>after</em> the header, content and footer in the source order, just before the end of the page container. Where in the source order you place the panel markup will depend on how you want to page content to read for people experiencing the page in a C-grade device (HTML only) or for a screen reader.</p>
- <h2>Panel markup conventions</h2>
-
- <p>A panel consists of a container with a <code>data-role=&quot;panel&quot;</code> attribute and a unique <code>ID</code>. This <code>ID</code> will be referenced by the link or button to open and close the panel. The most basic panel markup looks like this:</p>
-<pre><code>
+ <h2>Panel markup conventions</h2>
+
+ <p>A panel consists of a container with a <code>data-role=&quot;panel&quot;</code> attribute and a unique <code>ID</code>. This <code>ID</code> will be referenced by the link or button to open and close the panel. The most basic panel markup looks like this:</p>
+
+ <pre><code>
&lt;div <strong>data-role=&quot;panel&quot; id=&quot;mypanel&quot;</strong>&gt;
- &lt;!-- panel content goes here --&gt;
+ &lt;!-- panel content goes here --&gt;
&lt;/div&gt;
-</code></pre>
-
- <p>The <strong>position</strong> of the panel on the screen is set by the <code>data-position</code> attribute. The defaults to <code>left</code>, meaning it will appear from the left edge of the screen. Specify <code>data-position="right"</code> for it to appear from the right edge instead.</p>
+ </code></pre>
+
+ <p>The <strong>position</strong> of the panel on the screen is set by the <code>data-position</code> attribute. The defaults to <code>left</code>, meaning it will appear from the left edge of the screen. Specify <code>data-position="right"</code> for it to appear from the right edge instead.</p>
- <p>The <strong>display mode</strong> of the panel is set by the <code>data-display</code> attribute. The defaults to <code>overlay</code>, meaning the panel will appear on top of the page contents. Specify <code>data-display="reveal"</code> for the panel to sit under the page and reveal as the page slides away. A third mode, <code>data-display="push"</code> animates both the panel and page at the same time.</p>
+ <p>The <strong>display mode</strong> of the panel is set by the <code>data-display</code> attribute. The defaults to <code>reveal</code>, meaning the panel will sit under the page and reveal as the page slides away. Specify <code>data-display="overlay"</code> for the panel to appear on top of the page contents. A third mode, <code>data-display="push"</code> animates both the panel and page at the same time.</p>
- <p>The overlay style panel will always be the smoothest and most reliable display mode, especially if combined with fixed toolbars so we recommend you use that mode if possible.</p>
-
- <p>Here is an example of a panel with a custom position and display option set:</p>
+ <p>Here is an example of a panel with a custom position and display option set:</p>
-<pre><code>
-&lt;div data-role=&quot;panel&quot; id=&quot;mypanel&quot; <strong>data-position=&quot;right&quot; data-display=&quot;reveal&quot;</strong>&gt;
- &lt;!-- panel content goes here --&gt;
+ <pre><code>
+&lt;div data-role=&quot;panel&quot; id=&quot;mypanel&quot; <strong>data-position=&quot;right&quot; data-display=&quot;push&quot;</strong>&gt;
+ &lt;!-- panel content goes here --&gt;
&lt;/div&gt;
-</code></pre>
-
-
+ </code></pre>
- <h2>Opening a panel</h2>
-
- <p>A panel's visibility is toggled by a link somewhere on the page or by calling the panel's <code>open</code> method directly. The defaults place the panel on the left and will open over the page (overlay display mode). Open a panel programmatically like this:</p>
-
- <pre><code>$( "#idofpanel" ).panel( "open" , optionsHash );</code></pre>
+ <h2>Opening a panel</h2>
+
+ <p>A panel's visibility is toggled by a link somewhere on the page or by calling the panel's <code>open</code> method directly. The defaults place the panel on the left and it will be revealed. Open a panel programmatically like this:</p>
-
- <p>To control a panel from a link, point the <code>href</code> to references the <code>ID</code> of the panel you want to toggle (<code>mypanel</code> in the example above). This instructs the framework to bind the link to the panel. This link will toggle the visibility of the panel so tapping it will open the panel, and tapping it again will close it.</p>
-
- <pre><code>
+ <pre><code>$( "#idofpanel" ).panel( "open" , optionsHash );</code></pre>
+
+ <p>To control a panel from a link, point the <code>href</code> to references the <code>ID</code> of the panel you want to toggle (<code>mypanel</code> in the example above). This instructs the framework to bind the link to the panel. This link will toggle the visibility of the panel so tapping it will open the panel, and tapping it again will close it.</p>
+
+ <pre><code>
&lt;a href=&quot;#mypanel&quot;&gt;Open panel&lt;/a&gt;
- </code></pre>
+ </code></pre>
- <a href="#defaultpanel" data-role="button" data-inline="true" data-icon="bars">Default panel</a>
+ <a href="#defaultpanel" data-role="button" data-inline="true" data-icon="bars">Default panel</a>
- <p>When using markup to control panels, you can only have a single panel open at once. Clicking a link to open a panel while one is already open will auto-close the first. This is done to keep the markup-only configuration simple.</p>
+ <p>When using markup to control panels, you can only have a single panel open at once. Clicking a link to open a panel while one is already open will auto-close the first. This is done to keep the markup-only configuration simple.</p>
- <p>That said, it's possible to open multiple panels at once programmatically:</p>
- <pre><code>
+ <p>That said, it's possible to open multiple panels at once programmatically:</p>
+
+ <pre><code>
$( "#idofpanel" )
-.panel( "open" , optionsHash )
-.then( function( options ){
- $( "#idofpanel2" ).panel( "open" , options );
-});
-</code></pre>
+ .panel( "open" , optionsHash )
+ .then( function( options ){
+ $( "#idofpanel2" ).panel( "open" , options );
+ });
+ </code></pre>
- <h2>Closing a panel</h2>
-
- <p>Clicking the link that opened the panel, swiping left or right, or tapping the Esc key will close the panel. To turn off the swipt o close behavior, add the <code>data-swipe-close="false"</code> attribute to the panel.</p>
- <p>By default, panels can also be closed clicking outside the panel onto the page contents. To prevent this behavior, add the <code>data-dismissible="false"</code> attribute to the panel. It's possible to have the panel and page sit side-by-side at wider screen widths and prevent the click-out-to-close behavior only above a certain screen width by applying a media query. See the responsive section below for details. </p>
+ <h2>Closing a panel</h2>
+
+ <p>Clicking the link that opened the panel, swiping left or right, or tapping the Esc key will close the panel. To turn off the swipe to close behavior, add the <code>data-swipe-close="false"</code> attribute to the panel.</p>
- <p>A panel can also be closed by calling the panel's <code>close</code> method directly.</p>
+ <p>By default, panels can also be closed clicking outside the panel onto the page contents. To prevent this behavior, add the <code>data-dismissible="false"</code> attribute to the panel. It's possible to have the panel and page sit side-by-side at wider screen widths and prevent the click-out-to-close behavior only above a certain screen width by applying a media query. See the responsive section below for details. </p>
- <pre><code>$( "#idofpanel" ).panel( "close" );</code></pre>
+ <p>A panel can also be closed by calling the panel's <code>close</code> method directly.</p>
- <p>It's common to also add a close button inside the panel. To add the link that will close the panel, add the <code>data-rel="close"</code> attribute to tell the framework to close that panel when clicked. It's important to ensure that this link also makes sense if JavaScript isn't available, so we recommend that the <code>href</code> points to the ID of the page where the user should jump to when closing. For example, if the button to open the panel is in the header bar that has and ID of <code>my-header</code>, the close link in the panel should be:</p>
+ <pre><code>$( "#idofpanel" ).panel( "close" );</code></pre>
-<pre><code>
-&lt;a href=&quot;#my-header&quot; <strong>data-rel=&quot;close&quot;</strong>&gt;Close panel&lt;/a&gt;
-</code></pre>
+ <p>It's common to also add a close button inside the panel. To add the link that will close the panel, add the <code>data-rel="close"</code> attribute to tell the framework to close that panel when clicked. It's important to ensure that this link also makes sense if JavaScript isn't available, so we recommend that the <code>href</code> points to the ID of the page where the user should jump to when closing. For example, if the button to open the panel is in the header bar that has and ID of <code>my-header</code>, the close link in the panel should be:</p>
-
- <h2>Panel animations</h2>
+ <pre><code>
+&lt;a href=&quot;#my-header&quot; <strong>data-rel=&quot;close&quot;</strong>&gt;Close panel&lt;/a&gt;
+ </code></pre>
- <p>Panels will animate if the browser supports 3D transforms, the same criteria for CSS animation support we use for page transitions. Panel animations use <code>translateX</code> CSS transforms to ensure they are hardware accelerated and smooth.</p>
+
+ <h2>Panel animations</h2>
- <p>The framework has a feature test to detect if the required CSS properties are supported and will fall back to a simple hide/show if not available. After thorough testing, we decided to not animate panels on less capable platforms because the choppier animations weren't a better experience than a simple hide/show.</p>
+ <p>Panels will animate if the browser supports 3D transforms, the same criteria for CSS animation support we use for page transitions. Panel animations use <code>translate3d(x,y,z)</code> CSS transforms to ensure they are hardware accelerated and smooth.</p>
- <p>The <code>animate</code> option allows you to turn off panel animations for all devices. To turn off animations via markup, add the <code>data-animate="false"</code> attribute to the panel container.</p>
+ <p>The framework has a feature test to detect if the required CSS properties are supported and will fall back to a simple hide/show if not available. After thorough testing, we decided to not animate panels on less capable platforms because the choppier animations weren't a better experience than a simple hide/show.</p>
+ <p>The <code>animate</code> option allows you to turn off panel animations for all devices. To turn off animations via markup, add the <code>data-animate="false"</code> attribute to the panel container.</p>
- <h2>Panel + fixed positioning</h2>
- <p>The panel will be displayed with the <code>position:fixed</code> CSS property so their contents will appear no matter how far down the page you're scrolled. The framework also checks to see if the panel contents will fit within the viewport before applying the fixed positioning because this property would prevent the panel contents from scrolling and using <code>overflow</code> is not well supported enough to use at this time.</p>
+ <h2>Panel positioning</h2>
- <p>If a browser doesn't support fixed positioning or if the panel contents are too long to fit within the viewport, the framework will simply display the panel without fixed positioning. If the user has scrolled down and opens a panel, they may need to scroll up to view the contents. Fixed positioning can be disabled by adding the <code>data-position-fixed="false"</code> attribute to the panel.</p>
+ <p>The panel will be displayed with the <code>position: absolute</code> CSS property, meaning it will scroll with the page. When a panel is a opened the framework checks to see if the bottom of the panel contents is in view and, if not, scrolls to the top of the page.</p>
+
+ <p>You can set a panel to <code>position: fixed</code>, so its contents will appear no matter how far down the page you're scrolled, by adding the <code>data-position-fixed="true"</code> attribute to the panel. The framework also checks to see if the panel contents will fit within the viewport before applying the fixed positioning because this property would prevent the panel contents from scrolling and using <code>overflow</code> is not well supported enough to use at this time. If the panel contents are too long to fit within the viewport, the framework will simply display the panel without absolute positioning.</p>
- <p>In general, we recommend that you place the buttons that open the panel at the very top of the screen which is the most common UI pattern for panels. This will avoid the need to scroll and also makes the transitions a bit smoother.</p>
+ <p>In general, we recommend that you place the buttons that open the panel at the very top of the screen which is the most common UI pattern for panels. This will avoid the need to scroll and also makes the transitions a bit smoother.</p>
+
+ <p>Note that there are issues with fixed positioning within Android WebView applications (not the browser) that can cause layout issues, especially when hardware acceleration isn't enabled. We recommend not to use the fixed position panel option if deploying to an Android app. Also, although the framework supports the combination of panels and fixed toolbars, fixed toolbars don't transition together with the page content. You can use the following custom CSS to hide fixed toolbars when a panel is opened.</p>
- <p>Making panels work with fixed toolbars is fairly complex, but the framework supports this combination. Just be aware that the animation performance will not quite a smooth as inline toolbars and that we must hide the fixed toolbar when the panel opens with the reveal or push display mode and you're scrolled down. We recommend using overlay style panels with fixed headers for best results.</p>
-
- <p>Note that there are issues with fixed positioning within webviews within Android applications (not the browser) that can cause layout issues. We recommend that you turn off the fixed position panel option if deploying to an Android app.</p>
- <h2>Styling panels</h2>
+ <h2>Styling panels</h2>
- <p>By default, panels have very simple styles to let you customize them as needed. Panels are essentially just simple blocks with no padding or margins that sit on either side of the page content. </p>
+ <p>By default, panels have very simple styles to let you customize them as needed. Panels are essentially just simple blocks with no margins that sit on either side of the page content. The framework wraps the panel content in a <code>div</code> with class <code>ui-pannel-inner</code> which has a padding of 15 pixels. If needed you can override this with custom CSS or use option <code>classes.panelInner</code> to set a different class name for the <code>div</code></p>
+
+ <p>Panels have a fixed width of 17em (272 pixels) which is narrow enough to still show some of the page contents when open to make clicking out to close easy, and still looks good on wider tablet or desktop screens. The styles to set widths on panels are fairly complex but these can be overridden with CSS as needed.</p>
- <p>Panels have a fixed width of 17em (272 pixels) which is narrow enough to still show some of the page contents when open to make clicking out to close easy, and still looks good on wider tablet or desktop screens. The styles to set widths on panels are fairly complex but these can be overridden with CSS as needed.</p>
+ <p>Other than the width and 100% height styles, panels have very little styling on their own. You can set a theme on the panel by add a <code>data-theme</code> to the panel container or add your own classes to style it as needed.</p>
+
+ <p>Note that adding padding, borders, or margins directly to the panel container will alter the overall dimensions and could cause the positioning and animation to be affected.</p>
- <p>Other than the width and 100% height styles, panels have very little styling on their own. You can set a theme on the panel by add a <code>data-theme</code> to the panel container or add your own classes to style it as needed.</p>
-
- <p>Note that adding padding, borders, or margins directly to the panel container will alter the overall dimensions and could cause the positioning and animation to be affected.</p>
+ <p>To add padding to a panel, we recommend adding a container inside the panel and applying styles to that to avoid any issues. All the examples on this page follow this pattern.</p>
- <p>To add padding to a panel, we recommend adding a container inside the panel and applying styles to that to avoid any issues. All the examples on this page follow this pattern.</p>
- <h2>Making the panel responsive</h2>
+ <h2>Making the panel responsive</h2>
- <p>When the push or reveal display is used, a panel pushes the page aside when it opens. Since some of the page is pushed offscreen, the panel is modal and must be closed to interact with the page content again. On larger screens, you may want to have the panel work more like a collapsible column that can be opened and used alongside the page to take better use of the screen real estate. </p>
- <p>To make the page work alongside the open panel, it needs to re-flow to a narrower width so it will fit next to the panel. This can be done purely with CSS by adding a left or right margin equal to the panel width (17em) to the page contents to force a re-flow. Second, the invisible layer placed over the page for the click out to dismiss behavior is hidden with CSS so you can click on the page and not close the menu. </p>
- <p>Here is an example of these rules wrapped in a media query to only apply this behavior above 35em (560px):</p>
-
- <pre><code>
+ <p>When the push or reveal display is used, a panel pushes the page aside when it opens. Since some of the page is pushed offscreen, the panel is modal and must be closed to interact with the page content again. On larger screens, you may want to have the panel work more like a collapsible column that can be opened and used alongside the page to take better use of the screen real estate. </p>
+ <p>To make the page work alongside the open panel, it needs to re-flow to a narrower width so it will fit next to the panel. This can be done purely with CSS by adding a left or right margin equal to the panel width (17em) to the page contents to force a re-flow. Second, the invisible layer placed over the page for the click out to dismiss behavior is hidden with CSS so you can click on the page and not close the menu. </p>
+ <p>Here is an example of these rules wrapped in a media query to only apply this behavior above 35em (560px):</p>
+
+ <pre><code>
/* wrap push on wide viewports once open */
@media (min-width: 35em){
- .ui-panel-content-wrap.ui-panel-content-wrap-open-complete.ui-panel-content-wrap-display-push,
- .ui-panel-content-wrap.ui-panel-content-wrap-open-complete.ui-panel-content-wrap-display-reveal {
+ .ui-responsive-panel.ui-page-panel-open .ui-panel-content-fixed-toolbar-open.ui-panel-content-fixed-toolbar-display-push,
+ .ui-responsive-panel.ui-page-panel-open .ui-panel-content-fixed-toolbar-open.ui-panel-content-fixed-toolbar-display-reveal,
+ .ui-responsive-panel.ui-page-panel-open .ui-panel-content-wrap-open.ui-panel-content-wrap-display-push,
+ .ui-responsive-panel.ui-page-panel-open .ui-panel-content-wrap-open.ui-panel-content-wrap-display-reveal {
margin-right: 17em;
}
- .ui-panel-content-wrap.ui-panel-content-wrap-open-complete.ui-panel-content-wrap-display-push.ui-panel-content-wrap-position-right,
- .ui-panel-content-wrap.ui-panel-content-wrap-open-complete.ui-panel-content-wrap-display-reveal.ui-panel-content-wrap-position-right {
+ .ui-responsive-panel.ui-page-panel-open .ui-panel-content-fixed-toolbar-open.ui-panel-content-wrap-display-push.ui-panel-content-fixed-toolbar-position-right,
+ .ui-responsive-panel.ui-page-panel-open .ui-panel-content-fixed-toolbar-open.ui-panel-content-wrap-display-reveal.ui-panel-content-fixed-toolbar-position-right,
+ .ui-responsive-panel.ui-page-panel-open .ui-panel-content-wrap-open.ui-panel-content-wrap-display-push.ui-panel-content-wrap-position-right,
+ .ui-responsive-panel.ui-page-panel-open .ui-panel-content-wrap-open.ui-panel-content-wrap-display-reveal.ui-panel-content-wrap-position-right {
margin: 0 0 0 17em;
}
- .ui-panel-dismiss-display-push {
+ .ui-responsive-panel .ui-panel-dismiss-display-push {
display: none;
}
}
- </code></pre>
-
- <h4>Applying a preset breakpoint</h4>
- <p>Included in the widget styles is a breakpoint preset for this behavior that kicks in at 55em (880px). This breakpoint is not applied by default to make it easier for you to write custom breakpoints that work best for your content and design. To apply the breakpoint preset, add the <code>ui-responsive-panel</code> class to the <em>page wrapper</em> (not the panel).</p>
-
-
-
- </div><!-- /content -->
-
- <div data-role="footer" class="footer-docs" data-theme="c">
- <p class="jqm-version"></p>
- <p>&copy; 2012 jQuery Foundation and other contributors</p>
- </div>
-
-
- <!-- Here are a bunch of panels at the end, just before the close page tag -->
-
- <!-- leftpanel1 -->
- <div data-role="panel" id="leftpanel1" data-position="left" data-display="reveal" data-dismissible="true" data-theme="a">
-
- <div class="panel-content">
- <h3>Left Panel: Reveal</h3>
- <p>This panel is positioned on the left with the reveal display mode. The panel markup is <em>after</em> the header, content and footer in the source order.</p>
- <p>To close, click off the panel, swipe left or right, hit the Esc key, or use the button below:</p>
- <a href="#demo-links" data-rel="close" data-role="button" data-theme="a" data-icon="delete" data-inline="true">Close panel</a>
- </div><!-- /content wrapper for padding -->
-
- </div><!-- /leftpanel1 -->
-
-
-
- <!-- leftpanel2 -->
- <div data-role="panel" id="leftpanel2" data-position="left" data-display="push" data-dismissible="true" data-theme="a">
-
- <div class="panel-content">
- <h3>Left Panel: Push</h3>
- <p>This panel is positioned on the left with the push display mode. The panel markup is <em>after</em> the header, content and footer in the source order.</p>
- <p>To close, click off the panel, swipe left or right, hit the Esc key, or use the button below:</p>
- <a href="#demo-links" data-rel="close" data-role="button" data-theme="a" data-icon="delete" data-inline="true">Close panel</a>
- </div><!-- /content wrapper for padding -->
-
- </div><!-- /leftpanel2 -->
-
-
-
- <!-- leftpanel3 -->
- <div data-role="panel" id="leftpanel3" data-position="left" data-display="overlay" data-dismissible="true" data-theme="a">
-
- <div class="panel-content">
- <h3>Left Panel: Overlay</h3>
- <p>This panel is positioned on the left with the overlay display mode. The panel markup is <em>after</em> the header, content and footer in the source order.</p>
- <p>To close, click off the panel, swipe left or right, hit the Esc key, or use the button below:</p>
- <a href="#demo-links" data-rel="close" data-role="button" data-theme="a" data-icon="delete" data-inline="true">Close panel</a>
- </div><!-- /content wrapper for padding -->
-
- </div><!-- /leftpanel3 -->
-
-
-
- <!-- rightpanel1 -->
- <div data-role="panel" id="rightpanel1" data-position="right" data-display="reveal" data-dismissible="true" data-theme="b">
-
- <div class="panel-content">
- <h3>Right Panel: Reveal</h3>
- <p>This panel is positioned on the right with the reveal display mode. The panel markup is <em>after</em> the header, content and footer in the source order.</p>
- <p>To close, click off the panel, swipe left or right, hit the Esc key, or use the button below:</p>
- <a href="#demo-links" data-rel="close" data-role="button" data-theme="c" data-icon="delete" data-inline="true">Close panel</a>
- </div><!-- /content wrapper for padding -->
-
- </div><!-- /rightpanel1 -->
-
+ </code></pre>
+
+ <h4>Applying a preset breakpoint</h4>
+
+ <p>Included in the widget styles is a breakpoint preset for this behavior that kicks in at 55em (880px). This breakpoint is not applied by default to make it easier for you to write custom breakpoints that work best for your content and design. To apply the breakpoint preset, add the <code>ui-responsive-panel</code> class to the <em>page wrapper</em> (not the panel).</p>
+
+ </div><!-- /content -->
- <!-- rightpanel2 -->
- <div data-role="panel" id="rightpanel2" data-position="right" data-display="push" data-dismissible="true" data-theme="b">
-
- <div class="panel-content">
- <h3>Right Panel: Push</h3>
- <p>This panel is positioned on the right with the push display mode. The panel markup is <em>after</em> the header, content and footer in the source order.</p>
- <p>To close, click off the panel, swipe left or right, hit the Esc key, or use the button below:</p>
- <a href="#demo-links" data-rel="close" data-role="button" data-theme="c" data-icon="delete" data-inline="true">Close panel</a>
- </div><!-- /content wrapper for padding -->
-
- </div><!-- /rightpanel2 -->
-
-
- <!-- rightpanel3 -->
- <div data-role="panel" id="rightpanel3" data-position="right" data-display="overlay" data-dismissible="true" data-theme="b">
-
- <div class="panel-content">
- <h3>Right Panel: Overlay</h3>
- <p>This panel is positioned on the right with the overlay display mode. The panel markup is <em>after</em> the header, content and footer in the source order.</p>
- <p>To close, click off the panel, swipe left or right, hit the Esc key, or use the button below:</p>
- <a href="#demo-links" data-rel="close" data-role="button" data-theme="c" data-icon="delete" data-inline="true">Close panel</a>
- </div><!-- /content wrapper for padding -->
-
- </div><!-- /rightpanel3 -->
+ <div data-role="footer" class="footer-docs" data-theme="c">
+ <p class="jqm-version"></p>
+ <p>&copy; 2012 jQuery Foundation and other contributors</p>
+ </div>
+
+ <!-- Here are a bunch of panels at the end, just before the close page tag -->
+
+ <!-- leftpanel1 -->
+ <div data-role="panel" id="leftpanel1" data-position="left" data-display="reveal" data-dismissible="true" data-theme="a">
+
+ <h3>Left Panel: Reveal</h3>
+ <p>This panel is positioned on the left with the reveal display mode. The panel markup is <em>after</em> the header, content and footer in the source order.</p>
+ <p>To close, click off the panel, swipe left or right, hit the Esc key, or use the button below:</p>
+ <a href="#demo-links" data-rel="close" data-role="button" data-theme="a" data-icon="delete" data-inline="true">Close panel</a>
+
+ </div><!-- /leftpanel1 -->
+
+
+ <!-- leftpanel2 -->
+ <div data-role="panel" id="leftpanel2" data-position="left" data-display="push" data-dismissible="true" data-theme="a">
+
+ <h3>Left Panel: Push</h3>
+ <p>This panel is positioned on the left with the push display mode. The panel markup is <em>after</em> the header, content and footer in the source order.</p>
+ <p>To close, click off the panel, swipe left or right, hit the Esc key, or use the button below:</p>
+ <a href="#demo-links" data-rel="close" data-role="button" data-theme="a" data-icon="delete" data-inline="true">Close panel</a>
+
+ </div><!-- /leftpanel2 -->
+
+
+ <!-- leftpanel3 -->
+ <div data-role="panel" id="leftpanel3" data-position="left" data-display="overlay" data-dismissible="true" data-theme="a">
+
+ <h3>Left Panel: Overlay</h3>
+ <p>This panel is positioned on the left with the overlay display mode. The panel markup is <em>after</em> the header, content and footer in the source order.</p>
+ <p>To close, click off the panel, swipe left or right, hit the Esc key, or use the button below:</p>
+ <a href="#demo-links" data-rel="close" data-role="button" data-theme="a" data-icon="delete" data-inline="true">Close panel</a>
+
+ </div><!-- /leftpanel3 -->
+
+
+ <!-- rightpanel1 -->
+ <div data-role="panel" id="rightpanel1" data-position="right" data-display="reveal" data-dismissible="true" data-theme="b">
+
+ <h3>Right Panel: Reveal</h3>
+ <p>This panel is positioned on the right with the reveal display mode. The panel markup is <em>after</em> the header, content and footer in the source order.</p>
+ <p>To close, click off the panel, swipe left or right, hit the Esc key, or use the button below:</p>
+ <a href="#demo-links" data-rel="close" data-role="button" data-theme="c" data-icon="delete" data-inline="true">Close panel</a>
+
+ </div><!-- /rightpanel1 -->
+
+
+ <!-- rightpanel2 -->
+ <div data-role="panel" id="rightpanel2" data-position="right" data-display="push" data-dismissible="true" data-theme="b">
+
+ <h3>Right Panel: Push</h3>
+ <p>This panel is positioned on the right with the push display mode. The panel markup is <em>after</em> the header, content and footer in the source order.</p>
+ <p>To close, click off the panel, swipe left or right, hit the Esc key, or use the button below:</p>
+ <a href="#demo-links" data-rel="close" data-role="button" data-theme="c" data-icon="delete" data-inline="true">Close panel</a>
+
+ </div><!-- /rightpanel2 -->
+
+
+ <!-- rightpanel3 -->
+ <div data-role="panel" id="rightpanel3" data-position="right" data-display="overlay" data-dismissible="true" data-theme="b">
+
+ <h3>Right Panel: Overlay</h3>
+ <p>This panel is positioned on the right with the overlay display mode. The panel markup is <em>after</em> the header, content and footer in the source order.</p>
+ <p>To close, click off the panel, swipe left or right, hit the Esc key, or use the button below:</p>
+ <a href="#demo-links" data-rel="close" data-role="button" data-theme="c" data-icon="delete" data-inline="true">Close panel</a>
+
+ </div><!-- /rightpanel3 -->
- </div><!-- /page -->
- </body>
+ </div><!-- /page -->
+</body>
</html>
View
51 docs/panels/options.html
@@ -30,8 +30,6 @@
<li><a href="events.html" data-role="button" data-transition="fade">Events</a></li>
</ul>
-
-
<dl>
<dt><code>animate</code> default: true</dt>
@@ -49,12 +47,11 @@
<dt><code>position</code> default: "left"</dt>
<dd>The side of the screen the panel appears on. Values can be "left" or "right". Also available via the <code>data-position</code> attribute on the link that opens the panel.</dd>
- <dt><code>positionFixed</code> default: "true"</dt>
- <dd>Sets whether the panel has fixed positioning so the contents are in view even if the page is scrolled down. This also allows the page to scroll while the panel stays fixed. If set to true, the fixed positioning is only applied if a feature test passes and will fallback to static positioning so the panel will scroll with the document. We recommend disabling this feature when panels are used withing Android apps because of poor performance and display issues. Also available via the <code>data-position-fixed</code> attribute on the panel.</dd>
+ <dt><code>positionFixed</code> default: "false"</dt>
+ <dd>Sets whether the panel has fixed positioning so the contents are in view even if the page is scrolled down. This also allows the page to scroll while the panel stays fixed. We recommend not to enable this feature when panels are used withing Android apps because of poor performance and display issues. Also available via the <code>data-position-fixed</code> attribute on the panel.</dd>
<dt><code>swipeClose</code> default: "true"</dt>
<dd>Sets whether the panel can be closed by swiping left or right over the panel. Also available via the <code>data-swipe-close</code> attribute on the panel.</dd>
-
<dt><code>theme</code> default: null</dt>
<dd>Theme swatch for the panel. Can be any valid swatch letter in your theme (a-z). Also available via the <code>data-theme</code> attribute on the panel container.</dd>
@@ -63,11 +60,9 @@
<h3>Classes Option</h3>
<p>The <code>classes</code> option define the structural classnames that the plugin uses. This is only configurable via JavaScript because it expects an object literal value.</p>
-
-
-
<dl>
+
<dt><code>classes.panel</code> default: "ui-panel"</dt>
<dd>Class added to the panel.</dd>
@@ -77,8 +72,11 @@
<dt><code>classes.panelClosed</code> default: "ui-panel-closed"</dt>
<dd>Class added to the panel when closed.</dd>
- <dt><code>classes.panelUnfixed</code> default: "ui-panel-unfixed"</dt>
- <dd>Class added to the panel when fixed positioning is not applied.</dd>
+ <dt><code>classes.panelFixed</code> default: "ui-panel-fixed"</dt>
+ <dd>Class added to the panel when fixed positioning is applied.</dd>
+
+ <dt><code>classes.panelInner</code> default: "ui-panel-inner"</dt>
+ <dd>Class added to the panel contents wrapper div.</dd>
<dt><code>classes.modal</code> default: "ui-panel-dismiss"</dt>
<dd>Class added to the overlay on the page to dismiss the panel when hidden.</dd>
@@ -86,29 +84,32 @@
<dt><code>classes.modalOpen</code> default: "ui-panel-dismiss-open"</dt>
<dd>Class added to the invisible overlay over the page when the panel is open. Used to dismiss the panel.</dd>
- <dt><code>classes.openComplete</code> default: "ui-panel-open-complete"</dt>
- <dd>Class added to the page when the panel animation is complete.</dd>
+ <dt><code>classes.pagePanel</code> default: "ui-page-panel"</dt>
+ <dd>Class added to the page container when a panel widget is present.</dd>
+
+ <dt><code>classes.pagePanelOpen</code> default: "ui-page-panel-open"</dt>
+ <dd>Class added to the page when a panel is open.</dd>
<dt><code>classes.contentWrap</code> default: "ui-panel-content-wrap"</dt>
- <dd>Class added to the wrapper injected around the page contents (header, content, footer), needed for positioning of the panel.</dd>
+ <dd>Class added to the wrapper injected around the page contents (header, content, footer), needed for transitioning the page contents. Fixed toolbars are not wrapped.</dd>
<dt><code>classes.contentWrapOpen</code> default: "ui-panel-content-wrap-open"</dt>
- <dd>Class added to the wrapper injected around the page contents (header, content, footer) when the panel is opening. Used for targeting hardware acceleration only during transitions.</dd>
+ <dd>Class added to the page contents wrapper when the panel is opening.</dd>
- <dt><code>classes.wrapOpenComplete</code> default: "ui-panel-content-wrap-open-complete"</dt>
- <dd>Class added to the page contents wrapper after the open animation is complete.</dd>
-
- <dt><code>classes.wrapOpenClosed</code> default: "ui-panel-content-wrap-closed"</dt>
+ <dt><code>classes.contentWrapClosed</code> default: "ui-panel-content-wrap-closed"</dt>
<dd>Class added to the page contents wrapper after the close animation is complete.</dd>
- <dt><code>classes.pageBlock</code> default: "ui-panel-page-block"</dt>
- <dd>Class added to the page container to suppress scrolling horizontally</dd>
-
- <dt><code>classes.pagePanel</code> default: "ui-page-panel"</dt>
- <dd>Class added to the page container when a panel widget is present.</dd>
+ <dt><code>classes.contentFixedToolbar</code> default: "ui-panel-fixed-toolbar-wrap"</dt>
+ <dd>Class added to fixed header and footer, needed for transitioning fixed toolbars.</dd>
+
+ <dt><code>classes.contentFixedToolbarOpen</code> default: "ui-panel-content-fixed-toolbar-open"</dt>
+ <dd>Class added to fixed toolbars when the panel is opening.</dd>
+
+ <dt><code>classes.contentFixedToolbarClosed</code> default: "ui-panel-content-fixed-toolbar-closed"</dt>
+ <dd>Class added to fixed toolbars after the close animation is complete.</dd>
- <dt><code>classes.cssTransform3d</code> default: "ui-panel-3dtransforms"</dt>
- <dd>Class added to the page container when the 3D transform feature test is true.</dd>
+ <dt><code>classes.animate</code> default: "ui-panel-animate"</dt>
+ <dd>Class added to the panel, page contents wrapper and fixed toolbars when option <code>animate</code> is <code>true</code> and the 3D transform feature test returns <code>true</code>.</dd>
</dl>
View
2  js/widgets/fixedToolbar.js
@@ -17,7 +17,7 @@ define( [ "jquery", "../jquery.mobile.widget", "../jquery.mobile.core", "../jque
transition: "slide", //can be none, fade, slide (slide maps to slideup or slidedown)
fullscreen: false,
tapToggle: true,
- tapToggleBlacklist: "a, button, input, select, textarea, .ui-header-fixed, .ui-footer-fixed, .ui-popup",
+ tapToggleBlacklist: "a, button, input, select, textarea, .ui-header-fixed, .ui-footer-fixed, .ui-popup, .ui-panel, .ui-panel-dismiss-open",
hideDuringFocus: "input, textarea, select",
updatePagePadding: true,
trackPersistentToolbars: true,
View
235 js/widgets/panel.js
@@ -15,26 +15,28 @@ $.widget( "mobile.panel", $.mobile.widget, {
panel: "ui-panel",
panelOpen: "ui-panel-open",
panelClosed: "ui-panel-closed",
+ panelFixed: "ui-panel-fixed",
+ panelInner: "ui-panel-inner",
modal: "ui-panel-dismiss",
modalOpen: "ui-panel-dismiss-open",
- openComplete: "ui-panel-open-complete",
+ pagePanel: "ui-page-panel",
+ pagePanelOpen: "ui-page-panel-open",
contentWrap: "ui-panel-content-wrap",
contentWrapOpen: "ui-panel-content-wrap-open",
contentWrapClosed: "ui-panel-content-wrap-closed",
- panelUnfixed: "ui-panel-unfixed",
- contentWrapOpenComplete: "ui-panel-content-wrap-open-complete",
- pageBlock: "ui-panel-page-block",
- pagePanel: "ui-page-panel",
- cssTransform3d: "ui-panel-3dtransforms"
+ contentFixedToolbar: "ui-panel-content-fixed-toolbar",
+ contentFixedToolbarOpen: "ui-panel-content-fixed-toolbar-open",
+ contentFixedToolbarClosed: "ui-panel-content-fixed-toolbar-closed",
+ animate: "ui-panel-animate"
},
animate: true,
theme: null,
position: "left",
dismissible: true,
- display: "overlay", //accepts reveal, push, overlay
+ display: "reveal", //accepts reveal, push, overlay
initSelector: ":jqmData(role='panel')",
swipeClose: true,
- positionFixed: true
+ positionFixed: false
},
_panelID: null,
@@ -42,126 +44,161 @@ $.widget( "mobile.panel", $.mobile.widget, {
_page: null,
_modal: null,
_wrapper: null,
+ _fixedToolbar: null,
_create: function() {
var self = this,
$el = self.element,
- _getWrapper = function(){
+ _getPageTheme = function() {
+ var $theme = $.data( self._page[0], "mobilePage" ).options.theme,
+ $pageThemeClass = "ui-body-" + $theme;
+ return $pageThemeClass;
+ }
+ _getPanelInner = function() {
+ var $pannelInner = $el.find( "." + self.options.classes.panelInner );
+ if ( $pannelInner.length === 0 ) {
+ $pannelInner = $el.children().wrapAll( '<div class="' + self.options.classes.panelInner + '" />' ).parent();
+ }
+ return $pannelInner;
+ },
+ _getWrapper = function() {
var $wrapper = self._page.find( "." + self.options.classes.contentWrap );
- if( $wrapper.length === 0 ){
- $wrapper = self._page.find( ".ui-header, .ui-content, .ui-footer" ).wrapAll( '<div class="' + self.options.classes.contentWrap + '" />' ).parent();
- if( $.support.cssTransform3d && !!self.options.positionFixed ) {
- $wrapper.addClass( self.options.classes.cssTransform3d );
+ if ( $wrapper.length === 0 ) {
+ $wrapper = self._page.children( ".ui-header:not(.ui-header-fixed), .ui-content:not(.ui-popup), .ui-footer:not(.ui-footer-fixed)" ).wrapAll( '<div class="' + self.options.classes.contentWrap + ' ' + _getPageTheme() + '" />' ).parent();
+ if ( $.support.cssTransform3d && !!self.options.animate ) {
+ $wrapper.addClass( self.options.classes.animate );
}
}
return $wrapper;
+ },
+ _getFixedToolbar = function() {
+ var $fixedToolbar = self._page.find( "." + self.options.classes.contentFixedToolbar );
+ if ( $fixedToolbar.length === 0 ) {
+ $fixedToolbar = self._page.find( ".ui-header-fixed, .ui-footer-fixed" ).addClass( self.options.classes.contentFixedToolbar );
+ if ( $.support.cssTransform3d && !!self.options.animate ) {
+ $fixedToolbar.addClass( self.options.classes.animate );
+ }
+ }
+ return $fixedToolbar;
};
// expose some private props to other methods
self._panelID = $el.attr( "id" );
self._closeLink = $el.find( ":jqmData(rel='close')" );
self._page = $el.closest( ":jqmData(role='page')" );
+ self._pageTheme = _getPageTheme();
+ self._pannelInner = _getPanelInner();
self._wrapper = _getWrapper();
+ self._fixedToolbar = _getFixedToolbar();
self._addPanelClasses();
self._wrapper.addClass( this.options.classes.contentWrapClosed );
-
+ self._fixedToolbar.addClass( this.options.classes.contentFixedToolbarClosed );
+
+ // add class to page so we can set "overflow-x: hidden;" for it to fix Android zoom issue
+ self._page.addClass( self.options.classes.pagePanel );
+
// if animating, add the class to do so
- if ( $.support.cssTransform3d && self.options.animate ) {
- this.element.add( self._wrapper ).addClass( "ui-panel-animate" );
+ if ( $.support.cssTransform3d && !!self.options.animate ) {
+ this.element.addClass( self.options.classes.animate );
}
self._bindCloseEvents();
self._bindLinkListeners();
self._bindPageEvents();
- if( self.options.dismissible ){
+ if ( self.options.dismissible ) {
self._createModal();
}
},
- _createModal: function( options ){
+ _createModal: function( options ) {
var self = this;
- self._modal = $( "<div class='" + self.options.classes.modal + " " + self.options.display + "-" + self.options.position +"' data-panelid='" + self._panelID + "'></div>" )
- .on( "mousedown" , function(){
+ self._modal = $( "<div class='" + self.options.classes.modal + "' data-panelid='" + self._panelID + "'></div>" )
+ .on( "mousedown" , function() {
self.close();
})
.appendTo( this._page );
},
- _getPosDisplayClasses: function( prefix ){
+ _getPosDisplayClasses: function( prefix ) {
return prefix + "-position-" + this.options.position + " " + prefix + "-display-" + this.options.display;
},
- _getPanelClasses: function(){
+ _getPanelClasses: function() {
var panelClasses = this.options.classes.panel +
- " " + this._getPosDisplayClasses( this.options.classes.panel ) +
- " " + this.options.classes.panelClosed;
+ " " + this._getPosDisplayClasses( this.options.classes.panel ) +
+ " " + this.options.classes.panelClosed;
- if( this.options.theme ){
+ if ( this.options.theme ) {
panelClasses += " ui-body-" + this.options.theme;
}
-
- if( $.support.cssTransform3d && !!this.options.positionFixed ) {
- panelClasses += " " + this.options.classes.cssTransform3d;
+ if ( !!this.options.positionFixed ) {
+ panelClasses += " " + this.options.classes.panelFixed;
}
return panelClasses;
},
- _addPanelClasses: function(){
+ _addPanelClasses: function() {
this.element.addClass( this._getPanelClasses() );
},
- _bindCloseEvents: function(){
+ _bindCloseEvents: function() {
var self = this;
- self._closeLink.on( "click.panel" , function( e ){
+ self._closeLink.on( "click.panel" , function( e ) {
e.preventDefault();
self.close();
return false;
});
},
- _positionPanel: function(){
- if ( this.element.height() > $.mobile.getScreenHeight() ) {
+ _positionPanel: function() {
+ var self = this,
+ pannelInnerHeight = self._pannelInner.height();
+
+ if ( ( pannelInnerHeight > $.mobile.getScreenHeight() ) || !this.options.positionFixed ) {
this._unfixPanel();
- this._scrollIntoView();
- }
- else {
+ this._scrollIntoView( pannelInnerHeight );
+ } else {
this._fixPanel();
}
},
- _scrollIntoView: function(){
- if( $(window).scrollTop() > $.mobile.getScreenHeight() ){
- window.scrollTo( 0, 0);
- }
+ _scrollIntoView: function( pannelInnerHeight ) {
+ if ( pannelInnerHeight < $( window ).scrollTop() ) {
+ window.scrollTo( 0, 0 );
+ }
},
- _bindFixListener: function(){
+ _bindFixListener: function() {
this._on( $( window ), { "throttledresize": "_positionPanel" });
},
- _unbindFixListener: function(){
+ _unbindFixListener: function() {
this._off( $( window ), "throttledresize" );
},
- _unfixPanel: function(){
- this.element.addClass( this.options.classes.panelUnfixed );
+ _unfixPanel: function() {
+ if ( !!this.options.positionFixed ) {
+ this.element.removeClass( this.options.classes.panelFixed );
+ }
},
- _fixPanel: function(){
- this.element.removeClass( this.options.classes.panelUnfixed );
+ _fixPanel: function() {
+ if ( !!this.options.positionFixed ) {
+ this.element.addClass( this.options.classes.panelFixed );
+ }
},
- _bindLinkListeners: function(){
+ _bindLinkListeners: function() {
var self = this;
this._page.on( "click.panel" , "a", function( e ) {
- if( this.href.split( "#" )[ 1 ] === self._panelID && self._panelID !== undefined ){
+ if ( this.href.split( "#" )[ 1 ] === self._panelID && self._panelID !== undefined ) {
e.preventDefault();
var $link = $( this );
$link.addClass( $.mobile.activeBtnClass );
- self.element.one( "panelopen panelclose", function(){
+ self.element.one( "panelopen panelclose", function() {
$link.removeClass( $.mobile.activeBtnClass );
});
self.toggle();
@@ -170,7 +207,7 @@ $.widget( "mobile.panel", $.mobile.widget, {
});
},
- _bindPageEvents: function(){
+ _bindPageEvents: function() {
var self = this;
if( !!this.options.swipeClose ){
self.element
@@ -181,14 +218,14 @@ $.widget( "mobile.panel", $.mobile.widget, {
}
self._page
// Close immediately if another panel on the page opens
- .on( "panelbeforeopen", function( e ){
- if( self._open && e.target !== self.element[ 0 ] ){
+ .on( "panelbeforeopen", function( e ) {
+ if ( self._open && e.target !== self.element[ 0 ] ) {
self.close( true );
}
})
// clean up open panels after page hide
.on( "pagebeforehide", function( e ) {
- if( self._open ){
+ if ( self._open ) {
self.close( true );
}
})
@@ -206,95 +243,120 @@ $.widget( "mobile.panel", $.mobile.widget, {
_contentWrapOpenClasses: null,
_modalOpenClasses: null,
- open: function( immediate ){
- if( !this._open ){
+ open: function( immediate ) {
+ if ( !this._open ) {
var self = this,
o = self.options,
- complete = function(){
- self.element.add( self._wrapper ).unbind( self._transitionEndEvents, complete );
- self.element.addClass( o.classes.openComplete );
- self._wrapper.addClass( o.classes.contentWrapOpenComplete );
- self._page.addClass( o.classes.pageBlock );
+ complete = function() {
+ self.element.add( self._wrapper ).add( self._fixedToolbar ).off( self._transitionEndEvents, complete );
+ self._page.addClass( o.classes.pagePanelOpen );
self._positionPanel();
self._bindFixListener();
self._trigger( "open" );
};
- if( this.element.closest( ".ui-page-active" ).length < 0 ){
+ if ( this.element.closest( ".ui-page-active" ).length < 0 ) {
immediate = true;
}
self._trigger( "beforeopen" );
- if ( !immediate && $.support.cssTransform3d && o.animate ) {
- self.element.add( self._wrapper ).on( self._transitionEndEvents , complete );
- } else{
- setTimeout( complete , 0 );
+ if ( !immediate && $.support.cssTransform3d && !!o.animate ) {
+ self.element.add( self._wrapper ).add( self._fixedToolbar ).on( self._transitionEndEvents, complete );
+ } else {
+ setTimeout( complete, 0 );
+ }
+ if ( self.options.theme ) {
+ self._page.removeClass( self._pageTheme ).addClass( "ui-body-" + self.options.theme );
}
self.element.removeClass( o.classes.panelClosed );
self.element.addClass( o.classes.panelOpen );
self._contentWrapOpenClasses = self._getPosDisplayClasses( o.classes.contentWrap );
self._wrapper.removeClass( o.classes.contentWrapClosed );
self._wrapper.addClass( self._contentWrapOpenClasses + " " + o.classes.contentWrapOpen );
+ self._fixedToolbarOpenClasses = self._getPosDisplayClasses( o.classes.contentFixedToolbar );
+ self._fixedToolbar.removeClass( o.classes.contentFixedToolbarClosed );
+ self._fixedToolbar.addClass( self._fixedToolbarOpenClasses + " " + o.classes.contentFixedToolbarOpen );
self._modalOpenClasses = self._getPosDisplayClasses( o.classes.modal ) + " " + o.classes.modalOpen;
- if( this._modal ) {
+ if ( this._modal ) {
self._modal.addClass( self._modalOpenClasses );
}
self._open = true;
}
},
- close: function( immediate ){
- if( this._open ){
+ close: function( immediate ) {
+ if ( this._open ) {
var o = this.options,
self = this,
- complete = function(){
- self.element.add( self._wrapper ).off( self._transitionEndEvents , complete );
+ complete = function() {
+ if ( self.options.theme ) {
+ self._page.removeClass( "ui-body-" + self.options.theme ).addClass( self._pageTheme );
+ }
+ self.element.add( self._wrapper ).add( self._fixedToolbar ).off( self._transitionEndEvents, complete );
self.element.addClass( o.classes.panelClosed );
self._wrapper.removeClass( self._contentWrapOpenClasses );
self._wrapper.addClass( o.classes.contentWrapClosed );
- self._page.removeClass( o.classes.pageBlock );
+ self._fixedToolbar.removeClass( self._fixedToolbarOpenClasses );
+ self._fixedToolbar.addClass( o.classes.contentFixedToolbarClosed );
+ self._page.removeClass( o.classes.pagePanelOpen );
self._fixPanel();
self._unbindFixListener();
self._trigger( "close" );
};
- if( this.element.closest( ".ui-page-active" ).length < 0 ){
+ if ( this.element.closest( ".ui-page-active" ).length < 0 ) {
immediate = true;
}
self._trigger( "beforeclose" );
- if ( !immediate && $.support.cssTransform3d && o.animate ) {
- self.element.add( self._wrapper ).on( self._transitionEndEvents , complete );
+ if ( !immediate && $.support.cssTransform3d && !!o.animate ) {
+ self.element.add( self._wrapper ).add( self._fixedToolbar ).on( self._transitionEndEvents, complete );
} else{
- setTimeout( complete , 0 );
+ setTimeout( complete, 0 );
}
- self.element.removeClass( o.classes.panelOpen + " " + o.classes.openComplete );
- if( this._modal ) {
+ self.element.removeClass( o.classes.panelOpen );
+ if ( this._modal ) {
self._modal.removeClass( self._modalOpenClasses );
}
- self._wrapper.removeClass( o.classes.contentWrapOpen + " " + o.classes.contentWrapOpenComplete );
+ self._wrapper.removeClass( o.classes.contentWrapOpen );
+ self._fixedToolbar.removeClass( o.classes.contentFixedToolbarOpen );
self._open = false;
}
},
- toggle: function( options ){
+ toggle: function( options ) {
this[ this._open ? "close" : "open" ]();
},
_transitionEndEvents: "webkitTransitionEnd oTransitionEnd otransitionend transitionend msTransitionEnd",
- _destroy: function(){
+ _destroy: function() {
var classes = this.options.classes,
+ theme = this.options.theme,
hasOtherSiblingPanels = this.element.siblings( "." + classes.panel ).length;
// create
- if( !hasOtherSiblingPanels ) {
+ if ( !hasOtherSiblingPanels ) {
this._wrapper.children().unwrap();
this._page.find( "a" ).unbind( "panelopen panelclose" );
- } else if( this._open ) {
- this._wrapper.removeClass( [ classes.contentWrapOpen, classes.contentWrapOpenComplete ].join( " " ) );
+ this._page.removeClass( classes.pagePanel );
+ if ( this._open ) {
+ this._page.removeClass( classes.pagePanelOpen );
+ if ( theme ) {
+ self._page.removeClass( "ui-body-" + theme ).addClass( self._pageTheme );
+ }
+ }
+ } else if ( this._open ) {
+ this._wrapper.removeClass( classes.contentWrapOpen );
+ this._fixedToolbar.removeClass( classes.contentFixedToolbarOpen );
+ this._page.removeClass( classes.pagePanelOpen );
+ if ( theme ) {
+ self._page.removeClass( "ui-body-" + theme ).addClass( self._pageTheme );
+ }
}
+
+ this._pannelInner.children().unwrap();
this.element.removeClass( [ this._getPanelClasses(), classes.panelAnimate ].join( " " ) )
.off( "swipe.panel" )
@@ -304,18 +366,16 @@ $.widget( "mobile.panel", $.mobile.widget, {
this._closeLink.off( "click.panel" );
- if( this._modal ) {
+ if ( this._modal ) {
this._modal.remove();
}
// open and close
this.element.off( this._transitionEndEvents )
- .removeClass( [ classes.openComplete, classes.panelUnfixed, classes.panelClosed, classes.panelOpen ].join( " " ) );
- this._page.removeClass( classes.pageBlock );
+ .removeClass( [ classes.panelUnfixed, classes.panelClosed, classes.panelOpen ].join( " " ) );
}
});
-
//auto self-init widgets
$( document ).bind( "pagecreate create", function( e ) {
$.mobile.panel.prototype.enhanceWithin( e.target );
@@ -325,4 +385,3 @@ $( document ).bind( "pagecreate create", function( e ) {
//>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
});
//>>excludeEnd("jqmBuildExclude");
-
View
14 tests/unit/panel/panel_core.js
@@ -35,10 +35,8 @@
ok( $panel.hasClass( "ui-panel-display-" + defaults.display ), "display class is added per the default" );
ok( $panel.hasClass( "ui-panel-position-" + defaults.position ), "position class is added per the default" );
- equal( $panel.hasClass( "ui-panel-animate" ), $.support.cssTransform3d, "animate class is present by default when supported" );
- equal( $page.hasClass( defaults.classes.pageChildAnimations ), $.support.cssTransform3d, "animation wrapper class added to page" );
+ equal( $panel.hasClass( defaults.classes.animate ), $.support.cssTransform3d, "animate class is present by default when supported" );
ok( $panel.hasClass( defaults.classes.panelClosed ), "panel is closed by default" );
- equal( $panel.hasClass( defaults.classes.cssTransform3d ), $.support.cssTransform3d, "transforms class added to page" );
});
asyncTest( "expected open, close events", function() {
@@ -60,7 +58,7 @@
});
asyncTest( "classes modified by open", function() {
- expect( 14 );
+ expect( 12 );
var $panel = $( "#panel-test-open" ),
$page = getPageFromPanel( $panel ),
@@ -71,7 +69,6 @@
$panel.one( "panelopen", function( event ) {
ok( !$openButton.hasClass( $.mobile.activeBtnClass ), "button doesn't have active class" );
- ok( $page.hasClass( defaults.classes.pageBlock ), "page block class added to page" );
ok( !$panel.hasClass( defaults.classes.panelClosed ), "closed class removed" );
ok( $panel.hasClass( defaults.classes.panelOpen ), "open class added" );
@@ -82,16 +79,15 @@
var prefix = defaults.classes.contentWrap;
ok( $wrapper.hasClass( prefix + "-position-left" ), "wrapper position class" );
- ok( $wrapper.hasClass( prefix + "-display-overlay" ), "wrapper display type class" );
+ ok( $wrapper.hasClass( prefix + "-display-reveal" ), "wrapper display type class" );
ok( $modal.hasClass( defaults.classes.modalOpen ), "modal open class" );
prefix = defaults.classes.modal;
ok( $modal.hasClass( prefix + "-position-left" ), "modal position class" );
- ok( $modal.hasClass( prefix + "-display-overlay" ), "modal display type class" );
+ ok( $modal.hasClass( prefix + "-display-reveal" ), "modal display type class" );
// complete
- ok( $panel.hasClass( defaults.classes.openComplete ), "open complete class" );
- ok( $wrapper.hasClass( defaults.classes.contentWrapOpenComplete ), "wrapper open complete class" );
+ ok( $page.hasClass( defaults.classes.pagePanelOpen ), "page panel open class added to page" );
// TODO test positioning when panel height > screen height
// TODO test rebind resize after complete
Please sign in to comment.
Something went wrong with that request. Please try again.