Index: pkg/polymer/lib/elements/polymer-ui-theme-aware/polymer-ui-theme-aware.html |
diff --git a/pkg/polymer/lib/elements/polymer-ui-theme-aware/polymer-ui-theme-aware.html b/pkg/polymer/lib/elements/polymer-ui-theme-aware/polymer-ui-theme-aware.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..e683c745da5aae30076e3bd34eb1ebd07d2feac1 |
--- /dev/null |
+++ b/pkg/polymer/lib/elements/polymer-ui-theme-aware/polymer-ui-theme-aware.html |
@@ -0,0 +1,40 @@ |
+<!-- |
+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-ui-theme-aware" attributes="theme"> |
+ <script> |
+ PolymerUI = { |
+ validateTheme: function() { |
+ var theme = this.theme; |
+ var defaultTheme = this.defaultTheme; |
+ if (!theme) { |
+ var p = this; |
+ while (p && !theme) { |
+ theme = p.getAttribute && p.getAttribute('theme'); |
+ defaultTheme = defaultTheme || p.defaultTheme; |
+ p = p.parentNode || p.host; |
+ } |
+ } |
+ this.activeTheme = this.theme || theme || defaultTheme; |
+ } |
+ }; |
+ Polymer('polymer-ui-theme-aware', { |
+ defaultTheme: '', |
+ activeTheme: '', |
+ validateTheme: PolymerUI.validateTheme, |
+ enteredView: function() { |
+ this.validateTheme(); |
+ }, |
+ themeChanged: function() { |
+ this.activeTheme = this.theme; |
+ }, |
+ activeThemeChanged: function(old) { |
+ this.classList.switch(old, this.activeTheme); |
+ } |
+ }); |
+ </script> |
+</polymer-element> |