1.1.4:灯箱互斥,避免 Fancybox 与 ViewImage 各开一层
This commit is contained in:
31
Plugin.php
31
Plugin.php
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user