竞赛图片的上传

This commit is contained in:
cxt 2017-01-06 15:52:34 +08:00
parent cc4d46c3ee
commit 83c00d1225
8 changed files with 33 additions and 13 deletions

View File

@ -40,7 +40,7 @@ class AvatarController < ApplicationController
@urlfile='/' << File.join("images","avatars",avatar_directory(@source_type),avatar_filename(@source_id,@image_file))
# 用户头像上传时进行特别处理
if @is_direct == '1' && (@source_type == 'User' || @source_type == 'Course' || @source_type == 'Project' || @source_type == 'Organization')
if @is_direct == '1' && (@source_type == 'User' || @source_type == 'Course' || @source_type == 'Project' || @source_type == 'Organization'|| @source_type == 'Contest')
diskfile += "temp"
@urlfile += "temp"
end

View File

@ -1,4 +1,4 @@
<% if @is_direct == '1' && (@source_type=='User'|| @source_type == 'Course' || @source_type == 'Project' || @source_type == 'Organization') %>
<% if @is_direct == '1' && (@source_type=='User'|| @source_type == 'Course' || @source_type == 'Project' || @source_type == 'Organization'|| @source_type == 'Contest') %>
var imgSpan = $("img[nhname='avatar_image']");
imgSpan.attr({"src":'<%= "#{@urlfile.to_s}?#{Time.now.to_i}" %>'});
<% else %>

View File

@ -9,7 +9,12 @@
<div class="cl"></div>
<div class="banner-game">
<%=render :partial => 'avatar/new_contest_avatar_form', :locals => {source: @contest, is_admin: User.current.admin_of_contest?(@contest) || User.current.admin?} %>
<%= image_tag(url_to_avatar(@contest), :width => "968", :height => "110", :alt => "竞赛图片", :id=>'nh_source_tx')%>
<% if User.current.admin_of_contest?(@contest) || User.current.admin? %>
<a class="banner-inner" href="<%=my_clear_user_avatar_temp_path(:contest => @contest.id) %>" data-remote="true"></a>
<a class="banner-notice" href="<%=my_clear_user_avatar_temp_path(:contest => @contest.id) %>" data-remote="true">点击替换图片(968*110)</a>
<% end %>
<%#=render :partial => 'avatar/new_contest_avatar_form', :locals => {source: @contest, is_admin: User.current.admin_of_contest?(@contest) || User.current.admin?} %>
</div>
<div class="sy_class_info fl">
<div class="sy_class_titbox">

View File

@ -1,12 +1,12 @@
<div id="sy_popup_box" style="width:400px;">
<div id="sy_popup_box" style="width:1000px;">
<div class="sy_popup_top">
<h3 class="fl">上传图片</h3>
<a href="javascript:void(0);" class="sy_icons_close fr" onclick="hideModal()"></a>
<div class="cl"></div>
</div>
<div class="sy_popup_con">
<div class="uppicBox">
<input type="button" class="uppic_btn" onclick="$('#upload_avatar').click();" value="浏览.."/>
<div class="">
<div style="margin: 10px 20px;">
<a type="button" class="BlueCirBtn" onclick="$('#upload_avatar').click();">上传图片</a>
<%= file_field_tag 'avatar[image]',
:id => "upload_avatar",
:style => 'display:none;',#added by young
@ -28,10 +28,16 @@
<!--<br/>-->
<!--<span>只支持jpg,png,gif,大小不超过5M</span>-->
</div>
<div class="cl"></div>
<div>
<p style="text-align: center; font-size: 16px;">预览(968px*110px)</p>
<%= image_tag(url_to_avatar(source), :style=>"width:968px;height:110px;",:class=>"mb5 mt10 ml16",:nhname=>'avatar_image') %>
<br/>
</div>
<div class="cl mb10"></div>
<a href="javascript:hideModal();" class=" fr grey_btn mr15 f14"> 取&nbsp;&nbsp;消</a>
<a href="<%= url_for(:controller => 'my', :action => 'save_user_avatar', :source_id => source.id, :source_type => source.class.to_s) %>" data-remote="true" class="blue_btn fr mr10 f14">确&nbsp;&nbsp;定</a>
<a href="<%= url_for(:controller => 'my', :action => 'save_user_avatar', :source_id => source.id, :source_type => source.class.to_s) %>" data-remote="true" class="sy_btn_blue fr mr16 f14">确&nbsp;&nbsp;定</a>
<a href="javascript:hideModal();" class="fr sy_btn_grey mr5 f14"> 取&nbsp;&nbsp;消</a>
<div class="cl"></div>
</div>
</div>
<script>

