| OLD | NEW |
| 1 Polymer({ | 1 Polymer({ |
| 2 | 2 |
| 3 is: 'iron-icon', | 3 is: 'iron-icon', |
| 4 | 4 |
| 5 properties: { | 5 properties: { |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * The name of the icon to use. The name should be of the form: | 8 * The name of the icon to use. The name should be of the form: |
| 9 * `iconset_name:icon_name`. | 9 * `iconset_name:icon_name`. |
| 10 */ | 10 */ |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 }, | 23 }, |
| 24 | 24 |
| 25 /** | 25 /** |
| 26 * If using iron-icon without an iconset, you can set the src to be | 26 * If using iron-icon without an iconset, you can set the src to be |
| 27 * the URL of an individual icon image file. Note that this will take | 27 * the URL of an individual icon image file. Note that this will take |
| 28 * precedence over a given icon attribute. | 28 * precedence over a given icon attribute. |
| 29 */ | 29 */ |
| 30 src: { | 30 src: { |
| 31 type: String, | 31 type: String, |
| 32 observer: '_srcChanged' | 32 observer: '_srcChanged' |
| 33 }, |
| 34 |
| 35 _meta: { |
| 36 value: Polymer.Base.create('iron-meta', {type: 'iconset'}) |
| 33 } | 37 } |
| 38 |
| 34 }, | 39 }, |
| 35 | 40 |
| 36 _DEFAULT_ICONSET: 'icons', | 41 _DEFAULT_ICONSET: 'icons', |
| 37 | 42 |
| 38 _iconChanged: function(icon) { | 43 _iconChanged: function(icon) { |
| 39 var parts = (icon || '').split(':'); | 44 var parts = (icon || '').split(':'); |
| 40 this._iconName = parts.pop(); | 45 this._iconName = parts.pop(); |
| 41 this._iconsetName = parts.pop() || this._DEFAULT_ICONSET; | 46 this._iconsetName = parts.pop() || this._DEFAULT_ICONSET; |
| 42 this._updateIcon(); | 47 this._updateIcon(); |
| 43 }, | 48 }, |
| 44 | 49 |
| 45 _srcChanged: function(src) { | 50 _srcChanged: function(src) { |
| 46 this._updateIcon(); | 51 this._updateIcon(); |
| 47 }, | 52 }, |
| 48 | 53 |
| 49 _usesIconset: function() { | 54 _usesIconset: function() { |
| 50 return this.icon || !this.src; | 55 return this.icon || !this.src; |
| 51 }, | 56 }, |
| 52 | 57 |
| 58 /** @suppress {visibility} */ |
| 53 _updateIcon: function() { | 59 _updateIcon: function() { |
| 54 if (this._usesIconset()) { | 60 if (this._usesIconset()) { |
| 55 if (this._iconsetName) { | 61 if (this._iconsetName) { |
| 56 this._iconset = this.$.meta.byKey(this._iconsetName); | 62 this._iconset = this._meta.byKey(this._iconsetName); |
| 57 if (this._iconset) { | 63 if (this._iconset) { |
| 58 this._iconset.applyIcon(this, this._iconName, this.theme); | 64 this._iconset.applyIcon(this, this._iconName, this.theme); |
| 59 } else { | 65 } else { |
| 60 this._warn(this._logf('_updateIcon', 'could not find iconset `' | 66 this._warn(this._logf('_updateIcon', 'could not find iconset `' |
| 61 + this._iconsetName + '`, did you import the iconset?')); | 67 + this._iconsetName + '`, did you import the iconset?')); |
| 62 } | 68 } |
| 63 } | 69 } |
| 64 } else { | 70 } else { |
| 65 if (!this._img) { | 71 if (!this._img) { |
| 66 this._img = document.createElement('img'); | 72 this._img = document.createElement('img'); |
| 67 this._img.style.width = '100%'; | 73 this._img.style.width = '100%'; |
| 68 this._img.style.height = '100%'; | 74 this._img.style.height = '100%'; |
| 75 this._img.draggable = false; |
| 69 } | 76 } |
| 70 this._img.src = this.src; | 77 this._img.src = this.src; |
| 71 Polymer.dom(this.root).appendChild(this._img); | 78 Polymer.dom(this.root).appendChild(this._img); |
| 72 } | 79 } |
| 73 } | 80 } |
| 74 | 81 |
| 75 }); | 82 }); |
| OLD | NEW |