]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-includes/js/tinymce/plugins/charmap/plugin.js
WordPress 4.1
[autoinstalls/wordpress.git] / wp-includes / js / tinymce / plugins / charmap / plugin.js
1 /**
2  * plugin.js
3  *
4  * Copyright, Moxiecode Systems AB
5  * Released under LGPL License.
6  *
7  * License: http://www.tinymce.com/license
8  * Contributing: http://www.tinymce.com/contributing
9  */
10
11 /*global tinymce:true */
12
13 tinymce.PluginManager.add('charmap', function(editor) {
14         var charmap = [
15                 ['160', 'no-break space'],
16                 ['38', 'ampersand'],
17                 ['34', 'quotation mark'],
18         // finance
19                 ['162', 'cent sign'],
20                 ['8364', 'euro sign'],
21                 ['163', 'pound sign'],
22                 ['165', 'yen sign'],
23         // signs
24                 ['169', 'copyright sign'],
25                 ['174', 'registered sign'],
26                 ['8482', 'trade mark sign'],
27                 ['8240', 'per mille sign'],
28                 ['181', 'micro sign'],
29                 ['183', 'middle dot'],
30                 ['8226', 'bullet'],
31                 ['8230', 'three dot leader'],
32                 ['8242', 'minutes / feet'],
33                 ['8243', 'seconds / inches'],
34                 ['167', 'section sign'],
35                 ['182', 'paragraph sign'],
36                 ['223', 'sharp s / ess-zed'],
37         // quotations
38                 ['8249', 'single left-pointing angle quotation mark'],
39                 ['8250', 'single right-pointing angle quotation mark'],
40                 ['171', 'left pointing guillemet'],
41                 ['187', 'right pointing guillemet'],
42                 ['8216', 'left single quotation mark'],
43                 ['8217', 'right single quotation mark'],
44                 ['8220', 'left double quotation mark'],
45                 ['8221', 'right double quotation mark'],
46                 ['8218', 'single low-9 quotation mark'],
47                 ['8222', 'double low-9 quotation mark'],
48                 ['60', 'less-than sign'],
49                 ['62', 'greater-than sign'],
50                 ['8804', 'less-than or equal to'],
51                 ['8805', 'greater-than or equal to'],
52                 ['8211', 'en dash'],
53                 ['8212', 'em dash'],
54                 ['175', 'macron'],
55                 ['8254', 'overline'],
56                 ['164', 'currency sign'],
57                 ['166', 'broken bar'],
58                 ['168', 'diaeresis'],
59                 ['161', 'inverted exclamation mark'],
60                 ['191', 'turned question mark'],
61                 ['710', 'circumflex accent'],
62                 ['732', 'small tilde'],
63                 ['176', 'degree sign'],
64                 ['8722', 'minus sign'],
65                 ['177', 'plus-minus sign'],
66                 ['247', 'division sign'],
67                 ['8260', 'fraction slash'],
68                 ['215', 'multiplication sign'],
69                 ['185', 'superscript one'],
70                 ['178', 'superscript two'],
71                 ['179', 'superscript three'],
72                 ['188', 'fraction one quarter'],
73                 ['189', 'fraction one half'],
74                 ['190', 'fraction three quarters'],
75         // math / logical
76                 ['402', 'function / florin'],
77                 ['8747', 'integral'],
78                 ['8721', 'n-ary sumation'],
79                 ['8734', 'infinity'],
80                 ['8730', 'square root'],
81                 ['8764', 'similar to'],
82                 ['8773', 'approximately equal to'],
83                 ['8776', 'almost equal to'],
84                 ['8800', 'not equal to'],
85                 ['8801', 'identical to'],
86                 ['8712', 'element of'],
87                 ['8713', 'not an element of'],
88                 ['8715', 'contains as member'],
89                 ['8719', 'n-ary product'],
90                 ['8743', 'logical and'],
91                 ['8744', 'logical or'],
92                 ['172', 'not sign'],
93                 ['8745', 'intersection'],
94                 ['8746', 'union'],
95                 ['8706', 'partial differential'],
96                 ['8704', 'for all'],
97                 ['8707', 'there exists'],
98                 ['8709', 'diameter'],
99                 ['8711', 'backward difference'],
100                 ['8727', 'asterisk operator'],
101                 ['8733', 'proportional to'],
102                 ['8736', 'angle'],
103         // undefined
104                 ['180', 'acute accent'],
105                 ['184', 'cedilla'],
106                 ['170', 'feminine ordinal indicator'],
107                 ['186', 'masculine ordinal indicator'],
108                 ['8224', 'dagger'],
109                 ['8225', 'double dagger'],
110         // alphabetical special chars
111                 ['192', 'A - grave'],
112                 ['193', 'A - acute'],
113                 ['194', 'A - circumflex'],
114                 ['195', 'A - tilde'],
115                 ['196', 'A - diaeresis'],
116                 ['197', 'A - ring above'],
117                 ['198', 'ligature AE'],
118                 ['199', 'C - cedilla'],
119                 ['200', 'E - grave'],
120                 ['201', 'E - acute'],
121                 ['202', 'E - circumflex'],
122                 ['203', 'E - diaeresis'],
123                 ['204', 'I - grave'],
124                 ['205', 'I - acute'],
125                 ['206', 'I - circumflex'],
126                 ['207', 'I - diaeresis'],
127                 ['208', 'ETH'],
128                 ['209', 'N - tilde'],
129                 ['210', 'O - grave'],
130                 ['211', 'O - acute'],
131                 ['212', 'O - circumflex'],
132                 ['213', 'O - tilde'],
133                 ['214', 'O - diaeresis'],
134                 ['216', 'O - slash'],
135                 ['338', 'ligature OE'],
136                 ['352', 'S - caron'],
137                 ['217', 'U - grave'],
138                 ['218', 'U - acute'],
139                 ['219', 'U - circumflex'],
140                 ['220', 'U - diaeresis'],
141                 ['221', 'Y - acute'],
142                 ['376', 'Y - diaeresis'],
143                 ['222', 'THORN'],
144                 ['224', 'a - grave'],
145                 ['225', 'a - acute'],
146                 ['226', 'a - circumflex'],
147                 ['227', 'a - tilde'],
148                 ['228', 'a - diaeresis'],
149                 ['229', 'a - ring above'],
150                 ['230', 'ligature ae'],
151                 ['231', 'c - cedilla'],
152                 ['232', 'e - grave'],
153                 ['233', 'e - acute'],
154                 ['234', 'e - circumflex'],
155                 ['235', 'e - diaeresis'],
156                 ['236', 'i - grave'],
157                 ['237', 'i - acute'],
158                 ['238', 'i - circumflex'],
159                 ['239', 'i - diaeresis'],
160                 ['240', 'eth'],
161                 ['241', 'n - tilde'],
162                 ['242', 'o - grave'],
163                 ['243', 'o - acute'],
164                 ['244', 'o - circumflex'],
165                 ['245', 'o - tilde'],
166                 ['246', 'o - diaeresis'],
167                 ['248', 'o slash'],
168                 ['339', 'ligature oe'],
169                 ['353', 's - caron'],
170                 ['249', 'u - grave'],
171                 ['250', 'u - acute'],
172                 ['251', 'u - circumflex'],
173                 ['252', 'u - diaeresis'],
174                 ['253', 'y - acute'],
175                 ['254', 'thorn'],
176                 ['255', 'y - diaeresis'],
177                 ['913', 'Alpha'],
178                 ['914', 'Beta'],
179                 ['915', 'Gamma'],
180                 ['916', 'Delta'],
181                 ['917', 'Epsilon'],
182                 ['918', 'Zeta'],
183                 ['919', 'Eta'],
184                 ['920', 'Theta'],
185                 ['921', 'Iota'],
186                 ['922', 'Kappa'],
187                 ['923', 'Lambda'],
188                 ['924', 'Mu'],
189                 ['925', 'Nu'],
190                 ['926', 'Xi'],
191                 ['927', 'Omicron'],
192                 ['928', 'Pi'],
193                 ['929', 'Rho'],
194                 ['931', 'Sigma'],
195                 ['932', 'Tau'],
196                 ['933', 'Upsilon'],
197                 ['934', 'Phi'],
198                 ['935', 'Chi'],
199                 ['936', 'Psi'],
200                 ['937', 'Omega'],
201                 ['945', 'alpha'],
202                 ['946', 'beta'],
203                 ['947', 'gamma'],
204                 ['948', 'delta'],
205                 ['949', 'epsilon'],
206                 ['950', 'zeta'],
207                 ['951', 'eta'],
208                 ['952', 'theta'],
209                 ['953', 'iota'],
210                 ['954', 'kappa'],
211                 ['955', 'lambda'],
212                 ['956', 'mu'],
213                 ['957', 'nu'],
214                 ['958', 'xi'],
215                 ['959', 'omicron'],
216                 ['960', 'pi'],
217                 ['961', 'rho'],
218                 ['962', 'final sigma'],
219                 ['963', 'sigma'],
220                 ['964', 'tau'],
221                 ['965', 'upsilon'],
222                 ['966', 'phi'],
223                 ['967', 'chi'],
224                 ['968', 'psi'],
225                 ['969', 'omega'],
226         // symbols
227                 ['8501', 'alef symbol'],
228                 ['982',  'pi symbol'],
229                 ['8476', 'real part symbol'],
230                 ['978',  'upsilon - hook symbol'],
231                 ['8472', 'Weierstrass p'],
232                 ['8465', 'imaginary part'],
233         // arrows
234                 ['8592', 'leftwards arrow'],
235                 ['8593', 'upwards arrow'],
236                 ['8594', 'rightwards arrow'],
237                 ['8595', 'downwards arrow'],
238                 ['8596', 'left right arrow'],
239                 ['8629', 'carriage return'],
240                 ['8656', 'leftwards double arrow'],
241                 ['8657', 'upwards double arrow'],
242                 ['8658', 'rightwards double arrow'],
243                 ['8659', 'downwards double arrow'],
244                 ['8660', 'left right double arrow'],
245                 ['8756', 'therefore'],
246                 ['8834', 'subset of'],
247                 ['8835', 'superset of'],
248                 ['8836', 'not a subset of'],
249                 ['8838', 'subset of or equal to'],
250                 ['8839', 'superset of or equal to'],
251                 ['8853', 'circled plus'],
252                 ['8855', 'circled times'],
253                 ['8869', 'perpendicular'],
254                 ['8901', 'dot operator'],
255                 ['8968', 'left ceiling'],
256                 ['8969', 'right ceiling'],
257                 ['8970', 'left floor'],
258                 ['8971', 'right floor'],
259                 ['9001', 'left-pointing angle bracket'],
260                 ['9002', 'right-pointing angle bracket'],
261                 ['9674', 'lozenge'],
262                 ['9824', 'black spade suit'],
263                 ['9827', 'black club suit'],
264                 ['9829', 'black heart suit'],
265                 ['9830', 'black diamond suit'],
266                 ['8194', 'en space'],
267                 ['8195', 'em space'],
268                 ['8201', 'thin space'],
269                 ['8204', 'zero width non-joiner'],
270                 ['8205', 'zero width joiner'],
271                 ['8206', 'left-to-right mark'],
272                 ['8207', 'right-to-left mark'],
273                 ['173',  'soft hyphen']
274         ];
275
276         function showDialog() {
277                 var gridHtml, x, y, win;
278
279                 function getParentTd(elm) {
280                         while (elm) {
281                                 if (elm.nodeName == 'TD') {
282                                         return elm;
283                                 }
284
285                                 elm = elm.parentNode;
286                         }
287                 }
288
289                 gridHtml = '<table role="presentation" cellspacing="0" class="mce-charmap"><tbody>';
290
291                 var width = 25;
292                 for (y = 0; y < 10; y++) {
293                         gridHtml += '<tr>';
294
295                         for (x = 0; x < width; x++) {
296                                 var chr = charmap[y * width + x];
297
298                                 gridHtml += '<td title="' + chr[1] + '"><div tabindex="-1" title="' + chr[1] + '" role="button">' +
299                                         (chr ? String.fromCharCode(parseInt(chr[0], 10)) : '&nbsp;') + '</div></td>';
300                         }
301
302                         gridHtml += '</tr>';
303                 }
304
305                 gridHtml += '</tbody></table>';
306
307                 var charMapPanel = {
308                         type: 'container',
309                         html: gridHtml,
310                         onclick: function(e) {
311                                 var target = e.target;
312
313                                 if (target.tagName == 'TD') {
314                                         target = target.firstChild;
315                                 }
316
317                                 if (target.tagName == 'DIV') {
318                                         editor.execCommand('mceInsertContent', false, target.firstChild.data);
319
320                                         if (!e.ctrlKey) {
321                                                 win.close();
322                                         }
323                                 }
324                         },
325                         onmouseover: function(e) {
326                                 var td = getParentTd(e.target);
327
328                                 if (td) {
329                                         win.find('#preview').text(td.firstChild.firstChild.data);
330                                 }
331                         }
332                 };
333
334                 win = editor.windowManager.open({
335                         title: "Special character",
336                         spacing: 10,
337                         padding: 10,
338                         items: [
339                                 charMapPanel,
340                                 {
341                                         type: 'label',
342                                         name: 'preview',
343                                         text: ' ',
344                                         style: 'font-size: 40px; text-align: center',
345                                         border: 1,
346                                         minWidth: 100,
347                                         minHeight: 80
348                                 }
349                         ],
350                         buttons: [
351                                 {text: "Close", onclick: function() {
352                                         win.close();
353                                 }}
354                         ]
355                 });
356         }
357
358         editor.addButton('charmap', {
359                 icon: 'charmap',
360                 tooltip: 'Special character',
361                 onclick: showDialog
362         });
363
364         editor.addMenuItem('charmap', {
365                 icon: 'charmap',
366                 text: 'Special character',
367                 onclick: showDialog,
368                 context: 'insert'
369         });
370 });