Import xinha so we can switch from htmlarea and fix a bunch of in-browser issues that htmlarea has
This commit is contained in:
123
xinha/plugins/CharacterMap/character-map.js
Normal file
123
xinha/plugins/CharacterMap/character-map.js
Normal file
@@ -0,0 +1,123 @@
|
||||
// Character Map plugin for HTMLArea
|
||||
// Original Author - Bernhard Pfeifer novocaine@gmx.net
|
||||
HTMLArea.loadStyle( 'CharacterMap.css', 'CharacterMap' );
|
||||
|
||||
function CharacterMap( editor )
|
||||
{
|
||||
this.editor = editor;
|
||||
var cfg = editor.config;
|
||||
var self = this;
|
||||
cfg.registerButton(
|
||||
{
|
||||
id : 'insertcharacter',
|
||||
tooltip : HTMLArea._lc( 'Insert special character', 'CharacterMap' ),
|
||||
image : editor.imgURL( 'ed_charmap.gif', 'CharacterMap' ),
|
||||
textMode : false,
|
||||
action : function( editor ) { self.buttonPress( editor ); }
|
||||
}
|
||||
);
|
||||
cfg.addToolbarElement('insertcharacter', 'createlink', -1);
|
||||
|
||||
if ( cfg.CharacterMap.mode == 'panel' )
|
||||
{
|
||||
editor._CharacterMap = editor.addPanel( 'right' );
|
||||
HTMLArea._addClass( editor._CharacterMap, 'CharacterMap' );
|
||||
|
||||
editor.notifyOn( 'modechange',
|
||||
function( e, args )
|
||||
{
|
||||
if ( args.mode == 'text' ) editor.hidePanel( editor._CharacterMap );
|
||||
}
|
||||
);
|
||||
|
||||
var entites =
|
||||
[
|
||||
'Ÿ', 'š', '@', '"', '¡', '¢', '£', '¤', '¥', '¦',
|
||||
'§', '¨', '©', 'ª', '«', '¬', '¯', '°', '±', '²',
|
||||
'³', '´', 'µ', '¶', '·', '¸', '¹', 'º', '»', '¼',
|
||||
'½', '¾', '¿', '×', 'Ø', '÷', 'ø', 'ƒ', 'ˆ',
|
||||
'˜', '–', '—', '‘', '’', '‚', '“', '”', '„',
|
||||
'†', '‡', '•', '…', '‰', '‹', '›', '€', '™',
|
||||
'À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È',
|
||||
'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ð', 'Ñ',
|
||||
'Ò', 'Ó', 'Ô', 'Õ', 'Ö', '®', '×', 'Ù', 'Ú',
|
||||
'Û', 'Ü', 'Ý', 'Þ', 'ß', 'à', 'á', 'â', 'ã',
|
||||
'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì',
|
||||
'í', 'î', 'ï', 'ð', 'ñ', 'ò', 'ó', 'ô', 'õ',
|
||||
'ö', '÷', 'ø', 'ù', 'ú', 'û', 'ü', 'ý', 'þ',
|
||||
'ÿ', 'Œ', 'œ', 'Š'
|
||||
];
|
||||
|
||||
for ( var i=0; i<entites.length; i++ )
|
||||
this.addEntity( entites[i], i );
|
||||
|
||||
editor.hidePanel( editor._CharacterMap );
|
||||
}
|
||||
};
|
||||
|
||||
// configuration mode : panel or popup
|
||||
HTMLArea.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 : "Creative Commons Attribution-ShareAlike License"
|
||||
};
|
||||
|
||||
CharacterMap._isActive = false;
|
||||
|
||||
CharacterMap.prototype.buttonPress = function( editor )
|
||||
{
|
||||
var cfg = editor.config;
|
||||
if ( cfg.CharacterMap.mode == 'panel' )
|
||||
{
|
||||
if ( this._isActive )
|
||||
{
|
||||
this._isActive = false;
|
||||
editor.hidePanel( editor._CharacterMap );
|
||||
}
|
||||
else
|
||||
{
|
||||
this._isActive = true;
|
||||
editor.showPanel( editor._CharacterMap );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
editor._popupDialog( "plugin://CharacterMap/select_character", function( entity )
|
||||
{
|
||||
if ( !entity ) return false;
|
||||
if ( HTMLArea.is_ie ) editor.focusEditor();
|
||||
editor.insertHTML( entity );
|
||||
}, null);
|
||||
}
|
||||
};
|
||||
|
||||
CharacterMap.prototype.addEntity = function ( entite, pos )
|
||||
{
|
||||
editor = this.editor;
|
||||
var self = this;
|
||||
var a = document.createElement( 'a' );
|
||||
HTMLArea._addClass( a, 'entity' );
|
||||
a.innerHTML = entite;
|
||||
a.href = 'javascript:void(0)';
|
||||
HTMLArea._addClass(a, (pos%2)? 'light':'dark');
|
||||
a.onclick = function()
|
||||
{
|
||||
if (HTMLArea.is_ie) editor.focusEditor();
|
||||
editor.insertHTML( entite );
|
||||
self._isActive = false;
|
||||
editor.hidePanel( editor._CharacterMap );
|
||||
return false;
|
||||
};
|
||||
editor._CharacterMap.appendChild( a );
|
||||
};
|
||||
Reference in New Issue
Block a user