From 82d747f688f67f117dff3eed2393b42d4a572a8a Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Mon, 26 Aug 2013 20:32:57 -0500 Subject: [PATCH] working panel --- dist/framework.css | 35 +++++++----------- example/panels.html | 12 ++++-- js/framework/framework-panel.js | 55 ++++++++++++++++++++++++++++ scss/framework/_theme-variables.scss | 3 +- scss/framework/structure/_base.scss | 12 +----- scss/framework/structure/_panel.scss | 27 +++++++------- scss/framework/theme/_panel.scss | 3 +- 7 files changed, 95 insertions(+), 52 deletions(-) create mode 100644 js/framework/framework-panel.js diff --git a/dist/framework.css b/dist/framework.css index a5830ce91a..eb90b0e65f 100644 --- a/dist/framework.css +++ b/dist/framework.css @@ -23,16 +23,6 @@ ul { margin: 0; padding: 0; } -body > section { - position: relative; - z-index: 100; - width: 100%; - min-width: 100%; - max-width: 100%; - height: 100%; - min-height: 100%; - max-height: 100%; } - main { position: fixed; top: 0; @@ -40,6 +30,7 @@ main { bottom: 0; left: 0; overflow: auto; + width: 100%; -webkit-overflow-scrolling: touch; } /* Hack to force all relatively and absolutely positioned elements still render while scrolling @@ -230,24 +221,25 @@ a.list-item { margin-bottom: 0; line-height: 1.3; } -/* the page content the panel should move around */ -.panel-page-container > * { - width: 400px; - left: 100px; } - /* the container of panel content to show */ .panel-content { + display: block; width: 17em; min-height: 100%; max-height: 100%; - border-width: 0; position: absolute; top: 0; - display: block; } + z-index: 0; } -.panel-reveal { - z-index: 0; - left: -17em; } +header, main, footer { + left: 0; + right: 0; + -webkit-transition: -webkit-transform 200ms ease; + -moz-transition: -moz-transform 200ms ease; + transition: transform 200ms ease; + -webkit-transform: translate3d(0, 0, 0); + -moz-transform: translate3d(0, 0, 0); + transform: translate3d(0, 0, 0); } .ptr-capable { -webkit-user-drag: element; } @@ -533,7 +525,8 @@ a.list-item { color: #333333; } .panel-content { - background: #eeeeee; } + background: #eeeeee; + border-right: 1px solid #bbbbbb; } .ptr-content { background: #eee; } diff --git a/example/panels.html b/example/panels.html index 1bdf93961e..74e7beb920 100644 --- a/example/panels.html +++ b/example/panels.html @@ -13,20 +13,24 @@
+
+ Panel! +
+

Panels

A whole bunch of content

- Panel + Panel
-
- Panel! -
+ + + diff --git a/js/framework/framework-panel.js b/js/framework/framework-panel.js new file mode 100644 index 0000000000..bdce6bd6ee --- /dev/null +++ b/js/framework/framework-panel.js @@ -0,0 +1,55 @@ +(function(window, document, framework) { + + var + el, + styleElement, + isPanelOpen; + + function onTap(e) { + if(e.target) { + el = e.target; + if(el.dataset.togglePanel) { + return togglePanel(e, el, el.dataset.togglePanel); + } + while(el.parentElement) { + el = el.parentElement; + if(el.dataset.togglePanel) { + return togglePanel(e, el, el.dataset.togglePanel); + } + } + } + } + + function togglePanel(e, el, panelName) { + var styles = ""; + + if(isPanelOpen) { + // there is a panel already open, so close it + isPanelOpen = false; + } else { + // open the panel + styles = "section .panel-content ~ * { width:" + document.width + "px !important; \ + -webkit-transform: translate3d(17em,0,0); \ + -moz-transform: translate3d(17em,0,0); \ + transform: translate3d(17em,0,0); }"; + isPanelOpen = true; + } + + setStyles(styles); + } + + function setStyles(styles) { + // get the