$(function(){ if ($('.table-checkable')) { var table = $('.table-checkable'); table.find('.group-checkable').change(function () { var set = jquery(this).attr("data-set"); var checked = jquery(this).is(":checked"); jquery(set).each(function () { if (checked) { $(this).prop("checked", true); $(this).parents('tr').addclass("active"); } else { $(this).prop("checked", false); $(this).parents('tr').removeclass("active"); } }); }); } }); function geturlpathname() { var url = document.location.tostring(); var arrurl = url.split("//"); var start = arrurl[1].indexof("/"); var relurl = arrurl[1].substring(start); if(relurl.indexof("?") != -1){ relurl = relurl.split("?")[0]; } return relurl; } function confirmurl(url,message) { if (typeof pc_hash == 'string') url += (url.indexof('?') > -1 ? '&': '?') + 'pc_hash=' + pc_hash; dialog.confirm(message,function() { redirect(url); }); } function redirect(url) { location.href = url; } function topinyin(name, from, url) { var val = $("#" + from).val(); if ($("#" + name).val()) { return false } $.get(url+'&name='+val+'&rand='+math.random(), function(data){ $('#'+name).val(data); }); } //滚动条 $(function(){ $(":text").addclass('input-text'); }) /** * 全选checkbox,注意:标识checkbox id固定为为check_box * @param string name 列表check名称,如 uid[] */ function selectall(name) { if ($("#check_box").attr("checked")=='checked') { $("input[name='"+name+"']").each(function() { $(this).attr("checked","checked"); $(this).parents('tr').addclass("active"); }); } else { $("input[name='"+name+"']").each(function() { $(this).removeattr("checked"); $(this).parents('tr').removeclass("active"); }); } } function openwinx(url,name,w,h) { if(!w) w='100%'; if(!h) h='100%'; if (w=='100%' && h=='100%') { var drag = false; } else { var drag = true; } if (typeof pc_hash == 'string') url += (url.indexof('?') > -1 ? '&': '?') + 'pc_hash=' + pc_hash; var diag = new dialog({ id:'content_id', title:name, url:geturlpathname()+url, width:w, height:h, modal:true, draggable:drag }); diag.canceltext = '关闭(x)'; diag.oncancel=function() { $dw.close(); }; diag.show(); } function contentopen(url,name,w,h) { if(!w) w='100%'; if(!h) h='100%'; if (w=='100%' && h=='100%') { var drag = false; } else { var drag = true; } if (typeof pc_hash == 'string') url += (url.indexof('?') > -1 ? '&': '?') + 'pc_hash=' + pc_hash; var diag = new dialog({ id:'content_id', title:name, url:geturlpathname()+url, width:w, height:h, modal:true, draggable:drag }); diag.addbutton('dosubmit','保存后自动关闭',function(){ //var body = diag.innerframe.contentwindow.document; //$(body).find('#myform').serialize() var form = $dw.$('#dosubmit'); if(form.length > 0) { form.click(); } else { if (parent.right) { parent.right.location.reload(); } else { parent.location.reload(); } diag.close(); } return false; },0,1); diag.oktext = '保存并继续发表'; diag.onok = function(){ var form = $dw.$('#dosubmit_continue'); if(form.length > 0) { form.click(); } else { if (parent.right) { parent.right.location.reload(); } else { parent.location.reload(); } diag.close(); } return false; }; diag.canceltext = '关闭(x)'; diag.oncancel=function(){ var form = $dw.$('#close'); if(form.length > 0) { form.click(); } else { if (parent.right) { parent.right.location.reload(); } else { parent.location.reload(); } $dw.close(); } return false; }; diag.onclose=function(){ if (parent.right) { parent.right.location.reload(); } else { parent.location.reload(); } $dw.close(); }; diag.show(); } //弹出对话框 function artdialog(id,url,title,w,h) { if (typeof pc_hash == 'string') url += (url.indexof('?') > -1 ? '&': '?') + 'pc_hash=' + pc_hash; if(!w) w=700; if(!h) h=500; if (w=='100%' && h=='100%') { var drag = false; } else { var drag = true; } var diag = new dialog({ id:id, title:title, url:geturlpathname()+url, width:w, height:h, modal:true, draggable:drag }); diag.onok = function(){ var form = $dw.$('#dosubmit'); form.click(); return false; }; diag.oncancel=function() { $dw.close(); }; diag.show(); } //弹出对话框 function omnipotent(id,linkurl,title,close_type,w,h) { if (typeof pc_hash == 'string') linkurl += (linkurl.indexof('?') > -1 ? '&': '?') + 'pc_hash=' + pc_hash; if(!w) w=700; if(!h) h=500; if (w=='100%' && h=='100%') { var drag = false; } else { var drag = true; } var diag = new dialog({ id:id, title:title, url:geturlpathname()+linkurl, width:w, height:h, modal:true, draggable:drag }); diag.onok = function(){ if(close_type==1) { diag.close(); } else { var form = $dw.$('#dosubmit'); form.click(); } return false; }; diag.oncancel=function() { $dw.close(); }; diag.show(); } function dr_bfb_submit(title, myform, url) { layer.load(2, {shade:[ .3, "#fff" ],time:1000}); $.ajax({ type:"post", datatype:"json", url:url, data:$("#"+myform).serialize(), success:function(json) { layer.closeall("loading"); if (json.code == 1) { layer.open({ type:2, title:title, scrollbar:false, resize:true, maxmin:true, shade:0, area:[ "80%", "80%" ], success:function(layero, index) { var body = layer.getchildframe("body", index); var json = $(body).html(); if (json.indexof('"code":0') > 0 && json.length < 150) { var obj = json.parse(json); layer.closeall("loading"); dr_tips(0, obj.msg); } }, content:json.data.url }); } else { dr_tips(0, json.msg, 90000); } return false; }, error:function(httprequest, ajaxoptions, thrownerror) { dr_ajax_admin_alert_error(httprequest, ajaxoptions, thrownerror); } }); } function dr_tips(code, msg, time) { if (!time || time == "undefined") { time = 3000; } else { time = time * 1000; } var is_tip = 0; if (time < 0) { is_tip = 1; } else if (code == 0 && msg.length > 15) { is_tip = 1; } if (is_tip) { if (code == 0) { layer.alert(msg, { shade: 0, title: "", icon: 2 }) } else { layer.alert(msg, { shade: 0, title: "", icon: 1 }) } } else { var tip = ''; //var theme = 'teal'; if (code >= 1) { tip = ''; //theme = 'lime'; } else if (code == 0) { tip = ''; //theme = 'ruby'; } layer.msg(tip+'  '+msg, {time: time}); } } function dr_ajax_admin_alert_error(httprequest, ajaxoptions, thrownerror) { layer.closeall("loading"); var msg = httprequest.responsetext; if (!msg) { dr_tips(0, "系统错误"); } else { layer.open({ type:1, title:"系统错误", fix:true, shadeclose:true, shade:0, area:[ "50%", "50%" ], content:'
' + msg + "
" }); } }