Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
c41fffdb
Commit
c41fffdb
authored
Jan 30, 2018
by
Clement Ho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace $.get in render math with axios
parent
4752f629
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
13 deletions
+25
-13
app/assets/javascripts/render_math.js
app/assets/javascripts/render_math.js
+25
-13
No files found.
app/assets/javascripts/render_math.js
View file @
c41fffdb
...
@@ -7,7 +7,12 @@
...
@@ -7,7 +7,12 @@
//
//
// <code class="js-render-math"></div>
// <code class="js-render-math"></div>
//
//
// Only load once
import
{
__
}
from
'
./locale
'
;
import
axios
from
'
./lib/utils/axios_utils
'
;
import
flash
from
'
./flash
'
;
// Only load once
let
katexLoaded
=
false
;
let
katexLoaded
=
false
;
// Loop over all math elements and render math
// Loop over all math elements and render math
...
@@ -33,19 +38,26 @@ export default function renderMath($els) {
...
@@ -33,19 +38,26 @@ export default function renderMath($els) {
if
(
katexLoaded
)
{
if
(
katexLoaded
)
{
renderWithKaTeX
(
$els
);
renderWithKaTeX
(
$els
);
}
else
{
}
else
{
$
.
get
(
gon
.
katex_css_url
,
()
=>
{
axios
.
get
(
gon
.
katex_css_url
)
.
then
(()
=>
{
const
css
=
$
(
'
<link>
'
,
{
const
css
=
$
(
'
<link>
'
,
{
rel
:
'
stylesheet
'
,
rel
:
'
stylesheet
'
,
type
:
'
text/css
'
,
type
:
'
text/css
'
,
href
:
gon
.
katex_css_url
,
href
:
gon
.
katex_css_url
,
});
});
css
.
appendTo
(
'
head
'
);
css
.
appendTo
(
'
head
'
);
})
// Load KaTeX js
.
then
(()
=>
axios
.
get
(
gon
.
katex_js_url
,
{
$
.
getScript
(
gon
.
katex_js_url
,
()
=>
{
responseType
:
'
text
'
,
}))
.
then
(({
data
})
=>
{
// Add katex js to our document
$
.
globalEval
(
data
);
})
.
then
(()
=>
{
katexLoaded
=
true
;
katexLoaded
=
true
;
renderWithKaTeX
(
$els
);
// Run KaTeX
renderWithKaTeX
(
$els
);
// Run KaTeX
})
;
})
}
);
.
catch
(()
=>
flash
(
__
(
'
An error occurred while rendering KaTeX
'
))
);
}
}
}
}
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