socialforge/app/views/poll/show.html.erb

253 lines
11 KiB
Plaintext
Raw Normal View History

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
2015-01-16 16:13:03 +08:00
<title><%= l(:label_poll_title) %></title>
<%= stylesheet_link_tag 'polls', :media => 'all' %>
2015-01-15 18:22:30 +08:00
<style type="text/css">
2015-01-15 18:35:27 +08:00
.alert_box{width:480px;height:180px;position:fixed;z-index:100;left:55%;top:50%;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;}
.commit{
height: 28px;
display: block;
width: 80px;
color: #fff !important;
background: #15bccf;
text-align: center;
padding-top: 4px;
margin-left: 130px;
margin-top: 4px;
margin-right: 10px;
}
2015-01-15 18:22:30 +08:00
</style>
2015-01-15 17:36:30 +08:00
<script type="text/javascript">
function hidden_atert_form(cur_page,cur_type)
{
hideModal($("#popbox"));
}
</script>
</head>
<body>
<div class="polls_content polls_box" id="polls">
<div class="ur_page_head" >
<h1 class="ur_page_title">
<%= @poll.polls_name%>
</h1>
<p class="ur_prefix_content">
<%= @poll.polls_description %>
</p>
</div>
<div class="ur_card">
<ol class="ur_questions">
2015-01-14 11:50:59 +08:00
<% @poll_questions.each do |pq| %>
<% if pq.question_type == 1 %>
<!-- 单选题 -->
<li class="ur_question_item radio">
<div class="ur_title">
2015-01-16 16:13:03 +08:00
<span class="title_index"><%= l(:label_question_number,:question_number => pq.question_number) %></span>
2015-01-14 11:50:59 +08:00
<%= pq.question_title %>
<% if pq.is_necessary == 1 %>
2015-01-16 16:13:03 +08:00
<span class="ur_required" title="<%= l(:label_must_answer) %>">*</span>
2015-01-14 11:50:59 +08:00
<% end %>
</div>
<div class="cl"></div>
<div class="ur_inputs">
2015-01-15 11:54:30 +08:00
<form>
2015-01-14 11:50:59 +08:00
<table class="ur_table" >
<tbody>
<% pq.poll_answers.each do |pa| %>
<tr>
<td>
<label >
2015-01-15 09:41:19 +08:00
<script>
2015-01-15 10:11:52 +08:00
function click_<%= pa.id %>(obj)
2015-01-15 09:41:19 +08:00
{
$.ajax({
2015-01-15 10:11:52 +08:00
type: "post",
url: "<%= commit_answer_poll_path(@poll) %>",
data: {
poll_answer_id: <%= pa.id %>,
poll_question_id: <%= pq.id %>
},
2015-01-15 09:41:19 +08:00
success: function (data) {
2015-01-16 15:32:09 +08:00
var dataObj = eval(data);
obj.checked = true;
var span = $('#percent');
span.html(dataObj.percent);
2015-01-15 09:41:19 +08:00
}
});
}
</script>
<%= radio_button "poll_vote","poll_answer_id",pa.id,:class=>"ur_radio",:onclick =>"click_#{pa.id}(this);return false;",:checked => answer_be_selected?(pa,User.current),:disabled => !@can_edit_poll %>
2015-01-15 09:41:19 +08:00
<%= pa.answer_text %>
2015-01-14 11:50:59 +08:00
</label>
</td>
</tr>
<% end %>
</tbody>
</table>
2015-01-15 11:54:30 +08:00
</form>
2015-01-14 11:50:59 +08:00
</div>
</li>
<% elsif pq.question_type == 2 %>
<!-- 多选题 -->
<li class="ur_question_item checkbox">
<div class="ur_title">
2015-01-16 16:13:03 +08:00
<span class="title_index"><%= l(:label_question_number,:question_number => pq.question_number) %></span>
2015-01-14 11:50:59 +08:00
<%= pq.question_title %>
<% if pq.is_necessary == 1 %>
2015-01-16 16:13:03 +08:00
<span class="ur_required" title="<%= l(:label_must_answer) %>">*</span>
2015-01-14 11:50:59 +08:00
<% end %>
</div>
<div class="cl"></div>
<div class="ur_inputs">
2015-01-15 11:54:30 +08:00
<form>
<table class="ur_table" >
<tbody>
<% pq.poll_answers.each do |pa| %>
<tr>
<td>
<label >
<script>
function click_<%= pa.id %>(obj)
{
$.ajax({
type: "post",
url: "<%= commit_answer_poll_path(@poll) %>",
data: {
poll_answer_id: <%= pa.id %>,
poll_question_id: <%= pq.id %>
},
success: function (data) {
2015-01-16 15:32:09 +08:00
var dataObj = eval(data);
if(dataObj.text == "true")
2015-01-15 11:54:30 +08:00
{
obj.checked = true;
}
else
{
obj.checked = false;
}
2015-01-16 15:32:09 +08:00
var span = $('#percent');
span.html(dataObj.percent);
2015-01-15 11:54:30 +08:00
}
});
}
</script>
<input class="ur_checkbox" type="checkbox" onclick="click_<%= pa.id %>(this);return false;" <%= answer_be_selected?(pa,User.current) ? "checked":"" %> <%= @can_edit_poll?"":"disabled=disabled" %> >
2015-01-15 11:54:30 +08:00
<%= pa.answer_text %>
</label>
</td>
</tr>
<% end %>
</tbody>
</table>
</form>
2015-01-14 11:50:59 +08:00
</div>
</li>
<% elsif pq.question_type == 3 %>
<!-- 单行文字-->
<li class="ur_question_item text">
<div class="ur_title">
2015-01-16 16:13:03 +08:00
<span class="title_index"><%= l(:label_question_number,:question_number => pq.question_number) %></span>
2015-01-14 11:50:59 +08:00
<%= pq.question_title %>
<% if pq.is_necessary == 1 %>
2015-01-16 16:13:03 +08:00
<span class="ur_required" title="<%= l(:label_must_answer) %>">*</span>
2015-01-14 11:50:59 +08:00
<% end %>
</div>
<div class="cl"></div>
<div class="ur_inputs">
2015-01-15 17:36:30 +08:00
<script>
function onblur_<%= pq.id %>(obj)
{
$(window).unbind('beforeunload');
$.ajax({
type: "post",
url: "<%= commit_answer_poll_path(@poll) %>",
data: {
poll_question_id: <%= pq.id %> ,
vote_text: obj.value
},
success: function (data) {
2015-01-16 15:32:09 +08:00
var dataObj = eval(data);
var span = $('#percent');
span.html(dataObj.percent);
2015-01-15 17:36:30 +08:00
// obj.value = data;
}
});
}
</script>
<input class="ur_text ur_textbox" type="text" size="" maxlength="" value="<%= get_anwser_vote_text(pq.id,User.current.id) %>" onblur="onblur_<%= pq.id %>(this);" <%= @can_edit_poll?"":"disabled=disabled" %>>
2015-01-14 11:50:59 +08:00
</div>
2015-01-15 17:36:30 +08:00
</li><!--单行输入 end-->
2015-01-14 11:50:59 +08:00
<% elsif pq.question_type == 4 %>
<!-- 多行文字-->
<li class="ur_question_item textarea">
<div class="ur_preview">
<div class="ur_title">
2015-01-16 16:13:03 +08:00
<span class="title_index"><%= l(:label_question_number,:question_number => pq.question_number) %></span>
2015-01-14 11:50:59 +08:00
<%= pq.question_title %>
<% if pq.is_necessary == 1 %>
2015-01-16 16:13:03 +08:00
<span class="ur_required" title="<%= l(:label_must_answer) %>">*</span>
2015-01-14 11:50:59 +08:00
<% end %>
</div>
<div class="cl"></div>
<div class="ur_inputs">
2015-01-15 17:36:30 +08:00
<script>
function onblur_<%= pq.id %>(obj)
{
$.ajax({
type: "post",
url: "<%= commit_answer_poll_path(@poll) %>",
data: {
poll_question_id: <%= pq.id %> ,
vote_text: obj.innerHTML
},
success: function (data) {
2015-01-16 15:32:09 +08:00
var dataObj = eval(data);
if(dataObj.text != 'failure')
{
var span = $('#percent');
span.html(dataObj.percent);
}
else
{
alert("error");
}
2015-01-15 17:36:30 +08:00
}
});
}
</script>
<div contenteditable='<%= @can_edit_poll %>' class="ur_textbox" style="min-height: 150px;width: 100%;<%= @can_edit_poll?"":"background-color:#DCDCDC;" %>" onblur="onblur_<%= pq.id %>(this);"><%= get_anwser_vote_text(pq.id,User.current.id) %></div>
2015-01-14 11:50:59 +08:00
</div>
</div>
</li><!--多行输入 end-->
<% else %>
<!-- 未知题型 -->
<% end %>
<% end %>
</ol>
2015-01-14 11:50:59 +08:00
<ul class="wlist">
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%>
</ul>
<div class="cl"></div>
<div class="ur_buttons" style="width: 100px;">
2015-01-16 10:59:25 +08:00
<% if @poll.polls_status == 2 %>
2015-01-16 16:13:03 +08:00
<%= link_to l(:button_submit),commit_poll_poll_path(@poll), :method => :post,:class => "ur_button",:format => 'js',:remote=>true %>
2015-01-16 10:59:25 +08:00
<% end %>
</div>
<div class="cl"></div>
2015-01-16 16:13:03 +08:00
<div class="ur_progress_text"><%= l(:label_complete_question) %> <strong class="ur_progress_number"><span id="percent"><%= format "%.2f" ,@percent %></span>%</strong> </div>
</div>
</div><!--问卷内容end-->
</body>
</html>