Merge branch 'szzh' into develop

This commit is contained in:
sw 2015-03-27 20:05:57 +08:00
commit ba518f0bd9
7 changed files with 61 additions and 67 deletions

View File

@ -30,19 +30,19 @@ class CoursesController < ApplicationController
def join def join
if User.current.logged? if User.current.logged?
cs = CoursesService.new cs = CoursesService.new
join = cs.join_course params,User.current user = User.current
join = cs.join_course params,user
@state = join[:state] @state = join[:state]
course = join[:course] course = join[:course]
else else
@state = 5 #未登录 @state = 5 #未登录
end end
respond_to do |format| respond_to do |format|
format.js { render :partial => 'set_join', :locals => {:user => User.current, :course => course, :object_id => params[:object_id]} } format.js { render :partial => 'set_join', :locals => {:user => user, :course => course, :object_id => params[:object_id]} }
end end
rescue Exception => e rescue Exception => e
@state = 4 #已经加入了课程 @state = 4 #已经加入了课程
respond_to do |format| respond_to do |format|
# format.html { redirect_to_referer_or {render :text => (watching ? 'Watcher added.' : 'Watcher removed.'), :layout => true}}
format.js { render :partial => 'set_join', :locals => {:user => User.current, :course => nil, :object_id => nil} } format.js { render :partial => 'set_join', :locals => {:user => User.current, :course => nil, :object_id => nil} }
end end
end end

View File

@ -677,7 +677,7 @@ module CoursesHelper
#加入课程、退出课程按钮 #加入课程、退出课程按钮
def join_in_course_header(course, user, options=[]) def join_in_course_header(course, user, options=[])
if user.logged? if user.logged?
joined = user.member_of_course? course joined = course.members.map{|member| member.user_id}.include? user.id
text = joined ? ("<em class='pr_arrow'></em>".html_safe + l(:label_course_exit_student)) : ("<em class='pr_add'></em>".html_safe + l(:label_course_join_student)) text = joined ? ("<em class='pr_arrow'></em>".html_safe + l(:label_course_exit_student)) : ("<em class='pr_add'></em>".html_safe + l(:label_course_join_student))
url = joined ? join_path(:object_id => course.id) : try_join_path(:object_id => course.id) url = joined ? join_path(:object_id => course.id) : try_join_path(:object_id => course.id)
method = joined ? 'delete' : 'post' method = joined ? 'delete' : 'post'

View File

@ -33,8 +33,9 @@
<p id="bid_evaluation_num_span" class="c_red" style="padding-left: 90px;"></p> <p id="bid_evaluation_num_span" class="c_red" style="padding-left: 90px;"></p>
</li> </li>
<li class="ml45"> <li class="ml45">
<label>&nbsp;&nbsp;<%= l(:label_attachment_plural) %>&nbsp;&nbsp;</label> <label class="fl">&nbsp;&nbsp;<%= l(:label_attachment_plural) %>&nbsp;&nbsp;</label>
<%= render :partial => 'attachments/new_form', :locals => {:container => bid} %> <%= render :partial => 'attachments/new_form', :locals => {:container => bid} %>
<div class="cl"></div>
</li> </li>
<li class=" ml90" > <li class=" ml90" >
<a class="blue_btn fl c_white" onclick="submit_new_bid('<%= bid_id%>');" href="#"><%= l(:button_create)%></a> <a class="blue_btn fl c_white" onclick="submit_new_bid('<%= bid_id%>');" href="#"><%= l(:button_create)%></a>

View File

@ -1,9 +1,10 @@
<% if object_id%> <% if object_id%>
$("#<%=object_id%>").replaceWith('<%= escape_javascript join_in_course(course, user) %>'); $("#join_in_course_header").html("<%= escape_javascript(join_in_course_header(course, user)) %>");
<% end %> <% end %>
<% if @state %> <% if @state %>
<% if @state == 0 %> <% if @state == 0 %>
alert("加入成功"); alert("加入成功");
hideModal("#popbox02");
<% elsif @state == 1 %> <% elsif @state == 1 %>
alert("密码错误"); alert("密码错误");
<% elsif @state == 2 %> <% elsif @state == 2 %>

View File

