Skip to content

Commit

Permalink
[K6.0] The spoiler changes from Click to expand to true (part 3) #9458
Browse files Browse the repository at this point in the history
  • Loading branch information
xillibit committed Jan 26, 2023
1 parent 172ca9a commit 3c8f754
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 30 deletions.
7 changes: 0 additions & 7 deletions src/libraries/kunena/src/BBCode/KunenaBBCode.php
Expand Up @@ -1540,12 +1540,6 @@ public function DoSpoiler($bbcode, $action, $name, $default, $params, $content)
$title = $default ? $default : Text::_('COM_KUNENA_BBCODE_SPOILER');
$hidden = ($document instanceof HtmlDocument);

if ($bbcode->parent->message instanceof KunenaMessage) {
$message_id = $bbcode->parent->message->id;
} else {
$message_id = $bbcode->parent->id;
}

$layout = KunenaLayout::factory('BBCode/Spoiler');

if ($layout->getPath()) {
Expand All @@ -1555,7 +1549,6 @@ public function DoSpoiler($bbcode, $action, $name, $default, $params, $content)
->set('title', htmlspecialchars($title, ENT_COMPAT, 'UTF-8'))
->set('hidden', $hidden)
->set('content', $content)
->set('message_id', $message_id)
->set('params', $params);
}

Expand Down
17 changes: 6 additions & 11 deletions src/site/template/aurelia/assets/js/topic.js
Expand Up @@ -10,17 +10,12 @@
jQuery(document).ready(function ($) {

/* To hide or open spoiler on click */
var collapseElementList = [].slice.call(document.querySelectorAll('.collapse'))
var collapseList = collapseElementList.map(function (collapseEl) {
collapseEl.addEventListener('shown.bs.collapse', function (mopt) {
var idString = collapseEl.id;
$('#collapse-btn'+idString.substr(15)).html(Joomla.Text._('COM_KUNENA_LIB_BBCODE_SPOILER_HIDE'));
})
collapseEl.addEventListener('hidden.bs.collapse', function (mopt) {
var idString = collapseEl.id;
$('#collapse-btn'+idString.substr(15)).html(Joomla.Text._('COM_KUNENA_LIB_BBCODE_SPOILER_EXPAND'));
})
})
$(document).on('click', '.kspoiler-expand', function (e) {
e.preventDefault()
const show = $(this.children[0]).val() === Joomla.Text._('COM_KUNENA_LIB_BBCODE_SPOILER_EXPAND');
$(this.children[0]).val(show ? Joomla.Text._('COM_KUNENA_LIB_BBCODE_SPOILER_HIDE') : Joomla.Text._('COM_KUNENA_LIB_BBCODE_SPOILER_EXPAND'));
$(this).parent().children('.kspoiler-wrapper').toggle()
});

/* To allow to close or open the quick-reply modal box */
$('.openmodal').click(function () {
Expand Down
26 changes: 14 additions & 12 deletions src/site/template/aurelia/layouts/bbcode/spoiler/default.php
Expand Up @@ -24,16 +24,18 @@
Text::script('COM_KUNENA_LIB_BBCODE_SPOILER_EXPAND');
?>

<p>
<div class="kspoiler-title" style="display:inline-block;">
<?php echo $this->title; ?>
</div>
<a class="btn btn-primary" id="collapse-btn<?php echo $this->message_id ?>" data-bs-toggle="collapse" href="#collapseSpoiler<?php echo $this->message_id ?>" role="button" aria-expanded="false" aria-controls="collapseSpoiler<?php echo $this->message_id ?>">
<?php echo Text::_('COM_KUNENA_LIB_BBCODE_SPOILER_EXPAND'); ?>
</a>
</p>
<div class="collapse" id="collapseSpoiler<?php echo $this->message_id ?>">
<div class="card card-body">
<?php echo $this->content; ?>
</div>
<div class="kspoiler">
<div class="kspoiler-header">
<div class="kspoiler-title" style="display:inline-block;">
<?php echo $this->title; ?>
</div>
<div class="kspoiler-expand" style="display:inline-block;">
<input class="btn btn-primary" type="button" id="kspoiler-show" value="<?php echo Text::_('COM_KUNENA_LIB_BBCODE_SPOILER_EXPAND'); ?>"/>
</div>
<div class="kspoiler-wrapper" style="display:none;">
<div class="kspoiler-content">
<?php echo $this->content; ?>
</div>
</div>
</div>
</div>

0 comments on commit 3c8f754

Please sign in to comment.