Changeset 627


Ignore:
Timestamp:
12/30/06 17:18:02 (11 years ago)
Author:
ray
Message:

Plugin Equation (aka ASCIIMath): some updates

Location:
trunk/plugins/Equation
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/plugins/Equation/ASCIIMathML.js

    r613 r627  
    3333var checkForMathML = true;   // check if browser can display MathML 
    3434var notifyIfNoMathML = true; // put note at top of page if no MathML capability 
    35 var mathcolor = "red";       // change it to "" (to inherit) or any other color 
    36 var mathfontfamily = "serif"; // change to "" to inherit (works in IE)  
    37                               // or another family (e.g. "arial") 
     35 
     36if ( typeof mathcolor == "undefined" ) 
     37{ 
     38        var mathcolor = "red";      // change it to "" (to inherit) or any other color 
     39} 
     40if ( typeof mathfontfamily == "undefined" )  
     41{ 
     42        var mathfontfamily = "serif"; // change to "" to inherit (works in IE) or another family (e.g. "arial") 
     43} 
    3844var displaystyle = true;      // puts limits above and below large operators 
    39 var showasciiformulaonhover = true; // helps students learn ASCIIMath 
     45 
     46if ( typeof showasciiformulaonhover == "undefined" )  
     47{ 
     48        var showasciiformulaonhover = true; // helps students learn ASCIIMath 
     49} 
     50 
    4051var decimalsign = ".";        // change to "," if you like, beware of `(1,2)`! 
    4152var AMdelimiter1 = "`", AMescape1 = "\\\\`"; // can use other characters 
  • trunk/plugins/Equation/equation.js

    r613 r627  
    149149        args['editor'] = editor; 
    150150         
    151         var parent = editor._getFirstAncestor(editor._getSelection(),['span','math']); 
     151        var parent = editor._getFirstAncestor(editor._getSelection(),['span']); 
    152152        if (parent) 
    153153        { 
     
    161161Equation.prototype.insert = function (param) 
    162162{ 
    163         if (param["formula"]) 
     163        if (typeof param["formula"] != "undefined") 
    164164        { 
    165                 var formula = param["formula"].replace(/^`?(.*)`?$/m,"`$1`"); 
     165                var formula = (param["formula"] != '') ? param["formula"].replace(/^`?(.*)`?$/m,"`$1`") : ''; 
    166166 
    167                 if (param["editedNode"] && (param["editedNode"].tagName.toLowerCase() == 'math')) 
     167                if (param["editedNode"] && (param["editedNode"].tagName.toLowerCase() == 'span'))  
    168168                { 
    169                         var parent = param["editedNode"].parentNode;  
    170                         if (parent.tagName.toLowerCase() == 'span') 
     169                        var span = param["editedNode"];  
     170                        if (formula != '') 
    171171                        { 
    172                                 parent.innerHTML = formula; 
    173                                 parent.title = formula; 
    174                                  
     172                                span.innerHTML = formula; 
     173                                span.title = formula; 
    175174                        } 
    176175                        else 
    177176                        { 
    178                                 parent.removeChild(param["editedNode"]); 
    179                                 param["editedNode"] = null; 
     177                                span.parentNode.removeChild(span); 
    180178                        } 
     179                         
    181180                } 
    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"]) 
     181                else if (!param["editedNode"] && formula != '') 
    190182                { 
    191183                        if (!HTMLArea.is_ie) 
  • trunk/plugins/Equation/lang/de.js

    r613 r627  
    1717  "Input":"Eingabe", 
    1818  "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:" 
     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  "Attention: Editing the formula in the editor is not possible, please use this dialog!" : "Achtung, Àndern der Formel im Editor ist nicht möglich. Bitte benutzen Sie diesen Dialog!" 
    2122} 
  • trunk/plugins/Equation/popups/dialog.html

    r613 r627  
    7676         
    7777        var inputField = document.getElementById("inputText");  
    78         if (param["editedNode"] && param["editedNode"].tagName.toLowerCase() == 'math') 
     78         
     79        if (param["editedNode"] && param["editedNode"].tagName.toLowerCase() == 'span') 
    7980        { 
    80                 var formula = param["editedNode"].getAttribute("title"); 
    81                 inputField.value = formula;  
     81                var formula = param["editedNode"].getAttribute("title").replace(/^`*(.*?)`*$/m,"$1");; 
     82                inputField.value = formula; 
    8283                preview(); 
    83         } 
    84         else if (param["editedNode"] && param["editedNode"].tagName.toLowerCase() == 'span') 
    85         { 
    86                 var formula = param["editedNode"].innerHTML.replace(/^`?(.*?)`?$/m,"$1");; 
    87                 inputField.value = formula; 
    8884        } 
    8985        else inputField.value = ''; 
     
    292288  </tr> 
    293289  <tr><td colspan="2"> 
    294   Based on ASCIIMathML by <a href="http://www.chapman.edu/~jipsen" target="new">Peter Jipsen</a>,  
     290  <span>Based on ASCIIMathML by </span><a href="http://www.chapman.edu/~jipsen" target="new">Peter Jipsen</a>,  
    295291<a href="http://www.chapman.edu" target="new">Chapman University</a><br /> 
    296   For more information on AsciiMathML visit this page: <a href="http://www1.chapman.edu/~jipsen/mathml/asciimath.html" onclick="window.open(this.href,'_blank','');return false;">http://www1.chapman.edu/~jipsen/mathml/asciimath.html</a></td></tr> 
     292  <span>For more information on AsciiMathML visit this page: </span><a href="http://www1.chapman.edu/~jipsen/mathml/asciimath.html" onclick="window.open(this.href,'_blank','');return false;">http://www1.chapman.edu/~jipsen/mathml/asciimath.html</a></td></tr> 
    297293</table> 
    298294 
    299295<div id="buttons"> 
     296<span style="color:red">Attention: Editing the formula in the editor is not possible, please use this dialog!</span> 
    300297  <button type="submit" name="ok" onclick="return onOK();">OK</button> 
    301298  <button type="button" name="cancel" onclick="return onCancel();">Cancel</button> 
  • trunk/plugins/Equation/readme.txt

    r613 r627  
    1010 The formmulae are stored in their ASCII representation, so you have to include the  
    1111 ASCIIMathML library which can be found in the plugin folder in order render the MathML output in your pages.  
    12  Example: 
    13   <script type="text/javascript" src="/xinha/plugins/AsciiMath/ASCIIMathML.js" 
     12  
     13 Example (also see example.html): 
     14  var mathcolor = "black"; //  You may change the color of the formulae (default: red) 
     15  var mathfontfamily = "Arial"; //and the font (default: serif, which is good I think) 
     16  var showasciiformulaonhover = false; // if true helps students learn ASCIIMath (default:true) 
     17  <script type="text/javascript" src="/xinha/plugins/AsciiMath/ASCIIMathML.js"></script> 
    1418 
    15  The recommended browser for using this plugin is Mozilla/Firefox. 
     19   
     20 The recommended browser for using this plugin is Mozilla/Firefox. At the moment showing the MathML output 
     21 inside the editor is not supported in Internet Explorer. 
     22  
    1623  
    1724License information 
Note: See TracChangeset for help on using the changeset viewer.