优化折叠框 folding和分栏 tab里的gallery 相册

This commit is contained in:
1152958806@qq.com 2023-08-29 15:40:03 +08:00
parent aca361db4f
commit bf12d22fe4
2 changed files with 4 additions and 42 deletions

View File

@ -98,31 +98,6 @@ document.addEventListener('DOMContentLoaded', function () {
}
}
// let detectJgJsLoad = false
// const runJustifiedGallery = function (ele) {
// const $justifiedGallery = $(ele)
// const $imgList = $justifiedGallery.find('img')
// $imgList.unwrap()
// if ($imgList.length) {
// $imgList.each(function (i, o) {
// if ($(o).attr('data-lazy-src')) $(o).attr('src', $(o).attr('data-lazy-src'))
// $(o).wrap('<div class="fj-gallery-item"></div>')
// })
// }
// const $gallery = document.querySelectorAll('.gallery')
// if (detectJgJsLoad) btf.initJustifiedGallerys($gallery)
// else {
// $('head').append(`<link rel="stylesheet" type="text/css" href="${GLOBAL_CONFIG.source.justifiedGallery.css}">`)
// $.getScript(`${GLOBAL_CONFIG.source.justifiedGallery.js}`, function () {
// btf.initJustifiedGallerys($gallery)
// })
// detectJgJsLoad = true
// }
// }
/**
* fancybox
*/
@ -355,8 +330,8 @@ document.addEventListener('DOMContentLoaded', function () {
const $hideContent = $this.nextElementSibling
$this.classList.toggle('open')
if ($this.classList.contains('open')) {
if ($hideContent.querySelectorAll('.justified-gallery').length > 0) {
btf.initJustifiedGallery($hideContent.querySelectorAll('.justified-gallery'))
if ($hideContent.querySelectorAll('.gallery').length > 0) {
btf.initJustifiedGallerys($hideContent.querySelectorAll('.gallery'))
}
}
})
@ -382,9 +357,9 @@ document.addEventListener('DOMContentLoaded', function () {
if (item.id === tabId) item.classList.add('active')
else item.classList.remove('active')
})
const $isTabJustifiedGallery = $tabContent.querySelectorAll(`#${tabId} .justified-gallery`)
const $isTabJustifiedGallery = $tabContent.querySelectorAll(`#${tabId} .gallery`)
if ($isTabJustifiedGallery.length > 0) {
btf.initJustifiedGallery($isTabJustifiedGallery)
btf.initJustifiedGallerys($isTabJustifiedGallery)
}
}
})

View File

@ -201,19 +201,6 @@ var btf = {
});
},
initJustifiedGallery: function (selector) {
if (!(selector instanceof jQuery)) {
selector = $(selector)
}
selector.each(function (i, o) {
if ($(this).is(':visible')) {
$(this).justifiedGallery({
rowHeight: 220,
margins: 4
})
}
})
},
initJustifiedGallerys: function (selector) {
selector.forEach((function(t) {
btf.isHidden(t) || fjGallery(t, {