Skip to content

Commit

Permalink
[K6.3]Add tabs when use Sceditor to be able to write the private message
Browse files Browse the repository at this point in the history
  • Loading branch information
xillibit committed Feb 28, 2024
1 parent ecab114 commit 8e67e6c
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 1 deletion.
40 changes: 40 additions & 0 deletions src/site/template/aurelia/assets/js/sceditor.js
Expand Up @@ -690,6 +690,7 @@ jQuery(document).ready(function ($) {
});

var textarea = document.getElementById('message');
var textarea_private = document.getElementById('message_private');
var toolbar_buttons = '';
if(Joomla.getOptions('com_kunena.template_editor_buttons_configuration') !== undefined)
{
Expand Down Expand Up @@ -747,5 +748,44 @@ jQuery(document).ready(function ($) {
$('#form_submit_button').prop("disabled", true);
}
});

sceditor.create(textarea_private, {
format: 'bbcode',
toolbar: toolbar_buttons,
style: Joomla.getOptions('com_kunena.sceditor_style_path'),
emoticonsRoot: Joomla.getOptions('com_kunena.root_path')+'/media/kunena/emoticons/',
/*emoticons: {
// Emoticons to be included in the dropdown
dropdown: list_emoticons,
// Emoticons to be included in the more section
more: {
':alien:': 'emoticons/alien.png',
':blink:': 'emoticons/blink.png'
},
// Emoticons that are not shown in the dropdown but will still
// be converted. Can be used for things like aliases
hidden: {
':aliasforalien:': 'emoticons/alien.png',
':aliasforblink:': 'emoticons/blink.png'
}
}*/
});

if (sceditor.instance(textarea_private).val().length > 0)
{
$('#form_submit_button').removeAttr("disabled");
}

sceditor.instance(textarea_private).bind('valuechanged', function(e) {
if (sceditor.instance(textarea_private).val().length > 0)
{
$('#form_submit_button').removeAttr("disabled");
}

if (sceditor.instance(textarea_private).val().length == 0 && $('#form_submit_button').disabled === undefined)
{
$('#form_submit_button').prop("disabled", true);
}
});
}
});
28 changes: 27 additions & 1 deletion src/site/template/aurelia/layouts/widget/editor/sceditor.php
Expand Up @@ -13,6 +13,7 @@

defined('_JEXEC') or die();

use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Kunena\Forum\Libraries\Html\KunenaParser;
use Kunena\Forum\Libraries\Route\KunenaRoute;
Expand Down Expand Up @@ -58,7 +59,7 @@
$this->doc->addScriptOptions('com_kunena.editor_emoticons', json_encode(KunenaParser::getEmoticons(0, 1, 0)));

$this->wa->registerAndUseScript('sceditor', 'components/com_kunena/template/aurelia/assets/js/sceditor.js');

HTMLHelper::_('bootstrap.tab');
// Echo $this->subLayout('Widget/Datepicker');

$topictemplate = !$this->config->pickup_category;
Expand All @@ -74,6 +75,18 @@ function localstorageremove() {
}
</script>

<ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item" role="presentation">
<button class="nav-link active" id="home-tab" data-bs-toggle="tab" data-bs-target="#message-tab" type="button" role="tab" aria-controls="home" aria-selected="true"><?php echo Text::_('COM_KUNENA_MESSAGE_TAB_MESSAGE') ?></button>
</li>
<?php if ($this->config->privateMessage): ?>
<li class="nav-item" role="presentation">
<button class="nav-link" id="profile-tab" data-bs-toggle="tab" data-bs-target="#message_private-tab" type="button" role="tab" aria-controls="profile" aria-selected="false"><?php echo Text::_('COM_KUNENA_MESSAGE_TAB_PRIVATE_MESSAGE') ?></button>
</li>
<?php endif; ?>
</ul>
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active" id="message-tab" role="tabpanel" aria-labelledby="home-tab">
<textarea class="span12" name="message" id="message" rows="12" tabindex="7"
placeholder="<?php echo Text::_('COM_KUNENA_ENTER_MESSAGE') ?>"><?php if (!empty($this->message->getCategory()->topictemplate) && !$this->message->getTopic()->first_post_id && $topictemplate) {
echo $this->message->getCategory()->topictemplate;
Expand All @@ -83,6 +96,19 @@ function localstorageremove() {
echo $this->escape($this->message->message);
} ?>
</textarea>
</div>
<div class="tab-pane fade" id="message_private-tab" role="tabpanel" aria-labelledby="profile-tab">
<textarea class="span12" name="message_private" id="message_private" rows="12" tabindex="7"
placeholder="<?php echo Text::_('COM_KUNENA_ENTER_MESSAGE') ?>"><?php if (!empty($this->message->getCategory()->topictemplate) && !$this->message->getTopic()->first_post_id && $topictemplate) {
echo $this->message->getCategory()->topictemplate;
}

if (!empty($this->message->message)) {
echo $this->escape($this->message->message);
} ?>
</textarea>
</div>
</div>

<input type="hidden" name="nb_options_allowed" id="nb_options_allowed"
value="<?php echo $this->config->pollNbOptions; ?>"/>
Expand Down

0 comments on commit 8e67e6c

Please sign in to comment.