1 |
efrain |
1 |
// This file is part of Moodle - http://moodle.org/
|
|
|
2 |
//
|
|
|
3 |
// Moodle is free software: you can redistribute it and/or modify
|
|
|
4 |
// it under the terms of the GNU General Public License as published by
|
|
|
5 |
// the Free Software Foundation, either version 3 of the License, or
|
|
|
6 |
// (at your option) any later version.
|
|
|
7 |
//
|
|
|
8 |
// Moodle is distributed in the hope that it will be useful,
|
|
|
9 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
10 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
11 |
// GNU General Public License for more details.
|
|
|
12 |
//
|
|
|
13 |
// You should have received a copy of the GNU General Public License
|
|
|
14 |
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
15 |
|
|
|
16 |
/*
|
|
|
17 |
* @package atto_charmap
|
|
|
18 |
* @copyright 2014 Frédéric Massart
|
|
|
19 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
20 |
*/
|
|
|
21 |
|
|
|
22 |
/**
|
|
|
23 |
* Atto text editor character map plugin
|
|
|
24 |
*
|
|
|
25 |
* @module moodle-atto_charmap-button
|
|
|
26 |
*/
|
|
|
27 |
|
|
|
28 |
var COMPONENTNAME = 'atto_charmap',
|
|
|
29 |
CSS = {
|
|
|
30 |
BUTTON: 'atto_charmap_character',
|
|
|
31 |
CHARMAP: 'atto_charmap_selector'
|
|
|
32 |
},
|
|
|
33 |
/*
|
|
|
34 |
* Map of special characters, kindly borrowed from TinyMCE.
|
|
|
35 |
*
|
|
|
36 |
* Each entries contains in order:
|
|
|
37 |
* - {String} HTML code
|
|
|
38 |
* - {String} HTML numerical code
|
|
|
39 |
* - {Boolean} Whether or not to include it in the list
|
|
|
40 |
* - {String} The language string key
|
|
|
41 |
*
|
|
|
42 |
* @property CHARMAP
|
|
|
43 |
* @type {Array}
|
|
|
44 |
*/
|
|
|
45 |
CHARMAP = [
|
|
|
46 |
[' ', ' ', true, 'nobreakspace'],
|
|
|
47 |
['&', '&', true, 'ampersand'],
|
|
|
48 |
['"', '"', true, 'quotationmark'],
|
|
|
49 |
['‽', '‽', true, 'interrobang'],
|
|
|
50 |
// Finance.
|
|
|
51 |
['¢', '¢', true, 'centsign'],
|
|
|
52 |
['€', '€', true, 'eurosign'],
|
|
|
53 |
['£', '£', true, 'poundsign'],
|
|
|
54 |
['¥', '¥', true, 'yensign'],
|
|
|
55 |
// Signs.
|
|
|
56 |
['©', '©', true, 'copyrightsign'],
|
|
|
57 |
['®', '®', true, 'registeredsign'],
|
|
|
58 |
['™', '™', true, 'trademarksign'],
|
|
|
59 |
['‰', '‰', true, 'permillesign'],
|
|
|
60 |
['µ', 'µ', true, 'microsign'],
|
|
|
61 |
['·', '·', true, 'middledot'],
|
|
|
62 |
['•', '•', true, 'bullet'],
|
|
|
63 |
['…', '…', true, 'threedotleader'],
|
|
|
64 |
['′', '′', true, 'minutesfeet'],
|
|
|
65 |
['″', '″', true, 'secondsinches'],
|
|
|
66 |
['§', '§', true, 'sectionsign'],
|
|
|
67 |
['¶', '¶', true, 'paragraphsign'],
|
|
|
68 |
['ß', 'ß', true, 'sharpsesszed'],
|
|
|
69 |
// Quotations.
|
|
|
70 |
['‹', '‹', true, 'singleleftpointinganglequotationmark'],
|
|
|
71 |
['›', '›', true, 'singlerightpointinganglequotationmark'],
|
|
|
72 |
['«', '«', true, 'leftpointingguillemet'],
|
|
|
73 |
['»', '»', true, 'rightpointingguillemet'],
|
|
|
74 |
['‘', '‘', true, 'leftsinglequotationmark'],
|
|
|
75 |
['’', '’', true, 'rightsinglequotationmark'],
|
|
|
76 |
['“', '“', true, 'leftdoublequotationmark'],
|
|
|
77 |
['”', '”', true, 'rightdoublequotationmark'],
|
|
|
78 |
['‚', '‚', true, 'singlelow9quotationmark'],
|
|
|
79 |
['„', '„', true, 'doublelow9quotationmark'],
|
|
|
80 |
['<', '<', true, 'lessthansign'],
|
|
|
81 |
['>', '>', true, 'greaterthansign'],
|
|
|
82 |
['≤', '≤', true, 'lessthanorequalto'],
|
|
|
83 |
['≥', '≥', true, 'greaterthanorequalto'],
|
|
|
84 |
['–', '–', true, 'endash'],
|
|
|
85 |
['—', '—', true, 'emdash'],
|
|
|
86 |
['¯', '¯', true, 'macron'],
|
|
|
87 |
['‾', '‾', true, 'overline'],
|
|
|
88 |
['¤', '¤', true, 'currencysign'],
|
|
|
89 |
['¦', '¦', true, 'brokenbar'],
|
|
|
90 |
['¨', '¨', true, 'diaeresis'],
|
|
|
91 |
['¡', '¡', true, 'invertedexclamationmark'],
|
|
|
92 |
['¿', '¿', true, 'turnedquestionmark'],
|
|
|
93 |
['ˆ', 'ˆ', true, 'circumflexaccent'],
|
|
|
94 |
['˜', '˜', true, 'smalltilde'],
|
|
|
95 |
['°', '°', true, 'degreesign'],
|
|
|
96 |
['−', '−', true, 'minussign'],
|
|
|
97 |
['±', '±', true, 'plusminussign'],
|
|
|
98 |
['÷', '÷', true, 'divisionsign'],
|
|
|
99 |
['⁄', '⁄', true, 'fractionslash'],
|
|
|
100 |
['×', '×', true, 'multiplicationsign'],
|
|
|
101 |
['¹', '¹', true, 'superscriptone'],
|
|
|
102 |
['²', '²', true, 'superscripttwo'],
|
|
|
103 |
['³', '³', true, 'superscriptthree'],
|
|
|
104 |
['¼', '¼', true, 'fractiononequarter'],
|
|
|
105 |
['½', '½', true, 'fractiononehalf'],
|
|
|
106 |
['¾', '¾', true, 'fractionthreequarters'],
|
|
|
107 |
// Math / logical.
|
|
|
108 |
['ƒ', 'ƒ', true, 'functionflorin'],
|
|
|
109 |
['∫', '∫', true, 'integral'],
|
|
|
110 |
['∑', '∑', true, 'narysumation'],
|
|
|
111 |
['∞', '∞', true, 'infinity'],
|
|
|
112 |
['√', '√', true, 'squareroot'],
|
|
|
113 |
['∼', '∼', false, 'similarto'],
|
|
|
114 |
['≅', '≅', false, 'approximatelyequalto'],
|
|
|
115 |
['≈', '≈', true, 'almostequalto'],
|
|
|
116 |
['≠', '≠', true, 'notequalto'],
|
|
|
117 |
['≡', '≡', true, 'identicalto'],
|
|
|
118 |
['∈', '∈', false, 'elementof'],
|
|
|
119 |
['∉', '∉', false, 'notanelementof'],
|
|
|
120 |
['∋', '∋', false, 'containsasmember'],
|
|
|
121 |
['∏', '∏', true, 'naryproduct'],
|
|
|
122 |
['∧', '∧', false, 'logicaland'],
|
|
|
123 |
['∨', '∨', false, 'logicalor'],
|
|
|
124 |
['¬', '¬', true, 'notsign'],
|
|
|
125 |
['∩', '∩', true, 'intersection'],
|
|
|
126 |
['∪', '∪', false, 'union'],
|
|
|
127 |
['∂', '∂', true, 'partialdifferential'],
|
|
|
128 |
['∀', '∀', false, 'forall'],
|
|
|
129 |
['∃', '∃', false, 'thereexists'],
|
|
|
130 |
['∅', '∅', false, 'diameter'],
|
|
|
131 |
['∇', '∇', false, 'backwarddifference'],
|
|
|
132 |
['∗', '∗', false, 'asteriskoperator'],
|
|
|
133 |
['∝', '∝', false, 'proportionalto'],
|
|
|
134 |
['∠', '∠', false, 'angle'],
|
|
|
135 |
// Undefined.
|
|
|
136 |
['´', '´', true, 'acuteaccent'],
|
|
|
137 |
['¸', '¸', true, 'cedilla'],
|
|
|
138 |
['ª', 'ª', true, 'feminineordinalindicator'],
|
|
|
139 |
['º', 'º', true, 'masculineordinalindicator'],
|
|
|
140 |
['†', '†', true, 'dagger'],
|
|
|
141 |
['‡', '‡', true, 'doubledagger'],
|
|
|
142 |
// Alphabetical special chars.
|
|
|
143 |
['À', 'À', true, 'agrave_caps'],
|
|
|
144 |
['Á', 'Á', true, 'aacute_caps'],
|
|
|
145 |
['Â', 'Â', true, 'acircumflex_caps'],
|
|
|
146 |
['Ã', 'Ã', true, 'atilde_caps'],
|
|
|
147 |
['Ä', 'Ä', true, 'adiaeresis_caps'],
|
|
|
148 |
['Å', 'Å', true, 'aringabove_caps'],
|
|
|
149 |
['Ā', 'Ā', true, 'amacron_caps'],
|
|
|
150 |
['Æ', 'Æ', true, 'ligatureae_caps'],
|
|
|
151 |
['Ç', 'Ç', true, 'ccedilla_caps'],
|
|
|
152 |
['È', 'È', true, 'egrave_caps'],
|
|
|
153 |
['É', 'É', true, 'eacute_caps'],
|
|
|
154 |
['Ê', 'Ê', true, 'ecircumflex_caps'],
|
|
|
155 |
['Ë', 'Ë', true, 'ediaeresis_caps'],
|
|
|
156 |
['Ē', 'Ē', true, 'emacron_caps'],
|
|
|
157 |
['Ì', 'Ì', true, 'igrave_caps'],
|
|
|
158 |
['Í', 'Í', true, 'iacute_caps'],
|
|
|
159 |
['Î', 'Î', true, 'icircumflex_caps'],
|
|
|
160 |
['Ï', 'Ï', true, 'idiaeresis_caps'],
|
|
|
161 |
['Ī', 'Ī', true, 'imacron_caps'],
|
|
|
162 |
['Ð', 'Ð', true, 'eth_caps'],
|
|
|
163 |
['Ñ', 'Ñ', true, 'ntilde_caps'],
|
|
|
164 |
['Ò', 'Ò', true, 'ograve_caps'],
|
|
|
165 |
['Ó', 'Ó', true, 'oacute_caps'],
|
|
|
166 |
['Ô', 'Ô', true, 'ocircumflex_caps'],
|
|
|
167 |
['Õ', 'Õ', true, 'otilde_caps'],
|
|
|
168 |
['Ö', 'Ö', true, 'odiaeresis_caps'],
|
|
|
169 |
['Ø', 'Ø', true, 'oslash_caps'],
|
|
|
170 |
['Ō', 'Ō', true, 'omacron_caps'],
|
|
|
171 |
['Œ', 'Œ', true, 'ligatureoe_caps'],
|
|
|
172 |
['Š', 'Š', true, 'scaron_caps'],
|
|
|
173 |
['Ù', 'Ù', true, 'ugrave_caps'],
|
|
|
174 |
['Ú', 'Ú', true, 'uacute_caps'],
|
|
|
175 |
['Û', 'Û', true, 'ucircumflex_caps'],
|
|
|
176 |
['Ü', 'Ü', true, 'udiaeresis_caps'],
|
|
|
177 |
['Ū', 'Ū', true, 'umacron_caps'],
|
|
|
178 |
['Ý', 'Ý', true, 'yacute_caps'],
|
|
|
179 |
['Ÿ', 'Ÿ', true, 'ydiaeresis_caps'],
|
|
|
180 |
['Þ', 'Þ', true, 'thorn_caps'],
|
|
|
181 |
['à', 'à', true, 'agrave'],
|
|
|
182 |
['á', 'á', true, 'aacute'],
|
|
|
183 |
['â', 'â', true, 'acircumflex'],
|
|
|
184 |
['ã', 'ã', true, 'atilde'],
|
|
|
185 |
['ä', 'ä', true, 'adiaeresis'],
|
|
|
186 |
['å', 'å', true, 'aringabove'],
|
|
|
187 |
['ā', 'ā', true, 'amacron'],
|
|
|
188 |
['æ', 'æ', true, 'ligatureae'],
|
|
|
189 |
['ç', 'ç', true, 'ccedilla'],
|
|
|
190 |
['è', 'è', true, 'egrave'],
|
|
|
191 |
['é', 'é', true, 'eacute'],
|
|
|
192 |
['ê', 'ê', true, 'ecircumflex'],
|
|
|
193 |
['ë', 'ë', true, 'ediaeresis'],
|
|
|
194 |
['ē', 'ē', true, 'emacron'],
|
|
|
195 |
['ì', 'ì', true, 'igrave'],
|
|
|
196 |
['í', 'í', true, 'iacute'],
|
|
|
197 |
['î', 'î', true, 'icircumflex'],
|
|
|
198 |
['ï', 'ï', true, 'idiaeresis'],
|
|
|
199 |
['ī', 'ī', true, 'imacron'],
|
|
|
200 |
['ð', 'ð', true, 'eth'],
|
|
|
201 |
['ñ', 'ñ', true, 'ntilde'],
|
|
|
202 |
['ò', 'ò', true, 'ograve'],
|
|
|
203 |
['ó', 'ó', true, 'oacute'],
|
|
|
204 |
['ô', 'ô', true, 'ocircumflex'],
|
|
|
205 |
['õ', 'õ', true, 'otilde'],
|
|
|
206 |
['ö', 'ö', true, 'odiaeresis'],
|
|
|
207 |
['ø', 'ø', true, 'oslash'],
|
|
|
208 |
['ō', 'ō', true, 'omacron'],
|
|
|
209 |
['œ', 'œ', true, 'ligatureoe'],
|
|
|
210 |
['š', 'š', true, 'scaron'],
|
|
|
211 |
['ù', 'ù', true, 'ugrave'],
|
|
|
212 |
['ú', 'ú', true, 'uacute'],
|
|
|
213 |
['û', 'û', true, 'ucircumflex'],
|
|
|
214 |
['ü', 'ü', true, 'udiaeresis'],
|
|
|
215 |
['ū', 'ū', true, 'umacron'],
|
|
|
216 |
['ý', 'ý', true, 'yacute'],
|
|
|
217 |
['þ', 'þ', true, 'thorn'],
|
|
|
218 |
['ÿ', 'ÿ', true, 'ydiaeresis'],
|
|
|
219 |
['Α', 'Α', true, 'alpha_caps'],
|
|
|
220 |
['Β', 'Β', true, 'beta_caps'],
|
|
|
221 |
['Γ', 'Γ', true, 'gamma_caps'],
|
|
|
222 |
['Δ', 'Δ', true, 'delta_caps'],
|
|
|
223 |
['Ε', 'Ε', true, 'epsilon_caps'],
|
|
|
224 |
['Ζ', 'Ζ', true, 'zeta_caps'],
|
|
|
225 |
['Η', 'Η', true, 'eta_caps'],
|
|
|
226 |
['Θ', 'Θ', true, 'theta_caps'],
|
|
|
227 |
['Ι', 'Ι', true, 'iota_caps'],
|
|
|
228 |
['Κ', 'Κ', true, 'kappa_caps'],
|
|
|
229 |
['Λ', 'Λ', true, 'lambda_caps'],
|
|
|
230 |
['Μ', 'Μ', true, 'mu_caps'],
|
|
|
231 |
['Ν', 'Ν', true, 'nu_caps'],
|
|
|
232 |
['Ξ', 'Ξ', true, 'xi_caps'],
|
|
|
233 |
['Ο', 'Ο', true, 'omicron_caps'],
|
|
|
234 |
['Π', 'Π', true, 'pi_caps'],
|
|
|
235 |
['Ρ', 'Ρ', true, 'rho_caps'],
|
|
|
236 |
['Σ', 'Σ', true, 'sigma_caps'],
|
|
|
237 |
['Τ', 'Τ', true, 'tau_caps'],
|
|
|
238 |
['Υ', 'Υ', true, 'upsilon_caps'],
|
|
|
239 |
['Φ', 'Φ', true, 'phi_caps'],
|
|
|
240 |
['Χ', 'Χ', true, 'chi_caps'],
|
|
|
241 |
['Ψ', 'Ψ', true, 'psi_caps'],
|
|
|
242 |
['Ω', 'Ω', true, 'omega_caps'],
|
|
|
243 |
['α', 'α', true, 'alpha'],
|
|
|
244 |
['β', 'β', true, 'beta'],
|
|
|
245 |
['γ', 'γ', true, 'gamma'],
|
|
|
246 |
['δ', 'δ', true, 'delta'],
|
|
|
247 |
['ε', 'ε', true, 'epsilon'],
|
|
|
248 |
['ζ', 'ζ', true, 'zeta'],
|
|
|
249 |
['η', 'η', true, 'eta'],
|
|
|
250 |
['θ', 'θ', true, 'theta'],
|
|
|
251 |
['ι', 'ι', true, 'iota'],
|
|
|
252 |
['κ', 'κ', true, 'kappa'],
|
|
|
253 |
['λ', 'λ', true, 'lambda'],
|
|
|
254 |
['μ', 'μ', true, 'mu'],
|
|
|
255 |
['ν', 'ν', true, 'nu'],
|
|
|
256 |
['ξ', 'ξ', true, 'xi'],
|
|
|
257 |
['ο', 'ο', true, 'omicron'],
|
|
|
258 |
['π', 'π', true, 'pi'],
|
|
|
259 |
['ρ', 'ρ', true, 'rho'],
|
|
|
260 |
['ς', 'ς', true, 'finalsigma'],
|
|
|
261 |
['σ', 'σ', true, 'sigma'],
|
|
|
262 |
['τ', 'τ', true, 'tau'],
|
|
|
263 |
['υ', 'υ', true, 'upsilon'],
|
|
|
264 |
['φ', 'φ', true, 'phi'],
|
|
|
265 |
['χ', 'χ', true, 'chi'],
|
|
|
266 |
['ψ', 'ψ', true, 'psi'],
|
|
|
267 |
['ω', 'ω', true, 'omega'],
|
|
|
268 |
// Symbols.
|
|
|
269 |
['ℵ', 'ℵ', false, 'alefsymbol'],
|
|
|
270 |
['ϖ', 'ϖ', false, 'pisymbol'],
|
|
|
271 |
['ℜ', 'ℜ', false, 'realpartsymbol'],
|
|
|
272 |
['ϑ', 'ϑ', false, 'thetasymbol'],
|
|
|
273 |
['ϒ', 'ϒ', false, 'upsilonhooksymbol'],
|
|
|
274 |
['℘', '℘', false, 'weierstrassp'],
|
|
|
275 |
['ℑ', 'ℑ', false, 'imaginarypart'],
|
|
|
276 |
// Arrows.
|
|
|
277 |
['←', '←', true, 'leftwardsarrow'],
|
|
|
278 |
['↑', '↑', true, 'upwardsarrow'],
|
|
|
279 |
['→', '→', true, 'rightwardsarrow'],
|
|
|
280 |
['↓', '↓', true, 'downwardsarrow'],
|
|
|
281 |
['↔', '↔', true, 'leftrightarrow'],
|
|
|
282 |
['↵', '↵', false, 'carriagereturn'],
|
|
|
283 |
['⇐', '⇐', false, 'leftwardsdoublearrow'],
|
|
|
284 |
['⇑', '⇑', false, 'upwardsdoublearrow'],
|
|
|
285 |
['⇒', '⇒', false, 'rightwardsdoublearrow'],
|
|
|
286 |
['⇓', '⇓', false, 'downwardsdoublearrow'],
|
|
|
287 |
['⇔', '⇔', false, 'leftrightdoublearrow'],
|
|
|
288 |
['∴', '∴', false, 'therefore'],
|
|
|
289 |
['⊂', '⊂', false, 'subsetof'],
|
|
|
290 |
['⊃', '⊃', false, 'supersetof'],
|
|
|
291 |
['⊄', '⊄', false, 'notasubsetof'],
|
|
|
292 |
['⊆', '⊆', false, 'subsetoforequalto'],
|
|
|
293 |
['⊇', '⊇', false, 'supersetoforequalto'],
|
|
|
294 |
['⊕', '⊕', false, 'circledplus'],
|
|
|
295 |
['⊗', '⊗', false, 'circledtimes'],
|
|
|
296 |
['⊥', '⊥', false, 'perpendicular'],
|
|
|
297 |
['⋅', '⋅', false, 'dotoperator'],
|
|
|
298 |
['⌈', '⌈', false, 'leftceiling'],
|
|
|
299 |
['⌉', '⌉', false, 'rightceiling'],
|
|
|
300 |
['⌊', '⌊', false, 'leftfloor'],
|
|
|
301 |
['⌋', '⌋', false, 'rightfloor'],
|
|
|
302 |
['⟨', '〈', false, 'leftpointinganglebracket'],
|
|
|
303 |
['⟩', '〉', false, 'rightpointinganglebracket'],
|
|
|
304 |
['◊', '◊', true, 'lozenge'],
|
|
|
305 |
['♠', '♠', true, 'blackspadesuit'],
|
|
|
306 |
['♣', '♣', true, 'blackclubsuit'],
|
|
|
307 |
['♥', '♥', true, 'blackheartsuit'],
|
|
|
308 |
['♦', '♦', true, 'blackdiamondsuit'],
|
|
|
309 |
[' ', ' ', false, 'enspace'],
|
|
|
310 |
[' ', ' ', false, 'emspace'],
|
|
|
311 |
[' ', ' ', false, 'thinspace'],
|
|
|
312 |
['‌', '‌', false, 'zerowidthnonjoiner'],
|
|
|
313 |
['‍', '‍', false, 'zerowidthjoiner'],
|
|
|
314 |
['‎', '‎', false, 'lefttorightmark'],
|
|
|
315 |
['‏', '‏', false, 'righttoleftmark'],
|
|
|
316 |
['­', '­', false, 'softhyphen']
|
|
|
317 |
];
|
|
|
318 |
|
|
|
319 |
/**
|
|
|
320 |
* Atto text editor charmap plugin.
|
|
|
321 |
*
|
|
|
322 |
* @namespace M.atto_charmap
|
|
|
323 |
* @class button
|
|
|
324 |
* @extends M.editor_atto.EditorPlugin
|
|
|
325 |
*/
|
|
|
326 |
|
|
|
327 |
Y.namespace('M.atto_charmap').Button = Y.Base.create('button', Y.M.editor_atto.EditorPlugin, [], {
|
|
|
328 |
/**
|
|
|
329 |
* A reference to the current selection at the time that the dialogue
|
|
|
330 |
* was opened.
|
|
|
331 |
*
|
|
|
332 |
* @property _currentSelection
|
|
|
333 |
* @type Range
|
|
|
334 |
* @private
|
|
|
335 |
*/
|
|
|
336 |
_currentSelection: null,
|
|
|
337 |
|
|
|
338 |
initializer: function() {
|
|
|
339 |
this.addButton({
|
|
|
340 |
icon: 'e/special_character',
|
|
|
341 |
callback: this._displayDialogue
|
|
|
342 |
});
|
|
|
343 |
},
|
|
|
344 |
|
|
|
345 |
/**
|
|
|
346 |
* Display the Character Map selector.
|
|
|
347 |
*
|
|
|
348 |
* @method _displayDialogue
|
|
|
349 |
* @private
|
|
|
350 |
*/
|
|
|
351 |
_displayDialogue: function() {
|
|
|
352 |
// Store the current selection.
|
|
|
353 |
this._currentSelection = this.get('host').getSelection();
|
|
|
354 |
if (this._currentSelection === false) {
|
|
|
355 |
return;
|
|
|
356 |
}
|
|
|
357 |
|
|
|
358 |
var dialogue = this.getDialogue({
|
|
|
359 |
headerContent: M.util.get_string('insertcharacter', COMPONENTNAME),
|
|
|
360 |
focusAfterHide: true
|
|
|
361 |
}, true);
|
|
|
362 |
|
|
|
363 |
// Set the dialogue content, and then show the dialogue.
|
|
|
364 |
dialogue.set('bodyContent', this._getDialogueContent())
|
|
|
365 |
.show();
|
|
|
366 |
},
|
|
|
367 |
|
|
|
368 |
/**
|
|
|
369 |
* Return the dialogue content for the tool.
|
|
|
370 |
*
|
|
|
371 |
* @method _getDialogueContent
|
|
|
372 |
* @private
|
|
|
373 |
* @return {Node} The content to place in the dialogue.
|
|
|
374 |
*/
|
|
|
375 |
_getDialogueContent: function() {
|
|
|
376 |
var template = Y.Handlebars.compile(
|
|
|
377 |
'<div class="{{CSS.CHARMAP}}">' +
|
|
|
378 |
'{{#each CHARMAP}}' +
|
|
|
379 |
'{{#if this.[2]}}' +
|
|
|
380 |
'<button class="btn btn-secondary btn-sm {{../../CSS.BUTTON}}" ' +
|
|
|
381 |
'aria-label="{{get_string this.[3] ../../component}}" ' +
|
|
|
382 |
'title="{{get_string this.[3] ../../component}}" ' +
|
|
|
383 |
'data-character="{{this.[0]}}" ' +
|
|
|
384 |
'>{{{this.[0]}}}</button>' +
|
|
|
385 |
'{{/if}}' +
|
|
|
386 |
'{{/each}}' +
|
|
|
387 |
'</div>'
|
|
|
388 |
);
|
|
|
389 |
|
|
|
390 |
var content = Y.Node.create(template({
|
|
|
391 |
component: COMPONENTNAME,
|
|
|
392 |
CSS: CSS,
|
|
|
393 |
CHARMAP: CHARMAP
|
|
|
394 |
}));
|
|
|
395 |
|
|
|
396 |
content.delegate('click', this._insertChar, '.' + CSS.BUTTON, this);
|
|
|
397 |
return content;
|
|
|
398 |
},
|
|
|
399 |
|
|
|
400 |
/**
|
|
|
401 |
* Insert the picked character into the editor.
|
|
|
402 |
*
|
|
|
403 |
* @method _insertChar
|
|
|
404 |
* @param {EventFacade} e
|
|
|
405 |
* @private
|
|
|
406 |
*/
|
|
|
407 |
_insertChar: function(e) {
|
|
|
408 |
var character = e.target.getData('character');
|
|
|
409 |
|
|
|
410 |
// Hide the dialogue.
|
|
|
411 |
this.getDialogue({
|
|
|
412 |
focusAfterHide: null
|
|
|
413 |
}).hide();
|
|
|
414 |
|
|
|
415 |
var host = this.get('host');
|
|
|
416 |
|
|
|
417 |
// Focus on the last point.
|
|
|
418 |
host.setSelection(this._currentSelection);
|
|
|
419 |
|
|
|
420 |
// And add the character.
|
|
|
421 |
host.insertContentAtFocusPoint(character);
|
|
|
422 |
|
|
|
423 |
// And mark the text area as updated.
|
|
|
424 |
this.markUpdated();
|
|
|
425 |
}
|
|
|
426 |
});
|