parent
a99d7c5145
commit
a1f21f3ebb
|
@ -1,45 +1,45 @@
|
|||
<%= form_for PollQuestion.new,:url =>create_poll_question_poll_path(@poll.id),:remote => true do |f|%>
|
||||
<div>
|
||||
<!--编辑单选start-->
|
||||
<div class="ur_editor radio">
|
||||
<div class="ur_editor_title">
|
||||
<label>问题: </label>
|
||||
<input type="hidden" name="question_type" value="1"/>
|
||||
<input class="ur_question_title" type="text" name="poll_questions_title" placeholder="请输入单选题标题"/>
|
||||
<input type="checkbox" name="is_necessary" value="true" checked/>
|
||||
<label>必答</label>
|
||||
</div>
|
||||
<div class="ur_editor_content">
|
||||
<ul>
|
||||
<li class='ur_item'>
|
||||
<label>选项<span class='ur_index'></span>:</label>
|
||||
<input type='text' name='question_answer[0]' placeholder='新建选项'/>
|
||||
<a class='icon_add' title='向下插入选项' onclick='add_single_answer($(this));'></a>
|
||||
<a class='icon_remove' title='删除' onclick='remove_single_answer($(this))'></a>
|
||||
</li>
|
||||
<div class='cl'></div>
|
||||
<li class='ur_item'>
|
||||
<label>选项<span class='ur_index'></span>:</label>
|
||||
<input type='text' name='question_answer[1]' placeholder='新建选项'/>
|
||||
<a class='icon_add' title='向下插入选项' onclick='add_single_answer($(this));'></a>
|
||||
<a class='icon_remove' title='删除' onclick='remove_single_answer($(this))'></a>
|
||||
</li>
|
||||
<div class='cl'></div>
|
||||
<li class='ur_item'>
|
||||
<label>选项<span class='ur_index'></span>:</label>
|
||||
<input type='text' name='question_answer[2]' placeholder='新建选项'/>
|
||||
<a class='icon_add' title='向下插入选项' onclick='add_single_answer($(this));'></a>
|
||||
<a class='icon_remove' title='删除' onclick='remove_single_answer($(this))'></a>
|
||||
</li>
|
||||
<div class='cl'></div>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="ur_editor_footer">
|
||||
<a class="btn btn_dark btn_submit" data-button="ok" onclick="$(this).parent().parent().parent().parent().submit();">确定</a>
|
||||
<a class="btn btn_light btn_cancel" data-button="cancel" onclick="$(this).parent().parent().parent().parent().remove();">取消</a>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<div>
|
||||
<!--编辑单选start-->
|
||||
<div class="ur_editor radio">
|
||||
<div class="ur_editor_title">
|
||||
<label>问题: </label>
|
||||
<input type="hidden" name="question_type" value="1"/>
|
||||
<input class="ur_question_title" type="text" name="poll_questions_title" id="poll_questions_title" placeholder="请输入单选题标题"/>
|
||||
<input type="checkbox" name="is_necessary" value="true" checked/>
|
||||
<label>必答</label>
|
||||
</div>
|
||||
<!--编辑单选 end-->
|
||||
<div class="ur_editor_content">
|
||||
<ul>
|
||||
<li class='ur_item'>
|
||||
<label>选项<span class='ur_index'></span>:</label>
|
||||
<input type='text' name='question_answer[0]' placeholder='新建选项'/>
|
||||
<a class='icon_add' title='向下插入选项' onclick='add_single_answer($(this));'></a>
|
||||
<a class='icon_remove' title='删除' onclick='remove_single_answer($(this))'></a>
|
||||
</li>
|
||||
<div class='cl'></div>
|
||||
<li class='ur_item'>
|
||||
<label>选项<span class='ur_index'></span>:</label>
|
||||
<input type='text' name='question_answer[1]' placeholder='新建选项'/>
|
||||
<a class='icon_add' title='向下插入选项' onclick='add_single_answer($(this));'></a>
|
||||
<a class='icon_remove' title='删除' onclick='remove_single_answer($(this))'></a>
|
||||
</li>
|
||||
<div class='cl'></div>
|
||||
<li class='ur_item'>
|
||||
<label>选项<span class='ur_index'></span>:</label>
|
||||
<input type='text' name='question_answer[2]' placeholder='新建选项'/>
|
||||
<a class='icon_add' title='向下插入选项' onclick='add_single_answer($(this));'></a>
|
||||
<a class='icon_remove' title='删除' onclick='remove_single_answer($(this))'></a>
|
||||
</li>
|
||||
<div class='cl'></div>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="ur_editor_footer">
|
||||
<a class="btn btn_dark btn_submit" data-button="ok" onclick="$(this).parent().parent().parent().parent().submit();">确定</a>
|
||||
<a class="btn btn_light btn_cancel" data-button="cancel" onclick="$(this).parent().parent().parent().parent().parent().remove();">取消</a>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<!--编辑单选 end-->
|
||||
</div>
|
||||
<% end%>
|
|
@ -2,7 +2,7 @@
|
|||
<div class="ur_editor checkbox">
|
||||
<div class="ur_editor_title">
|
||||
<label >问题: </label>
|
||||
<input class="ur_question_title" type="text" name="title" placeholder="请输入多选题题标题"/>
|
||||
<input class="ur_question_title" type="text" name="poll_questions_title" id="poll_questions_title" placeholder="请输入多选题题标题"/>
|
||||
<input type="checkbox" name="required" value="true" checked=""/>
|
||||
<label >必答</label>
|
||||
</div>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<div class="ur_editor textarea"> <!--编辑多行文字start-->
|
||||
<div class="ur_editor_title">
|
||||
<label for="ur_question_title">问题: </label>
|
||||
<input id="ur_question_title" class="ur_question_title" contenteditable="true" type="text" name="title" placeholder="请输入多行文字标题"/>
|
||||
<input id="poll_questions_title" class="ur_question_title" contenteditable="true" type="text" name="poll_questions_title" placeholder="请输入多行文字标题"/>
|
||||
<input type="checkbox" name="required" value="true" id="ur_question_require" checked=""/>
|
||||
<label for="ur_question_require">必答</label>
|
||||
</div>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<div class="ur_editor text "> <!--编辑单行文字start-->
|
||||
<div class="ur_editor_title">
|
||||
<label for="ur_question_title">问题: </label>
|
||||
<input id="ur_question_title_1" class="ur_question_title" contenteditable="true" type="text" name="title" placeholder="请输入单行文字标题"/>
|
||||
<input id="poll_questions_title" class="ur_question_title" contenteditable="true" type="text" name="title" placeholder="请输入单行文字标题"/>
|
||||
<input type="checkbox" name="required" value="true" id="ur_question_require_2" checked=""/>
|
||||
<label for="ur_question_require">必答</label>
|
||||
</div>
|
||||
|
|
|
@ -4,12 +4,25 @@
|
|||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>问卷调查_问卷编辑</title>
|
||||
<%= stylesheet_link_tag 'polls', :media => 'all' %>
|
||||
<%#= javascript_include_tag "polls" %>
|
||||
|
||||
<script type="text/javascript">
|
||||
function add_MC(){$("#poll_content").append("<%= escape_javascript(render :partial => 'new_MC') %>");}
|
||||
function add_MCQ(){$("#poll_content").append("<%= escape_javascript(render :partial => 'new_MCQ') %>");}
|
||||
function add_single(){$("#poll_content").append("<%= escape_javascript(render :partial => 'new_single') %>");}
|
||||
function add_mulit(){$("#poll_content").append("<%= escape_javascript(render :partial => 'new_mulit') %>");}
|
||||
function add_MC(){
|
||||
$("#new_poll_question").html("<%= escape_javascript(render :partial => 'new_MC') %>");
|
||||
$("#poll_questions_title").focus();
|
||||
}
|
||||
function add_MCQ(){
|
||||
$("#new_poll_question").html("<%= escape_javascript(render :partial => 'new_MCQ') %>");
|
||||
$("#poll_questions_title").focus();
|
||||
}
|
||||
function add_single(){
|
||||
$("#new_poll_question").html("<%= escape_javascript(render :partial => 'new_single') %>");
|
||||
$("#poll_questions_title").focus();
|
||||
}
|
||||
function add_mulit(){
|
||||
$("#new_poll_question").html("<%= escape_javascript(render :partial => 'new_mulit') %>");
|
||||
$("#poll_questions_title").focus();
|
||||
}
|
||||
//问卷头
|
||||
function pollsCancel(){$("#polls_head_edit").hide();$("#polls_head_show").show();}
|
||||
function pollsEdit(){$("#polls_head_edit").show();$("#polls_head_show").hide();}
|
||||
|
@ -71,16 +84,21 @@
|
|||
<%= render :partial => 'edit_head', :locals => {:poll => @poll}%>
|
||||
</div>
|
||||
|
||||
<% @poll.poll_questions.each do |poll_question|%>
|
||||
<div id="show_polls_questions_<%= poll_question.id %>">
|
||||
<%= render :partial => 'show_MC', :locals => {:poll_question => poll_question} %>
|
||||
</div>
|
||||
<div id="edit_polls_questions_<%= poll_question.id %>" style="display: none;">
|
||||
<%= render :partial => 'edit_MC', :locals => {:poll_question => poll_question} %>
|
||||
</div>
|
||||
<% end%>
|
||||
<!-- 问题 -->
|
||||
<div id="poll_content">
|
||||
<%#= render :partial => 'edit_MC'%>
|
||||
<% @poll.poll_questions.each do |poll_question|%>
|
||||
<div id="poll_questions_<%= poll_question.id%>">
|
||||
<div id="show_poll_questions_<%= poll_question.id %>">
|
||||
<%= render :partial => 'show_MC', :locals => {:poll_question => poll_question} %>
|
||||
</div>
|
||||
<div id="edit_poll_questions_<%= poll_question.id %>" style="display: none;">
|
||||
<%= render :partial => 'edit_MC', :locals => {:poll_question => poll_question} %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div id="new_poll_question">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ur_buttons">
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
$("#new_poll_question").html("");
|
|
@ -0,0 +1,65 @@
|
|||
function add_MC(){
|
||||
var now = new Date().getTime();
|
||||
$("#poll_content").append("<div id='new_poll_question_" + now + "'>"+
|
||||
"<form accept-charset='UTF-8' action='/poll/2/create_poll_question' class='new_poll_question' data-remote='true' id='new_poll_question' method='post'>"+
|
||||
"<div>" +
|
||||
"<div class='ur_editor radio'>" +
|
||||
"<div class='ur_editor_title'>" +
|
||||
"<label>问题: </label>" +
|
||||
"<input type='hidden' name='question_type' value='1'/>" +
|
||||
"<input class='ur_question_title' type='text' name='poll_questions_title' placeholder='请输入单选题标题'/>" +
|
||||
"<input type='checkbox' name='is_necessary' value='true' checked/>" +
|
||||
"<label>必答</label>" +
|
||||
"</div>" +
|
||||
"<div class='ur_editor_content'>" +
|
||||
"<ul>" +
|
||||
"<li class='ur_item'>" +
|
||||
"<label>选项<span class='ur_index'></span>:</label>" +
|
||||
"<input type='text' name='question_answer[0]' placeholder='新建选项'/>" +
|
||||
"<a class='icon_add' title='向下插入选项' onclick='add_single_answer($(this));'></a>" +
|
||||
"<a class='icon_remove' title='删除' onclick='remove_single_answer($(this))'></a>" +
|
||||
"</li>" +
|
||||
"<div class='cl'></div>" +
|
||||
"<li class='ur_item'>" +
|
||||
"<label>选项<span class='ur_index'></span>:</label>" +
|
||||
"<input type='text' name='question_answer[1]' placeholder='新建选项'/>" +
|
||||
"<a class='icon_add' title='向下插入选项' onclick='add_single_answer($(this));'></a>" +
|
||||
"<a class='icon_remove' title='删除' onclick='remove_single_answer($(this))'></a>" +
|
||||
"</li>" +
|
||||
"<div class='cl'></div>" +
|
||||
"<li class='ur_item'>" +
|
||||
"<label>选项<span class='ur_index'></span>:</label>" +
|
||||
"<input type='text' name='question_answer[2]' placeholder='新建选项'/>" +
|
||||
"<a class='icon_add' title='向下插入选项' onclick='add_single_answer($(this));'></a>" +
|
||||
"<a class='icon_remove' title='删除' onclick='remove_single_answer($(this))'></a>" +
|
||||
"</li>" +
|
||||
"<div class='cl'></div>" +
|
||||
"</ul>" +
|
||||
"</div>" +
|
||||
"<div class='ur_editor_footer'>" +
|
||||
"<a class='btn btn_dark btn_submit' data-button='ok' onclick='$(this).parent().parent().parent().parent().submit();'>确定</a>" +
|
||||
"<a class='btn btn_light btn_cancel' data-button='cancel' onclick='$("+ '"#new_poll_question_' + now + '"' +").remove();'>取消</a>" +
|
||||
"</div>" +
|
||||
"<div class='cl'></div>" +
|
||||
"</div>" +
|
||||
"</div>" +
|
||||
"</form>" +
|
||||
"</div>");
|
||||
}
|
||||
function add_MCQ(){$("#poll_content").append("<%= escape_javascript(render :partial => 'new_MCQ') %>");}
|
||||
function add_single(){$("#poll_content").append("<%= escape_javascript(render :partial => 'new_single') %>");}
|
||||
function add_mulit(){$("#poll_content").append("<%= escape_javascript(render :partial => 'new_mulit') %>");}
|
||||
//问卷头
|
||||
function pollsCancel(){$("#polls_head_edit").hide();$("#polls_head_show").show();}
|
||||
function pollsEdit(){$("#polls_head_edit").show();$("#polls_head_show").hide();}
|
||||
//单选题
|
||||
function add_single_answer(doc)
|
||||
{
|
||||
doc.parent().after("<li class='ur_item'><label>选项<span class='ur_index'></span>:</label><input type='text' name='question_answer["+new Date().getTime()+"]' placeholder='新建选项'/>" +
|
||||
"<a class='icon_add' title='向下插入选项' onclick='add_single_answer($(this));'></a><a class='icon_remove' title='删除' onclick='remove_single_answer($(this))'></a>"+
|
||||
"</li><div class='cl'></div>");
|
||||
}
|
||||
function remove_single_answer(doc)
|
||||
{
|
||||
if(doc.parent().siblings("li").length == 0){doc.parent().parent().parent().parent().parent().parent().remove();}else{doc.parent().remove();}
|
||||
}
|
Loading…
Reference in New Issue