课程讨论区回复样式错误

Signed-off-by: alan <547533434@qq.com>
This commit is contained in:
alan 2015-05-15 10:07:52 +08:00
parent e9c1012cbe
commit cc5738c12f
4 changed files with 176 additions and 167 deletions

View File

@ -2,26 +2,30 @@
<% if defined?(container) && container && container.saved_attachments %> <% if defined?(container) && container && container.saved_attachments %>
<% if isReply %> <% if isReply %>
<% container.saved_attachments.each_with_index do |attachment, i| %> <% container.saved_attachments.each_with_index do |attachment, i| %>
<span id="attachments_p<%= i %>" class="attachment"> <span id="attachments_p<%= i %>" class="sub_btn">
<%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename readonly', :readonly=>'readonly')%> <%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename readonly', :readonly=>'readonly')%>
<%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 255, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") + <%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 255, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") %>
link_to('&nbsp;'.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') %>
<%#= render :partial => 'tags/tag', :locals => {:obj => attachment, :object_flag => "6"} %>
<span class="ispublic-label"><%= l(:field_is_public)%>:</span> <span class="ispublic-label"><%= l(:field_is_public)%>:</span>
<%= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public,attachment.is_public == 1 ? true : false, :class => 'is_public')%> <%= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public,attachment.is_public == 1 ? true : false, :class => 'is_public_checkbox')%>
<%= link_to('&nbsp;'.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') %>
<%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %> <%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %>
</span> </span>
<% end %> <% end %>
<% else %> <% else %>
<% container.attachments.each_with_index do |attachment, i| %> <% container.attachments.each_with_index do |attachment, i| %>
<span id="attachments_p<%= i %>" class="attachment"> <span id="attachments_p<%= i %>" class="attachment">
<%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename readonly', :readonly=>'readonly')%> <%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename readonly', :readonly=>'readonly')%>
<%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 255, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") + <%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 255, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") %>
link_to('&nbsp;'.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') %> <span class="ispublic-label"><%= l(:field_is_public)%>:</span>
<%#= render :partial => 'tags/tag', :locals => {:obj => attachment, :object_flag => "6"} %> <%= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public,attachment.is_public == 1 ? true : false, :class => 'is_public_checkbox')%>
<span class="ispublic-label"><%= l(:field_is_public)%>:</span>
<%= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public,attachment.is_public == 1 ? true : false, :class => 'is_public')%> <%= link_to('&nbsp;'.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') %>
<%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %> <%#= render :partial => 'tags/tag', :locals => {:obj => attachment, :object_flag => "6"} %>
<%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %>
</span> </span>
<% end %> <% end %>
<% end %> <% end %>
@ -56,7 +60,9 @@
:file_count => l(:label_file_count), :file_count => l(:label_file_count),
:delete_all_files => l(:text_are_you_sure_all) :delete_all_files => l(:text_are_you_sure_all)
} %> } %>
<span id="upload_file_count<%= container.id %>" :class="c_grey"><%= l(:label_no_file_uploaded)%></span> <% if container.nil? %>
<span id="upload_file_count" :class="c_grey"><%= l(:label_no_file_uploaded)%></span>
<% end %>
(<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>) (<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)
</span> </span>

View File

@ -124,7 +124,9 @@
:file_count => l(:label_file_count), :file_count => l(:label_file_count),
:delete_all_files => l(:text_are_you_sure_all) :delete_all_files => l(:text_are_you_sure_all)
} %> } %>
<span id="upload_file_count" :class="c_grey"><%= l(:label_no_file_uploaded)%></span> <% if container.nil? %>
<span id="upload_file_count" :class="c_grey"><%= l(:label_no_file_uploaded)%></span>
<% end %>
(<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>) (<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)
</span> </span>

View File

