##// END OF EJS Templates
[#20288] Update styles to match CodeRay 1.1.0 (preserving changes of r10132)....
[#20288] Update styles to match CodeRay 1.1.0 (preserving changes of r10132). This commit updates the CSS styles to match with CodeRay 1.1.0, while it preserves the custom changes applied in r10132. The CSS styles were still based on CodeRay 1.0.6 (included since Redmine 1.4.0) with the custom changes from r10132 (included since Redmine 2.1.0). Redmine 2.3.2 till 2.3.4 came with CodeRay 1.0.9, an upgrade that didn't needed changes in the CSS styles. Starting with 2.4.0 Redmine comes with CodeRay 1.1.0, a minor upgrade that came with new/changed token_kinds and lots of changes in the alpha stylesheet, that in turn is used as a base for Redmine's own CodeRay CSS styles. As such, this upgrade needed CSS stylesheet changes like done before in r7618 and r7623 (for 1.0.0 upgrade) and r9389 (for 1.0.6 upgrade). But these changes, plus an update of the Redmine core documentation that is shipped along the core (wiki_syntax_detailed_[markdown|textile].html), aren't integrated up untill today. Contributed by Mischa The Evil. git-svn-id: http://svn.redmine.org/redmine/trunk@14488 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r13490:000124f44f53
r14106:6fbb56e55735
Show More
attachments.js
191 lines | 5.8 KiB | application/javascript | JavascriptGenshiLexer
Jean-Philippe Lang
Merged ajax_upload branch (#3957)....
r10748 /* Redmine - project management software
Jean-Philippe Lang
Copyright update....
r13490 Copyright (C) 2006-2015 Jean-Philippe Lang */
Jean-Philippe Lang
Merged ajax_upload branch (#3957)....
r10748
function addFile(inputEl, file, eagerUpload) {
if ($('#attachments_fields').children().length < 10) {
var attachmentId = addFile.nextAttachmentId++;
var fileSpan = $('<span>', { id: 'attachments_' + attachmentId });
Toshi MARUYAMA
remove trailing white-spaces from public/javascripts/attachments.js...
r10760
Jean-Philippe Lang
Merged ajax_upload branch (#3957)....
r10748 fileSpan.append(
$('<input>', { type: 'text', 'class': 'filename readonly', name: 'attachments[' + attachmentId + '][filename]', readonly: 'readonly'} ).val(file.name),
$('<input>', { type: 'text', 'class': 'description', name: 'attachments[' + attachmentId + '][description]', maxlength: 255, placeholder: $(inputEl).data('description-placeholder') } ).toggle(!eagerUpload),
$('<a>&nbsp</a>').attr({ href: "#", 'class': 'remove-upload' }).click(removeFile).toggle(!eagerUpload)
).appendTo('#attachments_fields');
if(eagerUpload) {
ajaxUpload(file, attachmentId, fileSpan, inputEl);
}
return attachmentId;
}
return null;
}
addFile.nextAttachmentId = 1;
function ajaxUpload(file, attachmentId, fileSpan, inputEl) {
function onLoadstart(e) {
fileSpan.removeClass('ajax-waiting');
fileSpan.addClass('ajax-loading');
Toshi MARUYAMA
remove trailing white-spaces from public/javascripts/attachments.js...
r10760 $('input:submit', $(this).parents('form')).attr('disabled', 'disabled');
Jean-Philippe Lang
Merged ajax_upload branch (#3957)....
r10748 }
function onProgress(e) {
if(e.lengthComputable) {
this.progressbar( 'value', e.loaded * 100 / e.total );
}
}
function actualUpload(file, attachmentId, fileSpan, inputEl) {
ajaxUpload.uploading++;
uploadBlob(file, $(inputEl).data('upload-path'), attachmentId, {
loadstartEventHandler: onLoadstart.bind(progressSpan),
progressEventHandler: onProgress.bind(progressSpan)
})
.done(function(result) {
progressSpan.progressbar( 'value', 100 ).remove();
fileSpan.find('input.description, a').css('display', 'inline-block');
})
.fail(function(result) {
progressSpan.text(result.statusText);
}).always(function() {
ajaxUpload.uploading--;
fileSpan.removeClass('ajax-loading');
var form = fileSpan.parents('form');
if (form.queue('upload').length == 0 && ajaxUpload.uploading == 0) {
$('input:submit', form).removeAttr('disabled');
}
form.dequeue('upload');
});
}
var progressSpan = $('<div>').insertAfter(fileSpan.find('input.filename'));
progressSpan.progressbar();
fileSpan.addClass('ajax-waiting');
var maxSyncUpload = $(inputEl).data('max-concurrent-uploads');
if(maxSyncUpload == null || maxSyncUpload <= 0 || ajaxUpload.uploading < maxSyncUpload)
actualUpload(file, attachmentId, fileSpan, inputEl);
else
$(inputEl).parents('form').queue('upload', actualUpload.bind(this, file, attachmentId, fileSpan, inputEl));
}
ajaxUpload.uploading = 0;
function removeFile() {
$(this).parent('span').remove();
return false;
}
function uploadBlob(blob, uploadUrl, attachmentId, options) {
var actualOptions = $.extend({
loadstartEventHandler: $.noop,
progressEventHandler: $.noop
}, options);
uploadUrl = uploadUrl + '?attachment_id=' + attachmentId;
if (blob instanceof window.File) {
uploadUrl += '&filename=' + encodeURIComponent(blob.name);
Jean-Philippe Lang
Send the content type as parameter when uploading a file....
r13406 uploadUrl += '&content_type=' + encodeURIComponent(blob.type);
Jean-Philippe Lang
Merged ajax_upload branch (#3957)....
r10748 }
return $.ajax(uploadUrl, {
type: 'POST',
contentType: 'application/octet-stream',
Toshi MARUYAMA
fix Drag & Drop does not work with Safari 5.1 (#17581, #13932)...
r12992 beforeSend: function(jqXhr, settings) {
Jean-Philippe Lang
Merged ajax_upload branch (#3957)....
r10748 jqXhr.setRequestHeader('Accept', 'application/js');
Toshi MARUYAMA
fix Drag & Drop does not work with Safari 5.1 (#17581, #13932)...
r12992 // attach proper File object
settings.data = blob;
Jean-Philippe Lang
Merged ajax_upload branch (#3957)....
r10748 },
xhr: function() {
var xhr = $.ajaxSettings.xhr();
xhr.upload.onloadstart = actualOptions.loadstartEventHandler;
xhr.upload.onprogress = actualOptions.progressEventHandler;
return xhr;
},
data: blob,
cache: false,
processData: false
});
}
function addInputFiles(inputEl) {
var clearedFileInput = $(inputEl).clone().val('');
Toshi MARUYAMA
stricter check of uploading attachments (#17581)...
r13041 if ($.ajaxSettings.xhr().upload && inputEl.files) {
Jean-Philippe Lang
Merged ajax_upload branch (#3957)....
r10748 // upload files using ajax
uploadAndAttachFiles(inputEl.files, inputEl);
$(inputEl).remove();
} else {
// browser not supporting the file API, upload on form submission
var attachmentId;
var aFilename = inputEl.value.split(/\/|\\/);
attachmentId = addFile(inputEl, { name: aFilename[ aFilename.length - 1 ] }, false);
if (attachmentId) {
$(inputEl).attr({ name: 'attachments[' + attachmentId + '][file]', style: 'display:none;' }).appendTo('#attachments_' + attachmentId);
}
Toshi MARUYAMA
remove trailing white-spaces from public/javascripts/attachments.js...
r10760 }
Jean-Philippe Lang
Merged ajax_upload branch (#3957)....
r10748
Toshi MARUYAMA
revert r13199 (#17151)...
r12996 clearedFileInput.insertAfter('#attachments_fields');
Jean-Philippe Lang
Merged ajax_upload branch (#3957)....
r10748 }
function uploadAndAttachFiles(files, inputEl) {
var maxFileSize = $(inputEl).data('max-file-size');
var maxFileSizeExceeded = $(inputEl).data('max-file-size-message');
var sizeExceeded = false;
$.each(files, function() {
Jean-Philippe Lang
Fixed that JS warning is not displayed when attachment maximum size is 0 (#13949)....
r11611 if (this.size && maxFileSize != null && this.size > parseInt(maxFileSize)) {sizeExceeded=true;}
Jean-Philippe Lang
Merged ajax_upload branch (#3957)....
r10748 });
if (sizeExceeded) {
window.alert(maxFileSizeExceeded);
} else {
$.each(files, function() {addFile(inputEl, this, true);});
}
}
function handleFileDropEvent(e) {
$(this).removeClass('fileover');
blockEventPropagation(e);
if ($.inArray('Files', e.dataTransfer.types) > -1) {
Jean-Philippe Lang
Save the selected file just in case uploading stuff fails/is not supported....
r10781 uploadAndAttachFiles(e.dataTransfer.files, $('input:file.file_selector'));
Jean-Philippe Lang
Merged ajax_upload branch (#3957)....
r10748 }
}
function dragOverHandler(e) {
$(this).addClass('fileover');
blockEventPropagation(e);
}
function dragOutHandler(e) {
$(this).removeClass('fileover');
blockEventPropagation(e);
}
function setupFileDrop() {
if (window.File && window.FileList && window.ProgressEvent && window.FormData) {
$.event.fixHooks.drop = { props: [ 'dataTransfer' ] };
$('form div.box').has('input:file').each(function() {
$(this).on({
dragover: dragOverHandler,
dragleave: dragOutHandler,
drop: handleFileDropEvent
});
});
}
}
$(document).ready(setupFileDrop);