Sha256: b7548ea3886e6a4493774f912daf7c9c3a5b8ab3c805d009fed532309f4190ca

Contents?: true

Size: 988 Bytes

Versions: 5

Compression:

Stored size: 988 Bytes

Contents

//= require ./preview_area

(($, autosize) => {
  const COMPONENT_SELECTOR = '[data-thredded-post-form]';

  class ThreddedPostForm {
    constructor() {
      this.textareaSelector = 'textarea';
    }

    init($nodes) {
      let $textarea = $nodes.find(this.textareaSelector);
      this.autosize($textarea);
      $nodes.each(function() {
        new ThreddedPreviewArea($(this));
      });
      new ThreddedMentionAutocompletion($).init($nodes);
    }

    autosize($textarea) {
      autosize($textarea)
    }

    destroy($nodes) {
      autosize.destroy($nodes.find(this.textareaSelector));
    }
  }

  window.Thredded.onPageLoad(() => {
    const $nodes = $(COMPONENT_SELECTOR);
    if ($nodes.length) {
      new ThreddedPostForm().init($nodes);
    }
  });

  document.addEventListener('turbolinks:before-cache', () => {
    const $nodes = $(COMPONENT_SELECTOR);
    if ($nodes.length) {
      new ThreddedPostForm().destroy($nodes);
    }
  });
})(jQuery, window.autosize);

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
thredded-0.12.4 app/assets/javascripts/thredded/components/post_form.es6
thredded-0.12.3 app/assets/javascripts/thredded/components/post_form.es6
thredded-0.12.2 app/assets/javascripts/thredded/components/post_form.es6
thredded-0.12.1 app/assets/javascripts/thredded/components/post_form.es6
thredded-0.12.0 app/assets/javascripts/thredded/components/post_form.es6