@ -1,3 +1,8 @@
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'projects/new_join', :locals => {:course => @course}) %>'); $('#ajax-modal').html('<%= escape_javascript(render :partial => 'projects/new_join', locals: { :course => @course}) %>');
showModal('ajax-modal', '400px'); showModal('ajax-modal', '500px');
$('#ajax-modal').addClass('new-watcher'); $('#ajax-modal').css('height','100px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
"<a href='javascript:' onclick='clickCanel();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
$('#ajax-modal').parent().css("top","").css("left","");
$('#ajax-modal').parent().addClass("anonymos");

View File

@ -77,7 +77,7 @@
<%= set_course_time @course%> <%= set_course_time @course%>
<%= link_to "<span class='pr_copy'></span>#{l(:button_copy)}".html_safe, copy_course_course_path(@course.id), :class => "pr_join_a" %> <%= link_to "<span class='pr_copy'></span>#{l(:button_copy)}".html_safe, copy_course_course_path(@course.id), :class => "pr_join_a" %>
<% else%> <% else%>
<%= join_in_course_header(@course, User.current) %> <div id="join_in_course_header"><%= join_in_course_header(@course, User.current) %></div>
<% end%> <% end%>
</div> </div>
<div class="cl"></div> <div class="cl"></div>

View File

@ -1,62 +1,49 @@
<!-- added by fq --> <!-- added by fq -->
<style> <html xmlns="http://www.w3.org/1999/xhtml">
input[type="submit"].bid_btn { <head>
vertical-align: middle; <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
width: 60px;/*modified by ming*/ <style>
height: 25px; /* 匿名评分弹框 */
line-height: 19px; .anonymos{width:480px;height:180px;position:fixed !important;z-index:100;left:50%;top:60%;margin:-215px 0 0 -300px; background:#fff; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px; box-shadow:0px 0px 8px #194a81; overflow:auto;}
font-size: 14px; .ni_con { width:425px; margin:25px 30px;}
color: rgb(0, 0, 0); .ni_con h2{ display:block; height:40px; width:425px; text-align:center; color:#3a3a3a;}
background: buttonface;/*url("/images/button/bg103.jpg") no-repeat scroll left top transparent;*/ .ni_con label{ color:#808181; }
padding: 0px 0px 4px 0px; .ni_con a:hover{ text-decoration:none;}
border-radius: 2px; .ni_btn{ width:190px; margin:15px auto; line-height:1.9;}
border: 1px solid rgb(148, 148, 148); a.tijiao{ height:28px; display:block; width:80px; color:#fff; background:#15bccf; text-align:center; padding-top:4px; float:left; margin-right:15px;}
box-shadow: none; a:hover.tijiao{ background:#0f99a9;}
text-shadow: none; .c_blue{ color:#0195bd;}
/*margin-top: -10px;*/ .c_pink{ color:#e65d5e;}
/*margin-right: -4px;*/ </style>
}
input[type="button"].bid_btn {
width: 60px;/*modified by ming*/
height: 25px;
line-height: 19px;
font-size: 14px;
color: rgb(0, 0, 0);
background: buttonface;/*url("/images/button/bg103.jpg") no-repeat scroll left top transparent;*/
padding: 0px 0px 4px 0px;
border-radius: 2px;
border: 1px solid rgb(148, 148, 148);
box-shadow: none;
text-shadow: none;
/*margin-top: -10px;*/
margin-right: -2px;
}
textarea:focus {
border: #d5dee9 1px solid;
}
</style>
<h3 class="title">请输入课程密码</h3> <script type="text/javascript">
function clickCanel(){hideModal("#popbox02");}
</script>
</head>
<%= form_tag({:controller => 'courses', <body>
:action => 'join', <div id="popbox02">
:object_id => course.id}, <div class="ni_con">
:remote => true, <%= form_tag({:controller => 'courses',
:method => :post, :action => 'join',
:id => 'new-watcher-form') do %> :object_id => course.id},
<table border="0"> :remote => true,
<tr> :method => :post,
<td align="cneter"> :id => 'new_join_course') do %>
</td> <label>请输入课程密码:</label>
<%= text_field_tag 'course_password', nil, :style=>'width:300px;'%>
<div> <div class="ni_btn">
<%= text_field_tag 'course_password', nil, :style=>'width:100%'%> <a href="javascript:" class="tijiao" onclick="$('#new_join_course').submit();" >
确&nbsp;&nbsp;定
</a>
<a href="javascript:" class="tijiao" onclick="clickCanel();">
取&nbsp;&nbsp;消
</a>
</div>
<% end %>
</div> </div>
</div>
</body>
</html>
<p class="buttons" style="padding-top: 10px; padding-bottom: 1px; margin-bottom: 1px">
<%= submit_tag l(:label_new_join), :name => nil, :class => "bid_btn", :onclick => "hideModal(this);" %>
<%= submit_tag l(:button_cancel), :name => nil, :class => "bid_btn", :onclick => "hideModal(this);", :type => 'button' %>
</p>
</td>
</tr></table>
<% end %>