gitlab-org--gitlab-foss/app/assets/javascripts/new_commit_form.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

27 lines
969 B
JavaScript
Raw Normal View History

/* eslint-disable no-return-assign */
2017-11-20 20:28:29 +00:00
export default class NewCommitForm {
constructor(form) {
this.form = form;
this.renderDestination = this.renderDestination.bind(this);
this.branchName = form.find('.js-branch-name');
this.originalBranch = form.find('.js-original-branch');
this.createMergeRequest = form.find('.js-create-merge-request');
this.createMergeRequestContainer = form.find('.js-create-merge-request-container');
2017-11-20 20:28:29 +00:00
this.branchName.keyup(this.renderDestination);
this.renderDestination();
}
renderDestination() {
const different = this.branchName.val() !== this.originalBranch.val();
2017-11-20 20:28:29 +00:00
if (different) {
this.createMergeRequestContainer.show();
if (!this.wasDifferent) {
this.createMergeRequest.prop('checked', true);
2016-07-24 20:45:11 +00:00
}
2017-11-20 20:28:29 +00:00
} else {
this.createMergeRequestContainer.hide();
this.createMergeRequest.prop('checked', false);
}
return (this.wasDifferent = different);
2017-11-20 20:28:29 +00:00
}
}