1 line
11 KiB
JavaScript
1 line
11 KiB
JavaScript
|
|
jQuery(document).ready(function(t){let e=t("#cdp-purl").val(),i=[];function o(){t("#cdp_notice_error_modal").find(".cdp_notice_content").animate({top:"-20px"},300),t("#cdp_notice_error_modal").fadeOut(300)}function n(){setTimeout(()=>{t.post(ajaxurl,{action:"cdp_action_handling",token:"cdp",nonce:cdpGlobalJS.ajaxNonce,f:"i_saw_this_noti",noti_token:token}).done(()=>{delete i[i.findIndex(t=>t===token)]}).fail(()=>{n(token)})},500*i.length)}function c(){let e=t(".cdp-dd-item").length,i=t(".cdp-dd-d").length,o=t(".cdp-dd-ud").length;i<=0?(t(".cdp-done-notis, .cdp-done-notis").addClass("cdp-noti-hide"),t(".cdp-done-hr").hide()):(t(".cdp-done-notis, .cdp-done-notis").removeClass("cdp-noti-hide"),t(".cdp-done-hr").show()),o<=0?(t(".cdp-undone-notis, .cdp-undone-notis").addClass("cdp-noti-hide"),t(".cdp-undone-hr").hide()):(t(".cdp-undone-notis, .cdp-undone-notis").removeClass("cdp-noti-hide"),t(".cdp-undone-hr").show()),e<=0?t(".cdp-admin-bar-noti").addClass("cdp-noti-hide"):t(".cdp-admin-bar-noti").removeClass("cdp-noti-hide"),t(".cdp-notis-counter").text(t(".cdp-bnew-notis").length)}if(t("body").on("click",".cdp-notification .cdp-times-button",t.cdpRemoveNotifiaction),t("body").on("mouseover",".cdp-bnew-notis",function(){let e=parseInt(t(".cdp-notis-counter").text()),o=t(".cdp-bnew-notis").length,c=t(this).attr("data-token");t(this).hasClass("cdp-bnew-notis")&&e-1>=0&&(t(this).removeClass("cdp-bnew-notis"),t(".cdp-notis-counter").text(e-1));(e>0||o>0)&&(i.push(c),setTimeout(()=>{t.post(ajaxurl,{action:"cdp_action_handling",token:"cdp",nonce:cdpGlobalJS.ajaxNonce,f:"i_saw_this_noti",noti_token:c}).done(()=>{delete i[i.findIndex(t=>t===c)]}).fail(()=>{n()})},500*i.length))}),t("body").on("mouseover",".cdp-dropdown-left",function(){if(!t(this).hasClass("cdptipstered")){let e=t(t(this).parents(".cdp-dd-d")[0]),i=e.attr("data-fdate");if(fdate=e.attr("data-ftext"),!fdate)return;i=i?`<br>${i}`:"",t(this).cdptipster({delay:30,animationDuration:250,debug:!1,timer:30,delayTouch:[50,100],interactive:!0,distance:6,side:"left",contentAsHTML:!0,maxWidth:340,trigger:"custom",triggerOpen:{mouseenter:!0,touchstart:!0},triggerClose:{mouseleave:!0,click:!0,tap:!0},content:`${fdate}${i}`,theme:["cdptipster-noir","cdptipster-noir-customized","cdp-center"],repositionOnScroll:!0,functionReady:function(){setTimeout(()=>{t.tooltipReposition()},150)}}),t(this).cdptipster("open")}}),t("body").on("click",".cdp-dropdown-clear-all-notis",function(e){e.preventDefault(),t.post(ajaxurl,{action:"cdp_action_handling",token:"cdp",nonce:cdpGlobalJS.ajaxNonce,f:"clear_crons"}).done(e=>{if(t.isJsonString(e)&&(e=t.cdpParse(e)),"success"==e.status){let e=t(".cdp-dd-item");e.hide(300),setTimeout(()=>{e.remove(),c()},300),t.cdpNotification("success",cdpGlobalJS.strTasksCleared)}else"fail"==e.status?t.cdpNotification(e.type,e.msg):t.cdpNotification("error",cdpGlobalJS.strTasksUpdateIssue)}).fail(e=>{t.cdpNotification("error",cdpGlobalJS.strTasksUpdateIssue2)})}),t("body").on("click",".cdp-noti-hide-btn",function(){let e=t(this).parents(".ab-item").attr("data-token");t.post(ajaxurl,{action:"cdp_action_handling",token:"cdp",nonce:cdpGlobalJS.ajaxNonce,f:"try_to_hide_the_tasks",task:e}).done(e=>{t.isJsonString(e)&&(e=t.cdpParse(e)),"success"==e.status?(t(this).parents(".ab-item").hide(300),setTimeout(()=>{t(this).parents(".ab-item").remove(),c()},300),t.cdpNotification("success",cdpGlobalJS.strTaskHide)):"fail"==e.status?t.cdpNotification(e.type,e.msg):t.cdpNotification("error",cdpGlobalJS.strTaskHideIssue)}).fail(()=>{t.cdpNotification("error",cdpGlobalJS.strTaskHideIssue2)})}),t("body").on("click",".cdp-noti-kill-btn",function(){let e=t(this).parents(".ab-item").attr("data-token");t.post(ajaxurl,{action:"cdp_action_handling",token:"cdp",nonce:cdpGlobalJS.ajaxNonce,f:"try_to_kill_the_tasks",task:e}).done(e=>{t.isJsonString(e)&&(e=t.cdpParse(e)),"success"==e.status?(t(this).parents(".ab-item").hide(300),setTimeout(()=>{t(this).parents(".ab-item").remove(),c()},300),t.cdpNotification("success",cdpGlobalJS.strTaskKill)):"fail"==e.status?t.cdpNotification(e.type,e.msg):t.c
|