1 | // Character Map plugin for HTMLArea |
---|
2 | // Sponsored by http://www.systemconcept.de |
---|
3 | // Implementation by Holger Hees based on HTMLArea XTD 1.5 (http://mosforge.net/projects/htmlarea3xtd/) |
---|
4 | // Original Author - Bernhard Pfeifer novocaine@gmx.net |
---|
5 | // |
---|
6 | // (c) systemconcept.de 2004 |
---|
7 | // Distributed under the same terms as HTMLArea itself. |
---|
8 | // This notice MUST stay intact for use (see license.txt). |
---|
9 | |
---|
10 | function CharacterMap(editor) { |
---|
11 | this.editor = editor; |
---|
12 | |
---|
13 | var cfg = editor.config; |
---|
14 | var toolbar = cfg.toolbar; |
---|
15 | var self = this; |
---|
16 | var i18n = CharacterMap.I18N; |
---|
17 | |
---|
18 | cfg.registerButton({ |
---|
19 | id : "insertcharacter", |
---|
20 | tooltip : i18n["CharacterMapTooltip"], |
---|
21 | image : editor.imgURL("ed_charmap.gif", "CharacterMap"), |
---|
22 | textMode : false, |
---|
23 | action : function(editor) { |
---|
24 | self.buttonPress(editor); |
---|
25 | } |
---|
26 | }) |
---|
27 | |
---|
28 | var a, i, j, found = false; |
---|
29 | for (i = 0; !found && i < toolbar.length; ++i) { |
---|
30 | a = toolbar[i]; |
---|
31 | for (j = 0; j < a.length; ++j) { |
---|
32 | if (a[j] == "inserthorizontalrule") { |
---|
33 | found = true; |
---|
34 | break; |
---|
35 | } |
---|
36 | } |
---|
37 | } |
---|
38 | if (found) |
---|
39 | a.splice(j, 0, "insertcharacter"); |
---|
40 | else{ |
---|
41 | toolbar[1].splice(0, 0, "separator"); |
---|
42 | toolbar[1].splice(0, 0, "insertcharacter"); |
---|
43 | } |
---|
44 | }; |
---|
45 | |
---|
46 | CharacterMap._pluginInfo = { |
---|
47 | name : "CharacterMap", |
---|
48 | version : "1.0", |
---|
49 | developer : "Holger Hees & Bernhard Pfeifer", |
---|
50 | developer_url : "http://www.systemconcept.de/", |
---|
51 | c_owner : "Holger Hees & Bernhard Pfeifer", |
---|
52 | sponsor : "System Concept GmbH & Bernhard Pfeifer", |
---|
53 | sponsor_url : "http://www.systemconcept.de/", |
---|
54 | license : "htmlArea" |
---|
55 | }; |
---|
56 | |
---|
57 | CharacterMap.prototype.buttonPress = function(editor) { |
---|
58 | editor._popupDialog( "plugin://CharacterMap/select_character", function( entity ) |
---|
59 | { |
---|
60 | if ( !entity ) |
---|
61 | { |
---|
62 | //user must have pressed Cancel |
---|
63 | return false; |
---|
64 | } |
---|
65 | |
---|
66 | editor.insertHTML( entity ); |
---|
67 | |
---|
68 | }, null); |
---|
69 | } |
---|