@ -68,6 +68,7 @@
</div> </div>
<p style="display: none" id="project_show_<%= topic.id%>"> <p style="display: none" id="project_show_<%= topic.id%>">
<label id="expend_more_information<%= topic.id%>" onclick="show_more_reply('#content_<%=topic.id%>','#expend_more_information<%= topic.id%>','#arrow<%=topic.id%>');" value="show_more">[展开]</label> <label id="expend_more_information<%= topic.id%>" onclick="show_more_reply('#content_<%=topic.id%>','#expend_more_information<%= topic.id%>','#arrow<%=topic.id%>');" value="show_more">[展开]</label>
<span class="g-arr-down"> <span class="g-arr-down">
@ -125,7 +126,7 @@
<div class="Msg_txt"> <div class="Msg_txt">
<%= link_to_user_header message.author,false,:class => 'fl c_orange ' %> <%= link_to_user_header message.author,false,:class => 'fl c_orange ' %>
<br/> <br/>
<p class="fl"><%= textAreailizable message,:content,:attachments => message.attachments %></p> <p class="fl break_word"><%= textAreailizable message,:content,:attachments => message.attachments %></p>
<br/> <br/>
<span class=" c_grey fl"><%= format_time(message.created_on) %></span> <span class=" c_grey fl"><%= format_time(message.created_on) %></span>

View File

