Commit 38b3d8ef authored by Van's avatar Van

🎨 #12720

parent b4b2236a
......@@ -17,9 +17,6 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
-->
<script src="${staticServePath}/js/lib/compress/pjax.min.js"></script>
<script src="${staticServePath}/js/common${miniPostfix}.js?${staticResourceVersion}"></script>
<script src="${staticServePath}/skins/${skinDirName}/js/common${miniPostfix}.js?${staticResourceVersion}"></script>
<script>
var Label = {
"servePath": "${servePath}",
......
......@@ -37,16 +37,7 @@
</div>
</#if>
<script type="text/javascript">
if (!window.Page) {
var xhrObj = new XMLHttpRequest()
xhrObj.open('GET', '${staticServePath}/js/page${miniPostfix}.js?${staticResourceVersion}', false)
xhrObj.setRequestHeader('Accept', 'text/javascript, application/javascript, application/ecmascript, application/x-ecmascript, */*; q=0.01')
xhrObj.send('')
var scriptElement = document.createElement('script')
scriptElement.type = 'text/javascript'
scriptElement.text = xhrObj.responseText
document.getElementsByTagName('head')[0].appendChild(scriptElement)
}
Util.addScript('${staticServePath}/js/page${miniPostfix}.js?${staticResourceVersion}', 'soloPageScript')
var page = new Page({
"commentContentCannotEmptyLabel": "${commentContentCannotEmptyLabel}",
"oId": "${oId}",
......
......@@ -103,6 +103,11 @@ var Util = {
window.open(this.src)
})
},
/**
* 异步添加 css
* @param url css 文件访问地址
* @param id css 文件标示
*/
addStyle: function (url, id) {
if (!document.getElementById(id)) {
var styleElement = document.createElement('link')
......@@ -113,6 +118,25 @@ var Util = {
document.getElementsByTagName('head')[0].appendChild(styleElement)
}
},
/**
* 异步添加 js
* @param url js 文件访问地址
* @param id js 文件标示
*/
addScript: function (url, id) {
if (!document.getElementById(id)) {
var xhrObj = new XMLHttpRequest()
xhrObj.open('GET', url, false)
xhrObj.setRequestHeader('Accept',
'text/javascript, application/javascript, application/ecmascript, application/x-ecmascript, */*; q=0.01')
xhrObj.send('')
var scriptElement = document.createElement('script')
scriptElement.id = id
scriptElement.type = 'text/javascript'
scriptElement.text = xhrObj.responseText
document.getElementsByTagName('head')[0].appendChild(scriptElement)
}
},
/*
* @description 解析语法高亮
*/
......@@ -141,23 +165,19 @@ var Util = {
}
},
/**
* 按需加载 MathJax 及图标
* 按需加载数学公式、代码复制、图标
* @returns {undefined}
*/
parseMarkdown: function () {
if (!window.Vditor) {
var xhrObj = new XMLHttpRequest()
xhrObj.open('GET', Label.staticServePath +
'/js/lib/vditor-1.1.10/index.min.js', false)
xhrObj.setRequestHeader('Accept',
'text/javascript, application/javascript, application/ecmascript, application/x-ecmascript, */*; q=0.01')
xhrObj.send('')
var scriptElement = document.createElement('script')
scriptElement.type = 'text/javascript'
scriptElement.text = xhrObj.responseText
document.getElementsByTagName('head')[0].appendChild(scriptElement)
var text = $('.vditor-reset').text()
if ($('.vditor-reset pre > code').length === 0 ||
!(text.split('$').length > 2 ||
(text.split('\\(').length > 1 && text.split('\\)').length > 1))) {
return
}
Util.addScript(Label.staticServePath + '/js/lib/vditor-1.1.10/index.min.js', 'vditorScript')
Vditor.mermaidRender(document.body)
Vditor.mathRender(document.body)
Vditor.codeRender(document.body, Label.langLabel)
......
......@@ -65,6 +65,7 @@ $.extend(Page.prototype, {
if (typeof vditor === 'undefined') {
var that = this
Util.addScript(Label.staticServePath + '/js/lib/vditor-1.1.10/index.min.js', 'vditorScript')
window.vditor = new Vditor('soloEditorComment', {
placeholder: that.tips.commentContentCannotEmptyLabel,
height: 180,
......
Subproject commit 1605dceed8fe66f27f266881e237957248d23fb7
Subproject commit 8c9b13c393450bd679876182c350de5fd7bd8d2c
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment