1.1.4:灯箱互斥,避免 Fancybox 与 ViewImage 各开一层

This commit is contained in:
XIGE
2026-12-03 22:40:56 +08:00
parent 8352bbfa05
commit c1612b5ca8
2 changed files with 33 additions and 2 deletions

View File

@@ -2,6 +2,10 @@
> 本文件记录本插件的所有修改与变化。仓库建立于 2026-12-03,此前历史见插件目录内的 `更新日志.MD`。
## 2026-12-03 · 1.1.4:灯箱互斥,避免 Fancybox 与 ViewImage 各开一层
- 同步源码更新 1 个文件(新增/修改 1,删除 0)。
## 插件信息
- 名称:FlexPhoto(图片横排)

View File

@@ -5,7 +5,7 @@ if (!defined('__TYPECHO_ROOT_DIR__')) exit;
*
* @package FlexPhoto
* @author 石头厝
* @version 1.1.3
* @version 1.1.4
* @link https://www.shitoucuo.com/
*/
class FlexPhoto_Plugin implements Typecho_Plugin_Interface
@@ -56,7 +56,34 @@ class FlexPhoto_Plugin implements Typecho_Plugin_Interface
public static function skinhead(){
?>
<link rel="stylesheet" href="<?php Helper::options()->pluginUrl(); ?>/FlexPhoto/style.css?20261203a">
<link rel="stylesheet" href="<?php Helper::options()->pluginUrl(); ?>/FlexPhoto/style.css?20261203b">
<script>
(function () {
/* 灯箱互斥:本主题默认只有 ViewImage 一个灯箱,画廊缩略图由它接管即可。
若站点额外装了 Fancybox(data-fancybox 属性本来就是给它用的),
就让 Fancybox 负责画廊,缩略图打上 no-view 让 ViewImage 跳过,
避免一次点击弹出两层。 */
function guard() {
if (!window.Fancybox) { return; }
var imgs = document.querySelectorAll('.flexphoto img');
for (var i = 0; i < imgs.length; i++) {
imgs[i].setAttribute('no-view', '');
}
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', guard);
} else {
guard();
}
/* Fancybox 可能异步加载,加载完再兜一次 */
window.addEventListener('load', guard);
/* 分页/无限滚动后新插入的图同样处理 */
if (window.MutationObserver) {
new MutationObserver(guard).observe(document.body, {childList: true, subtree: true});
}
})();
</script>
<?php
}
public static function tutu($data, $ojbk,$last)