var BuzzyMail=function(){"use strict";return{init:function(){var t;t=function(t){var e=t.responseJSON.errors||"An Unexpected Error Occurred";swal({title:"Error",text:e,type:"error",html:!0,showCancelButton:!1})},$("#compose-textarea").length>0&&$("#compose-textarea").wysihtml5(),$('.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").on("click",(function(e){var r=$(this).find(".fa"),a=$(this).attr("data-id");$.ajax({type:"POST",url:buzzy_base_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})})),$(".mailbox-important").on("click",(function(e){var r=$(this).find(".fa"),a=$(this).attr("data-id");$.ajax({type:"POST",url:buzzy_base_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})})),$(".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:buzzy_base_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,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)},error:t}))}))})),$(".doaction").on("click",(function(){var e=$(this).attr("data-action"),r=$(this).attr("data-type"),a=$("#contacts").serialize(),o=$(this).parents(".box").find(".overlay");o.removeClass("hide"),$.ajax({type:"POST",dataType:"json",url:buzzy_base_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),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),setTimeout((function(){o.addClass("hide")}),1e3)},error:t})})),$(".sendmail").on("click",(function(){var e=$(this).attr("data-type"),r=$(this).closest("form"),a=r.attr("action"),o=r.serialize(),s=$(".box").find(".overlay");s.removeClass("hide"),$.ajax({type:"POST",dataType:"json",url:a,data:o+"&type="+e,success:function(t){var e=t.type,r=t.message,a=t.url,o=t.status,i=t.errors;"Error"==o?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(){s.addClass("hide")}),1e3)},error:t})}))}}}();BuzzyMail.init();
