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

Version Path
thredded-0.16.13 app/assets/javascripts/thredded/components/post_form.es6
thredded-0.16.12 app/assets/javascripts/thredded/components/post_form.es6
thredded-0.16.11 app/assets/javascripts/thredded/components/post_form.es6
thredded-0.16.10 app/assets/javascripts/thredded/components/post_form.es6
thredded-0.16.9 app/assets/javascripts/thredded/components/post_form.es6
thredded-0.16.8 app/assets/javascripts/thredded/components/post_form.es6
thredded-0.16.7 app/assets/javascripts/thredded/components/post_form.es6
thredded-0.16.6 app/assets/javascripts/thredded/components/post_form.es6
thredded-0.16.5 app/assets/javascripts/thredded/components/post_form.es6
thredded-0.16.4 app/assets/javascripts/thredded/components/post_form.es6
thredded-0.16.3 app/assets/javascripts/thredded/components/post_form.es6
thredded-0.16.1 app/assets/javascripts/thredded/components/post_form.es6
thredded-0.16.0 app/assets/javascripts/thredded/components/post_form.es6
thredded-0.15.5 app/assets/javascripts/thredded/components/post_form.es6
thredded-0.15.4 app/assets/javascripts/thredded/components/post_form.es6
thredded-0.15.3 app/assets/javascripts/thredded/components/post_form.es6
thredded-0.15.2 app/assets/javascripts/thredded/components/post_form.es6
thredded-0.15.1 app/assets/javascripts/thredded/components/post_form.es6
threddedDANIEL-0.14.5 app/assets/javascripts/thredded/components/post_form.es6
thredded-0.14.4 app/assets/javascripts/thredded/components/post_form.es6