Skip to content

Commit 07fb53a

Browse files
committed
Patch summernote on modal windows for more stability and according to official docs
1 parent 3634288 commit 07fb53a

4 files changed

Lines changed: 15 additions & 6 deletions

File tree

src/Views/tickets/partials/summernote.blade.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@
1212
@endif
1313

1414
<script>
15+
var summernote_options = "";
16+
1517
$(function() {
1618
17-
var options = $.extend(true, {lang: '{{$editor_locale}}' {!! $codemirror_enabled ? ", codemirror: {theme: '{$codemirror_theme}', mode: 'text/html', htmlMode: true, lineWrapping: true}" : '' !!} } , {!! $editor_options !!});
19+
summernote_options = $.extend(true, {lang: '{{$editor_locale}}' {!! $codemirror_enabled ? ", codemirror: {theme: '{$codemirror_theme}', mode: 'text/html', htmlMode: true, lineWrapping: true}" : '' !!} } , {!! $editor_options !!});
1820
19-
$("textarea.summernote-editor").summernote(options);
21+
// Usage within HTML Body
22+
$("textarea.summernote-editor").summernote(summernote_options);
2023
2124
$("label[for=content]").click(function () {
2225
$("#content").summernote("focus");

src/Views/tickets/show/modal_comment_edit.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
]) !!}
2020
<div class="form-group row">
2121
<div class="col-lg-12 summernote-text-wrapper">
22-
{!! CollectiveForm::textarea('content', $comment->html, ['class' => 'form-control summernote-editor', 'rows' => "3"]) !!}
22+
{!! CollectiveForm::textarea('content', $comment->html, ['class' => 'form-control modal-summernote-editor', 'style' => 'display: none', 'rows' => "3"]) !!}
2323
</div>
2424
</div>
2525
@if($setting->grab('ticket_attachments_feature'))

src/Views/tickets/show/modal_comment_new.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
@endif
3232
<div class="form-group row">
3333
<div class="col-lg-12 summernote-text-wrapper">
34-
{!! CollectiveForm::textarea('content', null, ['class' => 'form-control summernote-editor', 'rows' => "3"]) !!}
34+
{!! CollectiveForm::textarea('content', null, ['class' => 'form-control modal-summernote-editor', 'style' => 'display: none', 'rows' => "3"]) !!}
3535
</div>
3636
</div>
3737

src/Views/tickets/show/script.blade.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,16 @@
8686
$(this).find('.fieldset-for-attachment').hide();
8787
});
8888
89-
$('#modal-comment-new').on('show.bs.modal', function (e) {
90-
$(this).find('.modal-title').text($(e.relatedTarget).text());
89+
$('.comment-modal').on('shown.bs.modal', function (e) {
90+
$(this).find('.modal-title').text($(e.relatedTarget).text());
9191
if ($(e.relatedTarget).data('add-comment') == 'no') $(this).find('#comment-type-buttons').hide();
92+
93+
$(this).find("textarea.modal-summernote-editor").summernote(summernote_options);
9294
});
95+
96+
$('.comment-modal').on('hidden.bs.modal', function (e) {
97+
$(this).find("textarea.modal-summernote-editor").summernote('destroy');
98+
});
9399
94100
// Comment form: Click on response type buttons (reply or note)
95101
$('.response_type').click(function(){

0 commit comments

Comments
 (0)