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
Léo-Paul Géneau
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
Hide 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 @@
//
// <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