OLD | NEW |
(Empty) | |
| 1 <!-- |
| 2 Copyright 2013 The Polymer Authors. All rights reserved. |
| 3 Use of this source code is governed by a BSD-style |
| 4 license that can be found in the LICENSE file. |
| 5 --> |
| 6 <link rel="import" href="../polymer/polymer.html"> |
| 7 |
| 8 <polymer-element name="polymer-ui-theme-aware" attributes="theme"> |
| 9 <script> |
| 10 PolymerUI = { |
| 11 validateTheme: function() { |
| 12 var theme = this.theme; |
| 13 var defaultTheme = this.defaultTheme; |
| 14 if (!theme) { |
| 15 var p = this; |
| 16 while (p && !theme) { |
| 17 theme = p.getAttribute && p.getAttribute('theme'); |
| 18 defaultTheme = defaultTheme || p.defaultTheme; |
| 19 p = p.parentNode || p.host; |
| 20 } |
| 21 } |
| 22 this.activeTheme = this.theme || theme || defaultTheme; |
| 23 } |
| 24 }; |
| 25 Polymer('polymer-ui-theme-aware', { |
| 26 defaultTheme: '', |
| 27 activeTheme: '', |
| 28 validateTheme: PolymerUI.validateTheme, |
| 29 enteredView: function() { |
| 30 this.validateTheme(); |
| 31 }, |
| 32 themeChanged: function() { |
| 33 this.activeTheme = this.theme; |
| 34 }, |
| 35 activeThemeChanged: function(old) { |
| 36 this.classList.switch(old, this.activeTheme); |
| 37 } |
| 38 }); |
| 39 </script> |
| 40 </polymer-element> |
OLD | NEW |