-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
edit.php
68 lines (52 loc) · 2.54 KB
/
edit.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
use humhub\compat\CActiveForm;
use humhub\compat\CHtml;
use yii\helpers\Url;
?>
<div class="content_edit" id="post_edit_<?php echo $post->id; ?>">
<?php $form = CActiveForm::begin(['id' => 'post-edit-form']); ?>
<?php echo $form->textArea($post, 'message', array('class' => 'form-control', 'id' => 'post_input_' . $post->id, 'placeholder' => Yii::t('PostModule.views_edit', 'Edit your post...'))); ?>
<!-- create contenteditable div for HEditorWidget to place the data -->
<div id="post_input_<?php echo $post->id; ?>_contenteditable" class="form-control atwho-input"
contenteditable="true"><?php echo \humhub\widgets\RichText::widget(['text' => $post->message, 'edit' => true]); ?></div>
<?= \humhub\widgets\RichTextEditor::widget(['id' => 'post_input_' . $post->id, 'inputContent' => $post->message, 'record' => $post]); ?>
<div class="comment-buttons">
<?php
// Creates Uploading Button
echo humhub\modules\file\widgets\FileUploadButton::widget(array(
'uploaderId' => 'post_upload_' . $post->id,
'object' => $post
));
?>
<?php
echo \humhub\widgets\AjaxButton::widget([
'label' => 'Save',
'ajaxOptions' => [
'type' => 'POST',
'beforeSend' => new yii\web\JsExpression('function(html){ $("#post_input_' . $post->id . '_contenteditable").hide(); showLoader("' . $post->id . '"); }'),
'success' => new yii\web\JsExpression('function(html){ $(".wall_' . $post->getUniqueId() . '").replaceWith(html); }'),
'url' => $post->content->container->createUrl('/post/post/edit', ['id' => $post->id]),
],
'htmlOptions' => [
'class' => 'btn btn-default btn-sm btn-comment-submit',
'id' => 'post_edit_post_' . $post->id,
'type' => 'submit'
]
]);
?>
</div>
<?php
// Creates a list of already uploaded Files
echo \humhub\modules\file\widgets\FileUploadList::widget(array(
'uploaderId' => 'post_upload_' . $post->id,
'object' => $post
));
?>
<?php CActiveForm::end(); ?>
</div>
<script type="text/javascript">
// show loader during ajax call
function showLoader(post_id) {
$('#post_edit_' + post_id).html('<div class="loader" style="padding: 15px 0;"><div class="sk-spinner sk-spinner-three-bounce" style="margin:0;"><div class="sk-bounce1"></div><div class="sk-bounce2"></div><div class="sk-bounce3"></div></div>');
}
</script>