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

Unified Diff: third_party/polymer/components/core-overlay/core-overlay-layer.html

Issue 582873003: Polymer elements added to third_party/polymer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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/components/core-overlay/core-overlay-layer.html
diff --git a/third_party/polymer/components/core-overlay/core-overlay-layer.html b/third_party/polymer/components/core-overlay/core-overlay-layer.html
new file mode 100644
index 0000000000000000000000000000000000000000..c75ce3abd3ae78d7644937d0fb8119bdbffbdc4b
--- /dev/null
+++ b/third_party/polymer/components/core-overlay/core-overlay-layer.html
@@ -0,0 +1,112 @@
+<!--
+Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
+This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
+The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
+The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
+Code distributed by Google as part of the polymer project is also
+subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
+-->
+
+<polymer-element name="core-overlay-layer">
+<template>
+ <style>
+ :host {
+ position: fixed;
+ top: 0;
+ left: 0;
+ z-index: 1000;
+ display: none;
+ }
+
+ :host(.core-opened) {
+ display: block;
+ }
+ </style>
+ <content></content>
+</template>
+<script>
+(function() {
+
+ Polymer('core-overlay-layer', {
+ publish: {
+ opened: false
+ },
+ openedChanged: function() {
+ this.classList.toggle('core-opened', this.opened);
+ },
+ /**
+ * Adds an element to the overlay layer
+ */
+ addElement: function(element) {
+ if (!this.parentNode) {
+ document.querySelector('body').appendChild(this);
+ }
+ if (element.parentNode !== this) {
+ element.__contents = [];
+ var ip$ = element.querySelectorAll('content');
+ for (var i=0, l=ip$.length, n; (i<l) && (n = ip$[i]); i++) {
+ this.moveInsertedElements(n);
+ this.cacheDomLocation(n);
+ n.parentNode.removeChild(n);
+ element.__contents.push(n);
+ }
+ this.cacheDomLocation(element);
+ this.updateEventController(element);
+ var h = this.makeHost();
+ h.shadowRoot.appendChild(element);
+ element.__host = h;
+ }
+ },
+ makeHost: function() {
+ var h = document.createElement('overlay-host');
+ h.createShadowRoot();
+ this.appendChild(h);
+ return h;
+ },
+ moveInsertedElements: function(insertionPoint) {
+ var n$ = insertionPoint.getDistributedNodes();
+ var parent = insertionPoint.parentNode;
+ insertionPoint.__contents = [];
+ for (var i=0, l=n$.length, n; (i<l) && (n=n$[i]); i++) {
+ this.cacheDomLocation(n);
+ this.updateEventController(n);
+ insertionPoint.__contents.push(n);
+ parent.appendChild(n);
+ }
+ },
+ updateEventController: function(element) {
+ element.eventController = this.element.findController(element);
+ },
+ /**
+ * Removes an element from the overlay layer
+ */
+ removeElement: function(element) {
+ element.eventController = null;
+ this.replaceElement(element);
+ var h = element.__host;
+ if (h) {
+ h.parentNode.removeChild(h);
+ }
+ },
+ replaceElement: function(element) {
+ if (element.__contents) {
+ for (var i=0, c$=element.__contents, c; (c=c$[i]); i++) {
+ this.replaceElement(c);
+ }
+ element.__contents = null;
+ }
+ if (element.__parentNode) {
+ var n = element.__nextElementSibling && element.__nextElementSibling
+ === element.__parentNode ? element.__nextElementSibling : null;
+ element.__parentNode.insertBefore(element, n);
+ }
+ },
+ cacheDomLocation: function(element) {
+ element.__nextElementSibling = element.nextElementSibling;
+ element.__parentNode = element.parentNode;
+ }
+ });
+
+})();
+</script>
+</polymer-element>
« no previous file with comments | « third_party/polymer/components/core-overlay/core-overlay.html ('k') | third_party/polymer/components/core-overlay/demo.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698