2018-06-16 09:20:30 -04:00
|
|
|
/* eslint-disable no-var, no-return-assign */
|
2017-11-20 15:28:29 -05: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');
|
2018-10-10 03:13:34 -04:00
|
|
|
this.createMergeRequestContainer = form.find('.js-create-merge-request-container');
|
2017-11-20 15:28:29 -05:00
|
|
|
this.branchName.keyup(this.renderDestination);
|
|
|
|
this.renderDestination();
|
|
|
|
}
|
|
|
|
renderDestination() {
|
|
|
|
var different;
|
|
|
|
different = this.branchName.val() !== this.originalBranch.val();
|
|
|
|
if (different) {
|
|
|
|
this.createMergeRequestContainer.show();
|
|
|
|
if (!this.wasDifferent) {
|
|
|
|
this.createMergeRequest.prop('checked', true);
|
2016-07-24 16:45:11 -04:00
|
|
|
}
|
2017-11-20 15:28:29 -05:00
|
|
|
} else {
|
|
|
|
this.createMergeRequestContainer.hide();
|
|
|
|
this.createMergeRequest.prop('checked', false);
|
|
|
|
}
|
2017-12-21 10:05:47 -05:00
|
|
|
return (this.wasDifferent = different);
|
2017-11-20 15:28:29 -05:00
|
|
|
}
|
|
|
|
}
|