Changeset 613
 Timestamp:
 11/29/06 10:46:16 (13 years ago)
 Location:
 trunk/plugins/Equation
 Files:

 3 added
 3 deleted
 2 edited
Legend:
 Unmodified
 Added
 Removed

trunk/plugins/Equation/equation.js
r491 r613 1 // Table Operations Plugin for HTMLArea3.0 2 // Implementation by Nazarij Dubnytskyj. Sponsored by NasCreative 3 // 4 // htmlArea v3.0  Copyright (c) 2002 interactivetools.com, inc. 5 // This notice MUST stay intact for use (see license.txt). 6 // 7 // A free WYSIWYG editor replacement for <textarea> fields. 8 // For full source code and docs, visit http://www.interactivetools.com/ 9 // 10 // Version 1.0 developed by Nazarij Dubnytskyj for NasCreative. 11 // 12 // $Id: eguationoperations.js,v 1.0 2004/09/07 20:40:00 Exp $ 13 14 // Object that will encapsulate all the equation operations 1 /**\ 2 AsciiMathML Formula Editor for Xinha 3 _______________________ 4 5 Based on AsciiMathML by Peter Jipsen http://www.chapman.edu/~jipsen 6 7 Including a table with math symbols for easy input modified from CharacterMap for ASCIIMathML by Peter Jipsen 8 HTMLSource based on HTMLArea XTD 1.5 (http://mosforge.net/projects/htmlarea3xtd/) modified by Holger Hees 9 Original Author  Bernhard Pfeifer novocaine@gmx.net 10 11 See readme.txt 12 13 This program is free software; you can redistribute it and/or modify 14 it under the terms of the GNU Lesser General Public License as published by 15 the Free Software Foundation; either version 2.1 of the License, or (at 16 your option) any later version. 17 18 This program is distributed in the hope that it will be useful, 19 but WITHOUT ANY WARRANTY; without even the implied warranty of 20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 Lesser General Public License (at http://www.gnu.org/licenses/lgpl.html) 22 for more details. 23 24 Raimund Meyer 11/23/2006 25 26 \**/ 15 27 function Equation(editor) { 16 28 this.editor = editor; … … 18 30 var cfg = editor.config; 19 31 var self = this; 32 20 33 21 34 // register the toolbar buttons provided by this plugin 22 35 cfg.registerButton({ 23 36 id : "equation", 24 tooltip : this._lc(" EquationEditor"),37 tooltip : this._lc("Formula Editor"), 25 38 image : editor.imgURL("equation.gif", "Equation"), 26 39 textMode : false, … … 29 42 } 30 43 }); 31 cfg.addToolbarElement("equation", "inserthorizontalrule", 1); 44 cfg.addToolbarElement("equation", "inserthorizontalrule", 1); 45 46 mathcolor = cfg.Equation.mathcolor; // change it to "" (to inherit) or any other color 47 mathfontfamily = cfg.Equation.mathfontfamily; 48 49 //if (HTMLArea.is_ie) return; 50 if (!HTMLArea.is_ie) 51 { 52 editor.notifyOn( 'modechange', 53 function( e, args ) 54 { 55 self.onModeChange( args ); 56 } 57 ); 58 HTMLArea.prependDom0Event (editor._textArea.form,'submit',function () {self.unParse();self.reParse = true}); 59 } 60 61 if (typeof AMprocessNode != "function") 62 { 63 HTMLArea._loadback(_editor_url + "plugins/Equation/ASCIIMathML.js", function () { translate(); }); 64 } 65 } 66 67 HTMLArea.Config.prototype.Equation = 68 { 69 "mathcolor" : "red", // change it to "" (to inherit) or any other color 70 "mathfontfamily" : "serif" // change to "" to inherit (works in IE) 71 // or another family (e.g. "arial") 32 72 } 33 73 34 74 Equation._pluginInfo = { 35 name : " Equation",36 version : " 1.0",37 developer : " Nazarij Dubnytskyj",38 developer_url : " ",75 name : "ASCIIMathML Formula Editor", 76 version : "2.0", 77 developer : "Raimund Meyer", 78 developer_url : "http://rheinaufCMS.de", 39 79 c_owner : "", 40 sponsor : "Nascreative", 41 sponsor_url : "", 42 license : "htmlArea" 43 }; 44 45 Equation.prototype._lc = function(string) { 80 sponsor : "Rheinauf", 81 sponsor_url : "http://rheinaufCMS.de", 82 license : "GNU/LGPL" 83 }; 84 85 Equation.prototype._lc = function(string) 86 { 46 87 return HTMLArea._lc(string, 'Equation'); 47 88 }; 48 49 Equation.prototype.buttonPress = function(editor, id) { 89 Equation.prototype.onGenerate = function() 90 { 91 this.parse(); 92 }; 93 Equation.prototype.onUpdateToolbar = function() 94 { 95 if (!HTMLArea.is_ie && this.reParse) AMprocessNode(this.editor._doc.body, false); 96 }; 97 98 Equation.prototype.onModeChange = function( args ) 99 { 100 var doc = this.editor._doc; 101 switch (args.mode) 102 { 103 case 'text': 104 this.unParse(); 105 break; 106 case 'wysiwyg': 107 this.parse(); 108 break; 109 } 110 }; 111 112 Equation.prototype.parse = function () 113 { 114 if (!HTMLArea.is_ie) 115 { 116 var doc = this.editor._doc; 117 var spans = doc.getElementsByTagName("span"); 118 for (var i = 0;i<spans.length;i++) 119 { 120 var node = spans[i]; 121 if (node.className != 'AM') continue; 122 node.title = node.innerHTML; 123 AMprocessNode(node, false); 124 } 125 } 126 } 127 128 Equation.prototype.unParse = function () 129 { 130 var doc = this.editor._doc; 131 var spans = doc.getElementsByTagName("span"); 132 for (var i = 0;i<spans.length;i++) 133 { 134 var node = spans[i]; 135 if (node.className.indexOf ("AM") == 1) continue; 136 var formula = node.getAttribute("title"); 137 node.innerHTML = formula; 138 node.setAttribute("title", null); 139 this.editor.setHTML(this.editor.getHTML()); 140 } 141 } 142 143 Equation.prototype.buttonPress = function() 144 { 50 145 var self = this; 51 this.editor = editor; 52 53 switch (id) { 54 case "equation": 55 editor._popupDialog("plugin://Equation/operations", function(params) { 56 self.insertOperation(editor,params); 57 }, ''); 58 break; 59 } 60 }; 61 62 Equation.prototype.insertOperation = function(editor,params) { 63 var cur_operation=params["op"]; 64 65 this.editor = editor; 66 67 switch (cur_operation) { 68 case "less_equal": 69 editor.insertHTML('<img src="' + _editor_url + '/plugins/Equation/img/dsp_less_equal.gif" style="position:relative; top:4px;">'); 70 break; 71 case "greater_egual": 72 editor.insertHTML('<img src="' + _editor_url + '/plugins/Equation/img/dsp_greater_equal.gif" style="position:relative; top:4px;">'); 73 break; 74 case "notequal": 75 editor.insertHTML('<img src="' + _editor_url + '/plugins/Equation/img/dsp_notequal.gif" style="position:relative; top:4px;">'); 76 break; 77 case "mul": 78 editor.insertHTML(' * '); 79 break; 80 case "divide": 81 editor.insertHTML(' ÷ '); 82 break; 83 case "abs_value": 84 tstr='<table taglabel="ABS" style="display: inline; verticalalign: middle;" border="0" cellpadding="0" cellspacing="0">'; 85 tstr+='<tbody>'; 86 tstr+=' <tr>'; 87 tstr+=' <td style="fontsize: 16px; fontfamily: times new roman,times,serif;" type="paren" autosize="absVal" noresize="1" nowrap="nowrap" valign="middle"><b></b></td>'; 88 tstr+=' <td nowrap="nowrap" valign="bottom"><table style="display: inline;" border="0" cellpadding="0" cellspacing="0"><tbody ><tr ><td taglabel="CONTENTS" style="verticalalign: middle; paddingtop: 0px; textalign: center;" nowrap="nowrap">x</td></tr></tbody></table></td>'; 89 tstr+=' <td style="fontsize: 16px; fontfamily: times new roman,times,serif;" type="paren" autosize="absVal" noresize="1" nowrap="nowrap" valign="middle"><b></b></td>'; 90 tstr+=' </tr>'; 91 tstr+='</tbody></table>'; 92 editor.insertHTML(tstr); 93 break; 94 case "parenthesis": 95 tstr='<table taglabel="PARENTHESIS" style="display: inline; verticalalign: middle;" border="0" cellpadding="0" cellspacing="0">'; 96 tstr+='<tbody>'; 97 tstr+=' <tr>'; 98 tstr+=' <td style="fontfamily: times new roman,times,serif; fontsize: 32px;" type="paren" autosize="paren" noresize="1" nowrap="nowrap" valign="middle">(</td>'; 99 tstr+=' <td nowrap="nowrap" valign="middle">x</td>'; 100 tstr+=' <td style="fontfamily: times new roman,times,serif; fontsize: 32px;" type="paren" autosize="paren" noresize="1" nowrap="nowrap" valign="middle">)</td>'; 101 tstr+=' </tr>'; 102 tstr+='</tbody></table>'; 103 editor.insertHTML(tstr); 104 break; 105 case "hor_fraction": 106 tstr='<table cellpadding="3" cellspacing="0" style="float:left;" taglabel="FRACTION">'; 107 tstr+='<tr><td align="center" style="borderbottom:1px solid #000;" type="numerator"> x </td></tr>'; 108 tstr+='<tr><td align="center" type="denominator"> y </td></tr>'; 109 tstr+='</table>'; 110 tstr+='<div style="margin:15px 5px 0px 5px;float:left;"> </div>'; 111 tstr+='<div style="clear:both;"></div><br /><br />'; 112 editor.insertHTML(tstr); 113 break; 114 case "diag_fraction": 115 tstr='<table taglabel="ABS" style="display: inline; verticalalign: middle;" border="0" cellpadding="0" cellspacing="0">'; 116 tstr+='<tbody>'; 117 tstr+=' <tr>'; 118 tstr+=' <td style="fontsize: 16px; fontfamily: times new roman,times,serif;" type="paren" autosize="diag_fraction" noresize="1" nowrap="nowrap" valign="middle">x</td>'; 119 tstr+=' <td nowrap="nowrap" valign="bottom"><table style="display: inline;" border="0" cellpadding="0" cellspacing="0"><tbody ><tr ><td taglabel="CONTENTS" style="verticalalign: middle; paddingtop: 0px; textalign: center; fontsize: 24px; fontweight:900;" nowrap="nowrap"> / </td></tr></tbody></table></td>'; 120 tstr+=' <td style="fontsize: 16px; fontfamily: times new roman,times,serif;" type="paren" autosize="diag_fraction" noresize="1" nowrap="nowrap" valign="middle">y</td>'; 121 tstr+=' </tr>'; 122 tstr+='</tbody></table>'; 123 editor.insertHTML(tstr); 124 break; 125 case "square_root": 126 tstr='<table style="display: inline; verticalalign: middle;" taglabel="RADICAL" border="0" cellpadding="0" cellspacing="0">'; 127 tstr+='<tbody>'; 128 tstr+=' <tr>'; 129 tstr+=' <td style="padding: 0px 0px 0px 2px; fontfamily: times new roman,times,serif; fontsize: 8pt;" align="right" nowrap="nowrap" valign="bottom"> <br><strong style="fontweight: 900; fontfamily: times new roman,times,serif;">\\</strong></td>'; 130 tstr+=' <td style="bordertop: 2px solid black; borderleft: 2px solid black; padding: 2px 3px 1px 5px;" align="center" nowrap="nowrap"> x</td>'; 131 tstr+=' </tr>'; 132 tstr+='</tbody></table>'; 133 editor.insertHTML(tstr); 134 break; 135 case "root": 136 tstr='<table style="display: inline; verticalalign: middle;" taglabel="RADICAL" border="0" cellpadding="0" cellspacing="0">'; 137 tstr+='<tbody>'; 138 tstr+=' <tr>'; 139 tstr+=' <td style="padding: 0px 0px 0px 2px; fontfamily: times new roman,times,serif; fontsize: 8pt;" align="right" nowrap="nowrap" valign="bottom">y <br><strong style="fontweight: 900; fontfamily: times new roman,times,serif;">\\</strong></td>'; 140 tstr+=' <td style="bordertop: 2px solid black; borderleft: 2px solid black; padding: 2px 3px 1px 5px;" align="center" nowrap="nowrap"> x</td>'; 141 tstr+=' </tr>'; 142 tstr+='</tbody></table>'; 143 editor.insertHTML(tstr); 144 break; 145 } 146 }; 146 var editor = this.editor; 147 var args = {}; 148 149 args['editor'] = editor; 150 151 var parent = editor._getFirstAncestor(editor._getSelection(),['span','math']); 152 if (parent) 153 { 154 args["editedNode"] = parent; 155 } 156 editor._popupDialog("plugin://Equation/dialog", function(params) { 157 self.insert(params); 158 }, args); 159 }; 160 161 Equation.prototype.insert = function (param) 162 { 163 if (param["formula"]) 164 { 165 var formula = param["formula"].replace(/^`?(.*)`?$/m,"`$1`"); 166 167 if (param["editedNode"] && (param["editedNode"].tagName.toLowerCase() == 'math')) 168 { 169 var parent = param["editedNode"].parentNode; 170 if (parent.tagName.toLowerCase() == 'span') 171 { 172 parent.innerHTML = formula; 173 parent.title = formula; 174 175 } 176 else 177 { 178 parent.removeChild(param["editedNode"]); 179 param["editedNode"] = null; 180 } 181 } 182 183 if (param["editedNode"] && (param["editedNode"].tagName.toLowerCase() == 'span')) 184 { 185 var span = param["editedNode"]; 186 span.innerHTML = formula; 187 span.title = formula; 188 } 189 else if (!param["editedNode"]) 190 { 191 if (!HTMLArea.is_ie) 192 { 193 var span = document.createElement('span'); 194 span.className = 'AM'; 195 this.editor.insertNodeAtSelection(span); 196 span.innerHTML = formula; 197 span.title = formula; 198 } 199 else 200 { 201 this.editor.insertHTML('<span class="AM" title="'+formula+'">'+formula+'</span>'); 202 } 203 } 204 if (!HTMLArea.is_ie) AMprocessNode(this.editor._doc.body, false); 205 } 206 } 
trunk/plugins/Equation/lang/de.js
r383 r613 1 // I18N for the Equation plugin 2 // LANG: "de", ENCODING: UTF8 3 // Author: Joe Hobson, jhobson@bcoe.org 1 // I18N constants 2 // 3 //LANG: "base", ENCODING: UTF8 4 //Author: TranslatorName, <email@example.com> 5 // FOR TRANSLATORS: 6 // 7 // 1. PLEASE PUT YOUR CONTACT INFO IN THE ABOVE LINE 8 // (at least a valid email address) 9 // 10 // 2. PLEASE TRY TO USE UTF8 FOR ENCODING; 11 // (if this is not possible, please include a comment 12 // that states what encoding is necessary.) 13 4 14 { 5 "Equation Editor": "GleichungsEditor", 6 "Select operation": "Auswahl", 7 "Insert": "EinfÃŒgen", 8 "Cancel": "Abbrechen" 9 }; 15 "AsciiMath Formula Input": "AsciiMath Formeleditor", 16 "Formula Editor": "Formeleditor", 17 "Input":"Eingabe", 18 "Preview":"Vorschau", 19 "Based on ASCIIMathML by": "Basiert auf ASCIIMathML von", 20 "For more information on AsciiMathML visit this page:":"FÃŒr weitere Informationen besuchen Sie bitte diese Seite:" 21 }
Note: See TracChangeset
for help on using the changeset viewer.