2016-12-13 22:01:05 -05:00
|
|
|
/* eslint-disable no-new, comma-dangle, class-methods-use-this, prefer-const, no-param-reassign */
|
|
|
|
|
2016-06-24 15:43:46 -04:00
|
|
|
((global) => {
|
|
|
|
class IssuableTemplateSelectors {
|
2016-10-05 06:48:18 -04:00
|
|
|
constructor({ $dropdowns, editor } = {}) {
|
|
|
|
this.$dropdowns = $dropdowns || $('.js-issuable-selector');
|
|
|
|
this.editor = editor || this.initEditor();
|
2016-06-24 15:43:46 -04:00
|
|
|
|
|
|
|
this.$dropdowns.each((i, dropdown) => {
|
2016-10-05 06:48:18 -04:00
|
|
|
const $dropdown = $(dropdown);
|
|
|
|
new gl.IssuableTemplateSelector({
|
2016-06-24 15:43:46 -04:00
|
|
|
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;
|
2016-10-05 06:48:18 -04:00
|
|
|
})(window.gl || (window.gl = {}));
|