parent
706e051d2e
commit
27ae0bcae7
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
$magicWords = [
|
||||
'en' => [
|
||||
'htmldetails' => [0, 'htmldetails'],
|
||||
'htmlsummary' => [0, 'htmlsummary'],
|
||||
],
|
||||
];
|
Binary file not shown.
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
namespace Isekai\Widgets;
|
||||
|
||||
use Html;
|
||||
|
||||
class Html5Widget {
|
||||
public static function createDetails(string $text, array $args, \Parser $parser, \PPFrame $frame) {
|
||||
$parser->getOutput()->addModules('ext.isekai.collapse');
|
||||
$allowedAttr = ['class'];
|
||||
$htmlArgs = array_filter($args, function($k) use($allowedAttr) {
|
||||
return in_array($k, $allowedAttr);
|
||||
}, ARRAY_FILTER_USE_KEY);
|
||||
|
||||
$content = '';
|
||||
if ($text) {
|
||||
$content = $parser->recursiveTagParse($text, $frame);
|
||||
}
|
||||
|
||||
return [Html::rawElement('details', $htmlArgs, $content), "markerType" => 'nowiki'];
|
||||
}
|
||||
|
||||
public static function createSummary(string $text, array $args, \Parser $parser, \PPFrame $frame) {
|
||||
$allowedAttr = ['class'];
|
||||
$htmlArgs = array_filter($args, function($k) use($allowedAttr) {
|
||||
return in_array($k, $allowedAttr);
|
||||
}, ARRAY_FILTER_USE_KEY);
|
||||
|
||||
$content = '';
|
||||
if ($text) {
|
||||
$content = $parser->recursiveTagParse($text, $frame);
|
||||
}
|
||||
|
||||
return [Html::rawElement('summary', $htmlArgs, $content), "markerType" => 'nowiki'];
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
(function($) {
|
||||
$('.isekai-collapse').addClass('animate')
|
||||
$('.isekai-collapse .isekai-collapse-title').on('click', '', function(e) {
|
||||
e.preventDefault();
|
||||
var titleElem = $(this);
|
||||
var containerElem = titleElem.parent('.isekai-collapse');
|
||||
var contentElem = containerElem.find('.isekai-collapse-content');
|
||||
if (containerElem.prop('open')) { // 需要收起
|
||||
var collapsedHeight = titleElem.outerHeight();
|
||||
var expandedHeight = collapsedHeight + contentElem.outerHeight();
|
||||
containerElem.css('height', expandedHeight);
|
||||
console.log('expandedHeight', expandedHeight);
|
||||
requestAnimationFrame(function() {
|
||||
console.log('collapsedHeight', collapsedHeight);
|
||||
containerElem.addClass('closing').css('height', collapsedHeight);
|
||||
setTimeout(function() {
|
||||
containerElem.prop('open', false).removeClass('closing'); //.css('height', 'auto');
|
||||
}, 260);
|
||||
});
|
||||
} else { // 需要展开
|
||||
containerElem.prop('open', true);
|
||||
var collapsedHeight = titleElem.outerHeight();
|
||||
containerElem.css('height', collapsedHeight);
|
||||
requestAnimationFrame(function() {
|
||||
var expandedHeight = collapsedHeight + contentElem.outerHeight();
|
||||
containerElem.css('height', expandedHeight);
|
||||
/*setTimeout(function() {
|
||||
containerElem.css('height', 'auto');
|
||||
}, 260);*/
|
||||
});
|
||||
}
|
||||
});
|
||||
})(jQuery);
|
@ -0,0 +1,64 @@
|
||||
.isekai-collapse {
|
||||
width: 50%;
|
||||
background: #fff;
|
||||
margin-bottom: .5rem;
|
||||
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
|
||||
border-radius: 5px;
|
||||
overflow: hidden;
|
||||
|
||||
@media screen and (max-width: 767px) {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
&.animate {
|
||||
overflow-y: hidden;
|
||||
will-change: height;
|
||||
transition: height 250ms ease-in-out;
|
||||
}
|
||||
|
||||
.isekai-collapse-title {
|
||||
padding: 1rem;
|
||||
display: block;
|
||||
background-color: #f7f7f7;
|
||||
padding-left: 2.2rem;
|
||||
position: relative;
|
||||
cursor: pointer;
|
||||
color: black;
|
||||
font-size: 1rem;
|
||||
|
||||
&::before {
|
||||
content: '';
|
||||
border-width: 0.4rem;
|
||||
border-style: solid;
|
||||
border-color: transparent transparent transparent #000;
|
||||
position: absolute;
|
||||
top: 1.32rem;
|
||||
left: 1.2rem;
|
||||
transform: rotate(0);
|
||||
transform-origin: 0.2rem 50%;
|
||||
will-change: transform;
|
||||
transition: transform 250ms ease;
|
||||
}
|
||||
|
||||
&::-webkit-details-marker {
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
}
|
||||
|
||||
.isekai-collapse-content {
|
||||
padding: 1em;
|
||||
}
|
||||
|
||||
&[open] > .isekai-collapse-title:before {
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
|
||||
&.closing[open] > .isekai-collapse-title:before {
|
||||
transform: rotate(0);
|
||||
}
|
||||
}
|
||||
|
||||
.isekai-indent > .isekai-collapse {
|
||||
padding-left: 0;
|
||||
margin-left: 8px;
|
||||
}
|
Loading…
Reference in New Issue