Merge branch '5.x' into critic_markup_styling

This commit is contained in:
Bart Kamphorst
2018-11-12 16:39:45 +01:00
committed by GitHub
14 changed files with 103 additions and 59 deletions
@@ -205,9 +205,8 @@
var file = e.dataTransfer.files[0],
formData = new FormData();
formData.append('upload_dest', uploadDest);
formData.append('file', file);
$.ajax({
url: '<%= upload_file_path %>',
data: formData,
@@ -228,8 +227,8 @@
}
window.ace_editor.insert(text);
},
error: function(r, textStatus) {
alert('Error uploading file: ' + textStatus);
error: function(r, textStatus, errorThrown) {
alert('Error uploading file: ' + textStatus + ' ' + errorThrown);
$editorBody.removeClass('uploading');
}
});
@@ -105,8 +105,6 @@
html += '<form method=post enctype="multipart/form-data" ' +
'action="' + action + '" ' + 'id="' + id + '">';
html += '<input type="hidden" name="upload_dest" value="' +
uploadDest + '">';
html += '<input type=file name="' + name + '">';
html += '</form>';
@@ -125,9 +123,9 @@
title +'</h4></div>' +
'<div id="gollum-dialog-dialog-body">' + body + '</div>' +
'<div id="gollum-dialog-dialog-buttons">' +
'<a href="#" title="Cancel" id="gollum-dialog-action-cancel" ' +
'<button name="Cancel" id="gollum-dialog-action-cancel" ' +
'class="gollum-minibutton">Cancel</a>' +
'<a href="#" title="OK" id="gollum-dialog-action-ok" '+
'<button name="OK" id="gollum-dialog-action-ok" '+
'class="gollum-minibutton">OK</a>' +
'</div>' +
'</div>';
@@ -139,9 +137,9 @@
title +'</h4></div>' +
'<div id="gollum-dialog-dialog-body">' + body + '</div>' +
'<div id="gollum-dialog-dialog-buttons">' +
'<a href="#" title="Cancel" id="gollum-dialog-action-cancel" ' +
'class="minibutton">Cancel</a>' +
'<a href="#" title="OK" id="gollum-dialog-action-ok" '+
'<button name="Cancel" id="gollum-dialog-action-cancel" ' +
'class="minibutton">Cancel</button>' +
'<button name="OK" id="gollum-dialog-action-ok" '+
'class="minibutton">OK</a>' +
'</div>' +
'</div>' +
@@ -158,6 +158,7 @@ $(document).ready(function() {
}
};
// ua detection
if ($.browser.mozilla) {
$('body').addClass('ff');
@@ -176,7 +177,7 @@ $(document).ready(function() {
$('#minibutton-upload-page').parent().removeClass('jaws');
$('#minibutton-upload-page').click(function(e) {
e.preventDefault();
$.GollumDialog.init({
title: 'Upload File',
fields: [
@@ -187,9 +188,40 @@ $(document).ready(function() {
}
],
OK: function( res ) {
$('#upload').submit();
$('#wiki-content').addClass('uploading');
var formData = new FormData($('#upload').get(0));
var endpoint = $('#upload').attr("action");
$.ajax({
url: endpoint,
type: 'POST',
data: formData,
processData: false,
contentType: false,
success: function(data) {
// File successfully uploaded
$('#wiki-content').removeClass('uploading');
},
error: function(data, textStatus, errorThrown) {
$('#wiki-content').removeClass('uploading');
if (data.status == 409) {
alert('This file already exists.');
} else {
alert('Error uploading file: ' + textStatus + ' ' + errorThrown);
}
}
});
}
});
$('#gollum-dialog-action-ok').attr('disabled', true);
$('input:file').on('change', function() {
if ($(this).val()) {
news = 'Your uploaded file will be accessible at<br>/' + uploadDest + '/' + $('input[type=file]').val().split('\\').pop();
$(".context").html(news);
$('#gollum-dialog-action-ok').attr('disabled', false);
};
});
});
}
@@ -20,6 +20,12 @@
height: 1%;
overflow: auto;
}
&.uploading {
opacity: 0.5;
}
}
/* @section body */
@@ -29,7 +29,7 @@
display: block;
}
a.minibutton {
button.minibutton {
float: right;
margin-right: 0.5em;
width: auto;
@@ -42,6 +42,12 @@
@include button-base;
}
button.minibutton:disabled {
opacity: 0.65;
cursor: not-allowed;
}
}
#gollum-dialog-dialog-inner {