BigW Consortium Gitlab

issuable_template_selectors.js.es6 906 Bytes
Newer Older
1
/* eslint-disable */
2 3
((global) => {
  class IssuableTemplateSelectors {
4 5 6
    constructor({ $dropdowns, editor } = {}) {
      this.$dropdowns = $dropdowns || $('.js-issuable-selector');
      this.editor = editor || this.initEditor();
7 8

      this.$dropdowns.each((i, dropdown) => {
9 10
        const $dropdown = $(dropdown);
        new gl.IssuableTemplateSelector({
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
          pattern: /(\.md)/,
          data: $dropdown.data('data'),
          wrapper: $dropdown.closest('.js-issuable-selector-wrap'),
          dropdown: $dropdown,
          editor: this.editor
        });
      });
    }

    initEditor() {
      let editor = $('.markdown-area');
      // Proxy ace-editor's .setValue to jQuery's .val
      editor.setValue = editor.val;
      editor.getValue = editor.val;
      return editor;
    }
  }

  global.IssuableTemplateSelectors = IssuableTemplateSelectors;
30
})(window.gl || (window.gl = {}));