$.fn.espcms_screen=function(options){options=$.extend({url:null,formname:null,isdebug:false,cssname:'.espcms_screen'},options||{});return this.each(function(){$(this).unbind('click').bind('click',function(){var field=$(this).attr('data-field');var value=$(this).attr('data-value');if(!field||value==undefined){return true;}
var url_key=field+'='+value;search_list(url_key,options.formname);$(options.cssname+"[data-field='"+field+"']").removeClass('hover');$(this).addClass('hover');});});};$.fn.batchset=function(options){options=$.extend({url:null,formname:null,isdebug:false,checkbox_name:'select_id'},options||{});return this.each(function(){var field_value=$(this).attr('set-value');var field=$(this).attr('set-field');$(this).unbind('click').bind('click',function(){var select_id_array=new Array();var checkbox_name='[name="'+options.checkbox_name+'"]:checked';$(checkbox_name).each(function(){select_id_array.push($(this).val());});$.ajax({type:"post",url:options.url,global:false,dataType:'json',data:{'select_id':select_id_array,'field_value':field_value,'field':field},beforeSend:function(){parent.espcms_are_loading();},success:function(data){if(options.isdebug){console.log(data);}
parent.$("#espcms_are_loading").dialog("close");if(data.code==='true'){loading(options.formname);parent.$.espcms_sticky(data.message,{'autoclose':2000});}else{parent.$("body").append(data.data);var botton=[{text:espcms_botton_colse,class:"btn btn-danger",click:function(){parent.$(this).dialog("close");}}];parent.espcms_public_dialog(data.domid_name,botton,530);}}});});});};$.fn.batchdel=function(options){options=$.extend({url:null,formname:null,isdebug:false,checkbox_name:'select_id'},options||{});return this.each(function(){$(this).unbind('click').bind('click',function(){var select_id_array=new Array();var checkbox_name='[name="'+options.checkbox_name+'"]:checked';$(checkbox_name).each(function(){select_id_array.push($(this).val());});var dialog_html='<div id="espcms_are_del_dialog" title="'+espcms_dialog_title+'" class="displaynone">'+'<p><span class="espcms_icon_fa espcms_icon_fa-exclamation-circle" style="float:left;margin:0 3px 0px 0;padding-top:4px;"></span>'+espcms_message_del_warning+'</p>'+'</div>';parent.$("body").append(dialog_html);var botton=[{text:espcms_botton_del_ok,class:"btn btn-danger",click:function(){$.ajax({type:"post",url:options.url,global:false,dataType:'json',data:{'select_id':select_id_array},success:function(data){if(options.isdebug){console.log(data);}
if(data.code==='true'){loading(options.formname,data.count);parent.$.espcms_sticky(data.message,{'autoclose':2000});}else{parent.$("body").append(data.data);var botton2=[{text:espcms_botton_colse,class:"btn btn-danger",click:function(){parent.$(this).dialog("close");}}];parent.espcms_public_dialog(data.domid_name,botton2,530);}}});parent.$(this).dialog("close");}},{text:espcms_botton_del_no,class:"btn btn-lightgray",click:function(){parent.$(this).dialog("close");}}];parent.espcms_public_dialog('espcms_are_del_dialog',botton);});});};$.fn.fieldsort=function(options){options=$.extend({formname:'ajax_list',cssname_asc:'espcms_icon_fa-sort-numeric-asc',cssname_desc:'espcms_icon_fa-sort-numeric-desc'},options||{});var sort_rank=$('#sort_rank').val();var sort_key=$('#sort_key').val();var key_field_name='th[sort-field="'+sort_key+'"]';var sort_icon='<span class="espcms_icon_fa sort_icon" aria-hidden="true">';$('.sort_field').each(function(){$(this).append(sort_icon);});if(sort_rank==='DESC'){$(key_field_name).children('.sort_icon').addClass(options.cssname_desc);}else if(sort_rank==='ASC'){$(key_field_name).children('.sort_icon').addClass(options.cssname_asc);}
return this.each(function(){$(this).unbind('click').bind('click',function(){var sort_field=$(this).attr('sort-field');var sort_field_array=new Array();$('.sort_field').each(function(){if(sort_field!==$(this).attr('sort-field')){sort_field_array.push($(this).attr('sort-field'));}});sort_rank=$('#sort_rank').val();if(sort_field===sort_key){if(sort_rank==='DESC'){$(this).children('.sort_icon').removeClass(options.cssname_desc).addClass(options.cssname_asc);$('#sort_rank').val('ASC');}else if(sort_rank==='ASC'){$(this).children('.sort_icon').removeClass(options.cssname_asc).addClass(options.cssname_desc);$('#sort_rank').val('DESC');}
loading(options.formname);}else{$('#sort_key').val(sort_field);for(var i=0;i<=sort_field_array.length;i++){$('th[sort-field="'+sort_field_array[i]+'"]').children('.sort_icon').removeClass(options.cssname_asc).removeClass(options.cssname_desc);}
if(sort_rank==='DESC'){$(this).children('.sort_icon').removeClass(options.cssname_desc).addClass(options.cssname_asc);$('#sort_rank').val('ASC');}else if(sort_rank==='ASC'){$(this).children('.sort_icon').removeClass(options.cssname_asc).addClass(options.cssname_desc);$('#sort_rank').val('DESC');}
loading(options.formname);}});});};$.fn.batset_dialog=function(options){options=$.extend({url:null,dialogname:null,formname:null,width:'780px',height:'450px',checkbox_name:'select_id',call:'',bgclose:true},options||{});return this.each(function(){$(this).unbind('click').bind('click',function(){var select_id_array=new Array();var checkbox_name='[name="'+options.checkbox_name+'"]:checked';$(checkbox_name).each(function(){select_id_array.push($(this).val());});if(select_id_array.length<=0){$.espcms_sticky(espcms_message_selectno_warning,{'autoclose':2500});return false;}
var queryString='select_id='+encodeURI(select_id_array);var loadingurl=espcms_combine_url(queryString,options.url);espcms_dialog(options.dialogname,'url',loadingurl,options.width,options.height,'dialog_set',options.call,options.bgclose);});});};$.fn.espcms_check_link=function(options){options=$.extend({url:null,dialogname:null,formname:null,width:'780px',height:'450px',checkbox_name:'select_id',call:'',bgclose:true},options||{});return this.each(function(){$(this).unbind('click').bind('click',function(){var check_url=$(this).attr('check_url');if(check_url){$.ajax({type:"get",url:check_url,global:false,async:false,success:function(data){if(data==0){returnValue=showMsg(obj,validation_warning,true);}else{returnValue=showMsg(obj,validation_warning,false);}}});}});});};