/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ CKEDITOR.dialog.add( 'specialchar', function( editor ) { /** * Simulate "this" of a dialog for non-dialog events. * @type {CKEDITOR.dialog} */ var dialog, lang = editor.lang.specialChar; var insertSpecialChar = function ( specialChar ) { var selection = editor.getSelection(), ranges = selection.getRanges(), range, textNode; editor.fire( 'saveSnapshot' ); for ( var i = 0, len = ranges.length ; i < len ; i++ ) { range = ranges[ i ]; range.deleteContents(); textNode = CKEDITOR.dom.element.createFromHtml( specialChar ); range.insertNode( textNode ); } range.moveToPosition( textNode, CKEDITOR.POSITION_AFTER_END ); range.select(); editor.fire( 'saveSnapshot' ); }; var onChoice = function( evt ) { var target, value; if ( evt.data ) target = evt.data.getTarget(); else target = new CKEDITOR.dom.element( evt ); if ( target.getName() == 'a' && ( value = target.getChild( 0 ).getHtml() ) ) { target.removeClass( "cke_light_background" ); dialog.hide(); // Firefox has bug on insert chars into a element use its own API. (#5170) if ( CKEDITOR.env.gecko ) insertSpecialChar( value ); else editor.insertHtml( value ); } }; var onClick = CKEDITOR.tools.addFunction( onChoice ); var focusedNode; var onFocus = function( evt, target ) { var value; target = target || evt.data.getTarget(); if ( target.getName() == 'span' ) target = target.getParent(); if ( target.getName() == 'a' && ( value = target.getChild( 0 ).getHtml() ) ) { // Trigger blur manually if there is focused node. if ( focusedNode ) onBlur( null, focusedNode ); var htmlPreview = dialog.getContentElement( 'info', 'htmlPreview' ).getElement(); dialog.getContentElement( 'info', 'charPreview' ).getElement().setHtml( value ); htmlPreview.setHtml( CKEDITOR.tools.htmlEncode( value ) ); target.getParent().addClass( "cke_light_background" ); // Memorize focused node. focusedNode = target; } }; var onBlur = function( evt, target ) { target = target || evt.data.getTarget(); if ( target.getName() == 'span' ) target = target.getParent(); if ( target.getName() == 'a' ) { dialog.getContentElement( 'info', 'charPreview' ).getElement().setHtml( ' ' ); dialog.getContentElement( 'info', 'htmlPreview' ).getElement().setHtml( ' ' ); target.getParent().removeClass( "cke_light_background" ); focusedNode = undefined; } }; var onKeydown = CKEDITOR.tools.addFunction( function( ev ) { ev = new CKEDITOR.dom.event( ev ); // Get an Anchor element. var element = ev.getTarget(); var relative, nodeToMove; var keystroke = ev.getKeystroke(); var rtl = editor.lang.dir == 'rtl'; switch ( keystroke ) { // UP-ARROW case 38 : // relative is TR if ( ( relative = element.getParent().getParent().getPrevious() ) ) { nodeToMove = relative.getChild( [element.getParent().getIndex(), 0] ); nodeToMove.focus(); onBlur( null, element ); onFocus( null, nodeToMove ); } ev.preventDefault(); break; // DOWN-ARROW case 40 : // relative is TR if ( ( relative = element.getParent().getParent().getNext() ) ) { nodeToMove = relative.getChild( [ element.getParent().getIndex(), 0 ] ); if ( nodeToMove && nodeToMove.type == 1 ) { nodeToMove.focus(); onBlur( null, element ); onFocus( null, nodeToMove ); } } ev.preventDefault(); break; // SPACE // ENTER is already handled as onClick case 32 : onChoice( { data: ev } ); ev.preventDefault(); break; // RIGHT-ARROW case rtl ? 37 : 39 : // TAB case 9 : // relative is TD if ( ( relative = element.getParent().getNext() ) ) { nodeToMove = relative.getChild( 0 ); if ( nodeToMove.type == 1 ) { nodeToMove.focus(); onBlur( null, element ); onFocus( null, nodeToMove ); ev.preventDefault( true ); } else onBlur( null, element ); } // relative is TR else if ( ( relative = element.getParent().getParent().getNext() ) ) { nodeToMove = relative.getChild( [ 0, 0 ] ); if ( nodeToMove && nodeToMove.type == 1 ) { nodeToMove.focus(); onBlur( null, element ); onFocus( null, nodeToMove ); ev.preventDefault( true ); } else onBlur( null, element ); } break; // LEFT-ARROW case rtl ? 39 : 37 : // SHIFT + TAB case CKEDITOR.SHIFT + 9 : // relative is TD if ( ( relative = element.getParent().getPrevious() ) ) { nodeToMove = relative.getChild( 0 ); nodeToMove.focus(); onBlur( null, element ); onFocus( null, nodeToMove ); ev.preventDefault( true ); } // relative is TR else if ( ( relative = element.getParent().getParent().getPrevious() ) ) { nodeToMove = relative.getLast().getChild( 0 ); nodeToMove.focus(); onBlur( null, element ); onFocus( null, nodeToMove ); ev.preventDefault( true ); } else onBlur( null, element ); break; default : // Do not stop not handled events. return; } }); return { title : lang.title, minWidth : 430, minHeight : 280, buttons : [ CKEDITOR.dialog.cancelButton ], charColumns : 17, chars : [ '!','"','#','$','%','&',"'",'(',')','*','+','-','.','/', '0','1','2','3','4','5','6','7','8','9',':',';', '<','=','>','?','@', 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O', 'P','Q','R','S','T','U','V','W','X','Y','Z', '[',']','^','_','`', 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p', 'q','r','s','t','u','v','w','x','y','z', '{','|','}','~','€(EURO SIGN)','‘(LEFT SINGLE QUOTATION MARK)','’(RIGHT SINGLE QUOTATION MARK)','“(LEFT DOUBLE QUOTATION MARK)', '”(RIGHT DOUBLE QUOTATION MARK)','–(EN DASH)','—(EM DASH)','¡(INVERTED EXCLAMATION MARK)','¢(CENT SIGN)','£(POUND SIGN)', '¤(CURRENCY SIGN)','¥(YEN SIGN)','¦(BROKEN BAR)','§(SECTION SIGN)','¨(DIAERESIS)','©(COPYRIGHT SIGN)','ª(FEMININE ORDINAL INDICATOR)', '«(LEFT-POINTING DOUBLE ANGLE QUOTATION MARK)','¬(NOT SIGN)','®(REGISTERED SIGN)','¯(MACRON)','°(DEGREE SIGN)','±(PLUS-MINUS SIGN)','²(SUPERSCRIPT TWO)', '³(SUPERSCRIPT THREE)','´(ACUTE ACCENT)','µ(MICRO SIGN)','¶(PILCROW SIGN)','·(MIDDLE DOT)','¸(CEDILLA)', '¹(SUPERSCRIPT ONE)','º(MASCULINE ORDINAL INDICATOR)','»(RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK)','¼(VULGAR FRACTION ONE QUARTER)','½(VULGAR FRACTION ONE HALF)','¾(VULGAR FRACTION THREE QUARTERS)', '¿(INVERTED QUESTION MARK)','À(LATIN CAPITAL LETTER A WITH GRAVE)','Á(LATIN CAPITAL LETTER A WITH ACUTE)','Â(LATIN CAPITAL LETTER A WITH CIRCUMFLEX)','Ã(LATIN CAPITAL LETTER A WITH TILDE)','Ä(LATIN CAPITAL LETTER A WITH DIAERESIS)', 'Å(LATIN CAPITAL LETTER A WITH RING ABOVE)','Æ(LATIN CAPITAL LETTER AE)','Ç(LATIN CAPITAL LETTER C WITH CEDILLA)','È(LATIN CAPITAL LETTER E WITH GRAVE)','É(LATIN CAPITAL LETTER E WITH ACUTE)','Ê(LATIN CAPITAL LETTER E WITH CIRCUMFLEX)', 'Ë(LATIN CAPITAL LETTER E WITH DIAERESIS)','Ì(LATIN CAPITAL LETTER I WITH GRAVE)','Í(LATIN CAPITAL LETTER I WITH ACUTE)','Î(LATIN CAPITAL LETTER I WITH CIRCUMFLEX)','Ï(LATIN CAPITAL LETTER I WITH DIAERESIS)','Ð(LATIN CAPITAL LETTER ETH)', 'Ñ(LATIN CAPITAL LETTER N WITH TILDE)','Ò(LATIN CAPITAL LETTER O WITH GRAVE)','Ó(LATIN CAPITAL LETTER O WITH ACUTE)','Ô(LATIN CAPITAL LETTER O WITH CIRCUMFLEX)','Õ(LATIN CAPITAL LETTER O WITH TILDE)','Ö(LATIN CAPITAL LETTER O WITH DIAERESIS)', '×(MULTIPLICATION SIGN)','Ø(LATIN CAPITAL LETTER O WITH STROKE)','Ù(LATIN CAPITAL LETTER U WITH GRAVE)','Ú(LATIN CAPITAL LETTER U WITH ACUTE)','Û(LATIN CAPITAL LETTER U WITH CIRCUMFLEX)','Ü(LATIN CAPITAL LETTER U WITH DIAERESIS)', 'Ý(LATIN CAPITAL LETTER Y WITH ACUTE)','Þ(LATIN CAPITAL LETTER THORN)','ß(LATIN SMALL LETTER SHARP S)','à(LATIN SMALL LETTER A WITH GRAVE)','á(LATIN SMALL LETTER A WITH ACUTE)','â(LATIN SMALL LETTER A WITH CIRCUMFLEX)', 'ã(LATIN SMALL LETTER A WITH TILDE)','ä(LATIN SMALL LETTER A WITH DIAERESIS)','å(LATIN SMALL LETTER A WITH RING ABOVE)','æ(LATIN SMALL LETTER AE)','ç(LATIN SMALL LETTER C WITH CEDILLA)','è(LATIN SMALL LETTER E WITH GRAVE)', 'é(LATIN SMALL LETTER E WITH ACUTE)','ê(LATIN SMALL LETTER E WITH CIRCUMFLEX)','ë(LATIN SMALL LETTER E WITH DIAERESIS)','ì(LATIN SMALL LETTER I WITH GRAVE)','í(LATIN SMALL LETTER I WITH ACUTE)','î(LATIN SMALL LETTER I WITH CIRCUMFLEX)', 'ï(LATIN SMALL LETTER I WITH DIAERESIS)','ð(LATIN SMALL LETTER ETH)','ñ(LATIN SMALL LETTER N WITH TILDE)','ò(LATIN SMALL LETTER O WITH GRAVE)','ó(LATIN SMALL LETTER O WITH ACUTE)','ô(LATIN SMALL LETTER O WITH CIRCUMFLEX)', 'õ(LATIN SMALL LETTER O WITH TILDE)','ö(LATIN SMALL LETTER O WITH DIAERESIS)', '÷(DIVISION SIGN)','ø(LATIN SMALL LETTER O WITH STROKE)', 'ù(LATIN SMALL LETTER U WITH GRAVE)','ú(LATIN SMALL LETTER U WITH ACUTE)', 'û(LATIN SMALL LETTER U WITH CIRCUMFLEX)','ü(LATIN SMALL LETTER U WITH DIAERESIS)', 'ü(LATIN SMALL LETTER U WITH DIAERESIS)','ý(LATIN SMALL LETTER Y WITH ACUTE)','þ(LATIN SMALL LETTER THORN)','ÿ(LATIN SMALL LETTER Y WITH DIAERESIS)', 'Œ(LATIN CAPITAL LIGATURE OE)', 'œ(LATIN SMALL LIGATURE OE)','Ŵ(LATIN CAPITAL LETTER W WITH CIRCUMFLEX)', 'Ŷ(LATIN CAPITAL LETTER Y WITH CIRCUMFLEX)','ŵ(LATIN SMALL LETTER W WITH CIRCUMFLEX)', 'ŷ(LATIN SMALL LETTER Y WITH CIRCUMFLEX)','‚(SINGLE LOW-9 QUOTATION MARK)', '‛(SINGLE HIGH-REVERSED-9 QUOTATION MARK)','„(DOUBLE LOW-9 QUOTATION MARK)','…(HORIZONTAL ELLIPSIS)', '™(TRADE MARK SIGN)','►(BLACK RIGHT-POINTING POINTER)','•(BULLET)', '→(RIGHTWARDS ARROW)','⇒(RIGHTWARDS DOUBLE ARROW)','⇔(LEFT RIGHT DOUBLE ARROW)','♦(BLACK DIAMOND SUIT)','≈(ALMOST EQUAL TO)' ], onLoad : function() { var columns = this.definition.charColumns, chars = this.definition.chars; var html = [ '' ]; var i = 0, size = chars.length, character, charDesc; while ( i < size ) { html.push( '' ) ; for ( var j = 0 ; j < columns ; j++, i++ ) { if ( ( character = chars[ i ] ) ) { charDesc = ''; character = character.replace( /\((.*?)\)/, function( match, desc ) { charDesc = desc; return ''; } ); // Use character in case description unavailable. charDesc = charDesc || character; html.push( '' ); } html.push( '' ); } html.push( '
 ' ); html.push( '
', '' + lang.options +'' ); this.getContentElement( 'info', 'charContainer' ).getElement().setHtml( html.join( '' ) ); }, contents : [ { id : 'info', label : editor.lang.common.generalTab, title : editor.lang.common.generalTab, padding : 0, align : 'top', elements : [ { type : 'hbox', align : 'top', widths : [ '320px', '90px' ], children : [ { type : 'html', id : 'charContainer', html : '', onMouseover : onFocus, onMouseout : onBlur, focus : function() { var firstChar = this.getElement().getElementsByTag( 'a' ).getItem( 0 ); setTimeout(function() { firstChar.focus(); onFocus( null, firstChar ); }); }, onShow : function() { var firstChar = this.getElement().getChild( [ 0, 0, 0, 0, 0 ] ); setTimeout( function() { firstChar.focus(); onFocus( null, firstChar ); }); }, onLoad : function( event ) { dialog = event.sender; } }, { type : 'hbox', align : 'top', widths : [ '100%' ], children : [ { type : 'vbox', align : 'top', children : [ { type : 'html', html : '
' }, { type : 'html', id : 'charPreview', className : 'cke_dark_background', style : 'border:1px solid #eeeeee;font-size:28px;height:40px;width:70px;padding-top:9px;font-family:\'Microsoft Sans Serif\',Arial,Helvetica,Verdana;text-align:center;', html : '
 
' }, { type : 'html', id : 'htmlPreview', className : 'cke_dark_background', style : 'border:1px solid #eeeeee;font-size:14px;height:20px;width:70px;padding-top:2px;font-family:\'Microsoft Sans Serif\',Arial,Helvetica,Verdana;text-align:center;', html : '
 
' } ] } ] } ] } ] } ] }; } );