125 lines
2.9 KiB
JavaScript
125 lines
2.9 KiB
JavaScript
// JavaScript Document
|
|
$(document).ready(function() {
|
|
gebo_select_row.init();
|
|
gebo_delete_rows.simple();
|
|
});
|
|
|
|
gebo_select_row = {
|
|
init: function() {
|
|
$('.select_rows').click(function () {
|
|
var tableid = $(this).data('tableid');
|
|
$('#'+tableid).find('input[name=row_sel]').attr('checked', this.checked);
|
|
});
|
|
}
|
|
};
|
|
|
|
gebo_delete_rows = {
|
|
simple: function() {
|
|
$(".delete_rows_simple").on('click',function (e) {
|
|
e.preventDefault();
|
|
var tableid = $(this).data('tableid');
|
|
if($('input[name=row_sel]:checked', '#'+tableid).length) {
|
|
$.colorbox({
|
|
initialHeight: '0',
|
|
initialWidth: '0',
|
|
href: "#confirm_dialog",
|
|
inline: true,
|
|
opacity: '0.3',
|
|
onComplete: function(){
|
|
$('.confirm_yes').click(function(e){
|
|
e.preventDefault();
|
|
$('input[name=row_sel]:checked', '#'+tableid).each(function(index, element) {
|
|
del($(this).val());
|
|
});
|
|
$('input[name=select_rows]:checked').removeAttr('checked');
|
|
$.colorbox.close();
|
|
});
|
|
$('.confirm_no').click(function(e){
|
|
e.preventDefault();
|
|
$.colorbox.close();
|
|
});
|
|
}
|
|
});
|
|
}
|
|
});
|
|
}
|
|
};
|
|
|
|
var confrimHTML = '<div class=""><div class="modal-header"><h3>是否确定删除?</h3></div>'
|
|
+ '<div class="modal-footer"><a href="javascript:void(0);" class="btn btn-primary confirm_yes">是</a><a href="javascript:void(0);" class="btn confirm_no">否</a></div></div>';
|
|
|
|
function onedel(id)
|
|
{
|
|
if(typeof(info) == "undefined")
|
|
{
|
|
Alert('信息参数设置不正确');
|
|
return false;
|
|
}
|
|
$.colorbox({
|
|
initialHeight: '100',
|
|
initialWidth: '200',
|
|
//href: "#confirm_dialog",
|
|
//inline: true,
|
|
opacity: '0.3',
|
|
onComplete: function(){
|
|
$('.confirm_yes').click(function(e){
|
|
e.preventDefault();
|
|
del(id);
|
|
$.colorbox.close();
|
|
});
|
|
$('.confirm_no').click(function(e){
|
|
e.preventDefault();
|
|
$.colorbox.close();
|
|
});
|
|
},
|
|
html: confrimHTML
|
|
});
|
|
}
|
|
|
|
function del(id){
|
|
if(typeof(info) == "undefined")
|
|
{
|
|
alert('信息参数设置不正确');
|
|
return false;
|
|
}
|
|
btn = $('#'+info.btn_prefix+id);
|
|
func = btn.attr('onclick');
|
|
html = btn.html();
|
|
$.ajax({
|
|
'type':"POST",
|
|
'url': info.url,
|
|
'data': 'id='+id,
|
|
'success':function(data){
|
|
if (typeof(data)=='object')
|
|
{
|
|
if(typeof(data.error) !== 'undefined')
|
|
{
|
|
Alert(data.error);return false;
|
|
}
|
|
if(typeof(data.deleted !== 'undefined'))
|
|
{
|
|
$('#'+info.item_prefix+id).remove();
|
|
}
|
|
}
|
|
else{
|
|
Alert('出现错误,请稍后再试');
|
|
}
|
|
},
|
|
'timeout': 15000,
|
|
'error': function(){
|
|
Alert('处理中出现错误,请刷新页面后重试');
|
|
},
|
|
'beforeSend':function(){
|
|
btn.attr('onclick','');
|
|
btn.html('<img src="/images/ajax-load-small.gif" />');
|
|
},
|
|
'complete':function(){
|
|
btn.attr('onclick',func);
|
|
btn.html(html);
|
|
}
|
|
});
|
|
}
|
|
|
|
function Alert(content){
|
|
$.colorbox({innerWidth:'40%',html:'<div style="line-height:30px;font-size:16px;">'+ content +'</div>'});
|
|
} |