115 lines
5.3 KiB
Plaintext
115 lines
5.3 KiB
Plaintext
<% board = @course.boards.where("parent_id is NULL").first %>
|
|
<div class="w730 mt10" id="org_subfield_list">
|
|
<ul class="orgListRow borderBottomNone orgListBg">
|
|
<li class="w270 fb fl"><span class="ml15">名称</span></li>
|
|
<li class="w140 fb fl">状态</li>
|
|
<li class="w170 fb fl">类型</li>
|
|
<li class="w150 fb fl"><span class="mr15 fr">操作</span></li>
|
|
<div class="cl"></div>
|
|
</ul>
|
|
<ul class="orgListRow">
|
|
<li class="w270 fl"> <span class="ml15">班级讨论区</span> </li>
|
|
<li class="w140 fl">默认</li>
|
|
<li class="w170 fl">帖子</li>
|
|
<li class="w150 fl"> <a href="javascript:void(0)" class="link-blue fr mr15" id="addSubMenu">添加子栏目</a> </li>
|
|
<div class="cl"></div>
|
|
<% count = board.children.count %>
|
|
<% board.children.reorder("position asc").each_with_index do |board, i|%>
|
|
<ul class="orgSubList" style="border-top: 1px solid rgb(228, 228, 228);">
|
|
<li class="<%= i == count - 1 ? 'orgSubTree2' : 'orgSubTree' %>"></li>
|
|
<li class="w210 mr10 fl">
|
|
<div id="board_sub_show_<%= board.id %>" class="w210 hidden" title="<%=board.name %>"><%=board.name %></div>
|
|
<div id="board_sub_edit_<%= board.id %>" style="display:none;">
|
|
<input type="text" name="name" onblur="update_sub_board_name('#board_sub_show_<%= board.id %>','#board_sub_edit_<%= board.id %>','<%= board.id %>','<%= @course.id %>',$(this).val());" value="<%= board.name %>" style="width:140px;"/>
|
|
</div>
|
|
</li>
|
|
<li class="w140 fl">新增</li>
|
|
<li class="w170 fl">帖子</li>
|
|
<li class="w150 fl">
|
|
<a href="javascript:void(0);" class="linkGrey fr ml5 mr15" onclick="edit('#board_sub_show_<%= board.id %>','#board_sub_edit_<%= board.id %>');">编辑</a>
|
|
<%= link_to('删除', {:controller => 'boards', :action => 'destroy', :id => board.id, :course_id => @course.id},:remote => true, :method => 'delete', :confirm => l(:text_are_you_sure), :class => "linkGrey fr ml5 mr5", :title => l(:button_delete)) %>
|
|
<% if i < count - 1 %>
|
|
<%= link_to('下移', {:controller => 'boards', :action => 'update_position', :id => board.id, :course_id => @course.id, :opr => 'down'},:remote => true, :method => 'post', :class => "linkGrey fr ml5 mr5", :title => '下移') %>
|
|
<% end %>
|
|
<% unless i == 0 %>
|
|
<%= link_to('上移', {:controller => 'boards', :action => 'update_position', :id => board.id, :course_id => @course.id, :opr => 'up'},:remote => true, :method => 'post', :class => "linkGrey fr ml5 mr5", :title => '上移') %>
|
|
<% end %>
|
|
</li>
|
|
<div class="cl"></div>
|
|
</ul>
|
|
<% end %>
|
|
</ul>
|
|
</div>
|
|
<!--新增二级栏目-->
|
|
<div class="mt10 fl orgListBg w730 undis" id="subMenuContent">
|
|
<%= form_tag url_for(:controller => 'boards', :action => 'create', :course_id => @course.id, :board_id => board.id), :id=> 'add_board_form_subboard',:remote => true do %>
|
|
<div class="ml15 mt10">
|
|
<span class="fontGrey3 mb5 mr10">新增子栏目名称 :</span>
|
|
<input id="subfield_name" name="name" placeholder="请输入子栏目名称" maxlength="30" class="orgAddSearch mb10" type="text">
|
|
<span id="new_notice" class="undis ml10">名称不能为空</span>
|
|
</div>
|
|
<div class="mb10">
|
|
<span class="fontGrey3 ml50 mr15 fl">栏目类型 :</span>
|
|
<input class="mr5" id="orgMng" value="Post" name="field_type" checked="checked" type="radio">
|
|
<label for="orgMng">帖子</label>
|
|
</div>
|
|
<div class="mb10">
|
|
<a href="javascript:void(0);" class="grey_btn_cir fr c_white mr15 ml15" id="subMenuCancel">取消</a>
|
|
<a href="javascript:void(0);" class="blue_btn_cir fr c_white" id="subMenuSubmit">确定</a>
|
|
<div class="cl"></div>
|
|
</div>
|
|
</form>
|
|
<% end %>
|
|
</div>
|
|
<!--over-->
|
|
|
|
<script>
|
|
$(function(){
|
|
$("#subMenuSubmit").one('click', function(){
|
|
sub_board_submit();
|
|
});
|
|
});
|
|
function sub_board_submit(){
|
|
if ($("#subfield_name").val().trim() != ""){
|
|
$("#new_notice").hide();
|
|
$("#add_board_form_subboard").submit();
|
|
} else {
|
|
$("#new_notice").show();
|
|
$("#subMenuSubmit").one('click', function(){
|
|
sub_board_submit();
|
|
});
|
|
}
|
|
}
|
|
$("#addSubMenu").click(function(){
|
|
$("#subMenuContent").toggle();
|
|
});
|
|
$("#subMenuCancel").click(function(){
|
|
$("#subMenuContent").hide();
|
|
});
|
|
|
|
function update_sub_board_name(show_id, edit_id, field_id, domain_id, input_value) {
|
|
if (input_value.trim() != "" && $(show_id).html().trim() != input_value.trim()) {
|
|
if (confirm('确定修改为' + input_value + "?"))
|
|
$.ajax({
|
|
url: "/boards/" + field_id + "/update_name?course_id=" + domain_id + "&name=" + input_value,
|
|
type: 'put'
|
|
});
|
|
else{
|
|
$(edit_id).children("input").val($(show_id).html().trim());
|
|
}
|
|
}
|
|
$(show_id).show();
|
|
$(edit_id).hide();
|
|
}
|
|
|
|
function edit(show_id, edit_id) {
|
|
$(show_id).toggle();
|
|
$(edit_id).toggle();
|
|
$(edit_id).find('input').focus();
|
|
$(edit_id).find('input').on('keypress', function (e) {
|
|
if (e.keyCode == 13) {
|
|
this.blur();
|
|
}
|
|
})
|
|
}
|
|
</script> |