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

Side by Side Diff: bower_components/core-overlay/core-overlay-layer.html

Issue 786953007: npm_modules: Fork bower_components into Polymer 0.4.0 and 0.5.0 versions (Closed) Base URL: https://chromium.googlesource.com/infra/third_party/npm_modules.git@master
Patch Set: Created 5 years, 11 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 Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
3 This code may only be used under the BSD style license found at http://polymer.g ithub.io/LICENSE.txt
4 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
5 The complete set of contributors may be found at http://polymer.github.io/CONTRI BUTORS.txt
6 Code distributed by Google as part of the polymer project is also
7 subject to an additional IP rights grant found at http://polymer.github.io/PATEN TS.txt
8 -->
9
10 <polymer-element name="core-overlay-layer">
11 <template>
12 <style>
13 :host {
14 position: fixed;
15 top: 0;
16 left: 0;
17 z-index: 1000;
18 display: none;
19 }
20
21 :host(.core-opened) {
22 display: block;
23 }
24 </style>
25 <content></content>
26 </template>
27 <script>
28 (function() {
29
30 Polymer('core-overlay-layer', {
31 publish: {
32 opened: false
33 },
34 openedChanged: function() {
35 this.classList.toggle('core-opened', this.opened);
36 },
37 /**
38 * Adds an element to the overlay layer
39 */
40 addElement: function(element) {
41 if (!this.parentNode) {
42 document.querySelector('body').appendChild(this);
43 }
44 if (element.parentNode !== this) {
45 element.__contents = [];
46 var ip$ = element.querySelectorAll('content');
47 for (var i=0, l=ip$.length, n; (i<l) && (n = ip$[i]); i++) {
48 this.moveInsertedElements(n);
49 this.cacheDomLocation(n);
50 n.parentNode.removeChild(n);
51 element.__contents.push(n);
52 }
53 this.cacheDomLocation(element);
54 this.updateEventController(element);
55 var h = this.makeHost();
56 h.shadowRoot.appendChild(element);
57 element.__host = h;
58 }
59 },
60 makeHost: function() {
61 var h = document.createElement('overlay-host');
62 h.createShadowRoot();
63 this.appendChild(h);
64 return h;
65 },
66 moveInsertedElements: function(insertionPoint) {
67 var n$ = insertionPoint.getDistributedNodes();
68 var parent = insertionPoint.parentNode;
69 insertionPoint.__contents = [];
70 for (var i=0, l=n$.length, n; (i<l) && (n=n$[i]); i++) {
71 this.cacheDomLocation(n);
72 this.updateEventController(n);
73 insertionPoint.__contents.push(n);
74 parent.appendChild(n);
75 }
76 },
77 updateEventController: function(element) {
78 element.eventController = this.element.findController(element);
79 },
80 /**
81 * Removes an element from the overlay layer
82 */
83 removeElement: function(element) {
84 element.eventController = null;
85 this.replaceElement(element);
86 var h = element.__host;
87 if (h) {
88 h.parentNode.removeChild(h);
89 }
90 },
91 replaceElement: function(element) {
92 if (element.__contents) {
93 for (var i=0, c$=element.__contents, c; (c=c$[i]); i++) {
94 this.replaceElement(c);
95 }
96 element.__contents = null;
97 }
98 if (element.__parentNode) {
99 var n = element.__nextElementSibling && element.__nextElementSibling
100 === element.__parentNode ? element.__nextElementSibling : null;
101 element.__parentNode.insertBefore(element, n);
102 }
103 },
104 cacheDomLocation: function(element) {
105 element.__nextElementSibling = element.nextElementSibling;
106 element.__parentNode = element.parentNode;
107 }
108 });
109
110 })();
111 </script>
112 </polymer-element>
OLDNEW
« no previous file with comments | « bower_components/core-overlay/core-overlay.html ('k') | bower_components/core-overlay/demo.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698