Separate inline listeners (#303)

This commit is contained in:
2021-06-30 20:40:42 +08:00 committed by GitHub
parent e942dc2d7e
commit 2329059cbd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 40 additions and 13 deletions

View File

@ -1,6 +1,6 @@
<div class="reward-container">
<div>{{ page.reward_settings.comment }}</div>
<button onclick="document.querySelector('.post-reward').classList.toggle('active');">
<button>
{{ __('reward.donate') }}
</button>
<div class="post-reward">

View File

@ -62,10 +62,8 @@
{%- if theme.chat.enable and (theme.chatra.enable or theme.tidio.enable or theme.gitter.enable) %}
<div class="sidebar-button site-overview-item animated">
{%- if theme.chatra.enable %}
<button onclick="Chatra('openChat', true);">
{%- elif theme.tidio.enable %}
<button onclick="tidioChatApi.open();">
{%- if theme.chatra.enable or theme.tidio.enable %}
<button>
{%- elif theme.gitter.enable %}
<button class="js-gitter-toggle-chat-button">
{%- endif %}

View File

@ -1 +1,2 @@
<script src="//code.tidio.co/{{ theme.tidio.key }}.js"></script>
{{ next_js('third-party/chat/tidio.js') }}

View File

@ -76,6 +76,7 @@ NexT.boot.refresh = function() {
NexT.utils.registerActiveMenuItem();
NexT.utils.registerLangSelect();
NexT.utils.registerSidebarTOC();
NexT.utils.registerPostReward();
NexT.utils.wrapTableWithBox();
NexT.utils.registerVideoIframe();
};

View File

@ -1,10 +1,19 @@
/* global CONFIG */
/* global CONFIG, Chatra */
if (CONFIG.chatra.embed) {
window.ChatraSetup = {
mode : 'frame',
injectTo: CONFIG.chatra.embed
};
}
(function() {
if (CONFIG.chatra.embed) {
window.ChatraSetup = {
mode : 'frame',
injectTo: CONFIG.chatra.embed
};
}
window.ChatraID = CONFIG.chatra.id;
window.ChatraID = CONFIG.chatra.id;
const chatButton = document.querySelector('.sidebar-button button');
if (chatButton) {
chatButton.addEventListener('click', () => {
Chatra('openChat', true);
});
}
})();

10
source/js/third-party/chat/tidio.js vendored Normal file
View File

@ -0,0 +1,10 @@
/* global tidioChatApi */
(function() {
const chatButton = document.querySelector('.sidebar-button button');
if (chatButton) {
chatButton.addEventListener('click', () => {
tidioChatApi.open();
});
}
})();

View File

@ -282,6 +282,14 @@ NexT.utils = {
});
},
registerPostReward: function() {
const button = document.querySelector('.reward-container button');
if (!button) return;
button.addEventListener('click', () => {
document.querySelector('.post-reward').classList.toggle('active');
});
},
activateNavByIndex: function(index) {
const target = document.querySelectorAll('.post-toc li a.nav-link')[index];
if (!target || target.classList.contains('active-current')) return;