Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Unified Diff: third_party/polymer/v0_8/components-chromium/iron-overlay-behavior/iron-overlay-manager-extracted.js

Issue 1162563004: Upgrade to 1.0 and switch clients to dom-repeat where needed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix a layout import and remove the gzipped webanimation in reproduce.sh Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/polymer/v0_8/components-chromium/iron-overlay-behavior/iron-overlay-manager-extracted.js
diff --git a/third_party/polymer/v0_8/components-chromium/iron-overlay-behavior/iron-overlay-manager-extracted.js b/third_party/polymer/v0_8/components-chromium/iron-overlay-behavior/iron-overlay-manager-extracted.js
new file mode 100644
index 0000000000000000000000000000000000000000..1a6f7dcd1e4a42047c905fa3572b78c663dcf8ee
--- /dev/null
+++ b/third_party/polymer/v0_8/components-chromium/iron-overlay-behavior/iron-overlay-manager-extracted.js
@@ -0,0 +1,94 @@
+
+
+ Polymer.IronOverlayManager = (function() {
+
+ var overlays = [];
+ var DEFAULT_Z = 10;
+ var backdrops = [];
+
+ // track overlays for z-index and focus managemant
+ function addOverlay(overlay) {
+ var z0 = currentOverlayZ();
+ overlays.push(overlay);
+ var z1 = currentOverlayZ();
+ if (z1 <= z0) {
+ applyOverlayZ(overlay, z0);
+ }
+ }
+
+ function removeOverlay(overlay) {
+ var i = overlays.indexOf(overlay);
+ if (i >= 0) {
+ overlays.splice(i, 1);
+ setZ(overlay, '');
+ }
+ }
+
+ function applyOverlayZ(overlay, aboveZ) {
+ setZ(overlay, aboveZ + 2);
+ }
+
+ function setZ(element, z) {
+ element.style.zIndex = z;
+ }
+
+ function currentOverlay() {
+ return overlays[overlays.length-1];
+ }
+
+ function currentOverlayZ() {
+ var z;
+ var current = currentOverlay();
+ if (current) {
+ var z1 = window.getComputedStyle(current).zIndex;
+ if (!isNaN(z1)) {
+ z = Number(z1);
+ }
+ }
+ return z || DEFAULT_Z;
+ }
+
+ function focusOverlay() {
+ var current = currentOverlay();
+ // We have to be careful to focus the next overlay _after_ any current
+ // transitions are complete (due to the state being toggled prior to the
+ // transition). Otherwise, we risk infinite recursion when a transitioning
+ // (closed) overlay becomes the current overlay.
+ //
+ // NOTE: We make the assumption that any overlay that completes a transition
+ // will call into focusOverlay to kick the process back off. Currently:
+ // transitionend -> _applyFocus -> focusOverlay.
+ if (current && !current.transitioning) {
+ current._applyFocus();
+ }
+ }
+
+ function trackBackdrop(element) {
+ // backdrops contains the overlays with a backdrop that are currently
+ // visible
+ if (element.opened) {
+ backdrops.push(element);
+ } else {
+ var index = backdrops.indexOf(element);
+ if (index >= 0) {
+ backdrops.splice(index, 1);
+ }
+ }
+ }
+
+ function getBackdrops() {
+ return backdrops;
+ }
+
+ return {
+ addOverlay: addOverlay,
+ removeOverlay: removeOverlay,
+ currentOverlay: currentOverlay,
+ currentOverlayZ: currentOverlayZ,
+ focusOverlay: focusOverlay,
+ trackBackdrop: trackBackdrop,
+ getBackdrops: getBackdrops
+ };
+
+ })();
+

Powered by Google App Engine
This is Rietveld 408576698