1、修改问卷列表页面样式

2、问卷列表增加发布问卷功能
3、增加js返回方式
4、去掉无用的js函数
This commit is contained in:
sw 2015-01-21 11:14:01 +08:00
parent 402dfc788f
commit 3bdaeb20c2
9 changed files with 94 additions and 52 deletions

View File

@ -187,7 +187,13 @@ class PollController < ApplicationController
@poll.polls_status = 2
@poll.published_at = Time.now
if @poll.save
redirect_to poll_index_url(:polls_type => "Course", :polls_group_id => @course.id)
if params[:is_remote]
redirect_to poll_index_url(:polls_type => "Course", :polls_group_id => @course.id)
else
respond_to do |format|
format.js
end
end
end
end

View File

@ -1,23 +1,44 @@
<% has_commit = has_commit_poll?(poll.id ,User.current)%>
<li title="<%= poll.polls_name %>">
<% if @is_teacher %>
<% if has_commit_poll?(poll.id ,User.current) %>
<sapn class="polls_title fl"> <%= poll.polls_name %></sapn>
<% if has_commit %>
<sapn class="polls_title fl">
<%= poll.polls_name.empty? ? l(:label_poll_new) : poll.polls_name%>
</sapn>
<% else %>
<%= link_to poll.polls_name, poll_path(poll.id), :class => "polls_title fl" %>
<%= link_to (poll.polls_name.empty? ? l(:label_poll_new) : poll.polls_name), poll_path(poll.id), :class => "polls_title polls_title_w fl" %>
<% end %>
<% else %>
<% if has_commit_poll?(poll.id ,User.current) && poll.polls_status == 2 %>
<% if has_commit && poll.polls_status == 2 %>
<sapn class="polls_title fl" >
<%= poll.polls_name %>
<%= poll.polls_name.empty? ? l(:label_poll_new) : poll.polls_name %>
</sapn>
<% elsif (!has_commit_poll?(poll.id ,User.current)) && poll.polls_status == 2 %>
<%= link_to poll.polls_name, poll_path(poll.id), :class => "polls_title fl" %>
<% elsif !has_commit && poll.polls_status == 2 %>
<%= link_to (poll.polls_name.empty? ? l(:label_poll_new) : poll.polls_name), poll_path(poll.id), :class => "polls_title polls_title_w fl" %>
<% end %>
<% end %>
</li>
<% if !@is_teacher && has_commit && poll.polls_status == 2%>
<li class="pollsbtn_tip fl ml5">已答</li>
<% end %>
<%if @is_teacher%>
<% if poll.polls_status == 1 %>
<li class="pollsbtn fl ml10 pollsbtn_grey">统计结果</li>
<% elsif poll.polls_status == 2%>
<li>
<%= link_to l(:label_statistical_results), statistics_result_poll_path(poll.id), :class => "pollsbtn fl ml10"%>
</li>
<% end%>
<% end%>
<li>
<%if @is_teacher && poll.polls_status == 2%>
<%= link_to l(:label_statistical_results), statistics_result_poll_path(poll.id), :class => "pollsbtn fl ml10"%>
<%if @is_teacher %>
<% if poll.polls_status == 1 %>
<a href="#" class="pollsbtn btn_pu fl ml5" onclick="poll_submit(<%= poll.id%>);">发布问卷</a>
<% elsif poll.polls_status == 2%>
<a href="#" class="pollsbtn btn_de fl ml5" onclick="republish_poll(<%= poll.id%>);">取消发布</a>
<% end%>
<% end%>
</li>
<li>
@ -28,18 +49,21 @@
<% end%>
</li>
<li>
<% if @is_teacher && poll.polls_status == 1%>
<!--新建状态的问卷可编辑-->
<%= link_to l(:button_edit), edit_poll_path(poll.id), :class => "polls_de fr ml20"%>
<% if @is_teacher%>
<% if poll.polls_status == 1 %>
<%= link_to l(:button_edit), edit_poll_path(poll.id), :class => "polls_de fr ml20"%>
<% elsif poll.polls_status == 2%>
<li class="polls_de_grey fr ml20">编辑</li>
<% end%>
<% end%>
</li>
<li>
<% if @is_teacher && poll.polls_status == 2%>
<a class="polls_de fr ml20" onclick="republish_poll(<%= poll.id%>);">
取消发布
</a>
<% end %>
</li>
<li class="polls_date fr">
<!--<li>-->
<!--<% if @is_teacher && poll.polls_status == 2%>-->
<!--<a class="polls_de fr ml20" onclick="republish_poll(<%= poll.id%>);">-->
<!--取消发布-->
<!--</a>-->
<!--<% end %>-->
<!--</li>-->
<li class="polls_date fr mr10">
<%= format_time poll.created_at%>
</li>

View File

@ -57,7 +57,7 @@
function poll_submit()
{
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'poll_submit', locals: { poll: @poll}) %>');
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'poll_submit', locals: { :poll => @poll},:is_remote => false) %>');
showModal('ajax-modal', '310px');
$('#ajax-modal').css('height','110px');
$('#ajax-modal').siblings().remove();

View File

