var BuzzyMail={init:function(){!function(){var t=this;$('.mailbox-messages input[type="checkbox"]').iCheck({checkboxClass:"icheckbox_flat-blue",radioClass:"iradio_flat-blue"}),$('.cho input[type="checkbox"]').iCheck({checkboxClass:"icheckbox_flat-blue",radioClass:"iradio_flat-blue"}).on("ifChecked",function(t){$(".mailbox-messages input[type='checkbox']").iCheck("check"),$(".fa",this).removeClass("fa-square-o").addClass("fa-check-square-o")}).on("ifUnchecked",function(t){$(".mailbox-messages input[type='checkbox']").iCheck("uncheck"),$(".fa",this).removeClass("fa-check-square-o").addClass("fa-square-o")}),$(".mailbox-star").click(function(e){var r=$(this).find(".fa"),a=$(this).attr("data-id");$.ajax({type:"POST",url:"/admin/mailbox/dostar",data:"mail="+a+"&_token="+$("#requesttoken").val(),success:function(t){var e=t.status,a=t.errors;"Error"==e&&swal({type:"warning",title:"Error",text:a,timer:2e3,showConfirmButton:!1}),"stared"==t?r.addClass("text-yellow"):r.removeClass("text-yellow")},error:t.error_message})}),$(".mailbox-important").click(function(e){var r=$(this).find(".fa"),a=$(this).attr("data-id");$.ajax({type:"POST",url:"/admin/mailbox/doimportant",data:"mail="+a+"&_token="+$("#requesttoken").val(),success:function(t){var e=t.status,a=t.errors;"Error"==e&&swal({type:"warning",title:"Error",text:a,timer:2e3,showConfirmButton:!1}),"important"==t?r.addClass("text-red"):r.removeClass("text-red")},error:t.error_message})}),$(".addcat").on("click",function(e){$(this);var r=$(this).attr("data-type");swal({title:"Add Section",type:"input",showCancelButton:!0,closeOnConfirm:!1,animation:"slide-from-top",inputPlaceholder:"Folder Name"},function(e){return!1!==e&&(""===e?(swal.showInputError("Type something"),!1):void $.ajax({type:"POST",dataType:"json",url:"/admin/mailbox/addcat",data:"name="+e+"&type="+r+"&_token="+$("#requesttoken").val(),success:function(t){var e=t.type,r=t.message,a=t.status,s=t.errors;"Error"==a?swal({type:"warning",title:"Error",text:s,timer:2e3,showConfirmButton:!1}):"error"==e?swal({type:"warning",title:"Error",text:r,timer:2e3,showConfirmButton:!1}):"success"==e&&(swal({type:"success",title:"Success",timer:2e3,showConfirmButton:!1}),location.href=location.href)},error:t.error_message}))})}),$(".doaction").on("click",function(){var e=$(this).attr("data-action"),r=$(this).attr("data-type"),a=$("#contacts").serialize(),s=$(this).parents(".box").find(".overlay");s.removeClass("hide"),$.ajax({type:"POST",dataType:"json",url:"/admin/mailbox/doaction",data:a+"&typo="+e+"&type="+r,success:function(t){var e=t.type,r=t.message,a=(t.url,t.status),o=t.errors;"Error"==a?swal({type:"warning",title:"Error",text:o,timer:2e3,showConfirmButton:!1}):"error"==e?swal({type:"warning",title:"Error",text:r,timer:2e3,showConfirmButton:!1}):"success"==e&&(swal({type:"success",title:"Success",timer:2e3,showConfirmButton:!1}),location.href=location.href),setTimeout(function(){s.addClass("hide")},1e3)},error:t.error_message})}),$(".sendmail").on("click",function(){var e=$(this).attr("data-type"),r=$(this).closest("form"),a=r.attr("action"),s=r.serialize(),o=$(".box").find(".overlay");o.removeClass("hide"),$.ajax({type:"POST",dataType:"json",url:a,data:s+"&type="+e,success:function(t){var e=t.type,r=t.message,a=t.url,s=t.status,i=t.errors;"Error"==s?swal({type:"warning",title:"Error",text:i,timer:2e3,showConfirmButton:!1}):"error"==e?swal({type:"warning",title:"Error",text:r,timer:2e3,showConfirmButton:!1}):"success"==e&&(swal({type:"success",title:"Success",timer:2e3,showConfirmButton:!1}),location.href=a),setTimeout(function(){o.addClass("hide")},1e3)},error:t.error_message})})}()}};BuzzyMail.init();
