PluginProbe
SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent / 3.5.4
SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent v3.5.4
3.5.4 3.5.3 3.5.2 3.5.1 3.4.9 3.5.0 3.4.8 3.4.7 trunk 2.3.1 3.3.6 3.3.7 3.3.8 3.3.9 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6
← All changes | asset/js/admin.js +370 -62 3.3.7 → 3.5.4 View file →
@@ -1428,67 +1428,8 @@
1428 1428 });
1429 1429 }
1430 1430
1431 1431 /**
1432 - * Get appearence agent collision settigns
1433 - */
1434 -function wpsc_get_ap_agent_collision() {
1435 - supportcandy.current_tab = "agent-collision";
1436 - jQuery(".wpsc-setting-tab-container button").removeClass("active");
1437 - jQuery(
1438 - ".wpsc-setting-tab-container button." + supportcandy.current_tab
1439 - ).addClass("active");
1440 -
1441 - window.history.replaceState(
1442 - {},
1443 - null,
1444 - "admin.php?page=wpsc-settings&section=" +
1445 - supportcandy.current_section +
1446 - "&tab=" +
1447 - supportcandy.current_tab
1448 - );
1449 - jQuery(".wpsc-setting-section-body").html(supportcandy.loader_html);
1450 -
1451 - wpsc_scroll_top();
1452 - var data = { action: "wpsc_get_ap_agent_collision" };
1453 - jQuery.post(supportcandy.ajax_url, data, function (response) {
1454 - jQuery(".wpsc-setting-section-body").html(response);
1455 - wpsc_reset_responsive_style();
1456 - });
1457 -}
1458 -
1459 -/**
1460 - * Set appearence agent collision settings
1461 - */
1462 -function wpsc_set_ap_agent_collision(el) {
1463 - var form = jQuery(".wpsc-frm-ap-agent-collision")[0];
1464 - var dataform = new FormData(form);
1465 - jQuery(el).text(supportcandy.translations.please_wait);
1466 - jQuery
1467 - .ajax({
1468 - url: supportcandy.ajax_url,
1469 - type: "POST",
1470 - data: dataform,
1471 - processData: false,
1472 - contentType: false,
1473 - })
1474 - .done(function (res) {
1475 - wpsc_get_ap_agent_collision();
1476 - });
1477 -}
1478 -
1479 -/**
1480 - * Reset appearence agent collision settings
1481 - */
1482 -function wpsc_reset_ap_agent_collision(el, nonce) {
1483 - jQuery(el).text(supportcandy.translations.please_wait);
1484 - var data = { action: "wpsc_reset_ap_agent_collision", _ajax_nonce: nonce };
1485 - jQuery.post(supportcandy.ajax_url, data, function (res) {
1486 - wpsc_get_ap_agent_collision();
1487 - });
1488 -}
1489 -
1490 -/**
1491 1432 * Set add new category
1492 1433 */
1493 1434 function wpsc_set_add_category(el) {
1494 1435 var form = jQuery(".wpsc-frm-add-category")[0];
@@ -2634,8 +2575,44 @@
2634 2575 });
2635 2576 }
2636 2577
2637 2578 /**
2579 + * Toggle enable/disable status of a single default filter.
2580 + * Note: the currently active default filter can't be disabled - if the
2581 + * server refuses the disable, it sends back is_enable: 1 and we resync
2582 + * the checkbox/row to reflect that.
2583 + */
2584 +function wpsc_toggle_atl_default_filter_status(el, slug, nonce) {
2585 + var checkbox = jQuery(el);
2586 + var is_enable = checkbox.is(":checked") ? 1 : 0;
2587 + var filter = checkbox.closest(".wpsc-setting-card");
2588 +
2589 + var data = {
2590 + action: "wpsc_toggle_atl_default_filter_status",
2591 + slug,
2592 + is_enable,
2593 + _ajax_nonce: nonce,
2594 + };
2595 + jQuery.post(supportcandy.ajax_url, data, function (response) {
2596 + var saved_enable = response.data.is_enable;
2597 + checkbox.prop("checked", !!saved_enable);
2598 + filter.attr(
2599 + "style",
2600 + saved_enable ? "" : "background-color:#eec7ca;color:#dc2222"
2601 + );
2602 + var total = jQuery(".wpsc-toggle-atl-default-filter").length;
2603 + var checked = jQuery(".wpsc-toggle-atl-default-filter:checked").length;
2604 + jQuery(".wpsc-toggle-all-atl-default-filters").prop(
2605 + "checked",
2606 + total > 0 && total === checked
2607 + );
2608 + }).fail(function () {
2609 + // Revert checkbox on failure.
2610 + checkbox.prop("checked", !is_enable);
2611 + });
2612 +}
2613 +
2614 +/**
2638 2615 * Get customer ticket list items
2639 2616 */
2640 2617 function wpsc_get_customer_tl_items() {
2641 2618 supportcandy.current_tab = "list-items";
@@ -2831,8 +2808,38 @@
2831 2808 });
2832 2809 }
2833 2810
2834 2811 /**
2812 + * Toggle enable/disable status of a single default filter.
2813 + * Note: the currently active default filter can't be disabled - if the
2814 + * server refuses the disable, it sends back is_enable: 1 and we resync
2815 + * the checkbox/row to reflect that.
2816 + */
2817 +function wpsc_toggle_ctl_default_filter_status(el, slug, nonce) {
2818 + var checkbox = jQuery(el);
2819 + var is_enable = checkbox.is(":checked") ? 1 : 0;
2820 + var filter = checkbox.closest(".wpsc-setting-card");
2821 +
2822 + var data = {
2823 + action: "wpsc_toggle_ctl_default_filter_status",
2824 + slug,
2825 + is_enable,
2826 + _ajax_nonce: nonce,
2827 + };
2828 + jQuery.post(supportcandy.ajax_url, data, function (response) {
2829 + var saved_enable = response.data.is_enable;
2830 + checkbox.prop("checked", !!saved_enable);
2831 + filter.attr(
2832 + "style",
2833 + saved_enable ? "" : "background-color:#eec7ca;color:#dc2222"
2834 + );
2835 + }).fail(function () {
2836 + // Revert checkbox on failure.
2837 + checkbox.prop("checked", !is_enable);
2838 + });
2839 +}
2840 +
2841 +/**
2835 2842 * Set add new customer list items
2836 2843 */
2837 2844 function wpsc_set_add_customer_tl_item(el) {
2838 2845 var form = jQuery(".frm-add-customer-tl-items")[0];
@@ -3171,12 +3178,12 @@
3171 3178
3172 3179 /**
3173 3180 * Reset email notification general settings
3174 3181 */
3175 -function wpsc_reset_en_general(el) {
3182 +function wpsc_reset_en_general(el, nonce) {
3176 3183 jQuery(".wpsc-modal-footer button").attr("disabled", true);
3177 3184 jQuery(el).text(supportcandy.translations.please_wait);
3178 - var data = { action: "wpsc_reset_en_general" };
3185 + var data = { action: "wpsc_reset_en_general", _ajax_nonce: nonce };
3179 3186 jQuery.post(supportcandy.ajax_url, data, function (response) {
3180 3187 wpsc_get_en_general_setting();
3181 3188 });
3182 3189 }
@@ -3599,8 +3606,116 @@
3599 3606 });
3600 3607 }
3601 3608
3602 3609 /**
3610 + * Toggle enable/disable status of a single ticket widget
3611 + */
3612 +function wpsc_toggle_ticket_widget_status(el, slug, nonce) {
3613 + var checkbox = jQuery(el);
3614 + var is_enable = checkbox.is(":checked") ? 1 : 0;
3615 + var widget = checkbox.closest(".wpsc-setting-card");
3616 +
3617 + var data = {
3618 + action: "wpsc_toggle_ticket_widget_status",
3619 + slug,
3620 + is_enable,
3621 + _ajax_nonce: nonce,
3622 + };
3623 + jQuery.post(supportcandy.ajax_url, data, function () {
3624 + widget.attr(
3625 + "style",
3626 + is_enable ? "" : "background-color:#eec7ca;color:#dc2222"
3627 + );
3628 + var total = jQuery(".wpsc-toggle-ticket-widget").length;
3629 + var checked = jQuery(".wpsc-toggle-ticket-widget:checked").length;
3630 + jQuery(".wpsc-toggle-all-ticket-widgets").prop(
3631 + "checked",
3632 + total > 0 && total === checked
3633 + );
3634 + }).fail(function () {
3635 + // Revert checkbox on failure.
3636 + checkbox.prop("checked", !is_enable);
3637 + });
3638 +}
3639 +
3640 +/**
3641 + * Enable or disable all ticket widgets at once
3642 + */
3643 +function wpsc_toggle_all_ticket_widgets(el, nonce) {
3644 + var checkbox = jQuery(el);
3645 + var is_enable = checkbox.is(":checked") ? 1 : 0;
3646 +
3647 + var data = {
3648 + action: "wpsc_toggle_all_ticket_widgets_status",
3649 + is_enable,
3650 + _ajax_nonce: nonce,
3651 + };
3652 + jQuery.post(supportcandy.ajax_url, data, function () {
3653 + jQuery(".wpsc-toggle-ticket-widget").prop("checked", !!is_enable);
3654 + jQuery(".wpsc-setting-card").attr(
3655 + "style",
3656 + is_enable ? "" : "background-color:#eec7ca;color:#dc2222"
3657 + );
3658 + }).fail(function () {
3659 + // Revert checkbox on failure.
3660 + checkbox.prop("checked", !is_enable);
3661 + });
3662 +}
3663 +
3664 +/**
3665 + * Get edit Agent Collision widget
3666 + */
3667 +function wpsc_get_tw_agent_collision() {
3668 +
3669 + wpsc_show_modal();
3670 + var data = { action: 'wpsc_get_tw_agent_collision' };
3671 + jQuery.post(
3672 + supportcandy.ajax_url,
3673 + data,
3674 + function (response) {
3675 +
3676 + // Set to modal.
3677 + jQuery( '.wpsc-modal-header' ).text( response.title );
3678 + jQuery( '.wpsc-modal-body' ).html( response.body );
3679 + jQuery( '.wpsc-modal-footer' ).html( response.footer );
3680 + // Display modal.
3681 + wpsc_show_modal_inner_container();
3682 + }
3683 + );
3684 +}
3685 +
3686 +/**
3687 + * Set edit Agent Collision widget
3688 + */
3689 +function wpsc_set_tw_agent_collision(el) {
3690 + var form = jQuery( '.wpsc-frm-edit-ac' )[0];
3691 + var dataform = new FormData( form );
3692 +
3693 + if (dataform.get( 'label' ).trim() == '') {
3694 + alert( supportcandy.translations.req_fields_missing );
3695 + return;
3696 + }
3697 +
3698 + jQuery( '.wpsc-modal-footer button' ).attr( 'disabled', true );
3699 + jQuery( el ).text( supportcandy.translations.please_wait );
3700 +
3701 + jQuery.ajax(
3702 + {
3703 + url: supportcandy.ajax_url,
3704 + type: 'POST',
3705 + data: dataform,
3706 + processData: false,
3707 + contentType: false
3708 + }
3709 + ).done(
3710 + function (res) {
3711 + wpsc_close_modal();
3712 + wpsc_get_ticket_widget();
3713 + }
3714 + );
3715 +}
3716 +
3717 +/**
3603 3718 * Ticket widget status
3604 3719 */
3605 3720 function wpsc_get_tw_ticket_status() {
3606 3721 wpsc_show_modal();
@@ -5728,8 +5843,63 @@
5728 5843 });
5729 5844 }
5730 5845
5731 5846 /**
5847 + * Toggle enable/disable status of a single dashboard card
5848 + */
5849 +function wpsc_toggle_dashboard_card_status(el, slug, nonce) {
5850 + var checkbox = jQuery(el);
5851 + var is_enable = checkbox.is(":checked") ? 1 : 0;
5852 + var card = checkbox.closest(".wpsc-setting-card");
5853 +
5854 + var data = {
5855 + action: "wpsc_toggle_dashboard_card_status",
5856 + slug,
5857 + is_enable,
5858 + _ajax_nonce: nonce,
5859 + };
5860 + jQuery.post(supportcandy.ajax_url, data, function () {
5861 + card.attr(
5862 + "style",
5863 + is_enable ? "" : "background-color:#eec7ca;color:#dc2222"
5864 + );
5865 + var total = jQuery(".wpsc-toggle-dashboard-card").length;
5866 + var checked = jQuery(".wpsc-toggle-dashboard-card:checked").length;
5867 + jQuery(".wpsc-toggle-all-dashboard-cards").prop(
5868 + "checked",
5869 + total > 0 && total === checked
5870 + );
5871 + }).fail(function () {
5872 + // Revert checkbox on failure.
5873 + checkbox.prop("checked", !is_enable);
5874 + });
5875 +}
5876 +
5877 +/**
5878 + * Enable or disable all dashboard cards at once
5879 + */
5880 +function wpsc_toggle_all_dashboard_cards(el, nonce) {
5881 + var checkbox = jQuery(el);
5882 + var is_enable = checkbox.is(":checked") ? 1 : 0;
5883 +
5884 + var data = {
5885 + action: "wpsc_toggle_all_dashboard_cards_status",
5886 + is_enable,
5887 + _ajax_nonce: nonce,
5888 + };
5889 + jQuery.post(supportcandy.ajax_url, data, function () {
5890 + jQuery(".wpsc-toggle-dashboard-card").prop("checked", !!is_enable);
5891 + jQuery(".wpsc-setting-card").attr(
5892 + "style",
5893 + is_enable ? "" : "background-color:#eec7ca;color:#dc2222"
5894 + );
5895 + }).fail(function () {
5896 + // Revert checkbox on failure.
5897 + checkbox.prop("checked", !is_enable);
5898 + });
5899 +}
5900 +
5901 +/**
5732 5902 * Get dashboard widgets settings
5733 5903 */
5734 5904 function wpsc_get_dashboard_widgets_settings() {
5735 5905 supportcandy.current_tab = "dashboard-widgets";
@@ -5896,8 +6066,63 @@
5896 6066 });
5897 6067 }
5898 6068
5899 6069 /**
6070 + * Toggle enable/disable status of a single dashboard widget
6071 + */
6072 +function wpsc_toggle_dashboard_widget_status(el, slug, nonce) {
6073 + var checkbox = jQuery(el);
6074 + var is_enable = checkbox.is(":checked") ? 1 : 0;
6075 + var widget = checkbox.closest(".wpsc-setting-card");
6076 +
6077 + var data = {
6078 + action: "wpsc_toggle_dashboard_widget_status",
6079 + slug,
6080 + is_enable,
6081 + _ajax_nonce: nonce,
6082 + };
6083 + jQuery.post(supportcandy.ajax_url, data, function () {
6084 + widget.attr(
6085 + "style",
6086 + is_enable ? "" : "background-color:#eec7ca;color:#dc2222"
6087 + );
6088 + var total = jQuery(".wpsc-toggle-dashboard-widget").length;
6089 + var checked = jQuery(".wpsc-toggle-dashboard-widget:checked").length;
6090 + jQuery(".wpsc-toggle-all-dashboard-widgets").prop(
6091 + "checked",
6092 + total > 0 && total === checked
6093 + );
6094 + }).fail(function () {
6095 + // Revert checkbox on failure.
6096 + checkbox.prop("checked", !is_enable);
6097 + });
6098 +}
6099 +
6100 +/**
6101 + * Enable or disable all dashboard widgets at once
6102 + */
6103 +function wpsc_toggle_all_dashboard_widgets(el, nonce) {
6104 + var checkbox = jQuery(el);
6105 + var is_enable = checkbox.is(":checked") ? 1 : 0;
6106 +
6107 + var data = {
6108 + action: "wpsc_toggle_all_dashboard_widgets_status",
6109 + is_enable,
6110 + _ajax_nonce: nonce,
6111 + };
6112 + jQuery.post(supportcandy.ajax_url, data, function () {
6113 + jQuery(".wpsc-toggle-dashboard-widget").prop("checked", !!is_enable);
6114 + jQuery(".wpsc-setting-card").attr(
6115 + "style",
6116 + is_enable ? "" : "background-color:#eec7ca;color:#dc2222"
6117 + );
6118 + }).fail(function () {
6119 + // Revert checkbox on failure.
6120 + checkbox.prop("checked", !is_enable);
6121 + });
6122 +}
6123 +
6124 +/**
5900 6125 * Edit bashboard widget
5901 6126 */
5902 6127 function wpsc_get_edit_dashboard_card_widget(type, slug, nonce) {
5903 6128 wpsc_show_modal();
@@ -5952,9 +6177,9 @@
5952 6177 function wpsc_get_ap_dashboard() {
5953 6178 supportcandy.current_tab = "dashboard";
5954 6179 jQuery(".wpsc-setting-tab-container button").removeClass("active");
5955 6180 jQuery(
5956 - ".wpsc-setting-tab-container button." + supportcandy.current_tabs
6181 + ".wpsc-setting-tab-container button." + supportcandy.current_tab
5957 6182 ).addClass("active");
5958 6183
5959 6184 window.history.replaceState(
5960 6185 {},
@@ -6043,4 +6268,87 @@
6043 6268 function (response) {
6044 6269 }
6045 6270 );
6046 6271 }
6272 +
6273 +/**
6274 + * Get ticket list
6275 + */
6276 +function wpsc_get_archive_ticket_list(is_humbargar = false) {
6277 +
6278 + supportcandy.current_section = "archive-ticket-list";
6279 + if (is_humbargar) {
6280 + wpsc_toggle_humbargar();
6281 + }
6282 +
6283 + var id = supportcandy.current_archived_ticket_id;
6284 + if (id) {
6285 + delete supportcandy.current_archived_ticket_id;
6286 + wpsc_get_individual_archive_ticket(id);
6287 + return;
6288 + }
6289 +
6290 + // set flag to differenciate between ticket list and individual ticket.
6291 + supportcandy.ticketListIsIndividual = false;
6292 +
6293 + jQuery(".wpsc-tickets-nav, .wpsc-humbargar-menu-item").removeClass("active");
6294 + jQuery(
6295 + ".wpsc-tickets-nav.archive-ticket-list, .wpsc-humbargar-menu-item.archive-ticket-list"
6296 + ).addClass("active");
6297 + jQuery(".wpsc-humbargar-title").html(
6298 + supportcandy.humbargar_titles.archived_ticket_list
6299 + );
6300 +
6301 + window.history.replaceState(
6302 + {},
6303 + null,
6304 + "admin.php?page=wpsc-archive-tickets&section=archive-ticket-list"
6305 + );
6306 + jQuery(".wpsc-body").html(supportcandy.loader_html);
6307 +
6308 + wpsc_scroll_top();
6309 +
6310 + var data = {
6311 + action: "wpsc_get_archive_ticket_list",
6312 + _ajax_nonce: supportcandy.nonce,
6313 + is_frontend: supportcandy.is_frontend,
6314 + };
6315 + jQuery.post(supportcandy.ajax_url, data, function (response) {
6316 + jQuery(".wpsc-body").html(response);
6317 + wpsc_reset_responsive_style();
6318 + });
6319 + wpsc_delete_auto_draft();
6320 +}
6321 +
6322 +/**
6323 + * Get individual ticket
6324 + */
6325 +function wpsc_get_individual_archive_ticket(id) {
6326 + jQuery(".wpsc-tickets-nav, .wpsc-humbargar-menu-item").removeClass("active");
6327 + jQuery(
6328 + ".wpsc-tickets-nav.archive-ticket-list, .wpsc-humbargar-menu-item.archive-ticket-list"
6329 + ).addClass("active");
6330 + jQuery(".wpsc-humbargar-title").html(
6331 + supportcandy.humbargar_titles.archived_ticket_list
6332 + );
6333 +
6334 + window.history.replaceState(
6335 + {},
6336 + null,
6337 + "admin.php?page=wpsc-archive-tickets&section=archive-ticket-list&id=" + id
6338 + );
6339 + jQuery(".wpsc-body").html(supportcandy.loader_html);
6340 +
6341 + wpsc_scroll_top();
6342 +
6343 + // set flag to differenciate between ticket list and individual ticket.
6344 + supportcandy.ticketListIsIndividual = true;
6345 +
6346 + var data = {
6347 + action: "wpsc_get_individual_archive_ticket",
6348 + ticket_id: id,
6349 + };
6350 + jQuery.post(supportcandy.ajax_url, data, function (response) {
6351 + jQuery(".wpsc-body").html(response);
6352 + wpsc_reset_responsive_style();
6353 + });
6354 +}