2017-03-07 19:04:20 -05:00
|
|
|
/* eslint-disable func-names, space-before-function-paren, prefer-arrow-callback, no-var, quotes, vars-on-top, no-unused-vars, no-new, max-len */
|
|
|
|
/* global EditBlob */
|
2018-03-09 15:18:59 -05:00
|
|
|
|
|
|
|
import $ from 'jquery';
|
2017-11-20 15:28:29 -05:00
|
|
|
import NewCommitForm from '../new_commit_form';
|
2017-03-07 19:04:20 -05:00
|
|
|
import EditBlob from './edit_blob';
|
|
|
|
import BlobFileDropzone from '../blob/blob_file_dropzone';
|
|
|
|
|
2018-02-21 15:22:56 -05:00
|
|
|
export default () => {
|
2017-03-07 19:04:20 -05:00
|
|
|
const editBlobForm = $('.js-edit-blob-form');
|
|
|
|
const uploadBlobForm = $('.js-upload-blob-form');
|
2017-08-01 04:50:59 -04:00
|
|
|
const deleteBlobForm = $('.js-delete-blob-form');
|
2017-03-07 19:04:20 -05:00
|
|
|
|
|
|
|
if (editBlobForm.length) {
|
2018-02-20 17:20:48 -05:00
|
|
|
const urlRoot = editBlobForm.data('relativeUrlRoot');
|
|
|
|
const assetsPath = editBlobForm.data('assetsPrefix');
|
|
|
|
const blobLanguage = editBlobForm.data('blobLanguage');
|
|
|
|
const currentAction = $('.js-file-title').data('currentAction');
|
2017-03-07 19:04:20 -05:00
|
|
|
|
2017-04-03 13:54:40 -04:00
|
|
|
new EditBlob(`${urlRoot}${assetsPath}`, blobLanguage, currentAction);
|
2017-03-07 19:04:20 -05:00
|
|
|
new NewCommitForm(editBlobForm);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (uploadBlobForm.length) {
|
|
|
|
const method = uploadBlobForm.data('method');
|
|
|
|
|
|
|
|
new BlobFileDropzone(uploadBlobForm, method);
|
|
|
|
new NewCommitForm(uploadBlobForm);
|
|
|
|
|
|
|
|
window.gl.utils.disableButtonIfEmptyField(
|
|
|
|
uploadBlobForm.find('.js-commit-message'),
|
|
|
|
'.btn-upload-file',
|
|
|
|
);
|
|
|
|
}
|
2017-08-01 04:50:59 -04:00
|
|
|
|
|
|
|
if (deleteBlobForm.length) {
|
|
|
|
new NewCommitForm(deleteBlobForm);
|
|
|
|
}
|
2018-02-21 15:22:56 -05:00
|
|
|
};
|