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

Side by Side Diff: third_party/polymer/v1_0/components/iron-overlay-behavior/iron-overlay-manager.html

Issue 1269803005: Remove third_party/polymer from .gitignore (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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 unified diff | Download patch
OLDNEW
(Empty)
1 <!--
2 @license
3 Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
4 This code may only be used under the BSD style license found at http://polymer.g ithub.io/LICENSE.txt
5 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
6 The complete set of contributors may be found at http://polymer.github.io/CONTRI BUTORS.txt
7 Code distributed by Google as part of the polymer project is also
8 subject to an additional IP rights grant found at http://polymer.github.io/PATEN TS.txt
9 -->
10
11 <link rel="import" href="../polymer/polymer.html">
12
13 <script>
14
15 Polymer.IronOverlayManager = (function() {
16
17 var overlays = [];
18 var DEFAULT_Z = 10;
19 var backdrops = [];
20
21 // track overlays for z-index and focus managemant
22 function addOverlay(overlay) {
23 var z0 = currentOverlayZ();
24 overlays.push(overlay);
25 var z1 = currentOverlayZ();
26 if (z1 <= z0) {
27 applyOverlayZ(overlay, z0);
28 }
29 }
30
31 function removeOverlay(overlay) {
32 var i = overlays.indexOf(overlay);
33 if (i >= 0) {
34 overlays.splice(i, 1);
35 setZ(overlay, '');
36 }
37 }
38
39 function applyOverlayZ(overlay, aboveZ) {
40 setZ(overlay, aboveZ + 2);
41 }
42
43 function setZ(element, z) {
44 element.style.zIndex = z;
45 }
46
47 function currentOverlay() {
48 return overlays[overlays.length-1];
49 }
50
51 function currentOverlayZ() {
52 var z;
53 var current = currentOverlay();
54 if (current) {
55 var z1 = window.getComputedStyle(current).zIndex;
56 if (!isNaN(z1)) {
57 z = Number(z1);
58 }
59 }
60 return z || DEFAULT_Z;
61 }
62
63 function focusOverlay() {
64 var current = currentOverlay();
65 // We have to be careful to focus the next overlay _after_ any current
66 // transitions are complete (due to the state being toggled prior to the
67 // transition). Otherwise, we risk infinite recursion when a transitioning
68 // (closed) overlay becomes the current overlay.
69 //
70 // NOTE: We make the assumption that any overlay that completes a transiti on
71 // will call into focusOverlay to kick the process back off. Currently:
72 // transitionend -> _applyFocus -> focusOverlay.
73 if (current && !current.transitioning) {
74 current._applyFocus();
75 }
76 }
77
78 function trackBackdrop(element) {
79 // backdrops contains the overlays with a backdrop that are currently
80 // visible
81 if (element.opened) {
82 backdrops.push(element);
83 } else {
84 var index = backdrops.indexOf(element);
85 if (index >= 0) {
86 backdrops.splice(index, 1);
87 }
88 }
89 }
90
91 function getBackdrops() {
92 return backdrops;
93 }
94
95 return {
96 addOverlay: addOverlay,
97 removeOverlay: removeOverlay,
98 currentOverlay: currentOverlay,
99 currentOverlayZ: currentOverlayZ,
100 focusOverlay: focusOverlay,
101 trackBackdrop: trackBackdrop,
102 getBackdrops: getBackdrops
103 };
104
105 })();
106
107 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698