/* Equation Editor Plugin for CKEditor v4 Version 1.4 This plugin allows equations to be created and edited from within CKEditor. For more information goto: http://www.codecogs.com/latex/integration/ckeditor_v4/install.php Copyright CodeCogs 2006-2013 Written by Will Bateman. Special Thanks to: - Kyle Jones for a fix to allow multiple editor to load on one page */ window.CCounter=0; CKEDITOR.dialog.add( 'eqneditorDialog', function(editor) { var http = ('https:' == document.location.protocol ? 'https://' : 'http://'); window.CCounter++; return { title : editor.lang.eqneditor.title, minWidth : 550, minHeight : 380, resizable: CKEDITOR.DIALOG_RESIZE_NONE, contents : [ { id : 'CCEquationEditor', label : 'EqnEditor', elements : [ { type: 'html', html: '
', style: 'margin-top:-9px' }, { type: 'html', html: '', }, { type: 'html', html: '', style:'border:1px solid #8fb6bd; width:540px; font-size:16px; padding:5px; background-color:#ffc', }, { type: 'html', html: '' }, { type :'html', html: '
Powered by CodeCogs   About | Install | Forum | CodeCogs © 2007-2013
' } ] } ], onLoad : function() { EqEditor.embed('CCtoolbar'+window.CCounter,'','efull'); EqEditor.add(new EqTextArea('CCequation'+window.CCounter, 'CClatex'+window.CCounter), false); }, onShow : function() { var dialog = this, sel = editor.getSelection(), image = sel.getStartElement().getAscendant('img',true); // has the users selected an equation. Make sure we have the image element, include itself if(image) { var sName = image.getAttribute('src').match( /(gif|svg)\.latex\?(.*)/ ); if(sName!=null) EqEditor.getTextArea().setText(sName[2]); dialog.insertMode = true; } // set-up the field values based on selected or newly created image dialog.setupContent( dialog.image ); }, onOk : function() { var eqn = editor.document.createElement( 'img' ); eqn.setAttribute( 'alt', EqEditor.getTextArea().getLaTeX()); eqn.setAttribute( 'src', EqEditor.getTextArea().exportEquation('urlencoded')); editor.insertElement(eqn); } }; });