Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-10-05 21:08:51 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-10-05 21:08:51 +0300
commitec18750aa8538712b952b8265581fc3b3e037923 (patch)
tree7eaf59fe40401415fde3c994bffae0031e2ffd23 /app/assets/javascripts/gl_form.js
parent61265b9f01c7db3d4f6e1266d165b1c85be7b9e7 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/gl_form.js')
-rw-r--r--app/assets/javascripts/gl_form.js15
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();