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

Unified Diff: pkg/polymer/lib/elements/polymer-layout/polymer-slide.html

Issue 175443005: [polymer] import all elements (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: updated from bower Created 6 years, 10 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: pkg/polymer/lib/elements/polymer-layout/polymer-slide.html
diff --git a/pkg/polymer/lib/elements/polymer-layout/polymer-slide.html b/pkg/polymer/lib/elements/polymer-layout/polymer-slide.html
new file mode 100644
index 0000000000000000000000000000000000000000..7c6c829b6e42739e503d328a2e164806de795267
--- /dev/null
+++ b/pkg/polymer/lib/elements/polymer-layout/polymer-slide.html
@@ -0,0 +1,155 @@
+<!--
+Copyright 2013 The Polymer Authors. All rights reserved.
+Use of this source code is governed by a BSD-style
+license that can be found in the LICENSE file.
+-->
+<link rel="import" href="../polymer/polymer.html">
+
+<polymer-element name="polymer-slide" attributes="open closed vertical target targetId">
+ <template>
+ <style>
+ :host {
+ display: none;
+ }
+ </style>
+ </template>
+ <script>
+ Polymer('polymer-slide', {
+ closed: false,
+ open: true,
+ vertical: false,
+ targetId: '',
+ target: null,
+ ready: function() {
+ this.setAttribute('nolayout', '');
+ },
+ enteredView: function() {
+ this.target = this.parentNode;
+ },
+ targetIdChanged: function() {
+ var p = this.parentNode;
+ while (p.parentNode) {p = p.parentNode;};
+ this.target = p.querySelector('#' + this.targetId);
+ },
+ targetChanged: function() {
+ if (this.closed) {
+ this.asyncMethod(this.update);
+ }
+ },
+ toggle: function() {
+ this.open = !this.open;
+ },
+ closedChanged: function() {
+ this.open = !this.closed;
+ },
+ openChanged: function() {
+ this.asyncMethod(this.update);
+ },
+ update: function() {
+ this.closed = !this.open;
+ if (this.target) {
+ if (this.vertical) {
+ if (this.target.style.top !== '') {
+ this.updateTop();
+ } else {
+ this.updateBottom();
+ }
+ } else {
+ if (this.target.style.left !== '') {
+ this.updateLeft();
+ } else {
+ this.updateRight();
+ }
+ }
+ }
+ },
+ updateLeft: function() {
+ var w = this.target.offsetWidth;
+ var l = this.open ? 0 : -w;
+ this.target.style.left = l + 'px';
+ var s = this.target.nextElementSibling;
+ while (s) {
+ if (!s.hasAttribute('nolayout')) {
+ if (s.style.left === '' && s.style.right !== '') {
+ break;
+ }
+ l += w;
+ s.style.left = l + 'px';
+ w = s.offsetWidth;
+ }
+ s = s.nextElementSibling;
+ }
+ },
+ updateRight: function() {
+ var w = this.target.offsetWidth;
+ var r = this.open ? 0 : -w;
+ this.target.style.right = r + 'px';
+ //var s = this.target.previousElementSibling;
+ var s = previousElementSibling(this.target);
+ while (s) {
+ if (!s.hasAttribute('nolayout')) {
+ if (s.style.right === '' && s.style.left !== '') {
+ break;
+ }
+ r += w;
+ s.style.right = r + 'px';
+ w = s.offsetWidth;
+ }
+ //if (s == s.previousElementSibling) {
+ // console.error(s.localName + ' is its own sibling', s);
+ // break;
+ //}
+ //s = s.previousElementSibling;
+ s = previousElementSibling(s);
+ }
+ },
+ updateTop: function() {
+ var h = this.target.offsetHeight;
+ var t = this.open ? 0 : -h;
+ this.target.style.top = t + 'px';
+ var s = this.target.nextElementSibling;
+ while (s) {
+ if (!s.hasAttribute('nolayout')) {
+ if (s.style.top === '' && s.style.bottom !== '') {
+ break;
+ }
+ t += h;
+ s.style.top = t + 'px';
+ h = s.offsetHeight;
+ }
+ s = s.nextElementSibling;
+ }
+ },
+ updateBottom: function() {
+ var h = this.target.offsetHeight;
+ var b = this.open ? 0 : -h;
+ this.target.style.bottom = b + 'px';
+ //var s = this.target.previousElementSibling;
+ var s = previousElementSibling(this.target);
+ while (s) {
+ if (!s.hasAttribute('nolayout')) {
+ if (s.style.bottom === '' && s.style.top !== '') {
+ break;
+ }
+ b = b + h;
+ s.style.bottom = b + 'px';
+ h = s.offsetHeight;
+ }
+ //if (s == s.previousElementSibling) {
+ // console.error(s.localName + ' is its own sibling', s);
+ // break;
+ //}
+ //s = s.previousElementSibling;
+ s = previousElementSibling(s);
+ }
+ }
+ });
+ // TODO(sjmiles): temporary workaround for b0rked property in ShadowDOMPolyfill
+ function previousElementSibling(e) {
+ do {
+ e = e.previousSibling;
+ } while (e && e.nodeType !== Node.ELEMENT_NODE);
+ return e;
+ };
+ </script>
+</polymer-element>
« no previous file with comments | « pkg/polymer/lib/elements/polymer-layout/polymer-layout.html ('k') | pkg/polymer/lib/elements/polymer-localstorage/.bower.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698