/** * @license Copyright (c) 2003-2014, CKSource - Frederico Knabben. All rights reserved. * For licensing, see LICENSE.md or http://ckeditor.com/license */ CKEDITOR.dialog.add( 'smiley', function( editor ) { var config = editor.config, lang = editor.lang.smiley, images = config.smiley_images, columns = config.smiley_columns || 8, i; // Simulate "this" of a dialog for non-dialog events. // @type {CKEDITOR.dialog} var dialog; var onClick = function( evt ) { var target = evt.data.getTarget(), targetName = target.getName(); if ( targetName == 'a' ) target = target.getChild( 0 ); else if ( targetName != 'img' ) return; var src = target.getAttribute( 'cke_src' ), title = target.getAttribute( 'title' ); var img = editor.document.createElement( 'img', { attributes: { src: src, 'data-cke-saved-src': src, title: title, alt: title, width: target.$.width, height: target.$.height } } ); editor.insertElement( img ); dialog.hide(); evt.data.preventDefault(); }; var onKeydown = CKEDITOR.tools.addFunction( function( ev, element ) { ev = new CKEDITOR.dom.event( ev ); element = new CKEDITOR.dom.element( element ); var relative, nodeToMove; var keystroke = ev.getKeystroke(), 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(); } 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.focus(); } ev.preventDefault(); break; // ENTER // SPACE case 32: onClick( { data: ev } ); ev.preventDefault(); break; // RIGHT-ARROW case rtl ? 37 : 39: // relative is TD if ( ( relative = element.getParent().getNext() ) ) { nodeToMove = relative.getChild( 0 ); nodeToMove.focus(); ev.preventDefault( true ); } // relative is TR else if ( ( relative = element.getParent().getParent().getNext() ) ) { nodeToMove = relative.getChild( [ 0, 0 ] ); if ( nodeToMove ) nodeToMove.focus(); ev.preventDefault( true ); } break; // LEFT-ARROW case rtl ? 39 : 37: // relative is TD if ( ( relative = element.getParent().getPrevious() ) ) { nodeToMove = relative.getChild( 0 ); nodeToMove.focus(); ev.preventDefault( true ); } // relative is TR else if ( ( relative = element.getParent().getParent().getPrevious() ) ) { nodeToMove = relative.getLast().getChild( 0 ); nodeToMove.focus(); ev.preventDefault( true ); } break; default: // Do not stop not handled events. return; } } ); var setBigSmileys = function (dwimages,which) { html.push('
' + '', '' + '' + descr + '' + '', ' | ' ); if ( i % columns == columns - 1 ) html.push( '' ); html.push( '' ); } dwimages = config.dokuFixmeSmiley; setBigSmileys(config.dokuFixmeSmiley,1); if(config.dokuLargeSmiley) { setBigSmileys(config.dokuLargeSmiley,2); } var size = images.length; for ( i = 0; i < size; i++ ) { if ( i % columns === 0 ) html.push( ' |
' + '', '' + '' + config.smiley_descriptions[ i ] + '' + '', ' | ' ); if ( i % columns == columns - 1 ) html.push( '' ); html.push( '' ); } html.push( ' |