OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 Polymer('kb-key', { | 5 Polymer('kb-key', { |
6 /** | 6 /** |
7 * The background image to display on this key. Does not display an | 7 * The background image to display on this key. Does not display an |
8 * image if this is the empty string. | 8 * image if this is the empty string. |
9 * @type {string} | 9 * @type {string} |
10 */ | 10 */ |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 | 60 |
61 /** | 61 /** |
62 * Called when the image attribute changes. This is used to set the | 62 * Called when the image attribute changes. This is used to set the |
63 * background image of the key. | 63 * background image of the key. |
64 * TODO(rsadam): Remove when polymer {{}} syntax regression is fixed. | 64 * TODO(rsadam): Remove when polymer {{}} syntax regression is fixed. |
65 */ | 65 */ |
66 imageChanged: function() { | 66 imageChanged: function() { |
67 if (!this.image) { | 67 if (!this.image) { |
68 this.$.key.style.backgroundImage = "none"; | 68 this.$.key.style.backgroundImage = "none"; |
69 } else { | 69 } else { |
| 70 // If no extension provided, default to svg. |
| 71 var image = |
| 72 this.image.split('.').length > 1 ? this.image : this.image + ".svg"; |
70 this.$.key.style.backgroundImage = | 73 this.$.key.style.backgroundImage = |
71 "url(images/" + this.image + ".svg)"; | 74 "url(images/" + image + ")"; |
72 } | 75 } |
73 }, | 76 }, |
74 | 77 |
75 /** | 78 /** |
76 * Returns a subset of the key attributes. | 79 * Returns a subset of the key attributes. |
77 * @param {string} caller The id of the function that called | 80 * @param {string} caller The id of the function that called |
78 * populateDetails. | 81 * populateDetails. |
79 * @return {Object} Mapping of attributes for the key element. | 82 * @return {Object} Mapping of attributes for the key element. |
80 */ | 83 */ |
81 populateDetails: function(caller) { | 84 populateDetails: function(caller) { |
(...skipping 20 matching lines...) Expand all Loading... |
102 return detail; | 105 return detail; |
103 } | 106 } |
104 }); | 107 }); |
105 ; | 108 ; |
106 | 109 |
107 Polymer('kb-hide-keyboard-key', { | 110 Polymer('kb-hide-keyboard-key', { |
108 up: function(event) { | 111 up: function(event) { |
109 hideKeyboard(); | 112 hideKeyboard(); |
110 }, | 113 }, |
111 }); | 114 }); |
OLD | NEW |