text: var app=app||{};app.init=function(){$(".select2").select2(),$('input[type="radio"], input[type="checkbox"]').length>0&&$('input[type="radio"], input[type="checkbox"]').iCheck({checkboxClass:"icheckbox_minimal-blue",radioClass:"iradio_minimal-blue"}),$("[data-mask]").inputmask(),$(document).on("shown.bs.tab",'a[data-toggle="tab"]',function(a){$.fn.dataTable.tables({visible:!0,api:!0}).columns.adjust()});var a=$(".table-dynamic-account").DataTable({processing:!0,ajax:base_admin+"/ajax/email",responsive:!0,paging:!0,lengthChange:!0,searching:!0,ordering:!0,info:!0,autoWidth:!0,scrollX:!0,scrollCollapse:!0,columns:[{data:"id"},{data:"smtp_server"},{data:"smtp_port"},{data:"smtp_username"},{data:"smtp_protocol"},{data:"smtp_name"},{data:"default"},{data:"action"}],columnDefs:[{targets:[1],class:"text-ellipsis"},{width:"150px",targets:[3,4,5],class:"text-center"},{width:"100px",targets:[0,2,-2],class:"text-center"}]});$(".table-dynamic-email").DataTable({processing:!0,ajax:base_admin+"/ajax/emailStatus",responsive:!0,paging:!0,lengthChange:!0,searching:!0,ordering:!0,info:!0,autoWidth:!0,scrollX:!0,scrollCollapse:!0,columns:[{data:"id"},{data:"title"},{data:"content"},{data:"group"},{data:"created_at"},{data:"status"},{data:"action"}],columnDefs:[{targets:[1],class:"text-ellipsis"},{width:"150px",targets:[3,4,5],class:"text-center"},{width:"100px",targets:[0],class:"text-center"},{width:"300px",targets:[2]}]});$("#editAccountForm").validator().on("submit",function(b){$("#editAccountBtn").button("loading"),$(".alert").addClass("no-display"),b.isDefaultPrevented()?$("#editAccountBtn").button("reset"):(b.preventDefault(),app.submitForm(a),$("#modal-account-edit").modal("hide"),$("#editAccountBtn").button("reset"))}),app.submitForm=function(a){$.ajax({url:base_admin+"/ajax/email",data:$("#editAccountForm").serialize(),type:"post",success:function(b){"200"==b.code?(a.ajax.reload(null,!0),$("#alert_msg_edit").removeClass("no-display"),$("#editAccountBtn").button("reset"),Lobibox.notify("success",{title:"Thông báo",pauseDelayOnHover:!1,continueDelayOnInactiveTab:!1,icon:!1,sound:!1,msg:"Thay đổi thông tin thành công"}),$("#confirm-delete-modal").modal("hide")):Lobibox.notify("warning",{title:"Thông báo",pauseDelayOnHover:!1,continueDelayOnInactiveTab:!1,icon:!1,sound:!1,msg:"Có lỗi xảy ra"})},error:function(a,b,c){Lobibox.notify("warning",{title:"Thông báo",pauseDelayOnHover:!1,continueDelayOnInactiveTab:!1,icon:!1,sound:!1,msg:"Có lỗi xảy ra"})}})},$(document).on("click",".table-action-delete",function(b){b.preventDefault(),$("#modal-account-edit #id").val($(this).data("id"));$(this).attr("data-lang");app.clearForm("delete");$(this),$(this).parents("table").DataTable();$("#confirm-delete-modal").modal({backdrop:"static",keyboard:!1}).one("click","#confirm-delete",function(b){app.submitForm(a)})}),$("#modal-account-edit").on("blur","#inputEditPassWord",function(){$(this).val()&&($(this).parents(".form-group").next().find("#inputEditrePassWord").prop("required",!0),$("#editAccountForm").validator("update"))}),$(document).on("click",".table-action-edit",function(a){a.preventDefault(),app.clearForm("update"),$("#modal-account-edit #ttlModal").html(" Cập nhật thông tin account"),$("#modal-account-edit .defaultBtn").show();var b=$(this).data("id");$("#modal-account-edit #inputEditSMTP").prop("required",!1),$("#modal-account-edit #inputEditrePassWord").prop("required",!1),$("#modal-account-edit #inputEditPort").prop("required",!1),$("#modal-account-edit #inputEditUserName").prop("required",!1),$("#modal-account-edit #inputEditProtocal").prop("required",!1),$("#modal-account-edit #inputEditSender").prop("required",!1),$("#modal-account-edit").validator("validate"),$("#modal-account-edit #inputEditSMTP").prop("required",!0),$("#modal-account-edit #inputEditPort").prop("required",!0),$("#modal-account-edit #inputEditUserName").prop("required",!0),$("#modal-account-edit #inputEditProtocal").prop("required",!0),$("#modal-account-edit #inputEditSender").prop("required",!0),$("#modal-account-edit").validator("update"),$.ajax({url:base_admin+"/ajax/email?id="+b,type:"get",success:function(a){"200"==a.code?($("#modal-account-edit #id").val(a.data[0].id),$("#modal-account-edit #inputEditSMTP").val(a.data[0].smtp_server),$("#modal-account-edit #inputEditPort").val(a.data[0].smtp_port),$("#modal-account-edit #inputEditUserName").val(a.data[0].smtp_username),$("#modal-account-edit #inputEditProtocal").val(a.data[0].smtp_protocol),$("#modal-account-edit #inputEditSender").val(a.data[0].smtp_name),1==a.data[0].default?$("#modal-account-edit #default").iCheck("check"):$("#modal-account-edit #default").iCheck("uncheck"),$("#modal-account-edit").modal("show")):$("#error-modal").modal("show")},error:function(a,b,c){$("#error_msg").html('<i class="fas fa-exclamation-triangle"></i> '+response.msg).show()}})}),$(document).on("click","#addAccount",function(a){a.preventDefault(),app.clearForm("insert"),$("#modal-account-edit .defaultBtn").hide(),$("#modal-account-edit #ttlModal").html(" Tạo mới account"),$("#modal-account-edit").modal("show")}),$(document).on("click","#editAccountBtn",function(a){a.preventDefault(),$("#editAccountForm").submit()}),$(document).on("click","#SelectAllBtn",function(a){a.preventDefault(),$(".select-email > option").prop("selected","selected"),$(".select-email").trigger("change")}),$(document).on("click","#UnselectAllBtn",function(a){a.preventDefault(),$(".select-email").val(null).trigger("change")})},app.clearForm=function(a){$("#editAccountForm")[0].reset(),$("#modal-account-edit #action").val(a),$("#modal-account-edit #default").iCheck("update")},$(function(){app.init()});