Index: lams_central/web/ckeditor/plugins/equation/images/equation.gif =================================================================== diff -u Binary files differ Index: lams_central/web/ckeditor/plugins/equation/lang/en.js =================================================================== diff -u --- lams_central/web/ckeditor/plugins/equation/lang/en.js (revision 0) +++ lams_central/web/ckeditor/plugins/equation/lang/en.js (revision e215b142c7d6806421645b25dbd5a45a23c129bc) @@ -0,0 +1,11 @@ + +CKEDITOR.plugins.setLang( 'equation', 'en', +{ + equation : + { + title : 'CodeCogs Equation Editor', + menu : 'Equation', + toolbar : 'Create Equation', + edit : 'Edit Equation', + } +}); Index: lams_central/web/ckeditor/plugins/equation/plugin.js =================================================================== diff -u --- lams_central/web/ckeditor/plugins/equation/plugin.js (revision 0) +++ lams_central/web/ckeditor/plugins/equation/plugin.js (revision e215b142c7d6806421645b25dbd5a45a23c129bc) @@ -0,0 +1,158 @@ +/* + Copyright CodeCogs 2006-2011 + Written by Will Bateman. + + Version 1: CK Editor Plugin that insert LaTeX into HTML +*/ + + + +/* +Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved. +For licensing, see LICENSE.html or http://ckeditor.com/license +*/ + +var currentEdit=null; + +(function() +{ + var popupEqnwin=null; + var createEqnDefinition = + { + preserveState:true, + editorFocus:false, + exec : function(editor, latex) + { + // LAMS fix; in original file was: currentEdit=CKEDITOR.currentInstance; + currentEdit=editor; + + //open a popup window when the button is clicked + if (popupEqnwin==null || popupEqnwin.closed || !popupEqnwin.location) + { + var url='http://latex.codecogs.com/editor_json3.php?type=url&editor=CKEditor'; + + //if(language!='') url+='&lang='+language; + if(latex!==undefined) + { + latex=unescape(latex); + latex=latex.replace(/\+/g,'+'); + url+='&latex='+escape(latex); + } + + popupEqnwin=window.open('','LaTexEditor','width=700,height=450,status=1,scrollbars=yes,resizable=1'); + if (!popupEqnwin.opener) popupEqnwin.opener = self; + popupEqnwin.document.open(); + popupEqnwin.document.write(''); + popupEqnwin.document.close(); + } + else if (window.focus) + { + popupEqnwin.focus() + if(latex!==undefined) + { + latex=unescape(latex); + latex = latex.replace(/\\/g,'\\\\'); + latex = latex.replace(/\'/g,'\\\''); + latex = latex.replace(/\"/g,'\\"'); + latex = latex.replace(/\0/g,'\\0'); + + eval("var old = popupEqnwin.document.getElementById('JSONload')"); + if (old != null) { + old.parentNode.removeChild(old); + delete old; + } + + var head = popupEqnwin.document.getElementsByTagName("head")[0]; + var script = document.createElement("script"); + script.type = "text/javascript"; + script.id = 'JSONload'; + script.innerHTML = 'EqEditor.load(\''+(latex)+'\');'; + head.appendChild(script); + } + } + } + }; + + CKEDITOR.plugins.add( 'equation', + { + lang : ['en'], + + init : function( editor ) + { + var com="equation"; + + // Add the link and unlink buttons. + editor.addCommand( com, createEqnDefinition); + + editor.ui.addButton( 'equation', + { + label : editor.lang.equation.title, + command : com, + icon: this.path + 'images/equation.gif' + }); + + // If the "menu" plugin is loaded, register the menu items. + if ( editor.addMenuItems ) + { + editor.addMenuItems( + { + equation : + { + label : 'Edit Equation', + command : 'equation', + group : 'equation' + } + }); + } + + editor.on( 'doubleclick', function(evt) + { + var element = evt.data.element; + if (element && element.is('img')) + { + var sName = element.getAttribute('src').match( /(gif|svg)\.latex\?(.*)/ ); + if(sName!=null) + { + // LAMS fix; a special field in global CKEDITOR object so later call to function CKEditor_Add() + // knows which editor to update; no other approach (currentEdit,CKEDITOR.currentInstance) was working; + CKEDITOR.equationInstance=evt.editor; + + createEqnDefinition.exec(null, sName[2]); + evt.cancelBubble = true; + evt.returnValue = false; + evt.stopPropagation(); + } + } + }, null, null, 1); + + } + + + }); + + + // Add a new placeholder at the actual selection. + CKEditor_Add = function( name ) + { + var sName = name.match( /(gif|svg)\.latex\?(.*)/ ); + var latex= unescape(sName[2]); + latex = latex.replace(/@plus;/g,'+'); + latex = latex.replace(/+/g,'+'); + latex = latex.replace(/&space;/g,' '); + + // LAMS fix; currentEdit is probably null so try to get it from currentInstance + if (currentEdit == null) { + currentEdit = CKEDITOR.currentInstance; + } + + // if it's still null, try to get it from special field + if (currentEdit == null) { + currentEdit = CKEDITOR.equationInstance; + } + + currentEdit.insertHtml(''+latex+''); + } + +})(); + + Index: lams_central/web/ckeditor/plugins/equation_html/equation.gif =================================================================== diff -u -r71fc993bdfde6c292ef4d611da5f571092cb9bff -re215b142c7d6806421645b25dbd5a45a23c129bc Binary files differ Fisheye: Tag e215b142c7d6806421645b25dbd5a45a23c129bc refers to a dead (removed) revision in file `lams_central/web/ckeditor/plugins/equation_html/lang/en.js'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag e215b142c7d6806421645b25dbd5a45a23c129bc refers to a dead (removed) revision in file `lams_central/web/ckeditor/plugins/equation_html/plugin.js'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_central/web/includes/javascript/ckconfig_custom.js =================================================================== diff -u -r63caec7d86903e659e906042390eee95cba3a801 -re215b142c7d6806421645b25dbd5a45a23c129bc --- lams_central/web/includes/javascript/ckconfig_custom.js (.../ckconfig_custom.js) (revision 63caec7d86903e659e906042390eee95cba3a801) +++ lams_central/web/includes/javascript/ckconfig_custom.js (.../ckconfig_custom.js) (revision e215b142c7d6806421645b25dbd5a45a23c129bc) @@ -1,5 +1,5 @@ CKEDITOR.config.toolbar_Default = [ - ['Source','-','Maximize', 'Preview','PasteFromWord','Undo','Redo','Bold','Italic','Underline', '-','Subscript','Superscript','NumberedList','BulletedList','-','Outdent','Indent','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','TextColor','BGColor','Equation'], + ['Source','-','Maximize', 'Preview','PasteFromWord','Undo','Redo','Bold','Italic','Underline', '-','Subscript','Superscript','NumberedList','BulletedList','-','Outdent','Indent','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','TextColor','BGColor','equation'], ['Paint_Button','MoviePlayer','VideoRecorder','Image','Link','Table','HorizontalRule','Smiley','SpecialChar','Templates','Format','Font','FontSize','About'] ] ; @@ -9,7 +9,7 @@ ['Bold','Italic','Underline', '-','Subscript','Superscript'], ['NumberedList','BulletedList','-','Outdent','Indent'], ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'], - ['Equation','About'], + ['equation','About'], ['TextColor','BGColor'], ['Table','HorizontalRule','Smiley','SpecialChar'], ['Format','Font','FontSize'] @@ -22,14 +22,14 @@ ['NumberedList','BulletedList','-','Outdent','Indent'], ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'], ['WikiLink','Link','Image'], - ['Equation','About'], + ['equation','About'], ['TextColor','BGColor'], ['Table','HorizontalRule','Smiley','SpecialChar'], ['Format','Font','FontSize'] ] ; CKEDITOR.config.toolbar_CustomPedplanner = [ - ['Source','-','Maximize','Preview','PasteFromWord','Bold','Italic','Underline', '-','NumberedList','BulletedList','-','Outdent','Indent','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','TextColor','BGColor','Equation'], + ['Source','-','Maximize','Preview','PasteFromWord','Bold','Italic','Underline', '-','NumberedList','BulletedList','-','Outdent','Indent','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','TextColor','BGColor','equation'], ['Image','Link','Table','Smiley','Font','FontSize'] ] ; @@ -43,7 +43,7 @@ CKEDITOR.config.format_tags = 'div;h1;h2;h3;h4;h5;h6;pre;address;p' ; CKEDITOR.config.enterMode = 'div' ; CKEDITOR.plugins.addExternal('WikiLink', CKEDITOR.basePath + '../tool/lawiki10/wikilink/', 'plugin.js') ; -CKEDITOR.config.extraPlugins = 'videorecorder,WikiLink,equation_html,paint,movieplayer' ; +CKEDITOR.config.extraPlugins = 'videorecorder,WikiLink,equation,paint,movieplayer' ; // ---- Additional scripts ----- // Hides editor instaces until they are fully initialized