Commit e12f7a3b authored by Joseph Frazier's avatar Joseph Frazier

Combine requestFileSuccess arguments into `opts`

See https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/6149#note_14830172
parent ad2b6cae
...@@ -72,14 +72,17 @@ ...@@ -72,14 +72,17 @@
// To be implemented on the extending class // To be implemented on the extending class
// e.g. // e.g.
// Api.gitignoreText item.name, @requestFileSuccess.bind(@) // Api.gitignoreText item.name, @requestFileSuccess.bind(@)
TemplateSelector.prototype.requestFileSuccess = function(file, skipFocus, append) { TemplateSelector.prototype.requestFileSuccess = function(file, opts) {
var oldValue = this.editor.getValue(); var oldValue = this.editor.getValue();
var newValue = file.content; var newValue = file.content;
if (append && oldValue.length && oldValue !== newValue) { if (opts == null) {
opts = {};
}
if (opts.append && oldValue.length && oldValue !== newValue) {
newValue = oldValue + '\n\n' + newValue; newValue = oldValue + '\n\n' + newValue;
} }
this.editor.setValue(newValue, 1); this.editor.setValue(newValue, 1);
if (!skipFocus) this.editor.focus(); if (!opts.skipFocus) this.editor.focus();
if (this.editor instanceof jQuery) { if (this.editor instanceof jQuery) {
this.editor.get(0).dispatchEvent(this.autosizeUpdateEvent); this.editor.get(0).dispatchEvent(this.autosizeUpdateEvent);
......
...@@ -38,12 +38,12 @@ ...@@ -38,12 +38,12 @@
// separated by a blank line if the previous value is non-empty. // separated by a blank line if the previous value is non-empty.
if (this.titleInput.val() === '') { if (this.titleInput.val() === '') {
// If the title has not yet been set, focus the title input and // If the title has not yet been set, focus the title input and
// skip focusing the description input by setting `true` as the 2nd // skip focusing the description input by setting `true` as the
// argument to `requestFileSuccess`. // `skipFocus` option to `requestFileSuccess`.
this.requestFileSuccess(this.currentTemplate, true, append); this.requestFileSuccess(this.currentTemplate, {skipFocus: true, append});
this.titleInput.focus(); this.titleInput.focus();
} else { } else {
this.requestFileSuccess(this.currentTemplate, false, append); this.requestFileSuccess(this.currentTemplate, {skipFocus: false, append});
} }
return; return;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment