Skip to content

Commit

Permalink
Added WYSIWYG option to local commenting form plugin.
Browse files Browse the repository at this point in the history
  • Loading branch information
cheesegrits committed Dec 12, 2015
1 parent c372cd7 commit 0f02329
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 13 deletions.
24 changes: 24 additions & 0 deletions plugins/fabrik_form/comment/comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,17 @@ protected function loadThumbJsOpts()
return $opts;
}

/**
* Is the WYWIWYG option enabled for local commenting
*
* @return boolean
*/
protected function isWYSIWYG()
{
$params = $this->getParams();
return $params->get('comment_internal_wysiwyg', '0') === '1';
}

/**
* Prepare local comment system
*
Expand Down Expand Up @@ -219,6 +230,7 @@ protected function _internal()
$opts->rowid = $rowId;
$opts->admin = $this->user->authorise('core.delete', 'com_fabrik');
$opts->label = '';
$opts->wysiwyg = $this->isWYSIWYG();

foreach ($formModel->data as $k => $v)
{
Expand Down Expand Up @@ -288,6 +300,18 @@ private function getAddCommentForm($reply_to = 0, $master = false)
$layoutData->name = trim($input->get('ide_people___voornaam', '', 'cookie') . ' ' . $input->get('ide_people___achternaam', '', 'cookie'));
$layoutData->email = $input->get('ide_people___email', '', 'cookie');
$layoutData->renderOrder = $this->renderOrder;
$layoutData->wysiwyg = $this->isWYSIWYG();

if ($layoutData->wysiwyg)
{
$cols = $params->get('comment_internal_wysiwyg_cols', '100');
$rows = $params->get('comment_internal_wysiwyg_rows', '5');
$layoutData->id = 'fabrik_form_comment_' . $layoutData->renderOrder . '_' . $reply_to;
$editor = JEditor::getInstance($this->config->get('editor'));
$buttons = (bool) $params->get('comment_internal_wysiwyg_extra_buttons', false);
$layoutData->editor = $editor->display($layoutData->id, '', '100%', '100%', $cols, $rows, $buttons, $layoutData->id);
}

$layoutData->userLoggedIn = $this->user->get('id') != 0;

return $layout->render($layoutData);
Expand Down
2 changes: 1 addition & 1 deletion plugins/fabrik_form/comment/comments-min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 25 additions & 12 deletions plugins/fabrik_form/comment/comments.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ var FabrikComment = new Class({
return {
'formid': 0,
'rowid': 0,
'label': ''
'label': '',
'wysiwyg': false
};
},

Expand Down Expand Up @@ -174,6 +175,13 @@ var FabrikComment = new Class({
return;
}
}

if (this.options.wysiwyg) {
if (typeof tinyMCE !== 'undefined') {
tinyMCE.triggerSave();
}
}

var v = replyform.getElement('textarea').get('value');
e.stop();
if (v === '') {
Expand Down Expand Up @@ -256,20 +264,25 @@ var FabrikComment = new Class({
commentform = a.getParent('.comment').getElement('.replyform');
}
if (typeOf(commentform) !== 'null') {
var li = a.getParent('.comment').getParent('li');
if (window.ie) {
fx = new Fx.Slide(commentform, 'opacity', {
duration : 5000
});

} else {
if (this.fx.toggleForms.has(li.id)) {
fx = this.fx.toggleForms.get(li.id);
} else {
if (this.options.wysiwyg) {
fx = commentform;
}
else {
var li = a.getParent('.comment').getParent('li');
if (window.ie) {
fx = new Fx.Slide(commentform, 'opacity', {
duration : 5000
});
this.fx.toggleForms.set(li.id, fx);

} else {
if (this.fx.toggleForms.has(li.id)) {
fx = this.fx.toggleForms.get(li.id);
} else {
fx = new Fx.Slide(commentform, 'opacity', {
duration : 5000
});
this.fx.toggleForms.set(li.id, fx);
}
}
}

Expand Down
11 changes: 11 additions & 0 deletions plugins/fabrik_form/comment/forms/fields.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@

<fieldset name="plg-form-comment-local" label="PLG_FORM_COMMENT_LOCAL_COMMENTING_SETTINGS">

<field name="comment_internal_wysiwyg"
type="radio"
default="0"
class="btn-group"
description="PLG_FORM_COMMENT_INTERNAL_WYSIWYG_DESC"
label="PLG_FORM_COMMENT_INTERNAL_WYSIWYG_LABEL"
repeat="true">
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>

<field name="comment_lock_element"
type="listfields"
description="PLG_FORM_COMMENT_LOCK_COMMENTS_DESC"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ PLG_FORM_COMMENT_DISQUS_DOMAIN_DESC="Sign up for a Disqus account @ http://disqu
PLG_FORM_COMMENT_INTENSE_DEBATE="Intense debate"
PLG_FORM_COMMENT_INTENSE_DEBATE_CODE_LABEL="Intense debate site key"
PLG_FORM_COMMENT_INTENSE_DEBATE_CODE_DESC="Sign up for an Intense debate code @ http://intensedebate.com/"
PLG_FORM_COMMENT_INTERNAL_WYSIWYG_DESC="Use WYSIWYG editor instead of simple textarea, only tested with standard Joomla TinyMC.E"
PLG_FORM_COMMENT_INTERNAL_WYSIWYG_LABEL="WYSIWYG"
PLG_FORM_COMMENT_LOCK_COMMENTS_LABEL="Lock comments element"
PLG_FORM_COMMENT_LOCK_COMMENTS_DESC="Select an element whose value, if set to 1 will disable addition of comments"
PLG_FORM_COMMENT_LOCAL_COMMENTING="Local commenting"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@
?>
<form action="index.php" <?php echo $d->formId; ?> class="replyform">
<p>
<?php
if ($d->wysiwyg) :
echo $d->editor;
else :
?>
<textarea style="width:95%" rows="6" cols="3" placeholder="<?php echo FText::_('PLG_FORM_COMMENT_TYPE_A_COMMENT_HERE'); ?>"></textarea>
<?php
endif;
?>
</p>
<table class="adminForm" style="width:350px" summary="comments">
<?php
Expand Down

0 comments on commit 0f02329

Please sign in to comment.