| 1 |
define([ |
| 2 |
"dojo", |
| 3 |
"dijit", |
| 4 |
"dojox", |
| 5 |
"dijit/_Widget", |
| 6 |
"dijit/_TemplatedMixin", |
| 7 |
"dijit/_PaletteMixin", |
| 8 |
"dojo/_base/connect", |
| 9 |
"dojo/_base/declare", |
| 10 |
"dojo/i18n", |
| 11 |
"dojo/i18n!dojox/editor/plugins/nls/Smiley" |
| 12 |
], function(dojo, dijit, dojox, _Widget, _TemplatedMixin, _PaletteMixin) { |
| 13 |
|
| 14 |
dojo.experimental("dojox.editor.plugins._SmileyPalette"); |
| 15 |
|
| 16 |
var Emoticon = dojo.declare("dojox.editor.plugins.Emoticon", |
| 17 |
null, |
| 18 |
{ |
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
constructor: function( id){ |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
this.id = id; |
| 28 |
}, |
| 29 |
|
| 30 |
getValue: function(){ |
| 31 |
|
| 32 |
|
| 33 |
return Emoticon.ascii[this.id]; |
| 34 |
}, |
| 35 |
|
| 36 |
imgHtml: function( clazz){ |
| 37 |
|
| 38 |
|
| 39 |
var eId = "emoticon" + this.id.substr(0,1).toUpperCase() + this.id.substr(1), |
| 40 |
src = dojo.moduleUrl("dojox.editor.plugins", "resources/emoticons/" + eId + ".gif"), |
| 41 |
label = dojo.i18n.getLocalization("dojox.editor.plugins", "Smiley")[eId], |
| 42 |
html = ['<img src=\"', |
| 43 |
src, |
| 44 |
'\" class=\"', |
| 45 |
clazz, |
| 46 |
'\" alt=\"', |
| 47 |
this.getValue(), |
| 48 |
'\" title=\"', |
| 49 |
label, |
| 50 |
'\">']; |
| 51 |
return html.join(""); |
| 52 |
}, |
| 53 |
|
| 54 |
fillCell: function(cell, blankGif){ |
| 55 |
dojo.place(this.imgHtml("dijitPaletteImg"), cell); |
| 56 |
} |
| 57 |
}); |
| 58 |
|
| 59 |
Emoticon.ascii = { |
| 60 |
smile: ":-)", |
| 61 |
laughing: "lol", |
| 62 |
wink: ";-)", |
| 63 |
grin: ":-D", |
| 64 |
cool: "8-)", |
| 65 |
angry: ":-@", |
| 66 |
half: ":-/", |
| 67 |
eyebrow: "/:)", |
| 68 |
frown: ":-(", |
| 69 |
shy: ":-$", |
| 70 |
goofy: ":-S", |
| 71 |
oops: ":-O", |
| 72 |
tongue: ":-P", |
| 73 |
idea: "(i)", |
| 74 |
yes: "(y)", |
| 75 |
no: "(n)", |
| 76 |
angel: "0:-)", |
| 77 |
crying: ":'(", |
| 78 |
happy: "=)" |
| 79 |
}; |
| 80 |
|
| 81 |
Emoticon.fromAscii = function(str){ |
| 82 |
|
| 83 |
|
| 84 |
var ascii = Emoticon.ascii; |
| 85 |
for(var i in ascii){ |
| 86 |
if(str == ascii[i]){ |
| 87 |
return new Emoticon(i); |
| 88 |
} |
| 89 |
} |
| 90 |
return null; |
| 91 |
}; |
| 92 |
|
| 93 |
var SmileyPalette = dojo.declare("dojox.editor.plugins._SmileyPalette", [_Widget, _TemplatedMixin, _PaletteMixin], { |
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
templateString: |
| 103 |
'<table class="dijitInline dijitEditorSmileyPalette dijitPaletteTable"' + |
| 104 |
' cellSpacing=0 cellPadding=0><tbody dojoAttachPoint="gridNode"></tbody></table>', |
| 105 |
|
| 106 |
baseClass: "dijitEditorSmileyPalette", |
| 107 |
|
| 108 |
_palette: [ |
| 109 |
["smile", "laughing", "wink", "grin"], |
| 110 |
["cool", "angry", "half", "eyebrow"], |
| 111 |
["frown", "shy", "goofy", "oops"], |
| 112 |
["tongue", "idea", "angel", "happy"], |
| 113 |
["yes", "no", "crying", ""] |
| 114 |
], |
| 115 |
|
| 116 |
dyeClass: Emoticon, |
| 117 |
|
| 118 |
buildRendering: function(){ |
| 119 |
|
| 120 |
|
| 121 |
this.inherited(arguments); |
| 122 |
|
| 123 |
var i18n = dojo.i18n.getLocalization("dojox.editor.plugins", "Smiley"); |
| 124 |
|
| 125 |
|
| 126 |
var emoticonI18n = {}; |
| 127 |
for(var name in i18n){ |
| 128 |
if(name.substr(0,8) == "emoticon"){ |
| 129 |
emoticonI18n[name.substr(8).toLowerCase()] = i18n[name]; |
| 130 |
} |
| 131 |
} |
| 132 |
this._preparePalette( |
| 133 |
this._palette, |
| 134 |
emoticonI18n |
| 135 |
); |
| 136 |
} |
| 137 |
}); |
| 138 |
|
| 139 |
|
| 140 |
SmileyPalette.Emoticon = Emoticon; |
| 141 |
|
| 142 |
return SmileyPalette; |
| 143 |
}); |