From f15bb6c5162117e6ed80e9404a9769c7c0b07ec2 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Tue, 18 Apr 2017 22:04:23 -0400 Subject: [PATCH] Add autosize call for all external textarea value changes --- js/acl.js | 2 +- js/autocomplete.js | 2 +- js/main.js | 1 + view/theme/frio/js/textedit.js | 2 ++ view/theme/frio/js/theme.js | 7 +++++++ 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/js/acl.js b/js/acl.js index 4924ac128..054f50960 100644 --- a/js/acl.js +++ b/js/acl.js @@ -65,7 +65,7 @@ ACL.prototype.add_mention = function(id) { if (this.element.val().indexOf( searchText) >= 0 ) { return; } - this.element.val(searchText + this.element.val()); + this.element.val(searchText + this.element.val()).trigger('change'); } ACL.prototype.on_submit = function(){ diff --git a/js/autocomplete.js b/js/autocomplete.js index 8702abbcf..3ed9fa30f 100644 --- a/js/autocomplete.js +++ b/js/autocomplete.js @@ -166,7 +166,7 @@ function listNewLineAutocomplete(id) { if (word != null) { var textBefore = text.value.substring(0, caretPos); var textAfter = text.value.substring(caretPos, text.length); - $('#' + id).val(textBefore + '\r\n[*] ' + textAfter); + $('#' + id).val(textBefore + '\r\n[*] ' + textAfter).trigger('change'); setCaretPosition(text, caretPos + 5); return true; } diff --git a/js/main.js b/js/main.js index c85aab4a2..5df33ed59 100644 --- a/js/main.js +++ b/js/main.js @@ -101,6 +101,7 @@ var start = textarea.selectionStart; var end = textarea.selectionEnd; textarea.value = textarea.value.substring(0, start) + bbcode + textarea.value.substring(end, textarea.value.length); + $(textarea).trigger('change'); }); diff --git a/view/theme/frio/js/textedit.js b/view/theme/frio/js/textedit.js index d212ee003..8794658dd 100644 --- a/view/theme/frio/js/textedit.js +++ b/view/theme/frio/js/textedit.js @@ -30,6 +30,8 @@ function insertFormatting(BBcode,id) { } } + $(textarea).trigger('change'); + return true; } diff --git a/view/theme/frio/js/theme.js b/view/theme/frio/js/theme.js index 27dd296e5..41a437de7 100644 --- a/view/theme/frio/js/theme.js +++ b/view/theme/frio/js/theme.js @@ -300,6 +300,13 @@ $(document).ready(function(){ }); }); + /* + * This event listeners ensures that the textarea size is updated event if the + * value is changed externally (textcomplete, insertFormatting, fbrowser...) + */ + $(document).on('change', 'textarea', function(event) { + autosize.update(event.target); + }); }); function openClose(theID) {