From: Mike G. v. a. <we...@ma...> - 2008-06-24 22:10:12
|
Log Message: ----------- updating jsMath to 3.5 again Tags: ---- rel-2-4-patches Modified Files: -------------- webwork2/htdocs/jsMath/extensions: bbox.js boldsymbol.js font.js newcommand.js webwork2/htdocs/jsMath/plugins: CHMmode.js autoload.js noImageFonts.js tex2math.js webwork2/htdocs/jsMath/test: index-images.html sample.html webwork2/htdocs/jsMath/uncompressed: jsMath-fallback-mac.js jsMath.js Added Files: ----------- webwork2/htdocs/jsMath/extensions: AMSmath.js autobold.js verb.js Revision Data ------------- --- /dev/null +++ htdocs/jsMath/extensions/autobold.js @@ -0,0 +1,51 @@ +/* + * extensions/autobold.js + * + * Part of the jsMath package for mathematics on the web. + * + * This file causes jsMath to use \boldsymbol{...} around mathematics + * that appears within <B>...</B> tags or has font-weight:bold applied + * via CSS rule. You can activate it by calling + * + * jsMath.Extension.Require('autobold'); + * + * once jsMath.js has been loaded, or by adding "extensions/autobold.js" + * to the loadFiles array in jsMath/easy/load.js. + * + * Note that you will need to install the cmmib10 and cmbsy10 fonts + * that are available from the jsMath extra font page at + * + * http://www.math.union.edu/locate/jsMath/download/extra-fonts/ + * + * to make this work in image mode. Note that there is no unicode + * fallback for these fonts at the moment. + * + * --------------------------------------------------------------------- + * + * Copyright 2008 by Davide P. Cervone + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/********************************************************************/ + +jsMath.Extension.Require("boldsymbol"); + +jsMath.Translate.OldParse = jsMath.Translate.Parse; +jsMath.Translate.Parse = function (style,text,noCache) { + if (jsMath.BBoxFor('</SPAN></SPAN>MMMMMMMMMM<SPAN><SPAN>').w > + jsMath.BBoxFor('</SPAN></SPAN><SPAN STYLE="font-weight:normal">MMMMMMMMMM</SPAN><SPAN><SPAN>').w) { + text = '\\boldsymbol{' + text + '}'; + } + return jsMath.Translate.OldParse(style,text,noCache); +} Index: boldsymbol.js =================================================================== RCS file: /webwork/cvs/system/webwork2/htdocs/jsMath/extensions/boldsymbol.js,v retrieving revision 1.1 retrieving revision 1.1.8.1 diff -Lhtdocs/jsMath/extensions/boldsymbol.js -Lhtdocs/jsMath/extensions/boldsymbol.js -u -r1.1 -r1.1.8.1 --- htdocs/jsMath/extensions/boldsymbol.js +++ htdocs/jsMath/extensions/boldsymbol.js @@ -25,7 +25,7 @@ * * --------------------------------------------------------------------- * - * Copyright 2006 by Davide P. Cervone + * Copyright 2006-2007 by Davide P. Cervone * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,12 +50,13 @@ * Implement \boldsymbol{...} */ BoldSymbol: function (name) { - var fam = jsMath.TeX.fam + var fam = jsMath.TeX.fam; var restart = 0; var oldfam = [fam[0],fam[1],fam[2]]; fam[0] = "cmbx10"; fam[1] = "cmmib10"; fam[2] = "cmbsy10"; - var box = this.ProcessArg(this.cmd+name); + try{var box = this.ProcessArg(this.cmd+name)} + catch (e) {restart = (e == "restart")} fam[0] = oldfam[0]; fam[1] = oldfam[1]; fam[2] = oldfam[2]; - if (this.error) return; + if (this.error) return; if (restart) {throw "restart"} this.mlist.Add(jsMath.mItem.Atom('ord',box)); } Index: bbox.js =================================================================== RCS file: /webwork/cvs/system/webwork2/htdocs/jsMath/extensions/bbox.js,v retrieving revision 1.2 retrieving revision 1.2.4.1 diff -Lhtdocs/jsMath/extensions/bbox.js -Lhtdocs/jsMath/extensions/bbox.js -u -r1.2 -r1.2.4.1 --- htdocs/jsMath/extensions/bbox.js +++ htdocs/jsMath/extensions/bbox.js @@ -58,16 +58,58 @@ }); +jsMath.Add(jsMath.mList.prototype.Atomize,{ + /* + * Creates the box HTML + */ + bbox: function (style,size,mitem,prev,mlist) { + var box = jsMath.Box.Set(mitem.nuc2,style,size,1).Remeasured(); + delete mitem.nuc2; + /* + * If the box has super- or subscripts, move them + * to the contained item if is in a big operator + * (does anything else need this?) + */ + if (mitem.sup || mitem.sub) { + if (mitem.nuc.type == 'mlist' && mitem.nuc.mlist.Length() == 1) { + var atom = mitem.nuc.mlist.Last(); + if (atom.atom && atom.type == 'op' && !atom.sup && !atom.sub) { + if (mitem.sup) {atom.sup = mitem.sup; delete mitem.sup} + if (mitem.sub) {atom.sub = mitem.sub; delete mitem.sub} + } + } + } + jsMath.mList.prototype.Atomize.SupSub(style,size,mitem); + var nuc = mitem.nuc; nuc.Styled(); var pad = mitem.pad; + if (pad) {box.w += 2*pad; box.h += pad; box.d += pad; nuc.w += pad} + if (jsMath.Browser.msieCenterBugFix) + {nuc.html = '<span style="position:relative">'+nuc.html+'</span>'} + nuc.html = + jsMath.HTML.BBox(box.w,box.h,box.d,mitem.color,mitem.style) + + jsMath.HTML.Spacer(pad-box.w) + + nuc.html; + if (pad && nuc.w < box.w) { + nuc.html += jsMath.HTML.Spacer(box.w-nuc.w); + nuc.w = box.w; + } + nuc.h = Math.max(nuc.h,box.h); nuc.d = Math.max(nuc.d,box.d); + nuc.bh = Math.max(nuc.bh,box.h); nuc.bd = Math.max(nuc.bd,box.d); + mitem.type = 'ord'; + } +}); + jsMath.Package(jsMath.Parser,{ macros: {bbox: 'BBox'}, - + /* * Implement \bbox[...]{...} */ BBox: function (name) { var extra = this.GetBrackets(this.cmd+name); if (this.error) return; - var arg = this.ProcessArg(this.cmd+name); if (this.error) return; + var arg = this.GetArgument(this.cmd+name); if (this.error) return; + var nuc = this.Process(arg); if (this.error) return; + var nuc2 = this.Process(arg); // need a second copy since Box.Set changes the list var color; var pad = 0; var style = ''; if (extra != '') { var parts = extra.split(/,/); @@ -78,15 +120,9 @@ else {color = parts[i]} } } - var box = jsMath.Box.Set(arg,this.mlist.data.style,this.mlist.data.size,1).Remeasured(); - var frame = jsMath.HTML.BBox(box.w+2*pad,box.h+pad,box.d+pad,color,style); - if (jsMath.Browser.msieCenterBugFix) - {box.html = '<span style="position:relative">'+box.html+'</span>'} - box.html = frame + jsMath.HTML.Spacer(-box.w-pad) + box.html; - if (pad) {box.html += jsMath.HTML.Spacer(pad)} - box.w += 2*pad; box.h += pad; box.d += pad; - box.bh = Math.max(box.bh,box.h); box.bd = Math.max(box.bd,box.d); - this.mlist.Add(jsMath.mItem.Atom('ord',box)); + this.mlist.Add(new jsMath.mItem('bbox',{ + nuc: nuc, nuc2: nuc2, atom: 1, pad: pad, color: color, style: style + })); } - + }); --- /dev/null +++ htdocs/jsMath/extensions/AMSmath.js @@ -0,0 +1,293 @@ +/* + * extensions/AMSmath.js + * + * Part of the jsMath package for mathematics on the web. + * + * This file defines most of the macros and environments from + * the amsmath LaTeX package. You can activate it by calling + * + * jsMath.Extension.Require('AMSmath'); + * + * once jsMath.js has been loaded, or by adding "extensions/AMSmath.js" + * to the loadFiles array in jsMath/easy/load.js. + * + * You may wish to load AMSsymbols.js as well, but note that it + * requires the extra msam10 and msb10 fonts that you will have + * to install on your server first. + * + * --------------------------------------------------------------------- + * + * Copyright 2007 by Davide P. Cervone + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/********************************************************************/ + +jsMath.Extension.Require("moreArrows"); + +jsMath.Package(jsMath.Parser,{ + macros: { + intI: ['Macro','\\mathchoice{\\!}{}{}{}\\!\\!\\int'], + iint: ['Macro','\\!\\!\\!\\mathop{\\,\\,\\,\\int\\intI}'], + iiint: ['Macro','\\!\\!\\!\\mathop{\\,\\,\\,\\int\\intI\\intI}'], + iiiint: ['Macro','\\!\\!\\!\\mathop{\\,\\,\\,\\int\\intI\\intI\\intI}'], + idotsint: ['Macro','\\!\\!\\mathop{\\,\\,\\int\\cdots\\int}'], + + dddot: ['Macro','\\mathop{#1}\\limits^{\\textstyle ...}',1], + ddddot: ['Macro','\\mathop{#1}\\limits^{\\textstyle ....}',1], + + sideset: ['Macro','\\mathop{\\rlap{\\phantom{#3}}}#1\\!{#3}#2',3], + stackrel: ['Macro','\\mathrel{\\mathop{#2}\\limits^{#1}}',2], + + boxed: ['Macro','\\fbox{$\\displaystyle{#1}$}',1], + + tag: 'HandleTag', + notag: ['Macro',''], + + substack: ['Macro','\\begin{subarray}{c}#1\\end{subarray}',1], + + varliminf: ['Macro','\\mathop{\\underline{\\raise1.5pt{\\rule{0pt}{.6em}{0pt}\\smash{\\lower1.5pt{\\rm lim}}}}}'], + varlimsup: ['Macro','\\mathop{\\overline{\\rule{0pt}{.6em}{0pt}\\smash{\\rm lim}}}'], + varinjlim: ['Macro','\\mathop{\\underrightarrow{\\rm lim}}'], + varprojlim: ['Macro','\\mathop{\\underleftarrow{\\rm lim}}'], + + DeclareMathOperator: 'HandleDeclareOp', + operatorname: 'HandleOperatorName', + + genfrac: 'Genfrac', + frac: ['Genfrac',"","","",""], + tfrac: ['Genfrac',"","","","1"], + dfrac: ['Genfrac',"","","","0"], + binom: ['Genfrac',"(",")","0pt",""], + tbinom: ['Genfrac',"(",")","0pt","1"], + dbinom: ['Genfrac',"(",")","0pt","0"], + + cfrac: 'CFrac', + + shoveleft: ['HandleShove','left'], + shoveright: ['HandleShove','right'] + }, + + environments: { + align: ['Array',null,null,'rlrlrlrlrlrl',[5/18,2,5/18,2,5/18,2,5/18,2,5/18,2,5/18],1,'D'], + 'align*': ['Array',null,null,'rlrlrlrlrlrl',[5/18,2,5/18,2,5/18,2,5/18,2,5/18,2,5/18],1,'D'], + aligned: ['Array',null,null,'rlrlrlrlrlrl',[5/18,2,5/18,2,5/18,2,5/18,2,5/18,2,5/18],1,'D'], + multline: 'Multline', + 'multline*': 'Multline', + split: ['Array',null,null,'rl',[5/18],1,'D'], + gather: ['Array',null,null,'c',null,1,'D'], + 'gather*': ['Array',null,null,'c',null,1,'D'], + gathered: ['Array',null,null,'c',null,1,'D'], + subarray: ['Array',null,null,null,[0,0,0,0],1,'S',0,.25], + smallmatrix: ['Array',null,null,'cccccccccc',[1/3,1/3,1/3,1/3,1/3,1/3,1/3,1/3,1/3,1/3],1,'S',0] + }, + + delimiter: { + '\\lvert': [4,2,0x6A,3,0x0C], + '\\rvert': [5,2,0x6A,3,0x0C], + '\\lVert': [4,2,0x6B,3,0x0D], + '\\rVert': [5,2,0x6B,3,0x0D] + }, + + /* + * Ignore the tag for now + */ + HandleTag: function (name) { + var arg = this.trimSpaces(this.GetArgument(this.cmd+name)); if (this.error) return; + if (arg == "*") this.GetArgument(this.cmd+name); + }, + + /* + * Handle \DeclareMathOperator + */ + HandleDeclareOp: function (name) { + var limits = ""; + var cs = this.trimSpaces(this.GetArgument(this.cmd+name)); if (this.error) return; + if (cs == "*") { + limits = "\\limits"; + cs = this.trimSpaces(this.GetArgument(this.cmd+name)); if (this.error) return; + } + if (cs.charAt(0) == "\\") {cs = cs.substr(1)} + var op = this.GetArgument(this.cmd+name); if (this.error) return; + op = op.replace(/\*/g,'\\char{cmr10}{0x2A}').replace(/-/g,'\\char{cmr10}{0x2D}'); + jsMath.Parser.prototype.macros[cs] = ['Macro','\\mathop{\\rm '+op+'}'+limits]; + }, + + HandleOperatorName: function (name) { + var limits = ""; + var op = this.trimSpaces(this.GetArgument(this.cmd+name)); if (this.error) return; + if (op == "*") { + limits = "\\limits"; + op = this.trimSpaces(this.GetArgument(this.cmd+name)); if (this.error) return; + } + op = op.replace(/\*/g,'\\char{cmr10}{0x2A}').replace(/-/g,'\\char{cmr10}{0x2D}'); + this.string = '\\mathop{\\rm '+op+'}'+limits+this.string.slice(this.i); + this.i = 0; + }, + + /* + * Record presence of \shoveleft and \shoveright + */ + HandleShove: function (name,data) { + if (this.mlist.data.entry == null) {this.mlist.data.entry = {}} + this.mlist.data.entry.shove = data[0]; + }, + + /* + * Handle \cfrac + */ + CFrac: function (name) { + var lr = this.GetBrackets(this.cmd+name); if (this.error) return; + var num = this.GetArgument(this.cmd+name); if (this.error) return; + var den = this.GetArgument(this.cmd+name); if (this.error) return; + + num = this.Process('\\strut\\textstyle{'+num+'}'); if (this.error) return; + den = this.Process('\\strut\\textstyle{'+den+'}'); if (this.error) return; + var data = this.mlist.data; + var TeX = jsMath.Typeset.TeX(data.style,data.size); + + if (lr != "") { + if (lr != 'l' && lr != 'r') {this.Error("Illegal alignment specified in "+this.cmd+name); return} + num = jsMath.Box.Set(num,data.style,data.size); + den = jsMath.Box.Set(den,data.style,data.size); + if (num.w > den.w) { + if (lr == 'l') {den.html += jsMath.HTML.Spacer(num.w-den.w)} + else {den.html = jsMath.HTML.Spacer(num.w-den.w) + den.html} + den.w = num.w; + } else if (num.w < den.w) { + if (lr == 'l') {num.html += jsMath.HTML.Spacer(den.w-num.w)} + else {num.html = jsMath.HTML.Spacer(den.w-num.w) + num.html} + num.w = den.w; + } + } + + this.mlist.Add(jsMath.mItem.Fraction(name,num,den,TeX.default_rule_thickness)); + }, + + /* + * Implement AMS generalized fraction + */ + Genfrac: function (name,data) { + var left = data[0]; var right = data[1]; + var thickness = data[2]; var style = data[3]; + + if (left != null) {left = this.delimiter[left]} else + {left = this.GetDelimiterArg(this.cmd+name); if (this.error) return} + if (right != null) {right = this.delimiter[right]} else + {right = this.GetDelimiterArg(this.cmd+name); if (this.error) return} + if (thickness == null) {thickness = this.GetArgument(this.cmd+name); if (this.error) return} + if (style == null) {style = this.GetArgument(this.cmd+name); if (this.error) return} + + var num = this.ProcessArg(this.cmd+name); if (this.error) return; + var den = this.ProcessArg(this.cmd+name); if (this.error) return; + + if (left == "") {left = null}; if (right == "") {right = null} + if (thickness == "") { + var TeX =jsMath.Typeset.TeX(this.mlist.data.style,this.mlist.data.size); + thickness = TeX.default_rule_thickness; + } else { + thickness = this.ParseDimen(thickness,this.cmd+name,0,0); + } + + var frac = jsMath.mItem.Fraction(name,num,den,thickness,left,right); + + if (style != "") { + style = (["D","T","S","SS"])[style]; + if (style == null) {this.Error("Bad math style for "+this.cmd+name); return} + var mlist = new jsMath.mList([new jsMath.mItem('style',{style:style}),frac]); + this.mlist.Add(jsMath.mItem.Atom('inner',{type:'mlist',mlist: mlist})); + } else { + this.mlist.Add(frac); + } + }, + + /* + * Implements the multline environment + */ + Multline: function (name,delim) { + var data = this.mlist.data; + var width = this.GetBrackets(this.cmd+'begin{'+name+'}'); if (this.error) return; + var arg = this.GetEnd(name); if (this.error) return; + + var parse = new jsMath.Parser(arg+this.cmd+'\\',null,data.size,'D'); + parse.matrix = name; parse.row = []; parse.table = []; parse.rspacing = []; + parse.Parse(); if (parse.error) {this.Error(parse); return} + parse.HandleRow(name,1); // be sure the last row is recorded + + // + // check rows for extra columns and maximum width + // + var i; var row; var W = 0; + for (i = 0; i < parse.table.length; i++) { + row = parse.table[i]; + if (row.length > 1) { + this.Error("Rows can contain only one equation in '"+name+"' environment"); + return; + } + if (row[0].w > W) {W = row[0].w} + } + + // + // Determine width of display + // + if (width == "") {width = W+2} else { + width = this.ParseDimen(width,name,0,0); + if (width < W) {width = W} + } + + // + // Shove the top and bottom lines + // + if (parse.table.length > 1) { + parse.table[0][0].entry.shove = 'left'; + row = parse.table[parse.table.length-1]; + if (!row[0].entry.shove) {row[0].entry.shove = 'right'} + } + // + // Adjust widths of shoved lines + // + for (i = 0; i < parse.table.length; i++) { + row = parse.table[i][0]; + if (row.entry.shove && row.w < width) { + switch (row.entry.shove) { + case 'left': + row.html += jsMath.HTML.Spacer(width-row.w); + break; + + case 'right': + row.html = jsMath.HTML.Spacer(width-row.w)+row.html; + break; + } + row.w = width; + } + } + + // + // Do the layout + // + var box = jsMath.Box.Layout(data.size,parse.table); + this.mlist.Add(jsMath.mItem.Atom('ord',box)); + }, + + /* + * Get a delimiter or empty argument + */ + GetDelimiterArg: function (name) { + var c = this.trimSpaces(this.GetArgument(name)); if (this.error) return null; + if (c == "") return null; + if (this.delimiter[c]) return this.delimiter[c]; + this.Error("Missing or unrecognized delimiter for "+name); + return null; + } +}); \ No newline at end of file Index: newcommand.js =================================================================== RCS file: /webwork/cvs/system/webwork2/htdocs/jsMath/extensions/newcommand.js,v retrieving revision 1.1.6.1 retrieving revision 1.1.6.1.2.1 diff -Lhtdocs/jsMath/extensions/newcommand.js -Lhtdocs/jsMath/extensions/newcommand.js -u -r1.1.6.1 -r1.1.6.1.2.1 --- htdocs/jsMath/extensions/newcommand.js +++ htdocs/jsMath/extensions/newcommand.js @@ -44,7 +44,7 @@ var def = this.GetArgument(this.cmd+name); if (this.error) return; if (n == '') {n = null} if (cs.charAt(0) == this.cmd) {cs = cs.substr(1)} - if (!cs.match(/^(.|[a-z]+)$/)) {this.Error("Illegal control sequence name for "+this.cmd+name); return} + if (!cs.match(/^(.|[a-z]+)$/i)) {this.Error("Illegal control sequence name for "+this.cmd+name); return} if (n != null && !n.match(/^[0-9]+$/)) {this.Error("Illegal number of parameters specified in "+this.cmd+name); return} jsMath.Parser.prototype.macros[cs] = ['Macro',def,n]; }, Index: font.js =================================================================== RCS file: /webwork/cvs/system/webwork2/htdocs/jsMath/extensions/font.js,v retrieving revision 1.1 retrieving revision 1.1.8.1 diff -Lhtdocs/jsMath/extensions/font.js -Lhtdocs/jsMath/extensions/font.js -u -r1.1 -r1.1.8.1 --- htdocs/jsMath/extensions/font.js +++ htdocs/jsMath/extensions/font.js @@ -1,6 +1,7 @@ jsMath.Package(jsMath.Parser,{ macros: {font: 'Font'}, + fontCS: {}, /* * Get a CS name or give an error @@ -23,10 +24,11 @@ var font = this.string.slice(this.i).match(/^[a-z]+[0-9]+/i); if (font) { this.i += (new String(font)).length; - if (jsMath.TeX.famName[font]) { + if (jsMath.TeX.famName[font] != null) { this.macros[cs] = ['HandleFont',jsMath.TeX.famName[font]]; } else { - this.macros[cs] = ['Extension',jsMath.Font.URL(font)]; + this.macros[cs] = ['Extension',jsMath.Font.URL(font),"fontCS"]; + this.fontCS[cs] = 1; // so Extension has something to delete } } else {this.Error("Missing font name")} } else {this.Error("Missing font definition")} --- /dev/null +++ htdocs/jsMath/extensions/verb.js @@ -0,0 +1,58 @@ +/* + * extensions/verb.js + * + * Part of the jsMath package for mathematics on the web. + * + * This file implements the \verb macro. You can activate it + * by calling + * + * jsMath.Extension.Macro('verb'); + * + * which will cause the extension to be loaded only when it is + * needed, or you can force it to be loaded via + * + * jsMath.Extension.Require('verb'); + * + * once jsMath.js has been loaded, or by adding "extensions/verb.js" + * to the loadFiles array in the easy/load.js file. + * + * --------------------------------------------------------------------- + * + * Copyright 2008 by Davide P. Cervone + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/********************************************************************/ + +jsMath.Package(jsMath.Parser,{ + + macros: {verb: 'Verb'}, + + /* + * Implement \verb|...| + */ + Verb: function (name) { + var c = this.GetNext(); var start = ++this.i; + if (c == "" ) {this.Error(this.cmd+name+" requires an argument"); return} + while (this.i < this.string.length && this.string.charAt(this.i) != c) {this.i++} + if (this.i == this.string.length) + {this.Error("Can't find closing delimiter for "+this.cmd+name); return} + var text = this.string.slice(start,this.i); this.i++; + text = text.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>'); + text = '<span style="font-family:monospace">'+text+'</span>'; + var box = jsMath.Box.Text(text,'normal','T',this.mlist.data.size).Styled(); + box.h = box.bh+box.bd -jsMath.d; box.d = jsMath.d; + this.mlist.Add(jsMath.mItem.Typeset(box)); + } +}); Index: noImageFonts.js =================================================================== RCS file: /webwork/cvs/system/webwork2/htdocs/jsMath/plugins/noImageFonts.js,v retrieving revision 1.4 retrieving revision 1.4.6.1 diff -Lhtdocs/jsMath/plugins/noImageFonts.js -Lhtdocs/jsMath/plugins/noImageFonts.js -u -r1.4 -r1.4.6.1 --- htdocs/jsMath/plugins/noImageFonts.js +++ htdocs/jsMath/plugins/noImageFonts.js @@ -24,4 +24,12 @@ */ if (!window.jsMath) {window.jsMath = {}} -window.jsMath.noImgFonts = 1; +jsMath.noImgFonts = 1; + +if (!jsMath.Font) {jsMath.Font = {}} +if (!jsMath.Font.extra_message) { + jsMath.Font.extra_message = + 'Extra TeX fonts not found: <b><span id="jsMath_ExtraFonts"></span></b><br/>' + + 'Using unicode fonts instead. This may be slow and might not print well.<br/>\n' + + 'Use the jsMath control panel to get additional information.'; +} \ No newline at end of file Index: autoload.js =================================================================== RCS file: /webwork/cvs/system/webwork2/htdocs/jsMath/plugins/autoload.js,v retrieving revision 1.7 retrieving revision 1.7.4.1 diff -Lhtdocs/jsMath/plugins/autoload.js -Lhtdocs/jsMath/plugins/autoload.js -u -r1.7 -r1.7.4.1 --- htdocs/jsMath/plugins/autoload.js +++ htdocs/jsMath/plugins/autoload.js @@ -95,12 +95,34 @@ request: null, // XMLHttpRequest object (if we can get it) iframe: null, // the hidden iframe (if not) + operaXMLHttpRequestBug: (window.opera != null), // is Opera browser /* * Get XMLHttpRequest object, if possible, and look up the URL root + * (MSIE can't use xmlReuest to load local files, so avoid that) */ Init: function () { - if (window.XMLHttpRequest) {try {this.request = new XMLHttpRequest} catch (err) {}} + this.Root(); + if (window.XMLHttpRequest) { + try {this.request = new XMLHttpRequest} catch (err) {} + // MSIE and FireFox3 can't use xmlRequest on local files, + // but we don't have jsMath.browser yet to tell, so use this check + if (this.request && window.location.protocol == "file:") { + try { + this.request.open("GET",jsMath.Autoload.root+"plugins/autoload.js",false); + this.request.send(null); + } catch (err) { + this.request = null; + // Firefox3 has window.postMessage for inter-window communication. + // It can be used to handle the new file:// security model, + // so set up the listener. + if (window.postMessage) { + this.mustPost = 1; + window.addEventListener("message",jsMath.Autoload.Post.Listener,false); + } + } + } + } if (!this.request && window.ActiveXObject) { var xml = ["MSXML2.XMLHTTP.5.0","MSXML2.XMLHTTP.4.0","MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP","Microsoft.XMLHTTP"]; @@ -108,14 +130,13 @@ try {this.request = new ActiveXObject(xml[i])} catch (err) {} } } - this.Root(); }, /* * Load an external JavaScript file */ Load: function (url) { - if (this.request) { + if (this.request && !(this.operaXMLHttpRequestBug && url == 'jsMath.js')) { setTimeout(function () {jsMath.Autoload.Script.xmlLoad(url)},1); } else { this.startLoad(url); @@ -167,12 +188,16 @@ * the issue, but that's the only time I see it). */ setURL: function () { - var url = jsMath.Autoload.root+"jsMath-autoload.html"; - var doc = this.iframe.contentDocument; - if (!doc && this.iframe.contentWindow) {doc = this.iframe.contentWindow.document} - if (navigator.vendor == "Apple Computer, Inc." && - document.location.protocol == 'file:') {doc = null} - if (doc) {doc.location.replace(url)} else {this.iframe.src = url} + if (this.mustPost) { + this.iframe.src = jsMath.Autoload.Post.startLoad(this.url,this.iframe); + } else { + var url = jsMath.Autoload.root+"jsMath-autoload.html"; + var doc = this.iframe.contentDocument; + if (!doc && this.iframe.contentWindow) {doc = this.iframe.contentWindow.document} + if (navigator.vendor == "Apple Computer, Inc." && + document.location.protocol == 'file:') {doc = null} + if (doc) {doc.location.replace(url)} else {this.iframe.src = url} + } }, /* @@ -202,7 +227,7 @@ if (script) { for (var i = 0; i < script.length; i++) { var src = script[i].src; - if (src && src.match('(^|/)plugins/autoload.js$')) { + if (src && src.match('(^|/|\\\\)plugins/autoload.js$')) { jsMath.Autoload.root = src.replace(/plugins\/autoload.js$/,''); break; } @@ -212,6 +237,44 @@ }, + /* + * Handle window.postMessage() events in Firefox3 + */ + Post: { + window: null, // iframe we are listening to + + Listener: function (event) { + if (event.source != jsMath.Autoload.Post.window) return; + var domain = event.origin; var ddomain = document.domain + if (domain == null || domain == "") {domain = "localhost"} + if (ddomain == null || ddomain == "") {ddomain = "localhost"} + if (domain != ddomain || event.data.substr(0,6) != "jsMAL:") return; + var type = event.data.substr(6,3).replace(/ /g,''); + var message = event.data.substr(10); + if (jsMath.Autoload.Post.Commands[type]) (jsMath.Autoload.Post.Commands[type])(message); + // cancel event? + }, + + /* + * Commands that can be performed by the listener + */ + Commands: { + SCR: function (message) {window.eval(message)}, + ERR: function (message) {jsMath.Autoload.Script.endLoad()}, + END: function (message) {jsMath.Autoload.Script.endLoad()} + }, + + startLoad: function (url,iframe) { + this.window = iframe.contentWindow; + return jsMath.Autoload.root+"jsMath-loader-post.html?autoload="+url; + }, + + endLoad: function () { + this.window = null; + } + }, + + /**************************************************************/ /* @@ -312,8 +375,10 @@ * and then do any pending commands. */ LoadJsMath: function () { + if (this.loading) return; if (jsMath.loaded) {this.afterLoad(); return} if (this.root) { + this.loading = 1; this.setMessage('Loading jsMath...'); this.Script.AfterLoad = this.afterLoad; this.Script.Load('jsMath.js'); @@ -322,20 +387,21 @@ } }, afterLoad: function () { - if (jsMath.tex2math.window) {jsMath.tex2math.window.jsMath = jsMath} + jsMath.Autoload.loading = 0; // // Handle MSIE bug where jsMath.window both is and is not the actual window // + if (jsMath.tex2math.window) {jsMath.tex2math.window.jsMath = jsMath} if (jsMath.browser == 'MSIE') {window.onscroll = jsMath.window.onscroll}; var fonts = jsMath.Autoload.loadFonts; if (fonts) { if (typeof(fonts) != 'object') {fonts = [fonts]} - for (var i in fonts) {jsMath.Font.Load(fonts[i])} + for (var i = 0; i < fonts.length; i++) {jsMath.Font.Load(fonts[i])} } var files = jsMath.Autoload.loadFiles; if (files) { if (typeof(files) != 'object') {files = [files]} - for (var i in files) {jsMath.Setup.Script(files[i])} + for (var i = 0; i < files.length; i++) {jsMath.Setup.Script(files[i])} } jsMath.Synchronize(function () {jsMath.Autoload.Script.RunStack()}); jsMath.Autoload.setMessage(); @@ -350,7 +416,7 @@ if (!document.body.hasChildNodes) {document.body.appendChild(this.div)} else {document.body.insertBefore(this.div,document.body.firstChild)} var style = { - position:'absolute', bottom:'1px', left:'2px', + position:'fixed', bottom:'1px', left:'2px', backgroundColor:'#E6E6E6', border:'solid 1px #959595', margin:'0px', padding:'1px 8px', zIndex:102, color:'black', fontSize:'75%', width:'auto' @@ -391,4 +457,4 @@ jsMath.Autoload.Script.Init(); jsMath.Autoload.InitStubs(); -if (document.body) {jsMath.Autoload.Check()} +if (document.body && !jsMath.Autoload.delayCheck) {jsMath.Autoload.Check()} Index: CHMmode.js =================================================================== RCS file: /webwork/cvs/system/webwork2/htdocs/jsMath/plugins/CHMmode.js,v retrieving revision 1.3 retrieving revision 1.3.4.1 diff -Lhtdocs/jsMath/plugins/CHMmode.js -Lhtdocs/jsMath/plugins/CHMmode.js -u -r1.3 -r1.3.4.1 --- htdocs/jsMath/plugins/CHMmode.js +++ htdocs/jsMath/plugins/CHMmode.js @@ -45,7 +45,7 @@ * to load the controls file, so fake it using XMLHttpRequest. * Load the data into a DIV instead of an IFRAME, and make sure * that the styles are correct for it. Change the GetPanel() - * call to get the hide the other panel and open the cirrect one. + * call to hide the other panel and open the correct one. */ jsMath.Controls.Init = function () { Index: tex2math.js =================================================================== RCS file: /webwork/cvs/system/webwork2/htdocs/jsMath/plugins/tex2math.js,v retrieving revision 1.11 retrieving revision 1.11.4.1 diff -Lhtdocs/jsMath/plugins/tex2math.js -Lhtdocs/jsMath/plugins/tex2math.js -u -r1.11 -r1.11.4.1 --- htdocs/jsMath/plugins/tex2math.js +++ htdocs/jsMath/plugins/tex2math.js @@ -10,7 +10,7 @@ * * --------------------------------------------------------------------- * - * Copyright 2004-2006 by Davide P. Cervone + * Copyright 2004-2007 by Davide P. Cervone * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,6 +44,7 @@ this.Convert(element,{ processSingleDollars: 1, processDoubleDollars: 1, processSlashParens: 1, processSlashBrackets: 1, + processLaTeXenvironments: 0, custom: 0, fixEscapedDollars: 1 }); }, @@ -52,6 +53,7 @@ this.Convert(element,{ processSingleDollars: 0, processDoubleDollars: 1, processSlashParens: 1, processSlashBrackets: 1, + processLaTeXenvironments: 0, custom: 0, fixEscapedDollars: 0 }); }, @@ -60,6 +62,7 @@ this.Convert(element,{ processSingleDollars: 0, processDoubleDollars: 0, processSlashParens: 1, processSlashBrackets: 1, + processLaTeXenvironments: 1, custom: 0, fixEscapedDollars: 0 }); }, @@ -133,7 +136,7 @@ } if (this.processDoubleDollars || this.processSingleDollars || this.processSlashParens || this.processSlashBrackets || - this.custom) this.ScanElement(element); + this.processLaTeXenvironments || this.custom) this.ScanElement(element); } }, @@ -194,8 +197,8 @@ stdProcessMatch: function (match,index,element) { if (match == this.search.end) { this.search.close = element; - this.search.clength = match.length; this.search.cpos = this.pattern.lastIndex; + this.search.clength = (match.substr(0,4) == '\\end' ? 0 : match.length); element = this.EncloseMath(element); } else { switch (match) { @@ -235,6 +238,14 @@ this.pattern.lastIndex--; } break; + + default: + if (match.substr(0,6) == '\\begin' && this.search.end == null && + this.processLaTeXenvironments) { + this.ScanMark('div',element,'\\end'+match.substr(6)); + this.search.olength = 0; + } + break; } } return element; @@ -357,9 +368,7 @@ if (this.inited || !jsMath.browser) return; /* * MSIE can't handle the DIV's properly, so we need to do it by - * hand. Look up the style for typeset math to see if the user - * has changed it, and get whether it is centered or indented - * so we can mirror that using a SPAN + * hand. Use an extra SPAN that uses CSS to act like a DIV. */ if (jsMath.browser == 'MSIE' && jsMath.platform == 'pc') {this.createMathTag = this.MSIEcreateMathTag} @@ -384,6 +393,6 @@ if (jsMath.Controls.cookie.tex2math == null) {jsMath.Controls.cookie.tex2math = 1} if (jsMath.tex2math.allowDisableTag == null) {jsMath.tex2math.allowDisableTag = 1} jsMath.tex2math.TestPatterns(); -jsMath.tex2math.createPattern('stdPattern',/(\\[\(\)\[\]$]|\$\$|\$)/g); +jsMath.tex2math.createPattern('stdPattern',/(\\[\(\)\[\]$]|\$\$|\$|\\(begin|end)\{[^}]+\})/g); } Index: index-images.html =================================================================== RCS file: /webwork/cvs/system/webwork2/htdocs/jsMath/test/index-images.html,v retrieving revision 1.1.6.1 retrieving revision 1.1.6.2 diff -Lhtdocs/jsMath/test/index-images.html -Lhtdocs/jsMath/test/index-images.html -u -r1.1.6.1 -r1.1.6.2 --- htdocs/jsMath/test/index-images.html +++ htdocs/jsMath/test/index-images.html @@ -68,7 +68,13 @@ installed the <A HREF="http://www.math.union.edu/locate/jsMath/download/jsMath.html">jsMath image fonts</A> file correctly. Follow the instructions on the linked -page. </BLOCKQUOTE> +page. +<p> + +Once you have jsMath working, go on to the <A HREF="sample.html">sample +page</A> to see if <CODE>easy/load.js</CODE> is configured properly. + +</BLOCKQUOTE> <SCRIPT> jsMath.Controls.cookie.autofont = 0; Index: sample.html =================================================================== RCS file: /webwork/cvs/system/webwork2/htdocs/jsMath/test/sample.html,v retrieving revision 1.1 retrieving revision 1.1.6.1 diff -Lhtdocs/jsMath/test/sample.html -Lhtdocs/jsMath/test/sample.html -u -r1.1 -r1.1.6.1 --- htdocs/jsMath/test/sample.html +++ htdocs/jsMath/test/sample.html @@ -5,7 +5,7 @@ <!-- | ----------------------------------------------------------- | The following line loads and initializes jsMath. - | You will need to edit the load.js file to set the + | You may need to edit the load.js file to set the | root URL for your site before this file will | display properly | ----------------------------------------------------------- @@ -36,7 +36,7 @@ This is a sample file showing you how to use jsMath to display mathematics in your web pages. Be sure you have followed the <A HREF="http://www.math.union.edu/locate/jsMath/authors/installation.html">installation -instructions</A> before loading this file. Also, you will need to edit the +instructions</A> before loading this file. Also, you may need to edit the <CODE>jsMath/easy/load.js</CODE> file to set the root URL for where jsMath can be found on your web site. The rest of this document gives examples of how to enter mathematics in your pages. Depending on the settings in @@ -93,18 +93,18 @@ paragraph is wrapped in a DIV tag with <CODE>CLASS="tex2math_ignore"</CODE>, and so no math delimiters will be processed: $f\colon X\to Y$, \(x^2 \gt 5\), $$1\over 1+x^2$$ and -\[\martrix{a& b\cr c& d}.\] +\[\matrix{a& b\cr c& d}.\] Note that this includes the processing of escaped dollars (\$) and -to custom delimiters ([math]a \mapsto a^2[/math]) as well. +custom delimiters ([math]a \mapsto a^2[/math]) as well. This makes it possible to produce examples of how to enter mathematics on your site, for instance. </DIV> <P> -Note also that jsMath will automatically ignore the text within +JsMath will automatically ignore the text within <CODE>PRE</CODE> tags, so you can easily enter examples that way as well: <PRE> $f\colon X\to Y$, \(x^2 \gt 5\), - $$1\over 1+x^2$$ and \[\martrix{a& b\cr c& d}.\] + $$1\over 1+x^2$$ and \[\matrix{a& b\cr c& d}.\] </PRE> <P> Index: jsMath.js =================================================================== RCS file: /webwork/cvs/system/webwork2/htdocs/jsMath/uncompressed/jsMath.js,v retrieving revision 1.10.2.1 retrieving revision 1.10.2.1.2.1 diff -Lhtdocs/jsMath/uncompressed/jsMath.js -Lhtdocs/jsMath/uncompressed/jsMath.js -u -r1.10.2.1 -r1.10.2.1.2.1 --- htdocs/jsMath/uncompressed/jsMath.js +++ htdocs/jsMath/uncompressed/jsMath.js @@ -67,7 +67,7 @@ window.jsMath = { - version: "3.4c", // change this if you edit the file, but don't edit this file + version: "3.5", // change this if you edit the file, but don't edit this file document: document, // the document loading jsMath window: window, // the window of the of loading document @@ -84,10 +84,10 @@ styles: { '.math': 'font-family:serif; font-style:normal; font-weight:normal', - '.typeset': 'font-family:serif; font-style:normal; font-weight:normal; line-height:normal', + '.typeset': 'font-family:serif; font-style:normal; font-weight:normal; line-height:normal;', 'div.typeset': 'text-align:center; margin:1em 0px;', 'span.typeset': 'text-align:left', - '.typeset span': 'text-align:left; border:0px; margin:0px; padding:0px', + '.typeset span': 'text-align:left; border:0px; margin:0px; padding:0px;', '.typeset .normal': 'font-family:serif; font-style:normal; font-weight:normal', @@ -213,8 +213,8 @@ if (!cache[this.em][s]) { var bbox = this.BBoxFor(s); if (s.match(/<i>|class=\"(icm|italic|igreek|iaccent)/i)) { - bbox.w = this.BBoxFor(s+jsMath.Browser.italicString).w - - jsMath.Browser.italicCorrection; + bbox.w = bbox.Mw = this.BBoxFor(s+jsMath.Browser.italicString).w + - jsMath.Browser.italicCorrection; } cache[this.em][s] = {w: bbox.w/this.em, h: bbox.h/this.em}; } @@ -236,11 +236,7 @@ jsMath.Setup.inited = 1; } } - this.em = this.BBoxFor('<span style="'+jsMath.Browser.block+';width:13em;height:1em"></span>').w/13; - if (this.em == 0) { - // handle older browsers - this.em = this.BBoxFor('<img src="'+jsMath.blank+'" style="width:13em;height:1em"/>').w/13; - } + this.em = this.CurrentEm(); var cache = jsMath.Global.cache.B; if (!cache[this.em]) { cache[this.em] = {}; @@ -253,7 +249,6 @@ var bb = cache[this.em].bb; var h = bb.h; var d = cache[this.em].d this.h = (h-d)/this.em; this.d = d/this.em; this.hd = this.h + this.d; - this.xWidth = bb.w; // used to tell if scale has changed this.Setup.TeXfonts(); @@ -274,11 +269,20 @@ }, /* - * Get the xWidth size and if it has changed, reinitialize the sizes + * Get the x size and if it has changed, reinitialize the sizes */ ReInit: function () { - var w = this.BBoxFor('x').w; - if (w != this.xWidth) {this.Init()} + if (this.em != this.CurrentEm()) {this.Init()} + }, + + /* + * Find the em size in effect at the current text location + */ + CurrentEm: function () { + var em = this.BBoxFor('<span style="'+jsMath.Browser.block+';width:13em;height:1em"></span>').w/13; + if (em > 0) {return em} + // handle older browsers + return this.BBoxFor('<img src="'+jsMath.blank+'" style="width:13em;height:1em"/>').w/13; }, /* @@ -422,7 +426,26 @@ */ Init: function () { if (!(jsMath.Controls.cookie.asynch && jsMath.Controls.cookie.progress)) { - if (window.XMLHttpRequest) {try {this.request = new XMLHttpRequest} catch (err) {}} + if (window.XMLHttpRequest) { + try {this.request = new XMLHttpRequest} catch (err) {} + // MSIE and FireFox3 can't use xmlRequest on local files, + // but we don't have jsMath.browser yet to tell, so use this check + if (this.request && jsMath.root.match(/^file:\/\//)) { + try { + this.request.open("GET",jsMath.root+"jsMath.js",false); + this.request.send(null); + } catch (err) { + this.request = null; + // Firefox3 has window.postMessage for inter-window communication. + // It can be used to handle the new file:// security model, + // so set up the listener. + if (window.postMessage) { + this.mustPost = 1; + jsMath.window.addEventListener("message",jsMath.Post.Listener,false); + } + } + } + } if (!this.request && window.ActiveXObject) { var xml = ["MSXML2.XMLHTTP.5.0","MSXML2.XMLHTTP.4.0","MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP","Microsoft.XMLHTTP"]; @@ -468,7 +491,7 @@ throw "jsMath can't load the file '"+url+"'\n" + "Message: "+err.message; } - if (this.request.status && this.request.status >= 400) { + if (this.request.status != null && (this.request.status >= 400 || this.request.status < 0)) { // Do we need to deal with redirected links? this.blocking = 0; if (jsMath.Translate.restart && jsMath.Translate.asynchronous) {return ""} @@ -495,7 +518,6 @@ cancelTimeout: 30*1000, // delay for canceling load (30 sec) - iframe: null, // the hidden iframe blocking: 0, // true when an asynchronous action is being performed cancelTimer: null, // timer to cancel load if it takes too long needsBody: 0, // true if loading files requires BODY to be present @@ -516,7 +538,7 @@ * If nothing is being loaded, do the pending commands. */ Push: function (object,method,data) { -// this.debug('Pushing: '+method+' at '+this.queue.length); +// this.debug('Pushing: '+method+' at '+this.queue.length); // debug this.queue[this.queue.length] = [object,method,data]; if (!(this.blocking || (this.needsBody && !jsMath.document.body))) this.Process(); }, @@ -526,16 +548,31 @@ */ Process: function () { while (this.queue.length && !this.blocking) { - var call = this.queue[0]; var tmpQueue = this.queue.slice(1); this.queue = []; + var call = this.queue[0]; this.queue = this.queue.slice(1); + var savedQueue = this.SaveQueue(); var object = call[0]; var method = call[1]; var data = call[2]; -// this.debug('Calling: '+method+' ['+tmpQueue.length+']'); +// this.debug('Calling: '+method+' ['+savedQueue.length+']'); // debug if (object) {object[method](data)} else if (method) {method(data)} -// this.debug('Done: '+method+' ['+this.queue.length+' + '+tmpQueue.length+']'); - this.queue = this.queue.concat(tmpQueue); +// this.debug('Done: '+method+' ['+this.queue.length+' + '+savedQueue.length+'] ('+this.blocking+')'); // debug + this.RestoreQueue(savedQueue); } }, /* + * Allows pushes to occur at the FRONT of the queue + * (so a command acts as a single unit, including anything + * that it pushes on to the command stack) + */ + SaveQueue: function () { + var queue = this.queue; + this.queue = []; + return queue; + }, + RestoreQueue: function (queue) { + this.queue = this.queue.concat(queue); + }, + + /* * Handle loading of scripts that run asynchronously */ delayedLoad: function (url) { @@ -543,26 +580,28 @@ this.Push(this,'startLoad',url); }, startLoad: function (url) { - this.iframe = jsMath.document.createElement('iframe'); - this.iframe.style.visibility = 'hidden'; - this.iframe.style.position = 'absolute'; - this.iframe.style.width = '0px'; - this.iframe.style.height = '0px'; + var iframe = jsMath.document.createElement('iframe'); + iframe.style.visibility = 'hidden'; + iframe.style.position = 'absolute'; + iframe.style.width = '0px'; + iframe.style.height = '0px'; if (jsMath.document.body.firstChild) { - jsMath.document.body.insertBefore(this.iframe,jsMath.document.body.firstChild); + jsMath.document.body.insertBefore(iframe,jsMath.document.body.firstChild); } else { - jsMath.document.body.appendChild(this.iframe); + jsMath.document.body.appendChild(iframe); } this.blocking = 1; this.url = url; - if (!url.match(/\.js$/)) {this.iframe.src = url} - else {this.iframe.src = jsMath.root+"jsMath-loader.html"} if (url.substr(0,jsMath.root.length) == jsMath.root) {url = url.substr(jsMath.root.length)} jsMath.Message.Set("Loading "+url); this.cancelTimer = setTimeout('jsMath.Script.cancelLoad()',this.cancelTimeout); + if (this.mustPost) {iframe.src = jsMath.Post.startLoad(url,iframe)} + else if (url.match(/\.js$/)) {iframe.src = jsMath.root+"jsMath-loader.html"} + else {iframe.src = this.url} }, endLoad: function (action) { - if (this.cancelTimer) {clearTimeout(this.cancelTimer); this.cancelTimer = null;} + if (this.cancelTimer) {clearTimeout(this.cancelTimer); this.cancelTimer = null} + jsMath.Post.endLoad(); jsMath.Message.Clear(); if (action != 'cancel') {this.blocking = 0; this.Process()} }, @@ -579,10 +618,12 @@ /* * If the loading takes too long, cancel it and end the load. */ - cancelLoad: function () { - this.cancelTimer = null; - jsMath.Message.Set("Can't load file"); - this.endLoad("cancel"); + cancelLoad: function (message,delay) { + if (this.cancelTimer) {clearTimeout(this.cancelTimer); this.cancelTimer = null} + if (message == null) {message = "Can't load file"} + if (delay == null) {delay = 2000} + jsMath.Message.Set(message); + setTimeout('jsMath.Script.endLoad("cancel")',delay); }, /* @@ -622,16 +663,57 @@ data[k] = d.join(''); } window.eval(data.join('')); - }//, + } /* * for debugging the event queue */ -// debug: function (message) { -// if (jsMath.document.body && jsMath.window.debug) {jsMath.window.debug(message)} -// else {alert(message)} -// } + /* + * ,debug: function (message) { + * if (jsMath.document.body && jsMath.window.debug) {jsMath.window.debug(message)} + * else {alert(message)} + * } + */ + +}; +/***************************************************************************/ + +/* + * Handle window.postMessage() events in Firefox3 + */ + +jsMath.Post = { + window: null, // iframe we are listening to + + Listener: function (event) { + if (event.source != jsMath.Post.window) return; + var domain = event.origin; var ddomain = document.domain + if (domain == null || domain == "") {domain = "localhost"} + if (ddomain == null || ddomain == "") {ddomain = "localhost"} + if (domain != ddomain || !event.data.substr(0,6).match(/jsM(CP|LD):/)) return; + var type = event.data.substr(6,3).replace(/ /g,''); + var message = event.data.substr(10); + if (jsMath.Post.Commands[type]) (jsMath.Post.Commands[type])(message); + // cancel event? + }, + + /* + * Commands that can be performed by the listener + */ + Commands: { + SCR: function (message) {jsMath.window.eval(message)}, + ERR: function (message) {jsMath.Script.cancelLoad(message,3000)}, + BGN: function (message) {jsMath.Script.Start()}, + END: function (message) {jsMath.Script.End(); jsMath.Script.endLoad()} + }, + + startLoad: function (url,iframe) { + this.window = iframe.contentWindow; + if (!url.match(/\.js$/)) {return jsMath.root+url} + return jsMath.root+"jsMath-loader-post.html?"+url; + }, + endLoad: function () {this.window = null} }; /***************************************************************************/ @@ -788,22 +870,27 @@ if (script) { for (var i = 0; i < script.length; i++) { var src = script[i].src; - if (src && src.match('(^|/)jsMath.js$')) { + if (src && src.match('(^|/|\\\\)jsMath.js$')) { jsMath.root = src.replace(/jsMath.js$/,''); - i = script.length; + break; } } } } + if (jsMath.root.charAt(0) == '\\') {jsMath.root = jsMath.root.replace(/\\/g,'/')} if (jsMath.root.charAt(0) == '/') { - jsMath.root = jsMath.document.location.protocol + '//' - + jsMath.document.location.host + jsMath.root; + if (jsMath.root.charAt(1) != '/') { + if (jsMath.document.location.port) + {jsMath.root = ':' + jsMath.document.location.port + jsMath.root} + jsMath.root = '//' + jsMath.document.location.host + jsMath.root; + } + jsMath.root = jsMath.document.location.protocol + jsMath.root; } else if (!jsMath.root.match(/^[a-z]+:/i)) { - src = new String(jsMath.document.location); + var src = new String(jsMath.document.location); + var pattern = new RegExp('/[^/]*/\\.\\./') jsMath.root = src.replace(new RegExp('[^/]*$'),'') + jsMath.root; - while (jsMath.root.match('/[^/]*/\\.\\./')) { - jsMath.root = jsMath.root.replace(new RegExp('/[^/]*/\\.\\./'),'/'); - } + while (jsMath.root.match(pattern)) + {jsMath.root = jsMath.root.replace(pattern,'/')} } jsMath.Img.root = jsMath.root + "fonts/"; jsMath.blank = jsMath.root + "blank.gif"; @@ -904,11 +991,11 @@ * Compute font parameters for various sizes */ Sizes: function () { - jsMath.TeXparams = []; - for (var j=0; j < jsMath.sizes.length; j++) {jsMath.TeXparams[j] = {}} - for (var i in jsMath.TeX) { + jsMath.TeXparams = []; var i; var j; + for (j=0; j < jsMath.sizes.length; j++) {jsMath.TeXparams[j] = {}} + for (i in jsMath.TeX) { if (typeof(jsMath.TeX[i]) != 'object') { - for (var j=0; j < jsMath.sizes.length; j++) { + for (j=0; j < jsMath.sizes.length; j++) { jsMath.TeXparams[j][i] = jsMath.sizes[j]*jsMath.TeX[i]/100; } } @@ -948,7 +1035,7 @@ */ Body: function () { if (this.inited) return; - + this.inited = -1; jsMath.Setup.Hidden(); this.inited = -2; @@ -1167,15 +1254,22 @@ if (jsMath.platform == 'pc') { this.IE7 = (window.XMLHttpRequest != null); this.quirks = (jsMath.document.compatMode == "BackCompat"); + this.msieStandard6 = !this.quirks && !this.IE7; this.allowAbsoluteDelim = 1; this.separateSkips = 1; this.buttonCheck = 1; this.msieBlankBug = 1; + this.msieAccentBug = 1; this.msieRelativeClipBug = 1; this.msieDivWidthBug = 1; this.msiePositionFixedBug = 1; this.msieIntegralBug = 1; this.waitForImages = 1; this.msieAlphaBug = !this.IE7; this.alphaPrintBug = !this.IE7; this.msieCenterBugFix = 'position:relative; '; this.msieInlineBlockFix = ' display:inline-block;'; - if (!this.IE7) {this.msieSpaceFix = '<span style="display:inline-block"></span>'} + this.msieTeXfontBaselineBug = !this.quirks; + this.msieBorderBug = this.blankWidthBug = 1; // force these, since IE7 doesn't register it + this.msieSpaceFix = '<span style="display:inline-block"></span>'; jsMath.Macro('joinrel','\\mathrel{\\kern-5mu}'), + jsMath.Parser.prototype.mathchardef.mapstocharOrig = jsMath.Parser.prototype.mathchardef.mapstochar; + delete jsMath.Parser.prototype.mathchardef.mapstochar; + jsMath.Macro('mapstochar','\\rlap{\\mapstocharOrig\\,}\\kern1mu'), jsMath.styles['.typeset .arial'] = "font-family: 'Arial unicode MS'"; if (!this.IE7 || this.quirks) { // MSIE doesn't implement fixed positioning, so use absolute @@ -1196,6 +1290,8 @@ jsMath.styles['.typeset .spacer'].replace(/display:inline-block/,''); // MSIE can't insert DIV's into text nodes, so tex2math must use SPAN's to fake DIV's jsMath.styles['.tex2math_div'] = jsMath.styles['div.typeset'] + '; width: 100%; display: inline-block'; + // Reduce occurrance of zoom bug in IE7 + jsMath.styles['.typeset'] += '; letter-spacing:0'; // MSIE will rescale images if the DPIs differ if (screen.deviceXDPI && screen.logicalXDPI && screen.deviceXDPI != screen.logicalXDPI) { @@ -1231,7 +1327,7 @@ jsMath.Macro('not','\\mathrel{\\rlap{\\kern3mu/}}'); if (navigator.vendor == 'Firefox') { this.version = navigator.vendorSub; - } else if (navigator.userAgent.match(' Firefox/([0-9.]+)( |$)')) { + } else if (navigator.userAgent.match(' Firefox/([0-9.]+)([a-z ]|$)')) { this.version = RegExp.$1; } } @@ -1378,8 +1474,11 @@ CheckTeX: function () { var wh = jsMath.BBoxFor('<span style="font-family: '+jsMath.Font.testFont+', serif">'+jsMath.TeX.cmex10[1].c+'</span>'); jsMath.nofonts = ((wh.w*3 > wh.h || wh.h == 0) && !this.Test1('cmr10',null,null,'jsMath-')); - if (jsMath.nofonts && (jsMath.platform != "mac" || - jsMath.browser != 'Mozilla' || !jsMath.Browser.VersionAtLeast(1.5))) { + if (!jsMath.nofonts) return; + if (jsMath.browser != 'Mozilla' || + (jsMath.platform == "mac" && + (!jsMath.Browser.VersionAtLeast(1.5) || jsMath.Browser.VersionAtLeast(3.0))) || + (jsMath.platform != "mac" && !jsMath.Browser.VersionAtLeast(3.0))) { wh = jsMath.BBoxFor('<span style="font-family: cmex10, serif">'+jsMath.TeX.cmex10[1].c+'</span>'); jsMath.nofonts = ((wh.w*3 > wh.h || wh.h == 0) && !this.Test1('cmr10')); if (!jsMath.nofonts) {jsMath.Setup.Script("jsMath-BaKoMa-fonts.js")} @@ -1538,7 +1637,12 @@ return; } // Image fonts - var font = {}; font[fontname] = ['all']; + var font = {}; + if (cookie.font == 'symbol' && data.symbol != null) { + font[fontname] = data.symbol(fontname,fontfam,data); + } else { + font[fontname] = ['all']; + } jsMath.Img.SetFont(font); jsMath.Img.LoadFont(fontname); if (jsMath.initialized) { @@ -2405,7 +2509,6 @@ */ UpdateFonts: function () { var change = this.update; if (!this.loaded) return; - var best = this[jsMath.Img.fonts[this.best]]; for (var font in change) { for (var i = 0; i < change[font].length; i++) { var c = change[font][i]; @@ -2525,8 +2628,12 @@ } if (w == 0) { if (jsMath.Browser.blankWidthBug) { - style += 'width:1px;'; - backspace = '<span class="spacer" style="margin-right:-1px"></span>' + if (jsMath.Browser.quirks) { + style += 'width:1px;'; + backspace = '<span class="spacer" style="margin-right:-1px"></span>' + } else if (!isRule) { + style += 'width:1px;margin-right:-1px;'; + } } } else {style += 'width:'+this.Em(w)+';'} if (d == null) {d = 0} @@ -2579,11 +2686,26 @@ * also doesn't combine vertical and horizontal spacing well. * Here the x and y positioning are done in separate <SPAN> tags */ - PlaceSeparateSkips: function (html,x,y) { + PlaceSeparateSkips: function (html,x,y,mw,Mw,w) { if (Math.abs(x) < .0001) {x = 0} if (Math.abs(y) < .0001) {y = 0} - if (y) {html = '<span style="position: relative; top:'+this.Em(-y)+';' - + '">' + html + '</span>'} + if (y) { + var lw = 0; var rw = 0; var width = ""; + if (mw != null) { + rw = Mw - w; lw = mw; + width = ' width:'+this.Em(Mw-mw)+';'; + } + html = + this.Spacer(lw-rw) + + '<span style="position: relative; ' + + 'top:'+this.Em(-y)+';' + + 'left:'+this.Em(rw)+';' + + width + '">' + + this.Spacer(-lw) + + html + + this.Spacer(rw) + + '</span>' + } if (x) {html = this.Spacer(x) + html} return html; }, @@ -2591,16 +2713,24 @@ /* * Place a SPAN with absolute coordinates */ - PlaceAbsolute: function (html,x,y) { + PlaceAbsolute: function (html,x,y,mw,Mw,w) { if (Math.abs(x) < .0001) {x = 0} if (Math.abs(y) < .0001) {y = 0} - html = '<span style="position:absolute; left:'+this.Em(x)+'; ' - + 'top:'+this.Em(y)+';">' + html + ' </span>'; - // space normalizes line height in script styles + var leftSpace = ""; var rightSpace = ""; + if (jsMath.Browser.msieRelativeClipBug && mw != null) { + leftSpace = this.Spacer(-mw); x += mw; + rightSpace = this.Spacer(Mw-w); + } + html = + '<span style="position:absolute; left:'+this.Em(x)+'; ' + + 'top:'+this.Em(y)+';">' + + leftSpace + html + rightSpace + + ' ' + // space normalizes line height in script styles + '</span>'; return html; }, - Absolute: function(html,w,h,d,y,H) { + Absolute: function(html,w,h,d,y) { if (y != "none") { if (Math.abs(y) < .0001) {y = 0} html = '<span style="position:absolute; ' @@ -2613,22 +2743,9 @@ if (jsMath.Browser.msieAbsoluteBug) { // for MSIE (Mac) html = '<span style="position:relative;">' + html + '</span>'; } - if (jsMath.Browser.spanHeightVaries) { - var style = ''; - style = jsMath.Browser.msieInlineBlockFix - + ' width:'+jsMath.HTML.Em(w)+';'; - if (jsMath.Browser.quirks) { - style += ' height:'+jsMath.HTML.Em(H)+';' - } else { - style += ' height: 0px;' - + ' vertical-align:'+jsMath.HTML.Em(H)+';' - } - html = '<span style="position:relative;' + style + '">' - + html - + '</span>'; - } else { - html = '<span style="position:relative">' + html + '</span>'; - } + html = '<span style="position:relative;' + + jsMath.Browser.msieInlineBlockFix + + '">' + html + '</span>'; return html; } @@ -2645,7 +2762,7 @@ if (d == null) {d = jsMath.d} this.type = 'typeset'; this.w = w; this.h = h; this.d = d; this.bh = h; this.bd = d; - this.... [truncated message content] |