🐛 fix: 修復highlight_shrink設為false時,導致script報錯的bug

🐛 fix: 修復highlight_shrink設為true時,按鈕點擊無反應,沒有打開代碼框的bug
🐛 fix: 修復自動切換darkmode時,切換按鈕icon沒有變更的bug
This commit is contained in:
Jerry
2020-03-24 19:03:51 +08:00
Unverified
parent ce72ba4f5d
commit c134d4fc86
2 changed files with 5 additions and 6 deletions

View File

@@ -112,7 +112,7 @@ script.
baiduPush: !{baiduPush}, baiduPush: !{baiduPush},
highlightCopy: !{highlightCopy}, highlightCopy: !{highlightCopy},
highlightLang: !{highlightLang}, highlightLang: !{highlightLang},
highlightShrink: !{highlightShrink}, highlightShrink: '!{highlightShrink}',
isFontAwesomeV5: !{isFontAwesomeV5} isFontAwesomeV5: !{isFontAwesomeV5}
} }

View File

@@ -271,16 +271,16 @@ $(function () {
* 代碼收縮 * 代碼收縮
*/ */
const $highlightTools = $('.highlight-tools') const $highlightTools = $('.highlight-tools')
if (isHighlightShrink === true) { if (isHighlightShrink === 'true') {
$highlightTools.append('<i class="fa fa-angle-down code-expand code-closed" aria-hidden="true"></i>') $highlightTools.append('<i class="fa fa-angle-down code-expand code-closed" aria-hidden="true"></i>')
} else if (isHighlightShrink === false) { } else if (isHighlightShrink === 'false') {
$highlightTools.append('<i class="fa fa-angle-down code-expand" aria-hidden="true"></i>') $highlightTools.append('<i class="fa fa-angle-down code-expand" aria-hidden="true"></i>')
} }
$(document).on('click', '.highlight-tools >.code-expand', function () { $(document).on('click', '.highlight-tools >.code-expand', function () {
var $table = $(this).parent().next() var $table = $(this).parent().next()
if ($(this).hasClass('code-closed')) { if ($(this).hasClass('code-closed')) {
$table.css('display', '') $table.css('display', 'block')
$(this).removeClass('code-closed') $(this).removeClass('code-closed')
} else { } else {
$table.css('display', 'none') $table.css('display', 'none')
@@ -668,8 +668,7 @@ $(function () {
var isFontAwesomeV5 = GLOBAL_CONFIG.isFontAwesomeV5 var isFontAwesomeV5 = GLOBAL_CONFIG.isFontAwesomeV5
var $darkModeButtom = $('#darkmode') var $darkModeButtom = $('#darkmode')
if (typeof autoChangeMode !== 'undefined') { if (typeof autoChangeMode !== 'undefined') {
if (Cookies.get('theme') === 'dark') changeLightIcon() document.documentElement.getAttribute('data-theme') === 'dark' ? changeLightIcon() : changeDarkIcon()
else changeDarkIcon()
} }
function changeLightIcon () { function changeLightIcon () {