View File

@ -13,7 +13,7 @@
<%= heads_for_theme %>
<%= call_hook :view_layouts_base_html_head %>
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2','css/common','css/public', 'css/structure','prettify', 'css/courses','css/popup','sy_public','syllabus', 'css/moduel','css/contest'%>
<%= javascript_include_tag "course","avatars","header","attachments",'prettify','contest','jq-upload/jquery.ui.widget', 'jq-upload/jquery.iframe-transport', 'jq-upload/jquery.fileupload', 'jq-upload/upload' %>
<%= javascript_include_tag "course","avatars","header","attachments",'prettify','contest' %>
<!-- page specific tags -->
<%= yield :header_tags -%>
@ -99,7 +99,8 @@
</div>
<div id="ajax-modal" style="display:none;"></div>
<div id="nh_tx_dialog_html" class="white_content" style="display:none;">
<%=render :partial => 'layouts/upload_avatar', :locals => {:source => @contest} %>
<%=render :partial => 'contests/upload_img', :locals => {:source => @contest} %>
<%#=render :partial => 'layouts/upload_avatar', :locals => {:source => @contest} %>
</div>
<%= call_hook :view_layouts_base_body_bottom %>
</body>

View File

@ -1,8 +1,13 @@
$("img[nhname='avatar_image']").attr('src',$("#nh_source_tx").attr('src'));
<% if @contest %>
var htmlvalue = $("#nh_tx_dialog_html").html();
pop_box_new(htmlvalue, 1000, 400);
<% else %>
$('#ajax-modal').html($("#nh_tx_dialog_html").html());
showModal('ajax-modal','460px');
$('#ajax-modal').siblings().hide();
$('#ajax-modal').parent().removeClass("alert_praise").removeClass("copyCoursePopup");
$('#ajax-modal').parent().css("top","30%").css("left","40%");
$('#ajax-modal').parent().addClass("alert_box");
$('#ajax-modal').parent().css("border", "3px solid #269ac9").css("border-radius", "0").css(" -webkit-border-radius", "0").css(" -moz-border-radius", "0");
$('#ajax-modal').parent().css("border", "3px solid #269ac9").css("border-radius", "0").css(" -webkit-border-radius", "0").css(" -moz-border-radius", "0");
<% end %>

View File

@ -6,6 +6,8 @@ $("#nh_source_tx").replaceWith('<%= image_tag(url_to_avatar(@course), :id=>'nh_s
if($("#course_avatar_form").length > 0) {
window.location.href = "<%=settings_course_path(@course) %>";
}
<% elsif @contest %>
$("#nh_source_tx").replaceWith('<%= image_tag(url_to_avatar(@contest), :id=>'nh_source_tx',:style=>"width:968px;height:110px;overflow:hidden",:alt=>"竞赛图片") %>');
<% elsif @project %>
$("#nh_source_tx").replaceWith('<%= image_tag(url_to_avatar(@project), :id=>'nh_source_tx',:style=>"width:110px;height:110px;overflow:hidden",:alt=>"项目logo") %>');
if($("#project_avatar_form").length > 0) {

View File

@ -160,6 +160,7 @@ h4{ font-size:14px;}/*color:#3b3b3b;*/
.mr10{ margin-right:10px;}
.mr12{ margin-right:12px;}
.mr15 {margin-right:15px;}
.mr16 {margin-right:16px;}
.mr18 {margin-right:18px;}
.mr20{ margin-right:20px;}
.mr25 {margin-right:25px;}