Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
9c942d7e
Commit
9c942d7e
authored
Sep 05, 2014
by
Waqas Khalid
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4910 from mlkwaqas/waqas/bld1199-mathjax-error
MaxJax error while submitting answer
parents
14d0ac01
4834e51a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
24 deletions
+38
-24
common/static/js/capa/spec/formula_equation_preview_spec.js
+13
-3
common/static/js/capa/src/formula_equation_preview.js
+25
-21
No files found.
common/static/js/capa/spec/formula_equation_preview_spec.js
View file @
9c942d7e
...
...
@@ -62,7 +62,17 @@ describe("Formula Equation Preview", function () {
window
.
MathJax
=
{
Hub
:
{}};
MathJax
.
Hub
.
getAllJax
=
jasmine
.
createSpy
(
'MathJax.Hub.getAllJax'
)
.
andReturn
([
this
.
jax
]);
MathJax
.
Hub
.
Queue
=
jasmine
.
createSpy
(
'MathJax.Hub.Queue'
);
MathJax
.
Hub
.
Queue
=
function
(
callback
)
{
if
(
typeof
(
callback
)
==
'function'
)
{
callback
();
}
}
spyOn
(
MathJax
.
Hub
,
'Queue'
).
andCallThrough
()
MathJax
.
Hub
.
Startup
=
jasmine
.
createSpy
(
'MathJax.Hub.Startup'
);
MathJax
.
Hub
.
Startup
.
signal
=
jasmine
.
createSpy
(
'MathJax.Hub.Startup.signal'
);
MathJax
.
Hub
.
Startup
.
signal
.
Interest
=
function
(
callback
)
{
callback
(
'End'
);
}
});
it
(
'(the test) is able to swap out the behavior of $'
,
function
()
{
...
...
@@ -245,7 +255,7 @@ describe("Formula Equation Preview", function () {
// Cannot find MathJax.
MathJax
.
Hub
.
getAllJax
.
andReturn
([]);
spyOn
(
console
,
'
warn
'
);
spyOn
(
console
,
'
log
'
);
callback
({
preview
:
'THE_FORMULA'
,
...
...
@@ -253,7 +263,7 @@ describe("Formula Equation Preview", function () {
});
// Tests.
expect
(
console
.
warn
).
toHaveBeenCalled
();
expect
(
console
.
log
).
toHaveBeenCalled
();
// We should look in the preview div for the MathJax.
var
previewElement
=
$
(
"#input_THE_ID_preview"
)[
0
];
...
...
common/static/js/capa/src/formula_equation_preview.js
View file @
9c942d7e
...
...
@@ -127,27 +127,31 @@ formulaEquationPreview.enable = function () {
}
function
display
(
latex
)
{
// Load jax if it failed before.
var
previewElement
=
inputData
.
$preview
[
0
];
if
(
!
inputData
.
jax
)
{
inputData
.
jax
=
MathJax
.
Hub
.
getAllJax
(
previewElement
)[
0
];
}
// MathJax might not be loaded yet (still).
if
(
inputData
.
jax
)
{
// Set the text as the latex code, and then update the MathJax.
MathJax
.
Hub
.
Queue
(
[
'Text'
,
inputData
.
jax
,
latex
],
[
'Reprocess'
,
inputData
.
jax
]
);
}
else
if
(
latex
)
{
console
.
warn
(
"[FormulaEquationInput] Oops no mathjax for "
,
latex
);
// Fall back to modifying the actual element.
var
textNode
=
previewElement
.
childNodes
[
0
];
textNode
.
data
=
"
\\
["
+
latex
+
"
\\
]"
;
MathJax
.
Hub
.
Queue
([
"Typeset"
,
MathJax
.
Hub
,
previewElement
]);
}
MathJax
.
Hub
.
Startup
.
signal
.
Interest
(
function
(
message
)
{
if
(
message
===
"End"
)
{
var
previewElement
=
inputData
.
$preview
[
0
];
MathJax
.
Hub
.
Queue
(
function
()
{
inputData
.
jax
=
MathJax
.
Hub
.
getAllJax
(
previewElement
)[
0
];
});
MathJax
.
Hub
.
Queue
(
function
()
{
// Check if MathJax is loaded
if
(
inputData
.
jax
)
{
// Set the text as the latex code, and then update the MathJax.
MathJax
.
Hub
.
Queue
(
[
'Text'
,
inputData
.
jax
,
latex
],
[
'Reprocess'
,
inputData
.
jax
]
);
}
else
if
(
latex
)
{
console
.
log
(
"[FormulaEquationInput] Oops no mathjax for "
,
latex
);
// Fall back to modifying the actual element.
var
textNode
=
previewElement
.
childNodes
[
0
];
textNode
.
data
=
"
\\
["
+
latex
+
"
\\
]"
;
MathJax
.
Hub
.
Queue
([
"Typeset"
,
MathJax
.
Hub
,
previewElement
]);
}
});
}
});
}
if
(
response
.
error
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment