BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
f4b91f7a
Commit
f4b91f7a
authored
Jan 31, 2018
by
Phil Hughes
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'axios-get-render-math' into 'master'
Replace $.get in render math with axios See merge request gitlab-org/gitlab-ce!16697
parents
078dac42
c41fffdb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
13 deletions
+25
-13
render_math.js
app/assets/javascripts/render_math.js
+25
-13
No files found.
app/assets/javascripts/render_math.js
View file @
f4b91f7a
...
...
@@ -7,7 +7,12 @@
//
// <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
;
// Loop over all math elements and render math
...
...
@@ -33,19 +38,26 @@ export default function renderMath($els) {
if
(
katexLoaded
)
{
renderWithKaTeX
(
$els
);
}
else
{
$
.
get
(
gon
.
katex_css_url
,
()
=>
{
const
css
=
$
(
'<link>'
,
{
rel
:
'stylesheet'
,
type
:
'text/css'
,
href
:
gon
.
katex_css_url
,
});
css
.
appendTo
(
'head'
);
// Load KaTeX js
$
.
getScript
(
gon
.
katex_js_url
,
()
=>
{
axios
.
get
(
gon
.
katex_css_url
)
.
then
(()
=>
{
const
css
=
$
(
'<link>'
,
{
rel
:
'stylesheet'
,
type
:
'text/css'
,
href
:
gon
.
katex_css_url
,
});
css
.
appendTo
(
'head'
);
})
.
then
(()
=>
axios
.
get
(
gon
.
katex_js_url
,
{
responseType
:
'text'
,
}))
.
then
(({
data
})
=>
{
// Add katex js to our document
$
.
globalEval
(
data
);
})
.
then
(()
=>
{
katexLoaded
=
true
;
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