$(".ibox-content table a,.ibox-title a,.row a").click(function(event) { var url = $(this).attr("href"); if ($(this).attr("target") == "dialog") { event.preventDefault(); var dialogWidth = $(this).attr("width"); var dialogHeight = $(this).attr("height"); var title = $(this).html(); parent.layer.open({ type : 2, title : title, closeBtn : 1, shadeClose : false, scrollbar : false, area : [ dialogWidth, dialogHeight ], content : url, skin : 'popup', btn : [ "确定", "取消" ], yes : function(indexIframe, layero) { // var iframeWin = // parent.window[layero.find('iframe')[0]['name']]; // //得到iframe页的窗口对象,执行iframe页的方法:iframeWin.method(); var body = parent.layer.getChildFrame('body', indexIframe); body.find('form').submit(); } }); }else if($(this).attr("target")=="ajaxTodo"){ event.preventDefault(); var msg = $(this).attr("title"); var title = $(this).html(); parent.layer.confirm(msg, { title:title, skin : 'popup', btn: ['确定','取消'] //按钮 }, function(){ parent.layer.closeAll(); $.ajax({ type : 'POST', url : url, dataType : "json", //async :false, success : function(json) { dialogAjaxDone(json); },error: function(xhr, ajaxOptions, thrownError){ ajaxError(xhr, ajaxOptions, thrownError); } }); }, function(){ parent.layer.closeAll(); }); }else if( $(this).attr("target")=='alert'){ event.preventDefault(); var title = $(this).html(); $.ajax({ type : 'POST', url : url, dataType : "json", //async :false, success : function(json) { parent.layer.alert(json.message,{title:title,skin : 'popup'}); },error: function(xhr, ajaxOptions, thrownError){ ajaxError(xhr, ajaxOptions, thrownError); } }); }else if( $(this).attr("target")=='tips'){ event.preventDefault(); var title = $(this).html(); var objId = this.id; objId = "#"+objId; $.ajax({ type : 'POST', url : url, dataType : "json", //async :false, success : function(json) { layer.tips(json.message, objId, {tips: [4, '#78BA32']}); },error: function(xhr, ajaxOptions, thrownError){ ajaxError(xhr, ajaxOptions, thrownError); } }); } }); function ajaxSuccess(json){ parent.layer.closeAll(); toastr.clear(); toastr.success(json.message); } function validateCallback(form) { var $form = $(form); if (!$form.valid()) { return false; } $.ajax({ type:form.method||'POST', url:$form.attr("action"), data:$form.serializeArray(), dataType:"json", //async :false, success : function(json) { dialogAjaxDone(json); },error: function(xhr, ajaxOptions, thrownError){ ajaxError(xhr, ajaxOptions, thrownError); } }); return false; } function dialogAjaxDone(json) { if (json.statusCode == "200") { parent.reloadPage(json.navTabId); if ("closeCurrent" == json.callbackType) { parent.ajaxDone(json); closeCurrent(); }else ajaxDone(json); }else ajaxDone(json); } function ajaxError(xhr, ajaxOptions, thrownError) { toastr.options = { "closeButton" : true, "debug" : false, "progressBar" : false, "positionClass" : "toast-top-center", "onclick" : null, "showEasing" : "swing", "showMethod" : "fadeIn" } toastr.clear(); toastr.error("Http status: " + xhr.status + " " + xhr.statusText + "\najaxOptions: " + ajaxOptions + "\nthrownError:" + thrownError + "\n" + xhr.responseText); } function ajaxDone(json) { if (json.statusCode == "300") { toastr.options = { "closeButton" : true, "debug" : false, "progressBar" : false, "positionClass" : "toast-top-center", "onclick" : null, "showEasing" : "swing", "showMethod" : "fadeIn" } toastr.clear(); toastr.error(json.message); } else if (json.statusCode == "200") { toastr.options = { "closeButton" : false, "debug" : false, "progressBar" : false, "positionClass" : "toast-top-center", "onclick" : null, "showDuration" : "400", "hideDuration" : "1000", "timeOut" : "7000", "extendedTimeOut" : "2000", "showEasing" : "swing", "hideEasing" : "linear", "showMethod" : "fadeIn", "hideMethod" : "fadeOut" } toastr.clear(); toastr.success(json.message); } } function closeCurrent(){ parent.layer.closeAll(); }; function reloadPage(navTabId){ $("#"+navTabId).trigger("click"); } function toastrError(message){ toastr.options = { "closeButton" : true, "debug" : false, "progressBar" : false, "positionClass" : "toast-top-center", "onclick" : null, "showEasing" : "swing", "showMethod" : "fadeIn" } toastr.clear(); toastr.error(message); } function toastrSuccess(message){ toastr.options = { "closeButton" : false, "debug" : false, "progressBar" : false, "positionClass" : "toast-top-center", "onclick" : null, "showDuration" : "400", "hideDuration" : "1000", "timeOut" : "7000", "extendedTimeOut" : "2000", "showEasing" : "swing", "hideEasing" : "linear", "showMethod" : "fadeIn", "hideMethod" : "fadeOut" } toastr.clear(); toastr.success(message); }