diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-21 10:08:36 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-21 10:08:36 +0300 |
commit | 48aff82709769b098321c738f3444b9bdaa694c6 (patch) | |
tree | e00c7c43e2d9b603a5a6af576b1685e400410dee /app/assets/javascripts/gl_form.js | |
parent | 879f5329ee916a948223f8f43d77fba4da6cd028 (diff) |
Add latest changes from gitlab-org/gitlab@13-5-stable-eev13.5.0-rc42
Diffstat (limited to 'app/assets/javascripts/gl_form.js')
-rw-r--r-- | app/assets/javascripts/gl_form.js | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/app/assets/javascripts/gl_form.js b/app/assets/javascripts/gl_form.js index 0a1e5490237..6958cf4c173 100644 --- a/app/assets/javascripts/gl_form.js +++ b/app/assets/javascripts/gl_form.js @@ -6,7 +6,14 @@ import { addMarkdownListeners, removeMarkdownListeners } from './lib/utils/text_ import { disableButtonIfEmptyField } from '~/lib/utils/common_utils'; export default class GLForm { - constructor(form, enableGFM = {}) { + /** + * Create a GLForm + * + * @param {jQuery} form Root element of the GLForm + * @param {Object} enableGFM Which autocomplete features should be enabled? + * @param {Boolean} forceNew If true, treat the element as a **new** form even if `gfm-form` class already exists. + */ + constructor(form, enableGFM = {}, forceNew = false) { this.form = form; this.textarea = this.form.find('textarea.js-gfm-input'); this.enableGFM = { ...defaultAutocompleteConfig, ...enableGFM }; @@ -22,7 +29,7 @@ export default class GLForm { // Before we start, we should clean up any previous data for this form this.destroy(); // Set up the form - this.setupForm(); + this.setupForm(forceNew); this.form.data('glForm', this); } @@ -39,8 +46,8 @@ export default class GLForm { this.form.data('glForm', null); } - setupForm() { - const isNewForm = this.form.is(':not(.gfm-form)'); + setupForm(forceNew = false) { + const isNewForm = this.form.is(':not(.gfm-form)') || forceNew; this.form.removeClass('js-new-note-form'); if (isNewForm) { this.form.find('.div-dropzone').remove(); |