1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
/*
Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
Available via Academic Free License >= 2.1 OR the modified BSD license.
see: http://dojotoolkit.org/license for details
*/
dojo._xdResourceLoaded(function(dojo, dijit, dojox){
return {depends: [["provide", "dojox.editor.plugins._SmileyPalette"],
["require", "dijit._Widget"],
["require", "dijit._PaletteMixin"],
["require", "dojo.i18n"],
["requireLocalization", "dojox.editor.plugins", "Smiley", null, "ROOT,ar,ca,cs,da,de,el,es,fi,fr,he,hu,it,ja,kk,ko,nb,nl,pl,pt,pt-pt,ro,ru,sl,sv,th,tr,zh,zh-tw", "ROOT,ar,ca,cs,da,de,el,es,fi,fr,he,hu,it,ja,kk,ko,nb,nl,pl,pt,pt-pt,ro,ru,sl,sv,th,tr,zh,zh-tw"]],
defineResource: function(dojo, dijit, dojox){if(!dojo._hasResource["dojox.editor.plugins._SmileyPalette"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dojox.editor.plugins._SmileyPalette"] = true;
dojo.provide("dojox.editor.plugins._SmileyPalette");
dojo.require("dijit._Widget");
dojo.require("dijit._PaletteMixin");
dojo.require("dojo.i18n");
;
dojo.experimental("dojox.editor.plugins._SmileyPalette");
dojo.declare("dojox.editor.plugins._SmileyPalette",
[dijit._Widget, dijit._Templated, dijit._PaletteMixin],
{
// summary:
// A keyboard accessible emoticon-picking widget (for inserting smiley characters)
// description:
// Grid showing various emoticons.
// Can be used standalone, or as a popup.
//
// example:
// | <div dojoType="dojox.editor.plugins._SmileyPalette"></div>
//
// example:
// | var picker = new dojox.editor.plugins._SmileyPalette({ },srcNode);
// | picker.startup();
// The template of this widget.
templateString:
'<table class="dijitInline dijitEditorSmileyPalette dijitPaletteTable"' +
' cellSpacing=0 cellPadding=0><tbody dojoAttachPoint="gridNode"></tbody></table>',
baseClass: "dijitEditorSmileyPalette",
_palette: [
["smile", "laughing", "wink", "grin"],
["cool", "angry", "half", "eyebrow"],
["frown", "shy", "goofy", "oops"],
["tongue", "idea", "angel", "happy"],
["yes", "no", "crying", ""]
],
dyeClass: 'dojox.editor.plugins.Emoticon',
buildRendering: function(){
// Instantiate the template, which makes a skeleton into which we'll insert a bunch of
// <img> nodes
this.inherited(arguments);
var i18n = dojo.i18n.getLocalization("dojox.editor.plugins", "Smiley");
// Generate hash from emoticon standard name (like "smile") to translation
var emoticonI18n = {};
for(var name in i18n){
if(name.substr(0,8) == "emoticon"){
emoticonI18n[name.substr(8).toLowerCase()] = i18n[name];
}
}
this._preparePalette(
this._palette,
emoticonI18n
);
}
});
dojo.declare("dojox.editor.plugins.Emoticon",
null,
{
// summary:
// JS Object representing an emoticon
constructor: function(/*String*/ id){
// summary:
// Create emoticon object from an id (like "smile")
// value: String
// alias name 'smile', 'cool' ..
this.id = id;
},
getValue: function(){
// summary:
// Returns a emoticon string in ascii representation, ex: :-)
return dojox.editor.plugins.Emoticon.ascii[this.id];
},
imgHtml: function(/*String*/ clazz){
// summary:
// Return the HTML string for an <img> node that shows this smiley
var eId = "emoticon" + this.id.substr(0,1).toUpperCase() + this.id.substr(1),
src = dojo.moduleUrl("dojox.editor.plugins", "resources/emoticons/" + eId + ".gif"),
label = dojo.i18n.getLocalization("dojox.editor.plugins", "Smiley")[eId],
html = ['<img src=\"',
src,
'\" class=\"',
clazz,
'\" alt=\"',
this.getValue(),
'\" title=\"',
label,
'\">'];
return html.join("");
},
fillCell: function(/*DOMNode*/cell, /*String*/ blankGif){
dojo.place(this.imgHtml("dijitPaletteImg"), cell);
}
});
dojox.editor.plugins.Emoticon.ascii = {
smile: ":-)",
laughing: "lol",
wink: ";-)",
grin: ":-D",
cool: "8-)",
angry: ":-@",
half: ":-/",
eyebrow: "/:)",
frown: ":-(",
shy: ":-$",
goofy: ":-S",
oops: ":-O",
tongue: ":-P",
idea: "(i)",
yes: "(y)",
no: "(n)",
angel: "0:-)",
crying: ":'(",
happy: "=)"
};
dojox.editor.plugins.Emoticon.fromAscii = function(/*String*/str){
// summary:
// Factory to create Emoticon object based on string like ":-)" rather than id like "smile"
var ascii = dojox.editor.plugins.Emoticon.ascii;
for(var i in ascii){
if(str == ascii[i]){
return new dojox.editor.plugins.Emoticon(i);
}
}
return null;
};
}
}};});
|