/** * @license Copyright (c) 2003-2014, CKSource - Frederico Knabben. All rights reserved. * For licensing, see LICENSE.md or http://ckeditor.com/license */ 'use strict'; CKEDITOR.dialog.add( 'asciimath', function( editor ) { var preview, lang = editor.lang.asciimath; var imagePath = CKEDITOR.plugins.getPath('asciimath') + "images/"; return { title: lang.title, minWidth: 350, minHeight: 100, contents: [ { id: 'info', elements: [ { id: 'equation', type: 'textarea', label: lang.dialogInput, class: 'asciimath_textarea', onLoad: function( widget ) { var that = this; if ( !( CKEDITOR.env.ie && CKEDITOR.env.version == 8 ) ) { this.getInputElement().on( 'keyup', function() { // Add ` and ` for preview. preview.setValue( '`' + that.getInputElement().getValue() + '`' ); } ); $('.Hand').on('click', function() { preview.setValue( '`' + that.getInputElement().getValue() + '`' ); }); } }, setup: function( widget ) { // Remove ` and `. this.setValue( CKEDITOR.plugins.asciimath.trim( widget.data.math ) ); }, commit: function( widget ) { // Add ` and ` to make ASCII be parsed by MathJax by default. widget.setData( 'math', '`' + this.getValue() + '`' ); } }, { id: 'clickInput', type: 'html', html: ''+ '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
' }, { id: 'documentation', type: 'html', html: '
' + '' + lang.docLabel + '' + '
' }, ( !( CKEDITOR.env.ie && CKEDITOR.env.version == 8 ) ) && { id: 'preview', type: 'html', html: '
' + '' + '
', onLoad: function( widget ) { var iFrame = CKEDITOR.document.getById( this.domId ).getChild( 0 ); preview = new CKEDITOR.plugins.asciimath.frameWrapper( iFrame, editor ); }, setup: function( widget ) { preview.setValue( widget.data.math ); } } ] } ] }; } ); // Highlighting formulas. function over(td) { td.className = 'LightBackground Hand' ; } function out(td) { td.className = 'Hand' ; } function Set( string ) { var inputField = document.getElementsByClassName('asciimath_textarea')[0]; inputField.value += string; return false; }