2017-01-11 23:27:41 -05:00
|
|
|
/* eslint-disable func-names, space-before-function-paren, no-var, prefer-rest-params, wrap-iife, no-return-assign, max-len */
|
2016-07-24 16:45:11 -04:00
|
|
|
(function() {
|
|
|
|
this.NewCommitForm = (function() {
|
2017-06-08 11:33:25 -04:00
|
|
|
function NewCommitForm(form) {
|
2016-12-22 01:21:40 -05:00
|
|
|
this.form = form;
|
2017-05-08 15:09:01 -04:00
|
|
|
this.renderDestination = this.renderDestination.bind(this);
|
2017-06-08 11:33:25 -04:00
|
|
|
this.branchName = form.find('.js-branch-name');
|
2016-07-24 16:45:11 -04:00
|
|
|
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-06-08 11:33:25 -04:00
|
|
|
this.branchName.keyup(this.renderDestination);
|
2016-07-24 16:45:11 -04:00
|
|
|
this.renderDestination();
|
|
|
|
}
|
|
|
|
|
|
|
|
NewCommitForm.prototype.renderDestination = function() {
|
|
|
|
var different;
|
2017-06-08 11:33:25 -04:00
|
|
|
different = this.branchName.val() !== this.originalBranch.val();
|
2016-07-24 16:45:11 -04:00
|
|
|
if (different) {
|
|
|
|
this.createMergeRequestContainer.show();
|
|
|
|
if (!this.wasDifferent) {
|
|
|
|
this.createMergeRequest.prop('checked', true);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
this.createMergeRequestContainer.hide();
|
|
|
|
this.createMergeRequest.prop('checked', false);
|
|
|
|
}
|
|
|
|
return this.wasDifferent = different;
|
|
|
|
};
|
|
|
|
|
|
|
|
return NewCommitForm;
|
|
|
|
})();
|
2017-02-10 01:50:50 -05:00
|
|
|
}).call(window);
|