Redmine 4.1.1

This commit is contained in:
Manuel Cillero 2020-11-22 21:20:06 +01:00
parent 33e7b881a5
commit 3d976f1b3b
1593 changed files with 36180 additions and 19489 deletions

View file

@ -1,5 +1,5 @@
/* Redmine - project management software
Copyright (C) 2006-2017 Jean-Philippe Lang */
Copyright (C) 2006-2019 Jean-Philippe Lang */
function addFile(inputEl, file, eagerUpload) {
var attachmentsFields = $(inputEl).closest('.attachments_form').find('.attachments_fields');
@ -103,7 +103,7 @@ function uploadBlob(blob, uploadUrl, attachmentId, options) {
}, options);
uploadUrl = uploadUrl + '?attachment_id=' + attachmentId;
if (blob instanceof window.File) {
if (blob instanceof window.Blob) {
uploadUrl += '&filename=' + encodeURIComponent(blob.name);
uploadUrl += '&content_type=' + encodeURIComponent(blob.type);
}
@ -185,6 +185,7 @@ handleFileDropEvent.target = '';
function dragOverHandler(e) {
$(this).addClass('fileover');
blockEventPropagation(e);
e.dataTransfer.dropEffect = 'copy';
}
function dragOutHandler(e) {
@ -195,13 +196,15 @@ function dragOutHandler(e) {
function setupFileDrop() {
if (window.File && window.FileList && window.ProgressEvent && window.FormData) {
$.event.fixHooks.dragover = { props: [ 'dataTransfer' ] };
$.event.fixHooks.drop = { props: [ 'dataTransfer' ] };
$('form div.box:not(.filedroplistner)').has('input:file.filedrop').each(function() {
$(this).on({
dragover: dragOverHandler,
dragleave: dragOutHandler,
drop: handleFileDropEvent
drop: handleFileDropEvent,
paste: copyImageFromClipboard
}).addClass('filedroplistner');
});
}
@ -237,8 +240,7 @@ function addInlineAttachmentMarkup(file) {
'selectionStart': cursorPosition + newLineBefore,
'selectionEnd': cursorPosition + inlineFilename.length + newLineBefore
});
$textarea.closest('.jstEditor')
.siblings('.jstElements')
$textarea.parents('.jstBlock')
.find('.jstb_img').click();
// move cursor into next line
@ -251,6 +253,35 @@ function addInlineAttachmentMarkup(file) {
}
}
function copyImageFromClipboard(e) {
if (!$(e.target).hasClass('wiki-edit')) { return; }
var clipboardData = e.clipboardData || e.originalEvent.clipboardData
if (!clipboardData) { return; }
if (clipboardData.types.some(function(t){ return /^text/.test(t); })) { return; }
var items = clipboardData.items
for (var i = 0 ; i < items.length ; i++) {
var item = items[i];
if (item.type.indexOf("image") != -1) {
var blob = item.getAsFile();
var date = new Date();
var filename = 'clipboard-'
+ date.getFullYear()
+ ('0'+(date.getMonth()+1)).slice(-2)
+ ('0'+date.getDate()).slice(-2)
+ ('0'+date.getHours()).slice(-2)
+ ('0'+date.getMinutes()).slice(-2)
+ '-' + randomKey(5).toLocaleLowerCase()
+ '.' + blob.name.split('.').pop();
var file = new Blob([blob], {type: blob.type});
file.name = filename;
var inputEl = $('input:file.filedrop').first()
handleFileDropEvent.target = e.target;
addFile(inputEl, file, true);
}
}
}
$(document).ready(setupFileDrop);
$(document).ready(function(){
$("input.deleted_attachment").change(function(){