| 1 |
// Copyright 2007 The Closure Library Authors. All Rights Reserved. |
| 2 |
// |
| 3 |
// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 |
// you may not use this file except in compliance with the License. |
| 5 |
// You may obtain a copy of the License at |
| 6 |
// |
| 7 |
// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 |
// |
| 9 |
// Unless required by applicable law or agreed to in writing, software |
| 10 |
// distributed under the License is distributed on an "AS-IS" BASIS, |
| 11 |
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 |
// See the License for the specific language governing permissions and |
| 13 |
// limitations under the License. |
| 14 |
|
| 15 |
/** |
| 16 |
* @fileoverview Emoji implementation. |
| 17 |
* |
| 18 |
*/ |
| 19 |
|
| 20 |
goog.provide('goog.ui.emoji.Emoji'); |
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
/** |
| 25 |
* Creates an emoji. |
| 26 |
* |
| 27 |
* A simple wrapper for an emoji. |
| 28 |
* |
| 29 |
* @param {string} url URL pointing to the source image for the emoji. |
| 30 |
* @param {string} id The id of the emoji, e.g., 'std.1'. |
| 31 |
* @param {number=} opt_height The height of the emoji, if undefined the |
| 32 |
* natural height of the emoji is used. |
| 33 |
* @param {number=} opt_width The width of the emoji, if undefined the natural |
| 34 |
* width of the emoji is used. |
| 35 |
* @param {string=} opt_altText The alt text for the emoji image, eg. the |
| 36 |
* unicode character representation of the emoji. |
| 37 |
* @constructor |
| 38 |
* @final |
| 39 |
*/ |
| 40 |
goog.ui.emoji.Emoji = function(url, id, opt_height, opt_width, opt_altText) { |
| 41 |
/** |
| 42 |
* The URL pointing to the source image for the emoji |
| 43 |
* |
| 44 |
* @type {string} |
| 45 |
* @private |
| 46 |
*/ |
| 47 |
this.url_ = url; |
| 48 |
|
| 49 |
/** |
| 50 |
* The id of the emoji |
| 51 |
* |
| 52 |
* @type {string} |
| 53 |
* @private |
| 54 |
*/ |
| 55 |
this.id_ = id; |
| 56 |
|
| 57 |
/** |
| 58 |
* The height of the emoji |
| 59 |
* |
| 60 |
* @type {?number} |
| 61 |
* @private |
| 62 |
*/ |
| 63 |
this.height_ = opt_height || null; |
| 64 |
|
| 65 |
/** |
| 66 |
* The width of the emoji |
| 67 |
* |
| 68 |
* @type {?number} |
| 69 |
* @private |
| 70 |
*/ |
| 71 |
this.width_ = opt_width || null; |
| 72 |
|
| 73 |
/** |
| 74 |
* The unicode of the emoji |
| 75 |
* |
| 76 |
* @type {?string} |
| 77 |
* @private |
| 78 |
*/ |
| 79 |
this.altText_ = opt_altText || null; |
| 80 |
}; |
| 81 |
|
| 82 |
|
| 83 |
/** |
| 84 |
* The name of the goomoji attribute, used for emoji image elements. |
| 85 |
* @type {string} |
| 86 |
* @deprecated Use goog.ui.emoji.Emoji.DATA_ATTRIBUTE instead. |
| 87 |
*/ |
| 88 |
goog.ui.emoji.Emoji.ATTRIBUTE = 'goomoji'; |
| 89 |
|
| 90 |
|
| 91 |
/** |
| 92 |
* The name of the goomoji data-attribute, used for emoji image elements. Data |
| 93 |
* attributes are the preferred way in HTML5 to set custom attributes. |
| 94 |
* @type {string} |
| 95 |
*/ |
| 96 |
goog.ui.emoji.Emoji.DATA_ATTRIBUTE = 'data-' + goog.ui.emoji.Emoji.ATTRIBUTE; |
| 97 |
|
| 98 |
|
| 99 |
/** |
| 100 |
* @return {string} The URL for this emoji. |
| 101 |
*/ |
| 102 |
goog.ui.emoji.Emoji.prototype.getUrl = function() { |
| 103 |
return this.url_; |
| 104 |
}; |
| 105 |
|
| 106 |
|
| 107 |
/** |
| 108 |
* @return {string} The id of this emoji. |
| 109 |
*/ |
| 110 |
goog.ui.emoji.Emoji.prototype.getId = function() { |
| 111 |
return this.id_; |
| 112 |
}; |
| 113 |
|
| 114 |
|
| 115 |
/** |
| 116 |
* @return {?number} The height of this emoji. |
| 117 |
*/ |
| 118 |
goog.ui.emoji.Emoji.prototype.getHeight = function() { |
| 119 |
return this.height_; |
| 120 |
}; |
| 121 |
|
| 122 |
|
| 123 |
/** |
| 124 |
* @return {?number} The width of this emoji. |
| 125 |
*/ |
| 126 |
goog.ui.emoji.Emoji.prototype.getWidth = function() { |
| 127 |
return this.width_; |
| 128 |
}; |
| 129 |
|
| 130 |
|
| 131 |
/** |
| 132 |
* @return {?string} The alt text for the emoji image, eg. the unicode character |
| 133 |
* representation of the emoji. |
| 134 |
*/ |
| 135 |
goog.ui.emoji.Emoji.prototype.getAltText = function() { |
| 136 |
return this.altText_; |
| 137 |
}; |