trustieplus/app/views/courses/settings/_moduels.html.erb

104 lines
4.7 KiB
Plaintext

<ul>
<form action="<%= update_position_course_path() %>" method="post" id="update_position" data-remote="true" >
<% @modules.each_with_index do |m, index| %>
<li class="clearfix mb10">
<p class="clearfix mb10">
<span class="fl edu-txt-w280 font-bd">
<input class="magic-checkbox" type="checkbox" value="<%= m.module_type %>" <%= m.hidden == 0 ? "checked" : "" %> name="message[]" id="message_<%= index %>" >
<label for="message_<%= index %>" ><%= switch_to_chinese m.module_type %></label>
</span>
<span class="fl mt3">
<% if m.position > 1 %>
<a href="javascript:void(0);" onclick="up_position(this);" class="fl ml30 up">上移</a>
<% end %>
<% if m.position < @modules.count %>
<a href="javascript:void(0);" onclick="down_position(this);" class="fl ml30 down">下移</a>
<% end %>
<% if m.module_type == "boards" %>
<a href="javascript:void(0);" class="color-green ml30" onclick="add_subtopic('<%= @course.id %>', '<%= @course_board.id %>');">添加子栏目</a>
<% end %>
</span>
</p>
<% if m.module_type == "boards" %>
<div id="setting_boards_list">
<%= render :partial => 'courses/settings/boards_list' %>
</div>
<% end %>
<input value="<%= m.module_type %>" name="position[]" class="undis" />
</li>
<% end %>
</form>
</ul>
<a href="javascript:void(0);" class="task-btn task-btn-orange fl" onclick="$('#update_position').submit();" >保存</a>
<a href="javascript:void(0);" class="task-btn fl ml10" >取消</a>
<div class="cl"></div>
<script>
/* ---------------------- 上移 ------------------------- */
function up_position(ev){
var nPos = $(ev).parent().parent().parent();
var nBroP = nPos.prev();
var nBroN = nPos.next();
if( nBroP.prev().size() == 0 ){
nBroP.find(".down").before("<a href='javascript:void(0);' onclick='up_position(this);' class='fl ml30 up'>上移</a>");
$(ev).remove();
}
if( nBroN.size() == 0){
$(ev).after("<a href='javascript:void(0);' onclick='down_position(this);' class='fl ml30 down'>下移</a>");
nBroP.find('.down').remove();
}
nBroP.before(nPos);
};
/* ---------------------- 下移 -------------------------- */
function down_position(ev){
var nPos = $(ev).parent().parent().parent();
var nBroN = nPos.next();
var nBroP = nPos.prev();
if( nBroN.next().size() == 0 ){
nBroN.find(".up").after("<a href='javascript:void(0);' onclick='down_position(this);' class='fl ml30 down'>下移</a>");
$(ev).remove();
}
if( nBroP.size() == 0 ){
$(ev).before("<a href='javascript:void(0);' onclick='up_position(this);' class='fl ml30 up'>上移</a>");
nBroN.find(".up").remove();
}
nBroN.after(nPos);
};
/* ------------------------ 添加子栏目 ---------------------------- */
function add_subtopic(course_id, board_id){
var htmlvalue = '<div class="task-popup newclass" style="width:450px;">' +
'<div class=" task-popup-title clearfix task-popup-bggrey">' +
'<h3 class="fl ">添加子栏目</h3>' +
'<a href="javascript:void()" onclick="hideModal();"><i class="fa fa-times-circle font-18 link-color-grey fr mt5"></i></a>' +
'</div>'+
'<div class="task_popup_con clearfix">' +
'<div class="pt20 clearfix mb20" style="width:400px;">'+
'<label class="panel-form-label label fl">名称&nbsp;&nbsp;&nbsp;&nbsp;</label>' +
'<input type="text" style="width:300px;" class="task task-height-40 panel-box-sizing fl color-grey" id="subtopic_name">' +
'<div class="cl"></div>' +
'</div>' +
'<a href="javascript:void(0);" onclick="create_subtopic();" class="task-btn task-btn-orange fr">确定</a>' +
'<a href="javascript:void(0);" onclick="hideModal();" class="task-btn fr mr10">取消</a>'+
'</div>'+
'</div>'
pop_box_new(htmlvalue, 400, 140);
};
function create_subtopic(){
var name = $("#subtopic_name").val();
if(name.trim() != ""){
$.ajax({
type: 'post',
url: "/courses/" + "<%= @course.id %>" + "/boards?board_id=" + "<%= @course_board.id %>",
data: { name: name },
dataType: 'script'
});
}
};
</script>