debian-mirror-gitlab/app/assets/javascripts/new_commit_form.js

33 lines
1.2 KiB
JavaScript
Raw Normal View History

2017-08-17 22:00:37 +05:30
/* eslint-disable func-names, space-before-function-paren, no-var, prefer-rest-params, wrap-iife, no-return-assign, max-len */
2016-09-13 17:45:13 +05:30
(function() {
this.NewCommitForm = (function() {
2017-09-10 17:25:29 +05:30
function NewCommitForm(form) {
2017-08-17 22:00:37 +05:30
this.form = form;
2017-09-10 17:25:29 +05:30
this.renderDestination = this.renderDestination.bind(this);
this.branchName = form.find('.js-branch-name');
2016-09-13 17:45:13 +05:30
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-09-10 17:25:29 +05:30
this.branchName.keyup(this.renderDestination);
2016-09-13 17:45:13 +05:30
this.renderDestination();
}
NewCommitForm.prototype.renderDestination = function() {
var different;
2017-09-10 17:25:29 +05:30
different = this.branchName.val() !== this.originalBranch.val();
2016-09-13 17:45:13 +05:30
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-08-17 22:00:37 +05:30
}).call(window);