// JavaScript Document sfadmin = { def_data_tag : 'tbody', def_select_input : '.select_item', init: function() { $('.select_rows').click(function () { var tableid = $(this).data(sfadmin.def_data_tag); $('#'+tableid).find(sfadmin.def_select_input).attr('checked', this.checked); }); sfadmin.ajax.error(); }, getSelected : function(tableid){ if(tableid == "") { dom = $(sfadmin.def_select_input + ':checked'); }else{ dom = $(sfadmin.def_select_input + ':checked', '#'+tableid); } datas = new Array(); dom.each(function(index, element) { datas.push($(this).val()); }); return datas; }, ajax : { error : function(){ $(document).ajaxError(function(event, request, settings) { sfadmin.Alert("请求中发生错误"); }) } }, Alert : function(content){ $.colorbox({width:'50%',html:'

'+content+'

'}); } } 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(''); }, 'complete':function(){ btn.attr('onclick',func); btn.html(html); } }); } function Alert(content){ $.colorbox({innerWidth:'40%',html:'
'+ content +'
'}); }