输出界面支持搜索

This commit is contained in:
fofolee
2020-07-02 22:05:31 +08:00
parent ed9b130305
commit 38edf7730b
4 changed files with 70 additions and 9 deletions

View File

@@ -1085,6 +1085,26 @@
programCheck()
$("#options").show()
}
// 输出搜索
let showSearchBox = () => {
if ($('#options').is(':hidden') && $('#out').is(":parent")) {
$('#out').append(`<div id="outputSearch"><input autofocus="autofocus"><kbd id="find-next">↓</kbd><kbd id="find-prev">↑</kbd><kbd id="find-close">✕</kbd></div>`)
$('#outputSearch').animate({ opacity: 1, top: '10px', })
document.getElementById('find-next').onclick = () => {
utools.findInPage($('#outputSearch > input').val())
}
document.getElementById('find-prev').onclick = () => {
utools.findInPage($('#outputSearch > input').val(), { forward: false })
}
document.getElementById('find-close').onclick = () => {
utools.stopFindInPage()
$('#outputSearch').animate({ opacity: 0, top: '-30px', }, () => {
$('#outputSearch').remove()
})
}
}
}
// 切换TAGS
$("#options").on('click', '.sidebar li', function () {
@@ -1156,4 +1176,9 @@
runCurrentCommand()
return false
});
Mousetrap.bind('ctrl+f', () => {
showSearchBox()
return false
});
}()