mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-24 20:17:24 +08:00
use details summary for spoiler
This commit is contained in:
@@ -290,13 +290,13 @@ function formatSpoiler($content, $title = '', $defaultCollapsed = true): string
|
|||||||
$title = $lang_functions['spoiler_default_title'];
|
$title = $lang_functions['spoiler_default_title'];
|
||||||
}
|
}
|
||||||
// $content = str_replace(['<br>', '<br />'], '', $content);
|
// $content = str_replace(['<br>', '<br />'], '', $content);
|
||||||
$contentClass = "spoiler-content";
|
$contentClass = "";
|
||||||
if ($defaultCollapsed) {
|
if ($defaultCollapsed) {
|
||||||
$contentClass .= " collapse";
|
$contentClass .= " open";
|
||||||
}
|
}
|
||||||
$HTML = sprintf(
|
$HTML = sprintf(
|
||||||
'<div><div class="spoiler-title-box"><div class="spoiler-title" title="%s">%s</div></div><div class="%s">%s</div></div>',
|
'<details%s><summary>%s</summary>%s</details>',
|
||||||
$lang_functions['spoiler_expand_collapse'], $title, $contentClass, $content
|
$contentClass, $title, $content
|
||||||
);
|
);
|
||||||
return addTempCode($HTML);
|
return addTempCode($HTML);
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
-9
@@ -1,13 +1,4 @@
|
|||||||
jQuery(document).ready(function () {
|
jQuery(document).ready(function () {
|
||||||
jQuery('.spoiler-title').on('click', function () {
|
|
||||||
let content = jQuery(this).parent().next();
|
|
||||||
if (content.hasClass('collapse')) {
|
|
||||||
content.height(content[0].scrollHeight).removeClass('collapse')
|
|
||||||
} else {
|
|
||||||
content.height(0).addClass('collapse')
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
function getImgPosition(e, imgEle) {
|
function getImgPosition(e, imgEle) {
|
||||||
// console.log(e, imgEle)
|
// console.log(e, imgEle)
|
||||||
let imgWidth = imgEle.prop('naturalWidth')
|
let imgWidth = imgEle.prop('naturalWidth')
|
||||||
|
|||||||
Vendored
+5
-7
@@ -4,20 +4,18 @@ img.hitandrun {
|
|||||||
background: url(icons.gif) no-repeat -100px -171px;
|
background: url(icons.gif) no-repeat -100px -171px;
|
||||||
margin-left: 0.5em;
|
margin-left: 0.5em;
|
||||||
}
|
}
|
||||||
.spoiler-title {
|
details summary {
|
||||||
|
width: fit-content;
|
||||||
line-height: 28px;
|
line-height: 28px;
|
||||||
color: #4d6c99;
|
color: #4d6c99;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
background-color: rgba(77, 108, 153, 0.1);
|
background-color: rgba(77, 108, 153, 0.1);
|
||||||
display: inline-block;
|
|
||||||
padding: 0 10px;
|
padding: 0 10px;
|
||||||
|
transition: margin .15s ease-out;
|
||||||
}
|
}
|
||||||
.spoiler-content {
|
details[open] summary {
|
||||||
display: inline-block;
|
margin-bottom: 10px;
|
||||||
height: 0;
|
|
||||||
overflow: hidden;
|
|
||||||
transition: height 0.3s ease;
|
|
||||||
}
|
}
|
||||||
.layui-layer {
|
.layui-layer {
|
||||||
color: black;
|
color: black;
|
||||||
|
|||||||
Reference in New Issue
Block a user