refactor: optimize code structure (#540)

pull/548/head
n0099 2022-11-12 10:34:50 +08:00 committed by GitHub
parent 82841130b3
commit 2bb8f1a22c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 28 deletions

View File

@ -14,9 +14,7 @@
} }
var tooltipConfig = function () { var tooltipConfig = function () {
$(function () { $('[data-toggle="tooltip"]').tooltip()
$('[data-toggle="tooltip"]').tooltip()
})
} }
var gotopConfig = function () { var gotopConfig = function () {
@ -34,33 +32,18 @@
}) })
$('.gotop').on('click', function (event) { $('.gotop').on('click', function (event) {
event.preventDefault() event.preventDefault()
$('html, body').animate( $('html, body').animate({ scrollTop: $('html').offset().top }, 500)
{
scrollTop: $('html').offset().top
},
500
)
return false return false
}) })
} }
var searchConfig = function () { var searchConfig = function () {
$('.search').on('click', function (e) { $('.search').on('click', function (e) {
$('.search-form').animate( $('.search-form').animate({ width: '200px' }, 200)
{ $('.search-form input').css('display', 'block')
width: '200px'
},
200
),
$('.search-form input').css('display', 'block')
$(document).one('click', function () { $(document).one('click', function () {
$('.search-form').animate( $('.search-form').animate({ width: '0' }, 100)
{ $('.search-form input').hide()
width: '0'
},
100
),
$('.search-form input').hide()
}) })
e.stopPropagation() e.stopPropagation()
}) })
@ -92,7 +75,7 @@
var postlikeConfig = function () { var postlikeConfig = function () {
$.fn.postLike = function () { $.fn.postLike = function () {
if ($(this).hasClass('done')) { if ($(this).hasClass('done')) {
layer.msg(kratos.repeat, function () { }) layer.msg(kratos.repeat, function () {})
return false return false
} else { } else {
$(this).addClass('done') $(this).addClass('done')
@ -134,7 +117,7 @@
kratos.directory + kratos.directory +
'/assets/img/payment/wechat.png"></label></div></div>' '/assets/img/payment/wechat.png"></label></div></div>'
}) })
$(".choose-pay input[type='radio']").click(function () { $('.choose-pay input[type="radio"]').click(function () {
var id = $(this).attr('id') var id = $(this).attr('id')
if (id == 'alipay') { if (id == 'alipay') {
$('.qr-pay #alipay_qr').removeClass('d-none') $('.qr-pay #alipay_qr').removeClass('d-none')
@ -171,7 +154,7 @@
}) })
} }
window.initKratos = function () { document.addEventListener('DOMContentLoaded', function () {
accordionConfig() accordionConfig()
navbarConfig() navbarConfig()
tooltipConfig() tooltipConfig()
@ -183,8 +166,7 @@
donateConfig() donateConfig()
consoleConfig() consoleConfig()
lightGalleryConfig() lightGalleryConfig()
}; });
$(window.initKratos);
})() })()
function grin(tag) { function grin(tag) {