@ -2,18 +2,6 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
function clickPublishPoll()
{
hideModal("#popbox02");
$.ajax({
type: "GET",
url: "<%= publish_poll_poll_path(poll.id)%>",
data: 'text',
success: function (data) {
}
});
}
function clickCanel(){hideModal("#popbox02");}
</script>
</head>

View File

@ -2,18 +2,6 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
function clickPublishPoll()
{
hideModal("#popbox02");
$.ajax({
type: "GET",
url: "<%= publish_poll_poll_path(poll.id)%>",
data: 'text',
success: function (data) {
}
});
}
function clickCanel(){hideModal("#popbox02");}
</script>
</head>
@ -27,16 +15,14 @@
是否确定发布该问卷?
</p>
<div class="polls_btn_box">
<%= link_to "确 定",publish_poll_poll_path(poll.id), :class => "upload_btn", :onclick => "clickCanel();" %>
<%= link_to "确 定",publish_poll_poll_path(poll.id,:is_remote => is_remote), :class => "upload_btn", :onclick => "clickCanel();" %>
<a class="upload_btn upload_btn_grey" onclick="clickCanel();">
取&nbsp;&nbsp;消
</a>
</div>
<div class="cl"></div>
</div>
</div>
</div>
</body>
</html>

View File

@ -25,6 +25,30 @@
}
function clickCanel(){hideModal("#popbox02");}
function poll_submit(poll_id)
{
$('#ajax-modal').html("<div id='popbox02'>" +
"<div class='upload_con'>" +
"<div class='upload_box'>" +
"<p class='polls_box_p'>问卷发布后将不能对问卷进行修改,<br />是否确定发布该问卷?</p>" +
"<div class='polls_btn_box'>" +
"<a href='/poll/"+ poll_id +"/publish_poll' class='upload_btn' onclick='clickCanel();' data-remote='true'>确&nbsp;&nbsp;定</a>" +
"<a class='upload_btn upload_btn_grey' onclick='clickCanel();'>取&nbsp;&nbsp;消</a>" +
"</div>" +
"<div class='cl'></div>" +
"</div>" +
"</div>" +
"</div>");
showModal('ajax-modal', '310px');
$('#ajax-modal').css('height','110px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
"<a href='#' onclick='clickCanel();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
$('#ajax-modal').parent().removeClass("alert_praise");
$('#ajax-modal').parent().css("top","").css("left","");
$('#ajax-modal').parent().addClass("popbox_polls");
}
</script>
<div class="polls_content" id="polls" style="width:677px;">
<div class="polls_head">

View File

@ -0,0 +1,2 @@
$("#polls_<%= @poll.id %>").html("<%= escape_javascript(render :partial => 'poll',:locals => {:poll => @poll}) %>");
alert("发布成功");

View File

@ -1 +1,2 @@
$("#polls_<%= @poll.id %>").html("<%= escape_javascript(render :partial => 'poll',:locals => {:poll => @poll}) %>");
$("#polls_<%= @poll.id %>").html("<%= escape_javascript(render :partial => 'poll',:locals => {:poll => @poll}) %>");
alert("取消成功");

View File

@ -26,8 +26,8 @@ div,html,img,ul,li,p,body,h1,h2,h3,h4,p,a,table,tr,td,fieldset,input,span{ margi
a.newbtn{ float:right; display:block; width:80px; height:30px; background:#64bdd9; color:#fff; font-size:14px; margin:10px; text-align:center;}
a:hover.newbtn{ background:#55a1b9; text-decoration:none;}
.polls_list ul{ padding-left:10px; border-bottom:1px dashed #c9c9c9; height:32px; padding-top:8px;}
a.polls_title{ font-weight:bold; color:#3e6d8e;max-width: 350px;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;}
.polls_title{ font-weight:bold; color:#3e6d8e;max-width: 350px;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;}
a.polls_title{ font-weight:bold; color:#3e6d8e;max-width: 300px;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;}
.polls_title{ font-weight:bold; color:#3e6d8e;max-width: 300px;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;}
a.pollsbtn{ display:block; width:66px; height:22px; text-align:center; border:1px solid #64bdd9; color:#64bdd9;}
a:hover.pollsbtn{ background:#64bdd9; color:#fff; text-decoration:none;}
.polls_date{ color:#666666;}
@ -134,3 +134,14 @@ a:hover.upload_btn_grey{background:#8a8a8a;}
.upload_con a:hover{ text-decoration:none;}
.polls_btn_box{ width:145px; margin:0 auto; padding-left:10px;}
.polls_btn_box02{ width:80px; margin:0 auto; padding-left:10px;}
/***新增20150120***/
.pollsbtn_tip{ width:30px; height:17px; display:block;background:url(images/icons.png) 0 -417px no-repeat;padding-left:7px; color:#fff;}
a.btn_de{ border:1px solid #ff5d31; color:#ff5d31; }
a:hover.btn_de{ background:#ff5d31;}
a.btn_pu{ border:1px solid #3cb761; color:#3cb761; }
a:hover.btn_pu{ background:#3cb761;}
.pollsbtn_grey{ border:1px solid #b1b1b1; color:#b1b1b1; padding:0px 9px; }
.polls_title_w { width:330px; overflow: hidden;white-space: nowrap;text-overflow: ellipsis;}
.polls_de_grey{ color:#b1b1b1;}
.ml5{ margin-left:5px;}