OLD | NEW |
(Empty) | |
| 1 |
| 2 |
| 3 Polymer({ |
| 4 |
| 5 is: 'iron-icon', |
| 6 |
| 7 properties: { |
| 8 |
| 9 icon: { |
| 10 type: String, |
| 11 //value: '', |
| 12 observer: '_iconChanged' |
| 13 }, |
| 14 |
| 15 theme: { |
| 16 type: String, |
| 17 //value: '', |
| 18 observer: '_updateIcon' |
| 19 }, |
| 20 |
| 21 src: { |
| 22 type: String, |
| 23 //value: '', |
| 24 observer: '_srcChanged' |
| 25 } |
| 26 |
| 27 }, |
| 28 |
| 29 _DEFAULT_ICONSET: 'icons', |
| 30 |
| 31 _iconChanged: function(icon) { |
| 32 var parts = (icon || '').split(':'); |
| 33 this._iconName = parts.pop(); |
| 34 this._iconsetName = parts.pop() || this._DEFAULT_ICONSET; |
| 35 this._updateIcon(); |
| 36 }, |
| 37 |
| 38 _srcChanged: function(src) { |
| 39 this._updateIcon(); |
| 40 }, |
| 41 |
| 42 _usesIconset: function() { |
| 43 return this.icon || !this.src; |
| 44 }, |
| 45 |
| 46 _updateIcon: function() { |
| 47 if (this._usesIconset()) { |
| 48 this._iconset = this.$.meta.byKey(this._iconsetName); |
| 49 if (this._iconset) { |
| 50 this._iconset.applyIcon(this, this._iconName, this.theme); |
| 51 } else { |
| 52 console.warn('iron-icon: could not find iconset `' |
| 53 + this._iconsetName + '`, did you import the iconset?'); |
| 54 } |
| 55 } else { |
| 56 //if (this._iconset) { |
| 57 // this._iconset.removeIcon(this.root); |
| 58 //} |
| 59 if (!this._img) { |
| 60 this._img = document.createElement('img'); |
| 61 } |
| 62 this._img.src = this.src; |
| 63 Polymer.dom(this.root).appendChild(this._img); |
| 64 } |
| 65 } |
| 66 |
| 67 }); |
| 68 |
OLD | NEW |