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

Unified Diff: third_party/polymer/components-chromium/paper-menu-button/paper-menu-button-overlay-extracted.js

Issue 592593002: Inline scripts were extracted from Polymer elements. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: s/echo ""/echo/ 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-chromium/paper-menu-button/paper-menu-button-overlay-extracted.js
diff --git a/third_party/polymer/components-chromium/paper-menu-button/paper-menu-button-overlay-extracted.js b/third_party/polymer/components-chromium/paper-menu-button/paper-menu-button-overlay-extracted.js
new file mode 100644
index 0000000000000000000000000000000000000000..d4fac62fa1e6f2cead8c58016b4f084ce2156874
--- /dev/null
+++ b/third_party/polymer/components-chromium/paper-menu-button/paper-menu-button-overlay-extracted.js
@@ -0,0 +1,62 @@
+
+ Polymer('paper-menu-button-overlay', {
+
+ publish: {
+
+ /**
+ * The `relatedTarget` is an element used to position the overlay, for example a
+ * button the user taps to show a menu.
+ *
+ * @attribute relatedTarget
+ * @type Element
+ */
+ relatedTarget: null,
+
+ /**
+ * The horizontal alignment of the overlay relative to the `relatedTarget`.
+ *
+ * @attribute halign
+ * @type 'left'|'right'|'center'
+ * @default 'left'
+ */
+ halign: 'left'
+
+ },
+
+ updateTargetDimensions: function() {
+ this.super();
+
+ var t = this.target;
+ this.target.cachedSize = t.getBoundingClientRect();
+ },
+
+ positionTarget: function() {
+ if (this.relatedTarget) {
+
+ var rect = this.relatedTarget.getBoundingClientRect();
+
+ if (this.halign === 'left') {
+ this.target.style.left = rect.left + 'px';
+ } else if (this.halign === 'right') {
+ this.target.style.right = (window.innerWidth - rect.right) + 'px';
+ } else {
+ this.target.style.left = (rect.left - (rect.width - this.target.cachedSize.width) / 2) + 'px';
+ }
+
+ if (this.valign === 'top') {
+ this.target.style.top = rect.top + 'px';
+ } else if (this.valign === 'bottom') {
+ this.target.style.top = rect.bottom + 'px';
+ } else {
+ this.target.style.top = rect.top + 'px';
+ }
+
+ // this.target.style.top = rect.top + 'px';
+
+ } else {
+ this.super();
+ }
+ }
+
+ });
+

Powered by Google App Engine
This is Rietveld 408576698