socialforge/app/views/attachments/_batch_setting.html.erb

124 lines
4.9 KiB
Plaintext

<script src="/javascripts/jquery.datetimepicker.js" type="text/javascript"></script>
<div id="muban_popup_box" style="width:550px;">
<div class="muban_popup_top">
<h3 class="fl">资源发布批量设置</h3>
<a href="javascript:void(0);" class="muban_icons_close fr" onclick="$('#datetimepicker_mask_batch').datetimepicker('destroy');"></a>
<div class="cl"></div>
</div>
<div class="muban_popup_con clear mt20 ml20 mr20">
<%= form_tag(resource_batch_setting_attachments_path(:course_id => @course), :id => 'batch_setting_form', :method => 'post') do %>
<input name="choose_ids" type="hidden" value="" id="choose_resource_ids">
<input type="hidden" name="all_check" value="0">
<input type="hidden" name="is_delete" value="0">
<div style="border-bottom: 1px solid #eeeeee;">
<div id="source_list">
<%= render :partial => "attachments/batch_setting_resources" %>
</div>
</div>
<ul class="ul-align">
<li class="clear mt10">
<label class="fl">延期发布:&nbsp;</label>
<div class="calendar_div fl mt4">
<input type="text" name="publish_time" id="datetimepicker_mask_batch" placeholder="发布时间(可选)" style="width: 130px;" class="InputBox fl calendar_input" readonly="readonly">
</div>
<a href="javascript:void(0)" id="reset_time_batch" class="fl sy_btn_grey ml10" style="display: none;" onclick="reset_publish_time_batch();">清空</a>
<div class="cl"></div>
<span class="c_red f12" style="margin-top: 4px;" id="publish_time_notice_batch"></span>
</li>
<li class="clear">
<label class="fl">公开:&nbsp;</label>
<span>
<input type="checkbox" id="set_public" name="is_public" class="fl mt10 mr5" style="height: 20px;"/>
<label for="set_public">选中后所有用户可见,否则仅课堂成员可见</label>
</span>
</li>
</ul>
<p class="clear mt5">
<a href="javascript:void(0);" onclick="submit_course_resource_batch();" class="sy_btn_blue fr mr10">保&nbsp;&nbsp;存</a>
<a href="javascript:void(0);" onclick="$('#datetimepicker_mask_batch').datetimepicker('destroy'); hideModal();" class="sy_btn_grey fr mr10">取&nbsp;&nbsp;消</a>
</p>
<% end %>
</div>
</div>
<script>
$(function(){
$('#datetimepicker_mask_batch').datetimepicker({
allowBlank:true,
lang:'ch',
format:'Y-m-d H:i',
formatTime:'H:i',
formatDate:'Y-m-d',
validateOnBlur:false,
onSelectDate:function() {
$("#reset_time_batch").show();
},
onSelectTime:function() {
$("#reset_time_batch").show();
}
});
$("#source_list").on('change', "input[name='attachments[]']", function(){
var choose_ids = $("#choose_resource_ids").val() == "" ? [] : $("#choose_resource_ids").val().split(",");
if($(this).is(':checked')){
choose_ids.push($(this).val());
} else{
$("input[name='all_check']").val(0);
$("input[name='check_all']").attr('checked', false);
choose_ids.splice($.inArray($(this).val(),choose_ids),1);
}
if(choose_ids.length != 0){
$("#choose_resource_ids").val(choose_ids.join(","));
} else{
$("#choose_resource_ids").val('');
}
});
});
function regex_publish_time_batch()
{
var myDate = new Date();
if($.trim($("#datetimepicker_mask_batch").val()) == "")
{
return true;
} else{
var publish_time = Date.parse($("#datetimepicker_mask_batch").val());
if(Date.parse(formate_time(myDate)) > publish_time)
{
$("#publish_time_notice_batch").text("发布时间不能小于当前时间");
return false;
}
else
{
$("#publish_time_notice_batch").text("");
return true;
}
}
}
function submit_course_resource_batch()
{
if($("input[name='attachments[]']:checked").length == 0){
$("#atta_check_notice_batch").show();
} else{
if(regex_publish_time_batch()) {
$('#batch_setting_form').submit();
hideModal();
}
}
}
function reset_publish_time_batch(){
$("#datetimepicker_mask_batch").val('');
$("#reset_time_batch").hide();
}
function delete_resources(){
$("input[name='is_delete']").val(1);
if($("input[name='attachments[]']:checked").length == 0){
$("#atta_check_notice_batch").show();
} else{
$("#atta_check_notice_batch").hide();
$('#batch_setting_form').submit();
hideModal();
}
}
</script>