From cc7911097a1b83c189401c44ef58896d002d3f6e Mon Sep 17 00:00:00 2001 From: Steve Orvell Date: Mon, 14 Apr 2014 19:04:42 -0700 Subject: [PATCH] outdent script; functions without a transition; transition controls all opening behavior. --- core-overlay.html | 760 +++++++++++++++++++++++----------------------- demo.html | 26 +- 2 files changed, 378 insertions(+), 408 deletions(-) diff --git a/core-overlay.html b/core-overlay.html index 720fee3..c6d8126 100644 --- a/core-overlay.html +++ b/core-overlay.html @@ -76,399 +76,391 @@ --> - - + return this[bound]; + }, + }); + + // TODO(sorvell): This should be an element with private state so it can + // be independent of overlay. + // track overlays for z-index and focus managemant + var overlays = []; + var trackOverlays = function(inOverlay) { + if (inOverlay.opened) { + var z0 = currentOverlayZ(); + overlays.push(inOverlay); + var z1 = currentOverlayZ(); + if (z1 <= z0) { + applyOverlayZ(inOverlay, z0); + } + } else { + var i = overlays.indexOf(inOverlay); + if (i >= 0) { + overlays.splice(i, 1); + setZ(inOverlay, null); + } + } + } + + var applyOverlayZ = function(inOverlay, inAboveZ) { + setZ(inOverlay.target, inAboveZ + 2); + } + + var setZ = function(inNode, inZ) { + inNode.style.zIndex = inZ; + } + + var currentOverlay = function() { + return overlays[overlays.length-1]; + } + + var DEFAULT_Z = 10; + + var currentOverlayZ = function() { + var z; + var current = currentOverlay(); + if (current) { + var z1 = window.getComputedStyle(current.target).zIndex; + if (!isNaN(z1)) { + z = Number(z1); + } + } + return z || DEFAULT_Z; + } + + var focusOverlay = function() { + var current = currentOverlay(); + if (current) { + current.applyFocus(); + } + } +})(); + diff --git a/demo.html b/demo.html index 58c7a37..8eff209 100644 --- a/demo.html +++ b/demo.html @@ -21,33 +21,11 @@ } #dialog { - /*top: 72px; - left: 10px;*/ width: 500px; } - #dialog.core-revealed { - transition: -webkit-transform 0.2s ease-in-out, opacity 0.2s ease-in; - -webkit-transform: scale(0.1) translateY(-500px); - } - - #dialog.core-overlay.core-opened { - -webkit-transform: none; - } - - #confirmation.core-opened { - top: 100px; - } - - #confirmation.core-closed { - left: 100%; - top: 100px; - } - #confirmation { - position: absolute; left: 50%; - top: 0; text-align: center; width: 150px; margin-left: -75px; @@ -64,7 +42,7 @@

Dialog


I agree with this wholeheartedly. - + Thank you.


@@ -98,7 +76,7 @@

Dialog

box-shadow: 0 4px 16px rgba(0,0,0,0.2); } - +