| // Character Map plugin for Xinha |
| // Original Author - Bernhard Pfeifer novocaine@gmx.net |
| Xinha.loadStyle( 'CharacterMap.css', 'CharacterMap' ); |
| |
| function CharacterMap( editor ) |
| { |
| this.editor = editor; |
| var cfg = editor.config; |
| var self = this; |
| cfg.registerButton( |
| { |
| id : 'insertcharacter', |
| tooltip : Xinha._lc( 'Insert special character', 'CharacterMap' ), |
| image : editor.imgURL('images/tango/16x16/apps/accessories-character-map.png'), |
| textMode : false, |
| action : function() { self.show(); } |
| } |
| ); |
| cfg.addToolbarElement('insertcharacter', 'createlink', -1); |
| |
| } |
| |
| // configuration mode : panel or popup |
| Xinha.Config.prototype.CharacterMap = |
| { |
| 'mode': 'popup' // configuration mode : panel or popup |
| }; |
| |
| CharacterMap._pluginInfo = |
| { |
| name : "CharacterMap", |
| version : "2.0", |
| developer : "Laurent Vilday", |
| developer_url : "http://www.mokhet.com/", |
| c_owner : "Xinha community", |
| sponsor : "", |
| sponsor_url : "", |
| license : "HTMLArea" |
| }; |
| |
| CharacterMap._isActive = false; |
| |
| |
| CharacterMap.prototype.addEntity = function ( entite, pos ) |
| { |
| var editor = this.editor; |
| var self = this; |
| var a = document.createElement( 'a' ); |
| Xinha._addClass( a, 'entity' ); |
| a.innerHTML = entite; |
| a.href = 'javascript:void(0)'; |
| Xinha._addClass(a, (pos%2)? 'light':'dark'); |
| a.onclick = function() |
| { |
| if (Xinha.is_ie) editor.focusEditor(); |
| editor.insertHTML( entite ); |
| //self._isActive = false; |
| //editor.hidePanel( editor._CharacterMap ); |
| return false; |
| }; |
| this.dialog.main.appendChild( a ); |
| a = null; |
| }; |
| |
| CharacterMap.prototype.onGenerateOnce = function() |
| { |
| this._prepareDialog(); |
| }; |
| |
| CharacterMap.prototype._prepareDialog = function() |
| { |
| var self = this; |
| var editor = this.editor; |
| |
| var html = '<h1><l10n>Insert special character</l10n></h1>'; |
| |
| // Now we have everything we need, so we can build the dialog. |
| this.dialog = new Xinha.Dialog(editor, html, 'CharacterMap',{width:300},{modal:false}); |
| Xinha._addClass( this.dialog.rootElem, 'CharacterMap' ); |
| |
| if (editor.config.CharacterMap && editor.config.CharacterMap.mode == 'panel') this.dialog.attachToPanel('right'); |
| |
| var entites = |
| [ |
| 'Ÿ', 'š', '@', '"', '¡', '¢', '£', '¤', '¥', '¦', |
| '§', '¨', '©', 'ª', '«', '¬', '¯', '°', '±', '²', |
| '³', '´', 'µ', '¶', '·', '¸', '¹', 'º', '»', '¼', |
| '½', '¾', '¿', '×', 'Ø', '÷', 'ø', 'ƒ', 'ˆ', |
| '˜', '–', '—', '‘', '’', '‚', '“', '”', '„', |
| '†', '‡', '•', '…', '‰', '‹', '›', '€', '™', |
| 'À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È', |
| 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ð', 'Ñ', |
| 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', '®', '×', 'Ù', 'Ú', |
| 'Û', 'Ü', 'Ý', 'Þ', 'ß', 'à', 'á', 'â', 'ã', |
| 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', |
| 'í', 'î', 'ï', 'ð', 'ñ', 'ò', 'ó', 'ô', 'õ', |
| 'ö', '÷', 'ø', 'ù', 'ú', 'û', 'ü', 'ý', 'þ', |
| 'ÿ', 'Œ', 'œ', 'Š' |
| ]; |
| |
| for ( var i=0; i<entites.length; i++ ) |
| { |
| this.addEntity( entites[i], i ); |
| } |
| |
| this.ready = true; |
| //this.hide(); |
| }; |
| |
| CharacterMap.prototype.show = function() |
| { |
| if(!this.ready) // if the user is too fast clicking the, we have to make them wait |
| { |
| var self = this; |
| window.setTimeout(function() {self.show();},100); |
| return; |
| } |
| this.dialog.toggle(); |
| }; |
| CharacterMap.prototype.hide = function() |
| { |
| this.dialog.hide(); |
| }; |
| |