Sha256: 4a40d6697b8901d1e86c20fa24b8d965662e77d17cea3f3f3d09d42f7f50fac7
Contents?: true
Size: 1.21 KB
Versions: 31
Compression:
Stored size: 1.21 KB
Contents
//= require thredded/dependencies/autosize //= require thredded/core/on_page_load //= require thredded/components/mention_autocompletion //= require thredded/components/preview_area (() => { const Thredded = window.Thredded; const ThreddedMentionAutocompletion = window.ThreddedMentionAutocompletion; const ThreddedPreviewArea = window.ThreddedPreviewArea; const autosize = window.autosize; const COMPONENT_SELECTOR = '[data-thredded-post-form]'; const CONTENT_TEXTAREA_SELECTOR = 'textarea[name$="[content]"]'; const initPostForm = (form) => { const textarea = form.querySelector(CONTENT_TEXTAREA_SELECTOR); autosize(textarea); new ThreddedPreviewArea(form, textarea); ThreddedMentionAutocompletion.init(form, textarea); }; const destroyPostForm = (form) => { autosize.destroy(form.querySelector(CONTENT_TEXTAREA_SELECTOR)); }; Thredded.onPageLoad(() => { Array.prototype.forEach.call(document.querySelectorAll(COMPONENT_SELECTOR), (node) => { initPostForm(node); }); }); document.addEventListener('turbolinks:before-cache', () => { Array.prototype.forEach.call(document.querySelectorAll(COMPONENT_SELECTOR), (node) => { destroyPostForm(node); }); }); })();
Version data entries
31 entries across 31 versions & 2 rubygems