@ -1,10 +1,10 @@
/* Redmine - project management software /* Redmine - project management software
Copyright (C) 2006-2013 Jean-Philippe Lang */ Copyright (C) 2006-2013 Jean-Philippe Lang */
function postUpMsg(attachmentId) function postUpMsg(attachmentId)
{ {
$.ajax({ $.ajax({
url: '/attachments/renderTag', url: '/attachments/renderTag',
type: "GET", type: "GET",
data: { data: {
attachmentId: attachmentId attachmentId: attachmentId
@ -25,39 +25,39 @@ function reload(fileSpan) {
function addFile_board(inputEl, file, eagerUpload, id) { function addFile_board(inputEl, file, eagerUpload, id) {
var attachments_frame = '#attachments_fields' + id; var attachments_frame = '#attachments_fields' + id;
if ($(attachments_frame).children().length < 30) { if ($(attachments_frame).children().length < 30) {
deleteallfiles = $(inputEl).data('deleteAllFiles'); deleteallfiles = $(inputEl).data('deleteAllFiles');
var attachmentId = addFile.nextAttachmentId++; var attachmentId = addFile.nextAttachmentId++;
var fileSpan = $('<span>', { 'id': 'attachments_' + attachmentId, 'class':'attachment' }); var fileSpan = $('<span>', { 'id': 'attachments_' + attachmentId, 'class':'attachment' });
fileSpan.append( fileSpan.append(
$('<input>', { 'type': 'text', 'class': 'filename readonly', 'name': 'attachments[' + attachmentId + '][filename]', 'readonly': 'readonly'} ).val(file.name), $('<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': 254, 'placeholder': $(inputEl).data('descriptionPlaceholder') } ).toggle(!eagerUpload), $('<input>', { 'type': 'text', 'class': 'description', 'name': 'attachments[' + attachmentId + '][description]', 'maxlength': 254, 'placeholder': $(inputEl).data('descriptionPlaceholder') } ).toggle(!eagerUpload),
$('<span >'+$(inputEl).data('fieldIsPublic')+':</span>').attr({ 'class': 'ispublic-label' }) , $('<span >'+$(inputEl).data('fieldIsPublic')+':</span>').attr({ 'class': 'ispublic-label' }) ,
$('<input>', { 'type': 'checkbox', 'class': 'is_public_checkbox','value':1, 'name': 'attachments[' + attachmentId + '][is_public_checkbox]', checked:'checked' } ).toggle(!eagerUpload), $('<input>', { 'type': 'checkbox', 'class': 'is_public_checkbox','value':1, 'name': 'attachments[' + attachmentId + '][is_public_checkbox]', checked:'checked' } ).toggle(!eagerUpload),
$('<a>&nbsp</a>').attr({ 'href': "#", 'class': 'remove-upload' }).click(function(){ $('<a>&nbsp</a>').attr({ 'href': "#", 'class': 'remove-upload' }).click(function(){
if(confirm($(inputEl).data('areYouSure'))){ if(confirm($(inputEl).data('areYouSure'))){
removeFile(); removeFile();
if(!eagerUpload){ if(!eagerUpload){
(function(e){ (function(e){
reload(e); reload(e);
})(fileSpan); })(fileSpan);
}
} }
}
}).toggle(!eagerUpload), }).toggle(!eagerUpload),
$('<div>', { 'class': 'div_attachments', 'name': 'div_'+'attachments_' + attachmentId} ) $('<div>', { 'class': 'div_attachments', 'name': 'div_'+'attachments_' + attachmentId} )
).appendTo(attachments_frame); ).appendTo(attachments_frame);
if(eagerUpload) { if(eagerUpload) {
ajaxUpload(file, attachmentId, fileSpan, inputEl); ajaxUpload(file, attachmentId, fileSpan, inputEl);
}
return attachmentId;
} }
return attachmentId; return null;
}
return null;
} }
function addFile(inputEl, file, eagerUpload) { function addFile(inputEl, file, eagerUpload) {
@ -99,132 +99,132 @@ addFile.nextAttachmentId = 1;
function ajaxUpload(file, attachmentId, fileSpan, inputEl) { function ajaxUpload(file, attachmentId, fileSpan, inputEl) {
function onLoadstart(e) { function onLoadstart(e) {
fileSpan.removeClass('ajax-waiting'); fileSpan.removeClass('ajax-waiting');
fileSpan.addClass('ajax-loading'); fileSpan.addClass('ajax-loading');
$('input:submit', $(this).parents('form')).attr('disabled', 'disabled'); $('input:submit', $(this).parents('form')).attr('disabled', 'disabled');
}
function onProgress(e) {
if(e.lengthComputable) {
this.progressbar( 'value', e.loaded * 100 / e.total );
} }
}
function actualUpload(file, attachmentId, fileSpan, inputEl) { function onProgress(e) {
if(e.lengthComputable) {
ajaxUpload.uploading++; this.progressbar( 'value', e.loaded * 100 / e.total );
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');
fileSpan.find('input.is_public_checkbox, a').css('display', 'inline-block');
})
.fail(function(result) {
progressSpan.text(result.statusText);
if($("#network_issue"))
{
$("#network_issue").show();
} }
}).always(function() { }
ajaxUpload.uploading--;
fileSpan.removeClass('ajax-loading'); function actualUpload(file, attachmentId, fileSpan, inputEl) {
var form = fileSpan.parents('form');
if (form.queue('upload').length == 0 && ajaxUpload.uploading == 0) { ajaxUpload.uploading++;
$('input:submit', form).removeAttr('disabled');
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');
fileSpan.find('input.is_public_checkbox, a').css('display', 'inline-block');
})
.fail(function(result) {
progressSpan.text(result.statusText);
if($("#network_issue"))
{
$("#network_issue").show();
}
}).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');
});
//gcm files count and add delete_all link
var count=$('#attachments_fields>span').length;
$('#upload_file_count').html("<span id=\"count\">"+count+"</span>"+$(inputEl).data('fileCount'));
if(count>=1){
var add_attachs=$('.add_attachment');
var delete_all=$('.remove_all');
if(delete_all.length<1){
add_attachs.append($("<a>&nbsp</a>").attr({"href":"javascript:void(0)", 'class': 'remove_all',"onclick": "removeAll()"}));
}
} }
form.dequeue('upload');
});
//gcm files count and add delete_all link
var count=$('#attachments_fields>span').length; //gcm
$('#upload_file_count').html("<span id=\"count\">"+count+"</span>"+$(inputEl).data('fileCount'));
if(count>=1){
var add_attachs=$('.add_attachment');
var delete_all=$('.remove_all');
if(delete_all.length<1){
add_attachs.append($("<a>&nbsp</a>").attr({"href":"javascript:void(0)", 'class': 'remove_all',"onclick": "removeAll()"}));
}
}
//gcm }
}
var progressSpan = $('<div>').insertAfter(fileSpan.find('input.filename')); var progressSpan = $('<div>').insertAfter(fileSpan.find('input.filename'));
progressSpan.progressbar(); progressSpan.progressbar();
fileSpan.addClass('ajax-waiting'); fileSpan.addClass('ajax-waiting');
var maxSyncUpload = $(inputEl).data('max-concurrent-uploads'); var maxSyncUpload = $(inputEl).data('max-concurrent-uploads');
if(maxSyncUpload == null || maxSyncUpload <= 0 || ajaxUpload.uploading < maxSyncUpload) if(maxSyncUpload == null || maxSyncUpload <= 0 || ajaxUpload.uploading < maxSyncUpload)
actualUpload(file, attachmentId, fileSpan, inputEl); actualUpload(file, attachmentId, fileSpan, inputEl);
else else
$(inputEl).parents('form').queue('upload', actualUpload.bind(this, file, attachmentId, fileSpan, inputEl)); $(inputEl).parents('form').queue('upload', actualUpload.bind(this, file, attachmentId, fileSpan, inputEl));
} }
ajaxUpload.uploading = 0; ajaxUpload.uploading = 0;
function removeFile() { function removeFile() {
$(this).parent('span').remove(); $(this).parent('span').remove();
return false; return false;
} }
//gcm delete all file //gcm delete all file
function removeAll(){ function removeAll(){
if(confirm(deleteallfiles)){ if(confirm(deleteallfiles)){
$(".remove-upload").removeAttr("data-confirm"); $(".remove-upload").removeAttr("data-confirm");
$(".remove-upload").click(); $(".remove-upload").click();
} }
// return false; // return false;
} }
//gcm //gcm
function uploadBlob(blob, uploadUrl, attachmentId, options) { function uploadBlob(blob, uploadUrl, attachmentId, options) {
var actualOptions = $.extend({ var actualOptions = $.extend({
loadstartEventHandler: $.noop, loadstartEventHandler: $.noop,
progressEventHandler: $.noop progressEventHandler: $.noop
}, options); }, options);
if(uploadUrl.indexOf('?') > 0){ if(uploadUrl.indexOf('?') > 0){
uploadUrl = uploadUrl + '&attachment_id=' + attachmentId; uploadUrl = uploadUrl + '&attachment_id=' + attachmentId;
}else{ }else{
uploadUrl = uploadUrl + '?attachment_id=' + attachmentId; uploadUrl = uploadUrl + '?attachment_id=' + attachmentId;
} }
if (blob instanceof window.File) { if (blob instanceof window.File) {
uploadUrl += '&filename=' + encodeURIComponent(blob.name); uploadUrl += '&filename=' + encodeURIComponent(blob.name);
} }
return $.ajax(uploadUrl, { return $.ajax(uploadUrl, {
type: 'POST', type: 'POST',
contentType: 'application/octet-stream', contentType: 'application/octet-stream',
beforeSend: function(jqXhr) { beforeSend: function(jqXhr) {
jqXhr.setRequestHeader('Accept', 'application/js'); jqXhr.setRequestHeader('Accept', 'application/js');
}, },
xhr: function() { xhr: function() {
var xhr = $.ajaxSettings.xhr(); var xhr = $.ajaxSettings.xhr();
xhr.upload.onloadstart = actualOptions.loadstartEventHandler; xhr.upload.onloadstart = actualOptions.loadstartEventHandler;
xhr.upload.onprogress = actualOptions.progressEventHandler; xhr.upload.onprogress = actualOptions.progressEventHandler;
return xhr; return xhr;
}, },
data: blob, data: blob,
cache: false, cache: false,
processData: false processData: false
}); });
} }
function addInputFiles(inputEl) { function addInputFiles(inputEl) {
// var clearedFileInput = $(inputEl).clone().val(''); // var clearedFileInput = $(inputEl).clone().val('');
if (inputEl.files) { if (inputEl.files) {
// upload files using ajax // upload files using ajax
uploadAndAttachFiles(inputEl.files, inputEl); uploadAndAttachFiles(inputEl.files, inputEl);
// $(inputEl).remove(); // $(inputEl).remove();
} else { } else {
// browser not supporting the file API, upload on form submission // browser not supporting the file API, upload on form submission
var attachmentId; var attachmentId;
@ -260,18 +260,18 @@ function addInputFiles_board(inputEl, id) {
} }
function uploadAndAttachFiles(files, inputEl) { function uploadAndAttachFiles(files, inputEl) {
var maxFileSize = $(inputEl).data('max-file-size'); var maxFileSize = $(inputEl).data('max-file-size');
var maxFileSizeExceeded = $(inputEl).data('max-file-size-message'); var maxFileSizeExceeded = $(inputEl).data('max-file-size-message');
var sizeExceeded = false; var sizeExceeded = false;
$.each(files, function() { $.each(files, function() {
if (this.size && maxFileSize != null && this.size > parseInt(maxFileSize)) {sizeExceeded=true;} if (this.size && maxFileSize != null && this.size > parseInt(maxFileSize)) {sizeExceeded=true;}
}); });
if (sizeExceeded) { if (sizeExceeded) {
window.alert(maxFileSizeExceeded); window.alert(maxFileSizeExceeded);
} else { } else {
$.each(files, function() {addFile(inputEl, this, true);}); $.each(files, function() {addFile(inputEl, this, true);});
} }
} }
function uploadAndAttachFiles_board(files, inputEl, id) { function uploadAndAttachFiles_board(files, inputEl, id) {
@ -290,37 +290,37 @@ function uploadAndAttachFiles_board(files, inputEl, id) {
} }
function handleFileDropEvent(e) { function handleFileDropEvent(e) {
$(this).removeClass('fileover'); $(this).removeClass('fileover');
blockEventPropagation(e); blockEventPropagation(e);
if ($.inArray('Files', e.dataTransfer.types) > -1) { if ($.inArray('Files', e.dataTransfer.types) > -1) {
uploadAndAttachFiles(e.dataTransfer.files, $('input:file.file_selector')); uploadAndAttachFiles(e.dataTransfer.files, $('input:file.file_selector'));
} }
} }
function dragOverHandler(e) { function dragOverHandler(e) {
$(this).addClass('fileover'); $(this).addClass('fileover');
blockEventPropagation(e); blockEventPropagation(e);
} }
function dragOutHandler(e) { function dragOutHandler(e) {
$(this).removeClass('fileover'); $(this).removeClass('fileover');
blockEventPropagation(e); blockEventPropagation(e);
} }
function setupFileDrop() { function setupFileDrop() {
if (window.File && window.FileList && window.ProgressEvent && window.FormData) { if (window.File && window.FileList && window.ProgressEvent && window.FormData) {
$.event.fixHooks.drop = { props: [ 'dataTransfer' ] }; $.event.fixHooks.drop = { props: [ 'dataTransfer' ] };
$('form div.box').has('input:file').each(function() { $('form div.box').has('input:file').each(function() {
$(this).on({ $(this).on({
dragover: dragOverHandler, dragover: dragOverHandler,
dragleave: dragOutHandler, dragleave: dragOutHandler,
drop: handleFileDropEvent drop: handleFileDropEvent
}); });
}); });
} }
} }
$(document).ready(setupFileDrop); $(document).ready(setupFileDrop);