1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- goog.provide('goog.editor.plugins.Emoticons');
- goog.require('goog.dom.TagName');
- goog.require('goog.editor.Plugin');
- goog.require('goog.editor.range');
- goog.require('goog.functions');
- goog.require('goog.ui.emoji.Emoji');
- goog.require('goog.userAgent');
- goog.editor.plugins.Emoticons = function() {
- goog.editor.plugins.Emoticons.base(this, 'constructor');
- };
- goog.inherits(goog.editor.plugins.Emoticons, goog.editor.Plugin);
- goog.editor.plugins.Emoticons.COMMAND = '+emoticon';
- goog.editor.plugins.Emoticons.prototype.getTrogClassId =
- goog.functions.constant(goog.editor.plugins.Emoticons.COMMAND);
- goog.editor.plugins.Emoticons.prototype.isSupportedCommand = function(command) {
- return command == goog.editor.plugins.Emoticons.COMMAND;
- };
- goog.editor.plugins.Emoticons.prototype.execCommandInternal = function(
- command, opt_arg) {
- var emoji = (opt_arg);
- var styleProperties = 'margin:0 0.2ex;vertical-align:middle;';
- var emojiHeight = emoji.getHeight();
- styleProperties += emojiHeight ? 'height:' + emojiHeight + 'px;' : '';
- var emojiWidth = emoji.getWidth();
- styleProperties += emojiWidth ? 'width:' + emojiWidth + 'px;' : '';
- var dom = this.getFieldDomHelper();
- var imgAttributes = {'src': emoji.getUrl(), 'style': styleProperties};
- if (emoji.getAltText()) {
- imgAttributes['alt'] = emoji.getAltText();
- }
- var img = dom.createDom(goog.dom.TagName.IMG, imgAttributes);
- img.setAttribute(goog.ui.emoji.Emoji.ATTRIBUTE, emoji.getId());
- img.setAttribute(goog.ui.emoji.Emoji.DATA_ATTRIBUTE, emoji.getId());
- this.getFieldObject().getRange().replaceContentsWithNode(img);
-
-
-
- if (!goog.userAgent.IE || goog.userAgent.isDocumentModeOrHigher(9)) {
- this.getFieldObject().focus();
- goog.editor.range.placeCursorNextTo(img, false);
- }
- };
|