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

Unified Diff: third_party/polymer/components-chromium/core-transition/core-transition-css-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/core-transition/core-transition-css-extracted.js
diff --git a/third_party/polymer/components-chromium/core-transition/core-transition-css-extracted.js b/third_party/polymer/components-chromium/core-transition/core-transition-css-extracted.js
new file mode 100644
index 0000000000000000000000000000000000000000..07b468b7cf69daf2d5237a45514590030b7c8c9c
--- /dev/null
+++ b/third_party/polymer/components-chromium/core-transition/core-transition-css-extracted.js
@@ -0,0 +1,102 @@
+
+
+ Polymer('core-transition-css', {
+
+ /**
+ * The class that will be applied to all animated nodes.
+ *
+ * @attribute baseClass
+ * @type string
+ * @default "core-transition"
+ */
+ baseClass: 'core-transition',
+
+ /**
+ * The class that will be applied to nodes in the opened state.
+ *
+ * @attribute openedClass
+ * @type string
+ * @default "core-opened"
+ */
+ openedClass: 'core-opened',
+
+ /**
+ * The class that will be applied to nodes in the closed state.
+ *
+ * @attribute closedClass
+ * @type string
+ * @default "core-closed"
+ */
+ closedClass: 'core-closed',
+
+ /**
+ * Event to listen to for animation completion.
+ *
+ * @attribute completeEventName
+ * @type string
+ * @default "transitionEnd"
+ */
+ completeEventName: 'transitionend',
+
+ publish: {
+ /**
+ * A secondary configuration attribute for the animation. The class
+ * `<baseClass>-<transitionType` is applied to the animated node during
+ * `setup`.
+ *
+ * @attribute transitionType
+ * @type string
+ */
+ transitionType: null
+ },
+
+ registerCallback: function(element) {
+ this.transitionStyle = element.templateContent().firstElementChild;
+ },
+
+ // template is just for loading styles, we don't need a shadowRoot
+ fetchTemplate: function() {
+ return null;
+ },
+
+ go: function(node, state) {
+ if (state.opened !== undefined) {
+ this.transitionOpened(node, state.opened);
+ }
+ },
+
+ setup: function(node) {
+ if (!node._hasTransitionStyle) {
+ if (!node.shadowRoot) {
+ node.createShadowRoot().innerHTML = '<content></content>';
+ }
+ this.installScopeStyle(this.transitionStyle, 'transition',
+ node.shadowRoot);
+ node._hasTransitionStyle = true;
+ }
+ node.classList.add(this.baseClass);
+ if (this.transitionType) {
+ node.classList.add(this.baseClass + '-' + this.transitionType);
+ }
+ },
+
+ teardown: function(node) {
+ node.classList.remove(this.baseClass);
+ if (this.transitionType) {
+ node.classList.remove(this.baseClass + '-' + this.transitionType);
+ }
+ },
+
+ transitionOpened: function(node, opened) {
+ this.listenOnce(node, this.completeEventName, function() {
+ node.classList.toggle(this.revealedClass, opened);
+ if (!opened) {
+ node.classList.remove(this.closedClass);
+ }
+ this.complete(node);
+ });
+ node.classList.toggle(this.openedClass, opened);
+ node.classList.toggle(this.closedClass, !opened);
+ }
+
+ });

Powered by Google App Engine
This is Rietveld 408576698