Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
separate activeTheme and theme concepts from theme-aware controls…
Browse files Browse the repository at this point in the history
…, so that an inherited theme is not expressed as an attribute
  • Loading branch information
Scott J. Miles committed Oct 9, 2013
1 parent f9f66ab commit f880291
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 25 deletions.
4 changes: 2 additions & 2 deletions polymer-ui-icon/polymer-ui-icon.html
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@
this.style.backgroundImage = 'url(' + this.src + ')';
this.updateIcon();
},
themeChanged: function(old) {
activeThemeChanged: function(old) {
this.super(arguments);
this.style.backgroundPosition = '';
this.bx = calcThemeOffset(this.theme, this);
this.bx = calcThemeOffset(this.activeTheme, this);
this.updateIcon();
},
updateIcon: function() {
Expand Down
17 changes: 9 additions & 8 deletions polymer-ui-menu/polymer-ui-menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,23 @@
<link rel="import" href="../../polymer-elements/polymer-selector/polymer-selector.html">
<link rel="import" href="../polymer-ui-theme-aware/polymer-ui-theme-aware.html">

<polymer-element name="polymer-ui-menu" extends="polymer-selector"
attributes="theme" on-polymer-select="selectionChange">
<polymer-element name="polymer-ui-menu" extends="polymer-selector" attributes="theme" on-polymer-select="selectionChange">
<template>
<link rel="stylesheet" href="polymer-ui-menu.css">
<shadow></shadow>
</template>
<script>
Polymer('polymer-ui-menu', {
activeTheme: '',
validateTheme: PolymerUI.validateTheme,
enteredView: function() {
if (!this.theme) {
this.findTheme();
}
this.validateTheme();
},
themeChanged: function() {
this.activeTheme = this.theme;
},
findTheme: PolymerUI.findTheme,
themeChanged: function(old) {
this.classList.switch(old, this.theme);
activeThemeChanged: function(old) {
this.classList.switch(old, this.activeTheme);
},
selectionChange: function(e, detail) {
if (detail.isSelected) {
Expand Down
4 changes: 2 additions & 2 deletions polymer-ui-sidebar-menu/metadata.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
<polymer-ui-menu-item label="Favorites 3"></polymer-ui-menu-item>
<polymer-ui-menu-item label="Favorites 4"></polymer-ui-menu-item>
</polymer-ui-submenu-item>
<polymer-ui-menu-item icon="settings" label="Explore">
<polymer-ui-submenu-item icon="settings" label="Explore">
<polymer-ui-menu-item label="Explore 1"></polymer-ui-menu-item>
<polymer-ui-menu-item label="Explore 2"></polymer-ui-menu-item>
</polymer-ui-menu-item>
</polymer-ui-submenu-item>
</polymer-ui-sidebar-menu>
</template>
<template id="imports">
Expand Down
31 changes: 18 additions & 13 deletions polymer-ui-theme-aware/polymer-ui-theme-aware.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,30 @@
-->
<polymer-element name="polymer-ui-theme-aware" attributes="theme">
<script>
PolymerUI = {
findTheme: function() {
var p = this, theme = null;
while (p && !theme) {
theme = p.getAttribute && p.getAttribute('theme');
p = p.parentNode || p.host;
PolymerUI = {
validateTheme: function() {
var theme = this.theme;
if (!theme) {
var p = this;
while (p && !theme) {
theme = p.getAttribute && p.getAttribute('theme');
p = p.parentNode || p.host;
}
}
this.theme = theme;
this.activeTheme = this.theme || theme;
}
};
Polymer('polymer-ui-theme-aware', {
activeTheme: '',
validateTheme: PolymerUI.validateTheme,
enteredView: function() {
if (!this.theme) {
this.findTheme();
}
this.validateTheme();
},
themeChanged: function() {
this.activeTheme = this.theme;
},
findTheme: PolymerUI.findTheme,
themeChanged: function(old) {
this.classList.switch(old, this.theme);
activeThemeChanged: function(old) {
this.classList.switch(old, this.activeTheme);
}
});
</script>
Expand Down

0 comments on commit f880291

Please sign in to comment.