mathquill_swiftcalcs_rails 0.9.3.118 → 0.9.3.119
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b449944480db749154242e71a731c6e3c68f1f3c
|
4
|
+
data.tar.gz: 5593cce23aafeaa2c2171f6dad33cbd1d6482665
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e3fa3f45fce6d9f1a8886b16c40c5a20a5d5d8918de45c9fe073eb6f76f21ad959d78a3add8511ec87a36935bf6461021de641a5af0c400b359506c78e831f9
|
7
|
+
data.tar.gz: eeb37f51749cac2124dbb4461392c840165e1c3559b4f212f7d73182849856aadeeb19c20db6d91e3347cb8087a142f0dbd90e02830f1ce9a90842e325cf4561
|
@@ -1,4 +1,4 @@
|
|
1
|
-
!function(){function noop(){}function variadic(t){var e=t.length-1;return function(){var n=__slice.call(arguments,0,e),i=__slice.call(arguments,e);return t.apply(this,n.concat([i]))}}function iterator(t){return variadic(function(e,n){"function"!=typeof e&&(e=send(e));var i=function(t){return e.apply(t,[t].concat(n))};return t.call(this,i)})}function bind(t){var e=__slice.call(arguments,1);return function(){return t.apply(this,e)}}function pray(t,e){if(!e)throw new Error("prayer failed: "+t)}function prayDirection(t){pray("a direction was passed",t===L||t===R)}function prayWellFormed(t,e,n){pray("a parent is always present",t),pray("leftward is properly set up",function(){return e?e[R]===n&&e.parent===t:t.ends[L]===n}()),pray("rightward is properly set up",function(){return n?n[L]===e&&n.parent===t:t.ends[R]===e}())}function MathQuill(t){if(!t||!t.nodeType)return null;var e=$(t).children(".mq-root-block").attr(mqBlockId);return e?Node.byId[e].controller.API:null}function APIFnFor(t){function e(e,n){var i=MathQuill(e);return i instanceof t||!e||!e.nodeType?i:t($(e),n)}return e.prototype=t.prototype,e}function RootBlockMixin(t){var e,n="moveOutOf deleteOutOf selectOutOf upOutOf downOutOf reflow".split(" ");for(e=0;e<n.length;e+=1)(function(e){t[e]=function(t){this.controller.handle(e,t)}})(n[e])}function DelimsMixin(t,e){t.jQadd=function(){e.jQadd.apply(this,arguments),this.delimjQs=this.jQ.children(":first").add(this.jQ.children(":last")),this.contentjQ=this.jQ.children(":eq(1)")},t.reflow=function(){var t=this.contentjQ.outerHeight()/parseInt(this.contentjQ.css("fontSize"),10);scale(this.delimjQs,min(1+.2*(t-1),1.2),1.05*t)}}function bindCharBracketPair(t,e){var e=e||t,n=OPP_BRACKS[t],i=OPP_BRACKS[e];CharCmds[t]=bind(Bracket,L,t,n,e,i,e,i),CharCmds[n]=bind(Bracket,R,t,n,e,i,e,i)}function insLeftOfMeUnlessAtEnd(t){var e=this.parent,n=t;do{if(n[R])return t.insLeftOf(e);n=n.parent.parent}while(n!==e);t.insRightOf(e)}var undefined,origMathQuill,Options,optionProcessors,AbstractMathQuill,EditableField,Parser,saneKeyboardEvents,latexMathParser,MathElement,MathCommand,DerivedMathCommand,Symbol,VanillaSymbol,BinaryOperator,MathBlock,RootMathBlock,Bracket,OPP_BRACKS,Binomial,Currency,Fraction,LiveFraction,Choose,FunctionCommand,LatexCommandInput,Matrix,MatrixMathBlock,OperatorName,fn,SquareRoot,NthRoot,ScientificNotation,SummationNotation,SupSub,Variable,Letter,BuiltInOpNames,NonSymbolaSymbol,LatexFragment,PlusMinus,Multiplication,Inequality,less,greater,factorial,Equality,equal,scale,forceIERedraw,div,div_style,transformPropNames,transformPropName,prop,Style,TextColor,Class,Vec,InnerMathField,Unit,jQuery=window.jQuery,mqCmdId="mathquill-command-id",mqBlockId="mathquill-block-id",min=Math.min,max=Math.max,__slice=[].slice,send=variadic(function(t,e){return variadic(function(n,i){return t in n?n[t].apply(n,e.concat(i)):void 0})}),P=function(t,e,n){function i(t){return"object"==typeof t}function s(t){return"function"==typeof t}function a(){}return function r(o,l){function c(){var t=new d;return s(t.init)&&t.init.apply(t,arguments),t}function d(){}var h,u,p;return l===n&&(l=o,o=Object),c.Bare=d,h=a[t]=o[t],u=d[t]=c[t]=c.p=new a,u.constructor=c,c.mixin=function(e){return d[t]=c[t]=r(c,e)[t],c},(c.open=function(t){if(p={},s(t)?p=t.call(c,u,h,c,o):i(t)&&(p=t),i(p))for(var n in p)e.call(p,n)&&(u[n]=p[n]);return s(u.init)||(u.init=o),c})(l)}}("prototype",{}.hasOwnProperty),L=MathQuill.L=-1,R=MathQuill.R=1,$=P(jQuery,function(t){t.insDirOf=function(t,e){return t===L?this.insertBefore(e.first()):this.insertAfter(e.last())},t.insAtDirEnd=function(t,e){return t===L?this.prependTo(e):this.appendTo(e)}}),Point=P(function(t){t.parent=0,t[L]=0,t[R]=0,t.init=function(t,e,n){this.parent=t,this[L]=e,this[R]=n},this.copy=function(t){return Point(t.parent,t[L],t[R])}}),Node=P(function(t){function e(){return n+=1}t[L]=0,t[R]=0,t.parent=0;var n=0;this.byId={},t.init=function(){this.id=e(),Node.byId[this.id]=this,this.ends={},this.ends[L]=0,this.ends[R]=0},t.getController=function(){return this.controller?this.controller:(this.controller=this.parent.getController(),this.controller)},t.dispose=function(){delete Node.byId[this.id]},t.toString=function(){return"{{ MathQuill Node #"+this.id+" }}"},t.jQ=$(),t.jQadd=function(t){return this.jQ=this.jQ.add(t)},t.jQize=function(t){function e(t){var n,i;for(t.getAttribute&&(n=t.getAttribute("mathquill-command-id"),i=t.getAttribute("mathquill-block-id"),n&&Node.byId[n].jQadd(t),i&&Node.byId[i].jQadd(t)),t=t.firstChild;t;t=t.nextSibling)e(t)}var n;for(t=$(t||this.html()),n=0;n<t.length;n+=1)e(t[n]);return t},t.createDir=function(t,e){prayDirection(t);var n=this;return n.jQize(),n.jQ.insDirOf(t,e.jQ),e[t]=n.adopt(e.parent,e[L],e[R]),n},t.createLeftOf=function(t){return this.createDir(L,t)},t.selectChildren=function(t,e){return Selection(t,e)},t.bubble=iterator(function(t){var e,n;for(e=this;e&&(n=t(e),n!==!1);e=e.parent);return this}),t.postOrder=iterator(function(t){return function e(n){n.eachChild(e),t(n)}(this),this}),t.isEmpty=function(){return 0===this.ends[L]&&0===this.ends[R]},t.children=function(){return Fragment(this.ends[L],this.ends[R])},t.eachChild=function(){var t=this.children();return t.each.apply(t,arguments),this},t.foldChildren=function(t,e){return this.children().fold(t,e)},t.withDirAdopt=function(t,e,n,i){return Fragment(this,this).withDirAdopt(t,e,n,i),this},t.adopt=function(t,e,n){return Fragment(this,this).adopt(t,e,n),this},t.disown=function(){return Fragment(this,this).disown(),this},t.remove=function(){return this.jQ.remove(),this.postOrder("dispose"),this.disown()}}),Fragment=P(function(t){t.init=function(t,e,n){n===undefined&&(n=L),prayDirection(n),pray("no half-empty fragments",!t==!e),this.ends={},t&&(pray("withDir is passed to Fragment",t instanceof Node),pray("oppDir is passed to Fragment",e instanceof Node),pray("withDir and oppDir have the same parent",t.parent===e.parent),this.ends[n]=t,this.ends[-n]=e,this.jQ=this.fold(this.jQ,function(t,e){return t.add(e.jQ)}))},t.jQ=$(),t.withDirAdopt=function(t,e,n,i){return t===L?this.adopt(e,n,i):this.adopt(e,i,n)},t.adopt=function(t,e,n){var i,s,a;return prayWellFormed(t,e,n),i=this,i.disowned=!1,(s=i.ends[L])?(a=i.ends[R],e||(t.ends[L]=s),n?n[L]=a:t.ends[R]=a,i.ends[R][R]=n,i.each(function(n){n[L]=e,n.parent=t,e&&(e[R]=n),e=n}),i):this},t.disown=function(){var t,e,n=this,i=n.ends[L];return!i||n.disowned?n:(n.disowned=!0,t=n.ends[R],e=i.parent,prayWellFormed(e,i[L],i),prayWellFormed(e,t,t[R]),i[L]?i[L][R]=t[R]:e.ends[L]=t[R],t[R]?t[R][L]=i[L]:e.ends[R]=i[L],n)},t.remove=function(){return this.jQ.remove(),this.each("postOrder","dispose"),this.disown()},t.each=iterator(function(t){var e,n=this,i=n.ends[L];if(!i)return n;for(;i!==n.ends[R][R]&&(e=t(i),e!==!1);i=i[R]);return n}),t.fold=function(t,e){return this.each(function(n){t=e.call(this,t,n)}),t}}),LatexCmds={},CharCmds={},Cursor=P(Point,function(t){t.init=function(t,e,n){this.parent=t,this.options=e,this.container=n;var i=this.jQ=this._jQ=$('<span class="mq-cursor">​</span>');this.blink=function(){i.toggleClass("mq-blink")},this.upDownCache={}},t.show=function(){return this.jQ=this._jQ.removeClass("mq-blink"),"intervalId"in this?clearInterval(this.intervalId):(this[R]?this.jQ.insertBefore(this.selection&&this.selection.ends[L][L]===this[L]?this.selection.jQ:this[R].jQ.first()):this.jQ.appendTo(this.parent.jQ),this.parent.focus()),this.intervalId=setInterval(this.blink,500),this},t.hide=function(){return"intervalId"in this&&clearInterval(this.intervalId),delete this.intervalId,this.jQ.detach(),this.jQ=$(),this},t.withDirInsertAt=function(t,e,n,i){e!==this.parent&&this.parent.blur&&this.parent.blur(),e.unit&&e.unit.focus(),e.parent&&e.parent.unit&&e.parent.unit.focus(),this.parent=e,this[t]=n,this[-t]=i},t.insDirOf=function(t,e){return prayDirection(t),this.withDirInsertAt(t,e.parent,e[t],e),this.parent.jQ.addClass("mq-hasCursor"),this.jQ.insDirOf(t,e.jQ),this},t.insLeftOf=function(t){return this.insDirOf(L,t)},t.insRightOf=function(t){return this.insDirOf(R,t)},t.insAtDirEnd=function(t,e){return prayDirection(t),this.withDirInsertAt(t,e,0,e.ends[t]),this.jQ.insAtDirEnd(t,e.jQ),e.focus(),this},t.insAtLeftEnd=function(t){return this.insAtDirEnd(L,t)},t.insAtRightEnd=function(t){return this.insAtDirEnd(R,t)},t.jumpUpDown=function(t,e){var n,i,s=this;s.upDownCache[t.id]=Point.copy(s),n=s.upDownCache[e.id],n?n[R]?s.insLeftOf(n[R]):s.insAtRightEnd(n.parent):(i=s.offset().left,e.seek(i,s))},t.offset=function(){var t=this,e=t.jQ.removeClass("mq-cursor").offset();return t.jQ.addClass("mq-cursor"),e},t.unwrapGramp=function(){var t=this.parent.parent,e=t.parent,n=t[R],i=this,s=t[L];if(t.disown().eachChild(function(i){i.isEmpty()||(i.children().adopt(e,s,n).each(function(e){e.jQ.insertBefore(t.jQ.first())}),s=i.ends[R])}),!this[R])if(this[L])this[R]=this[L][R];else for(;!this[R];){if(this.parent=this.parent[R],!this.parent){this[R]=t[R],this.parent=e;break}this[R]=this.parent.ends[L]}this[R]?this.insLeftOf(this[R]):this.insAtRightEnd(e),t.jQ.remove(),t[L].siblingDeleted&&t[L].siblingDeleted(i.options,R),t[R].siblingDeleted&&t[R].siblingDeleted(i.options,L)},t.workingGroupChange=function(){var t,e=this.container,n=!1;e.find(".active_block").replaceWith(function(){return $(this).contents()}),e.find(".hasCursor_highlighting").removeClass("hasCursor_highlighting"),t=this.jQ,t.addClass("hasCursor_highlighting"),n=!1,t.prevAll().each(function(){var t=$(this);t.hasClass("mq-binary-operator")&&(n=!0),n||t.addClass("hasCursor_highlighting")}),n=!1,t.nextAll().each(function(){var t=$(this);t.hasClass("mq-binary-operator")&&(n=!0),n||t.addClass("hasCursor_highlighting")}),e.find(".mq-hasCursor").first().children(".hasCursor_highlighting").wrapAll("<span class='active_block'></span>")},t.startSelection=function(){var t,e=this.anticursor=Point.copy(this),n=e.ancestors={};for(t=e;t.parent;t=t.parent)n[t.parent.id]=t},t.endSelection=function(){delete this.anticursor},t.select=function(){var t,e,n,i,s,a,r,o=this.anticursor;if(this[L]===o[L]&&this.parent===o.parent)return!1;for(t=this;t.parent;t=t.parent)if(t.parent.id in o.ancestors){e=t.parent;break}if(pray("cursor and anticursor in the same tree",e),n=o.ancestors[e.id],a=R,t[L]!==n)for(r=t;r;r=r[R])if(r[R]===n[R]){a=L,i=t,s=n;break}return a===R&&(i=n,s=t),i instanceof Point&&(i=i[R]),s instanceof Point&&(s=s[L]),this.hide().selection=e.selectChildren(i,s),this.insDirOf(a,this.selection.ends[a]),this.selectionChanged(),!0},t.clearSelection=function(){return this.selection&&(this.selection.clear(),delete this.selection,this.selectionChanged()),this},t.deleteSelection=function(){this.selection&&(this[L]=this.selection.ends[L][L],this[R]=this.selection.ends[R][R],this.selection.remove(),this.selectionChanged(),delete this.selection)},t.replaceSelection=function(){var t=this.selection;return t&&(this[L]=t.ends[L][L],this[R]=t.ends[R][R],delete this.selection),t}}),Selection=P(Fragment,function(t,e){t.init=function(){e.init.apply(this,arguments),this.jQ=this.jQ.wrapAll('<span class="mq-selection"></span>').parent()},t.adopt=function(){return this.jQ.replaceWith(this.jQ=this.jQ.children()),e.adopt.apply(this,arguments)},t.clear=function(){return this.jQ.replaceWith(this.jQ[0].childNodes),this},t.join=function(t){return this.fold("",function(e,n){return e+n[t]()})}}),Controller=P(function(t){t.init=function(t,e,n){this.API=t,this.root=e,this.container=n,t.__controller=e.controller=this,this.cursor=e.cursor=Cursor(e,t.__options,n)},t.handle=function(t,e){var n=this.API.__options.handlers;n&&n[t]&&(e===L||e===R?n[t](e,this.API):n[t](this.API))};var e=[];this.onNotify=function(t){e.push(t)},t.notify=function(){for(var t=0;t<e.length;t+=1)e[t].apply(this.cursor,arguments);return this},t.createPopup=function(t,e,n,i){var s=this.container.children(".mq-popup").first();0==s.length&&(s=$("<div class='mq-popup mq-autocomplete'></div>"),this.container.append(s)),s.css({top:Math.ceil(e)+"px",left:Math.floor(n)+"px"}),s.html(t),s.find("li").mouseenter(function(){$(this).closest("ul").find("li").removeClass("mq-popup-selected"),$(this).addClass("mq-popup-selected")}).click(i)},t.closePopup=function(){this.container.children(".mq-popup").remove()}});MathQuill.noConflict=function(){return window.MathQuill=origMathQuill,MathQuill},origMathQuill=window.MathQuill,window.MathQuill=MathQuill,Options=P(),optionProcessors={},MathQuill.__options=Options.p,AbstractMathQuill=P(function(t){t.init=function(){throw"wtf don't call me, I'm 'abstract'"},t.initRoot=function(t,e,n){var i,s;this.__options=Options(),this.config(n),i=Controller(this,t,e),i.createTextarea(),s=e.contents().detach(),t.jQ=$('<span class="mq-root-block"/>').attr(mqBlockId,t.id).appendTo(e),this.latex(s.text()),this.revert=function(){return e.empty().unbind(".mathquill").removeClass("mq-editable-field mq-math-mode mq-text-mode").append(s)}},t.config=MathQuill.config=function(t){var e,n,i;for(e in t)t.hasOwnProperty(e)&&(n=t[e],i=optionProcessors[e],this.__options[e]=i?i(n):n);return this},t.el=function(){return this.__controller.container[0]},t.text=function(){return this.__controller.exportText(this.__options)},t.latex=function(t){return arguments.length>0?(this.__controller.renderLatexMath(t),this.__controller.blurred&&this.__controller.cursor.hide().parent.blur(),this):this.__controller.exportLatex()},t.html=function(){return this.__controller.root.jQ.html().replace(/ mathquill-(?:command|block)-id="?\d+"?/g,"").replace(/<span class="?mq-cursor( mq-blink)?"?>.?<\/span>/i,"").replace(/ mq-hasCursor|mq-hasCursor ?/,"").replace(/ class=(""|(?= |>))/g,"")},t.reflow=function(){return this.__controller.root.postOrder("reflow"),this}}),MathQuill.prototype=AbstractMathQuill.prototype,MathQuill.StaticMath=APIFnFor(P(AbstractMathQuill,function(t,e){t.init=function(t){this.initRoot(MathBlock(),t.addClass("mq-math-mode")),this.__controller.delegateMouseEvents(),this.__controller.staticMathTextareaEvents()},t.latex=function(){var t=e.latex.apply(this,arguments);return arguments.length>0&&this.__controller.root.postOrder("registerInnerField",this.innerFields=[]),t}})),EditableField=MathQuill.EditableField=P(AbstractMathQuill,function(t){t.initRootAndEvents=function(t,e,n){this.initRoot(t,e,n),this.__controller.editable=!0,this.__controller.delegateMouseEvents(),this.__controller.editablesTextareaEvents()},t.focus=function(){return this.__controller.textarea.focus(),this},t.blur=function(){return this.__controller.textarea.blur(),this},t.write=function(t){return this.__controller.writeLatex(t),this.__controller.blurred&&this.__controller.cursor.hide().parent.blur(),this},t.setAutocomplete=function(t){return this.__options.autocomplete=t.sort(function(t,e){return t.toLowerCase().localeCompare(e.toLowerCase())}),this},t.addAutocomplete=function(t){if("undefined"==typeof this.__options.autocomplete)this.__options.autocomplete=[t];else{if(this.__options.autocomplete.indexOf(t)>-1)return;this.__options.autocomplete.push(t)}return this.__options.autocomplete=this.__options.autocomplete.sort(function(t,e){return t.toLowerCase().localeCompare(e.toLowerCase())}),this},t.cmd=function(t){var e,n=this.__controller.notify(),i=n.cursor.show();return/^\\[a-z]+$/i.test(t)?(t=t.slice(1),e=LatexCmds[t],e&&(t=e(t),i.selection&&t.replaces(i.replaceSelection()),t.createLeftOf(i))):i.parent.write(i,t,i.replaceSelection()),n.blurred&&i.hide().parent.blur(),this},t.select=function(){var t=this.__controller;for(t.notify("move").cursor.insAtRightEnd(t.root);t.cursor[L];)t.selectLeft();return this},t.clearSelection=function(){return this.__controller.cursor.clearSelection(),this},t.moveToDirEnd=function(t){return this.__controller.notify("move").cursor.insAtDirEnd(t,this.__controller.root),this},t.moveToLeftEnd=function(){return this.moveToDirEnd(L)},t.moveToRightEnd=function(){return this.moveToDirEnd(R)},t.keystroke=function(t){var e;for(t=t.replace(/^\s+|\s+$/g,"").split(/\s+/),e=0;e<t.length;e+=1)this.__controller.keystroke(t[e],{preventDefault:noop});return this},t.typedText=function(t){for(var e=0;e<t.length;e+=1)this.__controller.typedText(t.charAt(e));return this}}),Parser=P(function(t,e,n){function i(t,e){throw t=t?"'"+t+"'":"EOF","Parse Error: "+e+" at "+t}var s,a,r,o,l,c,d,h,u,p,m,f,L;t.init=function(t){this._=t},t.parse=function(t){function e(t,e){return e}return this.skip(L)._(t,e,i)},t.or=function(t){pray("or is passed a parser",t instanceof n);var e=this;return n(function(n,i,s){function a(){return t._(n,i,s)}return e._(n,i,a)})},t.then=function(t){var e=this;return n(function(i,s,a){function r(e,i){var r=t instanceof n?t:t(i);return pray("a parser is returned",r instanceof n),r._(e,s,a)}return e._(i,r,a)})},t.many=function(){var t=this;return n(function(e,n){function i(t,n){return e=t,a.push(n),!0}function s(){return!1}for(var a=[];t._(e,i,s););return n(e,a)})},t.times=function(t,e){arguments.length<2&&(e=t);var i=this;return n(function(n,s,a){function r(t,e){return h.push(e),n=t,!0}function o(t,e){return c=e,n=t,!1}function l(){return!1}var c,d,h=[],u=!0;for(d=0;t>d;d+=1)if(u=i._(n,r,o),!u)return a(n,c);for(;e>d&&u;d+=1)u=i._(n,r,l);return s(n,h)})},t.result=function(t){return this.then(r(t))},t.atMost=function(t){return this.times(0,t)},t.atLeast=function(t){var e=this;return e.times(t).then(function(t){return e.many().map(function(e){return t.concat(e)})})},t.map=function(t){return this.then(function(e){return r(t(e))})},t.skip=function(t){return this.then(function(e){return t.result(e)})},s=this.string=function(t){var e=t.length,i="expected '"+t+"'";return n(function(n,s,a){var r=n.slice(0,e);return r===t?s(n.slice(e),r):a(n,i)})},a=this.regex=function(t){pray("regexp parser is anchored","^"===t.toString().charAt(1));var e="expected "+t;return n(function(n,i,s){var a,r=t.exec(n);return r?(a=r[0],i(n.slice(a.length),a)):s(n,e)})},r=n.succeed=function(t){return n(function(e,n){return n(e,t)})},o=n.fail=function(t){return n(function(e,n,i){return i(e,t)})},l=n.letter=a(/^[a-z]/i),c=n.letters=a(/^[a-z]*/i),d=n.digit=a(/^[0-9]/),h=n.digits=a(/^[0-9]*/),u=n.whitespace=a(/^\s+/),p=n.optWhitespace=a(/^\s*/),m=n.any=n(function(t,e,n){return t?e(t.slice(1),t.charAt(0)):n(t,"expected any character")}),f=n.all=n(function(t,e){return e("",t)}),L=n.eof=n(function(t,e,n){return t?n(t,"expected EOF"):e(t,t)})}),saneKeyboardEvents=function(){function t(t){var n,i=t.which||t.keyCode,s=e[i],a=[];return t.ctrlKey&&a.push("Ctrl"),t.originalEvent&&t.originalEvent.metaKey&&a.push("Meta"),t.altKey&&a.push("Alt"),t.shiftKey&&a.push("Shift"),n=s||String.fromCharCode(i),a.length||s?(a.push(n),a.join("-")):n}var e={8:"Backspace",9:"Tab",10:"Enter",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Esc",32:"Spacebar",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",45:"Insert",46:"Del",144:"NumLock"};return function(e,n){function i(t){C=t,clearTimeout(p),p=setTimeout(t)}function s(t){C(),C=noop,clearTimeout(p),b.val(t),t&&b[0].select(),m=!!t}function a(){var t=b[0];return"selectionStart"in t?t.selectionStart!==t.selectionEnd:!1}function r(){n.keystroke(t(f),f)}function o(t){f=t,L=null,r(),m&&i(function(){b[0].select(),C=noop,clearTimeout(p)})}function l(t){f&&L&&r(),L=t,i(c)}function c(){if(!a()){var t=b.val();1===t.length?(b.val(""),n.typedText(t)):t&&b[0].select()}}function d(){f=L=null}function h(){b.focus(),i(u)}function u(){var t=b.val();b.val(""),t&&n.paste(t)}var p,m,f=null,L=null,b=jQuery(e),x=jQuery(n.container||b),C=noop;return x.bind("keydown keypress input keyup focusout paste",function(){C()}),m=!1,x.bind({keydown:o,keypress:l,focusout:d,paste:h}),{select:s}}}(),Controller.open(function(t){t.exportText=function(t){return this.root.foldChildren("",function(e,n){return e+n.text(t)})}}),Controller.open(function(t){t.focusBlurEvents=function(){function t(){clearTimeout(n),a.selection&&a.selection.jQ.addClass("mq-blur"),e()}function e(){a.hide().parent.blur(),i.closePopup(),i.container.removeClass("mq-focused"),$(window).off("blur",t),i.handle("enter")}var n,i=this,s=i.root,a=i.cursor;i.textarea.focus(function(){i.blurred=!1,clearTimeout(n),i.container.addClass("mq-focused"),a.parent||a.insAtRightEnd(s),a.selection?(a.selection.jQ.removeClass("mq-blur"),i.selectionChanged()):a.show()}).blur(function(){i.blurred=!0,n=setTimeout(function(){s.postOrder("intentionalBlur"),a.clearSelection(),e()}),$(window).on("blur",t)}),i.blurred=!0,a.hide().parent.blur()}}),Controller.open(function(t){t.keystroke=function(t,e){this.cursor.parent.keystroke(t,e,this)}}),Node.open(function(t){t.keystroke=function(t,e,n){var i,s=n.cursor;switch(t){case"Ctrl-Shift-Backspace":case"Ctrl-Backspace":for(;s[L]||s.selection;)n.backspace();break;case"Shift-Backspace":case"Backspace":n.backspace();break;case"Enter":if(i=n.container.children(".mq-popup"),i.length>0){i.find("li.mq-popup-selected").click();break}return;case"Esc":case"Tab":if(i=n.container.children(".mq-popup"),i.length>0){i.find("li.mq-popup-selected").click();break}return void n.escapeDir(R,t,e);case"Shift-Tab":case"Shift-Esc":return void n.escapeDir(L,t,e);case"End":n.notify("move").cursor.insAtRightEnd(s.parent);break;case"Ctrl-End":n.notify("move").cursor.insAtRightEnd(n.root);break;case"Shift-End":for(;s[R];)n.selectRight();break;case"Ctrl-Shift-End":for(;s[R]||s.parent!==n.root;)n.selectRight();break;case"Home":n.notify("move").cursor.insAtLeftEnd(s.parent);break;case"Ctrl-Home":n.notify("move").cursor.insAtLeftEnd(n.root);break;case"Shift-Home":for(;s[L];)n.selectLeft();break;case"Ctrl-Shift-Home":for(;s[L]||s.parent!==n.root;)n.selectLeft();break;case"Left":n.moveLeft();break;case"Shift-Left":n.selectLeft();break;case"Ctrl-Left":break;case"Right":n.moveRight();break;case"Shift-Right":n.selectRight();break;case"Ctrl-Right":break;case"Up":n.moveUp();break;case"Down":n.moveDown();break;case"Shift-Up":if(s[L])for(;s[L];)n.selectLeft();else n.selectLeft();case"Shift-Down":if(s[R])for(;s[R];)n.selectRight();else n.selectRight();case"Ctrl-Up":break;case"Ctrl-Down":break;case"Ctrl-Shift-Del":case"Ctrl-Del":for(;s[R]||s.selection;)n.deleteForward();break;case"Shift-Del":case"Del":n.deleteForward();break;case"Meta-A":case"Ctrl-A":for(n.notify("move").cursor.insAtRightEnd(n.root);s[L];)n.selectLeft();break;default:return}e.preventDefault(),n.scrollHoriz()},t.moveOutOf=t.moveTowards=t.deleteOutOf=t.deleteTowards=t.unselectInto=t.selectOutOf=t.selectTowards=function(){pray("overridden or never called on this node")}}),Controller.open(function(t){function e(t,e){var n,i,s,a,r,o=t.container.children(".mq-popup");return o.length>0?(n=o.find("li.mq-popup-selected"),i="up"===e?n.prev("li"):n.next("li"),0==i.length?t:(n.removeClass("mq-popup-selected"),i.addClass("mq-popup-selected"),t)):(s=t.notify("upDown").cursor,a=e+"Into",r=e+"OutOf",s[R][a]?s.insAtLeftEnd(s[R][a]):s[L][a]?s.insAtRightEnd(s[L][a]):s.parent.bubble(function(t){var e=t[r];return e&&("function"==typeof e&&(e=t[r](s)),e instanceof Node&&s.jumpUpDown(t,e),e!==!0)?!1:void 0}),s.workingGroupChange(),t)}this.onNotify(function(t){("move"===t||"upDown"===t)&&this.show().clearSelection()}),t.escapeDir=function(t,e,n){prayDirection(t);var i=this.cursor;return i.parent!==this.root&&n.preventDefault(),i.parent!==this.root?(i.parent.moveOutOf(t,i),i.workingGroupChange(),this.notify("move")):void 0},optionProcessors.leftRightIntoCmdGoes=function(t){if(t&&"up"!==t&&"down"!==t)throw'"up" or "down" required for leftRightIntoCmdGoes option, got "'+t+'"';return t},t.moveDir=function(t){prayDirection(t);var e=this.cursor,n=e.options.leftRightIntoCmdGoes;return e.selection?e.insDirOf(t,e.selection.ends[t]):e[t]?e[t].moveTowards(t,e,n):e.parent.moveOutOf(t,e,n),this.container.children(".mq-autocomplete").length>0&&(e[L]instanceof Variable?e[L].autoComplete():e[R]instanceof Variable?e[R].autoComplete():e[L]instanceof SupSub&&"sub"==e[L].supsub&&e[L].sub.ends[R]?e[L].sub.ends[R].autoComplete():this.container.children(".mq-autocomplete").remove()),e.workingGroupChange(),this.notify("move")},t.moveLeft=function(){return this.moveDir(L)},t.moveRight=function(){return this.moveDir(R)},t.moveUp=function(){return e(this,"up")},t.moveDown=function(){return e(this,"down")},this.onNotify(function(t){"upDown"!==t&&(this.upDownCache={})}),this.onNotify(function(t){"edit"===t&&this.show().deleteSelection()}),t.deleteDir=function(t){var e,n;return prayDirection(t),e=this.cursor,n=e.selection,this.notify("edit"),n||(e[t]?e[t].deleteTowards(t,e):e.parent.deleteOutOf(t,e)),e[L].siblingDeleted&&e[L].siblingDeleted(e.options,R),e[R].siblingDeleted&&e[R].siblingDeleted(e.options,L),e.parent.bubble("reflow"),e.workingGroupChange(),this},t.backspace=function(){return this.deleteDir(L)},t.deleteForward=function(){return this.deleteDir(R)},this.onNotify(function(t){"select"!==t&&this.endSelection()}),t.selectDir=function(t){var e,n=this.notify("select").cursor,i=n.selection;prayDirection(t),n.anticursor||n.startSelection(),e=n[t],e?i&&i.ends[t]===e&&n.anticursor[-t]!==e?e.unselectInto(t,n):e.selectTowards(t,n):n.parent.selectOutOf(t,n),n.clearSelection(),n.select()||n.show()},t.selectLeft=function(){return this.selectDir(L)},t.selectRight=function(){return this.selectDir(R)}}),latexMathParser=function(){function t(t){var e,n,i=MathBlock();if(t instanceof Letter&&t.ctrlSeq.length>1)for(e=t.ctrlSeq,n=0;n<e.length;n+=1)Letter(e[n]).adopt(i,i.ends[R],0);else t.adopt(i,0,0);return i}function e(t){var e,n=t[0]||MathBlock();for(e=1;e<t.length;e+=1)t[e].children().adopt(n,n.ends[R],0);return n}var n=Parser.string,i=Parser.regex,s=(Parser.letter,Parser.any),a=Parser.optWhitespace,r=Parser.succeed,o=Parser.fail,l=i(/^[a-z]+[0-9]*/i).map(function(t){return Letter(t)}),c=i(/^[^${}\\_^]/).map(function(t){return VanillaSymbol(t)}),d=i(/^[^\\a-eg-zA-Z]/).or(n("\\").then(i(/^[a-z]+/i).or(i(/^\s+/).result(" ")).or(s))).then(function(t){var e=LatexCmds[t];return e?e(t).parser():o("unknown command: \\"+t)}),h=d.or(l).or(c),u=n("{").then(function(){return m}).skip(n("}")),p=a.then(u.or(h.map(t))),m=p.many().map(e).skip(a),f=n("[").then(p.then(function(t){return"]"!==t.join("latex")?r(t):o()}).many().map(e).skip(a)).skip(n("]")),L=m;return L.block=p,L.optBlock=f,L}(),Controller.open(function(t){t.exportLatex=function(){return this.root.latex().replace(/(\\[a-z]+) (?![a-z])/gi,"$1")},t.writeLatex=function(t){var e,n=this.notify("edit").cursor,i=Parser.all,s=Parser.eof,a=latexMathParser.skip(s).or(i.result(!1)).parse(t);return a&&!a.isEmpty()&&(a.children().adopt(n.parent,n[L],n[R]),e=a.jQize(),e.insertBefore(n.jQ),n[L]=a.ends[R],a.finalizeInsert(n.options,n),a.ends[R][R].siblingCreated&&a.ends[R][R].siblingCreated(n.options,L),a.ends[L][L].siblingCreated&&a.ends[L][L].siblingCreated(n.options,R),n.parent.bubble("reflow")),this},t.renderLatexMath=function(t){var e,n,i=this.root,s=this.cursor,a=Parser.all,r=Parser.eof,o=latexMathParser.skip(r).or(a.result(!1)).parse(t);i.eachChild("postOrder","dispose"),i.ends[L]=i.ends[R]=0,o&&o.children().adopt(i,0,0),e=i.jQ,o?(n=o.join("html"),e.html(n),i.jQize(e.children()),i.finalizeInsert(s.options)):e.empty(),delete s.selection,s.insAtRightEnd(i)}}),Controller.open(function(t){t.delegateMouseEvents=function(){var t=this.root.jQ;this.container.bind("contextmenu.mathquill",function(e){for(var n=$(e.target).closest(".mq-root-block"),i=Node.byId[n.attr(mqBlockId)||t.attr(mqBlockId)],s=i.controller,a=s.cursor,r=s.seek($(e.target),e.pageX,e.pageY).cursor.parent;!(r instanceof MathCommand);)if(r=r.parent,"undefined"==typeof r){r=i;break}return r.contextMenu(a,e),e.preventDefault(),!1}),this.container.bind("mousedown.mathquill",function(e){function n(t){a=$(t.target)}function i(t){c.anticursor||c.startSelection(),l.seek(a,t.pageX,t.pageY).cursor.select(),a=undefined}function s(t){c.blink=d,c.selection||(l.editable?(h&&h.blur(),c.show(),c.parent.focus()):u.detach()),r.unbind("mousemove",n),$(t.target.ownerDocument).unbind("mousemove",i).unbind("mouseup",s)}var a,r=$(e.target).closest(".mq-root-block"),o=Node.byId[r.attr(mqBlockId)||t.attr(mqBlockId)],l=o.controller,c=l.cursor,d=c.blink,h=c.parent,u=l.textareaSpan,p=l.textarea;l.closePopup(),l.blurred&&(l.editable||r.prepend(u),p.focus()),e.preventDefault(),e.target.unselectable=!0,c.blink=noop,l.seek($(e.target),e.pageX,e.pageY).cursor.startSelection(),r.mousemove(n),$(e.target.ownerDocument).mousemove(i).mouseup(s)})}}),Controller.open(function(t){t.seek=function(t,e){var n,i,s,a=this.notify("select").cursor;return t&&(n=t.attr(mqBlockId)||t.attr(mqCmdId),n||(i=t.parent(),n=i.attr(mqBlockId)||i.attr(mqCmdId))),s=n?Node.byId[n]:this.root,pray("nodeId is the id of some Node that exists",s),a.clearSelection().show(),s.seek(e,a),this.scrollHoriz(),a.workingGroupChange(),this}}),Controller.open(function(t){t.scrollHoriz=function(){var t,e,n,i,s,a=this.cursor,r=a.selection,o=this.root.jQ[0].getBoundingClientRect();if(r)if(n=r.jQ[0].getBoundingClientRect(),i=n.left-(o.left+20),s=n.right-(o.right-20),r.ends[L]===a[R])if(0>i)e=i;else{if(!(s>0))return;e=n.left-s<o.left+20?i:s}else if(s>0)e=s;else{if(!(0>i))return;e=n.right-i>o.right-20?s:i}else if(t=a.jQ[0].getBoundingClientRect().left,t>o.right-20)e=t-(o.right-20);else{if(!(t<o.left+20))return;e=t-(o.left+20)}this.root.jQ.stop().animate({scrollLeft:"+="+e},100)}}),Controller.open(function(t){Options.p.substituteTextarea=function(){return $("<textarea>")[0]},t.createTextarea=function(){var t,e=this.textareaSpan=$('<span class="mq-textarea"></span>'),n=this.API.__options.substituteTextarea();if(!n.nodeType)throw"substituteTextarea() must return a DOM element, got "+n;n=this.textarea=$(n).appendTo(e),t=this,t.cursor.selectionChanged=function(){t.selectionChanged()},t.container.bind("copy",function(){t.setTextareaSelection()})},t.selectionChanged=function(){var t=this;forceIERedraw(t.container[0]),t.textareaSelectionTimeout===undefined&&(t.textareaSelectionTimeout=setTimeout(function(){t.setTextareaSelection()}))},t.setTextareaSelection=function(){this.textareaSelectionTimeout=undefined;var t="";this.cursor.selection&&(t=this.cursor.selection.join("latex"),this.API.__options.statelessClipboard&&(t="$"+t+"$")),this.selectFn(t)},t.staticMathTextareaEvents=function(){function t(){s.detach(),e.blurred=!0}var e=this,n=(e.root,e.cursor),i=e.textarea,s=e.textareaSpan;this.container.prepend('<span class="mq-selectable">$'+e.exportLatex()+"$</span>"),e.blurred=!0,i.bind("cut paste",!1).focus(function(){e.blurred=!1}).blur(function(){n.selection&&n.selection.clear(),setTimeout(t)}),e.selectFn=function(t){i.val(t),t&&i.select()}},t.editablesTextareaEvents=function(){var t=this,e=(t.root,t.cursor),n=t.textarea,i=t.textareaSpan,s=saneKeyboardEvents(n,this);this.selectFn=function(t){s.select(t)},this.container.prepend(i).on("cut",function(){e.selection&&setTimeout(function(){t.notify("edit"),e.parent.bubble("reflow")})}),this.focusBlurEvents()},t.typedText=function(t){if("\n"===t)return this.API.blur();var e=this.notify().cursor;e.parent.write(e,t,e.show().replaceSelection()),this.scrollHoriz()},t.paste=function(t){this.API.__options.statelessClipboard&&(t="$"===t.slice(0,1)&&"$"===t.slice(-1)?t.slice(1,-1):"\\text{"+t+"}"),this.writeLatex(t).cursor.show()}}),MathElement=P(Node,function(t){t.finalizeInsert=function(t,e){var n=this;n.postOrder("finalizeTree",t),n.postOrder("contactWeld",e),n.postOrder("blur"),n.postOrder("reflow"),n[R].siblingCreated&&n[R].siblingCreated(t,L),n[L].siblingCreated&&n[L].siblingCreated(t,R),n.bubble("reflow")},t.contextMenu=function(){}}),MathCommand=P(MathElement,function(t,e){t.init=function(t,n,i){var s=this;e.init.call(s),s.ctrlSeq||(s.ctrlSeq=t),n&&(s.htmlTemplate=n),i&&(s.textTemplate=i)},t.replaces=function(t){t.disown(),this.replacedFragment=t},t.isEmpty=function(){return this.foldChildren(!0,function(t,e){return t&&e.isEmpty()})},t.parser=function(){var t=latexMathParser.block,e=this;return t.times(e.numBlocks()).map(function(t){e.blocks=t;for(var n=0;n<t.length;n+=1)t[n].adopt(e,e.ends[R],0);return e})},t.createLeftOf=function(t){var n,i,s,a=this;
|
2
|
-
if(this instanceof Variable||"sub"===this.supsub||t.container.children(".mq-popup").remove(),"undefined"!=typeof t.parent&&t.parent.parent instanceof Matrix){if(","==a.ctrlSeq)return t.parent.parent.moveOrInsertColumn(t);if(";"==a.ctrlSeq)return t.parent.parent.insertRow(t);if(":"==a.ctrlSeq)return t.parent.parent.deleteRow(t);if("<"==a.ctrlSeq)return t.parent.parent.deleteColumn(t);if(">"==a.ctrlSeq)return t.parent.parent.insertColumn(t)}else if("undefined"!=typeof t.parent&&t.parent.parent instanceof Bracket&&"\\left["===t.parent.parent.ctrlSeq&&(","==a.ctrlSeq||";"==a.ctrlSeq))return n=t.parent.parent,0!==n[L]?t.insRightOf(n[L]):t.insAtLeftEnd(n.parent),i=Matrix("\\bmatrix",1,1),i.createLeftOf(t),n.ends[L].children().disown().adopt(i.ends[L],0,0).jQ.appendTo(i.ends[L].jQ),n.remove(),","==a.ctrlSeq?i.insertColumn(t):i.insertRow(t);s=a.replacedFragment,a.createBlocks(),e.createLeftOf.call(a,t),s&&(s.adopt(a.ends[L],0,0),s.jQ.appendTo(a.ends[L].jQ)),a.finalizeInsert(t.options),a.placeCursor(t),(this instanceof BinaryOperator||this instanceof Fraction||this instanceof SupSub||this instanceof SquareRoot)&&t.workingGroupChange()},t.createBlocks=function(){var t,e,n=this,i=n.numBlocks(),s=n.blocks=Array(i);for(t=0;i>t;t+=1)e=s[t]=MathBlock(),e.adopt(n,n.ends[R],0)},t.placeCursor=function(t){t.insAtRightEnd(this.foldChildren(this.ends[L],function(t,e){return t.isEmpty()?t:e}))},t.moveTowards=function(t,e,n){var i=n&&this[n+"Into"];e.insAtDirEnd(-t,i||this.ends[-t])},t.deleteTowards=function(t,e){e.startSelection(),this.selectTowards(t,e),e.select()},t.selectTowards=function(t,e){e[-t]=this,e[t]=this[t]},t.selectChildren=function(){return Selection(this,this)},t.unselectInto=function(t,e){e.insAtDirEnd(-t,e.anticursor.ancestors[this.id])},t.seek=function(t,e){function n(t){var e={};return e[L]=t.jQ.offset().left,e[R]=e[L]+t.jQ.outerWidth(),e}var i,s=this,a=n(s);return t<a[L]?e.insLeftOf(s):t>a[R]?e.insRightOf(s):(i=a[L],void s.eachChild(function(r){var o=n(r);return t<o[L]?(t-i<o[L]-t?r[L]?e.insAtRightEnd(r[L]):e.insLeftOf(s):e.insAtLeftEnd(r),!1):t>o[R]?void(r[R]?i=o[R]:a[R]-t<t-o[R]?e.insRightOf(s):e.insAtRightEnd(r)):(r.seek(t,e),!1)}))},t.numBlocks=function(){var t=this.htmlTemplate.match(/&\d+/g);return t?t.length:0},t.html=function(){var t,e,n,i=this,s=i.blocks,a=" mathquill-command-id="+i.id,r=i.htmlTemplate.match(/<[^<>]+>|[^<>]+/g);for(pray("no unmatched angle brackets",r.join("")===this.htmlTemplate),t=0,e=r[0];e;t+=1,e=r[t])if("/>"===e.slice(-2))r[t]=e.slice(0,-2)+a+"/>";else if("<"===e.charAt(0)){pray("not an unmatched top-level close tag","/"!==e.charAt(1)),r[t]=e.slice(0,-1)+a+">",n=1;do t+=1,e=r[t],pray("no missing close tags",e),"</"===e.slice(0,2)?n-=1:"<"===e.charAt(0)&&"/>"!==e.slice(-2)&&(n+=1);while(n>0)}return r.join("").replace(/>&(\d+)/g,function(t,e){return" mathquill-block-id="+s[e].id+">"+s[e].join("html")})},t.latex=function(){return this.foldChildren(this.ctrlSeq,function(t,e){return t+"{"+(e.latex()||" ")+"}"})},t.textTemplate=[""],t.text=function(t){var e=this,n=0;return e.foldChildren(e.textTemplate[n],function(i,s){n+=1;var a=s.text(t);return i&&"("===e.textTemplate[n]&&"("===a[0]&&")"===a.slice(-1)?i+a.slice(1,-1)+e.textTemplate[n]:i+s.text(t)+(e.textTemplate[n]||"")})},t.setUnit=function(){this.parent.unit&&(this.unit=this.parent.unit,(this.parent instanceof SupSub||this.parent.unitsup)&&(this.unitsup=!0)),this.parent.parent&&this.parent.parent.unit&&(this.unit=this.parent.parent.unit,(this.parent.parent instanceof SupSub||this.parent.parent.unitsup)&&(this.unitsup=!0))},t.recursiveSetUnit=function(){this.setUnit(),this.eachChild(function(t){t.recursiveSetUnit&&t.recursiveSetUnit()})}}),DerivedMathCommand=P(MathCommand,function(){}),Symbol=P(MathCommand,function(t,e){t.init=function(t,n,i){i||(i=(t&&t.length>1?t.slice(1):t).trim()),e.init.call(this,t,n,[i])},t.parser=function(){return Parser.succeed(this)},t.numBlocks=function(){return 0},t.replaces=function(t){t.remove()},t.createBlocks=noop,t.moveTowards=function(t,e){e.jQ.insDirOf(t,this.jQ),e[-t]=this,e[t]=this[t]},t.deleteTowards=function(t,e){e[t]=this.remove()[t]},t.seek=function(t,e){t-this.jQ.offset().left<this.jQ.outerWidth()/2?e.insLeftOf(this):e.insRightOf(this)},t.latex=function(){return this.ctrlSeq},t.text=function(){return this.textTemplate},t.placeCursor=noop,t.isEmpty=function(){return!0}}),VanillaSymbol=P(Symbol,function(t,e){t.init=function(t,n,i){e.init.call(this,t,"<span>"+(n||t)+"</span>",i||t)},t.createLeftOf=function(t){if("."===this.ctrlSeq)if(0===t[L]||t[L]instanceof BinaryOperator)VanillaSymbol("0").createLeftOf(t);else if(0!==t[L]&&"."===t[L].ctrlSeq)return t[L].ctrlSeq="…",t[L].jQ.html('<span class="mq-nonSymbola" style="font-size:0.6em;">…</span>'),void(t[L].textTemplate="..");e.createLeftOf.call(this,t)}}),BinaryOperator=P(Symbol,function(t,e){t.init=function(t,n,i){e.init.call(this,t,'<span class="mq-binary-operator">'+n+"</span>",i)}}),MathBlock=P(MathElement,function(t,e){t.join=function(t){return this.foldChildren("",function(e,n){return e+n[t]()})},t.html=function(){return this.join("html")},t.latex=function(){return this.join("latex")},t.text=function(t){return 0===this.ends[L]&&0===this.ends[R]?"":this.ends[L]===this.ends[R]?this.ends[L].text(t):this.foldChildren("",function(e,n){return e+n.text(t)})},t.keystroke=function(t,n,i){var s,a,r;if(i.API.__options.spaceBehavesLikeTab&&("Spacebar"===t||"Shift-Spacebar"===t))return s=i.container.children(".mq-popup"),s.length>0?s.find("li.mq-popup-selected").click():(a=i.cursor,a[L]instanceof Letter&&a[L].autoOperator(a),i.escapeDir("Shift-Spacebar"===t?L:R,t,n)),void n.preventDefault();if("Tab"===t)a=i.cursor,a[L]instanceof Letter&&a[L].autoOperator(a);else if("Backspace"===t||"Del"===t)return r=e.keystroke.apply(this,arguments),a=i.cursor,a[L]&&a[L]instanceof Variable?a[L].autoComplete():0===a[L]&&a.parent&&a.parent.parent instanceof SupSub&&"sub"===a.parent.parent.supsub&&a.parent.parent[L]?a.parent.parent[L].autoComplete():i.closePopup(),r;return e.keystroke.apply(this,arguments)},t.moveOutOf=function(t,e,n){var i=n&&this.parent[n+"Into"];!i&&this[t]?e.insAtDirEnd(-t,this[t]):e.insDirOf(t,this.parent)},t.selectOutOf=function(t,e){e.insDirOf(t,this.parent)},t.deleteOutOf=function(t,e){e.unwrapGramp()},t.seek=function(t,e){var n=this.ends[R];if(!n||n.jQ.offset().left+n.jQ.outerWidth()<t)return e.insAtRightEnd(this);if(t<this.ends[L].jQ.offset().left)return e.insAtLeftEnd(this);for(;t<n.jQ.offset().left;)n=n[L];return n.seek(t,e)},t.flash=function(){var t=this.jQ.closest(".mq-root-block");t.css("background-color","#ffe0e0"),window.setTimeout(function(){t.css("background-color","#ffffff")},100)},t.write=function(t,e,n){var i;if(e.match(/^[a-eg-zA-Z]$/)?i=Letter(e):e.match(/^[0-9\+\-]$/)&&t[L]instanceof Variable&&"e"===t[L].ctrlSeq&&0!==t[L][L]&&"undefined"!=typeof t[L][L]&&t[L][L].ctrlSeq.match(/^[0-9]$/)?i=ScientificNotation(e):e.match(/^[0-9\+\-]$/)&&t[L]instanceof Variable&&"e"===t[L].ctrlSeq&&0!==t[L][L]&&t[L][L]instanceof Multiplication&&t[L][L].addedImplicitly&&0!==t[L][L][L]&&"undefined"!=typeof t[L][L][L]&&t[L][L][L].ctrlSeq.match(/^[0-9]$/)?(t[L][L].remove(),i=ScientificNotation(e)):i=!e.match(/^[0-9\.]$/)||t.parent&&t.parent.unit||t.parent&&t.parent.parent&&t.parent.parent.unit||!(t[L]instanceof Variable||t.parent&&t.parent.parent instanceof SupSub&&"sub"===t.parent.parent.supsub)?(i=CharCmds[e]||LatexCmds[e])?i(e):VanillaSymbol(e):Letter(e),t.parent&&t.parent.parent&&t.parent.parent.unitsup){if(!e.match(/^[0-9\.\+\-\*\^\/\(\)]$/))return n&&n.remove(),void this.flash()}else if(t.parent&&t.parent.parent&&t.parent.parent.unit)if(t.parent.parent instanceof SupSub){if(!e.match(/^[0-9\.\+\-\*\^\/\(\)]$/))return n&&n.remove(),void this.flash();if(!("/"!==e&&"^"!==e||t[L]instanceof VanillaSymbol||t[L]instanceof Variable))return n&&n.remove(),void this.flash()}else{if(!e.match(/^[a-z\u00b52\^\*\/\(\)]$/i))return n&&n.remove(),void this.flash();if(!("/"!==e&&"^"!==e||t[L]instanceof VanillaSymbol||t[L]instanceof Variable))return n&&n.remove(),void this.flash()}if(n&&i.replaces(n),!(!(i instanceof Variable)&&t[L]instanceof Letter&&t[L].autoOperator(t)&&i instanceof Bracket&&i.side===L)){if(t.parent&&(t.parent.parent instanceof OperatorName||t.parent.parent instanceof FunctionCommand)&&t.parent===t.parent.parent.ends[L]){if(!(i instanceof Variable||"_"===e&&0===t[R]))return this.flash();if(t[L]instanceof SupSub||"_"===e&&0===t[L])return this.flash()}!(i instanceof Variable||i instanceof Currency)||!(t[L]instanceof VanillaSymbol||t[L]instanceof DerivedMathCommand||t[L]instanceof Currency)||t[L].ctrlSeq.match(/^[\,\u2026]$/)||t.parent&&t.parent.parent instanceof SupSub?i instanceof BinaryOperator||i instanceof Fraction||i instanceof DerivedMathCommand||i instanceof SupSub||i instanceof Bracket&&i.side===R||0===t[L]||!(t[L]instanceof Fraction||t[L]instanceof Bracket||t[L]instanceof DerivedMathCommand||t[L]instanceof SupSub&&!(i instanceof Bracket))||LatexCmds.cdot().implicit().createLeftOf(t):LatexCmds.cdot().implicit().createLeftOf(t),i.createLeftOf(t)}},t.focus=function(){return this.jQ.addClass("mq-hasCursor"),this.jQ.removeClass("mq-empty"),this.unit&&this.unit.focus(),this.parent&&this.parent.unit&&this.parent.unit.focus(),this},t.blur=function(){return this.jQ.removeClass("mq-hasCursor"),this.isEmpty()&&this.jQ.addClass("mq-empty"),this.unit&&this.unit.blur(),this.parent&&this.parent.unit&&this.parent.unit.blur(),this},t.recursiveSetUnit=function(){this.eachChild(function(t){t.recursiveSetUnit&&t.recursiveSetUnit()}),this.eachChild(function(t){if(t instanceof VanillaSymbol&&("µ"==t.ctrlSeq||"2"==t.ctrlSeq)){var e=Letter(t.ctrlSeq);e.jQize(),e.jQ.insDirOf(R,t.jQ),t[R]=e.adopt(t.parent,t,t[R]),t.remove()}})}}),RootMathBlock=P(MathBlock,RootBlockMixin),MathQuill.MathField=APIFnFor(P(EditableField,function(t){t.init=function(t,e){t.addClass("mq-editable-field mq-math-mode"),this.initRootAndEvents(RootMathBlock(),t,e)}})),Bracket=P(P(MathCommand,DelimsMixin),function(t,e){t.init=function(t,n,i,s,a,r,o){e.init.call(this,"\\left"+s,undefined,[n,i]),this.side=t,this.sides={},this.sides[L]={ch:n,ctrlSeq:s,textTemplate:r},this.sides[R]={ch:i,ctrlSeq:a,textTemplate:o}},t.numBlocks=function(){return 1},t.html=function(){return this.htmlTemplate='<span class="mq-non-leaf"><span class="mq-scaled mq-paren'+(this.side===R?" mq-ghost":"")+'">'+this.sides[L].ch+'</span><span class="mq-non-leaf">&0</span><span class="mq-scaled mq-paren'+(this.side===L?" mq-ghost":"")+'">'+this.sides[R].ch+"</span></span>",e.html.call(this)},t.latex=function(){return"\\left"+this.sides[L].ctrlSeq+this.ends[L].latex()+"\\right"+this.sides[R].ctrlSeq},t.text=function(t){return"\\left["!==this.ctrlSeq||this[L]instanceof Variable?this.sides[L].textTemplate+this.ends[L].text(t)+this.sides[R].textTemplate:"("+this.ends[L].text(t)+")"},t.oppBrack=function(t,e){return t instanceof Bracket&&t.side&&t.side!==-e&&("|"===this.sides[this.side].ch||t.side===-this.side)&&t},t.closeOpposing=function(t){t.side=0,t.sides[this.side]=this.sides[this.side],t.delimjQs.eq(this.side===L?0:1).removeClass("mq-ghost").html(this.sides[this.side].ch)},t.createLeftOf=function(t){var n,i,s,a,r,o,l;if(!this.replacedFragment){for(n=this.oppBrack(t[L],L)||this.oppBrack(t[R],R),i=!1,s=t.parent;0!==s&&!n;s=s.parent)if(i&&(n=this.oppBrack(s)),i=!0,this.side===R&&"\\left("===this.ctrlSeq){if(s instanceof OperatorName||s instanceof SummationNotation)return t.insRightOf(s),t.workingGroupChange()}else if(this.side===R&&"\\left["===this.ctrlSeq&&s instanceof Matrix)return t.insRightOf(s),t.workingGroupChange();if(!n&&"\\left("===this.ctrlSeq&&t[L]instanceof Variable&&this.side===L)return t[L].autoUnItalicize(t);if(!n&&"\\left("===this.ctrlSeq&&t[L]instanceof SupSub&&this.side===L&&"sub"===t[L].supsub&&t[L].sub.ends[R]instanceof Variable)return t.insAtRightEnd(t[L].sub),t[L].autoUnItalicize(t);if(!n&&"\\left["===this.ctrlSeq&&0===t[L]&&0===t[R]&&"undefined"!=typeof t.parent.parent&&t.parent.parent.ctrlSeq===this.ctrlSeq)return a=t.parent.parent[L],r=t.parent.parent.parent,t.parent.parent.unwrap(),0!==a?t.insRightOf(a):t.insAtLeftEnd(r),o=Matrix("\\bmatrix",1,1),void o.createLeftOf(t)}n?(l=this.side=-n.side,this.closeOpposing(n),n===t.parent.parent&&t[l]&&(Fragment(t[l],t.parent.ends[l],-l).disown().withDirAdopt(-l,n.parent,n,n[l]).jQ.insDirOf(l,n.jQ),n.bubble("reflow"))):(n=this,l=n.side,n.replacedFragment?n.side=0:t[-l]&&(n.replaces(Fragment(t[-l],t.parent.ends[-l],l)),t[-l]=0),e.createLeftOf.call(n,t)),l===L?t.insAtLeftEnd(n.ends[L]):t.insRightOf(n),t.workingGroupChange()},t.placeCursor=noop,t.unwrap=function(){this.ends[L].children().disown().adopt(this.parent,this,this[R]).jQ.insertAfter(this.jQ),this.remove()},t.deleteSide=function(t,e,n){var i,s=this.parent,a=this[t],r=s.ends[t];return t===this.side?(this.unwrap(),void(a?n.insDirOf(-t,a):n.insAtDirEnd(t,s))):(this.side=-t,void(this.oppBrack(this.ends[L].ends[this.side],t)?(this.closeOpposing(this.ends[L].ends[this.side]),i=this.ends[L].ends[t],this.unwrap(),i.siblingCreated&&i.siblingCreated(n.options,t),a?n.insDirOf(-t,a):n.insAtDirEnd(t,s)):(this.oppBrack(this.parent.parent,t)?(this.parent.parent.closeOpposing(this),this.parent.parent.unwrap()):(this.sides[t]={ch:OPP_BRACKS[this.sides[this.side].ch],ctrlSeq:OPP_BRACKS[this.sides[this.side].ctrlSeq]},this.delimjQs.removeClass("mq-ghost").eq(t===L?0:1).addClass("mq-ghost").html(this.sides[t].ch)),a?(i=this.ends[L].ends[t],Fragment(a,r,-t).disown().withDirAdopt(-t,this.ends[L],i,0).jQ.insAtDirEnd(t,this.ends[L].jQ.removeClass("mq-empty")),i.siblingCreated&&i.siblingCreated(n.options,t),n.insDirOf(-t,a)):e?n.insDirOf(t,this):n.insAtDirEnd(t,this.ends[L]))))},t.deleteTowards=function(t,e){this.deleteSide(-t,!1,e)},t.finalizeTree=function(){this.setUnit(),this.ends[L].deleteOutOf=function(t,e){this.parent.deleteSide(t,!0,e)},this.finalizeTree=this.intentionalBlur=function(){this.delimjQs.eq(this.side===L?1:0).removeClass("mq-ghost"),this.side=0}},t.siblingCreated=function(t,e){e===-this.side&&this.finalizeTree()}}),OPP_BRACKS={"(":")",")":"(","[":"]","]":"[","{":"}","}":"{","\\{":"\\}","\\}":"\\{","⟨":"⟩","⟩":"⟨","\\langle ":"\\rangle ","\\rangle ":"\\langle ","|":"|"},bindCharBracketPair("("),bindCharBracketPair("["),LatexCmds.langle=bind(Bracket,L,"⟨","⟩","\\langle ","\\rangle ","(",")"),LatexCmds.rangle=bind(Bracket,R,"⟨","⟩","\\langle ","\\rangle ","(",")"),CharCmds["|"]=LatexCmds.abs=bind(Bracket,L,"|","|","|","|","abs(",")"),CharCmds["{"]=bind(Bracket,L,"{","}","\\{","\\}","(",")"),CharCmds["}"]=bind(Bracket,R,"{","}","\\{","\\}","(",")"),LatexCmds.left=P(MathCommand,function(t){t.parser=function(){var t=Parser.regex,e=Parser.string,n=(Parser.succeed,Parser.optWhitespace);return n.then(t(/^(?:[([|]|\\\{)/)).then(function(i){var s="\\"===i.charAt(0)?i.slice(1):i;return latexMathParser.then(function(a){return e("\\right").skip(n).then(t(/^(?:[\])|]|\\\})/)).map(function(t){var e="\\"===t.charAt(0)?t.slice(1):t,n="["===s?"[":"|"===s?"abs(":"(",r="["===s?"]":")",o=Bracket(0,s,e,i,t,n,r);return o.blocks=[a],a.adopt(o,0,0),o})})})}}),LatexCmds.right=P(MathCommand,function(t){t.parser=function(){return Parser.fail("unmatched \\right")}}),Binomial=LatexCmds.binom=LatexCmds.binomial=P(P(MathCommand,DelimsMixin),function(t){t.ctrlSeq="\\binom",t.htmlTemplate='<span class="mq-non-leaf"><span class="mq-paren mq-scaled">(</span><span class="mq-non-leaf"><span class="mq-array mq-non-leaf"><span>&0</span><span>&1</span></span></span><span class="mq-paren mq-scaled">)</span></span>',t.textTemplate=["choose(",",",")"]}),Currency=P(MathCommand,function(t,e){t.init=function(t,n){this.htmlTemplate="<span><span>"+n+"</span><span>&0</span></span>",this.textTemplate=[" "+n," "],e.init.call(this,t)},t.finalizeTree=function(){this.ends[L].write=function(t,e){RegExp(/[0-9\.]/).test(e)?MathBlock.p.write.apply(this,arguments):(t.insRightOf(this.parent),t.parent.write(t,e))}}}),LatexCmds.$=bind(Currency,"\\$","$"),Fraction=LatexCmds.frac=LatexCmds.dfrac=LatexCmds.cfrac=LatexCmds.fraction=P(MathCommand,function(t){t.ctrlSeq="\\frac",t.htmlTemplate='<span class="mq-fraction mq-non-leaf"><span class="mq-numerator">&0</span><span class="mq-denominator">&1</span><span style="display:inline-block;width:0"> </span></span>',t.textTemplate=["((",")/(","))"],t.finalizeTree=function(){this.setUnit(),this.jQ.closest(".mq-editable-field").children(".mq-popup").remove(),this.upInto=this.ends[R].upOutOf=this.ends[L],this.downInto=this.ends[L].downOutOf=this.ends[R],this.blocks[1].ends[L]&&"."===this.blocks[1].ends[L].ctrlSeq&&(this.blocks[1].ends[L].remove(),this.elementWise=!0),this.elementWise&&(this.jQ.wrap("<span class='mq-fraction-elementwise'></span>"),this.jQ=this.jQ.parent())},t.text=function(t){return"(("+this.blocks[0].text(t)+")"+(this.elementWise?".":"")+"/("+this.blocks[1].text(t)+"))"},t.latex=function(){return this.ctrlSeq+"{"+this.blocks[0].latex()+"}{"+(this.elementWise?".":"")+this.blocks[1].latex()+"}"}}),LiveFraction=LatexCmds.over=CharCmds["/"]=P(Fraction,function(t,e){t.createLeftOf=function(t){var n,i,s,a;if(!this.replacedFragment){if(t[L]&&"."===t[L].ctrlSeq&&t[L][L]){for(n=[t[L]],t[L][L]&&t[L][L][L]&&t[L][L][L][L]&&"0"===t[L][L].ctrlSeq&&"\\cdot "===t[L][L][L].ctrlSeq?(n.push(t[L][L]),n.push(t[L][L][L]),i=t[L][L][L][L]):i=t[L][L],s=0;s<n.length;s++)n[s].remove();this.elementWise=!0,t.insRightOf(i)}for(a=t[L];a&&!(a instanceof BinaryOperator||a instanceof(LatexCmds.text||noop)||a instanceof SummationNotation||"\\ "===a.ctrlSeq||/^[,;:]$/.test(a.ctrlSeq));)a=a[L];a instanceof SummationNotation&&a[R]instanceof SupSub&&(a=a[R],a[R]instanceof SupSub&&a[R].ctrlSeq!=a.ctrlSeq&&(a=a[R])),a!==t[L]&&(this.replaces(Fragment(a[R]||t.parent.ends[L],t[L])),t[L]=a)}e.createLeftOf.call(this,t)}}),Choose=LatexCmds.choose=P(Binomial,function(t){t.createLeftOf=LiveFraction.prototype.createLeftOf}),FunctionCommand=LatexCmds.functionCommand=P(DerivedMathCommand,function(_,super_){_.ctrlSeq="FunctionCommand{...}{...}",_.htmlTemplate="<span><span>&0</span><span>.</span><span>&1</span></span>",_.init=function(t){"functionCommand"!==t&&(this.incorporate_previous=t),super_.init.call(this)},_.text=function(t){return this.blocks[0].text(t)+"__"+this.blocks[1].text(t)},_.latex=function(){return"\\functionCommand{"+this.blocks[0].latex()+"}{"+this.blocks[1].latex()+"}"},_.finalizeTree=function(){this.ends[R].write=function(t,e){RegExp(/[A-Za-z0-9_\(]/).test(e)?MathBlock.p.write.apply(this,arguments):(t[L]instanceof Variable&&t[L].autoOperator(t),t.insRightOf(this.parent),t.parent.write(t,e))}},_.getObject=function(){if(this.saved_object)return this.saved_object;try{return this.saved_object=SC_Objects[this.objectName()],"string"==typeof this.saved_object&&(SC_Objects[this.objectName()]=eval(this.saved_object),this.saved_object=SC_Objects[this.objectName()]),this.saved_object}catch(err){return this.saved_object=!1,SC_Object()}},_.objectName=function(){return this.blocks[0].text({})},_.createLeftOf=function(t){if(super_.createLeftOf.apply(this,arguments),"undefined"!=typeof this.incorporate_previous){var e=this[L];if(0===e)return;if(0===e[L])return;for(next=e[L];0!==next&&next instanceof Variable;next=e[L])next.disown().adopt(this.ends[L],0,this.ends[L].ends[L]),next.jQ.prependTo(this.ends[L].jQ);e.remove(),t.insAtLeftEnd(this.ends[R]),this.incorporate_previous!==!0&&Letter(this.incorporate_previous).createLeftOf(t)}}}),LatexCommandInput=CharCmds["\\"]=P(MathCommand,function(t,e){t.ctrlSeq="\\",t.replaces=function(t){this._replacedFragment=t.disown(),this.isEmpty=function(){return!1}},t.htmlTemplate='<span class="mq-latex-command-input mq-non-leaf">\\<span>&0</span></span>',t.textTemplate=["\\"],t.createBlocks=function(){e.createBlocks.call(this),this.ends[L].focus=function(){return this.parent.jQ.addClass("mq-hasCursor"),this.isEmpty()&&this.parent.jQ.removeClass("mq-empty"),this},this.ends[L].blur=function(){return this.parent.jQ.removeClass("mq-hasCursor"),this.isEmpty()&&this.parent.jQ.addClass("mq-empty"),this},this.ends[L].write=function(t,e,n){return n&&n.remove(),0==this.parent.ends[L].latex().indexOf("matrix")?void(/^matrix\dx\d$/.test(this.parent.ends[L].latex())?(this.parent.renderCommand(t),"\\"===e&&this.isEmpty()||this.parent.parent.write(t,e)):VanillaSymbol(e).createLeftOf(t)):void(e.match(/[a-z]/i)?VanillaSymbol(e).createLeftOf(t):(this.parent.renderCommand(t),"\\"===e&&this.isEmpty()||this.parent.parent.write(t,e)))},this.ends[L].keystroke=function(t,n,i){return"Tab"===t||"Enter"===t||"Spacebar"===t?(this.parent.renderCommand(i.cursor),void n.preventDefault()):e.keystroke.apply(this,arguments)}},t.createLeftOf=function(t){if(e.createLeftOf.call(this,t),this._replacedFragment){var n=this.jQ[0];this.jQ=this._replacedFragment.jQ.addClass("mq-blur").bind("mousedown mousemove",function(t){return $(t.target=n).trigger(t),!1}).insertBefore(this.jQ).add(this.jQ)}},t.latex=function(){return"\\"+this.ends[L].latex()+" "},t.renderCommand=function(t){var e,n,i;if(this.jQ=this.jQ.last(),this.remove(),this[R]?t.insLeftOf(this[R]):t.insAtRightEnd(this.parent),e=this.ends[L].latex(),e||(e=" "),n=LatexCmds[e])n=n(e),this._replacedFragment&&n.replaces(this._replacedFragment),n.createLeftOf(t);else{for(n=OperatorName(),this._replacedFragment&&n.replaces(this._replacedFragment),n.createLeftOf(t),t.insAtRightEnd(n.blocks[0]),i=0;i<e.length;i++)Letter(e[i]).createLeftOf(t);t.insAtRightEnd(n.blocks[1])}t.workingGroupChange()}}),Matrix=LatexCmds.begin=P(MathCommand,function(t,e){t.numBlocks=function(){return this.col*this.row},t.init=function(t,n,i){var s,a,r,o;for(this.col=n,this.row=i,this.ctrlSeq=t,s="",a=0;i>a;a++){for(r="",o=0;n>o;o++)r+='<span class="mq-cell">&'+(a*n+o)+"</span>";s+='<span class="mq-row">'+r+"</span>"}switch(this.ctrlSeq){case"\\pmatrix":s='<span class="mq-scaled mq-paren">(</span><span class="mq-matrix">'+s+'</span><span class="mq-scaled mq-paren">)</span>';break;case"\\bmatrix":s='<span class="mq-scaled mq-paren">[</span><span class="mq-matrix">'+s+'</span><span class="mq-scaled mq-paren">]</span>';break;case"\\Bmatrix":s='<span class="mq-scaled mq-paren">{</span><span class="mq-matrix">'+s+'</span><span class="mq-scaled mq-paren">}</span>';break;case"\\vmatrix":s='<span class="mq-scaled mq-paren">|</span><span class="mq-matrix">'+s+'</span><span class="mq-scaled mq-paren">|</span>';break;case"\\Vmatrix":s='<span class="mq-scaled mq-paren">||</span><span class="mq-matrix">'+s+'</span><span class="mq-scaled mq-paren">||</span>';break;default:s='<span class="mq-matrix">'+s+"</span>"}e.init.call(this,this.ctrlSeq,'<span class="mq-matrix-outer mq-non-leaf">'+s+"</span>",["text"])},t.reflow=function(){var t=this.jQ.children(".mq-paren"),e=this.jQ.children(".mq-matrix").first(),n=e.outerHeight()/(1.133333*parseInt(e.css("fontSize"),10));scale(t,min(1+.2*(n-1),1.2),1.05*n),t.css("position","relative"),t.css("top",Math.round(.6*n)+"px")},t.contextMenuOLD=function(t,e){var n=this,i=[{text:"Insert Column Before",handler:function(){n.insertColumn(t,L)}},{text:"Insert Column After",handler:function(){n.insertColumn(t,R)}},{text:"Insert Row Before",handler:function(){n.insertRow(t,L)}},{text:"Insert Row After",handler:function(){n.insertRow(t,R)}}];this.col>1&&i.push({text:"Delete Column",handler:function(){n.deleteColumn(t)}}),this.row>1&&i.push({text:"Delete Row",handler:function(){n.deleteRow(t)}}),this.showPopupMenu(i,e)},t.latex=function(){var t="",e=1,n=this.col,i=this.numBlocks(),s=this.ctrlSeq.substring(1,this.ctrlSeq.length);return this.eachChild(function(s){s.ends[L]&&(t+=s.latex()),e!=i&&(t+=e%n==0?" \\\\ ":" & "),e++}),"\\begin{"+s+"}"+t+"\\end{"+s+"}"},t.text=function(t){var e,n,i=[];for(this.eachChild(function(e){i.push(e.ends[L]?e.text(t):0)}),e="",n=0;n<i.length;n++)n>0&&n%this.col==0?e+="],[":n>0&&(e+=","),e+=i[n];return this.row>1?"[["+e+"]]":"["+e+"]"},t.parser=function(){var t=Parser.regex;return t(/^\{[pbvBV]?matrix\}[\s\S]*?\\end\{[pbvBV]?matrix\}/).map(function(t){var e,n,i,s,a,r,o,l,c;for("}"==t.substring(7,1)?(e=t.substring(1,7),t=t.substring(8,t.length-12).trim()):(e=t.substring(1,8),t=t.substring(9,t.length-13).trim()),n=t.split(/\\\\/).map(function(t){return t.trim()}),i=n.length,s=0,a=[],n.forEach(function(t){var e=t.split(/&/);s=Math.max(s,e.length),a=a.concat(e)}),r=Matrix("\\"+e,s,i),o=r.blocks=Array(r.numBlocks()),l=0;l<o.length;l++)c=o[l]=latexMathParser.parse(a[l]),c.deleteOutOf=MatrixMathBlock().deleteOutOf,c.adopt(r,r.ends[R],0);return r})},t.finalizeTree=function(){var t,e,n;for(t=0;t<this.row;t++)for(e=0;e<this.col;e++)n=this.blocks[t*this.col+e],n.upOutOf=0==t&&0!=e?this.blocks[this.row*this.col-this.row+e-1]:this.blocks[(t-1)*this.col+e],n.downOutOf=t+1==this.row&&e+1!=this.col?this.blocks[e+1]:this.blocks[(t+1)*this.col+e]},t.cursorRowCol=function(t){for(var e=0,n=0,i=t.parent;0!==i[L];)e++,e==this.col&&(e=0,n++),i=i[L];return{row:n,col:e}},t.deleteRow=function(t){var e,n,i;if(1!=this.row){for(e=this.cursorRowCol(t),n=e.row*this.col,i=0;i<this.col;i++)this.blocks[n].remove(),this.blocks.splice(n,1);n>0&&n<this.blocks.length?(this.blocks[n][L]=this.blocks[n-1],this.blocks[n-1][R]=this.blocks[n]):0==n?this.blocks[n][L]=0:this.blocks[n-1][R]=0,this.jQ.children(".mq-matrix").first().children(".mq-row").eq(e.row).remove(),this.row--,this.finalizeTree(),t.insAtLeftEnd(this.blocks[e.row>0?(e.row-1)*this.col+e.col:e.col]),this.reflow(),t.workingGroupChange()}},t.deleteColumn=function(t){var e,n,i;if(1!=this.col){for(e=this.cursorRowCol(t),n=e.col,i=0;i<this.row;i++)this.blocks[n].remove(),this.blocks.splice(n,1),n>0&&n<this.blocks.length?(this.blocks[n][L]=this.blocks[n-1],this.blocks[n-1][R]=this.blocks[n]):0==n?this.blocks[n][L]=0:this.blocks[n-1][R]=0,n+=this.col-1;this.col--,this.finalizeTree(),t.insAtLeftEnd(this.blocks[e.col<this.col?e.row*this.col+e.col:e.row*this.col+e.col-1]),this.reflow(),t.workingGroupChange()}},t.createBlocks=function(){var t,e,n=this,i=n.numBlocks(),s=n.blocks=Array(i);for(t=0;i>t;t+=1)e=s[t]=MatrixMathBlock(),e.adopt(n,n.ends[R],0)},t.insertRow=function(t,e){var n,i,s,a,r=this.cursorRowCol(t);for(n="undefined"==typeof e?0===t[L]&&0!==t[R]:e==L?!0:!1,i=r.row*this.col+(n?0:this.col),n?this.jQ.children(".mq-matrix").first().children(".mq-row").eq(r.row).before('<span class="mq-row"></span>'):this.jQ.children(".mq-matrix").first().children(".mq-row").eq(r.row).after('<span class="mq-row"></span>'),s=0;s<this.col;s++)a=MatrixMathBlock(),a.adopt(this,i+s>0?this.blocks[i+s-1]:0,i+s>0?this.blocks[i+s-1][R]:this.ends[L]),a.jQ=$('<span class="mq-cell mq-empty" '+mqBlockId+'="'+a.id+'"></span>'),i+s>0&&(this.blocks[i+s-1][R]=a),this.blocks.splice(i+s,0,a),this.jQ.children(".mq-matrix").first().children(".mq-row").eq(r.row+(n?0:1)).append(a.jQ);i+s<this.blocks.length&&(this.blocks[i+s][L]=a,a[R]=this.blocks[i+s]),this.row++,this.finalizeTree(),t.insAtLeftEnd(this.blocks[i]),this.reflow(),t.workingGroupChange()},t.insertColumn=function(t,e){var n,i,s,a=this.cursorRowCol(t);for(n="undefined"==typeof e?0===t[L]&&0!==t[R]:e==L?!0:!1,i=this.row-1;i>=0;i--)s=MatrixMathBlock(),n?(s.adopt(this,i*this.col+a.col-1>=0?this.blocks[i*this.col+a.col-1]:0,this.blocks[i*this.col+a.col]),s.jQ=$('<span class="mq-cell mq-empty" '+mqBlockId+'="'+s.id+'"></span>'),i*this.col+a.col-1>=0&&(this.blocks[i*this.col+a.col-1][R]=s),this.blocks[i*this.col+a.col][L]=s,this.blocks.splice(i*this.col+a.col,0,s),this.jQ.children(".mq-matrix").first().children(".mq-row").eq(i).children(".mq-cell").eq(a.col).before(s.jQ)):(s.adopt(this,this.blocks[i*this.col+a.col],i*this.col+a.col+1<this.row*this.col?this.blocks[i*this.col+a.col+1]:0),s.jQ=$('<span class="mq-cell mq-empty" '+mqBlockId+'="'+s.id+'"></span>'),this.blocks[i*this.col+a.col][R]=s,i*this.col+a.col+1<this.row*this.col&&(this.blocks[i*this.col+a.col+1][L]=s),this.blocks.splice(i*this.col+a.col+1,0,s),this.jQ.children(".mq-matrix").first().children(".mq-row").eq(i).children(".mq-cell").eq(a.col).after(s.jQ));this.col++,this.finalizeTree(),t.insAtLeftEnd(t.parent[n?L:R]),this.reflow(),t.workingGroupChange()},t.moveOrInsertColumn=function(t){var e=this.cursorRowCol(t);return e.col+1==this.col?this.insertColumn(t):(t.insAtLeftEnd(t.parent[R]),void t.workingGroupChange())}}),LatexCmds.matrix=bind(Matrix,"\\matrix",1,1),LatexCmds.bmatrix=bind(Matrix,"\\bmatrix",1,1),LatexCmds.Bmatrix=bind(Matrix,"\\Bmatrix",1,1),LatexCmds.vmatrix=bind(Matrix,"\\vmatrix",1,1),LatexCmds.Vmatrix=bind(Matrix,"\\Vmatrix",1,1),LatexCmds.pmatrix=bind(Matrix,"\\pmatrix",1,1),MatrixMathBlock=P(MathBlock,function(t){t.deleteOutOf=function(t,e){var n,i,s,a,r;if(0===this.ends[L])n=t===L?this[L]:this[R],this.parent.deleteColumn(e),t===L&&(n?e.insAtRightEnd(n):n&&e.insAtLeftEnd(n));else if(i=this[t],s=this.parent.cursorRowCol(e),t===L&&0===s.col&&(i=0),t===R&&s.col+1===this.parent.col&&(i=0),0===i)this.parent[L]?(a=this.parent[L],this.parent.remove(),e.insRightOf(a)):(a=this.parent.parent,this.parent.remove(),e.insAtLeftEnd(a));else{for(r=i.ends[L];0!==r;r=r[R])r.remove();e.insAtRightEnd(i),this.parent.deleteColumn(e),t===L?e.insAtLeftEnd(this):e.insAtRightEnd(this)}}}),OperatorName=LatexCmds.operatorname=P(MathCommand,function(t,e){t.htmlTemplate='<span><span class="mq-operator-name">&0</span><span class="mq-non-leaf"><span class="mq-scaled mq-paren">(</span><span class="mq-non-leaf">&1</span><span class="mq-scaled mq-paren">)</span></span></span>',t.init=function(t){e.init.call(this,t)},t.createLeftOf=function(t){e.createLeftOf.apply(this,arguments),t.insAtRightEnd(this.blocks[1])},t.reflow=function(){var t=this.jQ.children(":last").children(":first").add(this.jQ.children(":last").children(":last")),e=this.jQ.children(":last").children(":eq(1)"),n=e.outerHeight()/parseInt(e.css("fontSize"),10);scale(t,min(1+.2*(n-1),1.2),1.05*n)},t.text=function(t){return"undefined"!=typeof t.operatorNameTextOutput?t.operatorNameTextOutput(this,this.blocks[0].text(t),this.blocks[1].text(t)):this.blocks[0].text(t)+"("+this.blocks[1].text(t)+")"},t.latex=function(){return BuiltInOpNames.hasOwnProperty(this.blocks[0].text())?"\\"+this.blocks[0].latex()+"\\left({"+this.blocks[1].latex()+"}\\right)":"\\operatorname{"+this.blocks[0].latex()+"}\\left({"+this.blocks[1].latex()+"}\\right)"},t.parser=function(){var t,e=Parser.string,n=Parser.optWhitespace,i=Parser.succeed,s=latexMathParser.block,a=this.ctrlSeq,r=this,o=r.blocks=[MathBlock(),MathBlock()];for(t=0;t<o.length;t+=1)o[t].adopt(r,r.ends[R],0);if(BuiltInOpNames.hasOwnProperty(this.ctrlSeq)){for(t=0;t<a.length;t+=1)Letter(a.charAt(t)).adopt(this.ends[L],this.ends[L].ends[R],0);return n.then(e("\\left(")).then(function(){var t=o[1];return s.then(function(e){return e.children().adopt(t,t.ends[R],0),i(r)})}).then(e("\\right)")).result(r)}return n.then(function(){var t=o[0];return s.then(function(e){var n,s;for(e.children().adopt(t,t.ends[R],0),n=e.ends[L];0!==n;n=n[R])if("f"===n.ctrlSeq)n.htmlTemplate="<var>f</var>";else if(n instanceof SupSub&&"sub"===n.supsub)for(s=n.blocks[0].ends[L];0!==s;s=s[R])"f"===s.ctrlSeq&&(s.htmlTemplate="<var>f</var>");return i(r)})}).then(e("\\left(")).then(function(){var t=o[1];return s.then(function(e){return e.children().adopt(t,t.ends[R],0),i(r)})}).then(e("\\right)")).result(r)}});for(fn in BuiltInOpNames)BuiltInOpNames.hasOwnProperty(fn)&&(LatexCmds[fn]=OperatorName);SquareRoot=LatexCmds.sqrt=LatexCmds["√"]=P(MathCommand,function(t,e){t.ctrlSeq="\\sqrt",t.htmlTemplate='<span class="mq-non-leaf"><span class="mq-scaled mq-sqrt-prefix">√</span><span class="mq-non-leaf mq-sqrt-stem">&0</span></span>',t.textTemplate=[" sqrt(",")"],t.parser=function(){return latexMathParser.optBlock.then(function(t){return latexMathParser.block.map(function(e){var n=NthRoot();return n.blocks=[t,e],t.adopt(n,0,0),e.adopt(n,t,0),n})}).or(e.parser.call(this))},t.reflow=function(){var t=this.ends[R].jQ;scale(t.prev(),1,t.innerHeight()/+t.css("fontSize").slice(0,-2)-.1)}}),NthRoot=LatexCmds.nthroot=P(SquareRoot,function(t){t.htmlTemplate='<sup class="mq-nthroot mq-non-leaf">&0</sup><span class="mq-scaled"><span class="mq-sqrt-prefix mq-scaled">√</span><span class="mq-sqrt-stem mq-non-leaf">&1</span></span>',t.textTemplate=["sqrt[","](",")"],t.latex=function(){return"\\sqrt["+this.ends[L].latex()+"]{"+this.ends[R].latex()+"}"
|
3
|
-
},t.text=function(t){return" "+this.ends[R].text(t)+"^(1/"+this.ends[L].text(t)+")"}}),ScientificNotation=LatexCmds.scientificNotation=P(DerivedMathCommand,function(t,e){t.ctrlSeq="ScientificNotation{...}{...}",t.htmlTemplate='<span><span>&0</span><span style="font-size:0.7em;">×</span><span>10</span><span class="mq-supsub mq-non-leaf mq-sup-only"><span class="mq-sup">&1</span></span></span>',t.init=function(t){"scientificNotation"!==t&&(this.incorporate_previous=t),e.init.call(this)},t.text=function(t){return this.blocks[0].text(t)+"e"+this.blocks[1].text(t)},t.latex=function(){return"\\scientificNotation{"+this.blocks[0].latex()+"}{"+this.blocks[1].latex()+"}"},t.finalizeTree=function(){this.downInto=this.ends[L],this.upInto=this.ends[R],this.ends[L].upOutOf=this.ends[R],this.ends[R].downOutOf=this.ends[L],this.ends[L].write=function(t,e){RegExp(/[0-9]/).test(e)?MathBlock.p.write.apply(this,arguments):(t.insRightOf(this.parent),t.parent.write(t,e))},this.ends[R].write=function(t,e){if(RegExp(/[0-9\+\-]/).test(e))if("+"===e||"-"===e){if(0===t[L]&&0!==t[R]&&("-"===t[R].ctrlSeq||"+"===t[R].ctrlSeq))return t[R].ctrlSeq=e,t[R].textTemplate=e,void t[R].jQ.html(e);if(0!==t[L]&&0===t[L][L]&&("-"===t[L].ctrlSeq||"+"===t[L].ctrlSeq))return t[L].ctrlSeq=e,t[L].textTemplate=e,void t[L].jQ.html(e);0!==t[L]&&(t.insRightOf(this.parent),t.parent.write(t,e))}else MathBlock.p.write.apply(this,arguments);else t.insRightOf(this.parent),t.parent.write(t,e)}},t.createLeftOf=function(t){if(e.createLeftOf.apply(this,arguments),"undefined"!=typeof this.incorporate_previous){var n=this[L];if(0===n)return;if(0===n[L])return;for(next=n[L];0!==next&&"undefined"!=typeof next.ctrlSeq&&next.ctrlSeq.match(/^[0-9\.]$/);next=n[L])next.disown().adopt(this.ends[L],0,this.ends[L].ends[L]),next.jQ.prependTo(this.ends[L].jQ);n.remove(),t.insAtLeftEnd(this.ends[R]),this.ends[R].write(t,this.incorporate_previous)}}}),SummationNotation=P(MathCommand,function(t,e){t.init=function(t,e){var n='<span><span class="mq-large-operator mq-non-leaf"><span class="mq-to"><span>&1</span></span><big>'+e+'</big><span class="mq-from"><span>&0</span></span></span><span class="mq-non-leaf"><span class="mq-scaled mq-paren">(</span><span class="mq-non-leaf">&2</span><span class="mq-scaled mq-paren">)</span></span></span>';Symbol.prototype.init.call(this,t,n)},t.createLeftOf=function(t){e.createLeftOf.apply(this,arguments),Letter("n").createLeftOf(t),LatexCmds["="]().createLeftOf(t)},t.reflow=function(){var t=this.jQ.children(":last").children(":first").add(this.jQ.children(":last").children(":last")),e=this.jQ.children(":last").children(":eq(1)"),n=e.outerHeight()/parseInt(e.css("fontSize"),10);scale(t,min(1+.2*(n-1),1.2),1.05*n)},t.latex=function(){return this.ctrlSeq+"_{"+this.blocks[0].latex()+"}^{"+this.blocks[1].latex()+"}\\left({"+this.blocks[2].latex()+"}\\right)"},t.text=function(t){return" "+this.ctrlSeq+'("'+this.blocks[0].text(t).replace(" :=",'" , ')+" , "+this.blocks[1].text(t)+","+this.blocks[2].text(t)+")"},t.parser=function(){var t,e=Parser.string,n=Parser.optWhitespace,i=(Parser.whitespace,Parser.succeed),s=latexMathParser.block,a=this,r=a.blocks=[MathBlock(),MathBlock(),MathBlock()];for(t=0;t<r.length;t+=1)r[t].adopt(a,a.ends[R],0);return n.then(e("_")).then(function(){var t=r[0];return s.then(function(e){return e.children().adopt(t,t.ends[R],0),i(a)})}).then(n).then(e("^")).then(function(){var t=r[1];return s.then(function(e){return e.children().adopt(t,t.ends[R],0),i(a)})}).then(e("\\left(")).then(function(){var t=r[2];return s.then(function(e){return e.children().adopt(t,t.ends[R],0),i(a)})}).then(e("\\right)")).result(a)},t.finalizeTree=function(){this.downInto=this.ends[L],this.upInto=this.ends[R],this.ends[L].upOutOf=this.ends[R],this.ends[R].downOutOf=this.ends[L]}}),LatexCmds["∑"]=LatexCmds.sum=LatexCmds.summation=bind(SummationNotation,"\\sum ","∑"),LatexCmds["∏"]=LatexCmds.prod=LatexCmds.product=bind(SummationNotation,"\\prod ","∏"),LatexCmds.coprod=LatexCmds.coproduct=bind(SummationNotation,"\\coprod ","∐"),SupSub=P(MathCommand,function(t,e){t.ctrlSeq="_{...}^{...}",t.createLeftOf=function(t){var n,i,s,a,r,o,l,c;if("sub"===this.supsub){if(!(t[L]instanceof Variable))return;t[L]instanceof Variable&&t[R]instanceof Variable&&(n=LatexCmds.cdot(),n.createLeftOf(t),t.insLeftOf(n))}else{if(0===t[L]||t[L]instanceof BinaryOperator)return;if("."===t[L].ctrlSeq&&t[L][L]){for(i=[t[L]],t[L][L]&&t[L][L][L]&&t[L][L][L][L]&&"0"===t[L][L].ctrlSeq&&"\\cdot "===t[L][L][L].ctrlSeq?(i.push(t[L][L]),i.push(t[L][L][L]),s=t[L][L][L][L]):s=t[L][L],a=0;a<i.length;a++)i[a].remove();this.elementWise=!0,t.insRightOf(s)}if((t[L]instanceof Fraction||t[L]instanceof DerivedMathCommand)&&(r=CharCmds["("](),o=t[L],r.createLeftOf(t),o.disown(),o.adopt(r.ends[L],0,0),o.jQ.prependTo(r.ends[L].jQ),l=CharCmds[")"](),l.createLeftOf(t),r.reflow()),t[L]instanceof SupSub&&"sup"===t[L].supsub){for(r=CharCmds["("](),o=[t[L]],c=t[L];!(c instanceof BinaryOperator)&&0!==c;c=c[L])o.push(c);for(r.createLeftOf(t),a=0;a<o.length;a++)o[a].disown(),o[a].adopt(r.ends[L],0,r.ends[L].ends[L]),o[a].jQ.prependTo(r.ends[L].jQ);l=CharCmds[")"](),l.createLeftOf(t),r.reflow()}}return e.createLeftOf.call(this,t)},Options.p.charsThatBreakOutOfSupSub="",t.finalizeTree=function(){var t,e,n,i=this.supsub;this.setUnit(),this.unitsup=!1,this.ends[L].write=function(t,e){return"sub"==i&&"_"===e?this.flash():void(t.options.charsThatBreakOutOfSupSub.indexOf(e)>-1?(t[L]instanceof Variable&&t[L].autoOperator(t),t.insRightOf(this.parent),t.parent.write(t,e)):"sub"!=i||RegExp(/[A-Za-z0-9]/).test(e)?MathBlock.p.write.apply(this,arguments):(t[L]instanceof Variable&&t[L].autoOperator(t),t.insRightOf(this.parent),t.parent.write(t,e)))},this.sup&&this.sup.ends[L]&&"."===this.sup.ends[L].ctrlSeq&&(this.sup.ends[L].remove(),this.elementWise=!0),this.elementWise&&this.jQ.addClass("mq-elementwise"),this.sub&&(t=this.jQ.closest(".mq-editable-field").children(".mq-autocomplete").first(),t.length>0&&(e=this.jQ,n=e.position(),t.css({top:Math.ceil(n.top+e.height())+"px"})))},t.latex=function(){function t(t,n){var i=n&&n.latex();return n?t+(1===i.length?i:"{"+(e?".":"")+(i||" ")+"}"):""}var e=this.elementWise;return t("_",this.sub)+t("^",this.sup)},t.text=function(t){var e="";return this.sub&&(e+="_"+(this.sub&&0!==this.sub.ends[L]&&this.sub.ends[L]===this.sub.ends[R]?this.sub.ends[L].text(t):this.sub.foldChildren("",function(e,n){return e+n.text(t)}))),this.sup&&(this.elementWise&&(e+="."),e+="^"+(this.sup&&0!==this.sup.ends[L]&&this.sup.ends[L]===this.sup.ends[R]?this.sup.ends[L].text(t):"("+this.sup.foldChildren("",function(e,n){return e+n.text(t)})+")")),e},t.respace=t.siblingCreated=t.siblingDeleted=function(t,e){e!==R&&this.jQ.toggleClass("mq-limit","\\int "===this[L].ctrlSeq)},t.addBlock=function(t){"sub"===this.supsub?(this.sup=this.upInto=this.sub.upOutOf=t,t.adopt(this,this.sub,0).downOutOf=this.sub,t.jQ=$('<span class="mq-sup"/>').append(t.jQ.children()).attr(mqBlockId,t.id).prependTo(this.jQ)):(this.sub=this.downInto=this.sup.downOutOf=t,t.adopt(this,0,this.sup).upOutOf=this.sup,t.jQ=$('<span class="mq-sub"></span>').append(t.jQ.children()).attr(mqBlockId,t.id).appendTo(this.jQ.removeClass("mq-sup-only")),this.jQ.append('<span style="display:inline-block;width:0"> </span>'));for(var e=0;2>e;e+=1)(function(t,e,n,i){t[e].deleteOutOf=function(s,a){a.insDirOf(s,this.parent),this.isEmpty()||(a[-s]=this.ends[s],this.children().disown().withDirAdopt(s,a.parent,a[s],this.parent).jQ.insDirOf(s,this.parent.jQ)),t.supsub=n,delete t[e],delete t[i+"Into"],t[n][i+"OutOf"]=insLeftOfMeUnlessAtEnd,delete t[n].deleteOutOf,"sub"===e&&$(t.jQ.addClass("mq-sup-only")[0].lastChild).remove(),this.remove()}})(this,"sub sup".split(" ")[e],"sup sub".split(" ")[e],"down up".split(" ")[e])}}),LatexCmds.subscript=LatexCmds._=P(SupSub,function(t,e){t.supsub="sub",t.ctrlSeq="_",t.htmlTemplate='<span class="mq-supsub mq-non-leaf"><span class="mq-sub">&0</span><span style="display:inline-block;width:0"> </span></span>',t.textTemplate=["_"],t.finalizeTree=function(){this.downInto=this.sub=this.ends[L],this.sub.upOutOf=insLeftOfMeUnlessAtEnd,e.finalizeTree.call(this)}}),LatexCmds.superscript=LatexCmds.supscript=LatexCmds["^"]=P(SupSub,function(t,e){t.supsub="sup",t.ctrlSeq="^",t.htmlTemplate='<span class="mq-supsub mq-non-leaf mq-sup-only"><span class="mq-sup">&0</span></span>',t.textTemplate=["^"],t.finalizeTree=function(){this.upInto=this.sup=this.ends[R],this.sup.downOutOf=insLeftOfMeUnlessAtEnd,e.finalizeTree.call(this)}}),LatexCmds.notin=LatexCmds.sim=LatexCmds.cong=LatexCmds.equiv=LatexCmds.oplus=LatexCmds.otimes=P(BinaryOperator,function(t,e){t.init=function(t){e.init.call(this,"\\"+t+" ","&"+t+";")}}),LatexCmds.ast=LatexCmds.star=LatexCmds.loast=LatexCmds.lowast=bind(BinaryOperator,"\\ast ","∗"),LatexCmds.therefor=LatexCmds.therefore=bind(BinaryOperator,"\\therefore ","∴"),LatexCmds.cuz=LatexCmds.because=bind(BinaryOperator,"\\because ","∵"),LatexCmds.prop=LatexCmds.propto=bind(BinaryOperator,"\\propto ","∝"),LatexCmds["≈"]=LatexCmds.asymp=LatexCmds.approx=bind(BinaryOperator,"\\approx ","≈"),LatexCmds.isin=LatexCmds["in"]=bind(BinaryOperator,"\\in ","∈"),LatexCmds.ni=LatexCmds.contains=bind(BinaryOperator,"\\ni ","∋"),LatexCmds.notni=LatexCmds.niton=LatexCmds.notcontains=LatexCmds.doesnotcontain=bind(BinaryOperator,"\\not\\ni ","∌"),LatexCmds.sub=LatexCmds.subset=bind(BinaryOperator,"\\subset ","⊂"),LatexCmds.sup=LatexCmds.supset=LatexCmds.superset=bind(BinaryOperator,"\\supset ","⊃"),LatexCmds.nsub=LatexCmds.notsub=LatexCmds.nsubset=LatexCmds.notsubset=bind(BinaryOperator,"\\not\\subset ","⊄"),LatexCmds.nsup=LatexCmds.notsup=LatexCmds.nsupset=LatexCmds.notsupset=LatexCmds.nsuperset=LatexCmds.notsuperset=bind(BinaryOperator,"\\not\\supset ","⊅"),LatexCmds.sube=LatexCmds.subeq=LatexCmds.subsete=LatexCmds.subseteq=bind(BinaryOperator,"\\subseteq ","⊆"),LatexCmds.supe=LatexCmds.supeq=LatexCmds.supsete=LatexCmds.supseteq=LatexCmds.supersete=LatexCmds.superseteq=bind(BinaryOperator,"\\supseteq ","⊇"),LatexCmds.nsube=LatexCmds.nsubeq=LatexCmds.notsube=LatexCmds.notsubeq=LatexCmds.nsubsete=LatexCmds.nsubseteq=LatexCmds.notsubsete=LatexCmds.notsubseteq=bind(BinaryOperator,"\\not\\subseteq ","⊈"),LatexCmds.nsupe=LatexCmds.nsupeq=LatexCmds.notsupe=LatexCmds.notsupeq=LatexCmds.nsupsete=LatexCmds.nsupseteq=LatexCmds.notsupsete=LatexCmds.notsupseteq=LatexCmds.nsupersete=LatexCmds.nsuperseteq=LatexCmds.notsupersete=LatexCmds.notsuperseteq=bind(BinaryOperator,"\\not\\supseteq ","⊉"),LatexCmds.N=LatexCmds.naturals=LatexCmds.Naturals=bind(VanillaSymbol,"\\mathbb{N}","ℕ"),LatexCmds.P=LatexCmds.primes=LatexCmds.Primes=LatexCmds.projective=LatexCmds.Projective=LatexCmds.probability=LatexCmds.Probability=bind(VanillaSymbol,"\\mathbb{P}","ℙ"),LatexCmds.Z=LatexCmds.integers=LatexCmds.Integers=bind(VanillaSymbol,"\\mathbb{Z}","ℤ"),LatexCmds.Q=LatexCmds.rationals=LatexCmds.Rationals=bind(VanillaSymbol,"\\mathbb{Q}","ℚ"),LatexCmds.R=LatexCmds.reals=LatexCmds.Reals=bind(VanillaSymbol,"\\mathbb{R}","ℝ"),LatexCmds.C=LatexCmds.complex=LatexCmds.Complex=LatexCmds.complexes=LatexCmds.Complexes=LatexCmds.complexplane=LatexCmds.Complexplane=LatexCmds.ComplexPlane=bind(VanillaSymbol,"\\mathbb{C}","ℂ"),LatexCmds.H=LatexCmds.Hamiltonian=LatexCmds.quaternions=LatexCmds.Quaternions=bind(VanillaSymbol,"\\mathbb{H}","ℍ"),LatexCmds.quad=LatexCmds.emsp=bind(VanillaSymbol,"\\quad "," "),LatexCmds.qquad=bind(VanillaSymbol,"\\qquad "," "),LatexCmds.diamond=bind(VanillaSymbol,"\\diamond ","◇"),LatexCmds.bigtriangleup=bind(VanillaSymbol,"\\bigtriangleup ","△"),LatexCmds.ominus=bind(VanillaSymbol,"\\ominus ","⊖"),LatexCmds.uplus=bind(VanillaSymbol,"\\uplus ","⊎"),LatexCmds.bigtriangledown=bind(VanillaSymbol,"\\bigtriangledown ","▽"),LatexCmds.sqcap=bind(VanillaSymbol,"\\sqcap ","⊓"),LatexCmds.triangleleft=bind(VanillaSymbol,"\\triangleleft ","⊲"),LatexCmds.sqcup=bind(VanillaSymbol,"\\sqcup ","⊔"),LatexCmds.triangleright=bind(VanillaSymbol,"\\triangleright ","⊳"),LatexCmds.odot=bind(VanillaSymbol,"\\odot ","⊙"),LatexCmds.bigcirc=bind(VanillaSymbol,"\\bigcirc ","◯"),LatexCmds.dagger=bind(VanillaSymbol,"\\dagger ","†"),LatexCmds.ddagger=bind(VanillaSymbol,"\\ddagger ","‡"),LatexCmds.wr=bind(VanillaSymbol,"\\wr ","≀"),LatexCmds.amalg=bind(VanillaSymbol,"\\amalg ","∐"),LatexCmds.models=bind(VanillaSymbol,"\\models ","⊨"),LatexCmds.prec=bind(VanillaSymbol,"\\prec ","≺"),LatexCmds.succ=bind(VanillaSymbol,"\\succ ","≻"),LatexCmds.preceq=bind(VanillaSymbol,"\\preceq ","≼"),LatexCmds.succeq=bind(VanillaSymbol,"\\succeq ","≽"),LatexCmds.simeq=bind(VanillaSymbol,"\\simeq ","≃"),LatexCmds.mid=bind(VanillaSymbol,"\\mid ","∣"),LatexCmds.ll=bind(VanillaSymbol,"\\ll ","≪"),LatexCmds.gg=bind(VanillaSymbol,"\\gg ","≫"),LatexCmds.parallel=bind(VanillaSymbol,"\\parallel ","∥"),LatexCmds.bowtie=bind(VanillaSymbol,"\\bowtie ","⋈"),LatexCmds.sqsubset=bind(VanillaSymbol,"\\sqsubset ","⊏"),LatexCmds.sqsupset=bind(VanillaSymbol,"\\sqsupset ","⊐"),LatexCmds.smile=bind(VanillaSymbol,"\\smile ","⌣"),LatexCmds.sqsubseteq=bind(VanillaSymbol,"\\sqsubseteq ","⊑"),LatexCmds.sqsupseteq=bind(VanillaSymbol,"\\sqsupseteq ","⊒"),LatexCmds.doteq=bind(VanillaSymbol,"\\doteq ","≐"),LatexCmds.frown=bind(VanillaSymbol,"\\frown ","⌢"),LatexCmds.vdash=bind(VanillaSymbol,"\\vdash ","⊦"),LatexCmds.dashv=bind(VanillaSymbol,"\\dashv ","⊣"),LatexCmds.longleftarrow=bind(VanillaSymbol,"\\longleftarrow ","←"),LatexCmds.longrightarrow=bind(VanillaSymbol,"\\longrightarrow ","→"),LatexCmds.Longleftarrow=bind(VanillaSymbol,"\\Longleftarrow ","⇐"),LatexCmds.Longrightarrow=bind(VanillaSymbol,"\\Longrightarrow ","⇒"),LatexCmds.longleftrightarrow=bind(VanillaSymbol,"\\longleftrightarrow ","↔"),LatexCmds.updownarrow=bind(VanillaSymbol,"\\updownarrow ","↕"),LatexCmds.Longleftrightarrow=bind(VanillaSymbol,"\\Longleftrightarrow ","⇔"),LatexCmds.Updownarrow=bind(VanillaSymbol,"\\Updownarrow ","⇕"),LatexCmds.mapsto=bind(VanillaSymbol,"\\mapsto ","↦"),LatexCmds.nearrow=bind(VanillaSymbol,"\\nearrow ","↗"),LatexCmds.hookleftarrow=bind(VanillaSymbol,"\\hookleftarrow ","↩"),LatexCmds.hookrightarrow=bind(VanillaSymbol,"\\hookrightarrow ","↪"),LatexCmds.searrow=bind(VanillaSymbol,"\\searrow ","↘"),LatexCmds.leftharpoonup=bind(VanillaSymbol,"\\leftharpoonup ","↼"),LatexCmds.rightharpoonup=bind(VanillaSymbol,"\\rightharpoonup ","⇀"),LatexCmds.swarrow=bind(VanillaSymbol,"\\swarrow ","↙"),LatexCmds.leftharpoondown=bind(VanillaSymbol,"\\leftharpoondown ","↽"),LatexCmds.rightharpoondown=bind(VanillaSymbol,"\\rightharpoondown ","⇁"),LatexCmds.nwarrow=bind(VanillaSymbol,"\\nwarrow ","↖"),LatexCmds.ldots=bind(VanillaSymbol,"\\ldots ","…"),LatexCmds.cdots=bind(VanillaSymbol,"\\cdots ","⋯"),LatexCmds.vdots=bind(VanillaSymbol,"\\vdots ","⋮"),LatexCmds.ddots=bind(VanillaSymbol,"\\ddots ","⋰"),LatexCmds.surd=bind(VanillaSymbol,"\\surd ","√"),LatexCmds.triangle=bind(VanillaSymbol,"\\triangle ","▵"),LatexCmds.ell=bind(VanillaSymbol,"\\ell ","ℓ"),LatexCmds.top=bind(VanillaSymbol,"\\top ","⊤"),LatexCmds.flat=bind(VanillaSymbol,"\\flat ","♭"),LatexCmds.natural=bind(VanillaSymbol,"\\natural ","♮"),LatexCmds.sharp=bind(VanillaSymbol,"\\sharp ","♯"),LatexCmds.wp=bind(VanillaSymbol,"\\wp ","℘"),LatexCmds.bot=bind(VanillaSymbol,"\\bot ","⊥"),LatexCmds.clubsuit=bind(VanillaSymbol,"\\clubsuit ","♣"),LatexCmds.diamondsuit=bind(VanillaSymbol,"\\diamondsuit ","♢"),LatexCmds.heartsuit=bind(VanillaSymbol,"\\heartsuit ","♡"),LatexCmds.spadesuit=bind(VanillaSymbol,"\\spadesuit ","♠"),LatexCmds.oint=bind(VanillaSymbol,"\\oint ","∮"),LatexCmds.bigcap=bind(VanillaSymbol,"\\bigcap ","∩"),LatexCmds.bigcup=bind(VanillaSymbol,"\\bigcup ","∪"),LatexCmds.bigsqcup=bind(VanillaSymbol,"\\bigsqcup ","⊔"),LatexCmds.bigvee=bind(VanillaSymbol,"\\bigvee ","∨"),LatexCmds.bigwedge=bind(VanillaSymbol,"\\bigwedge ","∧"),LatexCmds.bigodot=bind(VanillaSymbol,"\\bigodot ","⊙"),LatexCmds.bigotimes=bind(VanillaSymbol,"\\bigotimes ","⊗"),LatexCmds.bigoplus=bind(VanillaSymbol,"\\bigoplus ","⊕"),LatexCmds.biguplus=bind(VanillaSymbol,"\\biguplus ","⊎"),LatexCmds.lfloor=bind(VanillaSymbol,"\\lfloor ","⌊"),LatexCmds.rfloor=bind(VanillaSymbol,"\\rfloor ","⌋"),LatexCmds.lceil=bind(VanillaSymbol,"\\lceil ","⌈"),LatexCmds.rceil=bind(VanillaSymbol,"\\rceil ","⌉"),LatexCmds.opencurlybrace=LatexCmds.lbrace=bind(VanillaSymbol,"\\lbrace ","{"),LatexCmds.closecurlybrace=LatexCmds.rbrace=bind(VanillaSymbol,"\\rbrace ","}"),LatexCmds["∫"]=LatexCmds["int"]=LatexCmds.integral=bind(Symbol,"\\int ","<big>∫</big>"),LatexCmds.caret=bind(VanillaSymbol,"\\text{^}","^"),LatexCmds.underscore=bind(VanillaSymbol,"\\_","_"),LatexCmds.slash=bind(VanillaSymbol,"/"),LatexCmds.vert=bind(VanillaSymbol,"|"),LatexCmds.perp=LatexCmds.perpendicular=bind(VanillaSymbol,"\\perp ","⊥"),LatexCmds.nabla=LatexCmds.del=bind(VanillaSymbol,"\\nabla ","∇"),LatexCmds.hbar=bind(VanillaSymbol,"\\hbar ","ℏ"),LatexCmds.AA=LatexCmds.Angstrom=LatexCmds.angstrom=bind(VanillaSymbol,"\\text\\AA ","Å"),LatexCmds.ring=LatexCmds.circ=LatexCmds.circle=bind(VanillaSymbol,"\\circ ","∘"),LatexCmds.bull=LatexCmds.bullet=bind(VanillaSymbol,"\\bullet ","•"),LatexCmds.setminus=LatexCmds.smallsetminus=bind(VanillaSymbol,"\\setminus ","∖"),LatexCmds.not=LatexCmds["¬"]=LatexCmds.neg=bind(VanillaSymbol,"\\neg ","¬"),LatexCmds.dots=LatexCmds.ellip=LatexCmds.hellip=LatexCmds.ellipsis=LatexCmds.hellipsis=bind(VanillaSymbol,"\\dots ","…"),LatexCmds["…"]=bind(VanillaSymbol,"…",'<span class="mq-nonSymbola" style="font-size:0.6em;">…</span>',".."),LatexCmds.converges=LatexCmds.darr=LatexCmds.dnarr=LatexCmds.dnarrow=LatexCmds.downarrow=bind(VanillaSymbol,"\\downarrow ","↓"),LatexCmds.dArr=LatexCmds.dnArr=LatexCmds.dnArrow=LatexCmds.Downarrow=bind(VanillaSymbol,"\\Downarrow ","⇓"),LatexCmds.diverges=LatexCmds.uarr=LatexCmds.uparrow=bind(VanillaSymbol,"\\uparrow ","↑"),LatexCmds.uArr=LatexCmds.Uparrow=bind(VanillaSymbol,"\\Uparrow ","⇑"),LatexCmds.to=bind(BinaryOperator,"\\to ","→"),LatexCmds.rarr=LatexCmds.rightarrow=bind(VanillaSymbol,"\\rightarrow ","→"),LatexCmds.implies=bind(BinaryOperator,"\\Rightarrow ","⇒"),LatexCmds.rArr=LatexCmds.Rightarrow=bind(VanillaSymbol,"\\Rightarrow ","⇒"),LatexCmds.gets=bind(BinaryOperator,"\\gets ","←"),LatexCmds.larr=LatexCmds.leftarrow=bind(VanillaSymbol,"\\leftarrow ","←"),LatexCmds.impliedby=bind(BinaryOperator,"\\Leftarrow ","⇐"),LatexCmds.lArr=LatexCmds.Leftarrow=bind(VanillaSymbol,"\\Leftarrow ","⇐"),LatexCmds.harr=LatexCmds.lrarr=LatexCmds.leftrightarrow=bind(VanillaSymbol,"\\leftrightarrow ","↔"),LatexCmds.iff=bind(BinaryOperator,"\\Leftrightarrow ","⇔"),LatexCmds.hArr=LatexCmds.lrArr=LatexCmds.Leftrightarrow=bind(VanillaSymbol,"\\Leftrightarrow ","⇔"),LatexCmds.Re=LatexCmds.Real=LatexCmds.real=bind(VanillaSymbol,"\\Re ","ℜ"),LatexCmds.Im=LatexCmds.imag=LatexCmds.image=LatexCmds.imagin=LatexCmds.imaginary=LatexCmds.Imaginary=bind(VanillaSymbol,"\\Im ","ℑ"),LatexCmds.part=LatexCmds.partial=bind(VanillaSymbol,"\\partial ","∂"),LatexCmds.infty=LatexCmds.infin=LatexCmds.infinity=bind(VanillaSymbol,"\\infty ","∞"),LatexCmds.alef=LatexCmds.alefsym=LatexCmds.aleph=LatexCmds.alephsym=bind(VanillaSymbol,"\\aleph ","ℵ"),LatexCmds.xist=LatexCmds.xists=LatexCmds.exist=LatexCmds.exists=bind(VanillaSymbol,"\\exists ","∃"),LatexCmds.and=LatexCmds.land=LatexCmds.wedge=bind(VanillaSymbol,"\\wedge ","∧"),LatexCmds.or=LatexCmds.lor=LatexCmds.vee=bind(VanillaSymbol,"\\vee ","∨"),LatexCmds.o=LatexCmds.O=LatexCmds.empty=LatexCmds.emptyset=LatexCmds.oslash=LatexCmds.Oslash=LatexCmds.nothing=LatexCmds.varnothing=bind(BinaryOperator,"\\varnothing ","∅"),LatexCmds.cup=LatexCmds.union=bind(BinaryOperator,"\\cup ","∪"),LatexCmds.cap=LatexCmds.intersect=LatexCmds.intersection=bind(BinaryOperator,"\\cap ","∩"),LatexCmds.deg=LatexCmds.degree=bind(VanillaSymbol,"^\\circ ","°"),LatexCmds.ang=LatexCmds.angle=bind(VanillaSymbol,"\\angle ","∠"),Variable=P(Symbol,function(t,e){t.init=function(t,n){e.init.call(this,t,"<var>"+(n||t)+"</var>")},t.text=function(t){return!t||!t.unit||this[L]instanceof Variable||this[L]&&"µ"==this[L].ctrlSeq?this.textTemplate:"_"+this.textTemplate},t.autoUnItalicize=function(t){var e,n,i,s,a="",r=[];for(e=this;e instanceof Variable;e=e[L])a=e.ctrlSeq+a,r.push(e);if(t.parent&&t.parent.parent instanceof SupSub&&"sub"===t.parent.parent.supsub){for(a="_"+a,r=[t.parent.parent],e=t.parent.parent[L];e instanceof Variable;e=e[L])a=e.ctrlSeq+a,r.push(e);t.insRightOf(t.parent.parent)}for(n=OperatorName(),n.createLeftOf(t),i=0;i<r.length;i++){if("f"===r[i].ctrlSeq&&r[i].jQ.removeClass("mq-florin").html("f"),r[i]instanceof SupSub&&"sub"===r[i].supsub)for(s=r[i].blocks[0].ends[L];0!==s;s=s[R])"f"===s.ctrlSeq&&s.jQ.removeClass("mq-florin").html("f");r[i].disown(),r[i].adopt(n.ends[L],0,n.ends[L].ends[L]),r[i].jQ.prependTo(n.ends[L].jQ)}n.ends[L].jQ.removeClass("mq-empty")},t.fullWord=function(){var t,e=this.text({})+"",n=[this];for(t=this[L];t instanceof Variable;t=t[L])n.unshift(t),e=t.text({})+e;if(this.parent&&this.parent.parent instanceof SupSub&&"sub"===this.parent.parent.supsub)for(e="_"+e,n=[this.parent.parent],t=this.parent.parent[L];t instanceof Variable;t=t[L])n.unshift(t),e=t.text({})+e;for(t=this[R];t instanceof Variable;t=t[R])n.push(t),e+=t.text({});if(t instanceof SupSub&&"sub"===t.supsub)for(e+="_",n.push(t),t=t.ends[L].ends[L];t instanceof Variable;t=t[R])e+=t.text({});return[e,n]},t.finalizeTree=function(){this.autoComplete()},t.autoComplete=function(){var t,e,n,i,s,a,r,o,l,c,d,h,u,p,m,f,b,x,C;if(this.controller||this.getController(),t=this.fullWord(),e=t[0],n=t[1],i=[],s=new RegExp("^"+e+".*$","i"),this.parent.unit||this.parent.parent&&this.parent.parent.unit){if(1==e.length&&(s=new RegExp("^"+e+"$","")),e.length>0){for(prefix_to_ignore=["micro","yocto","zepto","atto","femto","pico","nano","milli","centi","deci","deca","hecto","kilo","mega","giga","tera","peta","exa","zetta","yotta"],skip_this=!1,a=function(t){return t[0].toUpperCase()+t.slice(1)},r=0;r<prefix_to_ignore.length;r++)if(prefix_to_ignore[r].match(s)){skip_this=!0;break}if(!skip_this){for(o=this.controller.API.__options.unitList||{names:[],symbols:[]},l={},r=0;r<o.symbols.length;r++)o.symbols[r].match(s)&&(i.push("<li data-word='"+o.symbols[r]+"'><span class='mq-operator-name'>"+o.symbols[r]+" ("+a(o.symbol_to_name[o.symbols[r]])+")</span></li>"),l[o.symbols[r]]=!0);for(r=0;r<o.names.length;r++)o.names[r].match(s)&&!l[o.name_to_symbol[o.names[r]]]&&i.push("<li data-word='"+o.name_to_symbol[o.names[r]]+"'><span class='mq-operator-name'>"+o.name_to_symbol[o.names[r]]+" ("+a(o.names[r])+")</span></li>")}}}else if(e.length>0){if(c=function(t,e){var n,i=Object.keys(e.controller.API.__options.autoCommands);for(n=0;n<i.length;n++){if(t===i[n]){t=LatexCmds[i[n]](i[n]).htmlTemplate;break}t=t.replace(new RegExp("^"+i[n]+"_",""),LatexCmds[i[n]](i[n]).htmlTemplate+"_")}return t=t.indexOf("_")>-1?t.replace("_","<sub>")+"</sub>":t,t.indexOf(".")>-1&&(t=t.replace(".","")+".<span class='mq-inline-box'></span>"),t},d=[],h=[],u="",this.parent&&this.parent.parent instanceof FunctionCommand&&this.parent===this.parent.parent.ends[R])d=this.parent.parent.getObject().propertyList,h=this.parent.parent.getObject().methodList,u=this.parent.parent.objectName()+".";else{if(e.length<3)return;d=this.controller.API.__options.autocomplete||[],h=this.controller.API.__options.staticAutocomplete||[]}for(r=0;r<d.length;r++)d[r].match(s)&&i.push("<li data-word='"+d[r]+"'><span class='mq-nonSymbola'><i>"+u+c(d[r],this)+"</i></span></li>");for(r=0;r<h.length;r++)h[r].match(s)&&i.push("<li data-word='"+h[r]+"('><span class='mq-nonSymbola'><i>"+u+"</i></span><span class='mq-operator-name'>"+(h[r].indexOf("_")>-1?h[r].replace("_","<sub>")+"</sub>":h[r])+"(<span class='mq-inline-box'></span>)</span></li>")}i.length>0?(i[0]=i[0].replace("<li",'<li class="mq-popup-selected"'),p=this.parent&&this.parent.parent instanceof FunctionCommand&&this.parent===this.parent.parent.ends[R]?this.parent.parent.jQ:n[0].jQ,m=n[n.length-1].jQ,f=p.position(),b=m.position(),x=this,C=function(){var t,e=$(this).attr("data-word"),n=x.fullWord()[1],i=n[0][L],s=n[0].parent;for(t=0;t<n.length;t++)n[t].remove();i?x.controller.cursor.insRightOf(i):x.controller.cursor.insAtRightEnd(s),x.controller.API.typedText(e),"."===e[e.length-1]&&FunctionCommand(!0).createLeftOf(x.controller.cursor),x.controller.closePopup(),"("!==e[e.length-1]&&"."!==e[e.length-1]&&x.controller.cursor.parent&&x.controller.cursor.parent.parent instanceof SupSub&&"sub"===x.controller.cursor.parent.parent.supsub&&x.controller.cursor.insRightOf(x.controller.cursor.parent.parent),x.controller.cursor.workingGroupChange()},this.controller.createPopup("<ul>"+i.join("\n")+"</ul>",b.top+m.height(),f.left,C)):this.controller.closePopup()}}),Options.p.autoCommands={_maxLength:0},optionProcessors.autoCommands=function(t){var e,n,i,s,a;if(!/^[a-z]+(?: [a-z]+)*$/i.test(t))throw'"'+t+'" not a space-delimited list of only letters';for(e=t.split(" "),n={},i=0,s=0;s<e.length;s+=1){if(a=e[s],a.length<2)throw'autocommand "'+a+'" not minimum length of 2';if(LatexCmds[a]===OperatorName)throw'"'+a+'" is a built-in operator name';n[a]=1,i=max(i,a.length)}return n},Letter=P(Variable,function(t,e){t.init=function(t){return e.init.call(this,this.letter=t)},t.autoOperator=function(t){for(var e=t.options.autoCommands,n=t[L].letter,i=t[L][L],s=1;i instanceof Letter;)n=i.letter+n,i=i[L],s+=1;if(n.length>1&&e.hasOwnProperty(n)){for(s=1,i=t[L];s<n.length;s+=1,i=i[L]);return Fragment(i,t[L]).remove(),t[L]=i[L],LatexCmds[n](n).createLeftOf(t),!0}return!1},t.createLeftOf=function(t){"u"!=this.ctrlSeq||!(t.parent.unit||t.parent.parent&&t.parent.parent.unit)||t[L]instanceof Variable||t[L]&&"µ"==t[L].ctrlSeq?t[L]&&t[L][L]&&"."===t[L].ctrlSeq&&t[L][L]instanceof Variable?FunctionCommand(this.ctrlSeq).createLeftOf(t):e.createLeftOf.apply(this,arguments):Letter("µ").createLeftOf(t)}}),BuiltInOpNames={},function(){var t,e,n,i=Options.p.autoOperatorNames={_maxLength:9},s="arg deg det dim exp gcd hom inf ker lg lim ln log max min sup limsup liminf injlim projlim Pr".split(" ");for(t=0;t<s.length;t+=1)BuiltInOpNames[s[t]]=i[s[t]]=1;for(e="sin cos tan arcsin arccos arctan sinh cosh tanh sec csc cot coth".split(" "),t=0;t<e.length;t+=1)BuiltInOpNames[e[t]]=1;for(n="sin cos tan sec cosec csc cotan cot ctg".split(" "),t=0;t<n.length;t+=1)i[n[t]]=i["arc"+n[t]]=i[n[t]+"h"]=i["ar"+n[t]+"h"]=i["arc"+n[t]+"h"]=1}(),optionProcessors.autoOperatorNames=function(t){var e,n,i,s,a;if(!/^[a-z]+(?: [a-z]+)*$/i.test(t))throw'"'+t+'" not a space-delimited list of only letters';for(e=t.split(" "),n={},i=0,s=0;s<e.length;s+=1){if(a=e[s],a.length<2)throw'"'+a+'" not minimum length of 2';n[a]=1,i=max(i,a.length)}return n._maxLength=i,n},optionProcessors.unitList=function(t){var e,n,i,s={},a={},r=[],o=[],l={micro:"µ",yocto:"y",zepto:"z",atto:"a",femto:"f",pico:"p",nano:"n",milli:"m",centi:"c",deci:"d",deca:"D",hecto:"h",kilo:"k",mega:"M",giga:"G",tera:"T",peta:"P",exa:"E",zetta:"Z",yotta:"Y"};for(e=0;e<t.length;e++)if(r.push(t[e].name),o.push(t[e].symbol),s[t[e].name]=t[e].symbol,a[t[e].symbol]=t[e].name,t[e].prefix)for(n in l)r.push(n+t[e].name),o.push(l[n]+t[e].symbol),s[n+t[e].name]=l[n]+t[e].symbol,a[l[n]+t[e].symbol]=n+t[e].name;return i=function(t,e){return t.toLowerCase().localeCompare(e.toLowerCase())},{name_to_symbol:s,symbol_to_name:a,names:r.sort(i),symbols:o.sort(i)}},LatexCmds.µ=P(VanillaSymbol,function(t,e){t.init=function(){e.init.call(this,"µ")},t.createLeftOf=function(t){t.parent.unit||t.parent.parent&&t.parent.parent.unit?Letter("µ").createLeftOf(t):e.createLeftOf.call(this,t)}}),LatexCmds[2]=P(VanillaSymbol,function(t,e){t.init=function(){e.init.call(this,"2")},t.createLeftOf=function(t){t.parent&&t.parent.parent&&t.parent.parent instanceof Unit||t.parent&&t.parent.parent&&t.parent.parent.unit&&!(t.parent.parent instanceof SupSub)?t[L]&&"H"===t[L].ctrlSeq?Letter("2").createLeftOf(t):t.parent.flash():e.createLeftOf.call(this,t)}}),LatexCmds.f=P(Letter,function(t,e){t.init=function(){Symbol.p.init.call(this,this.letter="f",'<var class="mq-florin">ƒ</var>')},t.createLeftOf=function(t){t.parent&&t.parent.parent instanceof OperatorName&&t.parent===t.parent.parent.blocks[0]?Letter("f").createLeftOf(t):t.parent&&t.parent.parent&&t.parent.parent instanceof SupSub&&"sub"===t.parent.parent.supsub&&t.parent.parent.parent&&t.parent.parent.parent.parent instanceof OperatorName&&t.parent.parent.parent===t.parent.parent.parent.parent.blocks[0]?Letter("f").createLeftOf(t):t.parent.unit||t.parent.parent&&t.parent.parent.unit?Letter("f").createLeftOf(t):e.createLeftOf.call(this,t)}}),LatexCmds[" "]=LatexCmds.space=bind(VanillaSymbol,"\\ "," "),LatexCmds.backslash=bind(VanillaSymbol,"\\backslash ","\\"),CharCmds["\\"]||(CharCmds["\\"]=LatexCmds.backslash),NonSymbolaSymbol=P(Variable,function(t,e){t.init=function(t,n){e.init.call(this,t,'<span class="mq-nonSymbola">'+(n||t)+"</span>")}}),LatexCmds["@"]=NonSymbolaSymbol,LatexCmds["&"]=bind(NonSymbolaSymbol,"\\&","&"),LatexCmds["%"]=bind(NonSymbolaSymbol,"\\%","%"),LatexCmds.alpha=LatexCmds.beta=LatexCmds.gamma=LatexCmds.delta=LatexCmds.zeta=LatexCmds.eta=LatexCmds.theta=LatexCmds.iota=LatexCmds.kappa=LatexCmds.mu=LatexCmds.nu=LatexCmds.xi=LatexCmds.rho=LatexCmds.sigma=LatexCmds.tau=LatexCmds.chi=LatexCmds.psi=LatexCmds.omega=P(Variable,function(t,e){t.init=function(t){e.init.call(this,"\\"+t+" ","&"+t+";")}}),LatexCmds.phi=bind(Variable,"\\phi ","ϕ"),LatexCmds.phiv=LatexCmds.varphi=bind(Variable,"\\varphi ","φ"),LatexCmds.epsilon=bind(Variable,"\\epsilon ","ϵ"),LatexCmds.epsiv=LatexCmds.varepsilon=bind(Variable,"\\varepsilon ","ε"),LatexCmds.piv=LatexCmds.varpi=bind(Variable,"\\varpi ","ϖ"),LatexCmds.sigmaf=LatexCmds.sigmav=LatexCmds.varsigma=bind(Variable,"\\varsigma ","ς"),LatexCmds.thetav=LatexCmds.vartheta=LatexCmds.thetasym=bind(Variable,"\\vartheta ","ϑ"),LatexCmds.upsilon=LatexCmds.upsi=bind(Variable,"\\upsilon ","υ"),LatexCmds.gammad=LatexCmds.Gammad=LatexCmds.digamma=bind(Variable,"\\digamma ","ϝ"),LatexCmds.kappav=LatexCmds.varkappa=bind(Variable,"\\varkappa ","ϰ"),LatexCmds.rhov=LatexCmds.varrho=bind(Variable,"\\varrho ","ϱ"),LatexCmds.pi=LatexCmds["π"]=bind(NonSymbolaSymbol,"\\pi ","π"),LatexCmds.lambda=bind(NonSymbolaSymbol,"\\lambda ","λ"),LatexCmds.Upsilon=LatexCmds.Upsi=LatexCmds.upsih=LatexCmds.Upsih=bind(Symbol,"\\Upsilon ",'<var style="font-family: serif">ϒ</var>'),LatexCmds.Gamma=LatexCmds.Delta=LatexCmds.Theta=LatexCmds.Lambda=LatexCmds.Xi=LatexCmds.Pi=LatexCmds.Sigma=LatexCmds.Phi=LatexCmds.Psi=LatexCmds.Omega=LatexCmds.forall=P(VanillaSymbol,function(t,e){t.init=function(t){e.init.call(this,"\\"+t+" ","&"+t+";")}}),LatexFragment=P(MathCommand,function(t){t.init=function(t){this.latex=t},t.createLeftOf=function(t){var e=latexMathParser.parse(this.latex);e.children().adopt(t.parent,t[L],t[R]),t[L]=e.ends[R],e.jQize().insertBefore(t.jQ),e.finalizeInsert(t.options,t),e.ends[R][R].siblingCreated&&e.ends[R][R].siblingCreated(t.options,L),e.ends[L][L].siblingCreated&&e.ends[L][L].siblingCreated(t.options,R),t.parent.bubble("reflow")
|
4
|
-
},t.parser=function(){var t=latexMathParser.parse(this.latex).children();return Parser.succeed(t)}}),LatexCmds["¹"]=bind(LatexFragment,"^1"),LatexCmds["²"]=bind(LatexFragment,"^2"),LatexCmds["³"]=bind(LatexFragment,"^3"),LatexCmds["¼"]=bind(LatexFragment,"\\frac14"),LatexCmds["½"]=bind(LatexFragment,"\\frac12"),LatexCmds["¾"]=bind(LatexFragment,"\\frac34"),PlusMinus=P(BinaryOperator,function(t){t.init=VanillaSymbol.prototype.init,t.contactWeld=t.siblingCreated=t.siblingDeleted=function(t,e){return e!==R?(this.jQ[0].className=!this[L]||this[L]instanceof BinaryOperator?"":"mq-binary-operator",this):void 0}}),Multiplication=P(BinaryOperator,function(t){t.addedImplicitly=!1,t.finalizeTree=function(){var t,e;if(this[L]&&"."===this[L].ctrlSeq){for(t=[this[L]],this[L][L]&&this[L][L][L]&&"0"===this[L][L].ctrlSeq&&"\\cdot "===this[L][L][L].ctrlSeq&&(t.push(this[L][L]),t.push(this[L][L][L])),e=0;e<t.length;e++)t[e].remove();this.jQ.html("⊙"),this.jQ.addClass("mq-multiply-elementWise"),this.ctrlSeq="."+this.ctrlSeq,this.textTemplate="."+this.textTemplate}},t.implicit=function(){return this.addedImplicitly=!0,this}}),LatexCmds["+"]=bind(PlusMinus,"+","+"),LatexCmds["–"]=LatexCmds["-"]=bind(PlusMinus,"-","−"),LatexCmds["±"]=LatexCmds.pm=LatexCmds.plusmn=LatexCmds.plusminus=bind(PlusMinus,"\\pm ","±"),LatexCmds.mp=LatexCmds.mnplus=LatexCmds.minusplus=bind(PlusMinus,"\\mp ","∓"),CharCmds["*"]=LatexCmds.sdot=LatexCmds.cdot=bind(Multiplication,"\\cdot ","·","*"),Inequality=P(BinaryOperator,function(t,e){t.init=function(t,n){this.data=t,this.strict=n;var i=n?"Strict":"";e.init.call(this,t["ctrlSeq"+i],t["html"+i],t["text"+i])},t.swap=function(t){this.strict=t;var e=t?"Strict":"";this.ctrlSeq=this.data["ctrlSeq"+e],this.jQ.html(this.data["html"+e]),this.textTemplate=[this.data["text"+e]]},t.deleteTowards=function(t){return t!==L||this.strict?void e.deleteTowards.apply(this,arguments):void this.swap(!0)}}),less={ctrlSeq:"\\le ",html:"≤",text:" <= ",ctrlSeqStrict:"<",htmlStrict:"<",textStrict:" < "},greater={ctrlSeq:"\\ge ",html:"≥",text:" >= ",ctrlSeqStrict:">",htmlStrict:">",textStrict:" > "},factorial={ctrlSeq:"\\ne ",html:"≠",text:" != ",ctrlSeqStrict:"!",htmlStrict:"!",textStrict:"!"},LatexCmds["<"]=LatexCmds.lt=bind(Inequality,less,!0),LatexCmds[">"]=LatexCmds.gt=bind(Inequality,greater,!0),LatexCmds["≤"]=LatexCmds.le=LatexCmds.leq=bind(Inequality,less,!1),LatexCmds["≥"]=LatexCmds.ge=LatexCmds.geq=bind(Inequality,greater,!1),LatexCmds["!"]=bind(Inequality,factorial,!0),LatexCmds["≠"]=LatexCmds.ne=LatexCmds.neq=bind(Inequality,factorial,!1),Equality=P(Inequality,function(t,e){t.init=function(t,n){e.init.call(this,t,n)},t.createLeftOf=function(t){return(t[L]instanceof Inequality||t[L]instanceof Equality)&&t[L].strict?void t[L].swap(!1):void e.createLeftOf.apply(this,arguments)}}),equal={ctrlSeq:"\\eq ",html:"==",text:" == ",ctrlSeqStrict:"=",htmlStrict:"=",textStrict:" := "},LatexCmds["="]=bind(Equality,equal,!0),LatexCmds.eq=bind(Equality,equal,!1),LatexCmds.times=bind(BinaryOperator,"\\times ","×","[x]"),LatexCmds["÷"]=LatexCmds.div=LatexCmds.divide=LatexCmds.divides=bind(BinaryOperator,"\\div ","÷","[/]"),forceIERedraw=noop,div=document.createElement("div"),div_style=div.style,transformPropNames={transform:1,WebkitTransform:1,MozTransform:1,OTransform:1,msTransform:1};for(prop in transformPropNames)if(prop in div_style){transformPropName=prop;break}transformPropName?scale=function(t,e,n){t.css(transformPropName,"scale("+e+","+n+")")}:"filter"in div_style?(forceIERedraw=function(t){t.className=t.className},scale=function(t,e,n){function i(){t.css("marginRight",(s.width()-1)*(e-1)/e+"px")}var s,a;e/=1+(n-1)/2,t.css("fontSize",n+"em"),t.hasClass("mq-matrixed-container")||t.addClass("mq-matrixed-container").wrapInner('<span class="mq-matrixed"></span>'),s=t.children().css("filter","progid:DXImageTransform.Microsoft.Matrix(M11="+e+",SizingMethod='auto expand')"),i(),a=setInterval(i),$(window).load(function(){clearTimeout(a),i()})}):scale=function(t,e,n){t.css("fontSize",n+"em")},Style=P(MathCommand,function(t,e){t.init=function(t,n,i){e.init.call(this,t,"<"+n+" "+i+">&0</"+n+">")}}),LatexCmds.mathrm=bind(Style,"\\mathrm","span",'class="mq-roman mq-font"'),LatexCmds.mathit=bind(Style,"\\mathit","i",'class="mq-font"'),LatexCmds.mathbf=bind(Style,"\\mathbf","b",'class="mq-font"'),LatexCmds.mathsf=bind(Style,"\\mathsf","span",'class="mq-sans-serif mq-font"'),LatexCmds.mathtt=bind(Style,"\\mathtt","span",'class="mq-monospace mq-font"'),LatexCmds.underline=bind(Style,"\\underline","span",'class="mq-non-leaf mq-underline"'),LatexCmds.overline=LatexCmds.bar=bind(Style,"\\overline","span",'class="mq-non-leaf mq-overline"'),TextColor=LatexCmds.textcolor=P(MathCommand,function(t,e){t.setColor=function(t){this.color=t,this.htmlTemplate='<span class="mq-textcolor" style="color:'+t+'">&0</span>'},t.latex=function(){return"\\textcolor{"+this.color+"}{"+this.blocks[0].latex()+"}"},t.parser=function(){var t=this,n=Parser.optWhitespace,i=Parser.string,s=Parser.regex;return n.then(i("{")).then(s(/^[#\w\s.,()%-]*/)).skip(i("}")).then(function(n){return t.setColor(n),e.parser.call(t)})}}),Class=LatexCmds["class"]=P(MathCommand,function(t,e){t.parser=function(){var t=this,n=Parser.string,i=Parser.regex;return Parser.optWhitespace.then(n("{")).then(i(/^[-\w\s\\\xA0-\xFF]*/)).skip(n("}")).then(function(n){return t.htmlTemplate='<span class="mq-class '+n+'">&0</span>',e.parser.call(t)})}}),Vec=LatexCmds.vec=P(MathCommand,function(t){t.ctrlSeq="\\vec",t.htmlTemplate='<span class="mq-non-leaf"><span class="mq-vector-prefix">→</span><span class="mq-vector-stem">&0</span></span>',t.textTemplate=["vec(",")"]}),InnerMathField=P(MathQuill.MathField,function(t){t.init=function(t,e){RootBlockMixin(t),this.__options=Options();var n=Controller(this,t,e);n.editable=!0,n.createTextarea(),n.editablesTextareaEvents(),n.cursor.insAtRightEnd(t)}}),LatexCmds.MathQuillMathField=P(MathCommand,function(t,e){t.ctrlSeq="\\MathQuillMathField",t.htmlTemplate='<span class="mq-editable-field"><span class="mq-root-block">&0</span></span>',t.parser=function(){var t=this,n=Parser.string,i=Parser.regex,s=Parser.succeed;return n("[").then(i(/^[a-z][a-z0-9]*/i)).skip(n("]")).map(function(e){t.name=e}).or(s()).then(e.parser.call(t))},t.finalizeTree=function(){InnerMathField(this.ends[L],this.jQ)},t.registerInnerField=function(t){t.push(t[this.name]=this.ends[L].controller.API)},t.latex=function(){return this.ends[L].latex()},t.text=function(t){return this.ends[L].text(t)}}),Unit=LatexCmds.Unit=CharCmds["'"]=P(DerivedMathCommand,function(t,e){t.ctrlSeq="Unit{...}{...}",t.replaces=function(t){t.disown(),this._replacedFragment=t},t.htmlTemplate='<span><span>&0</span><span class="mq-unit mq-non-leaf">&1</span></span>',t.finalizeTree=function(){this.ends[R].focus=function(){return this.jQ.addClass("mq-active"),this.isEmpty()&&this.jQ.removeClass("mq-empty"),this},this.ends[R].blur=function(){return this.jQ.removeClass("mq-active").removeClass("mq-hasCursor"),this.isEmpty()&&this.jQ.addClass("mq-empty"),this},this.ends[R].write=function(t,e,n){return cmd=e.match(/^[a-z]$/i)?Letter(e):(cmd=CharCmds[e]||LatexCmds[e])?cmd(e):VanillaSymbol(e),e.match(/^[a-z\u00b52\^\*\/\(\)]$/i)?(n&&cmd.replaces(n),void cmd.createLeftOf(t)):(n&&n.remove(),void this.flash())},this.ends[R].unit=this.ends[R],this.ends[R].eachChild(function(t){if(t.recursiveSetUnit&&t.recursiveSetUnit(),t instanceof VanillaSymbol&&("µ"==t.ctrlSeq||"2"==t.ctrlSeq)){var e=Letter(t.ctrlSeq);e.jQize(),e.jQ.insDirOf(R,t.jQ),t[R]=e.adopt(t.parent,t,t[R]),t.remove()}}),this.ends[R].deleteOutOf=function(t,e){for(var n=this.ends[L];0!==n;n=n[R])n.remove();e.insAtRightEnd(this),e.unwrapGramp()},this.ends[L].deleteOutOf=function(t,e){for(var n=this.parent.ends[R].ends[L];0!==n;n=n[R])n.remove();e.insAtRightEnd(this),e.unwrapGramp()}},t.createLeftOf=function(t){var n,i,s,a,r;if(this._replacedFragment){for(n=!0,i=this._replacedFragment.ends[L];0!==i;i=i[R])if(!(i instanceof VanillaSymbol&&i.ctrlSeq.match(/[0-9\.]/))){n=!1;break}this._replacedFragment.ends[L]===this._replacedFragment.ends[R]&&this._replacedFragment.ends[L]instanceof ScientificNotation&&(n=!0),n?(e.createLeftOf.call(this,t),this._replacedFragment.adopt(this.ends[L],0,0),this._replacedFragment.jQ.appendTo(this.ends[L].jQ)):(s=CharCmds["("](),s.replaces(this._replacedFragment),s.createLeftOf(t),s.reflow(),t.insRightOf(s),LatexCmds.cdot().createLeftOf(t),e.createLeftOf.call(this,t),t.insAtRightEnd(this.ends[L]),VanillaSymbol("1").createLeftOf(t))}else{for(a=[],t[L]instanceof ScientificNotation&&a.push(t[L]),i=t[L];0!==i&&(i instanceof VanillaSymbol&&i.ctrlSeq.match(/[0-9\.]/));i=i[L])a.push(i);for(0===a.length&&(t[L]instanceof BinaryOperator||0===t[L]?VanillaSymbol("1").createLeftOf(t):(LatexCmds.cdot().createLeftOf(t),VanillaSymbol("1").createLeftOf(t)),a.push(t[L])),e.createLeftOf.call(this,t),r=0;r<a.length;r++)a[r].disown(),a[r].adopt(this.ends[L],0,this.ends[L].ends[L]),a[r].jQ.prependTo(this.ends[L].jQ)}t.insAtRightEnd(this.ends[R]),t.workingGroupChange()},t.latex=function(){return"\\Unit{"+this.blocks[0].latex()+"}{"+this.blocks[1].latex()+"}"},t.text=function(t){return this.blocks[0].text(t)+"*("+this.blocks[1].text(jQuery.extend({unit:!0},t))+")"}})}();
|
1
|
+
!function(){function noop(){}function variadic(t){var e=t.length-1;return function(){var n=__slice.call(arguments,0,e),i=__slice.call(arguments,e);return t.apply(this,n.concat([i]))}}function iterator(t){return variadic(function(e,n){"function"!=typeof e&&(e=send(e));var i=function(t){return e.apply(t,[t].concat(n))};return t.call(this,i)})}function bind(t){var e=__slice.call(arguments,1);return function(){return t.apply(this,e)}}function pray(t,e){if(!e)throw new Error("prayer failed: "+t)}function prayDirection(t){pray("a direction was passed",t===L||t===R)}function prayWellFormed(t,e,n){pray("a parent is always present",t),pray("leftward is properly set up",function(){return e?e[R]===n&&e.parent===t:t.ends[L]===n}()),pray("rightward is properly set up",function(){return n?n[L]===e&&n.parent===t:t.ends[R]===e}())}function MathQuill(t){if(!t||!t.nodeType)return null;var e=$(t).children(".mq-root-block").attr(mqBlockId);return e?Node.byId[e].controller.API:null}function APIFnFor(t){function e(e,n){var i=MathQuill(e);return i instanceof t||!e||!e.nodeType?i:t($(e),n)}return e.prototype=t.prototype,e}function RootBlockMixin(t){var e,n="moveOutOf deleteOutOf selectOutOf upOutOf downOutOf reflow".split(" ");for(e=0;e<n.length;e+=1)(function(e){t[e]=function(t){this.controller.handle(e,t)}})(n[e])}function DelimsMixin(t,e){t.jQadd=function(){e.jQadd.apply(this,arguments),this.delimjQs=this.jQ.children(":first").add(this.jQ.children(":last")),this.contentjQ=this.jQ.children(":eq(1)")},t.reflow=function(){var t=this.contentjQ.outerHeight()/parseInt(this.contentjQ.css("fontSize"),10);scale(this.delimjQs,min(1+.2*(t-1),1.2),1.05*t)}}function bindCharBracketPair(t,e){var e=e||t,n=OPP_BRACKS[t],i=OPP_BRACKS[e];CharCmds[t]=bind(Bracket,L,t,n,e,i,e,i),CharCmds[n]=bind(Bracket,R,t,n,e,i,e,i)}function insLeftOfMeUnlessAtEnd(t){var e=this.parent,n=t;do{if(n[R])return t.insLeftOf(e);n=n.parent.parent}while(n!==e);t.insRightOf(e)}var undefined,P,L,R,$,Point,Node,Fragment,LatexCmds,CharCmds,Cursor,Selection,Controller,origMathQuill,Options,optionProcessors,AbstractMathQuill,EditableField,Parser,latexMathParser,MathElement,MathCommand,DerivedMathCommand,Symbol,VanillaSymbol,BinaryOperator,MathBlock,RootMathBlock,Bracket,OPP_BRACKS,Binomial,Currency,Derivative,Fraction,LiveFraction,Choose,FunctionCommand,Integral,IntegralNoLimit,LatexCommandInput,Limit,Matrix,MatrixMathBlock,OperatorName,fn,SquareRoot,NthRoot,ScientificNotation,SummationNotation,SummationNotationNoLimits,SupSub,Variable,Letter,BuiltInOpNames,NonSymbolaSymbol,LatexFragment,PlusMinus,Multiplication,Inequality,less,greater,factorial,Equality,equal,scale,forceIERedraw,div,div_style,transformPropNames,transformPropName,prop,Style,TextColor,Class,Vec,InnerMathField,Unit,jQuery=window.jQuery,mqCmdId="mathquill-command-id",mqBlockId="mathquill-block-id",min=Math.min,max=Math.max,__slice=[].slice,send=variadic(function(t,e){return variadic(function(n,i){return t in n?n[t].apply(n,e.concat(i)):void 0})});!function(t,e){function n(t,e,n){var i=d[e.type]||{};return null==t?n||!e.def?null:e.def:(t=i.floor?~~t:parseFloat(t),isNaN(t)?e.def:i.mod?(t+i.mod)%i.mod:0>t?0:i.max<t?i.max:t)}function i(e){var n=c(),i=n._rgba=[];return e=e.toLowerCase(),m(l,function(t,s){var r,a=s.re.exec(e),o=a&&s.parse(a),l=s.space||"rgba";return o?(r=n[l](o),n[h[l].cache]=r[h[l].cache],i=n._rgba=r._rgba,!1):void 0}),i.length?("0,0,0,0"===i.join()&&t.extend(i,r.transparent),n):r[e]}function s(t,e,n){return n=(n+1)%1,1>6*n?t+(e-t)*n*6:1>2*n?e:2>3*n?t+(e-t)*(2/3-n)*6:t}var r,a="backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",o=/^([\-+])=\s*(\d+\.?\d*)/,l=[{re:/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,parse:function(t){return[t[1],t[2],t[3],t[4]]}},{re:/rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,parse:function(t){return[2.55*t[1],2.55*t[2],2.55*t[3],t[4]]}},{re:/#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,parse:function(t){return[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16)]}},{re:/#([a-f0-9])([a-f0-9])([a-f0-9])/,parse:function(t){return[parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16),parseInt(t[3]+t[3],16)]}},{re:/hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,space:"hsla",parse:function(t){return[t[1],t[2]/100,t[3]/100,t[4]]}}],c=t.Color=function(e,n,i,s){return new t.Color.fn.parse(e,n,i,s)},h={rgba:{props:{red:{idx:0,type:"byte"},green:{idx:1,type:"byte"},blue:{idx:2,type:"byte"}}},hsla:{props:{hue:{idx:0,type:"degrees"},saturation:{idx:1,type:"percent"},lightness:{idx:2,type:"percent"}}}},d={"byte":{floor:!0,max:255},percent:{max:1},degrees:{mod:360,floor:!0}},u=c.support={},p=t("<p>")[0],m=t.each;p.style.cssText="background-color:rgba(1,1,1,.5)",u.rgba=p.style.backgroundColor.indexOf("rgba")>-1,m(h,function(t,e){e.cache="_"+t,e.props.alpha={idx:3,type:"percent",def:1}}),c.fn=t.extend(c.prototype,{parse:function(s,a,o,l){if(s===e)return this._rgba=[null,null,null,null],this;(s.jquery||s.nodeType)&&(s=t(s).css(a),a=e);var d=this,u=t.type(s),p=this._rgba=[];return a!==e&&(s=[s,a,o,l],u="array"),"string"===u?this.parse(i(s)||r._default):"array"===u?(m(h.rgba.props,function(t,e){p[e.idx]=n(s[e.idx],e)}),this):"object"===u?(s instanceof c?m(h,function(t,e){s[e.cache]&&(d[e.cache]=s[e.cache].slice())}):m(h,function(e,i){var r=i.cache;m(i.props,function(t,e){if(!d[r]&&i.to){if("alpha"===t||null==s[t])return;d[r]=i.to(d._rgba)}d[r][e.idx]=n(s[t],e,!0)}),d[r]&&t.inArray(null,d[r].slice(0,3))<0&&(d[r][3]=1,i.from&&(d._rgba=i.from(d[r])))}),this):void 0},is:function(t){var e=c(t),n=!0,i=this;return m(h,function(t,s){var r,a=e[s.cache];return a&&(r=i[s.cache]||s.to&&s.to(i._rgba)||[],m(s.props,function(t,e){return null!=a[e.idx]?n=a[e.idx]===r[e.idx]:void 0})),n}),n},_space:function(){var t=[],e=this;return m(h,function(n,i){e[i.cache]&&t.push(n)}),t.pop()},transition:function(t,e){var i=c(t),s=i._space(),r=h[s],a=0===this.alpha()?c("transparent"):this,o=a[r.cache]||r.to(a._rgba),l=o.slice();return i=i[r.cache],m(r.props,function(t,s){var r=s.idx,a=o[r],c=i[r],h=d[s.type]||{};null!==c&&(null===a?l[r]=c:(h.mod&&(c-a>h.mod/2?a+=h.mod:a-c>h.mod/2&&(a-=h.mod)),l[r]=n((c-a)*e+a,s)))}),this[s](l)},blend:function(e){if(1===this._rgba[3])return this;var n=this._rgba.slice(),i=n.pop(),s=c(e)._rgba;return c(t.map(n,function(t,e){return(1-i)*s[e]+i*t}))},toRgbaString:function(){var e="rgba(",n=t.map(this._rgba,function(t,e){return null==t?e>2?1:0:t});return 1===n[3]&&(n.pop(),e="rgb("),e+n.join()+")"},toHslaString:function(){var e="hsla(",n=t.map(this.hsla(),function(t,e){return null==t&&(t=e>2?1:0),e&&3>e&&(t=Math.round(100*t)+"%"),t});return 1===n[3]&&(n.pop(),e="hsl("),e+n.join()+")"},toHexString:function(e){var n=this._rgba.slice(),i=n.pop();return e&&n.push(~~(255*i)),"#"+t.map(n,function(t){return t=(t||0).toString(16),1===t.length?"0"+t:t}).join("")},toString:function(){return 0===this._rgba[3]?"transparent":this.toRgbaString()}}),c.fn.parse.prototype=c.fn,h.hsla.to=function(t){if(null==t[0]||null==t[1]||null==t[2])return[null,null,null,t[3]];var e,n,i=t[0]/255,s=t[1]/255,r=t[2]/255,a=t[3],o=Math.max(i,s,r),l=Math.min(i,s,r),c=o-l,h=o+l,d=.5*h;return e=l===o?0:i===o?60*(s-r)/c+360:s===o?60*(r-i)/c+120:60*(i-s)/c+240,n=0===c?0:.5>=d?c/h:c/(2-h),[Math.round(e)%360,n,d,null==a?1:a]},h.hsla.from=function(t){if(null==t[0]||null==t[1]||null==t[2])return[null,null,null,t[3]];var e=t[0]/360,n=t[1],i=t[2],r=t[3],a=.5>=i?i*(1+n):i+n-i*n,o=2*i-a;return[Math.round(255*s(o,a,e+1/3)),Math.round(255*s(o,a,e)),Math.round(255*s(o,a,e-1/3)),r]},m(h,function(i,s){var r=s.props,a=s.cache,l=s.to,h=s.from;c.fn[i]=function(i){if(l&&!this[a]&&(this[a]=l(this._rgba)),i===e)return this[a].slice();var s,o=t.type(i),d="array"===o||"object"===o?i:arguments,u=this[a].slice();return m(r,function(t,e){var i=d["object"===o?t:e.idx];null==i&&(i=u[e.idx]),u[e.idx]=n(i,e)}),h?(s=c(h(u)),s[a]=u,s):c(u)},m(r,function(e,n){c.fn[e]||(c.fn[e]=function(s){var r,a=t.type(s),l="alpha"===e?this._hsla?"hsla":"rgba":i,c=this[l](),h=c[n.idx];return"undefined"===a?h:("function"===a&&(s=s.call(this,h),a=t.type(s)),null==s&&n.empty?this:("string"===a&&(r=o.exec(s),r&&(s=h+parseFloat(r[2])*("+"===r[1]?1:-1))),c[n.idx]=s,this[l](c)))})})}),c.hook=function(e){var n=e.split(" ");m(n,function(e,n){t.cssHooks[n]={set:function(e,s){var r,a,o="";if("transparent"!==s&&("string"!==t.type(s)||(r=i(s)))){if(s=c(r||s),!u.rgba&&1!==s._rgba[3]){for(a="backgroundColor"===n?e.parentNode:e;(""===o||"transparent"===o)&&a&&a.style;)try{o=t.css(a,"backgroundColor"),a=a.parentNode}catch(l){}s=s.blend(o&&"transparent"!==o?o:"_default")}s=s.toRgbaString()}try{e.style[n]=s}catch(l){}}},t.fx.step[n]=function(e){e.colorInit||(e.start=c(e.elem,n),e.end=c(e.end),e.colorInit=!0),t.cssHooks[n].set(e.elem,e.start.transition(e.end,e.pos))}})},c.hook(a),t.cssHooks.borderColor={expand:function(t){var e={};return m(["Top","Right","Bottom","Left"],function(n,i){e["border"+i+"Color"]=t}),e}},r=t.Color.names={aqua:"#00ffff",black:"#000000",blue:"#0000ff",fuchsia:"#ff00ff",gray:"#808080",green:"#008000",lime:"#00ff00",maroon:"#800000",navy:"#000080",olive:"#808000",purple:"#800080",red:"#ff0000",silver:"#c0c0c0",teal:"#008080",white:"#ffffff",yellow:"#ffff00",transparent:[null,null,null,0],_default:"#ffffff"}}(jQuery),P=function(t,e,n){function i(t){return"object"==typeof t}function s(t){return"function"==typeof t}function r(){}return function a(o,l){function c(){var t=new h;return s(t.init)&&t.init.apply(t,arguments),t}function h(){}var d,u,p;return l===n&&(l=o,o=Object),c.Bare=h,d=r[t]=o[t],u=h[t]=c[t]=c.p=new r,u.constructor=c,c.mixin=function(e){return h[t]=c[t]=a(c,e)[t],c},(c.open=function(t){if(p={},s(t)?p=t.call(c,u,d,c,o):i(t)&&(p=t),i(p))for(var n in p)e.call(p,n)&&(u[n]=p[n]);return s(u.init)||(u.init=o),c})(l)}}("prototype",{}.hasOwnProperty),L=MathQuill.L=-1,R=MathQuill.R=1,$=P(jQuery,function(t){t.insDirOf=function(t,e){return t===L?this.insertBefore(e.first()):this.insertAfter(e.last())},t.insAtDirEnd=function(t,e){return t===L?this.prependTo(e):this.appendTo(e)}}),Point=P(function(t){t.parent=0,t[L]=0,t[R]=0,t.init=function(t,e,n){this.parent=t,this[L]=e,this[R]=n},this.copy=function(t){return Point(t.parent,t[L],t[R])}}),Node=P(function(t){function e(){return n+=1}t[L]=0,t[R]=0,t.parent=0;var n=0;this.byId={},t.init=function(){this.id=e(),Node.byId[this.id]=this,this.ends={},this.ends[L]=0,this.ends[R]=0},t.getController=function(){return this.controller?this.controller:(this.controller=this.parent.getController(),this.controller)},t.dispose=function(){delete Node.byId[this.id]},t.toString=function(){return"{{ MathQuill Node #"+this.id+" }}"},t.jQ=$(),t.jQadd=function(t){return this.jQ=this.jQ.add(t)},t.jQize=function(t){function e(t){var n,i;for(t.getAttribute&&(n=t.getAttribute("mathquill-command-id"),i=t.getAttribute("mathquill-block-id"),n&&Node.byId[n].jQadd(t),i&&Node.byId[i].jQadd(t)),t=t.firstChild;t;t=t.nextSibling)e(t)}var n;for(t=$(t||this.html()),n=0;n<t.length;n+=1)e(t[n]);return t},t.createDir=function(t,e){prayDirection(t);var n=this;return n.jQize(),n.jQ.insDirOf(t,e.jQ),e[t]=n.adopt(e.parent,e[L],e[R]),n},t.createLeftOf=function(t){return this.createDir(L,t)},t.selectChildren=function(t,e){return Selection(t,e)},t.bubble=iterator(function(t){var e,n;for(e=this;e&&(n=t(e),n!==!1);e=e.parent);return this}),t.postOrder=iterator(function(t){return function e(n){n.eachChild(e),t(n)}(this),this}),t.isEmpty=function(){return 0===this.ends[L]&&0===this.ends[R]},t.children=function(){return Fragment(this.ends[L],this.ends[R])},t.eachChild=function(){var t=this.children();return t.each.apply(t,arguments),this},t.foldChildren=function(t,e){return this.children().fold(t,e)},t.withDirAdopt=function(t,e,n,i){return Fragment(this,this).withDirAdopt(t,e,n,i),this},t.adopt=function(t,e,n){return Fragment(this,this).adopt(t,e,n),this},t.disown=function(){return Fragment(this,this).disown(),this},t.remove=function(){return this.jQ.remove(),this.postOrder("dispose"),this.disown()}}),Fragment=P(function(t){t.init=function(t,e,n){n===undefined&&(n=L),prayDirection(n),pray("no half-empty fragments",!t==!e),this.ends={},t&&(pray("withDir is passed to Fragment",t instanceof Node),pray("oppDir is passed to Fragment",e instanceof Node),pray("withDir and oppDir have the same parent",t.parent===e.parent),this.ends[n]=t,this.ends[-n]=e,this.jQ=this.fold(this.jQ,function(t,e){return t.add(e.jQ)}))},t.jQ=$(),t.withDirAdopt=function(t,e,n,i){return t===L?this.adopt(e,n,i):this.adopt(e,i,n)},t.adopt=function(t,e,n){var i,s,r;return prayWellFormed(t,e,n),i=this,i.disowned=!1,(s=i.ends[L])?(r=i.ends[R],e||(t.ends[L]=s),n?n[L]=r:t.ends[R]=r,i.ends[R][R]=n,i.each(function(n){n[L]=e,n.parent=t,e&&(e[R]=n),e=n}),i):this},t.disown=function(){var t,e,n=this,i=n.ends[L];return!i||n.disowned?n:(n.disowned=!0,t=n.ends[R],e=i.parent,prayWellFormed(e,i[L],i),prayWellFormed(e,t,t[R]),i[L]?i[L][R]=t[R]:e.ends[L]=t[R],t[R]?t[R][L]=i[L]:e.ends[R]=i[L],n)},t.remove=function(){return this.jQ.remove(),this.each("postOrder","dispose"),this.disown()},t.each=iterator(function(t){var e,n=this,i=n.ends[L];if(!i)return n;for(;i!==n.ends[R][R]&&(e=t(i),e!==!1);i=i[R]);return n}),t.fold=function(t,e){return this.each(function(n){t=e.call(this,t,n)}),t}}),LatexCmds={},CharCmds={},Cursor=P(Point,function(t){t.init=function(t,e,n){this.parent=t,this.controller=t.controller,this.options=e,this.container=n;var i=this.jQ=this._jQ=$('<span class="mq-cursor">​</span>');this.blink=function(){i.toggleClass("mq-blink")},this.upDownCache={}},t.show=function(){return this.jQ=this._jQ.removeClass("mq-blink"),"intervalId"in this?clearInterval(this.intervalId):(this[R]?this.jQ.insertBefore(this.selection&&this.selection.ends[L][L]===this[L]?this.selection.jQ:this[R].jQ.first()):this.jQ.appendTo(this.parent.jQ),this.parent.focus()),this.intervalId=setInterval(this.blink,500),this.workingGroupChange(!0),this},t.hide=function(){var t=this.container;return t.find(".active_block").replaceWith(function(){return $(this).contents()}),t.find(".hasCursor_highlighting").removeClass("hasCursor_highlighting"),"intervalId"in this&&clearInterval(this.intervalId),delete this.intervalId,this.jQ.detach(),this.jQ=$(),this},t.withDirInsertAt=function(t,e,n,i){e!==this.parent&&this.parent.blur&&this.parent.blur(),e.unit&&e.unit.focus(),e.parent&&e.parent.unit&&e.parent.unit.focus(),this.parent=e,this[t]=n,this[-t]=i},t.insDirOf=function(t,e){return prayDirection(t),this.withDirInsertAt(t,e.parent,e[t],e),this.parent.jQ.addClass("mq-hasCursor"),this.jQ.insDirOf(t,e.jQ),this},t.insLeftOf=function(t){return this.insDirOf(L,t)},t.insRightOf=function(t){return this.insDirOf(R,t)},t.insAtDirEnd=function(t,e){return prayDirection(t),this.withDirInsertAt(t,e,0,e.ends[t]),this.jQ.insAtDirEnd(t,e.jQ),e.focus(),this},t.insAtLeftEnd=function(t){return this.insAtDirEnd(L,t)},t.insAtRightEnd=function(t){return this.insAtDirEnd(R,t)},t.jumpUpDown=function(t,e){var n,i,s=this;s.upDownCache[t.id]=Point.copy(s),n=s.upDownCache[e.id],n?n[R]?s.insLeftOf(n[R]):s.insAtRightEnd(n.parent):(i=s.offset().left,e.seek(i,s))},t.offset=function(){var t=this,e=t.jQ.removeClass("mq-cursor").offset();return t.jQ.addClass("mq-cursor"),e},t.unwrapGramp=function(){var t=this.parent.parent,e=t.parent,n=t[R],i=this,s=t[L];if(t.disown().eachChild(function(i){i.isEmpty()||(i.children().adopt(e,s,n).each(function(e){e.jQ.insertBefore(t.jQ.first())}),s=i.ends[R])}),!this[R])if(this[L])this[R]=this[L][R];else for(;!this[R];){if(this.parent=this.parent[R],!this.parent){this[R]=t[R],this.parent=e;break}this[R]=this.parent.ends[L]}this[R]?this.insLeftOf(this[R]):this.insAtRightEnd(e),t.jQ.remove(),t[L].siblingDeleted&&t[L].siblingDeleted(i.options,R),t[R].siblingDeleted&&t[R].siblingDeleted(i.options,L)},t.workingGroupChange=function(t){var e,n=this.container,i=!1;return n.find(".active_block").replaceWith(function(){return $(this).contents()}),n.find(".hasCursor_highlighting").removeClass("hasCursor_highlighting"),this.anticursor&&!t?this:(e=this.jQ,e.addClass("hasCursor_highlighting"),i=!1,e.prevAll().each(function(){var t=$(this);t.hasClass("mq-binary-operator")&&(i=!0),i||t.addClass("hasCursor_highlighting")}),i=!1,e.nextAll().each(function(){var t=$(this);t.hasClass("mq-binary-operator")&&(i=!0),i||t.addClass("hasCursor_highlighting")}),n.find(".mq-hasCursor").first().children(".hasCursor_highlighting").wrapAll("<span class='active_block'></span>"),this)},t.startSelection=function(){var t,e=this.anticursor=Point.copy(this),n=e.ancestors={};for(t=e;t.parent;t=t.parent)n[t.parent.id]=t},t.endSelection=function(){delete this.anticursor},t.select=function(){var t,e,n,i,s,r,a,o=this.anticursor;if(this[L]===o[L]&&this.parent===o.parent)return!1;for(t=this;t.parent;t=t.parent)if(t.parent.id in o.ancestors){e=t.parent;break}if(pray("cursor and anticursor in the same tree",e),n=o.ancestors[e.id],r=R,t[L]!==n)for(a=t;a;a=a[R])if(a[R]===n[R]){r=L,i=t,s=n;break}return r===R&&(i=n,s=t),i instanceof Point&&(i=i[R]),s instanceof Point&&(s=s[L]),this.hide().selection=e.selectChildren(i,s),this.insDirOf(r,this.selection.ends[r]),this.selectionChanged(),!0},t.clearSelection=function(){return this.selection&&(this.selection.clear(),delete this.selection,this.selectionChanged()),this},t.deleteSelection=function(){this.selection&&(this[L]=this.selection.ends[L][L],this[R]=this.selection.ends[R][R],this.selection.remove(),this.selectionChanged(),delete this.selection)},t.replaceSelection=function(){var t=this.selection;return t&&(this[L]=t.ends[L][L],this[R]=t.ends[R][R],delete this.selection),t}}),Selection=P(Fragment,function(t,e){t.init=function(){e.init.apply(this,arguments),this.jQ=this.jQ.wrapAll('<span class="mq-selection"></span>').parent()},t.adopt=function(){return this.jQ.replaceWith(this.jQ=this.jQ.children()),e.adopt.apply(this,arguments)},t.clear=function(){return this.jQ.replaceWith(this.jQ[0].childNodes),this},t.join=function(t){return this.fold("",function(e,n){return e+n[t]()})}}),Controller=P(function(t){t.init=function(t,e,n){this.API=t,this.element=0,this.root=e,this.container=n,t.__controller=e.controller=this,this.cursor=e.cursor=Cursor(e,t.__options,n)},t.handle=function(t,e){var n=this.API.__options.handlers;n&&n[t]&&(e===L||e===R?n[t](e,this.API):n[t](this.API))},t.notifyElementOfChange=function(){this.element&&this.element.changed&&this.element.changed(this.API)},t.notifyElementofBlur=function(){this.element&&this.element.mathquillBlurred&&this.element.mathquillBlurred(this.API)};var e=[];this.onNotify=function(t){e.push(t)},t.notify=function(){for(var t=0;t<e.length;t+=1)e[t].apply(this.cursor,arguments);return this},t.createPopup=function(t,e,n,i){var s=this.container.children(".mq-popup").first();0==s.length&&(s=$("<div class='mq-popup mq-autocomplete'></div>"),this.container.append(s)),s.css({top:Math.ceil(e)+"px",left:Math.floor(n)+"px"}),s.html(t),s.find("li").mouseenter(function(){$(this).closest("ul").find("li").removeClass("mq-popup-selected"),$(this).addClass("mq-popup-selected")}).click(i)},t.closePopup=function(){this.container.children(".mq-popup").remove()}}),MathQuill.noConflict=function(){return window.MathQuill=origMathQuill,MathQuill},origMathQuill=window.MathQuill,window.MathQuill=MathQuill,Options=P(),optionProcessors={},MathQuill.__options=Options.p,AbstractMathQuill=P(function(t){t.init=function(){throw"don't call me, I'm 'abstract'"},t.initRoot=function(t,e,n){var i,s;this.__options=Options(),this.config(n),i=Controller(this,t,e),i.createTextarea(),s=e.contents().detach(),t.jQ=$('<span class="mq-root-block"/>').attr(mqBlockId,t.id).appendTo(e),this.latex(s.text()),this.revert=function(){return e.empty().unbind(".mathquill").removeClass("mq-editable-field mq-math-mode mq-text-mode").append(s)}},t.config=MathQuill.config=function(t){var e,n,i;for(e in t)t.hasOwnProperty(e)&&(n=t[e],i=optionProcessors[e],this.__options[e]=i?i(n):n);return this},t.setElement=function(t){return this.__controller.element=t,this},t.el=function(){return this.__controller.container[0]},t.text=function(){return this.__controller.exportText(this.__options)},t.toString=function(){var t=this.__controller.exportLatex();return t="latex{"+t+"}"},t.html=function(){return this.__controller.root.jQ.html().replace(/ mathquill-(?:command|block)-id="?\d+"?/g,"").replace(/<span class="?mq-cursor( mq-blink)?"?>.?<\/span>/i,"").replace(/ mq-hasCursor|mq-hasCursor ?/,"").replace(/ class=(""|(?= |>))/g,"")},t.reflow=function(){return this.__controller.root.postOrder("reflow"),this}}),MathQuill.prototype=AbstractMathQuill.prototype,MathQuill.StaticMath=APIFnFor(P(AbstractMathQuill,function(t,e){t.init=function(t){this.initRoot(MathBlock(),t.addClass("mq-math-mode")),this.__controller.editable=!1,this.__controller.editablesTextareaEvents()},t.latex=function(){var t=e.latex.apply(this,arguments);return arguments.length>0&&this.__controller.root.postOrder("registerInnerField",this.innerFields=[]),t}})),EditableField=MathQuill.EditableField=P(AbstractMathQuill,function(t){t.initRootAndEvents=function(t,e,n){this.initRoot(t,e,n),this.__controller.editable=!0,this.__controller.editablesTextareaEvents()},t.focus=function(t){return this.__controller.focus(),t&&2>t?this.moveToDirEnd(t):t&&this.__controller.seek(!1,t,0),this},t.blur=function(){return this.__controller.blur(),this},t.windowBlur=function(){return this.__controller.windowBlur(),this},t.inFocus=function(){return!this.__controller.blurred},t.write=function(t){return"latex{"===t.slice(0,6)&&"}"===t.slice(-1)&&(t=t.slice(6,-1)),this.__controller.writeLatex(t),this.__controller.blurred&&this.__controller.cursor.hide().parent.blur(),this},t.setAutocomplete=function(t){return this.__options.autocomplete=t.sort(function(t,e){return t.toLowerCase().localeCompare(e.toLowerCase())}),this},t.addAutocomplete=function(t){if("undefined"==typeof this.__options.autocomplete)this.__options.autocomplete=[t];else{if(this.__options.autocomplete.indexOf(t)>-1)return;this.__options.autocomplete.push(t)}return this.__options.autocomplete=this.__options.autocomplete.sort(function(t,e){return t.toLowerCase().localeCompare(e.toLowerCase())}),this},t.command=function(t,e){var n,i,s,r;switch(t){case"matrix_add_column_before":case"matrix_add_column_after":for(n=0,n=this.__controller.cursor;0!==n&&!(n instanceof Matrix);n=n.parent);if(!n)return;n.insertColumn(this.__controller.cursor,"matrix_add_column_before"===t?L:R);break;case"matrix_add_row_before":case"matrix_add_row_after":for(n=0,n=this.__controller.cursor;0!==n&&!(n instanceof Matrix);n=n.parent);if(!n)return;n.insertRow(this.__controller.cursor,"matrix_add_row_before"===t?L:R);break;case"matrix_remove_column":for(n=0,n=this.__controller.cursor;0!==n&&!(n instanceof Matrix);n=n.parent);if(!n)return;n.deleteColumn(this.__controller.cursor);break;case"matrix_remove_row":for(n=0,n=this.__controller.cursor;0!==n&&!(n instanceof Matrix);n=n.parent);if(!n)return;n.deleteRow(this.__controller.cursor);break;case"unit":for(i=0,s=!1,i=this.__controller.cursor;0!==i&&!(i instanceof Unit);i=i.parent);i||(i=Unit().createLeftOf(this.__controller.cursor),s=!0),this.typedText(e),r=this.__controller.container.children(".mq-popup"),r.length>0&&r.find("li.mq-popup-selected").click(),s&&(this.__controller.cursor.insRightOf(i),this.__controller.cursor.workingGroupChange());break;default:this.cmd(t)}},t.cmd=function(t){var e,n=this.__controller.notify(),i=n.cursor.show();return/^\\[a-z]+$/i.test(t)?(t=t.slice(1),e=LatexCmds[t],e&&(t=e(t),i.selection&&t.replaces(i.replaceSelection()),t.createLeftOf(i))):i.parent.write(i,t,i.replaceSelection()),n.blurred&&i.hide().parent.blur(),this},t.select=function(){var t=this.__controller;for(t.notify("move").cursor.insAtRightEnd(t.root);t.cursor[L];)t.selectLeft();return this},t.clearSelection=function(){return this.__controller.cursor.clearSelection(),this},t.clear=function(){return this.select(),this.clearSelection(),this},t.moveToDirEnd=function(t){return this.__controller.notify("move").cursor.insAtDirEnd(t,this.__controller.root),this.__controller.cursor.workingGroupChange(),this},t.moveToLeftEnd=function(){return this.moveToDirEnd(L)},t.moveToRightEnd=function(){return this.moveToDirEnd(R)},t.keystroke=function(t,e){return this.__controller.keystroke(t,e),this},t.typedText=function(t){for(var e=0;e<t.length;e+=1)this.__controller.typedText(t.charAt(e));return this},t.cut=function(t){return this.__controller.cut(t),this},t.copy=function(t){return this.__controller.copy(t),this},t.paste=function(t){return this.__controller.paste(t),this},t.contextMenu=function(t){return this.__controller.contextMenu(t)},t.cursorX=function(){return this.__controller.cursor.jQ&&this.__controller.cursor.jQ.offset()?this.__controller.cursor.jQ.offset().left:undefined},t.mouseDown=function(t){this.__controller.mouseDown(t)},t.mouseMove=function(t){this.__controller.mouseMove(t)},t.mouseUp=function(t){this.__controller.mouseUp(t)},t.mouseOut=function(t){this.__controller.mouseOut(t)}}),Parser=P(function(t,e,n){function i(t,e){throw t=t?"'"+t+"'":"EOF","Parse Error: "+e+" at "+t}var s,r,a,o,l,c,h,d,u,p,m,f,L;t.init=function(t){this._=t},t.parse=function(t){function e(t,e){return e}return this.skip(L)._(t,e,i)},t.or=function(t){pray("or is passed a parser",t instanceof n);var e=this;return n(function(n,i,s){function r(){return t._(n,i,s)}return e._(n,i,r)})},t.then=function(t){var e=this;return n(function(i,s,r){function a(e,i){var a=t instanceof n?t:t(i);return pray("a parser is returned",a instanceof n),a._(e,s,r)}return e._(i,a,r)})},t.many=function(){var t=this;return n(function(e,n){function i(t,n){return e=t,r.push(n),!0}function s(){return!1}for(var r=[];t._(e,i,s););return n(e,r)})},t.times=function(t,e){arguments.length<2&&(e=t);var i=this;return n(function(n,s,r){function a(t,e){return d.push(e),n=t,!0}function o(t,e){return c=e,n=t,!1}function l(){return!1}var c,h,d=[],u=!0;for(h=0;t>h;h+=1)if(u=i._(n,a,o),!u)return r(n,c);for(;e>h&&u;h+=1)u=i._(n,a,l);return s(n,d)})},t.result=function(t){return this.then(a(t))},t.atMost=function(t){return this.times(0,t)},t.atLeast=function(t){var e=this;return e.times(t).then(function(t){return e.many().map(function(e){return t.concat(e)})})},t.map=function(t){return this.then(function(e){return a(t(e))})},t.skip=function(t){return this.then(function(e){return t.result(e)})},s=this.string=function(t){var e=t.length,i="expected '"+t+"'";return n(function(n,s,r){var a=n.slice(0,e);return a===t?s(n.slice(e),a):r(n,i)})},r=this.regex=function(t){pray("regexp parser is anchored","^"===t.toString().charAt(1));var e="expected "+t;return n(function(n,i,s){var r,a=t.exec(n);return a?(r=a[0],i(n.slice(r.length),r)):s(n,e)})},a=n.succeed=function(t){return n(function(e,n){return n(e,t)})},o=n.fail=function(t){return n(function(e,n,i){return i(e,t)})},l=n.letter=r(/^[a-z]/i),c=n.letters=r(/^[a-z]*/i),h=n.digit=r(/^[0-9]/),d=n.digits=r(/^[0-9]*/),u=n.whitespace=r(/^\s+/),p=n.optWhitespace=r(/^\s*/),m=n.any=n(function(t,e,n){return t?e(t.slice(1),t.charAt(0)):n(t,"expected any character")}),f=n.all=n(function(t,e){return e("",t)}),L=n.eof=n(function(t,e,n){return t?n(t,"expected EOF"):e(t,t)})}),Controller.open(function(t){t.exportText=function(t){return this.root.foldChildren("",function(e,n){return e+n.text(t)})}}),Controller.open(function(t){t.focusBlurEvents=function(){var t=this,e=t.root,n=t.cursor;t.focus=function(){t.blurred=!1,t.element&&t.element.setFocusedItem(t.API),t.container.addClass("mq-focused"),n.parent||n.insAtRightEnd(e),n.selection?(n.selection.jQ.removeClass("mq-blur"),t.selectionChanged()):n.anticursor?n.select():n.show(),t.element&&t.element.workspace.attachToolbar(t.API,t.element.workspace.mathToolbar())},t.blur=function(){t.blurred=!0,t.element&&t.element.workspace.blurToolbar(),t.element&&t.element.clearFocusedItem(t.API),e.postOrder("intentionalBlur"),n.clearSelection(),n.hide().parent.blur(),t.closePopup(),t.container.removeClass("mq-focused"),t.handle("blur")},t.windowBlur=function(){t.blurred=!0,t.element&&t.element.clearFocusedItem(t.API),n.selection&&n.selection.jQ.addClass("mq-blur"),n.hide().parent.blur(),t.closePopup(),t.container.removeClass("mq-focused"),t.handle("blur")},t.blurred=!0,n.hide().parent.blur()}}),Controller.open(function(t){t.keystroke=function(t,e){this.cursor.parent.keystroke(t,e,this)}}),Node.open(function(t){t.keystroke=function(t,e,n){var i,s=n.cursor;switch(t){case"Ctrl-Shift-Backspace":case"Ctrl-Backspace":for(;s[L]||s.selection;)n.backspace();break;case"Shift-Backspace":case"Backspace":n.backspace();break;case"Enter":if(i=n.container.children(".mq-popup"),i.length>0){i.find("li.mq-popup-selected").click();break}return;case"Esc":case"Tab":if(i=n.container.children(".mq-popup"),i.length>0){i.find("li.mq-popup-selected").click();break}return void n.escapeDir(R,t,e);case"Shift-Tab":case"Shift-Esc":return void n.escapeDir(L,t,e);case"End":n.notify("move").cursor.insAtRightEnd(s.parent),n.cursor.workingGroupChange();break;case"Ctrl-End":n.notify("move").cursor.insAtRightEnd(n.root),n.cursor.workingGroupChange();break;case"Shift-End":for(s.parent===n.root&&0===s[R]&&n.selectRight();s[R];)n.selectRight();break;case"Ctrl-Shift-End":for(s.parent===n.root&&0===s[R]&&n.selectRight();s[R]||s.parent!==n.root;)n.selectRight();break;case"Home":n.notify("move").cursor.insAtLeftEnd(s.parent),n.cursor.workingGroupChange();break;case"Ctrl-Home":n.notify("move").cursor.insAtLeftEnd(n.root),n.cursor.workingGroupChange();break;case"Shift-Home":for(s.parent===n.root&&0===s[L]&&n.selectLeft();s[L];)n.selectLeft();break;case"Ctrl-Shift-Home":for(s.parent===n.root&&0===s[L]&&n.selectLeft();s[L]||s.parent!==n.root;)n.selectLeft();break;case"Left":n.moveLeft();break;case"Shift-Left":n.selectLeft();break;case"Ctrl-Left":break;case"Right":n.moveRight();break;case"Shift-Right":n.selectRight();break;case"Ctrl-Right":break;case"Up":n.moveUp();break;case"Down":n.moveDown();break;case"Shift-Up":if(s[L])for(;s[L];)n.selectLeft();else n.selectLeft();break;case"Shift-Down":if(s[R])for(;s[R];)n.selectRight();else n.selectRight();break;case"Ctrl-Up":break;case"Ctrl-Down":break;case"Ctrl-Shift-Del":case"Ctrl-Del":for(;s[R]||s.selection;)n.deleteForward();break;case"Shift-Del":case"Del":n.deleteForward();break;case"Meta-A":case"Ctrl-A":for(n.notify("move").cursor.insAtRightEnd(n.root);s[L];)n.selectLeft();break;default:return}e.preventDefault(),n.blurred||n.scrollHoriz()},t.moveOutOf=t.moveTowards=t.deleteOutOf=t.deleteTowards=t.unselectInto=t.selectOutOf=t.selectTowards=function(){pray("overridden or never called on this node")}}),Controller.open(function(t){function e(t,e){var n,i,s,r,a,o=t.container.children(".mq-popup");return o.length>0?(n=o.find("li.mq-popup-selected"),i="up"===e?n.prev("li"):n.next("li"),0==i.length?t:(n.removeClass("mq-popup-selected"),i.addClass("mq-popup-selected"),t)):(s=t.notify("upDown").cursor,r=e+"Into",a=e+"OutOf",s[R][r]?s.insAtLeftEnd(s[R][r]):s[L][r]?s.insAtRightEnd(s[L][r]):s.parent.bubble(function(t){var e=t[a];return e&&("function"==typeof e&&(e=t[a](s)),e instanceof Node&&s.jumpUpDown(t,e),e!==!0)?!1:void 0}),s.workingGroupChange(),t)}this.onNotify(function(t){("move"===t||"upDown"===t)&&this.show().clearSelection()}),t.escapeDir=function(t,e,n){prayDirection(t);var i=this.cursor;return n.preventDefault(),i.parent.moveOutOf(t,i),i.workingGroupChange(),this.notify("move")},optionProcessors.leftRightIntoCmdGoes=function(t){if(t&&"up"!==t&&"down"!==t)throw'"up" or "down" required for leftRightIntoCmdGoes option, got "'+t+'"';return t},t.moveDir=function(t){prayDirection(t);var e=this.cursor,n=e.options.leftRightIntoCmdGoes;return e.selection?e.insDirOf(t,e.selection.ends[t]):e[t]?e[t].moveTowards(t,e,n):e.parent.moveOutOf(t,e,n),this.container.children(".mq-autocomplete").length>0&&(e[L]instanceof Variable?e[L].autoComplete():e[R]instanceof Variable?e[R].autoComplete():e[L]instanceof SupSub&&"sub"==e[L].supsub&&e[L].sub.ends[R]?e[L].sub.ends[R].autoComplete():this.container.children(".mq-autocomplete").remove()),e.workingGroupChange(),this.notify("move")
|
2
|
+
},t.moveLeft=function(){return this.moveDir(L)},t.moveRight=function(){return this.moveDir(R)},t.moveUp=function(){return e(this,"up")},t.moveDown=function(){return e(this,"down")},this.onNotify(function(t){"upDown"!==t&&(this.upDownCache={})}),this.onNotify(function(t){"edit"===t&&this.show().deleteSelection()}),t.deleteDir=function(t){var e,n;return prayDirection(t),e=this.cursor,n=e.selection,this.notify("edit"),n||(e[t]?e[t].deleteTowards(t,e):e.parent.deleteOutOf(t,e)),e[L].siblingDeleted&&e[L].siblingDeleted(e.options,R),e[R].siblingDeleted&&e[R].siblingDeleted(e.options,L),e.parent.bubble("reflow"),e.workingGroupChange(),this},t.backspace=function(){return this.deleteDir(L)},t.deleteForward=function(){return this.deleteDir(R)},this.onNotify(function(t){"select"!==t&&this.endSelection()}),t.selectDir=function(t){var e,n=this.notify("select").cursor,i=n.selection;prayDirection(t),n.anticursor||n.startSelection(),e=n[t],e?i&&i.ends[t]===e&&n.anticursor[-t]!==e?e.unselectInto(t,n):e.selectTowards(t,n):n.parent.selectOutOf(t,n),n.clearSelection(),n.select()||n.show()},t.selectLeft=function(){return this.selectDir(L)},t.selectRight=function(){return this.selectDir(R)}}),latexMathParser=function(){function t(t){var e,n,i=MathBlock();if(t instanceof Letter&&t.ctrlSeq.length>1)for(e=t.ctrlSeq,n=0;n<e.length;n+=1)Letter(e[n]).adopt(i,i.ends[R],0);else t.adopt(i,0,0);return i}function e(t){var e,n=t[0]||MathBlock();for(e=1;e<t.length;e+=1)t[e].children().adopt(n,n.ends[R],0);return n}var n=Parser.string,i=Parser.regex,s=(Parser.letter,Parser.any),r=Parser.optWhitespace,a=Parser.succeed,o=Parser.fail,l=i(/^[a-z]+[0-9]*/i).map(function(t){return Letter(t)}),c=i(/^[^${}\\_^]/).map(function(t){return VanillaSymbol(t)}),h=i(/^[^\\a-eg-zA-Z]/).or(n("\\").then(i(/^[a-z]+/i).or(i(/^\s+/).result(" ")).or(s))).then(function(t){var e=LatexCmds[t];return e?e(t).parser():o("unknown command: \\"+t)}),d=h.or(l).or(c),u=n("{").then(function(){return m}).skip(n("}")),p=r.then(u.or(d.map(t))),m=p.many().map(e).skip(r),f=n("[").then(p.then(function(t){return"]"!==t.join("latex")?a(t):o()}).many().map(e).skip(r)).skip(n("]")),L=m;return L.block=p,L.optBlock=f,L}(),Controller.open(function(t){t.exportLatex=function(){return this.root.latex().replace(/(\\[a-z]+) (?![a-z])/gi,"$1")},t.writeLatex=function(t){var e,n=this.notify("edit").cursor,i=Parser.all,s=Parser.eof,r=latexMathParser.skip(s).or(i.result(!1)).parse(t);return r&&!r.isEmpty()&&(r.children().adopt(n.parent,n[L],n[R]),e=r.jQize(),e.insertBefore(n.jQ),n[L]=r.ends[R],r.finalizeInsert(n.options,n),r.ends[R][R].siblingCreated&&r.ends[R][R].siblingCreated(n.options,L),r.ends[L][L].siblingCreated&&r.ends[L][L].siblingCreated(n.options,R),n.parent.bubble("reflow")),this},t.renderLatexMath=function(t){var e,n,i=this.root,s=this.cursor,r=Parser.all,a=Parser.eof,o=latexMathParser.skip(a).or(r.result(!1)).parse(t);i.eachChild("postOrder","dispose"),i.ends[L]=i.ends[R]=0,o&&o.children().adopt(i,0,0),e=i.jQ,o?(n=o.join("html"),e.html(n),i.jQize(e.children()),i.finalizeInsert(s.options)):e.empty(),delete s.selection,s.insAtRightEnd(i)},t.renderLatexText=function(t){console.log("renderLatexText: "+t);var e=this.root,n=this.cursor;e.jQ.children().slice(1).remove(),e.eachChild("postOrder","dispose"),e.ends[L]=e.ends[R]=0,delete n.selection,n.show().insAtRightEnd(e)}}),Controller.open(function(t){t.contextMenu=function(t){var e,n=$(t.target).closest(".mq-root-block"),i=Node.byId[n.attr(mqBlockId)||this.root.jQ.attr(mqBlockId)];for(this.blurred&&this.focus(),e=this.seek($(t.target),t.pageX,t.pageY).cursor.parent;!(e instanceof MathCommand);)if(e=e.parent,"undefined"==typeof e){e=i;break}return e.contextMenu(this.cursor,t),t.preventDefault(),!1},t.orig_block=0,t.mouseDown=function(t){this.orig_block=this.cursor.parent,this.closePopup(),this.blurred&&this.focus(),this.seek($(t.target),t.pageX,t.pageY).cursor.workingGroupChange(!0).startSelection()},t.mouseMove=function(t){this.cursor.anticursor||this.cursor.startSelection(),this.seek($(t.target),t.pageX,t.pageY).cursor.select()},t.mouseOut=function(){this.element.workspace.blurToolbar(),this.cursor.selection?this.cursor.selection.jQ.removeClass("mq-selection"):this.cursor.hide()},t.mouseUp=function(){this.cursor.selection||this.editable&&(this.orig_block&&this.orig_block.blur(),this.cursor.show(),this.cursor.parent.focus(),this.cursor.workingGroupChange(!0))}}),Controller.open(function(t){t.seek=function(t,e){var n,i,s,r=this.notify("select").cursor;return t&&(n=t.attr(mqBlockId)||t.attr(mqCmdId),n||(i=t.parent(),n=i.attr(mqBlockId)||i.attr(mqCmdId))),s=n?Node.byId[n]:this.root,pray("nodeId is the id of some Node that exists",s),r.clearSelection().show(),s.seek(e,r),this.scrollHoriz(),r.workingGroupChange(),this}}),Controller.open(function(t){t.scrollHoriz=function(){var t,e,n,i,s,r=this.cursor,a=r.selection,o=this.root.jQ[0].getBoundingClientRect();if(a)if(n=a.jQ[0].getBoundingClientRect(),i=n.left-(o.left+20),s=n.right-(o.right-20),a.ends[L]===r[R])if(0>i)e=i;else{if(!(s>0))return;e=n.left-s<o.left+20?i:s}else if(s>0)e=s;else{if(!(0>i))return;e=n.right-i>o.right-20?s:i}else if(t=r.jQ[0].getBoundingClientRect().left,t>o.right-20)e=t-(o.right-20);else{if(!(t<o.left+20))return;e=t-(o.left+20)}this.root.jQ.stop().animate({scrollLeft:"+="+e},100)}}),Controller.open(function(t){t.createTextarea=function(){var t=this;t.cursor.selectionChanged=function(){t.selectionChanged()},t.copy=function(){t.setTextareaSelection()}},t.selectionChanged=function(){var t=this;forceIERedraw(t.container[0]),t.textareaSelectionTimeout===undefined&&(t.textareaSelectionTimeout=setTimeout(function(){t.setTextareaSelection()}))},t.setTextareaSelection=function(){this.textareaSelectionTimeout=undefined;var t="";this.cursor.selection&&(t=this.cursor.selection.join("latex"),t="latex{"+t+"}"),this.selectFn(t)},t.editablesTextareaEvents=function(){var t=this,e=t.cursor;this.selectFn=function(t){this.element.workspace.clipboard=t},this.cut=function(){e.selection&&setTimeout(function(){t.notify("edit"),e.parent.bubble("reflow")})},this.focusBlurEvents()},t.typedText=function(t){if("\n"===t)return this.handle("enter"),this.API.blur();var e=this.notify().cursor;e.parent.write(e,t,e.show().replaceSelection()),this.scrollHoriz()},t.paste=function(t){"latex{"===t.slice(0,6)&&"}"===t.slice(-1)&&(t=t.slice(6,-1)),this.writeLatex(t).blur()}}),MathElement=P(Node,function(t){t.finalizeInsert=function(t,e){var n=this;n.postOrder("finalizeTree",t),n.postOrder("contactWeld",e),n.postOrder("blur"),n.postOrder("reflow"),n[R].siblingCreated&&n[R].siblingCreated(t,L),n[L].siblingCreated&&n[L].siblingCreated(t,R),n.bubble("reflow")},t.contextMenu=function(){}}),MathCommand=P(MathElement,function(t,e){t.init=function(t,n,i){var s=this;e.init.call(s),s.ctrlSeq||(s.ctrlSeq=t),n&&(s.htmlTemplate=n),i&&(s.textTemplate=i)},t.replaces=function(t){t.disown(),this.replacedFragment=t},t.isEmpty=function(){return this.foldChildren(!0,function(t,e){return t&&e.isEmpty()})},t.parser=function(){var t=latexMathParser.block,e=this;return t.times(e.numBlocks()).map(function(t){e.blocks=t;for(var n=0;n<t.length;n+=1)t[n].adopt(e,e.ends[R],0);return e})},t.createLeftOf=function(t){var n,i,s,r=this;if(this instanceof Variable||"sub"===this.supsub||t.container.children(".mq-popup").remove(),"undefined"!=typeof t.parent&&t.parent.parent instanceof Matrix){if(","==r.ctrlSeq)return t.parent.parent.moveOrInsertColumn(t);if(";"==r.ctrlSeq)return t.parent.parent.insertRow(t);if(":"==r.ctrlSeq)return t.parent.parent.deleteRow(t);if("<"==r.ctrlSeq)return t.parent.parent.deleteColumn(t);if(">"==r.ctrlSeq)return t.parent.parent.insertColumn(t)}else if("undefined"!=typeof t.parent&&t.parent.parent instanceof Bracket&&"\\left["===t.parent.parent.ctrlSeq&&(","==r.ctrlSeq||";"==r.ctrlSeq))return n=t.parent.parent,0!==n[L]?t.insRightOf(n[L]):t.insAtLeftEnd(n.parent),i=Matrix("\\bmatrix",1,1),i.createLeftOf(t),n.ends[L].children().disown().adopt(i.ends[L],0,0).jQ.appendTo(i.ends[L].jQ),n.remove(),","==r.ctrlSeq?i.insertColumn(t):i.insertRow(t);s=r.replacedFragment,r.createBlocks(),e.createLeftOf.call(r,t),s&&(s.adopt(r.ends[L],0,0),s.jQ.appendTo(r.ends[L].jQ)),r.finalizeInsert(t.options),r.placeCursor(t),(this instanceof BinaryOperator||this instanceof Fraction||this instanceof SupSub||this instanceof SquareRoot)&&t.workingGroupChange()},t.createBlocks=function(){var t,e,n=this,i=n.numBlocks(),s=n.blocks=Array(i);for(t=0;i>t;t+=1)e=s[t]=MathBlock(),e.adopt(n,n.ends[R],0)},t.placeCursor=function(t){t.insAtRightEnd(this.foldChildren(this.ends[L],function(t,e){return t.isEmpty()?t:e}))},t.moveTowards=function(t,e,n){var i=n&&this[n+"Into"];e.insAtDirEnd(-t,i||this.ends[-t])},t.deleteTowards=function(t,e){e.startSelection(),this.selectTowards(t,e),e.select()},t.selectTowards=function(t,e){e[-t]=this,e[t]=this[t]},t.selectChildren=function(){return Selection(this,this)},t.unselectInto=function(t,e){e.insAtDirEnd(-t,e.anticursor.ancestors[this.id])},t.seek=function(t,e){function n(t){var e={};return e[L]=t.jQ.offset().left,e[R]=e[L]+t.jQ.outerWidth(),e}var i,s=this,r=n(s);return t<r[L]?e.insLeftOf(s):t>r[R]?e.insRightOf(s):(i=r[L],void s.eachChild(function(a){var o=n(a);return t<o[L]?(t-i<o[L]-t?a[L]?e.insAtRightEnd(a[L]):e.insLeftOf(s):e.insAtLeftEnd(a),!1):t>o[R]?void(a[R]?i=o[R]:r[R]-t<t-o[R]?e.insRightOf(s):e.insAtRightEnd(a)):(a.seek(t,e),!1)}))},t.numBlocks=function(){var t=this.htmlTemplate.match(/&\d+/g);return t?t.length:0},t.html=function(){var t,e,n,i=this,s=i.blocks,r=" mathquill-command-id="+i.id,a=i.htmlTemplate.match(/<[^<>]+>|[^<>]+/g);for(pray("no unmatched angle brackets",a.join("")===this.htmlTemplate),t=0,e=a[0];e;t+=1,e=a[t])if("/>"===e.slice(-2))a[t]=e.slice(0,-2)+r+"/>";else if("<"===e.charAt(0)){pray("not an unmatched top-level close tag","/"!==e.charAt(1)),a[t]=e.slice(0,-1)+r+">",n=1;do t+=1,e=a[t],pray("no missing close tags",e),"</"===e.slice(0,2)?n-=1:"<"===e.charAt(0)&&"/>"!==e.slice(-2)&&(n+=1);while(n>0)}return a.join("").replace(/>&(\d+)/g,function(t,e){return" mathquill-block-id="+s[e].id+">"+s[e].join("html")})},t.latex=function(){return this.foldChildren(this.ctrlSeq,function(t,e){return t+"{"+(e.latex()||" ")+"}"})},t.textTemplate=[""],t.text=function(t){var e=this,n=0;return e.foldChildren(e.textTemplate[n],function(i,s){n+=1;var r=s.text(t);return i&&"("===e.textTemplate[n]&&"("===r[0]&&")"===r.slice(-1)?i+r.slice(1,-1)+e.textTemplate[n]:i+s.text(t)+(e.textTemplate[n]||"")})},t.setUnit=function(){this.parent.unit&&(this.unit=this.parent.unit,(this.parent instanceof SupSub||this.parent.unitsup)&&(this.unitsup=!0)),this.parent.parent&&this.parent.parent.unit&&(this.unit=this.parent.parent.unit,(this.parent.parent instanceof SupSub||this.parent.parent.unitsup)&&(this.unitsup=!0))},t.recursiveSetUnit=function(){this.setUnit(),this.eachChild(function(t){t.recursiveSetUnit&&t.recursiveSetUnit()})}}),DerivedMathCommand=P(MathCommand,function(){}),Symbol=P(MathCommand,function(t,e){t.init=function(t,n,i){i||(i=(t&&t.length>1?t.slice(1):t).trim()),e.init.call(this,t,n,[i])},t.parser=function(){return Parser.succeed(this)},t.numBlocks=function(){return 0},t.replaces=function(t){t.remove()},t.createBlocks=noop,t.moveTowards=function(t,e){e.jQ.insDirOf(t,this.jQ),e[-t]=this,e[t]=this[t]},t.deleteTowards=function(t,e){e[t]=this.remove()[t]},t.seek=function(t,e){t-this.jQ.offset().left<this.jQ.outerWidth()/2?e.insLeftOf(this):e.insRightOf(this)},t.latex=function(){return this.ctrlSeq},t.text=function(){return this.textTemplate},t.placeCursor=noop,t.isEmpty=function(){return!0}}),VanillaSymbol=P(Symbol,function(t,e){t.init=function(t,n,i){e.init.call(this,t,"<span>"+(n||t)+"</span>",i||t)},t.createLeftOf=function(t){if("."===this.ctrlSeq)if(0===t[L]||t[L]instanceof BinaryOperator)VanillaSymbol("0").createLeftOf(t);else if(0!==t[L]&&"."===t[L].ctrlSeq)return t[L].ctrlSeq="…",t[L].jQ.html('<span class="mq-nonSymbola" style="font-size:0.6em;">…</span>'),void(t[L].textTemplate="..");e.createLeftOf.call(this,t)}}),BinaryOperator=P(Symbol,function(t,e){t.init=function(t,n,i){e.init.call(this,t,'<span class="mq-binary-operator">'+n+"</span>",i)}}),MathBlock=P(MathElement,function(t,e){t.join=function(t){return this.foldChildren("",function(e,n){return e+n[t]()})},t.html=function(){return this.join("html")},t.latex=function(){return this.join("latex")},t.text=function(t){return 0===this.ends[L]&&0===this.ends[R]?"":this.ends[L]===this.ends[R]?this.ends[L].text(t):this.foldChildren("",function(e,n){return e+n.text(t)})},t.keystroke=function(t,n,i){var s,r,a,o;{if(!i.API.__options.spaceBehavesLikeTab||"Spacebar"!==t&&"Shift-Spacebar"!==t){if("Tab"===t)r=i.cursor,r[L]instanceof Letter&&r[L].autoOperator(r);else if("Enter"===t){if(i.cursor.parent==i.root&&!i.cursor[L]&&i.element&&i.element.PrependBlankItem)return i.element.PrependBlankItem(),void n.preventDefault();if(i.cursor.parent!=i.root||i.cursor.parent==i.root&&i.cursor[R])return i.cursor.insAtRightEnd(i.root),i.cursor.workingGroupChange(),void n.preventDefault()}else if("Backspace"===t||"Del"===t)return i.notifyElementOfChange(),o=e.keystroke.apply(this,arguments),r=i.cursor,r[L]&&r[L]instanceof Variable?r[L].autoComplete():0===r[L]&&r.parent&&r.parent.parent instanceof SupSub&&"sub"===r.parent.parent.supsub&&r.parent.parent[L]?r.parent.parent[L].autoComplete():i.closePopup(),o;return e.keystroke.apply(this,arguments)}if(s=i.container.children(".mq-popup"),n.preventDefault(),s.length>0)s.find("li.mq-popup-selected").click();else{if(r=i.cursor,r.parent===i.root&&i.element&&i.element.changeToText&&(a=i.API.text(),a.match(/^[a-z0-9\.-]*$/i)))return i.element.changeToText(a);r[L]instanceof Letter&&r[L].autoOperator(r),i.escapeDir("Shift-Spacebar"===t?L:R,t,n)}}},t.moveOutOf=function(t,e,n){var i=n&&this.parent[n+"Into"];!i&&this[t]?e.insAtDirEnd(-t,this[t]):e.insDirOf(t,this.parent)},t.selectOutOf=function(t,e){e.insDirOf(t,this.parent)},t.deleteOutOf=function(t,e){e.unwrapGramp()},t.seek=function(t,e){var n=this.ends[R];if(!n||n.jQ.offset().left+n.jQ.outerWidth()<t)return e.insAtRightEnd(this);if(t<this.ends[L].jQ.offset().left)return e.insAtLeftEnd(this);for(;t<n.jQ.offset().left;)n=n[L];return n.seek(t,e)},t.flash=function(){var t=this.jQ.closest(".sc_element");t.stop().css("background-color","#ffe0e0").animate({backgroundColor:"#FFFFFF"},400)},t.write=function(t,e,n){t.controller.notifyElementOfChange();var i;if(e.match(/^[a-eg-zA-Z]$/)?i=Letter(e):e.match(/^[0-9\+\-]$/)&&t[L]instanceof Variable&&"e"===t[L].ctrlSeq&&0!==t[L][L]&&"undefined"!=typeof t[L][L]&&t[L][L].ctrlSeq.match(/^[0-9]$/)?i=ScientificNotation(e):e.match(/^[0-9\+\-]$/)&&t[L]instanceof Variable&&"e"===t[L].ctrlSeq&&0!==t[L][L]&&t[L][L]instanceof Multiplication&&t[L][L].addedImplicitly&&0!==t[L][L][L]&&"undefined"!=typeof t[L][L][L]&&t[L][L][L].ctrlSeq.match(/^[0-9]$/)?(t[L][L].remove(),i=ScientificNotation(e)):i=!e.match(/^[0-9\.]$/)||t.parent&&t.parent.unit||t.parent&&t.parent.parent&&t.parent.parent.unit||!(t[L]instanceof Variable||t.parent&&t.parent.parent instanceof SupSub&&"sub"===t.parent.parent.supsub)?(i=CharCmds[e]||LatexCmds[e])?i(e):VanillaSymbol(e):Letter(e),t.parent&&t.parent.parent&&t.parent.parent.unitsup){if(!e.match(/^[0-9\.\+\-\*\^\/\(\)]$/))return n&&n.remove(),void this.flash()}else if(t.parent&&t.parent.parent&&t.parent.parent.unit)if(t.parent.parent instanceof SupSub){if(!e.match(/^[0-9\.\+\-\*\^\/\(\)]$/))return n&&n.remove(),void this.flash();if(!("/"!==e&&"^"!==e||t[L]instanceof VanillaSymbol||t[L]instanceof Variable))return n&&n.remove(),void this.flash()}else{if(!e.match(/^[a-z\u00b52\^\*\/\(\)]$/i))return n&&n.remove(),void this.flash();if(!("/"!==e&&"^"!==e||t[L]instanceof VanillaSymbol||t[L]instanceof Variable))return n&&n.remove(),void this.flash()}if(n&&i.replaces(n),!(!(i instanceof Variable)&&t[L]instanceof Letter&&t[L].autoOperator(t)&&i instanceof Bracket&&i.side===L)){if(t.parent&&(t.parent.parent instanceof OperatorName||t.parent.parent instanceof FunctionCommand)&&t.parent===t.parent.parent.ends[L]){if(!(i instanceof Variable||"_"===e&&0===t[R]))return this.flash();if(t[L]instanceof SupSub||"_"===e&&0===t[L])return this.flash()}!(i instanceof Variable||i instanceof Currency)||!(t[L]instanceof VanillaSymbol||t[L]instanceof DerivedMathCommand||t[L]instanceof Currency)||t[L].ctrlSeq.match(/^[\,\u2026]$/)||t.parent&&t.parent.parent instanceof SupSub?i instanceof BinaryOperator||i instanceof Fraction||i instanceof DerivedMathCommand||i instanceof SupSub||i instanceof Bracket&&i.side===R||0===t[L]||!(t[L]instanceof Fraction||t[L]instanceof Bracket||t[L]instanceof DerivedMathCommand||t[L]instanceof SupSub&&!(i instanceof Bracket))||LatexCmds.cdot().implicit().createLeftOf(t):LatexCmds.cdot().implicit().createLeftOf(t),i.createLeftOf(t)}},t.focus=function(){return this.jQ.addClass("mq-hasCursor"),this.jQ.removeClass("mq-empty"),this.unit&&this.unit.focus(),this.parent&&this.parent.unit&&this.parent.unit.focus(),this},t.blur=function(){return this.jQ.removeClass("mq-hasCursor"),this.isEmpty()&&this.jQ.addClass("mq-empty"),this.unit&&this.unit.blur(),this.parent&&this.parent.unit&&this.parent.unit.blur(),this},t.recursiveSetUnit=function(){this.eachChild(function(t){t.recursiveSetUnit&&t.recursiveSetUnit()}),this.eachChild(function(t){if(t instanceof VanillaSymbol&&("µ"==t.ctrlSeq||"2"==t.ctrlSeq)){var e=Letter(t.ctrlSeq);e.jQize(),e.jQ.insDirOf(R,t.jQ),t[R]=e.adopt(t.parent,t,t[R]),t.remove()}})}}),RootMathBlock=P(MathBlock,RootBlockMixin),MathQuill.MathField=APIFnFor(P(EditableField,function(t){t.init=function(t,e){t.addClass("mq-editable-field mq-math-mode"),this.initRootAndEvents(RootMathBlock(),t,e)},t.latex=function(t){return arguments.length>0?(this.__controller.renderLatexMath(t),this.__controller.blurred&&this.__controller.cursor.hide().parent.blur(),this):this.__controller.exportLatex()}})),Bracket=P(P(MathCommand,DelimsMixin),function(t,e){t.init=function(t,n,i,s,r,a,o){e.init.call(this,"\\left"+s,undefined,[n,i]),this.side=t,this.sides={},this.sides[L]={ch:n,ctrlSeq:s,textTemplate:a},this.sides[R]={ch:i,ctrlSeq:r,textTemplate:o}},t.numBlocks=function(){return 1},t.html=function(){return this.htmlTemplate='<span class="mq-non-leaf"><span class="mq-scaled mq-paren'+(this.side===R?" mq-ghost":"")+'">'+this.sides[L].ch+'</span><span class="mq-non-leaf">&0</span><span class="mq-scaled mq-paren'+(this.side===L?" mq-ghost":"")+'">'+this.sides[R].ch+"</span></span>",e.html.call(this)},t.latex=function(){return"\\left"+this.sides[L].ctrlSeq+this.ends[L].latex()+"\\right"+this.sides[R].ctrlSeq},t.text=function(t){return"\\left["!==this.ctrlSeq||this[L]instanceof Variable?this.sides[L].textTemplate+this.ends[L].text(t)+this.sides[R].textTemplate:"("+this.ends[L].text(t)+")"},t.oppBrack=function(t,e){return t instanceof Bracket&&t.side&&t.side!==-e&&("|"===this.sides[this.side].ch||t.side===-this.side)&&t},t.closeOpposing=function(t){t.side=0,t.sides[this.side]=this.sides[this.side],t.delimjQs.eq(this.side===L?0:1).removeClass("mq-ghost").html(this.sides[this.side].ch)},t.createLeftOf=function(t){var n,i,s,r,a,o,l;if(!this.replacedFragment){for(n=this.oppBrack(t[L],L)||this.oppBrack(t[R],R),i=!1,s=t.parent;0!==s&&!n;s=s.parent)if(i&&(n=this.oppBrack(s)),i=!0,this.side===R&&"\\left("===this.ctrlSeq){if(s instanceof OperatorName||s instanceof SummationNotation)return t.insRightOf(s),t.workingGroupChange()}else if(this.side===R&&"\\left["===this.ctrlSeq&&s instanceof Matrix)return t.insRightOf(s),t.workingGroupChange();if(!n&&"\\left("===this.ctrlSeq&&t[L]instanceof Variable&&this.side===L)return t[L].autoUnItalicize(t);if(!n&&"\\left("===this.ctrlSeq&&t[L]instanceof SupSub&&this.side===L&&"sub"===t[L].supsub&&t[L].sub.ends[R]instanceof Variable)return t.insAtRightEnd(t[L].sub),t[L].autoUnItalicize(t);if(!n&&"\\left["===this.ctrlSeq&&0===t[L]&&0===t[R]&&"undefined"!=typeof t.parent.parent&&t.parent.parent.ctrlSeq===this.ctrlSeq)return r=t.parent.parent[L],a=t.parent.parent.parent,t.parent.parent.unwrap(),0!==r?t.insRightOf(r):t.insAtLeftEnd(a),o=Matrix("\\bmatrix",1,1),void o.createLeftOf(t)}n?(l=this.side=-n.side,this.closeOpposing(n),n===t.parent.parent&&t[l]&&(Fragment(t[l],t.parent.ends[l],-l).disown().withDirAdopt(-l,n.parent,n,n[l]).jQ.insDirOf(l,n.jQ),n.bubble("reflow"))):(n=this,l=n.side,n.replacedFragment?n.side=0:t[-l]&&(n.replaces(Fragment(t[-l],t.parent.ends[-l],l)),t[-l]=0),e.createLeftOf.call(n,t)),l===L?t.insAtLeftEnd(n.ends[L]):t.insRightOf(n),t.workingGroupChange()},t.placeCursor=noop,t.unwrap=function(){this.ends[L].children().disown().adopt(this.parent,this,this[R]).jQ.insertAfter(this.jQ),this.remove()},t.deleteSide=function(t,e,n){var i,s=this.parent,r=this[t],a=s.ends[t];return t===this.side?(this.unwrap(),void(r?n.insDirOf(-t,r):n.insAtDirEnd(t,s))):(this.side=-t,void(this.oppBrack(this.ends[L].ends[this.side],t)?(this.closeOpposing(this.ends[L].ends[this.side]),i=this.ends[L].ends[t],this.unwrap(),i.siblingCreated&&i.siblingCreated(n.options,t),r?n.insDirOf(-t,r):n.insAtDirEnd(t,s)):(this.oppBrack(this.parent.parent,t)?(this.parent.parent.closeOpposing(this),this.parent.parent.unwrap()):(this.sides[t]={ch:OPP_BRACKS[this.sides[this.side].ch],ctrlSeq:OPP_BRACKS[this.sides[this.side].ctrlSeq]},this.delimjQs.removeClass("mq-ghost").eq(t===L?0:1).addClass("mq-ghost").html(this.sides[t].ch)),r?(i=this.ends[L].ends[t],Fragment(r,a,-t).disown().withDirAdopt(-t,this.ends[L],i,0).jQ.insAtDirEnd(t,this.ends[L].jQ.removeClass("mq-empty")),i.siblingCreated&&i.siblingCreated(n.options,t),n.insDirOf(-t,r)):e?n.insDirOf(t,this):n.insAtDirEnd(t,this.ends[L]))))},t.deleteTowards=function(t,e){this.deleteSide(-t,!1,e)},t.finalizeTree=function(){this.setUnit(),this.ends[L].deleteOutOf=function(t,e){this.parent.deleteSide(t,!0,e)},this.finalizeTree=this.intentionalBlur=function(){this.delimjQs.eq(this.side===L?1:0).removeClass("mq-ghost"),this.side=0}},t.siblingCreated=function(t,e){e===-this.side&&this.finalizeTree()}}),OPP_BRACKS={"(":")",")":"(","[":"]","]":"[","{":"}","}":"{","\\{":"\\}","\\}":"\\{","⟨":"⟩","⟩":"⟨","\\langle ":"\\rangle ","\\rangle ":"\\langle ","|":"|"},bindCharBracketPair("("),bindCharBracketPair("["),LatexCmds.langle=bind(Bracket,L,"⟨","⟩","\\langle ","\\rangle ","(",")"),LatexCmds.rangle=bind(Bracket,R,"⟨","⟩","\\langle ","\\rangle ","(",")"),CharCmds["|"]=LatexCmds.abs=bind(Bracket,L,"|","|","|","|","abs(",")"),CharCmds["{"]=bind(Bracket,L,"{","}","\\{","\\}","(",")"),CharCmds["}"]=bind(Bracket,R,"{","}","\\{","\\}","(",")"),LatexCmds.left=P(MathCommand,function(t){t.parser=function(){var t=Parser.regex,e=Parser.string,n=(Parser.succeed,Parser.optWhitespace);return n.then(t(/^(?:[([|]|\\\{)/)).then(function(i){var s="\\"===i.charAt(0)?i.slice(1):i;return latexMathParser.then(function(r){return e("\\right").skip(n).then(t(/^(?:[\])|]|\\\})/)).map(function(t){var e="\\"===t.charAt(0)?t.slice(1):t,n="["===s?"[":"|"===s?"abs(":"(",a="["===s?"]":")",o=Bracket(0,s,e,i,t,n,a);return o.blocks=[r],r.adopt(o,0,0),o})})})}}),LatexCmds.right=P(MathCommand,function(t){t.parser=function(){return Parser.fail("unmatched \\right")}}),Binomial=LatexCmds.binom=LatexCmds.binomial=P(P(MathCommand,DelimsMixin),function(t){t.ctrlSeq="\\binom",t.htmlTemplate='<span class="mq-non-leaf"><span class="mq-paren mq-scaled">(</span><span class="mq-non-leaf"><span class="mq-array mq-non-leaf"><span>&0</span><span>&1</span></span></span><span class="mq-paren mq-scaled">)</span></span>',t.textTemplate=["choose(",",",")"]}),Currency=P(MathCommand,function(t,e){t.init=function(t,n){this.htmlTemplate="<span><span>"+n+"</span><span>&0</span></span>",this.textTemplate=[" "+n," "],e.init.call(this,t)},t.finalizeTree=function(){this.ends[L].write=function(t,e){RegExp(/[0-9\.]/).test(e)?MathBlock.p.write.apply(this,arguments):(t.insRightOf(this.parent),t.parent.write(t,e))}}}),LatexCmds.$=bind(Currency,"\\$","$"),Derivative=P(MathCommand,function(t){t.power=1,t.symbol="d",t.init=function(t,e,n){this.power=e,n&&(this.symbol="∂");var i='<span class="mq-fraction mq-non-leaf"><span class="mq-numerator"'+(this.power>1?' style="padding-top:9px;"':"")+">"+this.symbol+(this.power>1?"<sup>"+this.power+"</sup>":"")+'<span>&0</span></span><span class="mq-denominator"'+(this.power>1?' style="padding-top:9px;"':"")+">"+this.symbol+"<span>&1</span>"+(this.power>1?"<sup>"+this.power+"</sup>":"")+'</span><span style="display:inline-block;width:0"> </span></span>';Symbol.prototype.init.call(this,t,i)},t.latex=function(){return this.ctrlSeq+"_{"+this.blocks[1].latex()+"}\\left({"+this.blocks[0].latex()+"}\\right)"},t.text=function(t){var e,n=" diff("+this.blocks[0].text(t)+" , "+this.blocks[1].text(t)+")";for(e=1;e<this.power;e++)n=" diff("+n+" , "+this.blocks[1].text(t)+")";return n},t.parser=function(){var t,e=Parser.string,n=Parser.optWhitespace,i=(Parser.whitespace,Parser.succeed),s=latexMathParser.block,r=this,a=r.blocks=[MathBlock(),MathBlock()];for(t=0;t<a.length;t+=1)a[t].adopt(r,r.ends[R],0);return n.then(e("_")).then(function(){var t=a[1];return s.then(function(e){return e.children().adopt(t,t.ends[R],0),i(r)})}).then(e("\\left(")).then(function(){var t=a[0];return s.then(function(e){return e.children().adopt(t,t.ends[R],0),i(r)})}).then(e("\\right)")).result(r)}}),LatexCmds.derivative=bind(Derivative,"\\derivative ",1,!1),LatexCmds.pderivative=bind(Derivative,"\\pderivative ",1,!0),LatexCmds.derivatived=bind(Derivative,"\\derivatived ",2,!1),LatexCmds.pderivatived=bind(Derivative,"\\pderivatived ",2,!0),Fraction=LatexCmds.frac=LatexCmds.dfrac=LatexCmds.cfrac=LatexCmds.fraction=P(MathCommand,function(t){t.ctrlSeq="\\frac",t.htmlTemplate='<span class="mq-fraction mq-non-leaf"><span class="mq-numerator">&0</span><span class="mq-denominator">&1</span><span style="display:inline-block;width:0"> </span></span>',t.textTemplate=["((",")/(","))"],t.finalizeTree=function(){this.setUnit(),this.jQ.closest(".mq-editable-field").children(".mq-popup").remove(),this.upInto=this.ends[R].upOutOf=this.ends[L],this.downInto=this.ends[L].downOutOf=this.ends[R],this.blocks[1].ends[L]&&"."===this.blocks[1].ends[L].ctrlSeq&&(this.blocks[1].ends[L].remove(),this.elementWise=!0),this.elementWise&&(this.jQ.wrap("<span class='mq-fraction-elementwise'></span>"),this.jQ=this.jQ.parent())},t.text=function(t){return"(("+this.blocks[0].text(t)+")"+(this.elementWise?".":"")+"/("+this.blocks[1].text(t)+"))"},t.latex=function(){return this.ctrlSeq+"{"+this.blocks[0].latex()+"}{"+(this.elementWise?".":"")+this.blocks[1].latex()+"}"}}),LiveFraction=LatexCmds.over=CharCmds["/"]=P(Fraction,function(t,e){t.createLeftOf=function(t){var n,i,s,r;if(!this.replacedFragment){if(t[L]&&"."===t[L].ctrlSeq&&t[L][L]){for(n=[t[L]],t[L][L]&&t[L][L][L]&&t[L][L][L][L]&&"0"===t[L][L].ctrlSeq&&"\\cdot "===t[L][L][L].ctrlSeq?(n.push(t[L][L]),n.push(t[L][L][L]),i=t[L][L][L][L]):i=t[L][L],s=0;s<n.length;s++)n[s].remove();this.elementWise=!0,t.insRightOf(i)}for(r=t[L];r&&!(r instanceof BinaryOperator||r instanceof(LatexCmds.text||noop)||r instanceof SummationNotation||"\\ "===r.ctrlSeq||/^[,;:]$/.test(r.ctrlSeq));)r=r[L];r instanceof SummationNotation&&r[R]instanceof SupSub&&(r=r[R],r[R]instanceof SupSub&&r[R].ctrlSeq!=r.ctrlSeq&&(r=r[R])),r!==t[L]&&(this.replaces(Fragment(r[R]||t.parent.ends[L],t[L])),t[L]=r)}e.createLeftOf.call(this,t)}}),Choose=LatexCmds.choose=P(Binomial,function(t){t.createLeftOf=LiveFraction.prototype.createLeftOf}),FunctionCommand=LatexCmds.functionCommand=P(DerivedMathCommand,function(_,super_){_.ctrlSeq="FunctionCommand{...}{...}",_.htmlTemplate="<span><span>&0</span><span>.</span><span>&1</span></span>",_.init=function(t){"functionCommand"!==t&&(this.incorporate_previous=t),super_.init.call(this)},_.text=function(t){return this.blocks[0].text(t)+"__"+this.blocks[1].text(t)},_.latex=function(){return"\\functionCommand{"+this.blocks[0].latex()+"}{"+this.blocks[1].latex()+"}"},_.finalizeTree=function(){this.ends[R].write=function(t,e){RegExp(/[A-Za-z0-9_\(]/).test(e)?MathBlock.p.write.apply(this,arguments):(t[L]instanceof Variable&&t[L].autoOperator(t),t.insRightOf(this.parent),t.parent.write(t,e))}},_.getObject=function(){if(this.saved_object)return this.saved_object;if(this.saved_object=SC_Objects[this.objectName()],"string"==typeof this.saved_object)SC_Objects[this.objectName()]=eval(this.saved_object),this.saved_object=SC_Objects[this.objectName()];else if("undefined"==typeof this.saved_object)return this.saved_object=!1,SC_Object();return this.saved_object},_.objectName=function(){return this.blocks[0].text({})},_.createLeftOf=function(t){if(super_.createLeftOf.apply(this,arguments),"undefined"!=typeof this.incorporate_previous){var e=this[L];if(0===e)return;if(0===e[L])return;for(next=e[L];0!==next&&next instanceof Variable;next=e[L])next.disown().adopt(this.ends[L],0,this.ends[L].ends[L]),next.jQ.prependTo(this.ends[L].jQ);e.remove(),t.insAtLeftEnd(this.ends[R]),this.incorporate_previous!==!0&&Letter(this.incorporate_previous).createLeftOf(t)}}}),Integral=P(MathCommand,function(t){t.init=function(t){var e='<span><span class="mq-large-operator mq-non-leaf"><span class="mq-to"> <span>&1</span></span><big>∫</big><span class="mq-from"><span>&0</span></span></span><span class="mq-non-leaf"><span class="mq-non-leaf">&2</span>d<span class="mq-non-leaf">&3</span></span></span>';Symbol.prototype.init.call(this,t,e)},t.reflow=function(){{var t=(this.jQ.children(":first").children("big"),this.jQ.children(":last").children(":first"));t.outerHeight()/parseInt(t.css("fontSize"),10)}},t.latex=function(){return this.ctrlSeq+"_{"+this.blocks[0].latex()+"}^{"+this.blocks[1].latex()+"}_{"+this.blocks[3].latex()+"}\\left({"+this.blocks[2].latex()+"}\\right)"},t.text=function(t){return" int("+this.blocks[2].text(t)+" , "+this.blocks[3].text(t)+","+this.blocks[0].text(t)+","+this.blocks[1].text(t)+")"},t.parser=function(){var t,e=Parser.string,n=Parser.optWhitespace,i=(Parser.whitespace,Parser.succeed),s=latexMathParser.block,r=this,a=r.blocks=[MathBlock(),MathBlock(),MathBlock(),MathBlock()];for(t=0;t<a.length;t+=1)a[t].adopt(r,r.ends[R],0);return n.then(e("_")).then(function(){var t=a[0];return s.then(function(e){return e.children().adopt(t,t.ends[R],0),i(r)})}).then(n).then(e("^")).then(function(){var t=a[1];return s.then(function(e){return e.children().adopt(t,t.ends[R],0),i(r)})}).then(n).then(e("_")).then(function(){var t=a[3];return s.then(function(e){return e.children().adopt(t,t.ends[R],0),i(r)})}).then(e("\\left(")).then(function(){var t=a[2];return s.then(function(e){return e.children().adopt(t,t.ends[R],0),i(r)})}).then(e("\\right)")).result(r)},t.finalizeTree=function(){this.downInto=this.ends[L],this.upInto=this.ends[R],this.ends[L].upOutOf=this.ends[R],this.ends[R].downOutOf=this.ends[L]}}),LatexCmds["∫"]=LatexCmds["int"]=LatexCmds.integral=bind(Integral,"\\int "),IntegralNoLimit=P(MathCommand,function(t){t.init=function(t){var e='<span><span class="mq-large-operator mq-non-leaf"><big>∫</big></span><span class="mq-non-leaf"><span class="mq-non-leaf">&0</span>d<span class="mq-non-leaf">&1</span></span></span>';Symbol.prototype.init.call(this,t,e)},t.reflow=function(){{var t=(this.jQ.children(":first").children("big"),this.jQ.children(":last").children(":first"));t.outerHeight()/parseInt(t.css("fontSize"),10)}},t.latex=function(){return this.ctrlSeq+"_{"+this.blocks[1].latex()+"}\\left({"+this.blocks[0].latex()+"}\\right)"},t.text=function(t){return" int("+this.blocks[0].text(t)+" , "+this.blocks[1].text(t)+")"},t.parser=function(){var t,e=Parser.string,n=Parser.optWhitespace,i=(Parser.whitespace,Parser.succeed),s=latexMathParser.block,r=this,a=r.blocks=[MathBlock(),MathBlock()];for(t=0;t<a.length;t+=1)a[t].adopt(r,r.ends[R],0);return n.then(e("_")).then(function(){var t=a[0];return s.then(function(e){return e.children().adopt(t,t.ends[R],0),i(r)})}).then(e("\\left(")).then(function(){var t=a[2];return s.then(function(e){return e.children().adopt(t,t.ends[R],0),i(r)
|
3
|
+
})}).then(e("\\right)")).result(r)},t.finalizeTree=function(){this.downInto=this.ends[L],this.upInto=this.ends[R],this.ends[L].upOutOf=this.ends[R],this.ends[R].downOutOf=this.ends[L]}}),LatexCmds.intn=bind(IntegralNoLimit,"\\intn "),LatexCommandInput=CharCmds["\\"]=P(MathCommand,function(t,e){t.ctrlSeq="\\",t.replaces=function(t){this._replacedFragment=t.disown(),this.isEmpty=function(){return!1}},t.htmlTemplate='<span class="mq-latex-command-input mq-non-leaf">\\<span>&0</span></span>',t.textTemplate=["\\"],t.createBlocks=function(){e.createBlocks.call(this),this.ends[L].focus=function(){return this.parent.jQ.addClass("mq-hasCursor"),this.isEmpty()&&this.parent.jQ.removeClass("mq-empty"),this},this.ends[L].blur=function(){return this.parent.jQ.removeClass("mq-hasCursor"),this.isEmpty()&&this.parent.jQ.addClass("mq-empty"),this},this.ends[L].write=function(t,e,n){return n&&n.remove(),0==this.parent.ends[L].latex().indexOf("matrix")?void(/^matrix\dx\d$/.test(this.parent.ends[L].latex())?(this.parent.renderCommand(t),"\\"===e&&this.isEmpty()||this.parent.parent.write(t,e)):VanillaSymbol(e).createLeftOf(t)):void(e.match(/[a-z]/i)?VanillaSymbol(e).createLeftOf(t):(this.parent.renderCommand(t),"\\"===e&&this.isEmpty()||this.parent.parent.write(t,e)))},this.ends[L].keystroke=function(t,n,i){return"Tab"===t||"Enter"===t||"Spacebar"===t?(this.parent.renderCommand(i.cursor),void n.preventDefault()):e.keystroke.apply(this,arguments)}},t.createLeftOf=function(t){if(e.createLeftOf.call(this,t),this._replacedFragment){var n=this.jQ[0];this.jQ=this._replacedFragment.jQ.addClass("mq-blur").bind("mousedown mousemove",function(t){return $(t.target=n).trigger(t),!1}).insertBefore(this.jQ).add(this.jQ)}},t.latex=function(){return"\\"+this.ends[L].latex()+" "},t.renderCommand=function(t){var e,n,i;if(this.jQ=this.jQ.last(),this.remove(),this[R]?t.insLeftOf(this[R]):t.insAtRightEnd(this.parent),e=this.ends[L].latex(),e||(e=" "),n=LatexCmds[e])n=n(e),this._replacedFragment&&n.replaces(this._replacedFragment),n.createLeftOf(t);else{for(n=OperatorName(),this._replacedFragment&&n.replaces(this._replacedFragment),n.createLeftOf(t),t.insAtRightEnd(n.blocks[0]),i=0;i<e.length;i++)Letter(e[i]).createLeftOf(t);t.insAtRightEnd(n.blocks[1])}t.workingGroupChange()}}),Limit=P(MathCommand,function(t){t.direction=0,t.init=function(t,e){this.direction=e;var n='<span><span class="mq-large-operator mq-non-leaf"><big>lim</big><span class="mq-from"><span>&0</span>→<span>&1</span>'+(0==e?"":1==e?"+":"-")+'</span></span><span class="mq-non-leaf"><span class="mq-scaled mq-paren">(</span><span class="mq-non-leaf">&2</span><span class="mq-scaled mq-paren">)</span></span></span>';Symbol.prototype.init.call(this,t,n)},t.reflow=function(){var t=this.jQ.children(":last").children(":first").add(this.jQ.children(":last").children(":last")),e=this.jQ.children(":last").children(":eq(1)"),n=e.outerHeight()/parseInt(e.css("fontSize"),10);scale(t,min(1+.2*(n-1),1.2),1.05*n)},t.latex=function(){return this.ctrlSeq+"_{"+this.blocks[0].latex()+"}^{"+this.blocks[1].latex()+"}\\left({"+this.blocks[2].latex()+"}\\right)"},t.text=function(t){var e=" limit("+this.blocks[2].text(t)+" , "+this.blocks[0].text(t)+" , "+this.blocks[1].text(t);return 0!=this.direction&&(e+=", "+this.direction),e+")"},t.parser=function(){var t,e=Parser.string,n=Parser.optWhitespace,i=(Parser.whitespace,Parser.succeed),s=latexMathParser.block,r=this,a=r.blocks=[MathBlock(),MathBlock(),MathBlock()];for(t=0;t<a.length;t+=1)a[t].adopt(r,r.ends[R],0);return n.then(e("_")).then(function(){var t=a[0];return s.then(function(e){return e.children().adopt(t,t.ends[R],0),i(r)})}).then(e("^")).then(function(){var t=a[1];return s.then(function(e){return e.children().adopt(t,t.ends[R],0),i(r)})}).then(e("\\left(")).then(function(){var t=a[2];return s.then(function(e){return e.children().adopt(t,t.ends[R],0),i(r)})}).then(e("\\right)")).result(r)}}),LatexCmds.limit=bind(Limit,"\\limit ",0),LatexCmds.limitn=bind(Limit,"\\limitn ",-1),LatexCmds.limitp=bind(Limit,"\\limitp ",1),Matrix=LatexCmds.begin=P(MathCommand,function(t,e){t.numBlocks=function(){return this.col*this.row},t.init=function(t,n,i){var s,r,a,o;for(this.col=n,this.row=i,this.ctrlSeq=t,s="",r=0;i>r;r++){for(a="",o=0;n>o;o++)a+='<span class="mq-cell">&'+(r*n+o)+"</span>";s+='<span class="mq-row">'+a+"</span>"}switch(this.ctrlSeq){case"\\pmatrix":s='<span class="mq-scaled mq-paren">(</span><span class="mq-matrix">'+s+'</span><span class="mq-scaled mq-paren">)</span>';break;case"\\bmatrix":s='<span class="mq-scaled mq-paren">[</span><span class="mq-matrix">'+s+'</span><span class="mq-scaled mq-paren">]</span>';break;case"\\Bmatrix":s='<span class="mq-scaled mq-paren">{</span><span class="mq-matrix">'+s+'</span><span class="mq-scaled mq-paren">}</span>';break;case"\\vmatrix":s='<span class="mq-scaled mq-paren">|</span><span class="mq-matrix">'+s+'</span><span class="mq-scaled mq-paren">|</span>';break;case"\\Vmatrix":s='<span class="mq-scaled mq-paren">||</span><span class="mq-matrix">'+s+'</span><span class="mq-scaled mq-paren">||</span>';break;default:s='<span class="mq-matrix">'+s+"</span>"}e.init.call(this,this.ctrlSeq,'<span class="mq-matrix-outer mq-non-leaf">'+s+"</span>",["text"])},t.reflow=function(){var t=this.jQ.children(".mq-paren"),e=this.jQ.children(".mq-matrix").first(),n=e.outerHeight()/(1.133333*parseInt(e.css("fontSize"),10));scale(t,min(1+.2*(n-1),1.2),1.05*n),t.css("position","relative"),t.css("top",Math.round(.6*n)+"px")},t.contextMenuOLD=function(t,e){var n=this,i=[{text:"Insert Column Before",handler:function(){n.insertColumn(t,L)}},{text:"Insert Column After",handler:function(){n.insertColumn(t,R)}},{text:"Insert Row Before",handler:function(){n.insertRow(t,L)}},{text:"Insert Row After",handler:function(){n.insertRow(t,R)}}];this.col>1&&i.push({text:"Delete Column",handler:function(){n.deleteColumn(t)}}),this.row>1&&i.push({text:"Delete Row",handler:function(){n.deleteRow(t)}}),this.showPopupMenu(i,e)},t.latex=function(){var t="",e=1,n=this.col,i=this.numBlocks(),s=this.ctrlSeq.substring(1,this.ctrlSeq.length);return this.eachChild(function(s){s.ends[L]&&(t+=s.latex()),e!=i&&(t+=e%n==0?" \\\\ ":" & "),e++}),"\\begin{"+s+"}"+t+"\\end{"+s+"}"},t.text=function(t){var e,n,i=[];for(this.eachChild(function(e){i.push(e.ends[L]?e.text(t):0)}),e="",n=0;n<i.length;n++)n>0&&n%this.col==0?e+="],[":n>0&&(e+=","),e+=i[n];return this.row>1?"[["+e+"]]":"["+e+"]"},t.parser=function(){var t=Parser.regex;return t(/^\{[pbvBV]?matrix\}[\s\S]*?\\end\{[pbvBV]?matrix\}/).map(function(t){var e,n,i,s,r,a,o,l,c;for("}"==t.substring(7,1)?(e=t.substring(1,7),t=t.substring(8,t.length-12).trim()):(e=t.substring(1,8),t=t.substring(9,t.length-13).trim()),n=t.split(/\\\\/).map(function(t){return t.trim()}),i=n.length,s=0,r=[],n.forEach(function(t){var e=t.split(/&/);s=Math.max(s,e.length),r=r.concat(e)}),a=Matrix("\\"+e,s,i),o=a.blocks=Array(a.numBlocks()),l=0;l<o.length;l++)c=o[l]=latexMathParser.parse(r[l]),c.deleteOutOf=MatrixMathBlock().deleteOutOf,c.adopt(a,a.ends[R],0);return a})},t.finalizeTree=function(){var t,e,n;for(t=0;t<this.row;t++)for(e=0;e<this.col;e++)n=this.blocks[t*this.col+e],n.upOutOf=0==t&&0!=e?this.blocks[this.row*this.col-this.row+e-1]:this.blocks[(t-1)*this.col+e],n.downOutOf=t+1==this.row&&e+1!=this.col?this.blocks[e+1]:this.blocks[(t+1)*this.col+e]},t.cursorRowCol=function(t){for(var e=0,n=0,i=t.parent;0!==i[L];)e++,e==this.col&&(e=0,n++),i=i[L];return{row:n,col:e}},t.deleteRow=function(t){var e,n,i;if(1!=this.row){for(e=this.cursorRowCol(t),n=e.row*this.col,i=0;i<this.col;i++)this.blocks[n].remove(),this.blocks.splice(n,1);n>0&&n<this.blocks.length?(this.blocks[n][L]=this.blocks[n-1],this.blocks[n-1][R]=this.blocks[n]):0==n?this.blocks[n][L]=0:this.blocks[n-1][R]=0,this.jQ.children(".mq-matrix").first().children(".mq-row").eq(e.row).remove(),this.row--,this.finalizeTree(),t.insAtLeftEnd(this.blocks[e.row>0?(e.row-1)*this.col+e.col:e.col]),this.reflow(),t.workingGroupChange()}},t.deleteColumn=function(t){var e,n,i;if(1!=this.col){for(e=this.cursorRowCol(t),n=e.col,i=0;i<this.row;i++)this.blocks[n].remove(),this.blocks.splice(n,1),n>0&&n<this.blocks.length?(this.blocks[n][L]=this.blocks[n-1],this.blocks[n-1][R]=this.blocks[n]):0==n?this.blocks[n][L]=0:this.blocks[n-1][R]=0,n+=this.col-1;this.col--,this.finalizeTree(),t.insAtLeftEnd(this.blocks[e.col<this.col?e.row*this.col+e.col:e.row*this.col+e.col-1]),this.reflow(),t.workingGroupChange()}},t.createBlocks=function(){var t,e,n=this,i=n.numBlocks(),s=n.blocks=Array(i);for(t=0;i>t;t+=1)e=s[t]=MatrixMathBlock(),e.adopt(n,n.ends[R],0)},t.insertRow=function(t,e){var n,i,s,r,a=this.cursorRowCol(t);for(n="undefined"==typeof e?0===t[L]&&0!==t[R]:e==L?!0:!1,i=a.row*this.col+(n?0:this.col),n?this.jQ.children(".mq-matrix").first().children(".mq-row").eq(a.row).before('<span class="mq-row"></span>'):this.jQ.children(".mq-matrix").first().children(".mq-row").eq(a.row).after('<span class="mq-row"></span>'),s=0;s<this.col;s++)r=MatrixMathBlock(),r.adopt(this,i+s>0?this.blocks[i+s-1]:0,i+s>0?this.blocks[i+s-1][R]:this.ends[L]),r.jQ=$('<span class="mq-cell mq-empty" '+mqBlockId+'="'+r.id+'"></span>'),i+s>0&&(this.blocks[i+s-1][R]=r),this.blocks.splice(i+s,0,r),this.jQ.children(".mq-matrix").first().children(".mq-row").eq(a.row+(n?0:1)).append(r.jQ);i+s<this.blocks.length&&(this.blocks[i+s][L]=r,r[R]=this.blocks[i+s]),this.row++,this.finalizeTree(),t.insAtLeftEnd(this.blocks[i]),this.reflow(),t.workingGroupChange()},t.insertColumn=function(t,e){var n,i,s,r=this.cursorRowCol(t);for(n="undefined"==typeof e?0===t[L]&&0!==t[R]:e==L?!0:!1,i=this.row-1;i>=0;i--)s=MatrixMathBlock(),n?(s.adopt(this,i*this.col+r.col-1>=0?this.blocks[i*this.col+r.col-1]:0,this.blocks[i*this.col+r.col]),s.jQ=$('<span class="mq-cell mq-empty" '+mqBlockId+'="'+s.id+'"></span>'),i*this.col+r.col-1>=0&&(this.blocks[i*this.col+r.col-1][R]=s),this.blocks[i*this.col+r.col][L]=s,this.blocks.splice(i*this.col+r.col,0,s),this.jQ.children(".mq-matrix").first().children(".mq-row").eq(i).children(".mq-cell").eq(r.col).before(s.jQ)):(s.adopt(this,this.blocks[i*this.col+r.col],i*this.col+r.col+1<this.row*this.col?this.blocks[i*this.col+r.col+1]:0),s.jQ=$('<span class="mq-cell mq-empty" '+mqBlockId+'="'+s.id+'"></span>'),this.blocks[i*this.col+r.col][R]=s,i*this.col+r.col+1<this.row*this.col&&(this.blocks[i*this.col+r.col+1][L]=s),this.blocks.splice(i*this.col+r.col+1,0,s),this.jQ.children(".mq-matrix").first().children(".mq-row").eq(i).children(".mq-cell").eq(r.col).after(s.jQ));this.col++,this.finalizeTree(),t.insAtLeftEnd(t.parent[n?L:R]),this.reflow(),t.workingGroupChange()},t.moveOrInsertColumn=function(t){var e=this.cursorRowCol(t);return e.col+1==this.col?this.insertColumn(t):(t.insAtLeftEnd(t.parent[R]),void t.workingGroupChange())}}),LatexCmds.matrix=bind(Matrix,"\\matrix",1,1),LatexCmds.bmatrix=bind(Matrix,"\\bmatrix",1,1),LatexCmds.Bmatrix=bind(Matrix,"\\Bmatrix",1,1),LatexCmds.vmatrix=bind(Matrix,"\\vmatrix",1,1),LatexCmds.Vmatrix=bind(Matrix,"\\Vmatrix",1,1),LatexCmds.pmatrix=bind(Matrix,"\\pmatrix",1,1),MatrixMathBlock=P(MathBlock,function(t){t.deleteOutOf=function(t,e){var n,i,s,r,a;if(0===this.ends[L])n=t===L?this[L]:this[R],this.parent.deleteColumn(e),t===L&&(n?e.insAtRightEnd(n):n&&e.insAtLeftEnd(n));else if(i=this[t],s=this.parent.cursorRowCol(e),t===L&&0===s.col&&(i=0),t===R&&s.col+1===this.parent.col&&(i=0),0===i)this.parent[L]?(r=this.parent[L],this.parent.remove(),e.insRightOf(r)):(r=this.parent.parent,this.parent.remove(),e.insAtLeftEnd(r));else{for(a=i.ends[L];0!==a;a=a[R])a.remove();e.insAtRightEnd(i),this.parent.deleteColumn(e),t===L?e.insAtLeftEnd(this):e.insAtRightEnd(this)}}}),OperatorName=LatexCmds.operatorname=P(MathCommand,function(t,e){t.htmlTemplate='<span><span class="mq-operator-name">&0</span><span class="mq-non-leaf"><span class="mq-scaled mq-paren">(</span><span class="mq-non-leaf">&1</span><span class="mq-scaled mq-paren">)</span></span></span>',t.init=function(t){e.init.call(this,t)},t.createLeftOf=function(t){e.createLeftOf.apply(this,arguments),t.insAtRightEnd(this.blocks[1])},t.reflow=function(){var t=this.jQ.children(":last").children(":first").add(this.jQ.children(":last").children(":last")),e=this.jQ.children(":last").children(":eq(1)"),n=e.outerHeight()/parseInt(e.css("fontSize"),10);scale(t,min(1+.2*(n-1),1.2),1.05*n)},t.text=function(t){return"undefined"!=typeof t.operatorNameTextOutput?t.operatorNameTextOutput(this,this.blocks[0].text(t),this.blocks[1].text(t)):this.blocks[0].text(t)+"("+this.blocks[1].text(t)+")"},t.latex=function(){return BuiltInOpNames.hasOwnProperty(this.blocks[0].text())?"\\"+this.blocks[0].latex()+"\\left({"+this.blocks[1].latex()+"}\\right)":"\\operatorname{"+this.blocks[0].latex()+"}\\left({"+this.blocks[1].latex()+"}\\right)"},t.parser=function(){var t,e=Parser.string,n=Parser.optWhitespace,i=Parser.succeed,s=latexMathParser.block,r=this.ctrlSeq,a=this,o=a.blocks=[MathBlock(),MathBlock()];for(t=0;t<o.length;t+=1)o[t].adopt(a,a.ends[R],0);if(BuiltInOpNames.hasOwnProperty(this.ctrlSeq)){for(t=0;t<r.length;t+=1)Letter(r.charAt(t)).adopt(this.ends[L],this.ends[L].ends[R],0);return n.then(e("\\left(")).then(function(){var t=o[1];return s.then(function(e){return e.children().adopt(t,t.ends[R],0),i(a)})}).then(e("\\right)")).result(a)}return n.then(function(){var t=o[0];return s.then(function(e){var n,s;for(e.children().adopt(t,t.ends[R],0),n=e.ends[L];0!==n;n=n[R])if("f"===n.ctrlSeq)n.htmlTemplate="<var>f</var>";else if(n instanceof SupSub&&"sub"===n.supsub)for(s=n.blocks[0].ends[L];0!==s;s=s[R])"f"===s.ctrlSeq&&(s.htmlTemplate="<var>f</var>");return i(a)})}).then(e("\\left(")).then(function(){var t=o[1];return s.then(function(e){return e.children().adopt(t,t.ends[R],0),i(a)})}).then(e("\\right)")).result(a)}});for(fn in BuiltInOpNames)BuiltInOpNames.hasOwnProperty(fn)&&(LatexCmds[fn]=OperatorName);SquareRoot=LatexCmds.sqrt=LatexCmds["√"]=P(MathCommand,function(t,e){t.ctrlSeq="\\sqrt",t.htmlTemplate='<span class="mq-non-leaf"><span class="mq-scaled mq-sqrt-prefix">√</span><span class="mq-non-leaf mq-sqrt-stem">&0</span></span>',t.textTemplate=[" sqrt(",")"],t.parser=function(){return latexMathParser.optBlock.then(function(t){return latexMathParser.block.map(function(e){var n=NthRoot();return n.blocks=[t,e],t.adopt(n,0,0),e.adopt(n,t,0),n})}).or(e.parser.call(this))},t.reflow=function(){var t=this.ends[R].jQ;scale(t.prev(),1,t.innerHeight()/+t.css("fontSize").slice(0,-2)-.1)}}),NthRoot=LatexCmds.nthroot=P(SquareRoot,function(t){t.htmlTemplate='<sup class="mq-nthroot mq-non-leaf">&0</sup><span class="mq-scaled"><span class="mq-sqrt-prefix mq-scaled">√</span><span class="mq-sqrt-stem mq-non-leaf">&1</span></span>',t.textTemplate=["sqrt[","](",")"],t.latex=function(){return"\\sqrt["+this.ends[L].latex()+"]{"+this.ends[R].latex()+"}"},t.text=function(t){return" "+this.ends[R].text(t)+"^(1/"+this.ends[L].text(t)+")"}}),ScientificNotation=LatexCmds.scientificNotation=LatexCmds.scientificNotationToolbar=P(DerivedMathCommand,function(t,e){t.ctrlSeq="ScientificNotation{...}{...}",t.htmlTemplate='<span><span>&0</span><span style="font-size:0.7em;">×</span><span>10</span><span class="mq-supsub mq-non-leaf mq-sup-only"><span class="mq-sup">&1</span></span></span>',t.init=function(t){"scientificNotation"!==t&&(this.incorporate_previous=t),e.init.call(this)},t.text=function(t){return this.blocks[0].text(t)+"e"+this.blocks[1].text(t)},t.latex=function(){return"\\scientificNotation{"+this.blocks[0].latex()+"}{"+this.blocks[1].latex()+"}"},t.finalizeTree=function(){this.downInto=this.ends[L],this.upInto=this.ends[R],this.ends[L].upOutOf=this.ends[R],this.ends[R].downOutOf=this.ends[L],this.ends[L].write=function(t,e){RegExp(/[0-9]/).test(e)?MathBlock.p.write.apply(this,arguments):(t.insRightOf(this.parent),t.parent.write(t,e))},this.ends[R].write=function(t,e){if(RegExp(/[0-9\+\-]/).test(e))if("+"===e||"-"===e){if(0===t[L]&&0!==t[R]&&("-"===t[R].ctrlSeq||"+"===t[R].ctrlSeq))return t[R].ctrlSeq=e,t[R].textTemplate=e,void t[R].jQ.html(e);if(0!==t[L]&&0===t[L][L]&&("-"===t[L].ctrlSeq||"+"===t[L].ctrlSeq))return t[L].ctrlSeq=e,t[L].textTemplate=e,void t[L].jQ.html(e);0!==t[L]&&(t.insRightOf(this.parent),t.parent.write(t,e))}else MathBlock.p.write.apply(this,arguments);else t.insRightOf(this.parent),t.parent.write(t,e)}},t.createLeftOf=function(t){var n,i;if(e.createLeftOf.apply(this,arguments),"scientificNotationToolbar"===this.incorporate_previous){for(n=!1,next=this[L];0!==next&&"undefined"!=typeof next.ctrlSeq&&next.ctrlSeq.match(/^[0-9\.]$/);next=this[L])next.disown().adopt(this.ends[L],0,this.ends[L].ends[L]),next.jQ.prependTo(this.ends[L].jQ),n=!0;n&&t.insAtLeftEnd(this.ends[R])}else if("undefined"!=typeof this.incorporate_previous){if(i=this[L],0===i)return;if(0===i[L])return;for(next=i[L];0!==next&&"undefined"!=typeof next.ctrlSeq&&next.ctrlSeq.match(/^[0-9\.]$/);next=i[L])next.disown().adopt(this.ends[L],0,this.ends[L].ends[L]),next.jQ.prependTo(this.ends[L].jQ);i.remove(),t.insAtLeftEnd(this.ends[R]),this.ends[R].write(t,this.incorporate_previous)}}}),SummationNotation=P(MathCommand,function(t){t.hide_limits=!1,t.init=function(t,e){var n='<span><span class="mq-large-operator mq-non-leaf">'+(this.hide_limits?"":'<span class="mq-to"><span>&2</span></span>')+"<big>"+e+'</big><span class="mq-from"><span>&0</span>'+(this.hide_limits?"":"=<span>&1</span>")+'</span></span><span class="mq-non-leaf"><span class="mq-scaled mq-paren">(</span><span class="mq-non-leaf">'+(this.hide_limits?"&1":"&3")+'</span><span class="mq-scaled mq-paren">)</span></span></span>';Symbol.prototype.init.call(this,t,n)},t.reflow=function(){var t=this.jQ.children(":last").children(":first").add(this.jQ.children(":last").children(":last")),e=this.jQ.children(":last").children(":eq(1)"),n=e.outerHeight()/parseInt(e.css("fontSize"),10);scale(t,min(1+.2*(n-1),1.2),1.05*n)},t.latex=function(){return this.hide_limits?this.ctrlSeq+"_{"+this.blocks[0].latex()+"}\\left({"+this.blocks[1].latex()+"}\\right)":this.ctrlSeq+"_{"+this.blocks[0].latex()+"}^{"+this.blocks[1].latex()+"}_{"+this.blocks[2].latex()+"}\\left({"+this.blocks[3].latex()+"}\\right)"},t.text=function(t){return this.hide_limits?" "+("\\sumn "==this.ctrlSeq?"sum":"product")+"("+this.blocks[1].text(t)+", "+this.blocks[0].text(t)+")":" "+("\\sum "==this.ctrlSeq?"sum":"product")+"("+this.blocks[3].text(t)+", "+this.blocks[0].text(t)+" , "+this.blocks[1].text(t)+" , "+this.blocks[2].text(t)+")"},t.parser=function(){var t,e,n=Parser.string,i=Parser.optWhitespace,s=(Parser.whitespace,Parser.succeed),r=latexMathParser.block,a=this;for(t=a.blocks=this.hide_limits?[MathBlock(),MathBlock()]:[MathBlock(),MathBlock(),MathBlock(),MathBlock()],e=0;e<t.length;e+=1)t[e].adopt(a,a.ends[R],0);return this.hide_limits?i.then(n("_")).then(function(){var e=t[0];return r.then(function(t){return t.children().adopt(e,e.ends[R],0),s(a)})}).then(n("\\left(")).then(function(){var e=t[1];return r.then(function(t){return t.children().adopt(e,e.ends[R],0),s(a)})}).then(n("\\right)")).result(a):i.then(n("_")).then(function(){var e=t[0];return r.then(function(t){return t.children().adopt(e,e.ends[R],0),s(a)})}).then(i).then(n("^")).then(function(){var e=t[1];return r.then(function(t){return t.children().adopt(e,e.ends[R],0),s(a)})}).then(i).then(n("_")).then(function(){var e=t[2];return r.then(function(t){return t.children().adopt(e,e.ends[R],0),s(a)})}).then(n("\\left(")).then(function(){var e=t[3];return r.then(function(t){return t.children().adopt(e,e.ends[R],0),s(a)})}).then(n("\\right)")).result(a)},t.finalizeTree=function(){this.downInto=this.ends[L],this.upInto=this.ends[R],this.ends[L].upOutOf=this.ends[R],this.ends[R].downOutOf=this.ends[L]}}),SummationNotationNoLimits=P(SummationNotation,function(t,e){t.init=function(){this.hide_limits=!0,e.init.apply(this,arguments)}}),LatexCmds["∑"]=LatexCmds.sum=LatexCmds.summation=bind(SummationNotation,"\\sum ","∑"),LatexCmds.sumn=bind(SummationNotationNoLimits,"\\sumn ","∑"),LatexCmds["∏"]=LatexCmds.prod=LatexCmds.product=bind(SummationNotation,"\\prod ","∏"),LatexCmds.coprod=LatexCmds.coproduct=bind(SummationNotation,"\\coprod ","∐"),SupSub=P(MathCommand,function(t,e){t.ctrlSeq="_{...}^{...}",t.createLeftOf=function(t){var n,i,s,r,a,o,l,c;if("sub"===this.supsub){if(!(t[L]instanceof Variable))return t.parent.flash();t[L]instanceof Variable&&t[R]instanceof Variable&&(n=LatexCmds.cdot(),n.createLeftOf(t),t.insLeftOf(n))}else{if(0===t[L]||t[L]instanceof BinaryOperator)return t.parent.flash();if("."===t[L].ctrlSeq&&t[L][L]){for(i=[t[L]],t[L][L]&&t[L][L][L]&&t[L][L][L][L]&&"0"===t[L][L].ctrlSeq&&"\\cdot "===t[L][L][L].ctrlSeq?(i.push(t[L][L]),i.push(t[L][L][L]),s=t[L][L][L][L]):s=t[L][L],r=0;r<i.length;r++)i[r].remove();this.elementWise=!0,t.insRightOf(s)}if((t[L]instanceof Fraction||t[L]instanceof DerivedMathCommand)&&(a=CharCmds["("](),o=t[L],a.createLeftOf(t),o.disown(),o.adopt(a.ends[L],0,0),o.jQ.prependTo(a.ends[L].jQ),l=CharCmds[")"](),l.createLeftOf(t),a.reflow()),t[L]instanceof SupSub&&"sup"===t[L].supsub){for(a=CharCmds["("](),o=[t[L]],c=t[L];!(c instanceof BinaryOperator)&&0!==c;c=c[L])o.push(c);for(a.createLeftOf(t),r=0;r<o.length;r++)o[r].disown(),o[r].adopt(a.ends[L],0,a.ends[L].ends[L]),o[r].jQ.prependTo(a.ends[L].jQ);l=CharCmds[")"](),l.createLeftOf(t),a.reflow()}}return e.createLeftOf.call(this,t)},Options.p.charsThatBreakOutOfSupSub="",t.finalizeTree=function(){var t,e,n,i=this.supsub;this.setUnit(),this.unitsup=!1,this.ends[L].write=function(t,e){return"sub"==i&&"_"===e?this.flash():void(t.options.charsThatBreakOutOfSupSub.indexOf(e)>-1?(t[L]instanceof Variable&&t[L].autoOperator(t),t.insRightOf(this.parent),t.parent.write(t,e)):"sub"!=i||RegExp(/[A-Za-z0-9]/).test(e)?MathBlock.p.write.apply(this,arguments):(t[L]instanceof Variable&&t[L].autoOperator(t),t.insRightOf(this.parent),t.parent.write(t,e)))},this.sup&&this.sup.ends[L]&&"."===this.sup.ends[L].ctrlSeq&&(this.sup.ends[L].remove(),this.elementWise=!0),this.elementWise&&this.jQ.addClass("mq-elementwise"),this.sub&&(t=this.jQ.closest(".mq-editable-field").children(".mq-autocomplete").first(),t.length>0&&(e=this.jQ,n=e.position(),t.css({top:Math.ceil(n.top+e.height())+"px"})))},t.latex=function(){function t(t,n){var i=n&&n.latex();return n?t+(1===i.length?i:"{"+(e?".":"")+(i||" ")+"}"):""}var e=this.elementWise;return t("_",this.sub)+t("^",this.sup)},t.text=function(t){var e="";return this.sub&&(e+="_"+(this.sub&&0!==this.sub.ends[L]&&this.sub.ends[L]===this.sub.ends[R]?this.sub.ends[L].text(t):this.sub.foldChildren("",function(e,n){return e+n.text(t)}))),this.sup&&(this.elementWise&&(e+="."),e+="^"+(this.sup&&0!==this.sup.ends[L]&&this.sup.ends[L]===this.sup.ends[R]?this.sup.ends[L].text(t):"("+this.sup.foldChildren("",function(e,n){return e+n.text(t)})+")")),e},t.respace=t.siblingCreated=t.siblingDeleted=function(t,e){e!==R&&this.jQ.toggleClass("mq-limit","\\int "===this[L].ctrlSeq)},t.addBlock=function(t){"sub"===this.supsub?(this.sup=this.upInto=this.sub.upOutOf=t,t.adopt(this,this.sub,0).downOutOf=this.sub,t.jQ=$('<span class="mq-sup"/>').append(t.jQ.children()).attr(mqBlockId,t.id).prependTo(this.jQ)):(this.sub=this.downInto=this.sup.downOutOf=t,t.adopt(this,0,this.sup).upOutOf=this.sup,t.jQ=$('<span class="mq-sub"></span>').append(t.jQ.children()).attr(mqBlockId,t.id).appendTo(this.jQ.removeClass("mq-sup-only")),this.jQ.append('<span style="display:inline-block;width:0"> </span>'));for(var e=0;2>e;e+=1)(function(t,e,n,i){t[e].deleteOutOf=function(s,r){r.insDirOf(s,this.parent),this.isEmpty()||(r[-s]=this.ends[s],this.children().disown().withDirAdopt(s,r.parent,r[s],this.parent).jQ.insDirOf(s,this.parent.jQ)),t.supsub=n,delete t[e],delete t[i+"Into"],t[n][i+"OutOf"]=insLeftOfMeUnlessAtEnd,delete t[n].deleteOutOf,"sub"===e&&$(t.jQ.addClass("mq-sup-only")[0].lastChild).remove(),this.remove()}})(this,"sub sup".split(" ")[e],"sup sub".split(" ")[e],"down up".split(" ")[e])}}),LatexCmds.subscript=LatexCmds._=P(SupSub,function(t,e){t.supsub="sub",t.ctrlSeq="_",t.htmlTemplate='<span class="mq-supsub mq-non-leaf"><span class="mq-sub">&0</span><span style="display:inline-block;width:0"> </span></span>',t.textTemplate=["_"],t.finalizeTree=function(){this.downInto=this.sub=this.ends[L],this.sub.upOutOf=insLeftOfMeUnlessAtEnd,e.finalizeTree.call(this)}}),LatexCmds.superscript=LatexCmds.supscript=LatexCmds["^"]=P(SupSub,function(t,e){t.supsub="sup",t.ctrlSeq="^",t.htmlTemplate='<span class="mq-supsub mq-non-leaf mq-sup-only"><span class="mq-sup">&0</span></span>',t.textTemplate=["^"],t.finalizeTree=function(){this.upInto=this.sup=this.ends[R],this.sup.downOutOf=insLeftOfMeUnlessAtEnd,e.finalizeTree.call(this)}}),LatexCmds.notin=LatexCmds.sim=LatexCmds.cong=LatexCmds.equiv=LatexCmds.oplus=LatexCmds.otimes=P(BinaryOperator,function(t,e){t.init=function(t){e.init.call(this,"\\"+t+" ","&"+t+";")}}),LatexCmds.ast=LatexCmds.star=LatexCmds.loast=LatexCmds.lowast=bind(BinaryOperator,"\\ast ","∗"),LatexCmds.therefor=LatexCmds.therefore=bind(BinaryOperator,"\\therefore ","∴"),LatexCmds.cuz=LatexCmds.because=bind(BinaryOperator,"\\because ","∵"),LatexCmds.prop=LatexCmds.propto=bind(BinaryOperator,"\\propto ","∝"),LatexCmds["≈"]=LatexCmds.asymp=LatexCmds.approx=bind(BinaryOperator,"\\approx ","≈"),LatexCmds.isin=LatexCmds["in"]=bind(BinaryOperator,"\\in ","∈"),LatexCmds.ni=LatexCmds.contains=bind(BinaryOperator,"\\ni ","∋"),LatexCmds.notni=LatexCmds.niton=LatexCmds.notcontains=LatexCmds.doesnotcontain=bind(BinaryOperator,"\\not\\ni ","∌"),LatexCmds.sub=LatexCmds.subset=bind(BinaryOperator,"\\subset ","⊂"),LatexCmds.sup=LatexCmds.supset=LatexCmds.superset=bind(BinaryOperator,"\\supset ","⊃"),LatexCmds.nsub=LatexCmds.notsub=LatexCmds.nsubset=LatexCmds.notsubset=bind(BinaryOperator,"\\not\\subset ","⊄"),LatexCmds.nsup=LatexCmds.notsup=LatexCmds.nsupset=LatexCmds.notsupset=LatexCmds.nsuperset=LatexCmds.notsuperset=bind(BinaryOperator,"\\not\\supset ","⊅"),LatexCmds.sube=LatexCmds.subeq=LatexCmds.subsete=LatexCmds.subseteq=bind(BinaryOperator,"\\subseteq ","⊆"),LatexCmds.supe=LatexCmds.supeq=LatexCmds.supsete=LatexCmds.supseteq=LatexCmds.supersete=LatexCmds.superseteq=bind(BinaryOperator,"\\supseteq ","⊇"),LatexCmds.nsube=LatexCmds.nsubeq=LatexCmds.notsube=LatexCmds.notsubeq=LatexCmds.nsubsete=LatexCmds.nsubseteq=LatexCmds.notsubsete=LatexCmds.notsubseteq=bind(BinaryOperator,"\\not\\subseteq ","⊈"),LatexCmds.nsupe=LatexCmds.nsupeq=LatexCmds.notsupe=LatexCmds.notsupeq=LatexCmds.nsupsete=LatexCmds.nsupseteq=LatexCmds.notsupsete=LatexCmds.notsupseteq=LatexCmds.nsupersete=LatexCmds.nsuperseteq=LatexCmds.notsupersete=LatexCmds.notsuperseteq=bind(BinaryOperator,"\\not\\supseteq ","⊉"),LatexCmds.N=LatexCmds.naturals=LatexCmds.Naturals=bind(VanillaSymbol,"\\mathbb{N}","ℕ"),LatexCmds.P=LatexCmds.primes=LatexCmds.Primes=LatexCmds.projective=LatexCmds.Projective=LatexCmds.probability=LatexCmds.Probability=bind(VanillaSymbol,"\\mathbb{P}","ℙ"),LatexCmds.Z=LatexCmds.integers=LatexCmds.Integers=bind(VanillaSymbol,"\\mathbb{Z}","ℤ"),LatexCmds.Q=LatexCmds.rationals=LatexCmds.Rationals=bind(VanillaSymbol,"\\mathbb{Q}","ℚ"),LatexCmds.R=LatexCmds.reals=LatexCmds.Reals=bind(VanillaSymbol,"\\mathbb{R}","ℝ"),LatexCmds.C=LatexCmds.complex=LatexCmds.Complex=LatexCmds.complexes=LatexCmds.Complexes=LatexCmds.complexplane=LatexCmds.Complexplane=LatexCmds.ComplexPlane=bind(VanillaSymbol,"\\mathbb{C}","ℂ"),LatexCmds.H=LatexCmds.Hamiltonian=LatexCmds.quaternions=LatexCmds.Quaternions=bind(VanillaSymbol,"\\mathbb{H}","ℍ"),LatexCmds.quad=LatexCmds.emsp=bind(VanillaSymbol,"\\quad "," "),LatexCmds.qquad=bind(VanillaSymbol,"\\qquad "," "),LatexCmds.diamond=bind(VanillaSymbol,"\\diamond ","◇"),LatexCmds.bigtriangleup=bind(VanillaSymbol,"\\bigtriangleup ","△"),LatexCmds.ominus=bind(VanillaSymbol,"\\ominus ","⊖"),LatexCmds.uplus=bind(VanillaSymbol,"\\uplus ","⊎"),LatexCmds.bigtriangledown=bind(VanillaSymbol,"\\bigtriangledown ","▽"),LatexCmds.sqcap=bind(VanillaSymbol,"\\sqcap ","⊓"),LatexCmds.triangleleft=bind(VanillaSymbol,"\\triangleleft ","⊲"),LatexCmds.sqcup=bind(VanillaSymbol,"\\sqcup ","⊔"),LatexCmds.triangleright=bind(VanillaSymbol,"\\triangleright ","⊳"),LatexCmds.odot=bind(VanillaSymbol,"\\odot ","⊙"),LatexCmds.bigcirc=bind(VanillaSymbol,"\\bigcirc ","◯"),LatexCmds.dagger=bind(VanillaSymbol,"\\dagger ","†"),LatexCmds.ddagger=bind(VanillaSymbol,"\\ddagger ","‡"),LatexCmds.wr=bind(VanillaSymbol,"\\wr ","≀"),LatexCmds.amalg=bind(VanillaSymbol,"\\amalg ","∐"),LatexCmds.models=bind(VanillaSymbol,"\\models ","⊨"),LatexCmds.prec=bind(VanillaSymbol,"\\prec ","≺"),LatexCmds.succ=bind(VanillaSymbol,"\\succ ","≻"),LatexCmds.preceq=bind(VanillaSymbol,"\\preceq ","≼"),LatexCmds.succeq=bind(VanillaSymbol,"\\succeq ","≽"),LatexCmds.simeq=bind(VanillaSymbol,"\\simeq ","≃"),LatexCmds.mid=bind(VanillaSymbol,"\\mid ","∣"),LatexCmds.ll=bind(VanillaSymbol,"\\ll ","≪"),LatexCmds.gg=bind(VanillaSymbol,"\\gg ","≫"),LatexCmds.parallel=bind(VanillaSymbol,"\\parallel ","∥"),LatexCmds.bowtie=bind(VanillaSymbol,"\\bowtie ","⋈"),LatexCmds.sqsubset=bind(VanillaSymbol,"\\sqsubset ","⊏"),LatexCmds.sqsupset=bind(VanillaSymbol,"\\sqsupset ","⊐"),LatexCmds.smile=bind(VanillaSymbol,"\\smile ","⌣"),LatexCmds.sqsubseteq=bind(VanillaSymbol,"\\sqsubseteq ","⊑"),LatexCmds.sqsupseteq=bind(VanillaSymbol,"\\sqsupseteq ","⊒"),LatexCmds.doteq=bind(VanillaSymbol,"\\doteq ","≐"),LatexCmds.frown=bind(VanillaSymbol,"\\frown ","⌢"),LatexCmds.vdash=bind(VanillaSymbol,"\\vdash ","⊦"),LatexCmds.dashv=bind(VanillaSymbol,"\\dashv ","⊣"),LatexCmds.longleftarrow=bind(VanillaSymbol,"\\longleftarrow ","←"),LatexCmds.longrightarrow=bind(VanillaSymbol,"\\longrightarrow ","→"),LatexCmds.Longleftarrow=bind(VanillaSymbol,"\\Longleftarrow ","⇐"),LatexCmds.Longrightarrow=bind(VanillaSymbol,"\\Longrightarrow ","⇒"),LatexCmds.longleftrightarrow=bind(VanillaSymbol,"\\longleftrightarrow ","↔"),LatexCmds.updownarrow=bind(VanillaSymbol,"\\updownarrow ","↕"),LatexCmds.Longleftrightarrow=bind(VanillaSymbol,"\\Longleftrightarrow ","⇔"),LatexCmds.Updownarrow=bind(VanillaSymbol,"\\Updownarrow ","⇕"),LatexCmds.mapsto=bind(VanillaSymbol,"\\mapsto ","↦"),LatexCmds.nearrow=bind(VanillaSymbol,"\\nearrow ","↗"),LatexCmds.hookleftarrow=bind(VanillaSymbol,"\\hookleftarrow ","↩"),LatexCmds.hookrightarrow=bind(VanillaSymbol,"\\hookrightarrow ","↪"),LatexCmds.searrow=bind(VanillaSymbol,"\\searrow ","↘"),LatexCmds.leftharpoonup=bind(VanillaSymbol,"\\leftharpoonup ","↼"),LatexCmds.rightharpoonup=bind(VanillaSymbol,"\\rightharpoonup ","⇀"),LatexCmds.swarrow=bind(VanillaSymbol,"\\swarrow ","↙"),LatexCmds.leftharpoondown=bind(VanillaSymbol,"\\leftharpoondown ","↽"),LatexCmds.rightharpoondown=bind(VanillaSymbol,"\\rightharpoondown ","⇁"),LatexCmds.nwarrow=bind(VanillaSymbol,"\\nwarrow ","↖"),LatexCmds.ldots=bind(VanillaSymbol,"\\ldots ","…"),LatexCmds.cdots=bind(VanillaSymbol,"\\cdots ","⋯"),LatexCmds.vdots=bind(VanillaSymbol,"\\vdots ","⋮"),LatexCmds.ddots=bind(VanillaSymbol,"\\ddots ","⋰"),LatexCmds.surd=bind(VanillaSymbol,"\\surd ","√"),LatexCmds.triangle=bind(VanillaSymbol,"\\triangle ","▵"),LatexCmds.ell=bind(VanillaSymbol,"\\ell ","ℓ"),LatexCmds.top=bind(VanillaSymbol,"\\top ","⊤"),LatexCmds.flat=bind(VanillaSymbol,"\\flat ","♭"),LatexCmds.natural=bind(VanillaSymbol,"\\natural ","♮"),LatexCmds.sharp=bind(VanillaSymbol,"\\sharp ","♯"),LatexCmds.wp=bind(VanillaSymbol,"\\wp ","℘"),LatexCmds.bot=bind(VanillaSymbol,"\\bot ","⊥"),LatexCmds.clubsuit=bind(VanillaSymbol,"\\clubsuit ","♣"),LatexCmds.diamondsuit=bind(VanillaSymbol,"\\diamondsuit ","♢"),LatexCmds.heartsuit=bind(VanillaSymbol,"\\heartsuit ","♡"),LatexCmds.spadesuit=bind(VanillaSymbol,"\\spadesuit ","♠"),LatexCmds.oint=bind(VanillaSymbol,"\\oint ","∮"),LatexCmds.bigcap=bind(VanillaSymbol,"\\bigcap ","∩"),LatexCmds.bigcup=bind(VanillaSymbol,"\\bigcup ","∪"),LatexCmds.bigsqcup=bind(VanillaSymbol,"\\bigsqcup ","⊔"),LatexCmds.bigvee=bind(VanillaSymbol,"\\bigvee ","∨"),LatexCmds.bigwedge=bind(VanillaSymbol,"\\bigwedge ","∧"),LatexCmds.bigodot=bind(VanillaSymbol,"\\bigodot ","⊙"),LatexCmds.bigotimes=bind(VanillaSymbol,"\\bigotimes ","⊗"),LatexCmds.bigoplus=bind(VanillaSymbol,"\\bigoplus ","⊕"),LatexCmds.biguplus=bind(VanillaSymbol,"\\biguplus ","⊎"),LatexCmds.lfloor=bind(VanillaSymbol,"\\lfloor ","⌊"),LatexCmds.rfloor=bind(VanillaSymbol,"\\rfloor ","⌋"),LatexCmds.lceil=bind(VanillaSymbol,"\\lceil ","⌈"),LatexCmds.rceil=bind(VanillaSymbol,"\\rceil ","⌉"),LatexCmds.opencurlybrace=LatexCmds.lbrace=bind(VanillaSymbol,"\\lbrace ","{"),LatexCmds.closecurlybrace=LatexCmds.rbrace=bind(VanillaSymbol,"\\rbrace ","}"),LatexCmds.caret=bind(VanillaSymbol,"\\text{^}","^"),LatexCmds.underscore=bind(VanillaSymbol,"\\_","_"),LatexCmds.slash=bind(VanillaSymbol,"/"),LatexCmds.vert=bind(VanillaSymbol,"|"),LatexCmds.perp=LatexCmds.perpendicular=bind(VanillaSymbol,"\\perp ","⊥"),LatexCmds.nabla=LatexCmds.del=bind(VanillaSymbol,"\\nabla ","∇"),LatexCmds.hbar=bind(VanillaSymbol,"\\hbar ","ℏ"),LatexCmds.AA=LatexCmds.Angstrom=LatexCmds.angstrom=bind(VanillaSymbol,"\\text\\AA ","Å"),LatexCmds.ring=LatexCmds.circ=LatexCmds.circle=bind(VanillaSymbol,"\\circ ","∘"),LatexCmds.bull=LatexCmds.bullet=bind(VanillaSymbol,"\\bullet ","•"),LatexCmds.setminus=LatexCmds.smallsetminus=bind(VanillaSymbol,"\\setminus ","∖"),LatexCmds.not=LatexCmds["¬"]=LatexCmds.neg=bind(VanillaSymbol,"\\neg ","¬"),LatexCmds.dots=LatexCmds.ellip=LatexCmds.hellip=LatexCmds.ellipsis=LatexCmds.hellipsis=bind(VanillaSymbol,"\\dots ","…"),LatexCmds["…"]=bind(VanillaSymbol,"…",'<span class="mq-nonSymbola" style="font-size:0.6em;">…</span>',".."),LatexCmds.converges=LatexCmds.darr=LatexCmds.dnarr=LatexCmds.dnarrow=LatexCmds.downarrow=bind(VanillaSymbol,"\\downarrow ","↓"),LatexCmds.dArr=LatexCmds.dnArr=LatexCmds.dnArrow=LatexCmds.Downarrow=bind(VanillaSymbol,"\\Downarrow ","⇓"),LatexCmds.diverges=LatexCmds.uarr=LatexCmds.uparrow=bind(VanillaSymbol,"\\uparrow ","↑"),LatexCmds.uArr=LatexCmds.Uparrow=bind(VanillaSymbol,"\\Uparrow ","⇑"),LatexCmds.to=bind(BinaryOperator,"\\to ","→"),LatexCmds.rarr=LatexCmds.rightarrow=bind(VanillaSymbol,"\\rightarrow ","→"),LatexCmds.implies=bind(BinaryOperator,"\\Rightarrow ","⇒"),LatexCmds.rArr=LatexCmds.Rightarrow=bind(VanillaSymbol,"\\Rightarrow ","⇒"),LatexCmds.gets=bind(BinaryOperator,"\\gets ","←"),LatexCmds.larr=LatexCmds.leftarrow=bind(VanillaSymbol,"\\leftarrow ","←"),LatexCmds.impliedby=bind(BinaryOperator,"\\Leftarrow ","⇐"),LatexCmds.lArr=LatexCmds.Leftarrow=bind(VanillaSymbol,"\\Leftarrow ","⇐"),LatexCmds.harr=LatexCmds.lrarr=LatexCmds.leftrightarrow=bind(VanillaSymbol,"\\leftrightarrow ","↔"),LatexCmds.iff=bind(BinaryOperator,"\\Leftrightarrow ","⇔"),LatexCmds.hArr=LatexCmds.lrArr=LatexCmds.Leftrightarrow=bind(VanillaSymbol,"\\Leftrightarrow ","⇔"),LatexCmds.Re=LatexCmds.Real=LatexCmds.real=bind(VanillaSymbol,"\\Re ","ℜ"),LatexCmds.Im=LatexCmds.imag=LatexCmds.image=LatexCmds.imagin=LatexCmds.imaginary=LatexCmds.Imaginary=bind(VanillaSymbol,"\\Im ","ℑ"),LatexCmds.part=LatexCmds.partial=bind(VanillaSymbol,"\\partial ","∂"),LatexCmds.infty=LatexCmds.infin=LatexCmds.infinity=bind(VanillaSymbol,"\\infty ","∞","infinity"),LatexCmds.alef=LatexCmds.alefsym=LatexCmds.aleph=LatexCmds.alephsym=bind(VanillaSymbol,"\\aleph ","ℵ"),LatexCmds.xist=LatexCmds.xists=LatexCmds.exist=LatexCmds.exists=bind(VanillaSymbol,"\\exists ","∃"),LatexCmds.and=LatexCmds.land=LatexCmds.wedge=bind(VanillaSymbol,"\\wedge ","∧"),LatexCmds.or=LatexCmds.lor=LatexCmds.vee=bind(VanillaSymbol,"\\vee ","∨"),LatexCmds.o=LatexCmds.O=LatexCmds.empty=LatexCmds.emptyset=LatexCmds.oslash=LatexCmds.Oslash=LatexCmds.nothing=LatexCmds.varnothing=bind(BinaryOperator,"\\varnothing ","∅"),LatexCmds.cup=LatexCmds.union=bind(BinaryOperator,"\\cup ","∪"),LatexCmds.cap=LatexCmds.intersect=LatexCmds.intersection=bind(BinaryOperator,"\\cap ","∩"),LatexCmds.deg=LatexCmds.degree=bind(VanillaSymbol,"^\\circ ","°"),LatexCmds.ang=LatexCmds.angle=bind(VanillaSymbol,"\\angle ","∠"),Variable=P(Symbol,function(t,e){t.init=function(t,n){e.init.call(this,t,"<var>"+(n||t)+"</var>")
|
4
|
+
},t.text=function(t){return!t||!t.unit||this[L]instanceof Variable||this[L]&&"µ"==this[L].ctrlSeq?this.textTemplate:"_"+this.textTemplate},t.autoUnItalicize=function(t){var e,n,i,s,r="",a=[];for(e=this;e instanceof Variable;e=e[L])r=e.ctrlSeq+r,a.push(e);if(t.parent&&t.parent.parent instanceof SupSub&&"sub"===t.parent.parent.supsub){for(r="_"+r,a=[t.parent.parent],e=t.parent.parent[L];e instanceof Variable;e=e[L])r=e.ctrlSeq+r,a.push(e);t.insRightOf(t.parent.parent)}for(n=OperatorName(),n.createLeftOf(t),i=0;i<a.length;i++){if("f"===a[i].ctrlSeq&&a[i].jQ.removeClass("mq-florin").html("f"),a[i]instanceof SupSub&&"sub"===a[i].supsub)for(s=a[i].blocks[0].ends[L];0!==s;s=s[R])"f"===s.ctrlSeq&&s.jQ.removeClass("mq-florin").html("f");a[i].disown(),a[i].adopt(n.ends[L],0,n.ends[L].ends[L]),a[i].jQ.prependTo(n.ends[L].jQ)}n.ends[L].jQ.removeClass("mq-empty")},t.fullWord=function(){var t,e=this.text({})+"",n=[this];for(t=this[L];t instanceof Variable;t=t[L])n.unshift(t),e=t.text({})+e;if(this.parent&&this.parent.parent instanceof SupSub&&"sub"===this.parent.parent.supsub)for(e="_"+e,n=[this.parent.parent],t=this.parent.parent[L];t instanceof Variable;t=t[L])n.unshift(t),e=t.text({})+e;for(t=this[R];t instanceof Variable;t=t[R])n.push(t),e+=t.text({});if(t instanceof SupSub&&"sub"===t.supsub)for(e+="_",n.push(t),t=t.ends[L].ends[L];t instanceof Variable;t=t[R])e+=t.text({});return[e,n]},t.finalizeTree=function(){this.autoComplete()},t.autoComplete=function(){var t,e,n,i,s,r,a,o,l,c,h,d,u,p,m,f,b,x,C;if(this.controller||this.getController(),t=this.fullWord(),e=t[0],n=t[1],i=[],s=new RegExp("^"+e+".*$","i"),this.parent.unit||this.parent.parent&&this.parent.parent.unit){if(1==e.length&&(s=new RegExp("^"+e+"$","")),e.length>0){for(prefix_to_ignore=["micro","yocto","zepto","atto","femto","pico","nano","milli","centi","deci","deca","hecto","kilo","mega","giga","tera","peta","exa","zetta","yotta"],skip_this=!1,r=function(t){return t[0].toUpperCase()+t.slice(1)},a=0;a<prefix_to_ignore.length;a++)if(prefix_to_ignore[a].match(s)){skip_this=!0;break}if(!skip_this){for(o=this.controller.API.__options.unitList||{names:[],symbols:[]},l={},a=0;a<o.symbols.length;a++)o.symbols[a].match(s)&&(i.push("<li data-word='"+o.symbols[a]+"'><span class='mq-operator-name'>"+o.symbols[a]+" ("+r(o.symbol_to_name[o.symbols[a]])+")</span></li>"),l[o.symbols[a]]=!0);for(a=0;a<o.names.length;a++)o.names[a].match(s)&&!l[o.name_to_symbol[o.names[a]]]&&i.push("<li data-word='"+o.name_to_symbol[o.names[a]]+"'><span class='mq-operator-name'>"+o.name_to_symbol[o.names[a]]+" ("+r(o.names[a])+")</span></li>")}}}else if(e.length>0){if(c=[],h=[],d="",this.parent&&this.parent.parent instanceof FunctionCommand&&this.parent===this.parent.parent.ends[R])c=this.parent.parent.getObject().propertyList,h=this.parent.parent.getObject().methodList,d=this.parent.parent.objectName()+".";else{if(e.length<3)return;c=this.controller.API.__options.autocomplete||[],h=this.controller.API.__options.staticAutocomplete||[]}for(u=function(t,e){var n,i=Object.keys(e.controller.API.__options.autoCommands);for(n=0;n<i.length;n++){if(t===i[n]){t=LatexCmds[i[n]](i[n]).htmlTemplate;break}t=t.replace(new RegExp("^"+i[n]+"_",""),LatexCmds[i[n]](i[n]).htmlTemplate+"_")}return t=t.indexOf("_")>-1?t.replace("_","<sub>")+"</sub>":t,t.indexOf(".")>-1&&(t=t.replace(".","")+".<span class='mq-inline-box'></span>"),t},a=0;a<c.length;a++)c[a].match(s)&&i.push("<li data-word='"+c[a]+"'><span class='mq-nonSymbola'><i>"+d+u(c[a],this)+"</i></span></li>");for(a=0;a<h.length;a++)h[a].match(s)&&i.push("<li data-word='"+h[a]+"('><span class='mq-nonSymbola'><i>"+d+"</i></span><span class='mq-operator-name'>"+(h[a].indexOf("_")>-1?h[a].replace("_","<sub>")+"</sub>":h[a])+"(<span class='mq-inline-box'></span>)</span></li>")}i.length>0?(i[0]=i[0].replace("<li",'<li class="mq-popup-selected"'),p=this.parent&&this.parent.parent instanceof FunctionCommand&&this.parent===this.parent.parent.ends[R]?this.parent.parent.jQ:n[0].jQ,m=n[n.length-1].jQ,f=p.position(),b=m.position(),x=this,C=function(){var t,e=$(this).attr("data-word"),n=x.fullWord()[1],i=n[0][L],s=n[0].parent;for(t=0;t<n.length;t++)n[t].remove();i?x.controller.cursor.insRightOf(i):x.controller.cursor.insAtRightEnd(s),x.controller.API.typedText(e),"."===e[e.length-1]&&FunctionCommand(!0).createLeftOf(x.controller.cursor),x.controller.closePopup(),"("!==e[e.length-1]&&"."!==e[e.length-1]&&x.controller.cursor.parent&&x.controller.cursor.parent.parent instanceof SupSub&&"sub"===x.controller.cursor.parent.parent.supsub&&x.controller.cursor.insRightOf(x.controller.cursor.parent.parent),x.controller.cursor.workingGroupChange()},this.controller.createPopup("<ul>"+i.join("\n")+"</ul>",b.top+m.height(),f.left,C)):this.controller.closePopup()}}),Options.p.autoCommands={_maxLength:0},optionProcessors.autoCommands=function(t){var e,n,i,s,r;if(!/^[a-z]+(?: [a-z]+)*$/i.test(t))throw'"'+t+'" not a space-delimited list of only letters';for(e=t.split(" "),n={},i=0,s=0;s<e.length;s+=1){if(r=e[s],r.length<2)throw'autocommand "'+r+'" not minimum length of 2';if(LatexCmds[r]===OperatorName)throw'"'+r+'" is a built-in operator name';n[r]=1,i=max(i,r.length)}return n},Letter=P(Variable,function(t,e){t.init=function(t){return e.init.call(this,this.letter=t)},t.autoOperator=function(t){for(var e=t.options.autoCommands,n=t[L].letter,i=t[L][L],s=1;i instanceof Letter;)n=i.letter+n,i=i[L],s+=1;if(n.length>1&&e.hasOwnProperty(n)){for(s=1,i=t[L];s<n.length;s+=1,i=i[L]);return Fragment(i,t[L]).remove(),t[L]=i[L],LatexCmds[n](n).createLeftOf(t),!0}return!1},t.createLeftOf=function(t){"u"!=this.ctrlSeq||!(t.parent.unit||t.parent.parent&&t.parent.parent.unit)||t[L]instanceof Variable||t[L]&&"µ"==t[L].ctrlSeq?t[L]&&t[L][L]&&"."===t[L].ctrlSeq&&t[L][L]instanceof Variable?FunctionCommand(this.ctrlSeq).createLeftOf(t):e.createLeftOf.apply(this,arguments):Letter("µ").createLeftOf(t)}}),BuiltInOpNames={},function(){var t,e,n,i=Options.p.autoOperatorNames={_maxLength:9},s="arg deg det dim exp gcd hom inf ker lg lim ln log max min sup limsup liminf injlim projlim Pr".split(" ");for(t=0;t<s.length;t+=1)BuiltInOpNames[s[t]]=i[s[t]]=1;for(e="sin cos tan arcsin arccos arctan sinh cosh tanh sec csc cot coth".split(" "),t=0;t<e.length;t+=1)BuiltInOpNames[e[t]]=1;for(n="sin cos tan sec cosec csc cotan cot ctg".split(" "),t=0;t<n.length;t+=1)i[n[t]]=i["arc"+n[t]]=i[n[t]+"h"]=i["ar"+n[t]+"h"]=i["arc"+n[t]+"h"]=1}(),optionProcessors.autoOperatorNames=function(t){var e,n,i,s,r;if(!/^[a-z]+(?: [a-z]+)*$/i.test(t))throw'"'+t+'" not a space-delimited list of only letters';for(e=t.split(" "),n={},i=0,s=0;s<e.length;s+=1){if(r=e[s],r.length<2)throw'"'+r+'" not minimum length of 2';n[r]=1,i=max(i,r.length)}return n._maxLength=i,n},optionProcessors.unitList=function(t){var e,n,i,s={},r={},a=[],o=[],l={micro:"µ",yocto:"y",zepto:"z",atto:"a",femto:"f",pico:"p",nano:"n",milli:"m",centi:"c",deci:"d",deca:"D",hecto:"h",kilo:"k",mega:"M",giga:"G",tera:"T",peta:"P",exa:"E",zetta:"Z",yotta:"Y"};for(e=0;e<t.length;e++)if(a.push(t[e].name),o.push(t[e].symbol),s[t[e].name]=t[e].symbol,r[t[e].symbol]=t[e].name,t[e].prefix)for(n in l)a.push(n+t[e].name),o.push(l[n]+t[e].symbol),s[n+t[e].name]=l[n]+t[e].symbol,r[l[n]+t[e].symbol]=n+t[e].name;return i=function(t,e){return t.toLowerCase().localeCompare(e.toLowerCase())},{name_to_symbol:s,symbol_to_name:r,names:a.sort(i),symbols:o.sort(i)}},LatexCmds.µ=P(VanillaSymbol,function(t,e){t.init=function(){e.init.call(this,"µ")},t.createLeftOf=function(t){t.parent.unit||t.parent.parent&&t.parent.parent.unit?Letter("µ").createLeftOf(t):e.createLeftOf.call(this,t)}}),LatexCmds[2]=P(VanillaSymbol,function(t,e){t.init=function(){e.init.call(this,"2")},t.createLeftOf=function(t){t.parent&&t.parent.parent&&t.parent.parent instanceof Unit||t.parent&&t.parent.parent&&t.parent.parent.unit&&!(t.parent.parent instanceof SupSub)?t[L]&&"H"===t[L].ctrlSeq?Letter("2").createLeftOf(t):t.parent.flash():e.createLeftOf.call(this,t)}}),LatexCmds.f=P(Letter,function(t,e){t.init=function(){Symbol.p.init.call(this,this.letter="f",'<var class="mq-florin">ƒ</var>')},t.createLeftOf=function(t){t.parent&&t.parent.parent instanceof OperatorName&&t.parent===t.parent.parent.blocks[0]?Letter("f").createLeftOf(t):t.parent&&t.parent.parent&&t.parent.parent instanceof SupSub&&"sub"===t.parent.parent.supsub&&t.parent.parent.parent&&t.parent.parent.parent.parent instanceof OperatorName&&t.parent.parent.parent===t.parent.parent.parent.parent.blocks[0]?Letter("f").createLeftOf(t):t.parent.unit||t.parent.parent&&t.parent.parent.unit?Letter("f").createLeftOf(t):e.createLeftOf.call(this,t)}}),LatexCmds[" "]=LatexCmds.space=bind(VanillaSymbol,"\\ "," "),LatexCmds.backslash=bind(VanillaSymbol,"\\backslash ","\\"),CharCmds["\\"]||(CharCmds["\\"]=LatexCmds.backslash),NonSymbolaSymbol=P(Variable,function(t,e){t.init=function(t,n){e.init.call(this,t,'<span class="mq-nonSymbola">'+(n||t)+"</span>")}}),LatexCmds["@"]=NonSymbolaSymbol,LatexCmds["&"]=bind(NonSymbolaSymbol,"\\&","&"),LatexCmds["%"]=bind(NonSymbolaSymbol,"\\%","%"),LatexCmds.alpha=LatexCmds.beta=LatexCmds.gamma=LatexCmds.delta=LatexCmds.zeta=LatexCmds.eta=LatexCmds.theta=LatexCmds.iota=LatexCmds.kappa=LatexCmds.mu=LatexCmds.nu=LatexCmds.xi=LatexCmds.rho=LatexCmds.sigma=LatexCmds.tau=LatexCmds.chi=LatexCmds.psi=LatexCmds.omega=P(Variable,function(t,e){t.init=function(t){e.init.call(this,"\\"+t+" ","&"+t+";")}}),LatexCmds.phi=bind(Variable,"\\phi ","ϕ"),LatexCmds.phiv=LatexCmds.varphi=bind(Variable,"\\varphi ","φ"),LatexCmds.epsilon=bind(Variable,"\\epsilon ","ϵ"),LatexCmds.epsiv=LatexCmds.varepsilon=bind(Variable,"\\varepsilon ","ε"),LatexCmds.piv=LatexCmds.varpi=bind(Variable,"\\varpi ","ϖ"),LatexCmds.sigmaf=LatexCmds.sigmav=LatexCmds.varsigma=bind(Variable,"\\varsigma ","ς"),LatexCmds.thetav=LatexCmds.vartheta=LatexCmds.thetasym=bind(Variable,"\\vartheta ","ϑ"),LatexCmds.upsilon=LatexCmds.upsi=bind(Variable,"\\upsilon ","υ"),LatexCmds.gammad=LatexCmds.Gammad=LatexCmds.digamma=bind(Variable,"\\digamma ","ϝ"),LatexCmds.kappav=LatexCmds.varkappa=bind(Variable,"\\varkappa ","ϰ"),LatexCmds.rhov=LatexCmds.varrho=bind(Variable,"\\varrho ","ϱ"),LatexCmds.pi=LatexCmds["π"]=bind(NonSymbolaSymbol,"\\pi ","π"),LatexCmds.lambda=bind(NonSymbolaSymbol,"\\lambda ","λ"),LatexCmds.Upsilon=LatexCmds.Upsi=LatexCmds.upsih=LatexCmds.Upsih=bind(Symbol,"\\Upsilon ",'<var style="font-family: serif">ϒ</var>'),LatexCmds.Gamma=LatexCmds.Delta=LatexCmds.Theta=LatexCmds.Lambda=LatexCmds.Xi=LatexCmds.Pi=LatexCmds.Sigma=LatexCmds.Phi=LatexCmds.Psi=LatexCmds.Omega=LatexCmds.forall=P(VanillaSymbol,function(t,e){t.init=function(t){e.init.call(this,"\\"+t+" ","&"+t+";")}}),LatexFragment=P(MathCommand,function(t){t.init=function(t){this.latex=t},t.createLeftOf=function(t){var e=latexMathParser.parse(this.latex);e.children().adopt(t.parent,t[L],t[R]),t[L]=e.ends[R],e.jQize().insertBefore(t.jQ),e.finalizeInsert(t.options,t),e.ends[R][R].siblingCreated&&e.ends[R][R].siblingCreated(t.options,L),e.ends[L][L].siblingCreated&&e.ends[L][L].siblingCreated(t.options,R),t.parent.bubble("reflow")},t.parser=function(){var t=latexMathParser.parse(this.latex).children();return Parser.succeed(t)}}),LatexCmds["¹"]=bind(LatexFragment,"^1"),LatexCmds["²"]=bind(LatexFragment,"^2"),LatexCmds["³"]=bind(LatexFragment,"^3"),LatexCmds["¼"]=bind(LatexFragment,"\\frac14"),LatexCmds["½"]=bind(LatexFragment,"\\frac12"),LatexCmds["¾"]=bind(LatexFragment,"\\frac34"),PlusMinus=P(BinaryOperator,function(t){t.init=VanillaSymbol.prototype.init,t.contactWeld=t.siblingCreated=t.siblingDeleted=function(t,e){return e!==R?(this.jQ[0].className=!this[L]||this[L]instanceof BinaryOperator?"":"mq-binary-operator",this):void 0}}),Multiplication=P(BinaryOperator,function(t){t.addedImplicitly=!1,t.finalizeTree=function(){var t,e;if(this[L]&&"."===this[L].ctrlSeq){for(t=[this[L]],this[L][L]&&this[L][L][L]&&"0"===this[L][L].ctrlSeq&&"\\cdot "===this[L][L][L].ctrlSeq&&(t.push(this[L][L]),t.push(this[L][L][L])),e=0;e<t.length;e++)t[e].remove();this.jQ.html("⊙"),this.jQ.addClass("mq-multiply-elementWise"),this.ctrlSeq="."+this.ctrlSeq,this.textTemplate="."+this.textTemplate}},t.implicit=function(){return this.addedImplicitly=!0,this}}),LatexCmds["+"]=bind(PlusMinus,"+","+"),LatexCmds["–"]=LatexCmds["-"]=bind(PlusMinus,"-","−"),LatexCmds["±"]=LatexCmds.pm=LatexCmds.plusmn=LatexCmds.plusminus=bind(PlusMinus,"\\pm ","±"),LatexCmds.mp=LatexCmds.mnplus=LatexCmds.minusplus=bind(PlusMinus,"\\mp ","∓"),CharCmds["*"]=LatexCmds.sdot=LatexCmds.cdot=bind(Multiplication,"\\cdot ","·","*"),Inequality=P(BinaryOperator,function(t,e){t.init=function(t,n){this.data=t,this.strict=n;var i=n?"Strict":"";e.init.call(this,t["ctrlSeq"+i],t["html"+i],t["text"+i])},t.swap=function(t){this.strict=t;var e=t?"Strict":"";this.ctrlSeq=this.data["ctrlSeq"+e],this.jQ.html(this.data["html"+e]),this.textTemplate=[this.data["text"+e]]},t.deleteTowards=function(t){return t!==L||this.strict?void e.deleteTowards.apply(this,arguments):void this.swap(!0)}}),less={ctrlSeq:"\\le ",html:"≤",text:" <= ",ctrlSeqStrict:"<",htmlStrict:"<",textStrict:" < "},greater={ctrlSeq:"\\ge ",html:"≥",text:" >= ",ctrlSeqStrict:">",htmlStrict:">",textStrict:" > "},factorial={ctrlSeq:"\\ne ",html:"≠",text:" != ",ctrlSeqStrict:"!",htmlStrict:"!",textStrict:"!"},LatexCmds["<"]=LatexCmds.lt=bind(Inequality,less,!0),LatexCmds[">"]=LatexCmds.gt=bind(Inequality,greater,!0),LatexCmds["≤"]=LatexCmds.le=LatexCmds.leq=bind(Inequality,less,!1),LatexCmds["≥"]=LatexCmds.ge=LatexCmds.geq=bind(Inequality,greater,!1),LatexCmds["!"]=bind(Inequality,factorial,!0),LatexCmds["≠"]=LatexCmds.ne=LatexCmds.neq=bind(Inequality,factorial,!1),Equality=P(Inequality,function(t,e){t.init=function(t,n){e.init.call(this,t,n)},t.createLeftOf=function(t){return(t[L]instanceof Inequality||t[L]instanceof Equality)&&t[L].strict?void t[L].swap(!1):void e.createLeftOf.apply(this,arguments)}}),equal={ctrlSeq:"\\eq ",html:"==",text:" == ",ctrlSeqStrict:"=",htmlStrict:"=",textStrict:" := "},LatexCmds["="]=bind(Equality,equal,!0),LatexCmds.eq=bind(Equality,equal,!1),LatexCmds.times=bind(BinaryOperator,"\\times ","×","[x]"),LatexCmds["÷"]=LatexCmds.div=LatexCmds.divide=LatexCmds.divides=bind(BinaryOperator,"\\div ","÷","[/]"),forceIERedraw=noop,div=document.createElement("div"),div_style=div.style,transformPropNames={transform:1,WebkitTransform:1,MozTransform:1,OTransform:1,msTransform:1};for(prop in transformPropNames)if(prop in div_style){transformPropName=prop;break}transformPropName?scale=function(t,e,n){t.css(transformPropName,"scale("+e+","+n+")")}:"filter"in div_style?(forceIERedraw=function(t){t.className=t.className},scale=function(t,e,n){function i(){t.css("marginRight",(s.width()-1)*(e-1)/e+"px")}var s,r;e/=1+(n-1)/2,t.css("fontSize",n+"em"),t.hasClass("mq-matrixed-container")||t.addClass("mq-matrixed-container").wrapInner('<span class="mq-matrixed"></span>'),s=t.children().css("filter","progid:DXImageTransform.Microsoft.Matrix(M11="+e+",SizingMethod='auto expand')"),i(),r=setInterval(i),$(window).load(function(){clearTimeout(r),i()})}):scale=function(t,e,n){t.css("fontSize",n+"em")},Style=P(MathCommand,function(t,e){t.init=function(t,n,i){e.init.call(this,t,"<"+n+" "+i+">&0</"+n+">")}}),LatexCmds.mathrm=bind(Style,"\\mathrm","span",'class="mq-roman mq-font"'),LatexCmds.mathit=bind(Style,"\\mathit","i",'class="mq-font"'),LatexCmds.mathbf=bind(Style,"\\mathbf","b",'class="mq-font"'),LatexCmds.mathsf=bind(Style,"\\mathsf","span",'class="mq-sans-serif mq-font"'),LatexCmds.mathtt=bind(Style,"\\mathtt","span",'class="mq-monospace mq-font"'),LatexCmds.underline=bind(Style,"\\underline","span",'class="mq-non-leaf mq-underline"'),LatexCmds.overline=LatexCmds.bar=bind(Style,"\\overline","span",'class="mq-non-leaf mq-overline"'),TextColor=LatexCmds.textcolor=P(MathCommand,function(t,e){t.setColor=function(t){this.color=t,this.htmlTemplate='<span class="mq-textcolor" style="color:'+t+'">&0</span>'},t.latex=function(){return"\\textcolor{"+this.color+"}{"+this.blocks[0].latex()+"}"},t.parser=function(){var t=this,n=Parser.optWhitespace,i=Parser.string,s=Parser.regex;return n.then(i("{")).then(s(/^[#\w\s.,()%-]*/)).skip(i("}")).then(function(n){return t.setColor(n),e.parser.call(t)})}}),Class=LatexCmds["class"]=P(MathCommand,function(t,e){t.parser=function(){var t=this,n=Parser.string,i=Parser.regex;return Parser.optWhitespace.then(n("{")).then(i(/^[-\w\s\\\xA0-\xFF]*/)).skip(n("}")).then(function(n){return t.htmlTemplate='<span class="mq-class '+n+'">&0</span>',e.parser.call(t)})}}),Vec=LatexCmds.vec=P(MathCommand,function(t){t.ctrlSeq="\\vec",t.htmlTemplate='<span class="mq-non-leaf"><span class="mq-vector-prefix">→</span><span class="mq-vector-stem">&0</span></span>',t.textTemplate=["vec(",")"]}),InnerMathField=P(MathQuill.MathField,function(t){t.init=function(t,e){RootBlockMixin(t),this.__options=Options();var n=Controller(this,t,e);n.editable=!0,n.createTextarea(),n.editablesTextareaEvents(),n.cursor.insAtRightEnd(t)}}),LatexCmds.MathQuillMathField=P(MathCommand,function(t,e){t.ctrlSeq="\\MathQuillMathField",t.htmlTemplate='<span class="mq-editable-field"><span class="mq-root-block">&0</span></span>',t.parser=function(){var t=this,n=Parser.string,i=Parser.regex,s=Parser.succeed;return n("[").then(i(/^[a-z][a-z0-9]*/i)).skip(n("]")).map(function(e){t.name=e}).or(s()).then(e.parser.call(t))},t.finalizeTree=function(){InnerMathField(this.ends[L],this.jQ)},t.registerInnerField=function(t){t.push(t[this.name]=this.ends[L].controller.API)},t.latex=function(){return this.ends[L].latex()},t.text=function(t){return this.ends[L].text(t)}}),Unit=LatexCmds.Unit=CharCmds["'"]=P(DerivedMathCommand,function(t,e){t.ctrlSeq="Unit{...}{...}",t.replaces=function(t){t.disown(),this._replacedFragment=t},t.htmlTemplate='<span><span>&0</span><span class="mq-unit mq-non-leaf">&1</span></span>',t.finalizeTree=function(){this.ends[R].focus=function(){return this.jQ.addClass("mq-active"),this.isEmpty()&&this.jQ.removeClass("mq-empty"),this},this.ends[R].blur=function(){return this.jQ.removeClass("mq-active").removeClass("mq-hasCursor"),this.isEmpty()&&this.jQ.addClass("mq-empty"),this},this.ends[R].write=function(t,e,n){return cmd=e.match(/^[a-z]$/i)?Letter(e):(cmd=CharCmds[e]||LatexCmds[e])?cmd(e):VanillaSymbol(e),e.match(/^[a-z\u00b52\^\*\/\(\)]$/i)?(n&&cmd.replaces(n),void cmd.createLeftOf(t)):(n&&n.remove(),void this.flash())},this.ends[R].unit=this.ends[R],this.ends[R].eachChild(function(t){if(t.recursiveSetUnit&&t.recursiveSetUnit(),t instanceof VanillaSymbol&&("µ"==t.ctrlSeq||"2"==t.ctrlSeq)){var e=Letter(t.ctrlSeq);e.jQize(),e.jQ.insDirOf(R,t.jQ),t[R]=e.adopt(t.parent,t,t[R]),t.remove()}}),this.ends[R].deleteOutOf=function(t,e){for(var n=this.ends[L];0!==n;n=n[R])n.remove();e.insAtRightEnd(this),e.unwrapGramp()},this.ends[L].deleteOutOf=function(t,e){for(var n=this.parent.ends[R].ends[L];0!==n;n=n[R])n.remove();e.insAtRightEnd(this),e.unwrapGramp()}},t.createLeftOf=function(t){var n,i,s,r,a;if(this._replacedFragment){for(n=!0,i=this._replacedFragment.ends[L];0!==i;i=i[R])if(!(i instanceof VanillaSymbol&&i.ctrlSeq.match(/[0-9\.]/))){n=!1;break}this._replacedFragment.ends[L]===this._replacedFragment.ends[R]&&this._replacedFragment.ends[L]instanceof ScientificNotation&&(n=!0),n?(e.createLeftOf.call(this,t),this._replacedFragment.adopt(this.ends[L],0,0),this._replacedFragment.jQ.appendTo(this.ends[L].jQ)):(s=CharCmds["("](),s.replaces(this._replacedFragment),s.createLeftOf(t),s.reflow(),t.insRightOf(s),LatexCmds.cdot().createLeftOf(t),e.createLeftOf.call(this,t),t.insAtRightEnd(this.ends[L]),VanillaSymbol("1").createLeftOf(t))}else{for(r=[],t[L]instanceof ScientificNotation&&r.push(t[L]),i=t[L];0!==i&&(i instanceof VanillaSymbol&&i.ctrlSeq.match(/[0-9\.]/));i=i[L])r.push(i);for(0===r.length&&(t[L]instanceof BinaryOperator||0===t[L]?VanillaSymbol("1").createLeftOf(t):(LatexCmds.cdot().createLeftOf(t),VanillaSymbol("1").createLeftOf(t)),r.push(t[L])),e.createLeftOf.call(this,t),a=0;a<r.length;a++)r[a].disown(),r[a].adopt(this.ends[L],0,this.ends[L].ends[L]),r[a].jQ.prependTo(this.ends[L].jQ)}return t.insAtRightEnd(this.ends[R]),t.workingGroupChange(),this},t.latex=function(){return"\\Unit{"+this.blocks[0].latex()+"}{"+this.blocks[1].latex()+"}"},t.text=function(t){return this.blocks[0].text(t)+"*("+this.blocks[1].text(jQuery.extend({unit:!0},t))+")"}})}();
|
@@ -45,15 +45,7 @@
|
|
45
45
|
}
|
46
46
|
.mq-editable-field,
|
47
47
|
.mq-math-mode .mq-editable-field {
|
48
|
-
border: 1px solid
|
49
|
-
}
|
50
|
-
.mq-editable-field.mq-focused,
|
51
|
-
.mq-math-mode .mq-editable-field.mq-focused {
|
52
|
-
-webkit-box-shadow: #8bd 0 0 1px 2px, inset #6ae 0 0 2px 0;
|
53
|
-
-moz-box-shadow: #8bd 0 0 1px 2px, inset #6ae 0 0 2px 0;
|
54
|
-
box-shadow: #8bd 0 0 1px 2px, inset #6ae 0 0 2px 0;
|
55
|
-
border-color: #709AC0;
|
56
|
-
border-radius: 1px;
|
48
|
+
border: 1px solid #bbccff;
|
57
49
|
}
|
58
50
|
.mq-math-mode .mq-editable-field {
|
59
51
|
margin: 1px;
|
@@ -231,7 +223,7 @@
|
|
231
223
|
}
|
232
224
|
.mq-math-mode sup.mq-nthroot {
|
233
225
|
font-size: 80%;
|
234
|
-
vertical-align: 0.
|
226
|
+
vertical-align: 0.3em;
|
235
227
|
margin-right: -0.6em;
|
236
228
|
margin-left: .2em;
|
237
229
|
min-width: .5em;
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mathquill_swiftcalcs_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.3.
|
4
|
+
version: 0.9.3.119
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brentan Alexander
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|