Version Description
Some editing bugs were fixed
Download this release
Release Info
Developer | premiocommit |
Plugin | Floating Chat Widget: Contact Chat Icons, Telegram Chat, Line, WeChat, Email, SMS, Call Button – Chaty |
Version | 2.8.1 |
Comparing to | |
See all releases |
Code changes from version 2.8 to 2.8.1
- admin/assets/js/cht-scripts.js +24 -15
- admin/assets/js/cht-scripts.min.js +1 -1
- admin/assets/js/spectrum.js +2408 -0
- admin/assets/js/spectrum.min.js +1 -1
- cht-icons.php +3 -2
- includes/class-frontend.php +14 -9
- includes/class-review-box.php +1 -1
- js/cht-front-script.js +18 -10
- js/cht-front-script.min.js +1 -1
- readme.txt +4 -1
- views/admin/channels-section.php +1 -1
admin/assets/js/cht-scripts.js
CHANGED
@@ -1246,7 +1246,8 @@ function check_for_number_chaty(phoneNumber, validationFor) {
|
|
1246 |
color = "#" + color;
|
1247 |
}
|
1248 |
}
|
1249 |
-
jQuery('.preview .page svg circle').css({fill: color});
|
|
|
1250 |
jQuery('#chaty-social-close ellipse').attr("fill", color);
|
1251 |
}
|
1252 |
|
@@ -1584,6 +1585,11 @@ var pageOptionContent = "";
|
|
1584 |
var totalDateAndTimeOptions = 0;
|
1585 |
var dateAndTimeOptionContent = "";
|
1586 |
jQuery(document).ready(function () {
|
|
|
|
|
|
|
|
|
|
|
1587 |
totalPageOptions = parseInt(jQuery(".chaty-page-option").length);
|
1588 |
pageOptionContent = jQuery(".chaty-page-options-html").html();
|
1589 |
jQuery(".chaty-page-options-html").remove();
|
@@ -1657,7 +1663,7 @@ jQuery(document).ready(function () {
|
|
1657 |
showInput: true,
|
1658 |
showAlpha: true,
|
1659 |
move: function (color) {
|
1660 |
-
jQuery(this).val(color.
|
1661 |
jQuery("#cta-box span").css("color", jQuery("#cht_cta_text_color").val());
|
1662 |
jQuery("#cta-box span").css("background", jQuery("#cht_cta_bg_color").val());
|
1663 |
jQuery("#custom-css").html("<style>.preview .page .chaty-widget .icon:before {border-color: transparent "+jQuery('#cht_cta_bg_color').val()+" transparent transparent } .preview .page .chaty-widget[style*='left: auto;'] .icon:before {border-color: transparent transparent transparent "+jQuery('#cht_cta_bg_color').val()+"}</style>");
|
@@ -1682,18 +1688,20 @@ jQuery(document).ready(function () {
|
|
1682 |
e.stopPropagation();
|
1683 |
});
|
1684 |
|
1685 |
-
|
1686 |
-
|
1687 |
-
|
1688 |
-
|
1689 |
-
|
1690 |
-
|
1691 |
-
|
1692 |
-
|
1693 |
-
|
1694 |
-
|
1695 |
-
|
1696 |
-
|
|
|
|
|
1697 |
|
1698 |
jQuery(document).ready(function(){
|
1699 |
set_wp_editor();
|
@@ -2028,7 +2036,8 @@ function setChtIcon(icon, colorSelf) {
|
|
2028 |
}
|
2029 |
if (colorSelf) {
|
2030 |
var color = jQuery('.color-picker-custom input').val() ? jQuery('.color-picker-custom input').val() : jQuery('.color-picker-radio input:checked').val();
|
2031 |
-
jQuery('.preview .page svg circle').css({fill: color});
|
|
|
2032 |
jQuery('#chaty-social-close ellipse').attr("fill", color);
|
2033 |
}
|
2034 |
jQuery('.js-widget-i:checked').trigger("change");
|
1246 |
color = "#" + color;
|
1247 |
}
|
1248 |
}
|
1249 |
+
jQuery('.preview .page #iconWidget svg circle').css({fill: color});
|
1250 |
+
jQuery('.preview .page .chaty-close-icon ellipse').css({fill: color});
|
1251 |
jQuery('#chaty-social-close ellipse').attr("fill", color);
|
1252 |
}
|
1253 |
|
1585 |
var totalDateAndTimeOptions = 0;
|
1586 |
var dateAndTimeOptionContent = "";
|
1587 |
jQuery(document).ready(function () {
|
1588 |
+
var isChatyInMobile = false; //initiate as false
|
1589 |
+
if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent)
|
1590 |
+
|| /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(navigator.userAgent.substr(0, 4))) {
|
1591 |
+
isChatyInMobile = true;
|
1592 |
+
}
|
1593 |
totalPageOptions = parseInt(jQuery(".chaty-page-option").length);
|
1594 |
pageOptionContent = jQuery(".chaty-page-options-html").html();
|
1595 |
jQuery(".chaty-page-options-html").remove();
|
1663 |
showInput: true,
|
1664 |
showAlpha: true,
|
1665 |
move: function (color) {
|
1666 |
+
jQuery(this).val(color.toRgbString());
|
1667 |
jQuery("#cta-box span").css("color", jQuery("#cht_cta_text_color").val());
|
1668 |
jQuery("#cta-box span").css("background", jQuery("#cht_cta_bg_color").val());
|
1669 |
jQuery("#custom-css").html("<style>.preview .page .chaty-widget .icon:before {border-color: transparent "+jQuery('#cht_cta_bg_color').val()+" transparent transparent } .preview .page .chaty-widget[style*='left: auto;'] .icon:before {border-color: transparent transparent transparent "+jQuery('#cht_cta_bg_color').val()+"}</style>");
|
1688 |
e.stopPropagation();
|
1689 |
});
|
1690 |
|
1691 |
+
if(!isChatyInMobile) {
|
1692 |
+
jQuery("#channels-selected-list").sortable({
|
1693 |
+
placeholder: "ui-chaty-state-hl",
|
1694 |
+
items: "li:not(#chaty-social-close)",
|
1695 |
+
stop: function () {
|
1696 |
+
set_wp_editor();
|
1697 |
+
},
|
1698 |
+
update: function (event, ui) {
|
1699 |
+
set_social_channel_order();
|
1700 |
+
change_custom_preview();
|
1701 |
+
set_wp_editor();
|
1702 |
+
}
|
1703 |
+
});
|
1704 |
+
}
|
1705 |
|
1706 |
jQuery(document).ready(function(){
|
1707 |
set_wp_editor();
|
2036 |
}
|
2037 |
if (colorSelf) {
|
2038 |
var color = jQuery('.color-picker-custom input').val() ? jQuery('.color-picker-custom input').val() : jQuery('.color-picker-radio input:checked').val();
|
2039 |
+
jQuery('.preview .page #iconWidget svg circle').css({fill: color});
|
2040 |
+
jQuery('.preview .page .chaty-close-icon ellipse').css({fill: color});
|
2041 |
jQuery('#chaty-social-close ellipse').attr("fill", color);
|
2042 |
}
|
2043 |
jQuery('.js-widget-i:checked').trigger("change");
|
admin/assets/js/cht-scripts.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
function check_for_number_chaty(e,t){return!(""==e||("+"==e[0]&&(e=e.substr(1,e.length)),"Phone"==t&&"*"==e[0]&&(e=e.substr(1,e.length)),!isNaN(e)))}function check_for_preview_pos(){if(jQuery(".chaty-setting-form").length)if(jQuery(window).width()>1179){var e=parseInt(jQuery(".chaty-setting-form").offset().top);jQuery(".btn-save-sticky, .chaty-sticky-buttons").css("top",e+58),jQuery(".preview").css("top",e+18),jQuery(".btn-help").css("top",e+58+145),jQuery("a.remove-chaty-widget-sticky").css("top",e+58+145+119)}else jQuery(".btn-save-sticky, .chaty-sticky-buttons").attr("style",""),jQuery(".preview").attr("style",""),jQuery(".btn-help").attr("style",""),jQuery("a.remove-chaty-widget-sticky").attr("style","");if(jQuery("#scroll-to-item").length&&jQuery("#admin-preview").length&&((e=jQuery("body").hasClass("has-premio-box")?jQuery("#scroll-to-item").offset().top-jQuery(window).scrollTop()-625:jQuery("#scroll-to-item").offset().top-jQuery(window).scrollTop()-485)<0?(e=Math.abs(e),jQuery("#admin-preview").css("margin-top",-1*e+"px")):jQuery("#admin-preview").css("margin-top","0")),jQuery(window).height()<=1180){var t=285;jQuery(window).width()<=600&&(t=310),jQuery(".chaty-sticky-buttons").css("top",jQuery(window).height()/2-t/2+"px")}jQuery(".html-tooltip:not(.no-position)").length&&jQuery(".html-tooltip:not(.no-position)").each(function(){jQuery(this).offset().top-jQuery(window).scrollTop()>540?(jQuery(this).addClass("top").removeClass("side").removeClass("bottom"),jQuery(this).find(".tooltip-text").attr("style",""),jQuery(this).find(".tooltip-text").removeClass("hide-arrow")):jQuery(window).height()-(jQuery(this).offset().top-jQuery(window).scrollTop())>460?(jQuery(this).addClass("bottom").removeClass("top").removeClass("side"),jQuery(this).find(".tooltip-text").attr("style",""),jQuery(this).find(".tooltip-text").removeClass("hide-arrow")):(jQuery(this).addClass("side").removeClass("top").removeClass("bottom"),jQuery(this).find(".tooltip-text").length&&(jQuery(this).find(".tooltip-text").attr("style",""),jQuery(this).find(".tooltip-text").removeClass("hide-arrow"),jQuery(this).find(".tooltip-text").offset().top-jQuery(window).scrollTop()-50<0?(jQuery(this).find(".tooltip-text").css("margin-top",Math.abs(jQuery(this).find(".tooltip-text").offset().top-jQuery(window).scrollTop()-50)+"px"),jQuery(this).find(".tooltip-text").addClass("hide-arrow")):(jQuery(this).find(".tooltip-text").attr("style",""),jQuery(this).find(".tooltip-text").offset().top+parseInt(jQuery(this).find(".tooltip-text").outerHeight())-jQuery(window).scrollTop()-jQuery(window).height()>0&&(jQuery(this).find(".tooltip-text").css("margin-top",-1*Math.abs(jQuery(this).find(".tooltip-text").offset().top+parseInt(jQuery(this).find(".tooltip-text").outerHeight())-jQuery(window).scrollTop()-jQuery(window).height())-10+"px"),jQuery(this).find(".tooltip-text").addClass("hide-arrow")))))})}jQuery(function(e){"use strict";var t=!1,a=!1,o=!1,c=!1,i=!1,n=!1,s=!1;function r(){if(e(".chaty-popup").hide(),0==e("#cht-form .js-chanel-desktop").length||0==e("#cht-form .js-chanel-mobile").length)return e("#no-device-popup").show(),!1;if(0==e("#cht-form .js-chanel-desktop:checked").length&&0==e("#cht-form .js-chanel-mobile:checked").length)return e("#device-popup").show(),!1;var t=0;return e("#channels-selected-list > li:not(#chaty-social-close)").find(".channels__input").each(function(){""==jQuery.trim(e(this).val())&&t++}),t!=e("#channels-selected-list > li:not(#chaty-social-close)").find(".channels__input").length||e("#chaty-social-Contact_Us").length?l():(e("#no-device-value").show(),!1)}function l(){return e(".chaty-popup").hide(),e("#trigger_on_time").is(":checked")||e("#chaty_trigger_on_exit").is(":checked")||e("#chaty_trigger_on_scroll").is(":checked")?u():(e("#trigger-popup").show(),!1)}function u(){return e(".chaty-popup").hide(),e(".cht_active").is(":checked")?(t=!0,e("#cht-form").trigger("submit"),!0):(e("#status-popup").show(),!1)}function h(){if(a){if(o){if(c){if(i){if(n)s||(s=!0,e("#channels-selected-list .phone-number").length&&e("#channels-selected-list .phone-number").each(function(){if(""!=jQuery.trim(e(this).val())&&jQuery.trim(e(this).val()).length>13)return e("#custom-message-popup .chaty-popup-header").text(e(this).data("label")+" number is not valid"),e("#custom-message-popup .chaty-popup-body").text("Seems like the "+e(this).data("label")+" number you're trying to enter isn't valid. Would you like to publish it anyway?"),e("#custom-message-popup").show(),!1}));else if(n=!0,e("#cht-form #Viber").length&&""!=e("#cht-form #Viber").val()){t=jQuery.trim(e("#cht-form #Viber").val());if(check_for_number_chaty(t,"Viber"))return e("#custom-message-popup .chaty-popup-header").text("Viber number is not valid"),e("#custom-message-popup .chaty-popup-body").text("Seems like the Viber number you're trying to enter isn't in the right syntax. Would you like to publish it anyway?"),e("#custom-message-popup").show(),!1}}else if(i=!0,e("#cht-form #SMS").length&&""!=e("#cht-form #SMS").val()){t=jQuery.trim(e("#cht-form #SMS").val());if(check_for_number_chaty(t,"SMS"))return e("#custom-message-popup .chaty-popup-header").text("SMS number is not valid"),e("#custom-message-popup .chaty-popup-body").text("Seems like the SMS number you're trying to enter isn't in the right syntax. Would you like to publish it anyway?"),e("#custom-message-popup").show(),!1}}else if(c=!0,e("#cht-form #Facebook_Messenger").length&&""!=e("#cht-form #Facebook_Messenger").val()){var t=jQuery.trim(e("#Facebook_Messenger").val());if(e("#cht-form #Facebook_Messenger").val(t),!/(?:http:\/\/)?facebook\.com\/(?:(?:\w)*#!\/)?(?:pages\/)?(?:[\w\-]*\/)*([\w\-]*)/.test(t)&&!/(?:http:\/\/)?m\.me\/(?:(?:\w)*#!\/)?(?:pages\/)?(?:[\w\-]*\/)*([\w\-]*)/.test(t))return e("#custom-message-popup .chaty-popup-header").text("Facebook page's URL is not valid"),e("#custom-message-popup .chaty-popup-body").text("Please make sure your Facebook page's URL looks like, <br/>https://m.me/YOURPAGE"),e("#custom-message-popup").show(),!1}}else if(o=!0,e("#cht-form #Phone").length&&""!=e("#cht-form #Phone").val()){var t=jQuery.trim(e("#cht-form #Phone").val());if(check_for_number_chaty(t,"Phone"))return e("#custom-message-popup .chaty-popup-header").text("Phone number is not valid"),e("#custom-message-popup .chaty-popup-body").text("Seems like the phone number you're trying to enter isn't in the right syntax. Would you like to publish it anyway?"),e("#custom-message-popup").show(),!1}}else{a=!0;if(e("#cht-form #Whatsapp").length&&""!=e("#cht-form #Whatsapp").val()){var t=jQuery.trim(e("#cht-form #Whatsapp").val());if(check_for_number_chaty(t,"Whatsapp"))return e("#custom-message-popup .chaty-popup-header").text("Whatsapp number is not valid"),e("#custom-message-popup .chaty-popup-body").text("Seems like the WhatsApp number you're trying to enter isn't in the right syntax. Would you like to publish it anyway?"),e("#custom-message-popup").show(),!1}}return r()}e(document).ready(function(){jQuery(document).on("click","#update-chaty-traffic-source-rule",function(e){jQuery(".traffic-options-box").addClass("active"),jQuery("#chaty_traffic_source").val("yes")}),jQuery(document).on("click","#remove-traffic-rules",function(e){jQuery(".traffic-options-box").removeClass("active"),jQuery("#chaty_traffic_source").val("no")}),jQuery(document).on("click",".remove-traffic-option",function(e){jQuery(this).closest(".custom-traffic-rule").remove()}),e(document).on("click",".chaty-switch-toggle",function(){setTimeout(function(){e(".chaty-field-setting").each(function(){e(this).is(":checked")?e(this).closest(".field-setting-col").find(".field-settings").addClass("active"):e(this).closest(".field-setting-col").find(".field-settings").removeClass("active")})},100)}),e(document).on("change",".chaty-close_form_after-setting",function(){setTimeout(function(){e(".chaty-close_form_after-setting").each(function(){e(this).is(":checked")?e(this).closest(".form-field-setting-col").find(".close_form_after-settings").addClass("active"):e(this).closest(".form-field-setting-col").find(".close_form_after-settings").removeClass("active")})},100)}),e("#channel_input_Whatsapp").length&&(cht_settings.channel_settings.Whatsapp=document.querySelector("#channel_input_Whatsapp"),window.intlTelInput(cht_settings.channel_settings.Whatsapp,{dropdownContainer:document.body,formatOnDisplay:!0,hiddenInput:"full_number",initialCountry:"auto",nationalMode:!1,utilsScript:cht_settings.plugin_url+"admin/assets/js/utils.js"})),e(".custom-channel-Whatsapp:not(#channel_input_Whatsapp)").length&&e(".custom-channel-Whatsapp:not(#channel_input_Whatsapp)").each(function(){var t=e(this).closest("li.chaty-channel").data("id");null!=t&&e("#channel_input_"+t).length&&(cht_settings.channel_settings[t]=document.querySelector("#channel_input_"+t),window.intlTelInput(cht_settings.channel_settings[t],{dropdownContainer:document.body,formatOnDisplay:!0,hiddenInput:"full_number",initialCountry:"auto",nationalMode:!1,utilsScript:cht_settings.plugin_url+"admin/assets/js/utils.js"}))}),e(document).on("change",".chaty-redirect-setting",function(){setTimeout(function(){e(".chaty-redirect-setting").each(function(){e(this).is(":checked")?e(this).closest(".form-field-setting-col").find(".redirect_action-settings").addClass("active"):e(this).closest(".form-field-setting-col").find(".redirect_action-settings").removeClass("active")})},100)}),e(document).on("click",".email-setting",function(){setTimeout(function(){e(".email-setting-field").each(function(){e(this).is(":checked")?e(this).closest(".form-field-setting-col").find(".email-settings").addClass("active"):e(this).closest(".form-field-setting-col").find(".email-settings").removeClass("active")})},100)}),e(document).on("click",".chaty-embedded-window",function(){setTimeout(function(){e(".embedded_window-checkbox").each(function(){e(this).is(":checked")?e(this).closest("li.chaty-channel").find(".whatsapp-welcome-message").addClass("active"):e(this).closest("li.chaty-channel").find(".whatsapp-welcome-message").removeClass("active")})},300)}),jQuery("input[name='switchPreview']:checked").trigger("change"),e(document).on("change","#cht-form input",function(){a=!1,o=!1,c=!1,i=!1,n=!1,s=!1}),e("#cht-form").on("submit",function(){if(t)return!0;set_social_channel_order();var a=0;return e("#chaty-page-options .cht-required").length&&e("#chaty-page-options .cht-required").each(function(){""==jQuery.trim(e(this).val())&&(e(this).addClass("cht-input-error"),a++)}),e(".chaty-data-and-time-rules .cht-required").length&&e(".chaty-data-and-time-rules .cht-required").each(function(){""==jQuery.trim(e(this).val())&&(e(this).addClass("cht-input-error"),a++)}),0==a?h():(e(".cht-input-error:first").focus(),!1)}),e(".close-chaty-popup-btn").on("click",function(t){t.stopPropagation(),e(".chaty-popup").hide(),e(this).hasClass("channel-setting-btn")?e("body, html").animate({scrollTop:e("#channel-list").offset().top-125},250):e(this).hasClass("select-trigger-btn")?e("body, html").animate({scrollTop:e("#trigger-setting").offset().top-50},250):e(this).hasClass("change-status-btn")&&e("body, html").animate({scrollTop:e("#launch-section").offset().top-100},250)}),e(".chaty-popup-inner").on("click",function(e){e.stopPropagation()}),e(".chaty-popup-outer").on("click",function(t){e(".chaty-popup").hide()}),e(".check-for-numbers").on("click",function(){h()}),e(".check-for-device").on("click",function(){r()}),e(".check-for-triggers").on("click",function(){l()}),e(".check-for-status").on("click",function(){u()}),e(".change-status-and-save").on("click",function(){e(".cht_active").prop("checked",!0),t=!0,e(".chaty-popup").hide(),e("#cht-form").trigger("submit")}),e(".status-and-save").on("click",function(){e(".cht_active").prop("checked",!1),t=!0,e(".chaty-popup").hide(),e("#cht-form").trigger("submit")}),e(document).on("click",".preview-section-chaty",function(e){e.stopPropagation()}),e(document).on("click",".preview-section-overlay",function(){e(".preview-help-btn").removeClass("active"),e(".preview-section-chaty").removeClass("active"),e(".preview-section-overlay").removeClass("active")}),e(document).on("click",".preview-help-btn",function(t){return t.preventDefault(),e(this).hasClass("active")?(e(this).removeClass("active"),e(".preview-section-chaty").removeClass("active"),e(".preview-section-overlay").removeClass("active")):(e(this).addClass("active"),e(".preview-section-chaty").addClass("active"),e(".preview-section-overlay").addClass("active")),!1}),jQuery(document).on("click","#create-date-rule",function(e){jQuery("#date-schedule").addClass("active"),jQuery("#cht_date_rules").val("yes")}),jQuery(document).on("click","#remove-date-rule",function(e){jQuery("#date-schedule").removeClass("active"),jQuery("#cht_date_rules").val("no")})})}),function(e){jQuery(window).on("popstate",function(e){window.onbeforeunload=null,window.history&&window.history.pushState&&window.history.back()}),jQuery(document).ready(function(){jQuery(".chaty-table").length||jQuery("body input, body .icon, body textarea, body .btn-cancel:not(.close-btn-set) ").on("click",function(e){window.onbeforeunload=function(e){(e=e||window.event).preventDefault=!0,e.cancelBubble=!0,e.returnValue="Your beautiful goodbye message"}}),jQuery(document).on("submit","form",function(e){window.onbeforeunload=null}),jQuery(document).on("change",".channel-select-input",function(t){var a=e(this).closest("li").attr("data-id");jQuery.ajax({type:"POST",url:ajaxurl,dataType:"json",data:{social:jQuery(this).val(),channel:a,action:"get_chaty_settings"},success:function(t){1==t.status&&("Whatsapp"==t.data.slug?e("#channel_input_"+t.channel).length&&(cht_settings.channel_settings[t.channel]=document.querySelector("#channel_input_"+t.channel),window.intlTelInput(cht_settings.channel_settings[t.channel],{dropdownContainer:document.body,formatOnDisplay:!0,hiddenInput:"full_number",initialCountry:"auto",nationalMode:!1,utilsScript:cht_settings.plugin_url+"admin/assets/js/utils.js"})):e("#chaty-social-"+t.channel+" .channels__input-box").html("<input type='text' class='channels__input' name='cht_social_"+t.channel+"[value]' id='channel_input_"+t.channel+"' />"),jQuery(".custom-icon-"+t.channel+" svg").html(t.data.svg),jQuery("#chaty-social-"+t.channel).attr("data-channel",t.data.slug),jQuery("#chaty-social-"+t.channel).find(".sp-preview-inner").css("background-color",t.data.color),jQuery("#chaty-social-"+t.channel).find(".chaty-color-field").val(t.data.color),jQuery("#chaty-social-"+t.channel).find(".channels__input").attr("placeholder",t.data.placeholder),jQuery("#chaty-social-"+t.channel).find(".channel-example").text(t.data.example),jQuery("#chaty-social-"+t.channel).find(".chaty-title").val(t.data.title),jQuery("#chaty-social-"+t.channel).find(".icon").attr("data-title",t.data.title),jQuery("#chaty-social-"+t.channel).find(".chaty-color-field").trigger("change"),jQuery(".help-section").html(""),""!=t.data.help_link?jQuery(".help-section").html('<div class="viber-help"><a target="_blank" href="'+t.data.help_link+'">'+t.data.help_title+"</a></div>"):""!=t.data.help_text&&jQuery(".help-section").html('<div class="viber-help"><span class="help-text">'+t.data.help_text+'</span><span class="help-title">'+t.data.help_title+"</span></div>"))}})}),jQuery(document).on("click","#chaty_icons_view",function(e){jQuery(".page-body .chaty-widget").removeClass("vertical").removeClass("horizontal"),jQuery(".page-body .chaty-widget").addClass(jQuery(this).val())}),jQuery(".upg").on("click",function(e){jQuery(".valid_domain_input").val(jQuery(".valid_domain_input").val().replace(" ","")),/^(http(s)?:\/\/)?(www\.)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/.test(jQuery(".valid_domain_input").val())||(e.preventDefault(),jQuery(".valid_domain").fadeIn().css({display:"block"}))}),jQuery(".del_token").on("click",function(t){e.ajax({type:"POST",url:ajaxurl,data:{action:"del_token",nonce_code:cht_nonce_ajax.cht_nonce},success:function(e){location.reload()},error:function(e,t,a){}})}),jQuery(document).on("blur","#channels-selected-list > li:not(#chaty-social-close) .channels__input",function(){jQuery(this).hasClass("border-red")&&""!=jQuery(this).val()&&jQuery(this).removeClass("border-red")});var t=1000000003;jQuery(".show_up").on("click",function(){t+=10,jQuery("#upgrade-modal").css({"z-index":t,display:"block","margin-left":"-258px"})}),jQuery(".color-picker-btn, .color-picker-btn-close, .color-picker-custom button").on("click",function(e){e.preventDefault(),jQuery(".color-picker-box").toggle(),jQuery(".color-picker-btn").toggle()}),jQuery(".color-picker-radio input").on("change",function(){var e=jQuery(this);if(jQuery('.color-picker-custom input[name="cht_custom_color"]').val(""),jQuery(".color-picker-custom .circle").html("?").css({"background-color":"#fff"}),e.prop("checked")){jQuery(".color-picker-radio input").prop("checked",!1),e.prop("checked",!0);var t=e.val(),a=e.prop("title")}else t=jQuery(".color-picker-custom input").val(),a="Custom";""!=t&&-1==t.indexOf("#")&&(t="#"+t),jQuery(".color-picker-btn .circle").css({backgroundColor:t}),jQuery(".color-picker-btn .text").text(a),jQuery("#chaty-social-close ellipse").attr("fill",t)}),jQuery(".color-picker-custom input").on("change",function(){jQuery(".color-picker-radio input").prop("checked",!1);var e=jQuery(this).val();""!=e&&-1==e.indexOf("#")&&(e="#"+e),jQuery(".color-picker-btn .circle").css({backgroundColor:e}),jQuery(".color-picker-btn .text").text("Custom"),jQuery("#chaty-social-close ellipse").attr("fill",e)}),jQuery('[name="cht_position"]').on("change",function(){jQuery("#positionCustom").prop("checked")?jQuery("#positionPro").show():jQuery("#positionPro").hide()}),jQuery(".update_token").on("click",function(t){t.preventDefault();var a=jQuery('input[name="cht_token"]').val();e.ajax({type:"POST",url:ajaxurl,data:{action:"add_token",nonce_code:cht_nonce_ajax.cht_nonce,token:a},beforeSend:function(e){},success:function(e){e?(alert("Your pro plan is activated"),location.reload()):alert("You`ve entered a wrong token")},error:function(e,t,a){}})}),jQuery("textarea[name=cht_cta]").on("keyup",function(e){if(jQuery(".tooltiptext span").html(jQuery(this).val()),0==jQuery(this).val().length)jQuery(".cta").hide(200),jQuery(".tooltiptext span").hide(200);else{jQuery(".cta").show(300),jQuery(".tooltiptext span").show(200);var t=jQuery(".tooltiptext span").html();count=(t.match(/\n/g)||[]).length,count>0?jQuery(".tooltiptext").addClass("has-multiline").removeClass("line-1").removeClass("line-2").removeClass("line-3").addClass("line-"+count):jQuery(".tooltiptext").removeClass("has-multiline")}}),jQuery("textarea[name=cht_cta]").trigger("keyup")})}(jQuery),function(e){jQuery(document).ready(function(){!function(){function e(){var e=jQuery("#positionBottom"),t=jQuery("#positionSide"),a=jQuery(".preview .page .chaty-widget"),o=jQuery('[name="cht_position"]:checked').val();if("right"===o)a.css({right:"7px",left:"auto",bottom:"7px"});else if("left"===o)a.css({left:"7px",right:"auto",bottom:"7px"});else if("custom"===o){if(e.val())var c=e.val()+"px";else c="7px";if(t.val())var i=t.val()+"px";else i="7px";e.on("change",function(){c=jQuery("#positionBottom").val()+"px",a.css({bottom:c})}),t.on("change",function(){var e=jQuery('[name="positionSide"]:checked').val();i=jQuery(this).val()+"px","right"===e?(jQuery(".page-body .chaty-widget ").removeClass("chaty-widget-icons-left"),jQuery(".page-body .chaty-widget ").addClass("chaty-widget-icons-right"),a.css({right:i,left:"auto"})):"left"===e&&(jQuery(".page-body .chaty-widget ").removeClass("chaty-widget-icons-right"),jQuery(".page-body .chaty-widget ").addClass("chaty-widget-icons-left"),a.css({left:i,right:"auto"}))}),jQuery('[name="positionSide"]').on("change",function(){var e=jQuery('[name="positionSide"]:checked').val();"right"===e?(jQuery(".page-body .chaty-widget ").removeClass("chaty-widget-icons-left"),jQuery(".page-body .chaty-widget ").addClass("chaty-widget-icons-right"),a.css({right:i,left:"auto"})):"left"===e&&(jQuery(".page-body .chaty-widget ").removeClass("chaty-widget-icons-right"),jQuery(".page-body .chaty-widget ").addClass("chaty-widget-icons-left"),a.css({left:i,right:"auto"}))})}}jQuery(".color-picker-radio input").on("change",function(){var e=jQuery(this);e.prop("checked")?e.val():jQuery(".color-picker-custom input").val(),u()}),jQuery(".color-picker-custom input").on("change",function(){jQuery(this).val(),u()}),jQuery(document).on("change","#chaty_default_state",function(){u()}),jQuery("#cht_close_button, #trigger_on_time, #chaty_trigger_on_scroll").on("click",function(){u()}),function(){var e=jQuery("#widgetTooltip"),t=jQuery(".preview .page .icon");function a(){jQuery("[name=cht_cta]").length&&(jQuery("[name=cht_cta]").val().length>=1?t.removeClass("no-tooltip"):t.addClass("no-tooltip"))}a(),e.on("change",function(){a()})}(),e(),jQuery('input[name="cht_position"]').on("change",function(){var t=jQuery('[name="cht_position"]:checked').val();"right"===t?(jQuery(".page-body .chaty-widget ").removeClass("chaty-widget-icons-left"),jQuery(".page-body .chaty-widget ").addClass("chaty-widget-icons-right")):"left"===t&&(jQuery(".page-body .chaty-widget ").removeClass("chaty-widget-icons-right"),jQuery(".page-body .chaty-widget ").addClass("chaty-widget-icons-left")),e()})}(),jQuery(".popover").hide(),o();var t=jQuery(".channels-icons > .icon-sm"),a=jQuery(".social-inputs");function o(){jQuery("section").is("#pro")||(jQuery(".channels-selected__item").length<=1?(jQuery(".channels-selected__item").hide(),jQuery(".popover").hide()):jQuery(".channels-selected__item").length>=2&&jQuery(".channels-selected__item").show())}jQuery("input[name=cht_custom_color]").on("keyup",function(e){var t=jQuery(this).val();(jQuery(".circle").html(""),""!=t)&&(-1==t.indexOf("#")&&(t="#"+t),jQuery(".color-picker-custom .circle").css({"background-color":t}));jQuery(this).val().length<1&&jQuery(".color-picker-custom .circle").html("?")}),t.on("click",function(){0,o();var c=jQuery(this),i=c.data("social");a.find(".social-form-group");if(c.hasClass("active")){var n=","+jQuery(this).attr("data-social");return s=(s=jQuery(".add_slug").val()).replace(n,""),jQuery(".add_slug").val(s),s=s.replace(n,""),jQuery(".add_slug").val(s),s=s.replace(n,""),jQuery(".add_slug").val(s),s=s.replace(n,""),jQuery(".add_slug").val(s),void c.toggleClass("active")}if(t.addClass("disabled"),icon=jQuery(this).data("social"),"1"==jQuery(".add_slug").val().indexOf(icon)&&""!=jQuery(".add_slug").val()){var s;n=","+icon;s=(s=jQuery(".add_slug").val()).replace(n,""),jQuery(".add_slug").val(s),s=s.replace(n,""),jQuery(".add_slug").val(s),s=s.replace(n,""),jQuery(".add_slug").val(s)}else jQuery(".add_slug").val(jQuery(".add_slug").val()+","+jQuery(this).attr("data-social"));if(!jQuery("section").is("#pro")&&jQuery(".channels-icons > .icon.active").length>=2)return t.removeClass("disabled"),jQuery(".popover").show(),jQuery(".popover .upgrade-link").addClass("active"),void setTimeout(function(){jQuery(".popover .upgrade-link").removeClass("active")},1e3);if(c.toggleClass("active"),jQuery("section").is("#pro"))var r="pro";else r="free";e.ajax({type:"POST",dataType:"json",url:ajaxurl,data:{action:"choose_social",social:i,nonce_code:cht_nonce_ajax.cht_nonce,version:r,widget_index:jQuery("#widget_index").val()},beforeSend:function(e){},success:function(a){var c=jQuery(a),n=c.find(".icon").data("title");c.data("channel");jQuery('.channels-selected div[data-social="'+n+'"]').length||(jQuery("#chaty-social-close").before(c),jQuery("#chaty-social-"+i+" .chaty-whatsapp-setting-textarea").length&&(editorId=jQuery("#chaty-social-"+i+" .chaty-whatsapp-setting-textarea").attr("id"),tinymce.execCommand("mceAddEditor",!0,editorId))),t.removeClass("disabled"),e("#iconWidget").show(),u(),o(),set_social_channel_order(),check_for_chaty_close_button(),jQuery(".chaty-color-field").spectrum({chooseText:"Submit",preferredFormat:"hex",showInput:!0,cancelText:"Cancel",showAlpha:!0,move:function(e){jQuery(this).val(e.toRgbString()),chaty_set_bg_color(),jQuery("input[name='switchPreview']:checked").trigger("change")},change:function(e){jQuery(this).val(e.toRgbString()),chaty_set_bg_color(),jQuery("input[name='switchPreview']:checked").trigger("change")}}),check_for_chaty_close_button(),"Whatsapp"==i&&e("#channel_input_Whatsapp").length&&(cht_settings.channel_settings.Whatsapp=document.querySelector("#channel_input_Whatsapp"),window.intlTelInput(cht_settings.channel_settings.Whatsapp,{dropdownContainer:document.body,formatOnDisplay:!0,hiddenInput:"full_number",initialCountry:"auto",nationalMode:!1,utilsScript:cht_settings.plugin_url+"admin/assets/js/utils.js"})),jQuery(".custom-channel-Whatsapp").length&&jQuery(".custom-channel-Whatsapp").each(function(){if(!jQuery(this).closest(".iti__flag-container").length){var e=jQuery(this).closest("li.chaty-channel").data("id");jQuery("#channel_input_"+e).length&&(cht_settings.channel_settings[e]=document.querySelector("#channel_input_"+e),window.intlTelInput(cht_settings.channel_settings[e],{dropdownContainer:document.body,formatOnDisplay:!0,hiddenInput:"full_number",initialCountry:"auto",nationalMode:!1,utilsScript:cht_settings.plugin_url+"admin/assets/js/utils.js"}))}})},error:function(e,t,a){}}),o()}),jQuery("body").on("click",".icon, .btn-cancel:not(.close-btn-set)",function(e){if(!jQuery(this).hasClass("close-btn-set")&&(e.preventDefault(),!jQuery(this).hasClass("icon")||!jQuery(this).hasClass("active"))){if(icon=jQuery(this).data("social"),jQuery(this).hasClass("btn-cancel")){jQuery('.icon.active[data-social^="'+icon+'"]').removeClass("active");var t=","+icon,a=jQuery(".add_slug").val();a=a.replace(t,""),jQuery(".add_slug").val(a)}jQuery("#chaty-social-"+icon).remove();jQuery(this).parent(".channels-selected__item"),jQuery(this).data("social");u(),o(),set_social_channel_order(),check_for_chaty_close_button()}}),jQuery(".btn-help").on("click",function(e){window.open("https://premio.io/help/chaty/","_blank")}),jQuery(".free-custom-radio, .free-custom-checkbox").on("click",function(e){e.preventDefault()});var c=jQuery("[name=cht_cta]"),i=jQuery(".preview .tooltip-show");c.on("keyup",function(){var e=jQuery(".preview .page .icon");c.val().length>=1?e.removeClass("no-tooltip"):e.addClass("no-tooltip"),i.attr("data-title",c.val())});var n,s,r='<svg version="1.1" id="ch" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="-496 507.7 54 54" style="enable-background:new -496 507.7 54 54;" xml:space="preserve">\n <style type="text/css">.st0 {fill: #A886CD;} .st1 {fill: #FFFFFF;}\n </style><g><circle class="st0" cx="-469" cy="534.7" r="27"/></g><path class="st1" d="M-459.9,523.7h-20.3c-1.9,0-3.4,1.5-3.4,3.4v15.3c0,1.9,1.5,3.4,3.4,3.4h11.4l5.9,4.9c0.2,0.2,0.3,0.2,0.5,0.2 h0.3c0.3-0.2,0.5-0.5,0.5-0.8v-4.2h1.7c1.9,0,3.4-1.5,3.4-3.4v-15.3C-456.5,525.2-458,523.7-459.9,523.7z"/>\n <path class="st0" d="M-477.7,530.5h11.9c0.5,0,0.8,0.4,0.8,0.8l0,0c0,0.5-0.4,0.8-0.8,0.8h-11.9c-0.5,0-0.8-0.4-0.8-0.8l0,0\n C-478.6,530.8-478.2,530.5-477.7,530.5z"/>\n <path class="st0" d="M-477.7,533.5h7.9c0.5,0,0.8,0.4,0.8,0.8l0,0c0,0.5-0.4,0.8-0.8,0.8h-7.9c-0.5,0-0.8-0.4-0.8-0.8l0,0\n C-478.6,533.9-478.2,533.5-477.7,533.5z"/>\n </svg>',l=document.getElementById("iconWidget");jQuery(".color-picker-radio input:checked").val();function u(){var t,a,o=!1;if(jQuery(".single-channel-setting").addClass("active"),jQuery("#iconWidget").removeClass("img-p-active"),d()?(0===jQuery(".js-chanel-desktop:checked").length?(t=!1,jQuery(".page-body .chaty-widget").hide()):jQuery(".page-body .chaty-widget").show(),1===jQuery(".js-chanel-desktop:checked").length&&(t=jQuery(".js-chanel-desktop:checked").closest("li").find(".icon.icon-md").html(),jQuery(".js-chanel-desktop:checked").closest(".channels-selected__item").hasClass("img-active")&&jQuery("#iconWidget").addClass("img-p-active")),jQuery(".js-chanel-desktop:checked").length>1&&(t=r,o=!0)):(0===jQuery(".js-chanel-mobile:checked").length?(a=!1,jQuery(".page-body .chaty-widget").hide()):jQuery(".page-body .chaty-widget").show(),1===jQuery(".js-chanel-mobile:checked").length&&(a=jQuery(".js-chanel-mobile:checked").closest("li").find(".icon.icon-md").html(),jQuery(".js-chanel-mobile:checked").closest(".channels-selected__item").hasClass("img-active")&&jQuery("#iconWidget").addClass("img-p-active")),jQuery(".js-chanel-mobile:checked").length>1&&(a=r,o=!0)),n=t,s=a,d()?h(n,o):h(s,o),e("#iconWidget .pop-number").remove(),jQuery("#cht_pending_messages").is(":checked")){var c=jQuery("#cht_number_of_messages").val();""!=c&&c>0&&(e("#iconWidget").append("<span class='pop-number'>"+c+"</span>"),e("#iconWidget .pop-number").css("color",jQuery("#cht_number_color").val()),e("#iconWidget .pop-number").css("background",jQuery("#cht_number_bg_color").val()))}var i=".js-chanel-mobile";if(d())i=".js-chanel-desktop";"open"==jQuery("#chaty_default_state").val()&&jQuery(i+":checked").length>1&&e("#iconWidget .pop-number").remove(),e("#cta-box span").css("color",e("#cht_cta_text_color").val()),e("#cta-box span").css("background",e("#cht_cta_bg_color").val()),e("#custom-css").html("<style>.preview .page .chaty-widget .icon:before {border-color: transparent "+e("#cht_cta_bg_color").val()+" transparent transparent } .preview .page .chaty-widget[style*='left: auto;'] .icon:before {border-color: transparent transparent transparent "+e("#cht_cta_bg_color").val()+"}</style>"),jQuery(".single-channel-setting").addClass("active"),1===jQuery("#channel-list .icon.active").length&&(jQuery(".single-channel-setting").removeClass("active"),"open"==jQuery("#chaty_default_state").val()&&jQuery(".hide-show-button").removeClass("active"))}function h(e,t){if(jQuery("#iconWidget").length){if(l.innerHTML=e||"",t){var a=jQuery(".color-picker-custom input").val()?jQuery(".color-picker-custom input").val():jQuery(".color-picker-radio input:checked").val();if(""!=a)-1==a.indexOf("#")&&(a="#"+a);jQuery(".preview .page svg circle").css({fill:a}),jQuery("#chaty-social-close ellipse").attr("fill",a)}thisVal=jQuery("#chaty_default_state").val(),"open"==thisVal?jQuery(".hide-show-button").addClass("active"):jQuery(".hide-show-button").removeClass("active"),jQuery(".chaty-widget").removeClass("active").removeClass("hover").removeClass("click").removeClass("hide_arrow"),"open"==thisVal?(jQuery(".chaty-widget").addClass("active").addClass("click"),"open"==thisVal&&jQuery(o+":checked").length>1&&jQuery(".chaty-widget").addClass("hide_arrow")):"hover"==thisVal?jQuery(".chaty-widget").addClass("hover"):jQuery(".chaty-widget").addClass("click"),jQuery(".chaty-channels").html("");var o=".js-chanel-mobile";if(d())o=".js-chanel-desktop";"open"==thisVal&&jQuery(o+":checked").length>1?(jQuery("#chaty_attention_effect").val(""),jQuery("#chaty_attention_effect, .test_textarea").attr("disabled",!0),jQuery("#chaty_attention_effect option:first-child").text("Doesn't apply for the open state"),"Doesn't apply for the open state"!=jQuery(".test_textarea").val()&&jQuery(".test_textarea").attr("data-value",jQuery(".test_textarea").val()),jQuery(".test_textarea").val("Doesn't apply for the open state"),jQuery("#cht_number_of_messages").attr("disabled",!0),jQuery("#cht_pending_messages").attr("disabled",!0),jQuery(".disable-message").addClass("label-tooltip").addClass("icon"),jQuery("#cht_pending_messages").attr("checked",!1),jQuery(".pending-message-items").removeClass("active"),jQuery(".cta-action-radio input").attr("disabled",!0)):(jQuery("#chaty_attention_effect, .test_textarea").attr("disabled",!1),jQuery("#chaty_attention_effect option:first-child").text("None"),jQuery(".test_textarea").attr("placeholder",""),"Doesn't apply for the open state"==jQuery(".test_textarea").val()&&jQuery(".test_textarea").val(jQuery(".test_textarea").attr("data-value")),jQuery("#cht_number_of_messages").attr("disabled",!1),jQuery("#cht_pending_messages").attr("disabled",!1),jQuery(".disable-message").removeClass("label-tooltip").removeClass("icon"),jQuery(".cta-action-radio input").attr("disabled",!1)),jQuery(".page-body .chaty-widget").removeClass("vertical").removeClass("horizontal"),jQuery(o+":checked").length>1?(jQuery(o+":checked").each(function(){var e=jQuery(this).closest("li").find(".icon").html(),t=(e=jQuery(this).closest("li").find(".icon").html(),jQuery(this).closest("li").find(".chaty-title").val()),a=jQuery(this).closest(".channels-selected__item").hasClass("img-active")?"img-active":"";""!=t&&(t="<span class='social-tooltip'>"+t+"</span>"),jQuery(".chaty-channels").append("<div class='social-item-box "+a+"'><span class='tooltip-icon'>"+e+"</span>"+t+"</div>")}),"open"==jQuery("#chaty_default_state").val()&&jQuery("#cht_close_button").is(":checked")?(jQuery("#iconWidget").css("display","block"),jQuery(".chaty-widget .tooltiptext").css("display","block"),jQuery(".chaty-widget").removeClass("hide-arrow")):"open"!=jQuery("#chaty_default_state").val()?(jQuery("#iconWidget").css("display","block"),jQuery(".chaty-widget .tooltiptext").css("display","block"),jQuery(".chaty-widget").removeClass("hide-arrow")):"open"==jQuery("#chaty_default_state").val()&&(jQuery("#iconWidget").hide(),jQuery(".chaty-widget .tooltiptext").hide(),jQuery(".chaty-widget").addClass("hide-arrow")),jQuery(".chaty-widget").removeClass("has-single"),jQuery(".page-body .chaty-widget").addClass(jQuery("#chaty_icons_view").val())):1==jQuery(o+":checked").length?("open"!=jQuery("#chaty_default_state").val()||jQuery("#cht_close_button").is(":checked")?"open"!=jQuery("#chaty_default_state").val()&&(jQuery("#iconWidget").css("display","block"),jQuery(".chaty-widget .tooltiptext").css("display","block"),jQuery(".chaty-widget").removeClass("hide-arrow")):(jQuery("#iconWidget").css("display","block"),jQuery(".chaty-widget .tooltiptext").css("display","block"),jQuery(".chaty-widget").removeClass("hide-arrow")),jQuery(".chaty-widget").addClass("has-single"),jQuery(".chaty-widget").removeClass("hide-arrow")):0==jQuery(o+":checked").length&&(jQuery("#iconWidget").hide(),jQuery(".chaty-widget .tooltiptext").hide(),jQuery(".chaty-widget").addClass("hide-arrow"),jQuery(".chaty-widget").removeClass("has-single")),jQuery(".chaty-channels .remove-icon-img").remove(),jQuery("#trigger_on_time").is(":checked")?jQuery("#chaty_trigger_time").attr("readonly",!1):jQuery("#chaty_trigger_time").attr("readonly",!0),jQuery("#chaty_trigger_on_scroll").is(":checked")?jQuery("#chaty_trigger_on_page_scroll").attr("readonly",!1):jQuery("#chaty_trigger_on_page_scroll").attr("readonly",!0),""==jQuery(".chaty-widget .tooltiptext").text()?jQuery(".chaty-widget .tooltiptext").hide():"open"==jQuery("#chaty_default_state").val()&&jQuery(o+":checked").length>1?jQuery(".chaty-widget .tooltiptext").hide():jQuery(".chaty-widget .tooltiptext").css("display","block")}}function d(){return!!jQuery("#previewDesktop").is(":checked")}jQuery("#testUpload").on("change",function(){this.value.length>0?document.querySelector(".js-upload").disabled=!1:(document.querySelector(".js-upload").disabled=!0,document.getElementById("uploadInput").checked=!1)}),jQuery(document).on("keyup","textarea.test_textarea",function(){u()}),jQuery(".js-switch-preview").on("change",function(){d()?jQuery(this).closest(".preview").removeClass("mobiel-view"):jQuery(this).closest(".preview").addClass("mobiel-view"),u()}),jQuery(document).on("change","input[name='cht_pending_messages']",function(){jQuery("#cht_pending_messages").is(":checked")?jQuery(".pending-message-items").addClass("active"):jQuery(".pending-message-items").removeClass("active"),u()}),jQuery(document).on("change","#cht_number_of_messages",function(){u()}),jQuery(document).on("keyup","#cht_number_of_messages",function(){u()}),jQuery(document).on("blur","#cht_number_of_messages",function(){u()}),jQuery(document).on("change",".js-chanel-icon",function(){u()}),jQuery(document).on("change",".js-widget-i",function(e){r=e.target.classList.contains("js-upload")?jQuery(".file-preview-image").last().parent().html():jQuery("i[data-type="+jQuery(".js-widget-i:checked").val()+"]").html(),u()}),"chat-image"!==jQuery(".js-widget-i:checked").attr("data-type")&&(r=jQuery("i[data-type="+jQuery(".js-widget-i:checked").attr("data-type")+"]").html(),u())}),jQuery(document).ready(function(){jQuery(".toast-message").length&&(jQuery(".toast-message").show(),jQuery(".toast-message").addClass("active"),setTimeout(function(){jQuery(".toast-message").removeClass("active")},5e3)),jQuery(document).on("click",".toast-close-btn a",function(e){e.preventDefault(),jQuery(".toast-message").removeClass("active")}),jQuery(document).on("click",".chaty-popup-box button, #chaty-intro-popup",function(t){t.stopPropagation();var a=jQuery("#chaty_update_popup_status").val();e("#chaty-intro-popup").remove(),e.ajax({type:"POST",url:ajaxurl,data:{action:"update_popup_status",nonce:a},beforeSend:function(e){},success:function(e){},error:function(e,t,a){}})}),jQuery(document).on("click",".chaty-popup-box",function(e){e.stopPropagation()}),jQuery(document).on("click",".remove-chaty-options",function(t){t.preventDefault(),t.stopPropagation(),confirm("Are you sure you want to delete this widget?")&&e.ajax({type:"POST",url:ajaxurl,data:{action:"remove_chaty_widget",nonce_code:cht_nonce_ajax.cht_nonce,widget_index:jQuery("#widget_index").val()},beforeSend:function(e){},success:function(e){window.location=e},error:function(e,t,a){}})});window.location.href;window.location.href.indexOf("page=chaty-app&widget=")>-1&&jQuery("#toplevel_page_chaty-app .wp-submenu.wp-submenu-wrap li").each(function(){var e=jQuery(this).find("a").attr("href");void 0!==e&&(jQuery(this).removeClass("current"),window.location.href.indexOf(e)>-1&&e.indexOf("&widget=")>-1&&jQuery(this).addClass("current"))})})}(jQuery),jQuery(window).on("resize",function(){check_for_preview_pos()}),jQuery(window).on("scroll",function(){check_for_preview_pos()}),jQuery(document).ready(function(){check_for_preview_pos()});var totalPageOptions=0,pageOptionContent="",totalDateAndTimeOptions=0,dateAndTimeOptionContent="";jQuery(document).ready(function(){function e(){jQuery(".chaty-whatsapp-setting-textarea").length&&jQuery(".chaty-whatsapp-setting-textarea").each(function(){jQuery("#cht_social_embedded_message_"+jQuery(this).data("id")+"_ifr").length&&tinymce.get(jQuery(this).attr("id")).remove(),tinymce.execCommand("mceAddEditor",!0,jQuery(this).attr("id"))})}totalPageOptions=parseInt(jQuery(".chaty-page-option").length),pageOptionContent=jQuery(".chaty-page-options-html").html(),jQuery(".chaty-page-options-html").remove(),totalDateAndTimeOptions=parseInt(jQuery(".chaty-date-time-option").length),dateAndTimeOptionContent=jQuery(".chaty-date-and-time-options-html").html(),jQuery(".chaty-date-and-time-options-html").remove(),jQuery("#create-rule").on("click",function(){jQuery(".page-options").toggle()}),jQuery("#create-data-and-time-rule").on("click",function(){jQuery(".chaty-data-and-time-rules").toggle()}),jQuery(document).on("change","#chaty_attention_effect",function(){var e=jQuery(this).attr("data-effect");""!=e&&jQuery("#iconWidget").removeClass("chaty-animation-"+e),jQuery("#iconWidget").removeClass("start-now"),jQuery("#iconWidget").addClass("chaty-animation-"+jQuery(this).val()).addClass("start-now"),jQuery(this).attr("data-effect",jQuery(this).val())}),setInterval(function(){var e=jQuery("#chaty_attention_effect").attr("data-effect");""!=e?(jQuery("#iconWidget").removeClass("chaty-animation-"+e),jQuery("#iconWidget").removeClass("start-now"),setTimeout(function(){jQuery("#iconWidget").addClass("chaty-animation-"+jQuery("#chaty_attention_effect").val()).addClass("start-now")},1e3)):jQuery("#chaty_attention_effect").attr("data-effect",jQuery("#chaty_attention_effect").val())},5e3),jQuery(document).on("click",".remove-chaty",function(){jQuery(".page-options").toggle()}),jQuery(document).on("click",".remove-page-option",function(){jQuery(".chaty-data-and-time-rules ").toggle()}),jQuery("#image-upload-content .custom-control-label").on("click",function(e){return e.stopPropagation(),jQuery(this).closest(".custom-control").find("input[type=radio]").attr("checked",!0),jQuery(".js-widget-i").trigger("change"),!1}),jQuery(".chaty-color-field").spectrum({chooseText:"Submit",preferredFormat:"hex",cancelText:"Cancel",showInput:!0,showAlpha:!0,move:function(e){jQuery(this).val(e.toHexString()),jQuery("#cta-box span").css("color",jQuery("#cht_cta_text_color").val()),jQuery("#cta-box span").css("background",jQuery("#cht_cta_bg_color").val()),jQuery("#custom-css").html("<style>.preview .page .chaty-widget .icon:before {border-color: transparent "+jQuery("#cht_cta_bg_color").val()+" transparent transparent } .preview .page .chaty-widget[style*='left: auto;'] .icon:before {border-color: transparent transparent transparent "+jQuery("#cht_cta_bg_color").val()+"}</style>"),chaty_set_bg_color(),jQuery("input[name='switchPreview']:checked").trigger("change")},change:function(e){jQuery(this).val(e.toRgbString()),chaty_set_bg_color(),jQuery("#cta-box span").css("color",jQuery("#cht_cta_text_color").val()),jQuery("#cta-box span").css("background",jQuery("#cht_cta_bg_color").val()),jQuery("#custom-css").html("<style>.preview .page .chaty-widget .icon:before {border-color: transparent "+jQuery("#cht_cta_bg_color").val()+" transparent transparent } .preview .page .chaty-widget[style*='left: auto;'] .icon:before {border-color: transparent transparent transparent "+jQuery("#cht_cta_bg_color").val()+"}</style>"),jQuery("input[name='switchPreview']:checked").trigger("change")}}),jQuery(".chaty-color-field").on("change",function(){chaty_set_bg_color(),change_custom_preview()}),jQuery(".remove-chaty-img").on("click",function(e){e.stopPropagation()}),jQuery("#channels-selected-list").sortable({placeholder:"ui-chaty-state-hl",items:"li:not(#chaty-social-close)",stop:function(){e()},update:function(t,a){set_social_channel_order(),change_custom_preview(),e()}}),jQuery(document).ready(function(){e()}),jQuery(".close-button-img img, .close-button-img .image-upload").on("click",function(){var e=wp.media({title:"Upload Image",multiple:!1,library:{type:"image"}}).open().on("select",function(t){var a=e.state().get("selection").first();imageData=a.toJSON(),jQuery(".close-button-img").addClass("active"),jQuery(".close-button-img input").val(imageData.id),jQuery(".close-button-img img").attr("src",imageData.url),change_custom_preview()})}),jQuery(".remove-close-img").on("click",function(){default_image=jQuery("#default_image").val(),jQuery(".close-button-img").removeClass("active"),jQuery(".close-button-img input").val(""),jQuery(".close-button-img img").attr("src",default_image),change_custom_preview()}),jQuery(document).on("click",".chaty-widget.click",function(e){e.preventDefault(),jQuery(".chaty-widget").toggleClass("active")}),jQuery(document).on("change",".url-options.cht-required",function(e){thisVal=jQuery(this).val(),siteURL=jQuery("#chaty_site_url").val(),newURL=siteURL,"page_has_url"==thisVal?newURL=siteURL:"page_contains"==thisVal?newURL=siteURL+"%s%":"page_start_with"==thisVal?newURL=siteURL+"s%":"page_end_with"==thisVal&&(newURL=siteURL+"%s"),jQuery(this).closest(".url-content").find(".chaty-url").text(newURL)}),check_for_chaty_close_button(),chaty_set_bg_color(),change_custom_preview(),jQuery(".chaty-settings.cls-btn a, .close-btn-set").on("click",function(e){e.preventDefault(),jQuery(".cls-btn-settings, .close-btn-set").toggleClass("active")}),0==jQuery("input[name='cht_position']:checked").length&&(jQuery("#right-position").attr("checked",!0),jQuery("input[name='cht_position']:checked").trigger("change")),0==jQuery("input[name='widget_icon']:checked").length&&(jQuery("input[name='widget_icon']:first").attr("checked",!0),jQuery("input[name='widget_icon']:checked").trigger("change")),jQuery(".form-fonts").on("change",function(){var e=jQuery(this).val();jQuery(".chaty-google-font").remove(),""!=e?(jQuery(".form-fonts option:selected").data("group"),jQuery(".preview-section-chaty #admin-preview .page-body").css("font-family",e)):jQuery(".preview-section-chaty #admin-preview .page-body").attr("style","")})}),jQuery(window).on("load",function(){check_for_chaty_close_button(),chaty_set_bg_color(),jQuery(".chaty-page-options .chaty-page-option").removeClass("last"),jQuery(".chaty-page-options .chaty-page-option:last").addClass("last"),jQuery(".url-options.cht-required").each(function(){jQuery(this).trigger("change")});var e=jQuery(".form-fonts").val();jQuery(".chaty-google-font").remove(),""!=e&&(jQuery(".form-fonts option:selected").data("group"),jQuery(".preview-section-chaty #admin-preview .page-body").css("font-family",e))});var selectedsocialSlug="";function upload_chaty_image(e){selectedsocialSlug=e;var t=wp.media({title:"Upload Image",multiple:!1,library:{type:"image"}}).open().on("select",function(e){var a=t.state().get("selection").first();imageData=a.toJSON(),jQuery("#cht_social_image_"+selectedsocialSlug).val(imageData.id),jQuery(".custom-image-"+selectedsocialSlug+" img").attr("src",imageData.url),jQuery("#chaty-social-"+selectedsocialSlug+" .channels-selected__item").addClass("img-active"),change_custom_preview()})}function toggle_chaty_setting(e){if(jQuery("#chaty-social-"+e).find(".chaty-advance-settings").toggle(),jQuery("#chaty-social-"+e).find(".chaty-advance-settings").toggleClass("active"),"Contact_Us"==e&&jQuery("#Contact_Us-close-btn").length){var t=jQuery("#Contact_Us-close-btn").data("nonce");jQuery("#Contact_Us-close-btn").hasClass("active")||(jQuery("#Contact_Us-close-btn").addClass("active"),jQuery.ajax({type:"POST",url:ajaxurl,data:{nonce:t,action:"update_channel_setting"},success:function(e){}}))}jQuery("#chaty-social-"+e+" .chaty-advance-settings.active").length&&jQuery("body,html").animate({scrollTop:jQuery("#chaty-social-"+e+" .chaty-advance-settings.active").offset().top-50},500),change_custom_preview()}function chaty_set_bg_color(){jQuery(".chaty-color-field:not(.button-color)").each(function(){""!=jQuery(this).val()&&"#ffffff"!=jQuery(this).val()&&("Linkedin"!=jQuery(this).closest("li").data("id")||"Linkedin"==jQuery(this).closest("li").data("id")&&"#ffffff"!=jQuery(this).val())&&(defaultColor=jQuery(this).val(),jQuery(this).closest(".channels-selected__item").find(".color-element").css("fill",defaultColor),jQuery(this).closest(".channels-selected__item").find(".custom-chaty-image").css("background",defaultColor),jQuery(this).closest(".channels-selected__item").find(".facustom-icon").css("background",defaultColor))}),change_custom_preview()}function upload_qr_code(){var e=wp.media({title:"Upload QR Image",multiple:!1,library:{type:"image"}}).open().on("select",function(t){var a=e.state().get("selection").first();imageData=a.toJSON(),jQuery("#upload_qr_code_val").val(imageData.id),jQuery("#upload_qr_code img").attr("src",imageData.url),jQuery(".remove-qr-code").addClass("active"),change_custom_preview()})}function remove_qr_code(){jQuery(".remove-qr-code").removeClass("active"),jQuery("#upload_qr_code_val").val(""),default_image=jQuery("#default_image").val(),jQuery("#upload_qr_code img").attr("src",default_image),change_custom_preview()}function remove_chaty_image(e){default_image=jQuery("#default_image").val(),jQuery("#chaty-social-"+e+" .channels-selected__item").removeClass("img-active"),jQuery("#cht_social_image_"+e).val(""),jQuery("#cht_social_image_src_"+e).attr("src",default_image),change_custom_preview()}var baseIcon='<svg version="1.1" id="ch" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="-496 507.7 54 54" style="enable-background:new -496 507.7 54 54;" xml:space="preserve">\n <style type="text/css">.st0 {fill: #A886CD;} .st1 {fill: #FFFFFF;}\n </style><g><circle class="st0" cx="-469" cy="534.7" r="27"/></g><path class="st1" d="M-459.9,523.7h-20.3c-1.9,0-3.4,1.5-3.4,3.4v15.3c0,1.9,1.5,3.4,3.4,3.4h11.4l5.9,4.9c0.2,0.2,0.3,0.2,0.5,0.2 h0.3c0.3-0.2,0.5-0.5,0.5-0.8v-4.2h1.7c1.9,0,3.4-1.5,3.4-3.4v-15.3C-456.5,525.2-458,523.7-459.9,523.7z"/>\n <path class="st0" d="M-477.7,530.5h11.9c0.5,0,0.8,0.4,0.8,0.8l0,0c0,0.5-0.4,0.8-0.8,0.8h-11.9c-0.5,0-0.8-0.4-0.8-0.8l0,0\n C-478.6,530.8-478.2,530.5-477.7,530.5z"/>\n <path class="st0" d="M-477.7,533.5h7.9c0.5,0,0.8,0.4,0.8,0.8l0,0c0,0.5-0.4,0.8-0.8,0.8h-7.9c-0.5,0-0.8-0.4-0.8-0.8l0,0\n C-478.6,533.9-478.2,533.5-477.7,533.5z"/>\n </svg>',defaultIcon='<svg version="1.1" id="ch" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="-496 507.7 54 54" style="enable-background:new -496 507.7 54 54;" xml:space="preserve">\n <style type="text/css">.st0 {fill: #A886CD;} .st1 {fill: #FFFFFF;}\n </style><g><circle class="st0" cx="-469" cy="534.7" r="27"/></g><path class="st1" d="M-459.9,523.7h-20.3c-1.9,0-3.4,1.5-3.4,3.4v15.3c0,1.9,1.5,3.4,3.4,3.4h11.4l5.9,4.9c0.2,0.2,0.3,0.2,0.5,0.2 h0.3c0.3-0.2,0.5-0.5,0.5-0.8v-4.2h1.7c1.9,0,3.4-1.5,3.4-3.4v-15.3C-456.5,525.2-458,523.7-459.9,523.7z"/>\n <path class="st0" d="M-477.7,530.5h11.9c0.5,0,0.8,0.4,0.8,0.8l0,0c0,0.5-0.4,0.8-0.8,0.8h-11.9c-0.5,0-0.8-0.4-0.8-0.8l0,0\n C-478.6,530.8-478.2,530.5-477.7,530.5z"/>\n <path class="st0" d="M-477.7,533.5h7.9c0.5,0,0.8,0.4,0.8,0.8l0,0c0,0.5-0.4,0.8-0.8,0.8h-7.9c-0.5,0-0.8-0.4-0.8-0.8l0,0\n C-478.6,533.9-478.2,533.5-477.7,533.5z"/>\n </svg>',iconBlock=document.getElementById("iconWidget");function set_social_channel_order(){socialString=[],jQuery("#channels-selected-list li").each(function(){socialString.push(jQuery(this).attr("data-id"))}),socialString=socialString.join(","),jQuery("#cht_numb_slug").val(socialString),check_for_chaty_close_button()}function check_for_chaty_close_button(){jQuery("#channels-selected-list > li:not(.chaty-cls-setting)").length>=2?jQuery("#chaty-social-close").show():jQuery("#chaty-social-close").hide(),change_custom_preview();var e="";jQuery("#channels-selected-list > li").each(function(){"undefined"!=jQuery(this).attr("data-id")&&""!=jQuery(this).attr("data-id")&&(e+=jQuery(this).attr("data-id")+","),e=e.trimRight(",")}),jQuery(".add_slug").val(e)}function change_custom_preview(){var e,t,a=!1;jQuery("#iconWidget").removeClass("img-p-active"),getChtPreviewDesktop()?(0===jQuery(".js-chanel-desktop:checked").length&&(e=!1),1===jQuery(".js-chanel-desktop:checked").length&&(e=jQuery(".js-chanel-desktop:checked").closest("li").find(".icon.icon-md").html(),jQuery(".js-chanel-desktop:checked").closest(".channels-selected__item").hasClass("img-active")&&jQuery("#iconWidget").addClass("img-p-active")),jQuery(".js-chanel-desktop:checked").length>1&&(e=defaultIcon,a=!0)):(0===jQuery(".js-chanel-mobile:checked").length&&(t=!1),1===jQuery(".js-chanel-mobile:checked").length&&(t=jQuery(".js-chanel-mobile:checked").closest("li").find(".icon.icon-md").html(),jQuery(".js-chanel-mobile:checked").closest(".channels-selected__item").hasClass("img-active")&&jQuery("#iconWidget").addClass("img-p-active")),jQuery(".js-chanel-mobile:checked").length>1&&(t=defaultIcon,a=!0)),desktopIcon=e,mobileIcon=t,getChtPreviewDesktop()?setChtIcon(desktopIcon,a):setChtIcon(mobileIcon,a),jQuery("#channels-selected-list > li.chaty-channel").length<=1?jQuery(".o-channel, .font-section").removeClass("active"):jQuery(".o-channel, .font-section").addClass("active")}function getChtPreviewDesktop(){return!!jQuery("#previewDesktop").is(":checked")}function setChtIcon(e,t){if(jQuery("iconWidget").length){if((iconBlock=document.getElementById("iconWidget")).innerHTML=e||"",t){var a=jQuery(".color-picker-custom input").val()?jQuery(".color-picker-custom input").val():jQuery(".color-picker-radio input:checked").val();jQuery(".preview .page svg circle").css({fill:a}),jQuery("#chaty-social-close ellipse").attr("fill",a)}jQuery(".js-widget-i:checked").trigger("change")}}
|
1 |
+
function check_for_number_chaty(e,t){return!(""==e||("+"==e[0]&&(e=e.substr(1,e.length)),"Phone"==t&&"*"==e[0]&&(e=e.substr(1,e.length)),!isNaN(e)))}function check_for_preview_pos(){if(jQuery(".chaty-setting-form").length)if(jQuery(window).width()>1179){var e=parseInt(jQuery(".chaty-setting-form").offset().top);jQuery(".btn-save-sticky, .chaty-sticky-buttons").css("top",e+58),jQuery(".preview").css("top",e+18),jQuery(".btn-help").css("top",e+58+145),jQuery("a.remove-chaty-widget-sticky").css("top",e+58+145+119)}else jQuery(".btn-save-sticky, .chaty-sticky-buttons").attr("style",""),jQuery(".preview").attr("style",""),jQuery(".btn-help").attr("style",""),jQuery("a.remove-chaty-widget-sticky").attr("style","");if(jQuery("#scroll-to-item").length&&jQuery("#admin-preview").length&&((e=jQuery("body").hasClass("has-premio-box")?jQuery("#scroll-to-item").offset().top-jQuery(window).scrollTop()-625:jQuery("#scroll-to-item").offset().top-jQuery(window).scrollTop()-485)<0?(e=Math.abs(e),jQuery("#admin-preview").css("margin-top",-1*e+"px")):jQuery("#admin-preview").css("margin-top","0")),jQuery(window).height()<=1180){var t=285;jQuery(window).width()<=600&&(t=310),jQuery(".chaty-sticky-buttons").css("top",jQuery(window).height()/2-t/2+"px")}jQuery(".html-tooltip:not(.no-position)").length&&jQuery(".html-tooltip:not(.no-position)").each(function(){jQuery(this).offset().top-jQuery(window).scrollTop()>540?(jQuery(this).addClass("top").removeClass("side").removeClass("bottom"),jQuery(this).find(".tooltip-text").attr("style",""),jQuery(this).find(".tooltip-text").removeClass("hide-arrow")):jQuery(window).height()-(jQuery(this).offset().top-jQuery(window).scrollTop())>460?(jQuery(this).addClass("bottom").removeClass("top").removeClass("side"),jQuery(this).find(".tooltip-text").attr("style",""),jQuery(this).find(".tooltip-text").removeClass("hide-arrow")):(jQuery(this).addClass("side").removeClass("top").removeClass("bottom"),jQuery(this).find(".tooltip-text").length&&(jQuery(this).find(".tooltip-text").attr("style",""),jQuery(this).find(".tooltip-text").removeClass("hide-arrow"),jQuery(this).find(".tooltip-text").offset().top-jQuery(window).scrollTop()-50<0?(jQuery(this).find(".tooltip-text").css("margin-top",Math.abs(jQuery(this).find(".tooltip-text").offset().top-jQuery(window).scrollTop()-50)+"px"),jQuery(this).find(".tooltip-text").addClass("hide-arrow")):(jQuery(this).find(".tooltip-text").attr("style",""),jQuery(this).find(".tooltip-text").offset().top+parseInt(jQuery(this).find(".tooltip-text").outerHeight())-jQuery(window).scrollTop()-jQuery(window).height()>0&&(jQuery(this).find(".tooltip-text").css("margin-top",-1*Math.abs(jQuery(this).find(".tooltip-text").offset().top+parseInt(jQuery(this).find(".tooltip-text").outerHeight())-jQuery(window).scrollTop()-jQuery(window).height())-10+"px"),jQuery(this).find(".tooltip-text").addClass("hide-arrow")))))})}jQuery(function(e){"use strict";var t=!1,a=!1,o=!1,c=!1,i=!1,n=!1,s=!1;function r(){if(e(".chaty-popup").hide(),0==e("#cht-form .js-chanel-desktop").length||0==e("#cht-form .js-chanel-mobile").length)return e("#no-device-popup").show(),!1;if(0==e("#cht-form .js-chanel-desktop:checked").length&&0==e("#cht-form .js-chanel-mobile:checked").length)return e("#device-popup").show(),!1;var t=0;return e("#channels-selected-list > li:not(#chaty-social-close)").find(".channels__input").each(function(){""==jQuery.trim(e(this).val())&&t++}),t!=e("#channels-selected-list > li:not(#chaty-social-close)").find(".channels__input").length||e("#chaty-social-Contact_Us").length?l():(e("#no-device-value").show(),!1)}function l(){return e(".chaty-popup").hide(),e("#trigger_on_time").is(":checked")||e("#chaty_trigger_on_exit").is(":checked")||e("#chaty_trigger_on_scroll").is(":checked")?u():(e("#trigger-popup").show(),!1)}function u(){return e(".chaty-popup").hide(),e(".cht_active").is(":checked")?(t=!0,e("#cht-form").trigger("submit"),!0):(e("#status-popup").show(),!1)}function h(){if(a){if(o){if(c){if(i){if(n)s||(s=!0,e("#channels-selected-list .phone-number").length&&e("#channels-selected-list .phone-number").each(function(){if(""!=jQuery.trim(e(this).val())&&jQuery.trim(e(this).val()).length>13)return e("#custom-message-popup .chaty-popup-header").text(e(this).data("label")+" number is not valid"),e("#custom-message-popup .chaty-popup-body").text("Seems like the "+e(this).data("label")+" number you're trying to enter isn't valid. Would you like to publish it anyway?"),e("#custom-message-popup").show(),!1}));else if(n=!0,e("#cht-form #Viber").length&&""!=e("#cht-form #Viber").val()){t=jQuery.trim(e("#cht-form #Viber").val());if(check_for_number_chaty(t,"Viber"))return e("#custom-message-popup .chaty-popup-header").text("Viber number is not valid"),e("#custom-message-popup .chaty-popup-body").text("Seems like the Viber number you're trying to enter isn't in the right syntax. Would you like to publish it anyway?"),e("#custom-message-popup").show(),!1}}else if(i=!0,e("#cht-form #SMS").length&&""!=e("#cht-form #SMS").val()){t=jQuery.trim(e("#cht-form #SMS").val());if(check_for_number_chaty(t,"SMS"))return e("#custom-message-popup .chaty-popup-header").text("SMS number is not valid"),e("#custom-message-popup .chaty-popup-body").text("Seems like the SMS number you're trying to enter isn't in the right syntax. Would you like to publish it anyway?"),e("#custom-message-popup").show(),!1}}else if(c=!0,e("#cht-form #Facebook_Messenger").length&&""!=e("#cht-form #Facebook_Messenger").val()){var t=jQuery.trim(e("#Facebook_Messenger").val());if(e("#cht-form #Facebook_Messenger").val(t),!/(?:http:\/\/)?facebook\.com\/(?:(?:\w)*#!\/)?(?:pages\/)?(?:[\w\-]*\/)*([\w\-]*)/.test(t)&&!/(?:http:\/\/)?m\.me\/(?:(?:\w)*#!\/)?(?:pages\/)?(?:[\w\-]*\/)*([\w\-]*)/.test(t))return e("#custom-message-popup .chaty-popup-header").text("Facebook page's URL is not valid"),e("#custom-message-popup .chaty-popup-body").text("Please make sure your Facebook page's URL looks like, <br/>https://m.me/YOURPAGE"),e("#custom-message-popup").show(),!1}}else if(o=!0,e("#cht-form #Phone").length&&""!=e("#cht-form #Phone").val()){var t=jQuery.trim(e("#cht-form #Phone").val());if(check_for_number_chaty(t,"Phone"))return e("#custom-message-popup .chaty-popup-header").text("Phone number is not valid"),e("#custom-message-popup .chaty-popup-body").text("Seems like the phone number you're trying to enter isn't in the right syntax. Would you like to publish it anyway?"),e("#custom-message-popup").show(),!1}}else{a=!0;if(e("#cht-form #Whatsapp").length&&""!=e("#cht-form #Whatsapp").val()){var t=jQuery.trim(e("#cht-form #Whatsapp").val());if(check_for_number_chaty(t,"Whatsapp"))return e("#custom-message-popup .chaty-popup-header").text("Whatsapp number is not valid"),e("#custom-message-popup .chaty-popup-body").text("Seems like the WhatsApp number you're trying to enter isn't in the right syntax. Would you like to publish it anyway?"),e("#custom-message-popup").show(),!1}}return r()}e(document).ready(function(){jQuery(document).on("click","#update-chaty-traffic-source-rule",function(e){jQuery(".traffic-options-box").addClass("active"),jQuery("#chaty_traffic_source").val("yes")}),jQuery(document).on("click","#remove-traffic-rules",function(e){jQuery(".traffic-options-box").removeClass("active"),jQuery("#chaty_traffic_source").val("no")}),jQuery(document).on("click",".remove-traffic-option",function(e){jQuery(this).closest(".custom-traffic-rule").remove()}),e(document).on("click",".chaty-switch-toggle",function(){setTimeout(function(){e(".chaty-field-setting").each(function(){e(this).is(":checked")?e(this).closest(".field-setting-col").find(".field-settings").addClass("active"):e(this).closest(".field-setting-col").find(".field-settings").removeClass("active")})},100)}),e(document).on("change",".chaty-close_form_after-setting",function(){setTimeout(function(){e(".chaty-close_form_after-setting").each(function(){e(this).is(":checked")?e(this).closest(".form-field-setting-col").find(".close_form_after-settings").addClass("active"):e(this).closest(".form-field-setting-col").find(".close_form_after-settings").removeClass("active")})},100)}),e("#channel_input_Whatsapp").length&&(cht_settings.channel_settings.Whatsapp=document.querySelector("#channel_input_Whatsapp"),window.intlTelInput(cht_settings.channel_settings.Whatsapp,{dropdownContainer:document.body,formatOnDisplay:!0,hiddenInput:"full_number",initialCountry:"auto",nationalMode:!1,utilsScript:cht_settings.plugin_url+"admin/assets/js/utils.js"})),e(".custom-channel-Whatsapp:not(#channel_input_Whatsapp)").length&&e(".custom-channel-Whatsapp:not(#channel_input_Whatsapp)").each(function(){var t=e(this).closest("li.chaty-channel").data("id");null!=t&&e("#channel_input_"+t).length&&(cht_settings.channel_settings[t]=document.querySelector("#channel_input_"+t),window.intlTelInput(cht_settings.channel_settings[t],{dropdownContainer:document.body,formatOnDisplay:!0,hiddenInput:"full_number",initialCountry:"auto",nationalMode:!1,utilsScript:cht_settings.plugin_url+"admin/assets/js/utils.js"}))}),e(document).on("change",".chaty-redirect-setting",function(){setTimeout(function(){e(".chaty-redirect-setting").each(function(){e(this).is(":checked")?e(this).closest(".form-field-setting-col").find(".redirect_action-settings").addClass("active"):e(this).closest(".form-field-setting-col").find(".redirect_action-settings").removeClass("active")})},100)}),e(document).on("click",".email-setting",function(){setTimeout(function(){e(".email-setting-field").each(function(){e(this).is(":checked")?e(this).closest(".form-field-setting-col").find(".email-settings").addClass("active"):e(this).closest(".form-field-setting-col").find(".email-settings").removeClass("active")})},100)}),e(document).on("click",".chaty-embedded-window",function(){setTimeout(function(){e(".embedded_window-checkbox").each(function(){e(this).is(":checked")?e(this).closest("li.chaty-channel").find(".whatsapp-welcome-message").addClass("active"):e(this).closest("li.chaty-channel").find(".whatsapp-welcome-message").removeClass("active")})},300)}),jQuery("input[name='switchPreview']:checked").trigger("change"),e(document).on("change","#cht-form input",function(){a=!1,o=!1,c=!1,i=!1,n=!1,s=!1}),e("#cht-form").on("submit",function(){if(t)return!0;set_social_channel_order();var a=0;return e("#chaty-page-options .cht-required").length&&e("#chaty-page-options .cht-required").each(function(){""==jQuery.trim(e(this).val())&&(e(this).addClass("cht-input-error"),a++)}),e(".chaty-data-and-time-rules .cht-required").length&&e(".chaty-data-and-time-rules .cht-required").each(function(){""==jQuery.trim(e(this).val())&&(e(this).addClass("cht-input-error"),a++)}),0==a?h():(e(".cht-input-error:first").focus(),!1)}),e(".close-chaty-popup-btn").on("click",function(t){t.stopPropagation(),e(".chaty-popup").hide(),e(this).hasClass("channel-setting-btn")?e("body, html").animate({scrollTop:e("#channel-list").offset().top-125},250):e(this).hasClass("select-trigger-btn")?e("body, html").animate({scrollTop:e("#trigger-setting").offset().top-50},250):e(this).hasClass("change-status-btn")&&e("body, html").animate({scrollTop:e("#launch-section").offset().top-100},250)}),e(".chaty-popup-inner").on("click",function(e){e.stopPropagation()}),e(".chaty-popup-outer").on("click",function(t){e(".chaty-popup").hide()}),e(".check-for-numbers").on("click",function(){h()}),e(".check-for-device").on("click",function(){r()}),e(".check-for-triggers").on("click",function(){l()}),e(".check-for-status").on("click",function(){u()}),e(".change-status-and-save").on("click",function(){e(".cht_active").prop("checked",!0),t=!0,e(".chaty-popup").hide(),e("#cht-form").trigger("submit")}),e(".status-and-save").on("click",function(){e(".cht_active").prop("checked",!1),t=!0,e(".chaty-popup").hide(),e("#cht-form").trigger("submit")}),e(document).on("click",".preview-section-chaty",function(e){e.stopPropagation()}),e(document).on("click",".preview-section-overlay",function(){e(".preview-help-btn").removeClass("active"),e(".preview-section-chaty").removeClass("active"),e(".preview-section-overlay").removeClass("active")}),e(document).on("click",".preview-help-btn",function(t){return t.preventDefault(),e(this).hasClass("active")?(e(this).removeClass("active"),e(".preview-section-chaty").removeClass("active"),e(".preview-section-overlay").removeClass("active")):(e(this).addClass("active"),e(".preview-section-chaty").addClass("active"),e(".preview-section-overlay").addClass("active")),!1}),jQuery(document).on("click","#create-date-rule",function(e){jQuery("#date-schedule").addClass("active"),jQuery("#cht_date_rules").val("yes")}),jQuery(document).on("click","#remove-date-rule",function(e){jQuery("#date-schedule").removeClass("active"),jQuery("#cht_date_rules").val("no")})})}),function(e){jQuery(window).on("popstate",function(e){window.onbeforeunload=null,window.history&&window.history.pushState&&window.history.back()}),jQuery(document).ready(function(){jQuery(".chaty-table").length||jQuery("body input, body .icon, body textarea, body .btn-cancel:not(.close-btn-set) ").on("click",function(e){window.onbeforeunload=function(e){(e=e||window.event).preventDefault=!0,e.cancelBubble=!0,e.returnValue="Your beautiful goodbye message"}}),jQuery(document).on("submit","form",function(e){window.onbeforeunload=null}),jQuery(document).on("change",".channel-select-input",function(t){var a=e(this).closest("li").attr("data-id");jQuery.ajax({type:"POST",url:ajaxurl,dataType:"json",data:{social:jQuery(this).val(),channel:a,action:"get_chaty_settings"},success:function(t){1==t.status&&("Whatsapp"==t.data.slug?e("#channel_input_"+t.channel).length&&(cht_settings.channel_settings[t.channel]=document.querySelector("#channel_input_"+t.channel),window.intlTelInput(cht_settings.channel_settings[t.channel],{dropdownContainer:document.body,formatOnDisplay:!0,hiddenInput:"full_number",initialCountry:"auto",nationalMode:!1,utilsScript:cht_settings.plugin_url+"admin/assets/js/utils.js"})):e("#chaty-social-"+t.channel+" .channels__input-box").html("<input type='text' class='channels__input' name='cht_social_"+t.channel+"[value]' id='channel_input_"+t.channel+"' />"),jQuery(".custom-icon-"+t.channel+" svg").html(t.data.svg),jQuery("#chaty-social-"+t.channel).attr("data-channel",t.data.slug),jQuery("#chaty-social-"+t.channel).find(".sp-preview-inner").css("background-color",t.data.color),jQuery("#chaty-social-"+t.channel).find(".chaty-color-field").val(t.data.color),jQuery("#chaty-social-"+t.channel).find(".channels__input").attr("placeholder",t.data.placeholder),jQuery("#chaty-social-"+t.channel).find(".channel-example").text(t.data.example),jQuery("#chaty-social-"+t.channel).find(".chaty-title").val(t.data.title),jQuery("#chaty-social-"+t.channel).find(".icon").attr("data-title",t.data.title),jQuery("#chaty-social-"+t.channel).find(".chaty-color-field").trigger("change"),jQuery(".help-section").html(""),""!=t.data.help_link?jQuery(".help-section").html('<div class="viber-help"><a target="_blank" href="'+t.data.help_link+'">'+t.data.help_title+"</a></div>"):""!=t.data.help_text&&jQuery(".help-section").html('<div class="viber-help"><span class="help-text">'+t.data.help_text+'</span><span class="help-title">'+t.data.help_title+"</span></div>"))}})}),jQuery(document).on("click","#chaty_icons_view",function(e){jQuery(".page-body .chaty-widget").removeClass("vertical").removeClass("horizontal"),jQuery(".page-body .chaty-widget").addClass(jQuery(this).val())}),jQuery(".upg").on("click",function(e){jQuery(".valid_domain_input").val(jQuery(".valid_domain_input").val().replace(" ","")),/^(http(s)?:\/\/)?(www\.)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/.test(jQuery(".valid_domain_input").val())||(e.preventDefault(),jQuery(".valid_domain").fadeIn().css({display:"block"}))}),jQuery(".del_token").on("click",function(t){e.ajax({type:"POST",url:ajaxurl,data:{action:"del_token",nonce_code:cht_nonce_ajax.cht_nonce},success:function(e){location.reload()},error:function(e,t,a){}})}),jQuery(document).on("blur","#channels-selected-list > li:not(#chaty-social-close) .channels__input",function(){jQuery(this).hasClass("border-red")&&""!=jQuery(this).val()&&jQuery(this).removeClass("border-red")});var t=1000000003;jQuery(".show_up").on("click",function(){t+=10,jQuery("#upgrade-modal").css({"z-index":t,display:"block","margin-left":"-258px"})}),jQuery(".color-picker-btn, .color-picker-btn-close, .color-picker-custom button").on("click",function(e){e.preventDefault(),jQuery(".color-picker-box").toggle(),jQuery(".color-picker-btn").toggle()}),jQuery(".color-picker-radio input").on("change",function(){var e=jQuery(this);if(jQuery('.color-picker-custom input[name="cht_custom_color"]').val(""),jQuery(".color-picker-custom .circle").html("?").css({"background-color":"#fff"}),e.prop("checked")){jQuery(".color-picker-radio input").prop("checked",!1),e.prop("checked",!0);var t=e.val(),a=e.prop("title")}else t=jQuery(".color-picker-custom input").val(),a="Custom";""!=t&&-1==t.indexOf("#")&&(t="#"+t),jQuery(".color-picker-btn .circle").css({backgroundColor:t}),jQuery(".color-picker-btn .text").text(a),jQuery("#chaty-social-close ellipse").attr("fill",t)}),jQuery(".color-picker-custom input").on("change",function(){jQuery(".color-picker-radio input").prop("checked",!1);var e=jQuery(this).val();""!=e&&-1==e.indexOf("#")&&(e="#"+e),jQuery(".color-picker-btn .circle").css({backgroundColor:e}),jQuery(".color-picker-btn .text").text("Custom"),jQuery("#chaty-social-close ellipse").attr("fill",e)}),jQuery('[name="cht_position"]').on("change",function(){jQuery("#positionCustom").prop("checked")?jQuery("#positionPro").show():jQuery("#positionPro").hide()}),jQuery(".update_token").on("click",function(t){t.preventDefault();var a=jQuery('input[name="cht_token"]').val();e.ajax({type:"POST",url:ajaxurl,data:{action:"add_token",nonce_code:cht_nonce_ajax.cht_nonce,token:a},beforeSend:function(e){},success:function(e){e?(alert("Your pro plan is activated"),location.reload()):alert("You`ve entered a wrong token")},error:function(e,t,a){}})}),jQuery("textarea[name=cht_cta]").on("keyup",function(e){if(jQuery(".tooltiptext span").html(jQuery(this).val()),0==jQuery(this).val().length)jQuery(".cta").hide(200),jQuery(".tooltiptext span").hide(200);else{jQuery(".cta").show(300),jQuery(".tooltiptext span").show(200);var t=jQuery(".tooltiptext span").html();count=(t.match(/\n/g)||[]).length,count>0?jQuery(".tooltiptext").addClass("has-multiline").removeClass("line-1").removeClass("line-2").removeClass("line-3").addClass("line-"+count):jQuery(".tooltiptext").removeClass("has-multiline")}}),jQuery("textarea[name=cht_cta]").trigger("keyup")})}(jQuery),function(e){jQuery(document).ready(function(){!function(){function e(){var e=jQuery("#positionBottom"),t=jQuery("#positionSide"),a=jQuery(".preview .page .chaty-widget"),o=jQuery('[name="cht_position"]:checked').val();if("right"===o)a.css({right:"7px",left:"auto",bottom:"7px"});else if("left"===o)a.css({left:"7px",right:"auto",bottom:"7px"});else if("custom"===o){if(e.val())var c=e.val()+"px";else c="7px";if(t.val())var i=t.val()+"px";else i="7px";e.on("change",function(){c=jQuery("#positionBottom").val()+"px",a.css({bottom:c})}),t.on("change",function(){var e=jQuery('[name="positionSide"]:checked').val();i=jQuery(this).val()+"px","right"===e?(jQuery(".page-body .chaty-widget ").removeClass("chaty-widget-icons-left"),jQuery(".page-body .chaty-widget ").addClass("chaty-widget-icons-right"),a.css({right:i,left:"auto"})):"left"===e&&(jQuery(".page-body .chaty-widget ").removeClass("chaty-widget-icons-right"),jQuery(".page-body .chaty-widget ").addClass("chaty-widget-icons-left"),a.css({left:i,right:"auto"}))}),jQuery('[name="positionSide"]').on("change",function(){var e=jQuery('[name="positionSide"]:checked').val();"right"===e?(jQuery(".page-body .chaty-widget ").removeClass("chaty-widget-icons-left"),jQuery(".page-body .chaty-widget ").addClass("chaty-widget-icons-right"),a.css({right:i,left:"auto"})):"left"===e&&(jQuery(".page-body .chaty-widget ").removeClass("chaty-widget-icons-right"),jQuery(".page-body .chaty-widget ").addClass("chaty-widget-icons-left"),a.css({left:i,right:"auto"}))})}}jQuery(".color-picker-radio input").on("change",function(){var e=jQuery(this);e.prop("checked")?e.val():jQuery(".color-picker-custom input").val(),u()}),jQuery(".color-picker-custom input").on("change",function(){jQuery(this).val(),u()}),jQuery(document).on("change","#chaty_default_state",function(){u()}),jQuery("#cht_close_button, #trigger_on_time, #chaty_trigger_on_scroll").on("click",function(){u()}),function(){var e=jQuery("#widgetTooltip"),t=jQuery(".preview .page .icon");function a(){jQuery("[name=cht_cta]").length&&(jQuery("[name=cht_cta]").val().length>=1?t.removeClass("no-tooltip"):t.addClass("no-tooltip"))}a(),e.on("change",function(){a()})}(),e(),jQuery('input[name="cht_position"]').on("change",function(){var t=jQuery('[name="cht_position"]:checked').val();"right"===t?(jQuery(".page-body .chaty-widget ").removeClass("chaty-widget-icons-left"),jQuery(".page-body .chaty-widget ").addClass("chaty-widget-icons-right")):"left"===t&&(jQuery(".page-body .chaty-widget ").removeClass("chaty-widget-icons-right"),jQuery(".page-body .chaty-widget ").addClass("chaty-widget-icons-left")),e()})}(),jQuery(".popover").hide(),o();var t=jQuery(".channels-icons > .icon-sm"),a=jQuery(".social-inputs");function o(){jQuery("section").is("#pro")||(jQuery(".channels-selected__item").length<=1?(jQuery(".channels-selected__item").hide(),jQuery(".popover").hide()):jQuery(".channels-selected__item").length>=2&&jQuery(".channels-selected__item").show())}jQuery("input[name=cht_custom_color]").on("keyup",function(e){var t=jQuery(this).val();(jQuery(".circle").html(""),""!=t)&&(-1==t.indexOf("#")&&(t="#"+t),jQuery(".color-picker-custom .circle").css({"background-color":t}));jQuery(this).val().length<1&&jQuery(".color-picker-custom .circle").html("?")}),t.on("click",function(){0,o();var c=jQuery(this),i=c.data("social");a.find(".social-form-group");if(c.hasClass("active")){var n=","+jQuery(this).attr("data-social");return s=(s=jQuery(".add_slug").val()).replace(n,""),jQuery(".add_slug").val(s),s=s.replace(n,""),jQuery(".add_slug").val(s),s=s.replace(n,""),jQuery(".add_slug").val(s),s=s.replace(n,""),jQuery(".add_slug").val(s),void c.toggleClass("active")}if(t.addClass("disabled"),icon=jQuery(this).data("social"),"1"==jQuery(".add_slug").val().indexOf(icon)&&""!=jQuery(".add_slug").val()){var s;n=","+icon;s=(s=jQuery(".add_slug").val()).replace(n,""),jQuery(".add_slug").val(s),s=s.replace(n,""),jQuery(".add_slug").val(s),s=s.replace(n,""),jQuery(".add_slug").val(s)}else jQuery(".add_slug").val(jQuery(".add_slug").val()+","+jQuery(this).attr("data-social"));if(!jQuery("section").is("#pro")&&jQuery(".channels-icons > .icon.active").length>=2)return t.removeClass("disabled"),jQuery(".popover").show(),jQuery(".popover .upgrade-link").addClass("active"),void setTimeout(function(){jQuery(".popover .upgrade-link").removeClass("active")},1e3);if(c.toggleClass("active"),jQuery("section").is("#pro"))var r="pro";else r="free";e.ajax({type:"POST",dataType:"json",url:ajaxurl,data:{action:"choose_social",social:i,nonce_code:cht_nonce_ajax.cht_nonce,version:r,widget_index:jQuery("#widget_index").val()},beforeSend:function(e){},success:function(a){var c=jQuery(a),n=c.find(".icon").data("title");c.data("channel");jQuery('.channels-selected div[data-social="'+n+'"]').length||(jQuery("#chaty-social-close").before(c),jQuery("#chaty-social-"+i+" .chaty-whatsapp-setting-textarea").length&&(editorId=jQuery("#chaty-social-"+i+" .chaty-whatsapp-setting-textarea").attr("id"),tinymce.execCommand("mceAddEditor",!0,editorId))),t.removeClass("disabled"),e("#iconWidget").show(),u(),o(),set_social_channel_order(),check_for_chaty_close_button(),jQuery(".chaty-color-field").spectrum({chooseText:"Submit",preferredFormat:"hex",showInput:!0,cancelText:"Cancel",showAlpha:!0,move:function(e){jQuery(this).val(e.toRgbString()),chaty_set_bg_color(),jQuery("input[name='switchPreview']:checked").trigger("change")},change:function(e){jQuery(this).val(e.toRgbString()),chaty_set_bg_color(),jQuery("input[name='switchPreview']:checked").trigger("change")}}),check_for_chaty_close_button(),"Whatsapp"==i&&e("#channel_input_Whatsapp").length&&(cht_settings.channel_settings.Whatsapp=document.querySelector("#channel_input_Whatsapp"),window.intlTelInput(cht_settings.channel_settings.Whatsapp,{dropdownContainer:document.body,formatOnDisplay:!0,hiddenInput:"full_number",initialCountry:"auto",nationalMode:!1,utilsScript:cht_settings.plugin_url+"admin/assets/js/utils.js"})),jQuery(".custom-channel-Whatsapp").length&&jQuery(".custom-channel-Whatsapp").each(function(){if(!jQuery(this).closest(".iti__flag-container").length){var e=jQuery(this).closest("li.chaty-channel").data("id");jQuery("#channel_input_"+e).length&&(cht_settings.channel_settings[e]=document.querySelector("#channel_input_"+e),window.intlTelInput(cht_settings.channel_settings[e],{dropdownContainer:document.body,formatOnDisplay:!0,hiddenInput:"full_number",initialCountry:"auto",nationalMode:!1,utilsScript:cht_settings.plugin_url+"admin/assets/js/utils.js"}))}})},error:function(e,t,a){}}),o()}),jQuery("body").on("click",".icon, .btn-cancel:not(.close-btn-set)",function(e){if(!jQuery(this).hasClass("close-btn-set")&&(e.preventDefault(),!jQuery(this).hasClass("icon")||!jQuery(this).hasClass("active"))){if(icon=jQuery(this).data("social"),jQuery(this).hasClass("btn-cancel")){jQuery('.icon.active[data-social^="'+icon+'"]').removeClass("active");var t=","+icon,a=jQuery(".add_slug").val();a=a.replace(t,""),jQuery(".add_slug").val(a)}jQuery("#chaty-social-"+icon).remove();jQuery(this).parent(".channels-selected__item"),jQuery(this).data("social");u(),o(),set_social_channel_order(),check_for_chaty_close_button()}}),jQuery(".btn-help").on("click",function(e){window.open("https://premio.io/help/chaty/","_blank")}),jQuery(".free-custom-radio, .free-custom-checkbox").on("click",function(e){e.preventDefault()});var c=jQuery("[name=cht_cta]"),i=jQuery(".preview .tooltip-show");c.on("keyup",function(){var e=jQuery(".preview .page .icon");c.val().length>=1?e.removeClass("no-tooltip"):e.addClass("no-tooltip"),i.attr("data-title",c.val())});var n,s,r='<svg version="1.1" id="ch" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="-496 507.7 54 54" style="enable-background:new -496 507.7 54 54;" xml:space="preserve">\n <style type="text/css">.st0 {fill: #A886CD;} .st1 {fill: #FFFFFF;}\n </style><g><circle class="st0" cx="-469" cy="534.7" r="27"/></g><path class="st1" d="M-459.9,523.7h-20.3c-1.9,0-3.4,1.5-3.4,3.4v15.3c0,1.9,1.5,3.4,3.4,3.4h11.4l5.9,4.9c0.2,0.2,0.3,0.2,0.5,0.2 h0.3c0.3-0.2,0.5-0.5,0.5-0.8v-4.2h1.7c1.9,0,3.4-1.5,3.4-3.4v-15.3C-456.5,525.2-458,523.7-459.9,523.7z"/>\n <path class="st0" d="M-477.7,530.5h11.9c0.5,0,0.8,0.4,0.8,0.8l0,0c0,0.5-0.4,0.8-0.8,0.8h-11.9c-0.5,0-0.8-0.4-0.8-0.8l0,0\n C-478.6,530.8-478.2,530.5-477.7,530.5z"/>\n <path class="st0" d="M-477.7,533.5h7.9c0.5,0,0.8,0.4,0.8,0.8l0,0c0,0.5-0.4,0.8-0.8,0.8h-7.9c-0.5,0-0.8-0.4-0.8-0.8l0,0\n C-478.6,533.9-478.2,533.5-477.7,533.5z"/>\n </svg>',l=document.getElementById("iconWidget");jQuery(".color-picker-radio input:checked").val();function u(){var t,a,o=!1;if(jQuery(".single-channel-setting").addClass("active"),jQuery("#iconWidget").removeClass("img-p-active"),d()?(0===jQuery(".js-chanel-desktop:checked").length?(t=!1,jQuery(".page-body .chaty-widget").hide()):jQuery(".page-body .chaty-widget").show(),1===jQuery(".js-chanel-desktop:checked").length&&(t=jQuery(".js-chanel-desktop:checked").closest("li").find(".icon.icon-md").html(),jQuery(".js-chanel-desktop:checked").closest(".channels-selected__item").hasClass("img-active")&&jQuery("#iconWidget").addClass("img-p-active")),jQuery(".js-chanel-desktop:checked").length>1&&(t=r,o=!0)):(0===jQuery(".js-chanel-mobile:checked").length?(a=!1,jQuery(".page-body .chaty-widget").hide()):jQuery(".page-body .chaty-widget").show(),1===jQuery(".js-chanel-mobile:checked").length&&(a=jQuery(".js-chanel-mobile:checked").closest("li").find(".icon.icon-md").html(),jQuery(".js-chanel-mobile:checked").closest(".channels-selected__item").hasClass("img-active")&&jQuery("#iconWidget").addClass("img-p-active")),jQuery(".js-chanel-mobile:checked").length>1&&(a=r,o=!0)),n=t,s=a,d()?h(n,o):h(s,o),e("#iconWidget .pop-number").remove(),jQuery("#cht_pending_messages").is(":checked")){var c=jQuery("#cht_number_of_messages").val();""!=c&&c>0&&(e("#iconWidget").append("<span class='pop-number'>"+c+"</span>"),e("#iconWidget .pop-number").css("color",jQuery("#cht_number_color").val()),e("#iconWidget .pop-number").css("background",jQuery("#cht_number_bg_color").val()))}var i=".js-chanel-mobile";if(d())i=".js-chanel-desktop";"open"==jQuery("#chaty_default_state").val()&&jQuery(i+":checked").length>1&&e("#iconWidget .pop-number").remove(),e("#cta-box span").css("color",e("#cht_cta_text_color").val()),e("#cta-box span").css("background",e("#cht_cta_bg_color").val()),e("#custom-css").html("<style>.preview .page .chaty-widget .icon:before {border-color: transparent "+e("#cht_cta_bg_color").val()+" transparent transparent } .preview .page .chaty-widget[style*='left: auto;'] .icon:before {border-color: transparent transparent transparent "+e("#cht_cta_bg_color").val()+"}</style>"),jQuery(".single-channel-setting").addClass("active"),1===jQuery("#channel-list .icon.active").length&&(jQuery(".single-channel-setting").removeClass("active"),"open"==jQuery("#chaty_default_state").val()&&jQuery(".hide-show-button").removeClass("active"))}function h(e,t){if(jQuery("#iconWidget").length){if(l.innerHTML=e||"",t){var a=jQuery(".color-picker-custom input").val()?jQuery(".color-picker-custom input").val():jQuery(".color-picker-radio input:checked").val();if(""!=a)-1==a.indexOf("#")&&(a="#"+a);jQuery(".preview .page #iconWidget svg circle").css({fill:a}),jQuery(".preview .page .chaty-close-icon ellipse").css({fill:a}),jQuery("#chaty-social-close ellipse").attr("fill",a)}thisVal=jQuery("#chaty_default_state").val(),"open"==thisVal?jQuery(".hide-show-button").addClass("active"):jQuery(".hide-show-button").removeClass("active"),jQuery(".chaty-widget").removeClass("active").removeClass("hover").removeClass("click").removeClass("hide_arrow"),"open"==thisVal?(jQuery(".chaty-widget").addClass("active").addClass("click"),"open"==thisVal&&jQuery(o+":checked").length>1&&jQuery(".chaty-widget").addClass("hide_arrow")):"hover"==thisVal?jQuery(".chaty-widget").addClass("hover"):jQuery(".chaty-widget").addClass("click"),jQuery(".chaty-channels").html("");var o=".js-chanel-mobile";if(d())o=".js-chanel-desktop";"open"==thisVal&&jQuery(o+":checked").length>1?(jQuery("#chaty_attention_effect").val(""),jQuery("#chaty_attention_effect, .test_textarea").attr("disabled",!0),jQuery("#chaty_attention_effect option:first-child").text("Doesn't apply for the open state"),"Doesn't apply for the open state"!=jQuery(".test_textarea").val()&&jQuery(".test_textarea").attr("data-value",jQuery(".test_textarea").val()),jQuery(".test_textarea").val("Doesn't apply for the open state"),jQuery("#cht_number_of_messages").attr("disabled",!0),jQuery("#cht_pending_messages").attr("disabled",!0),jQuery(".disable-message").addClass("label-tooltip").addClass("icon"),jQuery("#cht_pending_messages").attr("checked",!1),jQuery(".pending-message-items").removeClass("active"),jQuery(".cta-action-radio input").attr("disabled",!0)):(jQuery("#chaty_attention_effect, .test_textarea").attr("disabled",!1),jQuery("#chaty_attention_effect option:first-child").text("None"),jQuery(".test_textarea").attr("placeholder",""),"Doesn't apply for the open state"==jQuery(".test_textarea").val()&&jQuery(".test_textarea").val(jQuery(".test_textarea").attr("data-value")),jQuery("#cht_number_of_messages").attr("disabled",!1),jQuery("#cht_pending_messages").attr("disabled",!1),jQuery(".disable-message").removeClass("label-tooltip").removeClass("icon"),jQuery(".cta-action-radio input").attr("disabled",!1)),jQuery(".page-body .chaty-widget").removeClass("vertical").removeClass("horizontal"),jQuery(o+":checked").length>1?(jQuery(o+":checked").each(function(){var e=jQuery(this).closest("li").find(".icon").html(),t=(e=jQuery(this).closest("li").find(".icon").html(),jQuery(this).closest("li").find(".chaty-title").val()),a=jQuery(this).closest(".channels-selected__item").hasClass("img-active")?"img-active":"";""!=t&&(t="<span class='social-tooltip'>"+t+"</span>"),jQuery(".chaty-channels").append("<div class='social-item-box "+a+"'><span class='tooltip-icon'>"+e+"</span>"+t+"</div>")}),"open"==jQuery("#chaty_default_state").val()&&jQuery("#cht_close_button").is(":checked")?(jQuery("#iconWidget").css("display","block"),jQuery(".chaty-widget .tooltiptext").css("display","block"),jQuery(".chaty-widget").removeClass("hide-arrow")):"open"!=jQuery("#chaty_default_state").val()?(jQuery("#iconWidget").css("display","block"),jQuery(".chaty-widget .tooltiptext").css("display","block"),jQuery(".chaty-widget").removeClass("hide-arrow")):"open"==jQuery("#chaty_default_state").val()&&(jQuery("#iconWidget").hide(),jQuery(".chaty-widget .tooltiptext").hide(),jQuery(".chaty-widget").addClass("hide-arrow")),jQuery(".chaty-widget").removeClass("has-single"),jQuery(".page-body .chaty-widget").addClass(jQuery("#chaty_icons_view").val())):1==jQuery(o+":checked").length?("open"!=jQuery("#chaty_default_state").val()||jQuery("#cht_close_button").is(":checked")?"open"!=jQuery("#chaty_default_state").val()&&(jQuery("#iconWidget").css("display","block"),jQuery(".chaty-widget .tooltiptext").css("display","block"),jQuery(".chaty-widget").removeClass("hide-arrow")):(jQuery("#iconWidget").css("display","block"),jQuery(".chaty-widget .tooltiptext").css("display","block"),jQuery(".chaty-widget").removeClass("hide-arrow")),jQuery(".chaty-widget").addClass("has-single"),jQuery(".chaty-widget").removeClass("hide-arrow")):0==jQuery(o+":checked").length&&(jQuery("#iconWidget").hide(),jQuery(".chaty-widget .tooltiptext").hide(),jQuery(".chaty-widget").addClass("hide-arrow"),jQuery(".chaty-widget").removeClass("has-single")),jQuery(".chaty-channels .remove-icon-img").remove(),jQuery("#trigger_on_time").is(":checked")?jQuery("#chaty_trigger_time").attr("readonly",!1):jQuery("#chaty_trigger_time").attr("readonly",!0),jQuery("#chaty_trigger_on_scroll").is(":checked")?jQuery("#chaty_trigger_on_page_scroll").attr("readonly",!1):jQuery("#chaty_trigger_on_page_scroll").attr("readonly",!0),""==jQuery(".chaty-widget .tooltiptext").text()?jQuery(".chaty-widget .tooltiptext").hide():"open"==jQuery("#chaty_default_state").val()&&jQuery(o+":checked").length>1?jQuery(".chaty-widget .tooltiptext").hide():jQuery(".chaty-widget .tooltiptext").css("display","block")}}function d(){return!!jQuery("#previewDesktop").is(":checked")}jQuery("#testUpload").on("change",function(){this.value.length>0?document.querySelector(".js-upload").disabled=!1:(document.querySelector(".js-upload").disabled=!0,document.getElementById("uploadInput").checked=!1)}),jQuery(document).on("keyup","textarea.test_textarea",function(){u()}),jQuery(".js-switch-preview").on("change",function(){d()?jQuery(this).closest(".preview").removeClass("mobiel-view"):jQuery(this).closest(".preview").addClass("mobiel-view"),u()}),jQuery(document).on("change","input[name='cht_pending_messages']",function(){jQuery("#cht_pending_messages").is(":checked")?jQuery(".pending-message-items").addClass("active"):jQuery(".pending-message-items").removeClass("active"),u()}),jQuery(document).on("change","#cht_number_of_messages",function(){u()}),jQuery(document).on("keyup","#cht_number_of_messages",function(){u()}),jQuery(document).on("blur","#cht_number_of_messages",function(){u()}),jQuery(document).on("change",".js-chanel-icon",function(){u()}),jQuery(document).on("change",".js-widget-i",function(e){r=e.target.classList.contains("js-upload")?jQuery(".file-preview-image").last().parent().html():jQuery("i[data-type="+jQuery(".js-widget-i:checked").val()+"]").html(),u()}),"chat-image"!==jQuery(".js-widget-i:checked").attr("data-type")&&(r=jQuery("i[data-type="+jQuery(".js-widget-i:checked").attr("data-type")+"]").html(),u())}),jQuery(document).ready(function(){jQuery(".toast-message").length&&(jQuery(".toast-message").show(),jQuery(".toast-message").addClass("active"),setTimeout(function(){jQuery(".toast-message").removeClass("active")},5e3)),jQuery(document).on("click",".toast-close-btn a",function(e){e.preventDefault(),jQuery(".toast-message").removeClass("active")}),jQuery(document).on("click",".chaty-popup-box button, #chaty-intro-popup",function(t){t.stopPropagation();var a=jQuery("#chaty_update_popup_status").val();e("#chaty-intro-popup").remove(),e.ajax({type:"POST",url:ajaxurl,data:{action:"update_popup_status",nonce:a},beforeSend:function(e){},success:function(e){},error:function(e,t,a){}})}),jQuery(document).on("click",".chaty-popup-box",function(e){e.stopPropagation()}),jQuery(document).on("click",".remove-chaty-options",function(t){t.preventDefault(),t.stopPropagation(),confirm("Are you sure you want to delete this widget?")&&e.ajax({type:"POST",url:ajaxurl,data:{action:"remove_chaty_widget",nonce_code:cht_nonce_ajax.cht_nonce,widget_index:jQuery("#widget_index").val()},beforeSend:function(e){},success:function(e){window.location=e},error:function(e,t,a){}})});window.location.href;window.location.href.indexOf("page=chaty-app&widget=")>-1&&jQuery("#toplevel_page_chaty-app .wp-submenu.wp-submenu-wrap li").each(function(){var e=jQuery(this).find("a").attr("href");void 0!==e&&(jQuery(this).removeClass("current"),window.location.href.indexOf(e)>-1&&e.indexOf("&widget=")>-1&&jQuery(this).addClass("current"))})})}(jQuery),jQuery(window).on("resize",function(){check_for_preview_pos()}),jQuery(window).on("scroll",function(){check_for_preview_pos()}),jQuery(document).ready(function(){check_for_preview_pos()});var totalPageOptions=0,pageOptionContent="",totalDateAndTimeOptions=0,dateAndTimeOptionContent="";jQuery(document).ready(function(){var e=!1;function t(){jQuery(".chaty-whatsapp-setting-textarea").length&&jQuery(".chaty-whatsapp-setting-textarea").each(function(){jQuery("#cht_social_embedded_message_"+jQuery(this).data("id")+"_ifr").length&&tinymce.get(jQuery(this).attr("id")).remove(),tinymce.execCommand("mceAddEditor",!0,jQuery(this).attr("id"))})}(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(navigator.userAgent.substr(0,4)))&&(e=!0),totalPageOptions=parseInt(jQuery(".chaty-page-option").length),pageOptionContent=jQuery(".chaty-page-options-html").html(),jQuery(".chaty-page-options-html").remove(),totalDateAndTimeOptions=parseInt(jQuery(".chaty-date-time-option").length),dateAndTimeOptionContent=jQuery(".chaty-date-and-time-options-html").html(),jQuery(".chaty-date-and-time-options-html").remove(),jQuery("#create-rule").on("click",function(){jQuery(".page-options").toggle()}),jQuery("#create-data-and-time-rule").on("click",function(){jQuery(".chaty-data-and-time-rules").toggle()}),jQuery(document).on("change","#chaty_attention_effect",function(){var e=jQuery(this).attr("data-effect");""!=e&&jQuery("#iconWidget").removeClass("chaty-animation-"+e),jQuery("#iconWidget").removeClass("start-now"),jQuery("#iconWidget").addClass("chaty-animation-"+jQuery(this).val()).addClass("start-now"),jQuery(this).attr("data-effect",jQuery(this).val())}),setInterval(function(){var e=jQuery("#chaty_attention_effect").attr("data-effect");""!=e?(jQuery("#iconWidget").removeClass("chaty-animation-"+e),jQuery("#iconWidget").removeClass("start-now"),setTimeout(function(){jQuery("#iconWidget").addClass("chaty-animation-"+jQuery("#chaty_attention_effect").val()).addClass("start-now")},1e3)):jQuery("#chaty_attention_effect").attr("data-effect",jQuery("#chaty_attention_effect").val())},5e3),jQuery(document).on("click",".remove-chaty",function(){jQuery(".page-options").toggle()}),jQuery(document).on("click",".remove-page-option",function(){jQuery(".chaty-data-and-time-rules ").toggle()}),jQuery("#image-upload-content .custom-control-label").on("click",function(e){return e.stopPropagation(),jQuery(this).closest(".custom-control").find("input[type=radio]").attr("checked",!0),jQuery(".js-widget-i").trigger("change"),!1}),jQuery(".chaty-color-field").spectrum({chooseText:"Submit",preferredFormat:"hex",cancelText:"Cancel",showInput:!0,showAlpha:!0,move:function(e){jQuery(this).val(e.toRgbString()),jQuery("#cta-box span").css("color",jQuery("#cht_cta_text_color").val()),jQuery("#cta-box span").css("background",jQuery("#cht_cta_bg_color").val()),jQuery("#custom-css").html("<style>.preview .page .chaty-widget .icon:before {border-color: transparent "+jQuery("#cht_cta_bg_color").val()+" transparent transparent } .preview .page .chaty-widget[style*='left: auto;'] .icon:before {border-color: transparent transparent transparent "+jQuery("#cht_cta_bg_color").val()+"}</style>"),chaty_set_bg_color(),jQuery("input[name='switchPreview']:checked").trigger("change")},change:function(e){jQuery(this).val(e.toRgbString()),chaty_set_bg_color(),jQuery("#cta-box span").css("color",jQuery("#cht_cta_text_color").val()),jQuery("#cta-box span").css("background",jQuery("#cht_cta_bg_color").val()),jQuery("#custom-css").html("<style>.preview .page .chaty-widget .icon:before {border-color: transparent "+jQuery("#cht_cta_bg_color").val()+" transparent transparent } .preview .page .chaty-widget[style*='left: auto;'] .icon:before {border-color: transparent transparent transparent "+jQuery("#cht_cta_bg_color").val()+"}</style>"),jQuery("input[name='switchPreview']:checked").trigger("change")}}),jQuery(".chaty-color-field").on("change",function(){chaty_set_bg_color(),change_custom_preview()}),jQuery(".remove-chaty-img").on("click",function(e){e.stopPropagation()}),e||jQuery("#channels-selected-list").sortable({placeholder:"ui-chaty-state-hl",items:"li:not(#chaty-social-close)",stop:function(){t()},update:function(e,a){set_social_channel_order(),change_custom_preview(),t()}}),jQuery(document).ready(function(){t()}),jQuery(".close-button-img img, .close-button-img .image-upload").on("click",function(){var e=wp.media({title:"Upload Image",multiple:!1,library:{type:"image"}}).open().on("select",function(t){var a=e.state().get("selection").first();imageData=a.toJSON(),jQuery(".close-button-img").addClass("active"),jQuery(".close-button-img input").val(imageData.id),jQuery(".close-button-img img").attr("src",imageData.url),change_custom_preview()})}),jQuery(".remove-close-img").on("click",function(){default_image=jQuery("#default_image").val(),jQuery(".close-button-img").removeClass("active"),jQuery(".close-button-img input").val(""),jQuery(".close-button-img img").attr("src",default_image),change_custom_preview()}),jQuery(document).on("click",".chaty-widget.click",function(e){e.preventDefault(),jQuery(".chaty-widget").toggleClass("active")}),jQuery(document).on("change",".url-options.cht-required",function(e){thisVal=jQuery(this).val(),siteURL=jQuery("#chaty_site_url").val(),newURL=siteURL,"page_has_url"==thisVal?newURL=siteURL:"page_contains"==thisVal?newURL=siteURL+"%s%":"page_start_with"==thisVal?newURL=siteURL+"s%":"page_end_with"==thisVal&&(newURL=siteURL+"%s"),jQuery(this).closest(".url-content").find(".chaty-url").text(newURL)}),check_for_chaty_close_button(),chaty_set_bg_color(),change_custom_preview(),jQuery(".chaty-settings.cls-btn a, .close-btn-set").on("click",function(e){e.preventDefault(),jQuery(".cls-btn-settings, .close-btn-set").toggleClass("active")}),0==jQuery("input[name='cht_position']:checked").length&&(jQuery("#right-position").attr("checked",!0),jQuery("input[name='cht_position']:checked").trigger("change")),0==jQuery("input[name='widget_icon']:checked").length&&(jQuery("input[name='widget_icon']:first").attr("checked",!0),jQuery("input[name='widget_icon']:checked").trigger("change")),jQuery(".form-fonts").on("change",function(){var e=jQuery(this).val();jQuery(".chaty-google-font").remove(),""!=e?(jQuery(".form-fonts option:selected").data("group"),jQuery(".preview-section-chaty #admin-preview .page-body").css("font-family",e)):jQuery(".preview-section-chaty #admin-preview .page-body").attr("style","")})}),jQuery(window).on("load",function(){check_for_chaty_close_button(),chaty_set_bg_color(),jQuery(".chaty-page-options .chaty-page-option").removeClass("last"),jQuery(".chaty-page-options .chaty-page-option:last").addClass("last"),jQuery(".url-options.cht-required").each(function(){jQuery(this).trigger("change")});var e=jQuery(".form-fonts").val();jQuery(".chaty-google-font").remove(),""!=e&&(jQuery(".form-fonts option:selected").data("group"),jQuery(".preview-section-chaty #admin-preview .page-body").css("font-family",e))});var selectedsocialSlug="";function upload_chaty_image(e){selectedsocialSlug=e;var t=wp.media({title:"Upload Image",multiple:!1,library:{type:"image"}}).open().on("select",function(e){var a=t.state().get("selection").first();imageData=a.toJSON(),jQuery("#cht_social_image_"+selectedsocialSlug).val(imageData.id),jQuery(".custom-image-"+selectedsocialSlug+" img").attr("src",imageData.url),jQuery("#chaty-social-"+selectedsocialSlug+" .channels-selected__item").addClass("img-active"),change_custom_preview()})}function toggle_chaty_setting(e){if(jQuery("#chaty-social-"+e).find(".chaty-advance-settings").toggle(),jQuery("#chaty-social-"+e).find(".chaty-advance-settings").toggleClass("active"),"Contact_Us"==e&&jQuery("#Contact_Us-close-btn").length){var t=jQuery("#Contact_Us-close-btn").data("nonce");jQuery("#Contact_Us-close-btn").hasClass("active")||(jQuery("#Contact_Us-close-btn").addClass("active"),jQuery.ajax({type:"POST",url:ajaxurl,data:{nonce:t,action:"update_channel_setting"},success:function(e){}}))}jQuery("#chaty-social-"+e+" .chaty-advance-settings.active").length&&jQuery("body,html").animate({scrollTop:jQuery("#chaty-social-"+e+" .chaty-advance-settings.active").offset().top-50},500),change_custom_preview()}function chaty_set_bg_color(){jQuery(".chaty-color-field:not(.button-color)").each(function(){""!=jQuery(this).val()&&"#ffffff"!=jQuery(this).val()&&("Linkedin"!=jQuery(this).closest("li").data("id")||"Linkedin"==jQuery(this).closest("li").data("id")&&"#ffffff"!=jQuery(this).val())&&(defaultColor=jQuery(this).val(),jQuery(this).closest(".channels-selected__item").find(".color-element").css("fill",defaultColor),jQuery(this).closest(".channels-selected__item").find(".custom-chaty-image").css("background",defaultColor),jQuery(this).closest(".channels-selected__item").find(".facustom-icon").css("background",defaultColor))}),change_custom_preview()}function upload_qr_code(){var e=wp.media({title:"Upload QR Image",multiple:!1,library:{type:"image"}}).open().on("select",function(t){var a=e.state().get("selection").first();imageData=a.toJSON(),jQuery("#upload_qr_code_val").val(imageData.id),jQuery("#upload_qr_code img").attr("src",imageData.url),jQuery(".remove-qr-code").addClass("active"),change_custom_preview()})}function remove_qr_code(){jQuery(".remove-qr-code").removeClass("active"),jQuery("#upload_qr_code_val").val(""),default_image=jQuery("#default_image").val(),jQuery("#upload_qr_code img").attr("src",default_image),change_custom_preview()}function remove_chaty_image(e){default_image=jQuery("#default_image").val(),jQuery("#chaty-social-"+e+" .channels-selected__item").removeClass("img-active"),jQuery("#cht_social_image_"+e).val(""),jQuery("#cht_social_image_src_"+e).attr("src",default_image),change_custom_preview()}var baseIcon='<svg version="1.1" id="ch" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="-496 507.7 54 54" style="enable-background:new -496 507.7 54 54;" xml:space="preserve">\n <style type="text/css">.st0 {fill: #A886CD;} .st1 {fill: #FFFFFF;}\n </style><g><circle class="st0" cx="-469" cy="534.7" r="27"/></g><path class="st1" d="M-459.9,523.7h-20.3c-1.9,0-3.4,1.5-3.4,3.4v15.3c0,1.9,1.5,3.4,3.4,3.4h11.4l5.9,4.9c0.2,0.2,0.3,0.2,0.5,0.2 h0.3c0.3-0.2,0.5-0.5,0.5-0.8v-4.2h1.7c1.9,0,3.4-1.5,3.4-3.4v-15.3C-456.5,525.2-458,523.7-459.9,523.7z"/>\n <path class="st0" d="M-477.7,530.5h11.9c0.5,0,0.8,0.4,0.8,0.8l0,0c0,0.5-0.4,0.8-0.8,0.8h-11.9c-0.5,0-0.8-0.4-0.8-0.8l0,0\n C-478.6,530.8-478.2,530.5-477.7,530.5z"/>\n <path class="st0" d="M-477.7,533.5h7.9c0.5,0,0.8,0.4,0.8,0.8l0,0c0,0.5-0.4,0.8-0.8,0.8h-7.9c-0.5,0-0.8-0.4-0.8-0.8l0,0\n C-478.6,533.9-478.2,533.5-477.7,533.5z"/>\n </svg>',defaultIcon='<svg version="1.1" id="ch" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="-496 507.7 54 54" style="enable-background:new -496 507.7 54 54;" xml:space="preserve">\n <style type="text/css">.st0 {fill: #A886CD;} .st1 {fill: #FFFFFF;}\n </style><g><circle class="st0" cx="-469" cy="534.7" r="27"/></g><path class="st1" d="M-459.9,523.7h-20.3c-1.9,0-3.4,1.5-3.4,3.4v15.3c0,1.9,1.5,3.4,3.4,3.4h11.4l5.9,4.9c0.2,0.2,0.3,0.2,0.5,0.2 h0.3c0.3-0.2,0.5-0.5,0.5-0.8v-4.2h1.7c1.9,0,3.4-1.5,3.4-3.4v-15.3C-456.5,525.2-458,523.7-459.9,523.7z"/>\n <path class="st0" d="M-477.7,530.5h11.9c0.5,0,0.8,0.4,0.8,0.8l0,0c0,0.5-0.4,0.8-0.8,0.8h-11.9c-0.5,0-0.8-0.4-0.8-0.8l0,0\n C-478.6,530.8-478.2,530.5-477.7,530.5z"/>\n <path class="st0" d="M-477.7,533.5h7.9c0.5,0,0.8,0.4,0.8,0.8l0,0c0,0.5-0.4,0.8-0.8,0.8h-7.9c-0.5,0-0.8-0.4-0.8-0.8l0,0\n C-478.6,533.9-478.2,533.5-477.7,533.5z"/>\n </svg>',iconBlock=document.getElementById("iconWidget");function set_social_channel_order(){socialString=[],jQuery("#channels-selected-list li").each(function(){socialString.push(jQuery(this).attr("data-id"))}),socialString=socialString.join(","),jQuery("#cht_numb_slug").val(socialString),check_for_chaty_close_button()}function check_for_chaty_close_button(){jQuery("#channels-selected-list > li:not(.chaty-cls-setting)").length>=2?jQuery("#chaty-social-close").show():jQuery("#chaty-social-close").hide(),change_custom_preview();var e="";jQuery("#channels-selected-list > li").each(function(){"undefined"!=jQuery(this).attr("data-id")&&""!=jQuery(this).attr("data-id")&&(e+=jQuery(this).attr("data-id")+","),e=e.trimRight(",")}),jQuery(".add_slug").val(e)}function change_custom_preview(){var e,t,a=!1;jQuery("#iconWidget").removeClass("img-p-active"),getChtPreviewDesktop()?(0===jQuery(".js-chanel-desktop:checked").length&&(e=!1),1===jQuery(".js-chanel-desktop:checked").length&&(e=jQuery(".js-chanel-desktop:checked").closest("li").find(".icon.icon-md").html(),jQuery(".js-chanel-desktop:checked").closest(".channels-selected__item").hasClass("img-active")&&jQuery("#iconWidget").addClass("img-p-active")),jQuery(".js-chanel-desktop:checked").length>1&&(e=defaultIcon,a=!0)):(0===jQuery(".js-chanel-mobile:checked").length&&(t=!1),1===jQuery(".js-chanel-mobile:checked").length&&(t=jQuery(".js-chanel-mobile:checked").closest("li").find(".icon.icon-md").html(),jQuery(".js-chanel-mobile:checked").closest(".channels-selected__item").hasClass("img-active")&&jQuery("#iconWidget").addClass("img-p-active")),jQuery(".js-chanel-mobile:checked").length>1&&(t=defaultIcon,a=!0)),desktopIcon=e,mobileIcon=t,getChtPreviewDesktop()?setChtIcon(desktopIcon,a):setChtIcon(mobileIcon,a),jQuery("#channels-selected-list > li.chaty-channel").length<=1?jQuery(".o-channel, .font-section").removeClass("active"):jQuery(".o-channel, .font-section").addClass("active")}function getChtPreviewDesktop(){return!!jQuery("#previewDesktop").is(":checked")}function setChtIcon(e,t){if(jQuery("iconWidget").length){if((iconBlock=document.getElementById("iconWidget")).innerHTML=e||"",t){var a=jQuery(".color-picker-custom input").val()?jQuery(".color-picker-custom input").val():jQuery(".color-picker-radio input:checked").val();jQuery(".preview .page #iconWidget svg circle").css({fill:a}),jQuery(".preview .page .chaty-close-icon ellipse").css({fill:a}),jQuery("#chaty-social-close ellipse").attr("fill",a)}jQuery(".js-widget-i:checked").trigger("change")}}
|
admin/assets/js/spectrum.js
ADDED
@@ -0,0 +1,2408 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// Spectrum Colorpicker v1.8.1
|
2 |
+
// https://github.com/bgrins/spectrum
|
3 |
+
// Author: Brian Grinstead
|
4 |
+
// License: MIT
|
5 |
+
|
6 |
+
(function (factory) {
|
7 |
+
"use strict";
|
8 |
+
|
9 |
+
if (typeof define === 'function' && define.amd) { // AMD
|
10 |
+
define(['jquery'], factory);
|
11 |
+
}
|
12 |
+
else if (typeof exports == "object" && typeof module == "object") { // CommonJS
|
13 |
+
module.exports = factory(require('jquery'));
|
14 |
+
}
|
15 |
+
else { // Browser
|
16 |
+
factory(jQuery);
|
17 |
+
}
|
18 |
+
})(function($, undefined) {
|
19 |
+
"use strict";
|
20 |
+
|
21 |
+
var defaultOpts = {
|
22 |
+
|
23 |
+
// Callbacks
|
24 |
+
beforeShow: noop,
|
25 |
+
move: noop,
|
26 |
+
change: noop,
|
27 |
+
show: noop,
|
28 |
+
hide: noop,
|
29 |
+
|
30 |
+
// Options
|
31 |
+
color: false,
|
32 |
+
flat: false,
|
33 |
+
showInput: false,
|
34 |
+
allowEmpty: false,
|
35 |
+
showButtons: true,
|
36 |
+
clickoutFiresChange: true,
|
37 |
+
showInitial: false,
|
38 |
+
showPalette: false,
|
39 |
+
showPaletteOnly: false,
|
40 |
+
hideAfterPaletteSelect: false,
|
41 |
+
togglePaletteOnly: false,
|
42 |
+
showSelectionPalette: true,
|
43 |
+
localStorageKey: false,
|
44 |
+
appendTo: "body",
|
45 |
+
maxSelectionSize: 7,
|
46 |
+
cancelText: "cancel",
|
47 |
+
chooseText: "choose",
|
48 |
+
togglePaletteMoreText: "more",
|
49 |
+
togglePaletteLessText: "less",
|
50 |
+
clearText: "Clear Color Selection",
|
51 |
+
noColorSelectedText: "No Color Selected",
|
52 |
+
preferredFormat: false,
|
53 |
+
className: "", // Deprecated - use containerClassName and replacerClassName instead.
|
54 |
+
containerClassName: "",
|
55 |
+
replacerClassName: "",
|
56 |
+
showAlpha: false,
|
57 |
+
theme: "sp-light",
|
58 |
+
palette: [["#ffffff", "#000000", "#ff0000", "#ff8000", "#ffff00", "#008000", "#0000ff", "#4b0082", "#9400d3"]],
|
59 |
+
selectionPalette: [],
|
60 |
+
disabled: false,
|
61 |
+
offset: null
|
62 |
+
},
|
63 |
+
spectrums = [],
|
64 |
+
IE = !!/msie/i.exec( window.navigator.userAgent ),
|
65 |
+
rgbaSupport = (function() {
|
66 |
+
function contains( str, substr ) {
|
67 |
+
return !!~('' + str).indexOf(substr);
|
68 |
+
}
|
69 |
+
|
70 |
+
var elem = document.createElement('div');
|
71 |
+
var style = elem.style;
|
72 |
+
style.cssText = 'background-color:rgba(0,0,0,.5)';
|
73 |
+
return contains(style.backgroundColor, 'rgba') || contains(style.backgroundColor, 'hsla');
|
74 |
+
})(),
|
75 |
+
replaceInput = [
|
76 |
+
"<div class='sp-replacer'>",
|
77 |
+
"<div class='sp-preview'><div class='sp-preview-inner'></div></div>",
|
78 |
+
"<div class='sp-dd'>▼</div>",
|
79 |
+
"</div>"
|
80 |
+
].join(''),
|
81 |
+
markup = (function () {
|
82 |
+
|
83 |
+
// IE does not support gradients with multiple stops, so we need to simulate
|
84 |
+
// that for the rainbow slider with 8 divs that each have a single gradient
|
85 |
+
var gradientFix = "";
|
86 |
+
if (IE) {
|
87 |
+
for (var i = 1; i <= 6; i++) {
|
88 |
+
gradientFix += "<div class='sp-" + i + "'></div>";
|
89 |
+
}
|
90 |
+
}
|
91 |
+
|
92 |
+
return [
|
93 |
+
"<div class='sp-container sp-hidden'>",
|
94 |
+
"<div class='sp-palette-container'>",
|
95 |
+
"<div class='sp-palette sp-thumb sp-cf'></div>",
|
96 |
+
"<div class='sp-palette-button-container sp-cf'>",
|
97 |
+
"<button type='button' class='sp-palette-toggle'></button>",
|
98 |
+
"</div>",
|
99 |
+
"</div>",
|
100 |
+
"<div class='sp-picker-container'>",
|
101 |
+
"<div class='sp-top sp-cf'>",
|
102 |
+
"<div class='sp-fill'></div>",
|
103 |
+
"<div class='sp-top-inner'>",
|
104 |
+
"<div class='sp-color'>",
|
105 |
+
"<div class='sp-sat'>",
|
106 |
+
"<div class='sp-val'>",
|
107 |
+
"<div class='sp-dragger'></div>",
|
108 |
+
"</div>",
|
109 |
+
"</div>",
|
110 |
+
"</div>",
|
111 |
+
"<div class='sp-clear sp-clear-display'>",
|
112 |
+
"</div>",
|
113 |
+
"<div class='sp-hue'>",
|
114 |
+
"<div class='sp-slider'></div>",
|
115 |
+
gradientFix,
|
116 |
+
"</div>",
|
117 |
+
"</div>",
|
118 |
+
"<div class='sp-alpha'><div class='sp-alpha-inner'><div class='sp-alpha-handle'></div></div></div>",
|
119 |
+
"</div>",
|
120 |
+
"<div class='sp-input-container sp-cf'>",
|
121 |
+
"<input class='sp-input' type='text' spellcheck='false' />",
|
122 |
+
"</div>",
|
123 |
+
"<div class='sp-initial sp-thumb sp-cf'></div>",
|
124 |
+
"<div class='sp-button-container sp-cf'>",
|
125 |
+
"<a class='sp-cancel' href='#'></a>",
|
126 |
+
"<button type='button' class='sp-choose'></button>",
|
127 |
+
"</div>",
|
128 |
+
"</div>",
|
129 |
+
"</div>"
|
130 |
+
].join("");
|
131 |
+
})();
|
132 |
+
|
133 |
+
function paletteTemplate (p, color, className, opts) {
|
134 |
+
var html = [];
|
135 |
+
for (var i = 0; i < p.length; i++) {
|
136 |
+
var current = p[i];
|
137 |
+
if(current) {
|
138 |
+
var tiny = tinycolor(current);
|
139 |
+
var c = tiny.toHsl().l < 0.5 ? "sp-thumb-el sp-thumb-dark" : "sp-thumb-el sp-thumb-light";
|
140 |
+
c += (tinycolor.equals(color, current)) ? " sp-thumb-active" : "";
|
141 |
+
var formattedString = tiny.toString(opts.preferredFormat || "rgb");
|
142 |
+
var swatchStyle = rgbaSupport ? ("background-color:" + tiny.toRgbString()) : "filter:" + tiny.toFilter();
|
143 |
+
html.push('<span title="' + formattedString + '" data-color="' + tiny.toRgbString() + '" class="' + c + '"><span class="sp-thumb-inner" style="' + swatchStyle + ';"></span></span>');
|
144 |
+
} else {
|
145 |
+
var cls = 'sp-clear-display';
|
146 |
+
html.push($('<div />')
|
147 |
+
.append($('<span data-color="" style="background-color:transparent;" class="' + cls + '"></span>')
|
148 |
+
.attr('title', opts.noColorSelectedText)
|
149 |
+
)
|
150 |
+
.html()
|
151 |
+
);
|
152 |
+
}
|
153 |
+
}
|
154 |
+
return "<div class='sp-cf " + className + "'>" + html.join('') + "</div>";
|
155 |
+
}
|
156 |
+
|
157 |
+
function hideAll() {
|
158 |
+
for (var i = 0; i < spectrums.length; i++) {
|
159 |
+
if (spectrums[i]) {
|
160 |
+
spectrums[i].hide();
|
161 |
+
}
|
162 |
+
}
|
163 |
+
}
|
164 |
+
|
165 |
+
function instanceOptions(o, callbackContext) {
|
166 |
+
var opts = $.extend({}, defaultOpts, o);
|
167 |
+
opts.callbacks = {
|
168 |
+
'move': bind(opts.move, callbackContext),
|
169 |
+
'change': bind(opts.change, callbackContext),
|
170 |
+
'show': bind(opts.show, callbackContext),
|
171 |
+
'hide': bind(opts.hide, callbackContext),
|
172 |
+
'beforeShow': bind(opts.beforeShow, callbackContext)
|
173 |
+
};
|
174 |
+
|
175 |
+
return opts;
|
176 |
+
}
|
177 |
+
|
178 |
+
function spectrum(element, o) {
|
179 |
+
|
180 |
+
var opts = instanceOptions(o, element),
|
181 |
+
flat = opts.flat,
|
182 |
+
showSelectionPalette = opts.showSelectionPalette,
|
183 |
+
localStorageKey = opts.localStorageKey,
|
184 |
+
theme = opts.theme,
|
185 |
+
callbacks = opts.callbacks,
|
186 |
+
resize = throttle(reflow, 10),
|
187 |
+
visible = false,
|
188 |
+
isDragging = false,
|
189 |
+
dragWidth = 0,
|
190 |
+
dragHeight = 0,
|
191 |
+
dragHelperHeight = 0,
|
192 |
+
slideHeight = 0,
|
193 |
+
slideWidth = 0,
|
194 |
+
alphaWidth = 0,
|
195 |
+
alphaSlideHelperWidth = 0,
|
196 |
+
slideHelperHeight = 0,
|
197 |
+
currentHue = 0,
|
198 |
+
currentSaturation = 0,
|
199 |
+
currentValue = 0,
|
200 |
+
currentAlpha = 1,
|
201 |
+
palette = [],
|
202 |
+
paletteArray = [],
|
203 |
+
paletteLookup = {},
|
204 |
+
selectionPalette = opts.selectionPalette.slice(0),
|
205 |
+
maxSelectionSize = opts.maxSelectionSize,
|
206 |
+
draggingClass = "sp-dragging",
|
207 |
+
shiftMovementDirection = null;
|
208 |
+
|
209 |
+
var doc = element.ownerDocument,
|
210 |
+
body = doc.body,
|
211 |
+
boundElement = $(element),
|
212 |
+
disabled = false,
|
213 |
+
container = $(markup, doc).addClass(theme),
|
214 |
+
pickerContainer = container.find(".sp-picker-container"),
|
215 |
+
dragger = container.find(".sp-color"),
|
216 |
+
dragHelper = container.find(".sp-dragger"),
|
217 |
+
slider = container.find(".sp-hue"),
|
218 |
+
slideHelper = container.find(".sp-slider"),
|
219 |
+
alphaSliderInner = container.find(".sp-alpha-inner"),
|
220 |
+
alphaSlider = container.find(".sp-alpha"),
|
221 |
+
alphaSlideHelper = container.find(".sp-alpha-handle"),
|
222 |
+
textInput = container.find(".sp-input"),
|
223 |
+
paletteContainer = container.find(".sp-palette"),
|
224 |
+
initialColorContainer = container.find(".sp-initial"),
|
225 |
+
cancelButton = container.find(".sp-cancel"),
|
226 |
+
clearButton = container.find(".sp-clear"),
|
227 |
+
chooseButton = container.find(".sp-choose"),
|
228 |
+
toggleButton = container.find(".sp-palette-toggle"),
|
229 |
+
isInput = boundElement.is("input"),
|
230 |
+
isInputTypeColor = isInput && boundElement.attr("type") === "color" && inputTypeColorSupport(),
|
231 |
+
shouldReplace = isInput && !flat,
|
232 |
+
replacer = (shouldReplace) ? $(replaceInput).addClass(theme).addClass(opts.className).addClass(opts.replacerClassName) : $([]),
|
233 |
+
offsetElement = (shouldReplace) ? replacer : boundElement,
|
234 |
+
previewElement = replacer.find(".sp-preview-inner"),
|
235 |
+
initialColor = opts.color || (isInput && boundElement.val()),
|
236 |
+
colorOnShow = false,
|
237 |
+
currentPreferredFormat = opts.preferredFormat,
|
238 |
+
clickoutFiresChange = !opts.showButtons || opts.clickoutFiresChange,
|
239 |
+
isEmpty = !initialColor,
|
240 |
+
allowEmpty = opts.allowEmpty && !isInputTypeColor;
|
241 |
+
|
242 |
+
function applyOptions() {
|
243 |
+
|
244 |
+
if (opts.showPaletteOnly) {
|
245 |
+
opts.showPalette = true;
|
246 |
+
}
|
247 |
+
|
248 |
+
toggleButton.text(opts.showPaletteOnly ? opts.togglePaletteMoreText : opts.togglePaletteLessText);
|
249 |
+
|
250 |
+
if (opts.palette) {
|
251 |
+
palette = opts.palette.slice(0);
|
252 |
+
paletteArray = $.isArray(palette[0]) ? palette : [palette];
|
253 |
+
paletteLookup = {};
|
254 |
+
for (var i = 0; i < paletteArray.length; i++) {
|
255 |
+
for (var j = 0; j < paletteArray[i].length; j++) {
|
256 |
+
var rgb = tinycolor(paletteArray[i][j]).toRgbString();
|
257 |
+
paletteLookup[rgb] = true;
|
258 |
+
}
|
259 |
+
}
|
260 |
+
}
|
261 |
+
|
262 |
+
container.toggleClass("sp-flat", flat);
|
263 |
+
container.toggleClass("sp-input-disabled", !opts.showInput);
|
264 |
+
container.toggleClass("sp-alpha-enabled", opts.showAlpha);
|
265 |
+
container.toggleClass("sp-clear-enabled", allowEmpty);
|
266 |
+
container.toggleClass("sp-buttons-disabled", !opts.showButtons);
|
267 |
+
container.toggleClass("sp-palette-buttons-disabled", !opts.togglePaletteOnly);
|
268 |
+
container.toggleClass("sp-palette-disabled", !opts.showPalette);
|
269 |
+
container.toggleClass("sp-palette-only", opts.showPaletteOnly);
|
270 |
+
container.toggleClass("sp-initial-disabled", !opts.showInitial);
|
271 |
+
container.addClass(opts.className).addClass(opts.containerClassName);
|
272 |
+
|
273 |
+
reflow();
|
274 |
+
}
|
275 |
+
|
276 |
+
function initialize() {
|
277 |
+
|
278 |
+
if (IE) {
|
279 |
+
container.find("*:not(input)").attr("unselectable", "on");
|
280 |
+
}
|
281 |
+
|
282 |
+
applyOptions();
|
283 |
+
|
284 |
+
if (shouldReplace) {
|
285 |
+
boundElement.after(replacer).hide();
|
286 |
+
}
|
287 |
+
|
288 |
+
if (!allowEmpty) {
|
289 |
+
clearButton.hide();
|
290 |
+
}
|
291 |
+
|
292 |
+
if (flat) {
|
293 |
+
boundElement.after(container).hide();
|
294 |
+
}
|
295 |
+
else {
|
296 |
+
|
297 |
+
var appendTo = opts.appendTo === "parent" ? boundElement.parent() : $(opts.appendTo);
|
298 |
+
if (appendTo.length !== 1) {
|
299 |
+
appendTo = $("body");
|
300 |
+
}
|
301 |
+
|
302 |
+
appendTo.append(container);
|
303 |
+
}
|
304 |
+
|
305 |
+
updateSelectionPaletteFromStorage();
|
306 |
+
|
307 |
+
offsetElement.on("click.spectrum touchstart.spectrum", function (e) {
|
308 |
+
if (!disabled) {
|
309 |
+
toggle();
|
310 |
+
}
|
311 |
+
|
312 |
+
e.stopPropagation();
|
313 |
+
|
314 |
+
if (!$(e.target).is("input")) {
|
315 |
+
e.preventDefault();
|
316 |
+
}
|
317 |
+
});
|
318 |
+
|
319 |
+
if(boundElement.is(":disabled") || (opts.disabled === true)) {
|
320 |
+
disable();
|
321 |
+
}
|
322 |
+
|
323 |
+
// Prevent clicks from bubbling up to document. This would cause it to be hidden.
|
324 |
+
container.click(stopPropagation);
|
325 |
+
|
326 |
+
// Handle user typed input
|
327 |
+
textInput.change(setFromTextInput);
|
328 |
+
textInput.on("paste", function () {
|
329 |
+
setTimeout(setFromTextInput, 1);
|
330 |
+
});
|
331 |
+
textInput.keydown(function (e) { if (e.keyCode == 13) { setFromTextInput(); } });
|
332 |
+
|
333 |
+
cancelButton.text(opts.cancelText);
|
334 |
+
cancelButton.on("click.spectrum", function (e) {
|
335 |
+
e.stopPropagation();
|
336 |
+
e.preventDefault();
|
337 |
+
revert();
|
338 |
+
hide();
|
339 |
+
});
|
340 |
+
|
341 |
+
clearButton.attr("title", opts.clearText);
|
342 |
+
clearButton.on("click.spectrum", function (e) {
|
343 |
+
e.stopPropagation();
|
344 |
+
e.preventDefault();
|
345 |
+
isEmpty = true;
|
346 |
+
move();
|
347 |
+
|
348 |
+
if(flat) {
|
349 |
+
//for the flat style, this is a change event
|
350 |
+
updateOriginalInput(true);
|
351 |
+
}
|
352 |
+
});
|
353 |
+
|
354 |
+
chooseButton.text(opts.chooseText);
|
355 |
+
chooseButton.on("click.spectrum", function (e) {
|
356 |
+
e.stopPropagation();
|
357 |
+
e.preventDefault();
|
358 |
+
|
359 |
+
if (IE && textInput.is(":focus")) {
|
360 |
+
textInput.trigger('change');
|
361 |
+
}
|
362 |
+
|
363 |
+
if (isValid()) {
|
364 |
+
updateOriginalInput(true);
|
365 |
+
hide();
|
366 |
+
}
|
367 |
+
});
|
368 |
+
|
369 |
+
toggleButton.text(opts.showPaletteOnly ? opts.togglePaletteMoreText : opts.togglePaletteLessText);
|
370 |
+
toggleButton.on("click.spectrum", function (e) {
|
371 |
+
e.stopPropagation();
|
372 |
+
e.preventDefault();
|
373 |
+
|
374 |
+
opts.showPaletteOnly = !opts.showPaletteOnly;
|
375 |
+
|
376 |
+
// To make sure the Picker area is drawn on the right, next to the
|
377 |
+
// Palette area (and not below the palette), first move the Palette
|
378 |
+
// to the left to make space for the picker, plus 5px extra.
|
379 |
+
// The 'applyOptions' function puts the whole container back into place
|
380 |
+
// and takes care of the button-text and the sp-palette-only CSS class.
|
381 |
+
if (!opts.showPaletteOnly && !flat) {
|
382 |
+
container.css('left', '-=' + (pickerContainer.outerWidth(true) + 5));
|
383 |
+
}
|
384 |
+
applyOptions();
|
385 |
+
});
|
386 |
+
|
387 |
+
draggable(alphaSlider, function (dragX, dragY, e) {
|
388 |
+
currentAlpha = (dragX / alphaWidth);
|
389 |
+
isEmpty = false;
|
390 |
+
if (e.shiftKey) {
|
391 |
+
currentAlpha = Math.round(currentAlpha * 10) / 10;
|
392 |
+
}
|
393 |
+
|
394 |
+
move();
|
395 |
+
}, dragStart, dragStop);
|
396 |
+
|
397 |
+
draggable(slider, function (dragX, dragY) {
|
398 |
+
currentHue = parseFloat(dragY / slideHeight);
|
399 |
+
isEmpty = false;
|
400 |
+
if (!opts.showAlpha) {
|
401 |
+
currentAlpha = 1;
|
402 |
+
}
|
403 |
+
move();
|
404 |
+
}, dragStart, dragStop);
|
405 |
+
|
406 |
+
draggable(dragger, function (dragX, dragY, e) {
|
407 |
+
|
408 |
+
// shift+drag should snap the movement to either the x or y axis.
|
409 |
+
if (!e.shiftKey) {
|
410 |
+
shiftMovementDirection = null;
|
411 |
+
}
|
412 |
+
else if (!shiftMovementDirection) {
|
413 |
+
var oldDragX = currentSaturation * dragWidth;
|
414 |
+
var oldDragY = dragHeight - (currentValue * dragHeight);
|
415 |
+
var furtherFromX = Math.abs(dragX - oldDragX) > Math.abs(dragY - oldDragY);
|
416 |
+
|
417 |
+
shiftMovementDirection = furtherFromX ? "x" : "y";
|
418 |
+
}
|
419 |
+
|
420 |
+
var setSaturation = !shiftMovementDirection || shiftMovementDirection === "x";
|
421 |
+
var setValue = !shiftMovementDirection || shiftMovementDirection === "y";
|
422 |
+
|
423 |
+
if (setSaturation) {
|
424 |
+
currentSaturation = parseFloat(dragX / dragWidth);
|
425 |
+
}
|
426 |
+
if (setValue) {
|
427 |
+
currentValue = parseFloat((dragHeight - dragY) / dragHeight);
|
428 |
+
}
|
429 |
+
|
430 |
+
isEmpty = false;
|
431 |
+
if (!opts.showAlpha) {
|
432 |
+
currentAlpha = 1;
|
433 |
+
}
|
434 |
+
|
435 |
+
move();
|
436 |
+
|
437 |
+
}, dragStart, dragStop);
|
438 |
+
|
439 |
+
if (!!initialColor) {
|
440 |
+
set(initialColor);
|
441 |
+
|
442 |
+
// In case color was black - update the preview UI and set the format
|
443 |
+
// since the set function will not run (default color is black).
|
444 |
+
updateUI();
|
445 |
+
currentPreferredFormat = opts.preferredFormat || tinycolor(initialColor).format;
|
446 |
+
|
447 |
+
addColorToSelectionPalette(initialColor);
|
448 |
+
}
|
449 |
+
else {
|
450 |
+
updateUI();
|
451 |
+
}
|
452 |
+
|
453 |
+
if (flat) {
|
454 |
+
show();
|
455 |
+
}
|
456 |
+
|
457 |
+
function paletteElementClick(e) {
|
458 |
+
if (e.data && e.data.ignore) {
|
459 |
+
set($(e.target).closest(".sp-thumb-el").data("color"));
|
460 |
+
move();
|
461 |
+
}
|
462 |
+
else {
|
463 |
+
set($(e.target).closest(".sp-thumb-el").data("color"));
|
464 |
+
move();
|
465 |
+
|
466 |
+
// If the picker is going to close immediately, a palette selection
|
467 |
+
// is a change. Otherwise, it's a move only.
|
468 |
+
if (opts.hideAfterPaletteSelect) {
|
469 |
+
updateOriginalInput(true);
|
470 |
+
hide();
|
471 |
+
} else {
|
472 |
+
updateOriginalInput();
|
473 |
+
}
|
474 |
+
}
|
475 |
+
|
476 |
+
return false;
|
477 |
+
}
|
478 |
+
|
479 |
+
var paletteEvent = IE ? "mousedown.spectrum" : "click.spectrum touchstart.spectrum";
|
480 |
+
paletteContainer.on(paletteEvent, ".sp-thumb-el", paletteElementClick);
|
481 |
+
initialColorContainer.on(paletteEvent, ".sp-thumb-el:nth-child(1)", { ignore: true }, paletteElementClick);
|
482 |
+
}
|
483 |
+
|
484 |
+
function updateSelectionPaletteFromStorage() {
|
485 |
+
|
486 |
+
if (localStorageKey && window.localStorage) {
|
487 |
+
|
488 |
+
// Migrate old palettes over to new format. May want to remove this eventually.
|
489 |
+
try {
|
490 |
+
var oldPalette = window.localStorage[localStorageKey].split(",#");
|
491 |
+
if (oldPalette.length > 1) {
|
492 |
+
delete window.localStorage[localStorageKey];
|
493 |
+
$.each(oldPalette, function(i, c) {
|
494 |
+
addColorToSelectionPalette(c);
|
495 |
+
});
|
496 |
+
}
|
497 |
+
}
|
498 |
+
catch(e) { }
|
499 |
+
|
500 |
+
try {
|
501 |
+
selectionPalette = window.localStorage[localStorageKey].split(";");
|
502 |
+
}
|
503 |
+
catch (e) { }
|
504 |
+
}
|
505 |
+
}
|
506 |
+
|
507 |
+
function addColorToSelectionPalette(color) {
|
508 |
+
if (showSelectionPalette) {
|
509 |
+
var rgb = tinycolor(color).toRgbString();
|
510 |
+
if (!paletteLookup[rgb] && $.inArray(rgb, selectionPalette) === -1) {
|
511 |
+
selectionPalette.push(rgb);
|
512 |
+
while(selectionPalette.length > maxSelectionSize) {
|
513 |
+
selectionPalette.shift();
|
514 |
+
}
|
515 |
+
}
|
516 |
+
|
517 |
+
if (localStorageKey && window.localStorage) {
|
518 |
+
try {
|
519 |
+
window.localStorage[localStorageKey] = selectionPalette.join(";");
|
520 |
+
}
|
521 |
+
catch(e) { }
|
522 |
+
}
|
523 |
+
}
|
524 |
+
}
|
525 |
+
|
526 |
+
function getUniqueSelectionPalette() {
|
527 |
+
var unique = [];
|
528 |
+
if (opts.showPalette) {
|
529 |
+
for (var i = 0; i < selectionPalette.length; i++) {
|
530 |
+
var rgb = tinycolor(selectionPalette[i]).toRgbString();
|
531 |
+
|
532 |
+
if (!paletteLookup[rgb]) {
|
533 |
+
unique.push(selectionPalette[i]);
|
534 |
+
}
|
535 |
+
}
|
536 |
+
}
|
537 |
+
|
538 |
+
return unique.reverse().slice(0, opts.maxSelectionSize);
|
539 |
+
}
|
540 |
+
|
541 |
+
function drawPalette() {
|
542 |
+
|
543 |
+
var currentColor = get();
|
544 |
+
|
545 |
+
var html = $.map(paletteArray, function (palette, i) {
|
546 |
+
return paletteTemplate(palette, currentColor, "sp-palette-row sp-palette-row-" + i, opts);
|
547 |
+
});
|
548 |
+
|
549 |
+
updateSelectionPaletteFromStorage();
|
550 |
+
|
551 |
+
if (selectionPalette) {
|
552 |
+
html.push(paletteTemplate(getUniqueSelectionPalette(), currentColor, "sp-palette-row sp-palette-row-selection", opts));
|
553 |
+
}
|
554 |
+
|
555 |
+
paletteContainer.html(html.join(""));
|
556 |
+
}
|
557 |
+
|
558 |
+
function drawInitial() {
|
559 |
+
if (opts.showInitial) {
|
560 |
+
var initial = colorOnShow;
|
561 |
+
var current = get();
|
562 |
+
initialColorContainer.html(paletteTemplate([initial, current], current, "sp-palette-row-initial", opts));
|
563 |
+
}
|
564 |
+
}
|
565 |
+
|
566 |
+
function dragStart() {
|
567 |
+
if (dragHeight <= 0 || dragWidth <= 0 || slideHeight <= 0) {
|
568 |
+
reflow();
|
569 |
+
}
|
570 |
+
isDragging = true;
|
571 |
+
container.addClass(draggingClass);
|
572 |
+
shiftMovementDirection = null;
|
573 |
+
boundElement.trigger('dragstart.spectrum', [ get() ]);
|
574 |
+
}
|
575 |
+
|
576 |
+
function dragStop() {
|
577 |
+
isDragging = false;
|
578 |
+
container.removeClass(draggingClass);
|
579 |
+
boundElement.trigger('dragstop.spectrum', [ get() ]);
|
580 |
+
}
|
581 |
+
|
582 |
+
function setFromTextInput() {
|
583 |
+
|
584 |
+
var value = textInput.val();
|
585 |
+
|
586 |
+
value = hexToRGB(value);
|
587 |
+
|
588 |
+
if ((value === null || value === "") && allowEmpty) {
|
589 |
+
set(null);
|
590 |
+
move();
|
591 |
+
updateOriginalInput();
|
592 |
+
}
|
593 |
+
else {
|
594 |
+
var tiny = tinycolor(value);
|
595 |
+
if (tiny.isValid()) {
|
596 |
+
set(tiny);
|
597 |
+
move();
|
598 |
+
updateOriginalInput();
|
599 |
+
}
|
600 |
+
else {
|
601 |
+
textInput.addClass("sp-validation-error");
|
602 |
+
}
|
603 |
+
}
|
604 |
+
}
|
605 |
+
|
606 |
+
function toggle() {
|
607 |
+
if (visible) {
|
608 |
+
hide();
|
609 |
+
}
|
610 |
+
else {
|
611 |
+
show();
|
612 |
+
}
|
613 |
+
}
|
614 |
+
|
615 |
+
function show() {
|
616 |
+
var event = $.Event('beforeShow.spectrum');
|
617 |
+
|
618 |
+
if (visible) {
|
619 |
+
reflow();
|
620 |
+
return;
|
621 |
+
}
|
622 |
+
|
623 |
+
boundElement.trigger(event, [ get() ]);
|
624 |
+
|
625 |
+
if (callbacks.beforeShow(get()) === false || event.isDefaultPrevented()) {
|
626 |
+
return;
|
627 |
+
}
|
628 |
+
|
629 |
+
hideAll();
|
630 |
+
visible = true;
|
631 |
+
|
632 |
+
$(doc).on("keydown.spectrum", onkeydown);
|
633 |
+
$(doc).on("click.spectrum", clickout);
|
634 |
+
$(window).on("resize.spectrum", resize);
|
635 |
+
replacer.addClass("sp-active");
|
636 |
+
container.removeClass("sp-hidden");
|
637 |
+
|
638 |
+
reflow();
|
639 |
+
updateUI();
|
640 |
+
|
641 |
+
colorOnShow = get();
|
642 |
+
|
643 |
+
drawInitial();
|
644 |
+
callbacks.show(colorOnShow);
|
645 |
+
boundElement.trigger('show.spectrum', [ colorOnShow ]);
|
646 |
+
}
|
647 |
+
|
648 |
+
function onkeydown(e) {
|
649 |
+
// Close on ESC
|
650 |
+
if (e.keyCode === 27) {
|
651 |
+
hide();
|
652 |
+
}
|
653 |
+
}
|
654 |
+
|
655 |
+
function clickout(e) {
|
656 |
+
// Return on right click.
|
657 |
+
if (e.button == 2) { return; }
|
658 |
+
|
659 |
+
// If a drag event was happening during the mouseup, don't hide
|
660 |
+
// on click.
|
661 |
+
if (isDragging) { return; }
|
662 |
+
|
663 |
+
if (clickoutFiresChange) {
|
664 |
+
updateOriginalInput(true);
|
665 |
+
}
|
666 |
+
else {
|
667 |
+
revert();
|
668 |
+
}
|
669 |
+
hide();
|
670 |
+
}
|
671 |
+
|
672 |
+
function hide() {
|
673 |
+
// Return if hiding is unnecessary
|
674 |
+
if (!visible || flat) { return; }
|
675 |
+
visible = false;
|
676 |
+
|
677 |
+
$(doc).off("keydown.spectrum", onkeydown);
|
678 |
+
$(doc).off("click.spectrum", clickout);
|
679 |
+
$(window).off("resize.spectrum", resize);
|
680 |
+
|
681 |
+
replacer.removeClass("sp-active");
|
682 |
+
container.addClass("sp-hidden");
|
683 |
+
|
684 |
+
callbacks.hide(get());
|
685 |
+
boundElement.trigger('hide.spectrum', [ get() ]);
|
686 |
+
}
|
687 |
+
|
688 |
+
function revert() {
|
689 |
+
set(colorOnShow, true);
|
690 |
+
updateOriginalInput(true);
|
691 |
+
}
|
692 |
+
|
693 |
+
function set(color, ignoreFormatChange) {
|
694 |
+
if (tinycolor.equals(color, get())) {
|
695 |
+
// Update UI just in case a validation error needs
|
696 |
+
// to be cleared.
|
697 |
+
updateUI();
|
698 |
+
return;
|
699 |
+
}
|
700 |
+
|
701 |
+
var newColor, newHsv;
|
702 |
+
if (!color && allowEmpty) {
|
703 |
+
isEmpty = true;
|
704 |
+
} else {
|
705 |
+
isEmpty = false;
|
706 |
+
newColor = tinycolor(color);
|
707 |
+
newHsv = newColor.toHsv();
|
708 |
+
|
709 |
+
currentHue = (newHsv.h % 360) / 360;
|
710 |
+
currentSaturation = newHsv.s;
|
711 |
+
currentValue = newHsv.v;
|
712 |
+
currentAlpha = newHsv.a;
|
713 |
+
}
|
714 |
+
updateUI();
|
715 |
+
|
716 |
+
if (newColor && newColor.isValid() && !ignoreFormatChange) {
|
717 |
+
currentPreferredFormat = opts.preferredFormat || newColor.getFormat();
|
718 |
+
}
|
719 |
+
}
|
720 |
+
|
721 |
+
function get(opts) {
|
722 |
+
opts = opts || { };
|
723 |
+
|
724 |
+
if (allowEmpty && isEmpty) {
|
725 |
+
return null;
|
726 |
+
}
|
727 |
+
|
728 |
+
return tinycolor.fromRatio({
|
729 |
+
h: currentHue,
|
730 |
+
s: currentSaturation,
|
731 |
+
v: currentValue,
|
732 |
+
a: Math.round(currentAlpha * 1000) / 1000
|
733 |
+
}, { format: opts.format || currentPreferredFormat });
|
734 |
+
}
|
735 |
+
|
736 |
+
function isValid() {
|
737 |
+
return !textInput.hasClass("sp-validation-error");
|
738 |
+
}
|
739 |
+
|
740 |
+
function move() {
|
741 |
+
updateUI();
|
742 |
+
|
743 |
+
callbacks.move(get());
|
744 |
+
boundElement.trigger('move.spectrum', [ get() ]);
|
745 |
+
}
|
746 |
+
|
747 |
+
function updateUI() {
|
748 |
+
|
749 |
+
textInput.removeClass("sp-validation-error");
|
750 |
+
|
751 |
+
updateHelperLocations();
|
752 |
+
|
753 |
+
// Update dragger background color (gradients take care of saturation and value).
|
754 |
+
var flatColor = tinycolor.fromRatio({ h: currentHue, s: 1, v: 1 });
|
755 |
+
dragger.css("background-color", flatColor.toHexString());
|
756 |
+
|
757 |
+
// Get a format that alpha will be included in (hex and names ignore alpha)
|
758 |
+
var format = currentPreferredFormat;
|
759 |
+
if (currentAlpha < 1 && !(currentAlpha === 0 && format === "name")) {
|
760 |
+
if (format === "hex" || format === "hex3" || format === "hex6" || format === "name") {
|
761 |
+
format = "rgb";
|
762 |
+
}
|
763 |
+
}
|
764 |
+
|
765 |
+
var realColor = get({ format: format }),
|
766 |
+
displayColor = '';
|
767 |
+
|
768 |
+
//reset background info for preview element
|
769 |
+
previewElement.removeClass("sp-clear-display");
|
770 |
+
previewElement.css('background-color', 'transparent');
|
771 |
+
|
772 |
+
if (!realColor && allowEmpty) {
|
773 |
+
// Update the replaced elements background with icon indicating no color selection
|
774 |
+
previewElement.addClass("sp-clear-display");
|
775 |
+
}
|
776 |
+
else {
|
777 |
+
var realHex = realColor.toHexString(),
|
778 |
+
realRgb = realColor.toRgbString();
|
779 |
+
|
780 |
+
// Update the replaced elements background color (with actual selected color)
|
781 |
+
if (rgbaSupport || realColor.alpha === 1) {
|
782 |
+
previewElement.css("background-color", realRgb);
|
783 |
+
}
|
784 |
+
else {
|
785 |
+
previewElement.css("background-color", "transparent");
|
786 |
+
previewElement.css("filter", realColor.toFilter());
|
787 |
+
}
|
788 |
+
|
789 |
+
if (opts.showAlpha) {
|
790 |
+
var rgb = realColor.toRgb();
|
791 |
+
rgb.a = 0;
|
792 |
+
var realAlpha = tinycolor(rgb).toRgbString();
|
793 |
+
var gradient = "linear-gradient(left, " + realAlpha + ", " + realHex + ")";
|
794 |
+
|
795 |
+
if (IE) {
|
796 |
+
alphaSliderInner.css("filter", tinycolor(realAlpha).toFilter({ gradientType: 1 }, realHex));
|
797 |
+
}
|
798 |
+
else {
|
799 |
+
alphaSliderInner.css("background", "-webkit-" + gradient);
|
800 |
+
alphaSliderInner.css("background", "-moz-" + gradient);
|
801 |
+
alphaSliderInner.css("background", "-ms-" + gradient);
|
802 |
+
// Use current syntax gradient on unprefixed property.
|
803 |
+
alphaSliderInner.css("background",
|
804 |
+
"linear-gradient(to right, " + realAlpha + ", " + realHex + ")");
|
805 |
+
}
|
806 |
+
}
|
807 |
+
|
808 |
+
displayColor = realColor.toString(format);
|
809 |
+
}
|
810 |
+
|
811 |
+
// Update the text entry input as it changes happen
|
812 |
+
if (opts.showInput) {
|
813 |
+
displayColor = rgba2hex(displayColor);
|
814 |
+
textInput.val(displayColor);
|
815 |
+
}
|
816 |
+
|
817 |
+
if (opts.showPalette) {
|
818 |
+
drawPalette();
|
819 |
+
}
|
820 |
+
|
821 |
+
drawInitial();
|
822 |
+
}
|
823 |
+
|
824 |
+
function isValidHex(hex) {
|
825 |
+
return /^#([A-Fa-f0-9]{3,4}){1,2}$/.test(hex);
|
826 |
+
}
|
827 |
+
|
828 |
+
function getChunksFromString(st, chunkSize) {
|
829 |
+
return st.match(new RegExp(`.{${chunkSize}}`, "g"))
|
830 |
+
}
|
831 |
+
|
832 |
+
function convertHexUnitTo256(hexStr) {
|
833 |
+
return parseInt(hexStr.repeat(2 / hexStr.length), 16);
|
834 |
+
}
|
835 |
+
|
836 |
+
function getAlphafloat(a, alpha) {
|
837 |
+
if (typeof a !== "undefined") {return a / 255}
|
838 |
+
if ((typeof alpha != "number") || alpha <0 || alpha >1){
|
839 |
+
return 1
|
840 |
+
}
|
841 |
+
return alpha;
|
842 |
+
}
|
843 |
+
|
844 |
+
function hexToRGB(hex, alpha) {
|
845 |
+
if(hex != "") {
|
846 |
+
hex = hex.toLowerCase();
|
847 |
+
}
|
848 |
+
var hexStr = (hex.substring(0,3));
|
849 |
+
if(hexStr == "rgb") {
|
850 |
+
return hex;
|
851 |
+
}
|
852 |
+
|
853 |
+
hexStr = (hex.substring(0,1));
|
854 |
+
if(hexStr != "#") {
|
855 |
+
hex = "#"+hex;
|
856 |
+
}
|
857 |
+
|
858 |
+
if (!isValidHex(hex)) {
|
859 |
+
throw new Error("Invalid HEX")
|
860 |
+
}
|
861 |
+
const chunkSize = Math.floor((hex.length - 1) / 3)
|
862 |
+
const hexArr = getChunksFromString(hex.slice(1), chunkSize)
|
863 |
+
const [r, g, b, a] = hexArr.map(convertHexUnitTo256)
|
864 |
+
return `rgba(${r}, ${g}, ${b}, ${getAlphafloat(a, alpha)})`
|
865 |
+
}
|
866 |
+
|
867 |
+
function rgba2hex(orig) {
|
868 |
+
var a, isPercent,
|
869 |
+
rgb = orig.replace(/\s/g, '').match(/^rgba?\((\d+),(\d+),(\d+),?([^,\s)]+)?/i),
|
870 |
+
alpha = (rgb && rgb[4] || "").trim(),
|
871 |
+
hex = rgb ?
|
872 |
+
(rgb[1] | 1 << 8).toString(16).slice(1) +
|
873 |
+
(rgb[2] | 1 << 8).toString(16).slice(1) +
|
874 |
+
(rgb[3] | 1 << 8).toString(16).slice(1) : orig;
|
875 |
+
|
876 |
+
if (alpha !== "") {
|
877 |
+
a = alpha;
|
878 |
+
} else {
|
879 |
+
a = parseInt('01', 8);
|
880 |
+
}
|
881 |
+
// multiply before convert to HEX
|
882 |
+
a = ((a * 255) | 1 << 8).toString(16).slice(1)
|
883 |
+
hex = hex + a;
|
884 |
+
|
885 |
+
return hex;
|
886 |
+
}
|
887 |
+
|
888 |
+
function updateHelperLocations() {
|
889 |
+
var s = currentSaturation;
|
890 |
+
var v = currentValue;
|
891 |
+
|
892 |
+
if(allowEmpty && isEmpty) {
|
893 |
+
//if selected color is empty, hide the helpers
|
894 |
+
alphaSlideHelper.hide();
|
895 |
+
slideHelper.hide();
|
896 |
+
dragHelper.hide();
|
897 |
+
}
|
898 |
+
else {
|
899 |
+
//make sure helpers are visible
|
900 |
+
alphaSlideHelper.show();
|
901 |
+
slideHelper.show();
|
902 |
+
dragHelper.show();
|
903 |
+
|
904 |
+
// Where to show the little circle in that displays your current selected color
|
905 |
+
var dragX = s * dragWidth;
|
906 |
+
var dragY = dragHeight - (v * dragHeight);
|
907 |
+
dragX = Math.max(
|
908 |
+
-dragHelperHeight,
|
909 |
+
Math.min(dragWidth - dragHelperHeight, dragX - dragHelperHeight)
|
910 |
+
);
|
911 |
+
dragY = Math.max(
|
912 |
+
-dragHelperHeight,
|
913 |
+
Math.min(dragHeight - dragHelperHeight, dragY - dragHelperHeight)
|
914 |
+
);
|
915 |
+
dragHelper.css({
|
916 |
+
"top": dragY + "px",
|
917 |
+
"left": dragX + "px"
|
918 |
+
});
|
919 |
+
|
920 |
+
var alphaX = currentAlpha * alphaWidth;
|
921 |
+
alphaSlideHelper.css({
|
922 |
+
"left": (alphaX - (alphaSlideHelperWidth / 2)) + "px"
|
923 |
+
});
|
924 |
+
|
925 |
+
// Where to show the bar that displays your current selected hue
|
926 |
+
var slideY = (currentHue) * slideHeight;
|
927 |
+
slideHelper.css({
|
928 |
+
"top": (slideY - slideHelperHeight) + "px"
|
929 |
+
});
|
930 |
+
}
|
931 |
+
}
|
932 |
+
|
933 |
+
function updateOriginalInput(fireCallback) {
|
934 |
+
var color = get(),
|
935 |
+
displayColor = '',
|
936 |
+
hasChanged = !tinycolor.equals(color, colorOnShow);
|
937 |
+
|
938 |
+
if (color) {
|
939 |
+
displayColor = color.toString(currentPreferredFormat);
|
940 |
+
// Update the selection palette with the current color
|
941 |
+
addColorToSelectionPalette(color);
|
942 |
+
}
|
943 |
+
|
944 |
+
if (isInput) {
|
945 |
+
boundElement.val(displayColor);
|
946 |
+
}
|
947 |
+
|
948 |
+
if (fireCallback && hasChanged) {
|
949 |
+
callbacks.change(color);
|
950 |
+
boundElement.trigger('change', [ color ]);
|
951 |
+
}
|
952 |
+
}
|
953 |
+
|
954 |
+
function reflow() {
|
955 |
+
if (!visible) {
|
956 |
+
return; // Calculations would be useless and wouldn't be reliable anyways
|
957 |
+
}
|
958 |
+
dragWidth = dragger.width();
|
959 |
+
dragHeight = dragger.height();
|
960 |
+
dragHelperHeight = dragHelper.height();
|
961 |
+
slideWidth = slider.width();
|
962 |
+
slideHeight = slider.height();
|
963 |
+
slideHelperHeight = slideHelper.height();
|
964 |
+
alphaWidth = alphaSlider.width();
|
965 |
+
alphaSlideHelperWidth = alphaSlideHelper.width();
|
966 |
+
|
967 |
+
if (!flat) {
|
968 |
+
container.css("position", "absolute");
|
969 |
+
if (opts.offset) {
|
970 |
+
container.offset(opts.offset);
|
971 |
+
} else {
|
972 |
+
container.offset(getOffset(container, offsetElement));
|
973 |
+
}
|
974 |
+
}
|
975 |
+
|
976 |
+
updateHelperLocations();
|
977 |
+
|
978 |
+
if (opts.showPalette) {
|
979 |
+
drawPalette();
|
980 |
+
}
|
981 |
+
|
982 |
+
boundElement.trigger('reflow.spectrum');
|
983 |
+
}
|
984 |
+
|
985 |
+
function destroy() {
|
986 |
+
boundElement.show();
|
987 |
+
offsetElement.off("click.spectrum touchstart.spectrum");
|
988 |
+
container.remove();
|
989 |
+
replacer.remove();
|
990 |
+
spectrums[spect.id] = null;
|
991 |
+
}
|
992 |
+
|
993 |
+
function option(optionName, optionValue) {
|
994 |
+
if (optionName === undefined) {
|
995 |
+
return $.extend({}, opts);
|
996 |
+
}
|
997 |
+
if (optionValue === undefined) {
|
998 |
+
return opts[optionName];
|
999 |
+
}
|
1000 |
+
|
1001 |
+
opts[optionName] = optionValue;
|
1002 |
+
|
1003 |
+
if (optionName === "preferredFormat") {
|
1004 |
+
currentPreferredFormat = opts.preferredFormat;
|
1005 |
+
}
|
1006 |
+
applyOptions();
|
1007 |
+
}
|
1008 |
+
|
1009 |
+
function enable() {
|
1010 |
+
disabled = false;
|
1011 |
+
boundElement.attr("disabled", false);
|
1012 |
+
offsetElement.removeClass("sp-disabled");
|
1013 |
+
}
|
1014 |
+
|
1015 |
+
function disable() {
|
1016 |
+
hide();
|
1017 |
+
disabled = true;
|
1018 |
+
boundElement.attr("disabled", true);
|
1019 |
+
offsetElement.addClass("sp-disabled");
|
1020 |
+
}
|
1021 |
+
|
1022 |
+
function setOffset(coord) {
|
1023 |
+
opts.offset = coord;
|
1024 |
+
reflow();
|
1025 |
+
}
|
1026 |
+
|
1027 |
+
initialize();
|
1028 |
+
|
1029 |
+
var spect = {
|
1030 |
+
show: show,
|
1031 |
+
hide: hide,
|
1032 |
+
toggle: toggle,
|
1033 |
+
reflow: reflow,
|
1034 |
+
option: option,
|
1035 |
+
enable: enable,
|
1036 |
+
disable: disable,
|
1037 |
+
offset: setOffset,
|
1038 |
+
set: function (c) {
|
1039 |
+
set(c);
|
1040 |
+
updateOriginalInput();
|
1041 |
+
},
|
1042 |
+
get: get,
|
1043 |
+
destroy: destroy,
|
1044 |
+
container: container
|
1045 |
+
};
|
1046 |
+
|
1047 |
+
spect.id = spectrums.push(spect) - 1;
|
1048 |
+
|
1049 |
+
return spect;
|
1050 |
+
}
|
1051 |
+
|
1052 |
+
/**
|
1053 |
+
* checkOffset - get the offset below/above and left/right element depending on screen position
|
1054 |
+
* Thanks https://github.com/jquery/jquery-ui/blob/master/ui/jquery.ui.datepicker.js
|
1055 |
+
*/
|
1056 |
+
function getOffset(picker, input) {
|
1057 |
+
var extraY = 0;
|
1058 |
+
var dpWidth = picker.outerWidth();
|
1059 |
+
var dpHeight = picker.outerHeight();
|
1060 |
+
var inputHeight = input.outerHeight();
|
1061 |
+
var doc = picker[0].ownerDocument;
|
1062 |
+
var docElem = doc.documentElement;
|
1063 |
+
var viewWidth = docElem.clientWidth + $(doc).scrollLeft();
|
1064 |
+
var viewHeight = docElem.clientHeight + $(doc).scrollTop();
|
1065 |
+
var offset = input.offset();
|
1066 |
+
var offsetLeft = offset.left;
|
1067 |
+
var offsetTop = offset.top;
|
1068 |
+
|
1069 |
+
offsetTop += inputHeight;
|
1070 |
+
|
1071 |
+
offsetLeft -=
|
1072 |
+
Math.min(offsetLeft, (offsetLeft + dpWidth > viewWidth && viewWidth > dpWidth) ?
|
1073 |
+
Math.abs(offsetLeft + dpWidth - viewWidth) : 0);
|
1074 |
+
|
1075 |
+
offsetTop -=
|
1076 |
+
Math.min(offsetTop, ((offsetTop + dpHeight > viewHeight && viewHeight > dpHeight) ?
|
1077 |
+
Math.abs(dpHeight + inputHeight - extraY) : extraY));
|
1078 |
+
|
1079 |
+
return {
|
1080 |
+
top: offsetTop,
|
1081 |
+
bottom: offset.bottom,
|
1082 |
+
left: offsetLeft,
|
1083 |
+
right: offset.right,
|
1084 |
+
width: offset.width,
|
1085 |
+
height: offset.height
|
1086 |
+
};
|
1087 |
+
}
|
1088 |
+
|
1089 |
+
/**
|
1090 |
+
* noop - do nothing
|
1091 |
+
*/
|
1092 |
+
function noop() {
|
1093 |
+
|
1094 |
+
}
|
1095 |
+
|
1096 |
+
/**
|
1097 |
+
* stopPropagation - makes the code only doing this a little easier to read in line
|
1098 |
+
*/
|
1099 |
+
function stopPropagation(e) {
|
1100 |
+
e.stopPropagation();
|
1101 |
+
}
|
1102 |
+
|
1103 |
+
/**
|
1104 |
+
* Create a function bound to a given object
|
1105 |
+
* Thanks to underscore.js
|
1106 |
+
*/
|
1107 |
+
function bind(func, obj) {
|
1108 |
+
var slice = Array.prototype.slice;
|
1109 |
+
var args = slice.call(arguments, 2);
|
1110 |
+
return function () {
|
1111 |
+
return func.apply(obj, args.concat(slice.call(arguments)));
|
1112 |
+
};
|
1113 |
+
}
|
1114 |
+
|
1115 |
+
/**
|
1116 |
+
* Lightweight drag helper. Handles containment within the element, so that
|
1117 |
+
* when dragging, the x is within [0,element.width] and y is within [0,element.height]
|
1118 |
+
*/
|
1119 |
+
function draggable(element, onmove, onstart, onstop) {
|
1120 |
+
onmove = onmove || function () { };
|
1121 |
+
onstart = onstart || function () { };
|
1122 |
+
onstop = onstop || function () { };
|
1123 |
+
var doc = document;
|
1124 |
+
var dragging = false;
|
1125 |
+
var offset = {};
|
1126 |
+
var maxHeight = 0;
|
1127 |
+
var maxWidth = 0;
|
1128 |
+
var hasTouch = ('ontouchstart' in window);
|
1129 |
+
|
1130 |
+
var duringDragEvents = {};
|
1131 |
+
duringDragEvents["selectstart"] = prevent;
|
1132 |
+
duringDragEvents["dragstart"] = prevent;
|
1133 |
+
duringDragEvents["touchmove mousemove"] = move;
|
1134 |
+
duringDragEvents["touchend mouseup"] = stop;
|
1135 |
+
|
1136 |
+
function prevent(e) {
|
1137 |
+
if (e.stopPropagation) {
|
1138 |
+
e.stopPropagation();
|
1139 |
+
}
|
1140 |
+
if (e.preventDefault) {
|
1141 |
+
e.preventDefault();
|
1142 |
+
}
|
1143 |
+
e.returnValue = false;
|
1144 |
+
}
|
1145 |
+
|
1146 |
+
function move(e) {
|
1147 |
+
if (dragging) {
|
1148 |
+
// Mouseup happened outside of window
|
1149 |
+
if (IE && doc.documentMode < 9 && !e.button) {
|
1150 |
+
return stop();
|
1151 |
+
}
|
1152 |
+
|
1153 |
+
var t0 = e.originalEvent && e.originalEvent.touches && e.originalEvent.touches[0];
|
1154 |
+
var pageX = t0 && t0.pageX || e.pageX;
|
1155 |
+
var pageY = t0 && t0.pageY || e.pageY;
|
1156 |
+
|
1157 |
+
var dragX = Math.max(0, Math.min(pageX - offset.left, maxWidth));
|
1158 |
+
var dragY = Math.max(0, Math.min(pageY - offset.top, maxHeight));
|
1159 |
+
|
1160 |
+
if (hasTouch) {
|
1161 |
+
// Stop scrolling in iOS
|
1162 |
+
prevent(e);
|
1163 |
+
}
|
1164 |
+
|
1165 |
+
onmove.apply(element, [dragX, dragY, e]);
|
1166 |
+
}
|
1167 |
+
}
|
1168 |
+
|
1169 |
+
function start(e) {
|
1170 |
+
var rightclick = (e.which) ? (e.which == 3) : (e.button == 2);
|
1171 |
+
|
1172 |
+
if (!rightclick && !dragging) {
|
1173 |
+
if (onstart.apply(element, arguments) !== false) {
|
1174 |
+
dragging = true;
|
1175 |
+
maxHeight = $(element).height();
|
1176 |
+
maxWidth = $(element).width();
|
1177 |
+
offset = $(element).offset();
|
1178 |
+
|
1179 |
+
$(doc).on(duringDragEvents);
|
1180 |
+
$(doc.body).addClass("sp-dragging");
|
1181 |
+
|
1182 |
+
move(e);
|
1183 |
+
|
1184 |
+
prevent(e);
|
1185 |
+
}
|
1186 |
+
}
|
1187 |
+
}
|
1188 |
+
|
1189 |
+
function stop() {
|
1190 |
+
if (dragging) {
|
1191 |
+
$(doc).off(duringDragEvents);
|
1192 |
+
$(doc.body).removeClass("sp-dragging");
|
1193 |
+
|
1194 |
+
// Wait a tick before notifying observers to allow the click event
|
1195 |
+
// to fire in Chrome.
|
1196 |
+
setTimeout(function() {
|
1197 |
+
onstop.apply(element, arguments);
|
1198 |
+
}, 0);
|
1199 |
+
}
|
1200 |
+
dragging = false;
|
1201 |
+
}
|
1202 |
+
|
1203 |
+
$(element).on("touchstart mousedown", start);
|
1204 |
+
}
|
1205 |
+
|
1206 |
+
function throttle(func, wait, debounce) {
|
1207 |
+
var timeout;
|
1208 |
+
return function () {
|
1209 |
+
var context = this, args = arguments;
|
1210 |
+
var throttler = function () {
|
1211 |
+
timeout = null;
|
1212 |
+
func.apply(context, args);
|
1213 |
+
};
|
1214 |
+
if (debounce) clearTimeout(timeout);
|
1215 |
+
if (debounce || !timeout) timeout = setTimeout(throttler, wait);
|
1216 |
+
};
|
1217 |
+
}
|
1218 |
+
|
1219 |
+
function inputTypeColorSupport() {
|
1220 |
+
return $.fn.spectrum.inputTypeColorSupport();
|
1221 |
+
}
|
1222 |
+
|
1223 |
+
/**
|
1224 |
+
* Define a jQuery plugin
|
1225 |
+
*/
|
1226 |
+
var dataID = "spectrum.id";
|
1227 |
+
$.fn.spectrum = function (opts, extra) {
|
1228 |
+
|
1229 |
+
if (typeof opts == "string") {
|
1230 |
+
|
1231 |
+
var returnValue = this;
|
1232 |
+
var args = Array.prototype.slice.call( arguments, 1 );
|
1233 |
+
|
1234 |
+
this.each(function () {
|
1235 |
+
var spect = spectrums[$(this).data(dataID)];
|
1236 |
+
if (spect) {
|
1237 |
+
var method = spect[opts];
|
1238 |
+
if (!method) {
|
1239 |
+
throw new Error( "Spectrum: no such method: '" + opts + "'" );
|
1240 |
+
}
|
1241 |
+
|
1242 |
+
if (opts == "get") {
|
1243 |
+
returnValue = spect.get();
|
1244 |
+
}
|
1245 |
+
else if (opts == "container") {
|
1246 |
+
returnValue = spect.container;
|
1247 |
+
}
|
1248 |
+
else if (opts == "option") {
|
1249 |
+
returnValue = spect.option.apply(spect, args);
|
1250 |
+
}
|
1251 |
+
else if (opts == "destroy") {
|
1252 |
+
spect.destroy();
|
1253 |
+
$(this).removeData(dataID);
|
1254 |
+
}
|
1255 |
+
else {
|
1256 |
+
method.apply(spect, args);
|
1257 |
+
}
|
1258 |
+
}
|
1259 |
+
});
|
1260 |
+
|
1261 |
+
return returnValue;
|
1262 |
+
}
|
1263 |
+
|
1264 |
+
// Initializing a new instance of spectrum
|
1265 |
+
return this.spectrum("destroy").each(function () {
|
1266 |
+
var options = $.extend({}, $(this).data(), opts);
|
1267 |
+
var spect = spectrum(this, options);
|
1268 |
+
$(this).data(dataID, spect.id);
|
1269 |
+
});
|
1270 |
+
};
|
1271 |
+
|
1272 |
+
$.fn.spectrum.load = true;
|
1273 |
+
$.fn.spectrum.loadOpts = {};
|
1274 |
+
$.fn.spectrum.draggable = draggable;
|
1275 |
+
$.fn.spectrum.defaults = defaultOpts;
|
1276 |
+
$.fn.spectrum.inputTypeColorSupport = function inputTypeColorSupport() {
|
1277 |
+
if (typeof inputTypeColorSupport._cachedResult === "undefined") {
|
1278 |
+
var colorInput = $("<input type='color'/>")[0]; // if color element is supported, value will default to not null
|
1279 |
+
inputTypeColorSupport._cachedResult = colorInput.type === "color" && colorInput.value !== "";
|
1280 |
+
}
|
1281 |
+
return inputTypeColorSupport._cachedResult;
|
1282 |
+
};
|
1283 |
+
|
1284 |
+
$.spectrum = { };
|
1285 |
+
$.spectrum.localization = { };
|
1286 |
+
$.spectrum.palettes = { };
|
1287 |
+
|
1288 |
+
$.fn.spectrum.processNativeColorInputs = function () {
|
1289 |
+
var colorInputs = $("input[type=color]");
|
1290 |
+
if (colorInputs.length && !inputTypeColorSupport()) {
|
1291 |
+
colorInputs.spectrum({
|
1292 |
+
preferredFormat: "hex6"
|
1293 |
+
});
|
1294 |
+
}
|
1295 |
+
};
|
1296 |
+
|
1297 |
+
// TinyColor v1.1.2
|
1298 |
+
// https://github.com/bgrins/TinyColor
|
1299 |
+
// Brian Grinstead, MIT License
|
1300 |
+
|
1301 |
+
(function() {
|
1302 |
+
|
1303 |
+
var trimLeft = /^[\s,#]+/,
|
1304 |
+
trimRight = /\s+$/,
|
1305 |
+
tinyCounter = 0,
|
1306 |
+
math = Math,
|
1307 |
+
mathRound = math.round,
|
1308 |
+
mathMin = math.min,
|
1309 |
+
mathMax = math.max,
|
1310 |
+
mathRandom = math.random;
|
1311 |
+
|
1312 |
+
var tinycolor = function(color, opts) {
|
1313 |
+
|
1314 |
+
color = (color) ? color : '';
|
1315 |
+
opts = opts || { };
|
1316 |
+
|
1317 |
+
// If input is already a tinycolor, return itself
|
1318 |
+
if (color instanceof tinycolor) {
|
1319 |
+
return color;
|
1320 |
+
}
|
1321 |
+
// If we are called as a function, call using new instead
|
1322 |
+
if (!(this instanceof tinycolor)) {
|
1323 |
+
return new tinycolor(color, opts);
|
1324 |
+
}
|
1325 |
+
|
1326 |
+
var rgb = inputToRGB(color);
|
1327 |
+
this._originalInput = color;
|
1328 |
+
this._r = rgb.r;
|
1329 |
+
this._g = rgb.g;
|
1330 |
+
this._b = rgb.b;
|
1331 |
+
this._a = rgb.a;
|
1332 |
+
this._roundA = mathRound(1000 * this._a) / 1000;
|
1333 |
+
this._format = opts.format || rgb.format;
|
1334 |
+
this._gradientType = opts.gradientType;
|
1335 |
+
|
1336 |
+
// Don't let the range of [0,255] come back in [0,1].
|
1337 |
+
// Potentially lose a little bit of precision here, but will fix issues where
|
1338 |
+
// .5 gets interpreted as half of the total, instead of half of 1
|
1339 |
+
// If it was supposed to be 128, this was already taken care of by `inputToRgb`
|
1340 |
+
if (this._r < 1) { this._r = mathRound(this._r); }
|
1341 |
+
if (this._g < 1) { this._g = mathRound(this._g); }
|
1342 |
+
if (this._b < 1) { this._b = mathRound(this._b); }
|
1343 |
+
|
1344 |
+
this._ok = rgb.ok;
|
1345 |
+
this._tc_id = tinyCounter++;
|
1346 |
+
};
|
1347 |
+
|
1348 |
+
tinycolor.prototype = {
|
1349 |
+
isDark: function() {
|
1350 |
+
return this.getBrightness() < 128;
|
1351 |
+
},
|
1352 |
+
isLight: function() {
|
1353 |
+
return !this.isDark();
|
1354 |
+
},
|
1355 |
+
isValid: function() {
|
1356 |
+
return this._ok;
|
1357 |
+
},
|
1358 |
+
getOriginalInput: function() {
|
1359 |
+
return this._originalInput;
|
1360 |
+
},
|
1361 |
+
getFormat: function() {
|
1362 |
+
return this._format;
|
1363 |
+
},
|
1364 |
+
getAlpha: function() {
|
1365 |
+
return this._a;
|
1366 |
+
},
|
1367 |
+
getBrightness: function() {
|
1368 |
+
var rgb = this.toRgb();
|
1369 |
+
return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000;
|
1370 |
+
},
|
1371 |
+
setAlpha: function(value) {
|
1372 |
+
this._a = boundAlpha(value);
|
1373 |
+
this._roundA = mathRound(1000 * this._a) / 1000;
|
1374 |
+
return this;
|
1375 |
+
},
|
1376 |
+
toHsv: function() {
|
1377 |
+
var hsv = rgbToHsv(this._r, this._g, this._b);
|
1378 |
+
return { h: hsv.h * 360, s: hsv.s, v: hsv.v, a: this._a };
|
1379 |
+
},
|
1380 |
+
toHsvString: function() {
|
1381 |
+
var hsv = rgbToHsv(this._r, this._g, this._b);
|
1382 |
+
var h = mathRound(hsv.h * 360), s = mathRound(hsv.s * 100), v = mathRound(hsv.v * 100);
|
1383 |
+
return (this._a == 1) ?
|
1384 |
+
"hsv(" + h + ", " + s + "%, " + v + "%)" :
|
1385 |
+
"hsva(" + h + ", " + s + "%, " + v + "%, "+ this._roundA + ")";
|
1386 |
+
},
|
1387 |
+
toHsl: function() {
|
1388 |
+
var hsl = rgbToHsl(this._r, this._g, this._b);
|
1389 |
+
return { h: hsl.h * 360, s: hsl.s, l: hsl.l, a: this._a };
|
1390 |
+
},
|
1391 |
+
toHslString: function() {
|
1392 |
+
var hsl = rgbToHsl(this._r, this._g, this._b);
|
1393 |
+
var h = mathRound(hsl.h * 360), s = mathRound(hsl.s * 100), l = mathRound(hsl.l * 100);
|
1394 |
+
return (this._a == 1) ?
|
1395 |
+
"hsl(" + h + ", " + s + "%, " + l + "%)" :
|
1396 |
+
"hsla(" + h + ", " + s + "%, " + l + "%, "+ this._roundA + ")";
|
1397 |
+
},
|
1398 |
+
toHex: function(allow3Char) {
|
1399 |
+
return rgbToHex(this._r, this._g, this._b, allow3Char);
|
1400 |
+
},
|
1401 |
+
toHexString: function(allow3Char) {
|
1402 |
+
return '#' + this.toHex(allow3Char);
|
1403 |
+
},
|
1404 |
+
toHex8: function() {
|
1405 |
+
return rgbaToHex(this._r, this._g, this._b, this._a);
|
1406 |
+
},
|
1407 |
+
toHex8String: function() {
|
1408 |
+
return '#' + this.toHex8();
|
1409 |
+
},
|
1410 |
+
toRgb: function() {
|
1411 |
+
return { r: mathRound(this._r), g: mathRound(this._g), b: mathRound(this._b), a: this._a };
|
1412 |
+
},
|
1413 |
+
toRgbString: function() {
|
1414 |
+
return (this._a == 1) ?
|
1415 |
+
"rgb(" + mathRound(this._r) + ", " + mathRound(this._g) + ", " + mathRound(this._b) + ")" :
|
1416 |
+
"rgba(" + mathRound(this._r) + ", " + mathRound(this._g) + ", " + mathRound(this._b) + ", " + this._roundA + ")";
|
1417 |
+
},
|
1418 |
+
toPercentageRgb: function() {
|
1419 |
+
return { r: mathRound(bound01(this._r, 255) * 100) + "%", g: mathRound(bound01(this._g, 255) * 100) + "%", b: mathRound(bound01(this._b, 255) * 100) + "%", a: this._a };
|
1420 |
+
},
|
1421 |
+
toPercentageRgbString: function() {
|
1422 |
+
return (this._a == 1) ?
|
1423 |
+
"rgb(" + mathRound(bound01(this._r, 255) * 100) + "%, " + mathRound(bound01(this._g, 255) * 100) + "%, " + mathRound(bound01(this._b, 255) * 100) + "%)" :
|
1424 |
+
"rgba(" + mathRound(bound01(this._r, 255) * 100) + "%, " + mathRound(bound01(this._g, 255) * 100) + "%, " + mathRound(bound01(this._b, 255) * 100) + "%, " + this._roundA + ")";
|
1425 |
+
},
|
1426 |
+
toName: function() {
|
1427 |
+
if (this._a === 0) {
|
1428 |
+
return "transparent";
|
1429 |
+
}
|
1430 |
+
|
1431 |
+
if (this._a < 1) {
|
1432 |
+
return false;
|
1433 |
+
}
|
1434 |
+
|
1435 |
+
return hexNames[rgbToHex(this._r, this._g, this._b, true)] || false;
|
1436 |
+
},
|
1437 |
+
toFilter: function(secondColor) {
|
1438 |
+
var hex8String = '#' + rgbaToHex(this._r, this._g, this._b, this._a);
|
1439 |
+
var secondHex8String = hex8String;
|
1440 |
+
var gradientType = this._gradientType ? "GradientType = 1, " : "";
|
1441 |
+
|
1442 |
+
if (secondColor) {
|
1443 |
+
var s = tinycolor(secondColor);
|
1444 |
+
secondHex8String = s.toHex8String();
|
1445 |
+
}
|
1446 |
+
|
1447 |
+
return "progid:DXImageTransform.Microsoft.gradient("+gradientType+"startColorstr="+hex8String+",endColorstr="+secondHex8String+")";
|
1448 |
+
},
|
1449 |
+
toString: function(format) {
|
1450 |
+
var formatSet = !!format;
|
1451 |
+
format = format || this._format;
|
1452 |
+
|
1453 |
+
var formattedString = false;
|
1454 |
+
var hasAlpha = this._a < 1 && this._a >= 0;
|
1455 |
+
var needsAlphaFormat = !formatSet && hasAlpha && (format === "hex" || format === "hex6" || format === "hex3" || format === "name");
|
1456 |
+
|
1457 |
+
if (needsAlphaFormat) {
|
1458 |
+
// Special case for "transparent", all other non-alpha formats
|
1459 |
+
// will return rgba when there is transparency.
|
1460 |
+
if (format === "name" && this._a === 0) {
|
1461 |
+
return this.toName();
|
1462 |
+
}
|
1463 |
+
return this.toRgbString();
|
1464 |
+
}
|
1465 |
+
if (format === "rgb") {
|
1466 |
+
formattedString = this.toRgbString();
|
1467 |
+
}
|
1468 |
+
if (format === "prgb") {
|
1469 |
+
formattedString = this.toPercentageRgbString();
|
1470 |
+
}
|
1471 |
+
if (format === "hex" || format === "hex6") {
|
1472 |
+
formattedString = this.toHexString();
|
1473 |
+
}
|
1474 |
+
if (format === "hex3") {
|
1475 |
+
formattedString = this.toHexString(true);
|
1476 |
+
}
|
1477 |
+
if (format === "hex8") {
|
1478 |
+
formattedString = this.toHex8String();
|
1479 |
+
}
|
1480 |
+
if (format === "name") {
|
1481 |
+
formattedString = this.toName();
|
1482 |
+
}
|
1483 |
+
if (format === "hsl") {
|
1484 |
+
formattedString = this.toHslString();
|
1485 |
+
}
|
1486 |
+
if (format === "hsv") {
|
1487 |
+
formattedString = this.toHsvString();
|
1488 |
+
}
|
1489 |
+
|
1490 |
+
return formattedString || this.toHexString();
|
1491 |
+
},
|
1492 |
+
|
1493 |
+
_applyModification: function(fn, args) {
|
1494 |
+
var color = fn.apply(null, [this].concat([].slice.call(args)));
|
1495 |
+
this._r = color._r;
|
1496 |
+
this._g = color._g;
|
1497 |
+
this._b = color._b;
|
1498 |
+
this.setAlpha(color._a);
|
1499 |
+
return this;
|
1500 |
+
},
|
1501 |
+
lighten: function() {
|
1502 |
+
return this._applyModification(lighten, arguments);
|
1503 |
+
},
|
1504 |
+
brighten: function() {
|
1505 |
+
return this._applyModification(brighten, arguments);
|
1506 |
+
},
|
1507 |
+
darken: function() {
|
1508 |
+
return this._applyModification(darken, arguments);
|
1509 |
+
},
|
1510 |
+
desaturate: function() {
|
1511 |
+
return this._applyModification(desaturate, arguments);
|
1512 |
+
},
|
1513 |
+
saturate: function() {
|
1514 |
+
return this._applyModification(saturate, arguments);
|
1515 |
+
},
|
1516 |
+
greyscale: function() {
|
1517 |
+
return this._applyModification(greyscale, arguments);
|
1518 |
+
},
|
1519 |
+
spin: function() {
|
1520 |
+
return this._applyModification(spin, arguments);
|
1521 |
+
},
|
1522 |
+
|
1523 |
+
_applyCombination: function(fn, args) {
|
1524 |
+
return fn.apply(null, [this].concat([].slice.call(args)));
|
1525 |
+
},
|
1526 |
+
analogous: function() {
|
1527 |
+
return this._applyCombination(analogous, arguments);
|
1528 |
+
},
|
1529 |
+
complement: function() {
|
1530 |
+
return this._applyCombination(complement, arguments);
|
1531 |
+
},
|
1532 |
+
monochromatic: function() {
|
1533 |
+
return this._applyCombination(monochromatic, arguments);
|
1534 |
+
},
|
1535 |
+
splitcomplement: function() {
|
1536 |
+
return this._applyCombination(splitcomplement, arguments);
|
1537 |
+
},
|
1538 |
+
triad: function() {
|
1539 |
+
return this._applyCombination(triad, arguments);
|
1540 |
+
},
|
1541 |
+
tetrad: function() {
|
1542 |
+
return this._applyCombination(tetrad, arguments);
|
1543 |
+
}
|
1544 |
+
};
|
1545 |
+
|
1546 |
+
// If input is an object, force 1 into "1.0" to handle ratios properly
|
1547 |
+
// String input requires "1.0" as input, so 1 will be treated as 1
|
1548 |
+
tinycolor.fromRatio = function(color, opts) {
|
1549 |
+
if (typeof color == "object") {
|
1550 |
+
var newColor = {};
|
1551 |
+
for (var i in color) {
|
1552 |
+
if (color.hasOwnProperty(i)) {
|
1553 |
+
if (i === "a") {
|
1554 |
+
newColor[i] = color[i];
|
1555 |
+
}
|
1556 |
+
else {
|
1557 |
+
newColor[i] = convertToPercentage(color[i]);
|
1558 |
+
}
|
1559 |
+
}
|
1560 |
+
}
|
1561 |
+
color = newColor;
|
1562 |
+
}
|
1563 |
+
|
1564 |
+
return tinycolor(color, opts);
|
1565 |
+
};
|
1566 |
+
|
1567 |
+
// Given a string or object, convert that input to RGB
|
1568 |
+
// Possible string inputs:
|
1569 |
+
//
|
1570 |
+
// "red"
|
1571 |
+
// "#f00" or "f00"
|
1572 |
+
// "#ff0000" or "ff0000"
|
1573 |
+
// "#ff000000" or "ff000000"
|
1574 |
+
// "rgb 255 0 0" or "rgb (255, 0, 0)"
|
1575 |
+
// "rgb 1.0 0 0" or "rgb (1, 0, 0)"
|
1576 |
+
// "rgba (255, 0, 0, 1)" or "rgba 255, 0, 0, 1"
|
1577 |
+
// "rgba (1.0, 0, 0, 1)" or "rgba 1.0, 0, 0, 1"
|
1578 |
+
// "hsl(0, 100%, 50%)" or "hsl 0 100% 50%"
|
1579 |
+
// "hsla(0, 100%, 50%, 1)" or "hsla 0 100% 50%, 1"
|
1580 |
+
// "hsv(0, 100%, 100%)" or "hsv 0 100% 100%"
|
1581 |
+
//
|
1582 |
+
function inputToRGB(color) {
|
1583 |
+
|
1584 |
+
var rgb = { r: 0, g: 0, b: 0 };
|
1585 |
+
var a = 1;
|
1586 |
+
var ok = false;
|
1587 |
+
var format = false;
|
1588 |
+
|
1589 |
+
if (typeof color == "string") {
|
1590 |
+
color = stringInputToObject(color);
|
1591 |
+
}
|
1592 |
+
|
1593 |
+
if (typeof color == "object") {
|
1594 |
+
if (color.hasOwnProperty("r") && color.hasOwnProperty("g") && color.hasOwnProperty("b")) {
|
1595 |
+
rgb = rgbToRgb(color.r, color.g, color.b);
|
1596 |
+
ok = true;
|
1597 |
+
format = String(color.r).substr(-1) === "%" ? "prgb" : "rgb";
|
1598 |
+
}
|
1599 |
+
else if (color.hasOwnProperty("h") && color.hasOwnProperty("s") && color.hasOwnProperty("v")) {
|
1600 |
+
color.s = convertToPercentage(color.s);
|
1601 |
+
color.v = convertToPercentage(color.v);
|
1602 |
+
rgb = hsvToRgb(color.h, color.s, color.v);
|
1603 |
+
ok = true;
|
1604 |
+
format = "hsv";
|
1605 |
+
}
|
1606 |
+
else if (color.hasOwnProperty("h") && color.hasOwnProperty("s") && color.hasOwnProperty("l")) {
|
1607 |
+
color.s = convertToPercentage(color.s);
|
1608 |
+
color.l = convertToPercentage(color.l);
|
1609 |
+
rgb = hslToRgb(color.h, color.s, color.l);
|
1610 |
+
ok = true;
|
1611 |
+
format = "hsl";
|
1612 |
+
}
|
1613 |
+
|
1614 |
+
if (color.hasOwnProperty("a")) {
|
1615 |
+
a = color.a;
|
1616 |
+
}
|
1617 |
+
}
|
1618 |
+
|
1619 |
+
a = boundAlpha(a);
|
1620 |
+
|
1621 |
+
return {
|
1622 |
+
ok: ok,
|
1623 |
+
format: color.format || format,
|
1624 |
+
r: mathMin(255, mathMax(rgb.r, 0)),
|
1625 |
+
g: mathMin(255, mathMax(rgb.g, 0)),
|
1626 |
+
b: mathMin(255, mathMax(rgb.b, 0)),
|
1627 |
+
a: a
|
1628 |
+
};
|
1629 |
+
}
|
1630 |
+
|
1631 |
+
|
1632 |
+
// Conversion Functions
|
1633 |
+
// --------------------
|
1634 |
+
|
1635 |
+
// `rgbToHsl`, `rgbToHsv`, `hslToRgb`, `hsvToRgb` modified from:
|
1636 |
+
// <http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript>
|
1637 |
+
|
1638 |
+
// `rgbToRgb`
|
1639 |
+
// Handle bounds / percentage checking to conform to CSS color spec
|
1640 |
+
// <http://www.w3.org/TR/css3-color/>
|
1641 |
+
// *Assumes:* r, g, b in [0, 255] or [0, 1]
|
1642 |
+
// *Returns:* { r, g, b } in [0, 255]
|
1643 |
+
function rgbToRgb(r, g, b){
|
1644 |
+
return {
|
1645 |
+
r: bound01(r, 255) * 255,
|
1646 |
+
g: bound01(g, 255) * 255,
|
1647 |
+
b: bound01(b, 255) * 255
|
1648 |
+
};
|
1649 |
+
}
|
1650 |
+
|
1651 |
+
// `rgbToHsl`
|
1652 |
+
// Converts an RGB color value to HSL.
|
1653 |
+
// *Assumes:* r, g, and b are contained in [0, 255] or [0, 1]
|
1654 |
+
// *Returns:* { h, s, l } in [0,1]
|
1655 |
+
function rgbToHsl(r, g, b) {
|
1656 |
+
|
1657 |
+
r = bound01(r, 255);
|
1658 |
+
g = bound01(g, 255);
|
1659 |
+
b = bound01(b, 255);
|
1660 |
+
|
1661 |
+
var max = mathMax(r, g, b), min = mathMin(r, g, b);
|
1662 |
+
var h, s, l = (max + min) / 2;
|
1663 |
+
|
1664 |
+
if(max == min) {
|
1665 |
+
h = s = 0; // achromatic
|
1666 |
+
}
|
1667 |
+
else {
|
1668 |
+
var d = max - min;
|
1669 |
+
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
1670 |
+
switch(max) {
|
1671 |
+
case r: h = (g - b) / d + (g < b ? 6 : 0); break;
|
1672 |
+
case g: h = (b - r) / d + 2; break;
|
1673 |
+
case b: h = (r - g) / d + 4; break;
|
1674 |
+
}
|
1675 |
+
|
1676 |
+
h /= 6;
|
1677 |
+
}
|
1678 |
+
|
1679 |
+
return { h: h, s: s, l: l };
|
1680 |
+
}
|
1681 |
+
|
1682 |
+
// `hslToRgb`
|
1683 |
+
// Converts an HSL color value to RGB.
|
1684 |
+
// *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100]
|
1685 |
+
// *Returns:* { r, g, b } in the set [0, 255]
|
1686 |
+
function hslToRgb(h, s, l) {
|
1687 |
+
var r, g, b;
|
1688 |
+
|
1689 |
+
h = bound01(h, 360);
|
1690 |
+
s = bound01(s, 100);
|
1691 |
+
l = bound01(l, 100);
|
1692 |
+
|
1693 |
+
function hue2rgb(p, q, t) {
|
1694 |
+
if(t < 0) t += 1;
|
1695 |
+
if(t > 1) t -= 1;
|
1696 |
+
if(t < 1/6) return p + (q - p) * 6 * t;
|
1697 |
+
if(t < 1/2) return q;
|
1698 |
+
if(t < 2/3) return p + (q - p) * (2/3 - t) * 6;
|
1699 |
+
return p;
|
1700 |
+
}
|
1701 |
+
|
1702 |
+
if(s === 0) {
|
1703 |
+
r = g = b = l; // achromatic
|
1704 |
+
}
|
1705 |
+
else {
|
1706 |
+
var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
|
1707 |
+
var p = 2 * l - q;
|
1708 |
+
r = hue2rgb(p, q, h + 1/3);
|
1709 |
+
g = hue2rgb(p, q, h);
|
1710 |
+
b = hue2rgb(p, q, h - 1/3);
|
1711 |
+
}
|
1712 |
+
|
1713 |
+
return { r: r * 255, g: g * 255, b: b * 255 };
|
1714 |
+
}
|
1715 |
+
|
1716 |
+
// `rgbToHsv`
|
1717 |
+
// Converts an RGB color value to HSV
|
1718 |
+
// *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1]
|
1719 |
+
// *Returns:* { h, s, v } in [0,1]
|
1720 |
+
function rgbToHsv(r, g, b) {
|
1721 |
+
|
1722 |
+
r = bound01(r, 255);
|
1723 |
+
g = bound01(g, 255);
|
1724 |
+
b = bound01(b, 255);
|
1725 |
+
|
1726 |
+
var max = mathMax(r, g, b), min = mathMin(r, g, b);
|
1727 |
+
var h, s, v = max;
|
1728 |
+
|
1729 |
+
var d = max - min;
|
1730 |
+
s = max === 0 ? 0 : d / max;
|
1731 |
+
|
1732 |
+
if(max == min) {
|
1733 |
+
h = 0; // achromatic
|
1734 |
+
}
|
1735 |
+
else {
|
1736 |
+
switch(max) {
|
1737 |
+
case r: h = (g - b) / d + (g < b ? 6 : 0); break;
|
1738 |
+
case g: h = (b - r) / d + 2; break;
|
1739 |
+
case b: h = (r - g) / d + 4; break;
|
1740 |
+
}
|
1741 |
+
h /= 6;
|
1742 |
+
}
|
1743 |
+
return { h: h, s: s, v: v };
|
1744 |
+
}
|
1745 |
+
|
1746 |
+
// `hsvToRgb`
|
1747 |
+
// Converts an HSV color value to RGB.
|
1748 |
+
// *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100]
|
1749 |
+
// *Returns:* { r, g, b } in the set [0, 255]
|
1750 |
+
function hsvToRgb(h, s, v) {
|
1751 |
+
|
1752 |
+
h = bound01(h, 360) * 6;
|
1753 |
+
s = bound01(s, 100);
|
1754 |
+
v = bound01(v, 100);
|
1755 |
+
|
1756 |
+
var i = math.floor(h),
|
1757 |
+
f = h - i,
|
1758 |
+
p = v * (1 - s),
|
1759 |
+
q = v * (1 - f * s),
|
1760 |
+
t = v * (1 - (1 - f) * s),
|
1761 |
+
mod = i % 6,
|
1762 |
+
r = [v, q, p, p, t, v][mod],
|
1763 |
+
g = [t, v, v, q, p, p][mod],
|
1764 |
+
b = [p, p, t, v, v, q][mod];
|
1765 |
+
|
1766 |
+
return { r: r * 255, g: g * 255, b: b * 255 };
|
1767 |
+
}
|
1768 |
+
|
1769 |
+
// `rgbToHex`
|
1770 |
+
// Converts an RGB color to hex
|
1771 |
+
// Assumes r, g, and b are contained in the set [0, 255]
|
1772 |
+
// Returns a 3 or 6 character hex
|
1773 |
+
function rgbToHex(r, g, b, allow3Char) {
|
1774 |
+
|
1775 |
+
var hex = [
|
1776 |
+
pad2(mathRound(r).toString(16)),
|
1777 |
+
pad2(mathRound(g).toString(16)),
|
1778 |
+
pad2(mathRound(b).toString(16))
|
1779 |
+
];
|
1780 |
+
|
1781 |
+
// Return a 3 character hex if possible
|
1782 |
+
if (allow3Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1)) {
|
1783 |
+
return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0);
|
1784 |
+
}
|
1785 |
+
|
1786 |
+
return hex.join("");
|
1787 |
+
}
|
1788 |
+
// `rgbaToHex`
|
1789 |
+
// Converts an RGBA color plus alpha transparency to hex
|
1790 |
+
// Assumes r, g, b and a are contained in the set [0, 255]
|
1791 |
+
// Returns an 8 character hex
|
1792 |
+
function rgbaToHex(r, g, b, a) {
|
1793 |
+
|
1794 |
+
var hex = [
|
1795 |
+
pad2(convertDecimalToHex(a)),
|
1796 |
+
pad2(mathRound(r).toString(16)),
|
1797 |
+
pad2(mathRound(g).toString(16)),
|
1798 |
+
pad2(mathRound(b).toString(16))
|
1799 |
+
];
|
1800 |
+
|
1801 |
+
return hex.join("");
|
1802 |
+
}
|
1803 |
+
|
1804 |
+
// `equals`
|
1805 |
+
// Can be called with any tinycolor input
|
1806 |
+
tinycolor.equals = function (color1, color2) {
|
1807 |
+
if (!color1 || !color2) { return false; }
|
1808 |
+
return tinycolor(color1).toRgbString() == tinycolor(color2).toRgbString();
|
1809 |
+
};
|
1810 |
+
tinycolor.random = function() {
|
1811 |
+
return tinycolor.fromRatio({
|
1812 |
+
r: mathRandom(),
|
1813 |
+
g: mathRandom(),
|
1814 |
+
b: mathRandom()
|
1815 |
+
});
|
1816 |
+
};
|
1817 |
+
|
1818 |
+
|
1819 |
+
// Modification Functions
|
1820 |
+
// ----------------------
|
1821 |
+
// Thanks to less.js for some of the basics here
|
1822 |
+
// <https://github.com/cloudhead/less.js/blob/master/lib/less/functions.js>
|
1823 |
+
|
1824 |
+
function desaturate(color, amount) {
|
1825 |
+
amount = (amount === 0) ? 0 : (amount || 10);
|
1826 |
+
var hsl = tinycolor(color).toHsl();
|
1827 |
+
hsl.s -= amount / 100;
|
1828 |
+
hsl.s = clamp01(hsl.s);
|
1829 |
+
return tinycolor(hsl);
|
1830 |
+
}
|
1831 |
+
|
1832 |
+
function saturate(color, amount) {
|
1833 |
+
amount = (amount === 0) ? 0 : (amount || 10);
|
1834 |
+
var hsl = tinycolor(color).toHsl();
|
1835 |
+
hsl.s += amount / 100;
|
1836 |
+
hsl.s = clamp01(hsl.s);
|
1837 |
+
return tinycolor(hsl);
|
1838 |
+
}
|
1839 |
+
|
1840 |
+
function greyscale(color) {
|
1841 |
+
return tinycolor(color).desaturate(100);
|
1842 |
+
}
|
1843 |
+
|
1844 |
+
function lighten (color, amount) {
|
1845 |
+
amount = (amount === 0) ? 0 : (amount || 10);
|
1846 |
+
var hsl = tinycolor(color).toHsl();
|
1847 |
+
hsl.l += amount / 100;
|
1848 |
+
hsl.l = clamp01(hsl.l);
|
1849 |
+
return tinycolor(hsl);
|
1850 |
+
}
|
1851 |
+
|
1852 |
+
function brighten(color, amount) {
|
1853 |
+
amount = (amount === 0) ? 0 : (amount || 10);
|
1854 |
+
var rgb = tinycolor(color).toRgb();
|
1855 |
+
rgb.r = mathMax(0, mathMin(255, rgb.r - mathRound(255 * - (amount / 100))));
|
1856 |
+
rgb.g = mathMax(0, mathMin(255, rgb.g - mathRound(255 * - (amount / 100))));
|
1857 |
+
rgb.b = mathMax(0, mathMin(255, rgb.b - mathRound(255 * - (amount / 100))));
|
1858 |
+
return tinycolor(rgb);
|
1859 |
+
}
|
1860 |
+
|
1861 |
+
function darken (color, amount) {
|
1862 |
+
amount = (amount === 0) ? 0 : (amount || 10);
|
1863 |
+
var hsl = tinycolor(color).toHsl();
|
1864 |
+
hsl.l -= amount / 100;
|
1865 |
+
hsl.l = clamp01(hsl.l);
|
1866 |
+
return tinycolor(hsl);
|
1867 |
+
}
|
1868 |
+
|
1869 |
+
// Spin takes a positive or negative amount within [-360, 360] indicating the change of hue.
|
1870 |
+
// Values outside of this range will be wrapped into this range.
|
1871 |
+
function spin(color, amount) {
|
1872 |
+
var hsl = tinycolor(color).toHsl();
|
1873 |
+
var hue = (mathRound(hsl.h) + amount) % 360;
|
1874 |
+
hsl.h = hue < 0 ? 360 + hue : hue;
|
1875 |
+
return tinycolor(hsl);
|
1876 |
+
}
|
1877 |
+
|
1878 |
+
// Combination Functions
|
1879 |
+
// ---------------------
|
1880 |
+
// Thanks to jQuery xColor for some of the ideas behind these
|
1881 |
+
// <https://github.com/infusion/jQuery-xcolor/blob/master/jquery.xcolor.js>
|
1882 |
+
|
1883 |
+
function complement(color) {
|
1884 |
+
var hsl = tinycolor(color).toHsl();
|
1885 |
+
hsl.h = (hsl.h + 180) % 360;
|
1886 |
+
return tinycolor(hsl);
|
1887 |
+
}
|
1888 |
+
|
1889 |
+
function triad(color) {
|
1890 |
+
var hsl = tinycolor(color).toHsl();
|
1891 |
+
var h = hsl.h;
|
1892 |
+
return [
|
1893 |
+
tinycolor(color),
|
1894 |
+
tinycolor({ h: (h + 120) % 360, s: hsl.s, l: hsl.l }),
|
1895 |
+
tinycolor({ h: (h + 240) % 360, s: hsl.s, l: hsl.l })
|
1896 |
+
];
|
1897 |
+
}
|
1898 |
+
|
1899 |
+
function tetrad(color) {
|
1900 |
+
var hsl = tinycolor(color).toHsl();
|
1901 |
+
var h = hsl.h;
|
1902 |
+
return [
|
1903 |
+
tinycolor(color),
|
1904 |
+
tinycolor({ h: (h + 90) % 360, s: hsl.s, l: hsl.l }),
|
1905 |
+
tinycolor({ h: (h + 180) % 360, s: hsl.s, l: hsl.l }),
|
1906 |
+
tinycolor({ h: (h + 270) % 360, s: hsl.s, l: hsl.l })
|
1907 |
+
];
|
1908 |
+
}
|
1909 |
+
|
1910 |
+
function splitcomplement(color) {
|
1911 |
+
var hsl = tinycolor(color).toHsl();
|
1912 |
+
var h = hsl.h;
|
1913 |
+
return [
|
1914 |
+
tinycolor(color),
|
1915 |
+
tinycolor({ h: (h + 72) % 360, s: hsl.s, l: hsl.l}),
|
1916 |
+
tinycolor({ h: (h + 216) % 360, s: hsl.s, l: hsl.l})
|
1917 |
+
];
|
1918 |
+
}
|
1919 |
+
|
1920 |
+
function analogous(color, results, slices) {
|
1921 |
+
results = results || 6;
|
1922 |
+
slices = slices || 30;
|
1923 |
+
|
1924 |
+
var hsl = tinycolor(color).toHsl();
|
1925 |
+
var part = 360 / slices;
|
1926 |
+
var ret = [tinycolor(color)];
|
1927 |
+
|
1928 |
+
for (hsl.h = ((hsl.h - (part * results >> 1)) + 720) % 360; --results; ) {
|
1929 |
+
hsl.h = (hsl.h + part) % 360;
|
1930 |
+
ret.push(tinycolor(hsl));
|
1931 |
+
}
|
1932 |
+
return ret;
|
1933 |
+
}
|
1934 |
+
|
1935 |
+
function monochromatic(color, results) {
|
1936 |
+
results = results || 6;
|
1937 |
+
var hsv = tinycolor(color).toHsv();
|
1938 |
+
var h = hsv.h, s = hsv.s, v = hsv.v;
|
1939 |
+
var ret = [];
|
1940 |
+
var modification = 1 / results;
|
1941 |
+
|
1942 |
+
while (results--) {
|
1943 |
+
ret.push(tinycolor({ h: h, s: s, v: v}));
|
1944 |
+
v = (v + modification) % 1;
|
1945 |
+
}
|
1946 |
+
|
1947 |
+
return ret;
|
1948 |
+
}
|
1949 |
+
|
1950 |
+
// Utility Functions
|
1951 |
+
// ---------------------
|
1952 |
+
|
1953 |
+
tinycolor.mix = function(color1, color2, amount) {
|
1954 |
+
amount = (amount === 0) ? 0 : (amount || 50);
|
1955 |
+
|
1956 |
+
var rgb1 = tinycolor(color1).toRgb();
|
1957 |
+
var rgb2 = tinycolor(color2).toRgb();
|
1958 |
+
|
1959 |
+
var p = amount / 100;
|
1960 |
+
var w = p * 2 - 1;
|
1961 |
+
var a = rgb2.a - rgb1.a;
|
1962 |
+
|
1963 |
+
var w1;
|
1964 |
+
|
1965 |
+
if (w * a == -1) {
|
1966 |
+
w1 = w;
|
1967 |
+
} else {
|
1968 |
+
w1 = (w + a) / (1 + w * a);
|
1969 |
+
}
|
1970 |
+
|
1971 |
+
w1 = (w1 + 1) / 2;
|
1972 |
+
|
1973 |
+
var w2 = 1 - w1;
|
1974 |
+
|
1975 |
+
var rgba = {
|
1976 |
+
r: rgb2.r * w1 + rgb1.r * w2,
|
1977 |
+
g: rgb2.g * w1 + rgb1.g * w2,
|
1978 |
+
b: rgb2.b * w1 + rgb1.b * w2,
|
1979 |
+
a: rgb2.a * p + rgb1.a * (1 - p)
|
1980 |
+
};
|
1981 |
+
|
1982 |
+
return tinycolor(rgba);
|
1983 |
+
};
|
1984 |
+
|
1985 |
+
|
1986 |
+
// Readability Functions
|
1987 |
+
// ---------------------
|
1988 |
+
// <http://www.w3.org/TR/AERT#color-contrast>
|
1989 |
+
|
1990 |
+
// `readability`
|
1991 |
+
// Analyze the 2 colors and returns an object with the following properties:
|
1992 |
+
// `brightness`: difference in brightness between the two colors
|
1993 |
+
// `color`: difference in color/hue between the two colors
|
1994 |
+
tinycolor.readability = function(color1, color2) {
|
1995 |
+
var c1 = tinycolor(color1);
|
1996 |
+
var c2 = tinycolor(color2);
|
1997 |
+
var rgb1 = c1.toRgb();
|
1998 |
+
var rgb2 = c2.toRgb();
|
1999 |
+
var brightnessA = c1.getBrightness();
|
2000 |
+
var brightnessB = c2.getBrightness();
|
2001 |
+
var colorDiff = (
|
2002 |
+
Math.max(rgb1.r, rgb2.r) - Math.min(rgb1.r, rgb2.r) +
|
2003 |
+
Math.max(rgb1.g, rgb2.g) - Math.min(rgb1.g, rgb2.g) +
|
2004 |
+
Math.max(rgb1.b, rgb2.b) - Math.min(rgb1.b, rgb2.b)
|
2005 |
+
);
|
2006 |
+
|
2007 |
+
return {
|
2008 |
+
brightness: Math.abs(brightnessA - brightnessB),
|
2009 |
+
color: colorDiff
|
2010 |
+
};
|
2011 |
+
};
|
2012 |
+
|
2013 |
+
// `readable`
|
2014 |
+
// http://www.w3.org/TR/AERT#color-contrast
|
2015 |
+
// Ensure that foreground and background color combinations provide sufficient contrast.
|
2016 |
+
// *Example*
|
2017 |
+
// tinycolor.isReadable("#000", "#111") => false
|
2018 |
+
tinycolor.isReadable = function(color1, color2) {
|
2019 |
+
var readability = tinycolor.readability(color1, color2);
|
2020 |
+
return readability.brightness > 125 && readability.color > 500;
|
2021 |
+
};
|
2022 |
+
|
2023 |
+
// `mostReadable`
|
2024 |
+
// Given a base color and a list of possible foreground or background
|
2025 |
+
// colors for that base, returns the most readable color.
|
2026 |
+
// *Example*
|
2027 |
+
// tinycolor.mostReadable("#123", ["#fff", "#000"]) => "#000"
|
2028 |
+
tinycolor.mostReadable = function(baseColor, colorList) {
|
2029 |
+
var bestColor = null;
|
2030 |
+
var bestScore = 0;
|
2031 |
+
var bestIsReadable = false;
|
2032 |
+
for (var i=0; i < colorList.length; i++) {
|
2033 |
+
|
2034 |
+
// We normalize both around the "acceptable" breaking point,
|
2035 |
+
// but rank brightness constrast higher than hue.
|
2036 |
+
|
2037 |
+
var readability = tinycolor.readability(baseColor, colorList[i]);
|
2038 |
+
var readable = readability.brightness > 125 && readability.color > 500;
|
2039 |
+
var score = 3 * (readability.brightness / 125) + (readability.color / 500);
|
2040 |
+
|
2041 |
+
if ((readable && ! bestIsReadable) ||
|
2042 |
+
(readable && bestIsReadable && score > bestScore) ||
|
2043 |
+
((! readable) && (! bestIsReadable) && score > bestScore)) {
|
2044 |
+
bestIsReadable = readable;
|
2045 |
+
bestScore = score;
|
2046 |
+
bestColor = tinycolor(colorList[i]);
|
2047 |
+
}
|
2048 |
+
}
|
2049 |
+
return bestColor;
|
2050 |
+
};
|
2051 |
+
|
2052 |
+
|
2053 |
+
// Big List of Colors
|
2054 |
+
// ------------------
|
2055 |
+
// <http://www.w3.org/TR/css3-color/#svg-color>
|
2056 |
+
var names = tinycolor.names = {
|
2057 |
+
aliceblue: "f0f8ff",
|
2058 |
+
antiquewhite: "faebd7",
|
2059 |
+
aqua: "0ff",
|
2060 |
+
aquamarine: "7fffd4",
|
2061 |
+
azure: "f0ffff",
|
2062 |
+
beige: "f5f5dc",
|
2063 |
+
bisque: "ffe4c4",
|
2064 |
+
black: "000",
|
2065 |
+
blanchedalmond: "ffebcd",
|
2066 |
+
blue: "00f",
|
2067 |
+
blueviolet: "8a2be2",
|
2068 |
+
brown: "a52a2a",
|
2069 |
+
burlywood: "deb887",
|
2070 |
+
burntsienna: "ea7e5d",
|
2071 |
+
cadetblue: "5f9ea0",
|
2072 |
+
chartreuse: "7fff00",
|
2073 |
+
chocolate: "d2691e",
|
2074 |
+
coral: "ff7f50",
|
2075 |
+
cornflowerblue: "6495ed",
|
2076 |
+
cornsilk: "fff8dc",
|
2077 |
+
crimson: "dc143c",
|
2078 |
+
cyan: "0ff",
|
2079 |
+
darkblue: "00008b",
|
2080 |
+
darkcyan: "008b8b",
|
2081 |
+
darkgoldenrod: "b8860b",
|
2082 |
+
darkgray: "a9a9a9",
|
2083 |
+
darkgreen: "006400",
|
2084 |
+
darkgrey: "a9a9a9",
|
2085 |
+
darkkhaki: "bdb76b",
|
2086 |
+
darkmagenta: "8b008b",
|
2087 |
+
darkolivegreen: "556b2f",
|
2088 |
+
darkorange: "ff8c00",
|
2089 |
+
darkorchid: "9932cc",
|
2090 |
+
darkred: "8b0000",
|
2091 |
+
darksalmon: "e9967a",
|
2092 |
+
darkseagreen: "8fbc8f",
|
2093 |
+
darkslateblue: "483d8b",
|
2094 |
+
darkslategray: "2f4f4f",
|
2095 |
+
darkslategrey: "2f4f4f",
|
2096 |
+
darkturquoise: "00ced1",
|
2097 |
+
darkviolet: "9400d3",
|
2098 |
+
deeppink: "ff1493",
|
2099 |
+
deepskyblue: "00bfff",
|
2100 |
+
dimgray: "696969",
|
2101 |
+
dimgrey: "696969",
|
2102 |
+
dodgerblue: "1e90ff",
|
2103 |
+
firebrick: "b22222",
|
2104 |
+
floralwhite: "fffaf0",
|
2105 |
+
forestgreen: "228b22",
|
2106 |
+
fuchsia: "f0f",
|
2107 |
+
gainsboro: "dcdcdc",
|
2108 |
+
ghostwhite: "f8f8ff",
|
2109 |
+
gold: "ffd700",
|
2110 |
+
goldenrod: "daa520",
|
2111 |
+
gray: "808080",
|
2112 |
+
green: "008000",
|
2113 |
+
greenyellow: "adff2f",
|
2114 |
+
grey: "808080",
|
2115 |
+
honeydew: "f0fff0",
|
2116 |
+
hotpink: "ff69b4",
|
2117 |
+
indianred: "cd5c5c",
|
2118 |
+
indigo: "4b0082",
|
2119 |
+
ivory: "fffff0",
|
2120 |
+
khaki: "f0e68c",
|
2121 |
+
lavender: "e6e6fa",
|
2122 |
+
lavenderblush: "fff0f5",
|
2123 |
+
lawngreen: "7cfc00",
|
2124 |
+
lemonchiffon: "fffacd",
|
2125 |
+
lightblue: "add8e6",
|
2126 |
+
lightcoral: "f08080",
|
2127 |
+
lightcyan: "e0ffff",
|
2128 |
+
lightgoldenrodyellow: "fafad2",
|
2129 |
+
lightgray: "d3d3d3",
|
2130 |
+
lightgreen: "90ee90",
|
2131 |
+
lightgrey: "d3d3d3",
|
2132 |
+
lightpink: "ffb6c1",
|
2133 |
+
lightsalmon: "ffa07a",
|
2134 |
+
lightseagreen: "20b2aa",
|
2135 |
+
lightskyblue: "87cefa",
|
2136 |
+
lightslategray: "789",
|
2137 |
+
lightslategrey: "789",
|
2138 |
+
lightsteelblue: "b0c4de",
|
2139 |
+
lightyellow: "ffffe0",
|
2140 |
+
lime: "0f0",
|
2141 |
+
limegreen: "32cd32",
|
2142 |
+
linen: "faf0e6",
|
2143 |
+
magenta: "f0f",
|
2144 |
+
maroon: "800000",
|
2145 |
+
mediumaquamarine: "66cdaa",
|
2146 |
+
mediumblue: "0000cd",
|
2147 |
+
mediumorchid: "ba55d3",
|
2148 |
+
mediumpurple: "9370db",
|
2149 |
+
mediumseagreen: "3cb371",
|
2150 |
+
mediumslateblue: "7b68ee",
|
2151 |
+
mediumspringgreen: "00fa9a",
|
2152 |
+
mediumturquoise: "48d1cc",
|
2153 |
+
mediumvioletred: "c71585",
|
2154 |
+
midnightblue: "191970",
|
2155 |
+
mintcream: "f5fffa",
|
2156 |
+
mistyrose: "ffe4e1",
|
2157 |
+
moccasin: "ffe4b5",
|
2158 |
+
navajowhite: "ffdead",
|
2159 |
+
navy: "000080",
|
2160 |
+
oldlace: "fdf5e6",
|
2161 |
+
olive: "808000",
|
2162 |
+
olivedrab: "6b8e23",
|
2163 |
+
orange: "ffa500",
|
2164 |
+
orangered: "ff4500",
|
2165 |
+
orchid: "da70d6",
|
2166 |
+
palegoldenrod: "eee8aa",
|
2167 |
+
palegreen: "98fb98",
|
2168 |
+
paleturquoise: "afeeee",
|
2169 |
+
palevioletred: "db7093",
|
2170 |
+
papayawhip: "ffefd5",
|
2171 |
+
peachpuff: "ffdab9",
|
2172 |
+
peru: "cd853f",
|
2173 |
+
pink: "ffc0cb",
|
2174 |
+
plum: "dda0dd",
|
2175 |
+
powderblue: "b0e0e6",
|
2176 |
+
purple: "800080",
|
2177 |
+
rebeccapurple: "663399",
|
2178 |
+
red: "f00",
|
2179 |
+
rosybrown: "bc8f8f",
|
2180 |
+
royalblue: "4169e1",
|
2181 |
+
saddlebrown: "8b4513",
|
2182 |
+
salmon: "fa8072",
|
2183 |
+
sandybrown: "f4a460",
|
2184 |
+
seagreen: "2e8b57",
|
2185 |
+
seashell: "fff5ee",
|
2186 |
+
sienna: "a0522d",
|
2187 |
+
silver: "c0c0c0",
|
2188 |
+
skyblue: "87ceeb",
|
2189 |
+
slateblue: "6a5acd",
|
2190 |
+
slategray: "708090",
|
2191 |
+
slategrey: "708090",
|
2192 |
+
snow: "fffafa",
|
2193 |
+
springgreen: "00ff7f",
|
2194 |
+
steelblue: "4682b4",
|
2195 |
+
tan: "d2b48c",
|
2196 |
+
teal: "008080",
|
2197 |
+
thistle: "d8bfd8",
|
2198 |
+
tomato: "ff6347",
|
2199 |
+
turquoise: "40e0d0",
|
2200 |
+
violet: "ee82ee",
|
2201 |
+
wheat: "f5deb3",
|
2202 |
+
white: "fff",
|
2203 |
+
whitesmoke: "f5f5f5",
|
2204 |
+
yellow: "ff0",
|
2205 |
+
yellowgreen: "9acd32"
|
2206 |
+
};
|
2207 |
+
|
2208 |
+
// Make it easy to access colors via `hexNames[hex]`
|
2209 |
+
var hexNames = tinycolor.hexNames = flip(names);
|
2210 |
+
|
2211 |
+
|
2212 |
+
// Utilities
|
2213 |
+
// ---------
|
2214 |
+
|
2215 |
+
// `{ 'name1': 'val1' }` becomes `{ 'val1': 'name1' }`
|
2216 |
+
function flip(o) {
|
2217 |
+
var flipped = { };
|
2218 |
+
for (var i in o) {
|
2219 |
+
if (o.hasOwnProperty(i)) {
|
2220 |
+
flipped[o[i]] = i;
|
2221 |
+
}
|
2222 |
+
}
|
2223 |
+
return flipped;
|
2224 |
+
}
|
2225 |
+
|
2226 |
+
// Return a valid alpha value [0,1] with all invalid values being set to 1
|
2227 |
+
function boundAlpha(a) {
|
2228 |
+
a = parseFloat(a);
|
2229 |
+
|
2230 |
+
if (isNaN(a) || a < 0 || a > 1) {
|
2231 |
+
a = 1;
|
2232 |
+
}
|
2233 |
+
|
2234 |
+
return a;
|
2235 |
+
}
|
2236 |
+
|
2237 |
+
// Take input from [0, n] and return it as [0, 1]
|
2238 |
+
function bound01(n, max) {
|
2239 |
+
if (isOnePointZero(n)) { n = "100%"; }
|
2240 |
+
|
2241 |
+
var processPercent = isPercentage(n);
|
2242 |
+
n = mathMin(max, mathMax(0, parseFloat(n)));
|
2243 |
+
|
2244 |
+
// Automatically convert percentage into number
|
2245 |
+
if (processPercent) {
|
2246 |
+
n = parseInt(n * max, 10) / 100;
|
2247 |
+
}
|
2248 |
+
|
2249 |
+
// Handle floating point rounding errors
|
2250 |
+
if ((math.abs(n - max) < 0.000001)) {
|
2251 |
+
return 1;
|
2252 |
+
}
|
2253 |
+
|
2254 |
+
// Convert into [0, 1] range if it isn't already
|
2255 |
+
return (n % max) / parseFloat(max);
|
2256 |
+
}
|
2257 |
+
|
2258 |
+
// Force a number between 0 and 1
|
2259 |
+
function clamp01(val) {
|
2260 |
+
return mathMin(1, mathMax(0, val));
|
2261 |
+
}
|
2262 |
+
|
2263 |
+
// Parse a base-16 hex value into a base-10 integer
|
2264 |
+
function parseIntFromHex(val) {
|
2265 |
+
return parseInt(val, 16);
|
2266 |
+
}
|
2267 |
+
|
2268 |
+
// Need to handle 1.0 as 100%, since once it is a number, there is no difference between it and 1
|
2269 |
+
// <http://stackoverflow.com/questions/7422072/javascript-how-to-detect-number-as-a-decimal-including-1-0>
|
2270 |
+
function isOnePointZero(n) {
|
2271 |
+
return typeof n == "string" && n.indexOf('.') != -1 && parseFloat(n) === 1;
|
2272 |
+
}
|
2273 |
+
|
2274 |
+
// Check to see if string passed in is a percentage
|
2275 |
+
function isPercentage(n) {
|
2276 |
+
return typeof n === "string" && n.indexOf('%') != -1;
|
2277 |
+
}
|
2278 |
+
|
2279 |
+
// Force a hex value to have 2 characters
|
2280 |
+
function pad2(c) {
|
2281 |
+
return c.length == 1 ? '0' + c : '' + c;
|
2282 |
+
}
|
2283 |
+
|
2284 |
+
// Replace a decimal with it's percentage value
|
2285 |
+
function convertToPercentage(n) {
|
2286 |
+
if (n <= 1) {
|
2287 |
+
n = (n * 100) + "%";
|
2288 |
+
}
|
2289 |
+
|
2290 |
+
return n;
|
2291 |
+
}
|
2292 |
+
|
2293 |
+
// Converts a decimal to a hex value
|
2294 |
+
function convertDecimalToHex(d) {
|
2295 |
+
return Math.round(parseFloat(d) * 255).toString(16);
|
2296 |
+
}
|
2297 |
+
// Converts a hex value to a decimal
|
2298 |
+
function convertHexToDecimal(h) {
|
2299 |
+
return (parseIntFromHex(h) / 255);
|
2300 |
+
}
|
2301 |
+
|
2302 |
+
var matchers = (function() {
|
2303 |
+
|
2304 |
+
// <http://www.w3.org/TR/css3-values/#integers>
|
2305 |
+
var CSS_INTEGER = "[-\\+]?\\d+%?";
|
2306 |
+
|
2307 |
+
// <http://www.w3.org/TR/css3-values/#number-value>
|
2308 |
+
var CSS_NUMBER = "[-\\+]?\\d*\\.\\d+%?";
|
2309 |
+
|
2310 |
+
// Allow positive/negative integer/number. Don't capture the either/or, just the entire outcome.
|
2311 |
+
var CSS_UNIT = "(?:" + CSS_NUMBER + ")|(?:" + CSS_INTEGER + ")";
|
2312 |
+
|
2313 |
+
// Actual matching.
|
2314 |
+
// Parentheses and commas are optional, but not required.
|
2315 |
+
// Whitespace can take the place of commas or opening paren
|
2316 |
+
var PERMISSIVE_MATCH3 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
|
2317 |
+
var PERMISSIVE_MATCH4 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
|
2318 |
+
|
2319 |
+
return {
|
2320 |
+
rgb: new RegExp("rgb" + PERMISSIVE_MATCH3),
|
2321 |
+
rgba: new RegExp("rgba" + PERMISSIVE_MATCH4),
|
2322 |
+
hsl: new RegExp("hsl" + PERMISSIVE_MATCH3),
|
2323 |
+
hsla: new RegExp("hsla" + PERMISSIVE_MATCH4),
|
2324 |
+
hsv: new RegExp("hsv" + PERMISSIVE_MATCH3),
|
2325 |
+
hsva: new RegExp("hsva" + PERMISSIVE_MATCH4),
|
2326 |
+
hex3: /^([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
|
2327 |
+
hex6: /^([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
|
2328 |
+
hex8: /^([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/
|
2329 |
+
};
|
2330 |
+
})();
|
2331 |
+
|
2332 |
+
// `stringInputToObject`
|
2333 |
+
// Permissive string parsing. Take in a number of formats, and output an object
|
2334 |
+
// based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}`
|
2335 |
+
function stringInputToObject(color) {
|
2336 |
+
|
2337 |
+
color = color.replace(trimLeft,'').replace(trimRight, '').toLowerCase();
|
2338 |
+
var named = false;
|
2339 |
+
if (names[color]) {
|
2340 |
+
color = names[color];
|
2341 |
+
named = true;
|
2342 |
+
}
|
2343 |
+
else if (color == 'transparent') {
|
2344 |
+
return { r: 0, g: 0, b: 0, a: 0, format: "name" };
|
2345 |
+
}
|
2346 |
+
|
2347 |
+
// Try to match string input using regular expressions.
|
2348 |
+
// Keep most of the number bounding out of this function - don't worry about [0,1] or [0,100] or [0,360]
|
2349 |
+
// Just return an object and let the conversion functions handle that.
|
2350 |
+
// This way the result will be the same whether the tinycolor is initialized with string or object.
|
2351 |
+
var match;
|
2352 |
+
if ((match = matchers.rgb.exec(color))) {
|
2353 |
+
return { r: match[1], g: match[2], b: match[3] };
|
2354 |
+
}
|
2355 |
+
if ((match = matchers.rgba.exec(color))) {
|
2356 |
+
return { r: match[1], g: match[2], b: match[3], a: match[4] };
|
2357 |
+
}
|
2358 |
+
if ((match = matchers.hsl.exec(color))) {
|
2359 |
+
return { h: match[1], s: match[2], l: match[3] };
|
2360 |
+
}
|
2361 |
+
if ((match = matchers.hsla.exec(color))) {
|
2362 |
+
return { h: match[1], s: match[2], l: match[3], a: match[4] };
|
2363 |
+
}
|
2364 |
+
if ((match = matchers.hsv.exec(color))) {
|
2365 |
+
return { h: match[1], s: match[2], v: match[3] };
|
2366 |
+
}
|
2367 |
+
if ((match = matchers.hsva.exec(color))) {
|
2368 |
+
return { h: match[1], s: match[2], v: match[3], a: match[4] };
|
2369 |
+
}
|
2370 |
+
if ((match = matchers.hex8.exec(color))) {
|
2371 |
+
return {
|
2372 |
+
a: convertHexToDecimal(match[1]),
|
2373 |
+
r: parseIntFromHex(match[2]),
|
2374 |
+
g: parseIntFromHex(match[3]),
|
2375 |
+
b: parseIntFromHex(match[4]),
|
2376 |
+
format: named ? "name" : "hex8"
|
2377 |
+
};
|
2378 |
+
}
|
2379 |
+
if ((match = matchers.hex6.exec(color))) {
|
2380 |
+
return {
|
2381 |
+
r: parseIntFromHex(match[1]),
|
2382 |
+
g: parseIntFromHex(match[2]),
|
2383 |
+
b: parseIntFromHex(match[3]),
|
2384 |
+
format: named ? "name" : "hex"
|
2385 |
+
};
|
2386 |
+
}
|
2387 |
+
if ((match = matchers.hex3.exec(color))) {
|
2388 |
+
return {
|
2389 |
+
r: parseIntFromHex(match[1] + '' + match[1]),
|
2390 |
+
g: parseIntFromHex(match[2] + '' + match[2]),
|
2391 |
+
b: parseIntFromHex(match[3] + '' + match[3]),
|
2392 |
+
format: named ? "name" : "hex"
|
2393 |
+
};
|
2394 |
+
}
|
2395 |
+
|
2396 |
+
return false;
|
2397 |
+
}
|
2398 |
+
|
2399 |
+
window.tinycolor = tinycolor;
|
2400 |
+
})();
|
2401 |
+
|
2402 |
+
$(function () {
|
2403 |
+
if ($.fn.spectrum.load) {
|
2404 |
+
$.fn.spectrum.processNativeColorInputs();
|
2405 |
+
}
|
2406 |
+
});
|
2407 |
+
|
2408 |
+
});
|
admin/assets/js/spectrum.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(t){"use strict";"function"==typeof define&&define.amd?define(["jquery"],t):"object"==typeof exports&&"object"==typeof module?module.exports=t(require("jquery")):t(jQuery)}(function(t,e){"use strict";var r={beforeShow:f,move:f,change:f,show:f,hide:f,color:!1,flat:!1,showInput:!1,allowEmpty:!1,showButtons:!0,clickoutFiresChange:!0,showInitial:!1,showPalette:!1,showPaletteOnly:!1,hideAfterPaletteSelect:!1,togglePaletteOnly:!1,showSelectionPalette:!0,localStorageKey:!1,appendTo:"body",maxSelectionSize:7,cancelText:"cancel",chooseText:"choose",togglePaletteMoreText:"more",togglePaletteLessText:"less",clearText:"Clear Color Selection",noColorSelectedText:"No Color Selected",preferredFormat:!1,className:"",containerClassName:"",replacerClassName:"",showAlpha:!1,theme:"sp-light",palette:[["#ffffff","#000000","#ff0000","#ff8000","#ffff00","#008000","#0000ff","#4b0082","#9400d3"]],selectionPalette:[],disabled:!1,offset:null},a=[],n=!!/msie/i.exec(window.navigator.userAgent),i=function(){function t(t,e){return!!~(""+t).indexOf(e)}var e=document.createElement("div").style;return e.cssText="background-color:rgba(0,0,0,.5)",t(e.backgroundColor,"rgba")||t(e.backgroundColor,"hsla")}(),o=["<div class='sp-replacer'>","<div class='sp-preview'><div class='sp-preview-inner'></div></div>","<div class='sp-dd'>▼</div>","</div>"].join(""),s=function(){var t="";if(n)for(var e=1;e<=6;e++)t+="<div class='sp-"+e+"'></div>";return["<div class='sp-container sp-hidden'>","<div class='sp-palette-container'>","<div class='sp-palette sp-thumb sp-cf'></div>","<div class='sp-palette-button-container sp-cf'>","<button type='button' class='sp-palette-toggle'></button>","</div>","</div>","<div class='sp-picker-container'>","<div class='sp-top sp-cf'>","<div class='sp-fill'></div>","<div class='sp-top-inner'>","<div class='sp-color'>","<div class='sp-sat'>","<div class='sp-val'>","<div class='sp-dragger'></div>","</div>","</div>","</div>","<div class='sp-clear sp-clear-display'>","</div>","<div class='sp-hue'>","<div class='sp-slider'></div>",t,"</div>","</div>","<div class='sp-alpha'><div class='sp-alpha-inner'><div class='sp-alpha-handle'></div></div></div>","</div>","<div class='sp-input-container sp-cf'>","<input class='sp-input' type='text' spellcheck='false' />","</div>","<div class='sp-initial sp-thumb sp-cf'></div>","<div class='sp-button-container sp-cf'>","<a class='sp-cancel' href='#'></a>","<button type='button' class='sp-choose'></button>","</div>","</div>","</div>"].join("")}();function l(e,r,a,n){for(var o=[],s=0;s<e.length;s++){var l=e[s];if(l){var c=tinycolor(l),f=c.toHsl().l<.5?"sp-thumb-el sp-thumb-dark":"sp-thumb-el sp-thumb-light";f+=tinycolor.equals(r,l)?" sp-thumb-active":"";var u=c.toString(n.preferredFormat||"rgb"),h=i?"background-color:"+c.toRgbString():"filter:"+c.toFilter();o.push('<span title="'+u+'" data-color="'+c.toRgbString()+'" class="'+f+'"><span class="sp-thumb-inner" style="'+h+';"></span></span>')}else{o.push(t("<div />").append(t('<span data-color="" style="background-color:transparent;" class="sp-clear-display"></span>').attr("title",n.noColorSelectedText)).html())}}return"<div class='sp-cf "+a+"'>"+o.join("")+"</div>"}function c(c,f){var g,b,v,m,y=function(e,a){var n=t.extend({},r,e);return n.callbacks={move:h(n.move,a),change:h(n.change,a),show:h(n.show,a),hide:h(n.hide,a),beforeShow:h(n.beforeShow,a)},n}(f,c),w=y.flat,_=y.showSelectionPalette,x=y.localStorageKey,k=y.theme,S=y.callbacks,C=(g=Kt,b=10,function(){var t=this,e=arguments;v&&clearTimeout(m),!v&&m||(m=setTimeout(function(){m=null,g.apply(t,e)},b))}),P=!1,A=!1,M=0,R=0,H=0,F=0,T=0,O=0,q=0,N=0,j=0,E=0,D=1,I=[],z=[],B={},L=y.selectionPalette.slice(0),K=y.maxSelectionSize,V="sp-dragging",$=null,W=c.ownerDocument,X=(W.body,t(c)),Y=!1,G=t(s,W).addClass(k),Q=G.find(".sp-picker-container"),J=G.find(".sp-color"),U=G.find(".sp-dragger"),Z=G.find(".sp-hue"),tt=G.find(".sp-slider"),et=G.find(".sp-alpha-inner"),rt=G.find(".sp-alpha"),at=G.find(".sp-alpha-handle"),nt=G.find(".sp-input"),it=G.find(".sp-palette"),ot=G.find(".sp-initial"),st=G.find(".sp-cancel"),lt=G.find(".sp-clear"),ct=G.find(".sp-choose"),ft=G.find(".sp-palette-toggle"),ut=X.is("input"),ht=ut&&"color"===X.attr("type")&&p(),dt=ut&&!w,pt=dt?t(o).addClass(k).addClass(y.className).addClass(y.replacerClassName):t([]),gt=dt?pt:X,bt=pt.find(".sp-preview-inner"),vt=y.color||ut&&X.val(),mt=!1,yt=y.preferredFormat,wt=!y.showButtons||y.clickoutFiresChange,_t=!vt,xt=y.allowEmpty&&!ht;function kt(){if(y.showPaletteOnly&&(y.showPalette=!0),ft.text(y.showPaletteOnly?y.togglePaletteMoreText:y.togglePaletteLessText),y.palette){I=y.palette.slice(0),z=t.isArray(I[0])?I:[I],B={};for(var e=0;e<z.length;e++)for(var r=0;r<z[e].length;r++){var a=tinycolor(z[e][r]).toRgbString();B[a]=!0}}G.toggleClass("sp-flat",w),G.toggleClass("sp-input-disabled",!y.showInput),G.toggleClass("sp-alpha-enabled",y.showAlpha),G.toggleClass("sp-clear-enabled",xt),G.toggleClass("sp-buttons-disabled",!y.showButtons),G.toggleClass("sp-palette-buttons-disabled",!y.togglePaletteOnly),G.toggleClass("sp-palette-disabled",!y.showPalette),G.toggleClass("sp-palette-only",y.showPaletteOnly),G.toggleClass("sp-initial-disabled",!y.showInitial),G.addClass(y.className).addClass(y.containerClassName),Kt()}function St(){if(x&&window.localStorage){try{var e=window.localStorage[x].split(",#");e.length>1&&(delete window.localStorage[x],t.each(e,function(t,e){Ct(e)}))}catch(t){}try{L=window.localStorage[x].split(";")}catch(t){}}}function Ct(e){if(_){var r=tinycolor(e).toRgbString();if(!B[r]&&-1===t.inArray(r,L))for(L.push(r);L.length>K;)L.shift();if(x&&window.localStorage)try{window.localStorage[x]=L.join(";")}catch(t){}}}function Pt(){var e=Dt(),r=t.map(z,function(t,r){return l(t,e,"sp-palette-row sp-palette-row-"+r,y)});St(),L&&r.push(l(function(){var t=[];if(y.showPalette)for(var e=0;e<L.length;e++){var r=tinycolor(L[e]).toRgbString();B[r]||t.push(L[e])}return t.reverse().slice(0,y.maxSelectionSize)}(),e,"sp-palette-row sp-palette-row-selection",y)),it.html(r.join(""))}function At(){if(y.showInitial){var t=mt,e=Dt();ot.html(l([t,e],e,"sp-palette-row-initial",y))}}function Mt(){(R<=0||M<=0||F<=0)&&Kt(),A=!0,G.addClass(V),$=null,X.trigger("dragstart.spectrum",[Dt()])}function Rt(){A=!1,G.removeClass(V),X.trigger("dragstop.spectrum",[Dt()])}function Ht(){var t=nt.val();if(null!==t&&""!==t||!xt){var e=tinycolor(t);e.isValid()?(Et(e),It(),Lt()):nt.addClass("sp-validation-error")}else Et(null),It(),Lt()}function Ft(){P?Nt():Tt()}function Tt(){var e=t.Event("beforeShow.spectrum");P?Kt():(X.trigger(e,[Dt()]),!1===S.beforeShow(Dt())||e.isDefaultPrevented()||(!function(){for(var t=0;t<a.length;t++)a[t]&&a[t].hide()}(),P=!0,t(W).on("keydown.spectrum",Ot),t(W).on("click.spectrum",qt),t(window).on("resize.spectrum",C),pt.addClass("sp-active"),G.removeClass("sp-hidden"),Kt(),zt(),mt=Dt(),At(),S.show(mt),X.trigger("show.spectrum",[mt])))}function Ot(t){27===t.keyCode&&Nt()}function qt(t){2!=t.button&&(A||(wt?Lt(!0):jt(),Nt()))}function Nt(){P&&!w&&(P=!1,t(W).off("keydown.spectrum",Ot),t(W).off("click.spectrum",qt),t(window).off("resize.spectrum",C),pt.removeClass("sp-active"),G.addClass("sp-hidden"),S.hide(Dt()),X.trigger("hide.spectrum",[Dt()]))}function jt(){Et(mt,!0),Lt(!0)}function Et(t,e){var r,a;tinycolor.equals(t,Dt())?zt():(!t&&xt?_t=!0:(_t=!1,a=(r=tinycolor(t)).toHsv(),N=a.h%360/360,j=a.s,E=a.v,D=a.a),zt(),r&&r.isValid()&&!e&&(yt=y.preferredFormat||r.getFormat()))}function Dt(t){return t=t||{},xt&&_t?null:tinycolor.fromRatio({h:N,s:j,v:E,a:Math.round(1e3*D)/1e3},{format:t.format||yt})}function It(){zt(),S.move(Dt()),X.trigger("move.spectrum",[Dt()])}function zt(){nt.removeClass("sp-validation-error"),Bt();var t=tinycolor.fromRatio({h:N,s:1,v:1});J.css("background-color",t.toHexString());var e=yt;D<1&&(0!==D||"name"!==e)&&("hex"!==e&&"hex3"!==e&&"hex6"!==e&&"name"!==e||(e="rgb"));var r=Dt({format:e}),a="";if(bt.removeClass("sp-clear-display"),bt.css("background-color","transparent"),!r&&xt)bt.addClass("sp-clear-display");else{var o=r.toHexString(),s=r.toRgbString();if(i||1===r.alpha?bt.css("background-color",s):(bt.css("background-color","transparent"),bt.css("filter",r.toFilter())),y.showAlpha){var l=r.toRgb();l.a=0;var c=tinycolor(l).toRgbString(),f="linear-gradient(left, "+c+", "+o+")";n?et.css("filter",tinycolor(c).toFilter({gradientType:1},o)):(et.css("background","-webkit-"+f),et.css("background","-moz-"+f),et.css("background","-ms-"+f),et.css("background","linear-gradient(to right, "+c+", "+o+")"))}a=r.toString(e)}y.showInput&&nt.val(function(t){var e,r=t.replace(/\s/g,"").match(/^rgba?\((\d+),(\d+),(\d+),?([^,\s)]+)?/i),a=(r&&r[4]||"").trim(),n=r?(256|r[1]).toString(16).slice(1)+(256|r[2]).toString(16).slice(1)+(256|r[3]).toString(16).slice(1):t;e=""!==a?a:"01";return e=(255*e|256).toString(16).slice(1),n+=e}(a)),y.showPalette&&Pt(),At()}function Bt(){var t=j,e=E;if(xt&&_t)at.hide(),tt.hide(),U.hide();else{at.show(),tt.show(),U.show();var r=t*M,a=R-e*R;r=Math.max(-H,Math.min(M-H,r-H)),a=Math.max(-H,Math.min(R-H,a-H)),U.css({top:a+"px",left:r+"px"});var n=D*T;at.css({left:n-O/2+"px"});var i=N*F;tt.css({top:i-q+"px"})}}function Lt(t){var e=Dt(),r="",a=!tinycolor.equals(e,mt);e&&(r=e.toString(yt),Ct(e)),ut&&X.val(r),t&&a&&(S.change(e),X.trigger("change",[e]))}function Kt(){var e,r,a,n,i,o,s,l,c,f,u,h;P&&(M=J.width(),R=J.height(),H=U.height(),Z.width(),F=Z.height(),q=tt.height(),T=rt.width(),O=at.width(),w||(G.css("position","absolute"),y.offset?G.offset(y.offset):G.offset((r=gt,a=(e=G).outerWidth(),n=e.outerHeight(),i=r.outerHeight(),o=e[0].ownerDocument,s=o.documentElement,l=s.clientWidth+t(o).scrollLeft(),c=s.clientHeight+t(o).scrollTop(),f=r.offset(),u=f.left,h=f.top,h+=i,u-=Math.min(u,u+a>l&&l>a?Math.abs(u+a-l):0),{top:h-=Math.min(h,h+n>c&&c>n?Math.abs(n+i-0):0),bottom:f.bottom,left:u,right:f.right,width:f.width,height:f.height}))),Bt(),y.showPalette&&Pt(),X.trigger("reflow.spectrum"))}function Vt(){Nt(),Y=!0,X.attr("disabled",!0),gt.addClass("sp-disabled")}!function(){if(n&&G.find("*:not(input)").attr("unselectable","on"),kt(),dt&&X.after(pt).hide(),xt||lt.hide(),w)X.after(G).hide();else{var e="parent"===y.appendTo?X.parent():t(y.appendTo);1!==e.length&&(e=t("body")),e.append(G)}function r(e){return e.data&&e.data.ignore?(Et(t(e.target).closest(".sp-thumb-el").data("color")),It()):(Et(t(e.target).closest(".sp-thumb-el").data("color")),It(),y.hideAfterPaletteSelect?(Lt(!0),Nt()):Lt()),!1}St(),gt.on("click.spectrum touchstart.spectrum",function(e){Y||Ft(),e.stopPropagation(),t(e.target).is("input")||e.preventDefault()}),(X.is(":disabled")||!0===y.disabled)&&Vt(),G.click(u),nt.change(Ht),nt.on("paste",function(){setTimeout(Ht,1)}),nt.keydown(function(t){13==t.keyCode&&Ht()}),st.text(y.cancelText),st.on("click.spectrum",function(t){t.stopPropagation(),t.preventDefault(),jt(),Nt()}),lt.attr("title",y.clearText),lt.on("click.spectrum",function(t){t.stopPropagation(),t.preventDefault(),_t=!0,It(),w&&Lt(!0)}),ct.text(y.chooseText),ct.on("click.spectrum",function(t){t.stopPropagation(),t.preventDefault(),n&&nt.is(":focus")&&nt.trigger("change"),nt.hasClass("sp-validation-error")||(Lt(!0),Nt())}),ft.text(y.showPaletteOnly?y.togglePaletteMoreText:y.togglePaletteLessText),ft.on("click.spectrum",function(t){t.stopPropagation(),t.preventDefault(),y.showPaletteOnly=!y.showPaletteOnly,y.showPaletteOnly||w||G.css("left","-="+(Q.outerWidth(!0)+5)),kt()}),d(rt,function(t,e,r){D=t/T,_t=!1,r.shiftKey&&(D=Math.round(10*D)/10),It()},Mt,Rt),d(Z,function(t,e){N=parseFloat(e/F),_t=!1,y.showAlpha||(D=1),It()},Mt,Rt),d(J,function(t,e,r){if(r.shiftKey){if(!$){var a=j*M,n=R-E*R,i=Math.abs(t-a)>Math.abs(e-n);$=i?"x":"y"}}else $=null;var o=!$||"y"===$;(!$||"x"===$)&&(j=parseFloat(t/M)),o&&(E=parseFloat((R-e)/R)),_t=!1,y.showAlpha||(D=1),It()},Mt,Rt),vt?(Et(vt),zt(),yt=y.preferredFormat||tinycolor(vt).format,Ct(vt)):zt(),w&&Tt();var a=n?"mousedown.spectrum":"click.spectrum touchstart.spectrum";it.on(a,".sp-thumb-el",r),ot.on(a,".sp-thumb-el:nth-child(1)",{ignore:!0},r)}();var $t={show:Tt,hide:Nt,toggle:Ft,reflow:Kt,option:function(r,a){return r===e?t.extend({},y):a===e?y[r]:(y[r]=a,"preferredFormat"===r&&(yt=y.preferredFormat),void kt())},enable:function(){Y=!1,X.attr("disabled",!1),gt.removeClass("sp-disabled")},disable:Vt,offset:function(t){y.offset=t,Kt()},set:function(t){Et(t),Lt()},get:Dt,destroy:function(){X.show(),gt.off("click.spectrum touchstart.spectrum"),G.remove(),pt.remove(),a[$t.id]=null},container:G};return $t.id=a.push($t)-1,$t}function f(){}function u(t){t.stopPropagation()}function h(t,e){var r=Array.prototype.slice,a=r.call(arguments,2);return function(){return t.apply(e,a.concat(r.call(arguments)))}}function d(e,r,a,i){r=r||function(){},a=a||function(){},i=i||function(){};var o=document,s=!1,l={},c=0,f=0,u="ontouchstart"in window,h={};function d(t){t.stopPropagation&&t.stopPropagation(),t.preventDefault&&t.preventDefault(),t.returnValue=!1}function p(t){if(s){if(n&&o.documentMode<9&&!t.button)return g();var a=t.originalEvent&&t.originalEvent.touches&&t.originalEvent.touches[0],i=a&&a.pageX||t.pageX,h=a&&a.pageY||t.pageY,p=Math.max(0,Math.min(i-l.left,f)),b=Math.max(0,Math.min(h-l.top,c));u&&d(t),r.apply(e,[p,b,t])}}function g(){s&&(t(o).off(h),t(o.body).removeClass("sp-dragging"),setTimeout(function(){i.apply(e,arguments)},0)),s=!1}h.selectstart=d,h.dragstart=d,h["touchmove mousemove"]=p,h["touchend mouseup"]=g,t(e).on("touchstart mousedown",function(r){(r.which?3==r.which:2==r.button)||s||!1!==a.apply(e,arguments)&&(s=!0,c=t(e).height(),f=t(e).width(),l=t(e).offset(),t(o).on(h),t(o.body).addClass("sp-dragging"),p(r),d(r))})}function p(){return t.fn.spectrum.inputTypeColorSupport()}t.fn.spectrum=function(e,r){if("string"==typeof e){var n=this,i=Array.prototype.slice.call(arguments,1);return this.each(function(){var r=a[t(this).data("spectrum.id")];if(r){var o=r[e];if(!o)throw new Error("Spectrum: no such method: '"+e+"'");"get"==e?n=r.get():"container"==e?n=r.container:"option"==e?n=r.option.apply(r,i):"destroy"==e?(r.destroy(),t(this).removeData("spectrum.id")):o.apply(r,i)}}),n}return this.spectrum("destroy").each(function(){var r=c(this,t.extend({},t(this).data(),e));t(this).data("spectrum.id",r.id)})},t.fn.spectrum.load=!0,t.fn.spectrum.loadOpts={},t.fn.spectrum.draggable=d,t.fn.spectrum.defaults=r,t.fn.spectrum.inputTypeColorSupport=function e(){if(void 0===e._cachedResult){var r=t("<input type='color'/>")[0];e._cachedResult="color"===r.type&&""!==r.value}return e._cachedResult},t.spectrum={},t.spectrum.localization={},t.spectrum.palettes={},t.fn.spectrum.processNativeColorInputs=function(){var e=t("input[type=color]");e.length&&!p()&&e.spectrum({preferredFormat:"hex6"})},function(){var t=/^[\s,#]+/,e=/\s+$/,r=0,a=Math,n=a.round,i=a.min,o=a.max,s=a.random,l=function(s,c){if(c=c||{},(s=s||"")instanceof l)return s;if(!(this instanceof l))return new l(s,c);var f=function(r){var n={r:0,g:0,b:0},s=1,l=!1,c=!1;"string"==typeof r&&(r=function(r){r=r.replace(t,"").replace(e,"").toLowerCase();var a,n=!1;if(P[r])r=P[r],n=!0;else if("transparent"==r)return{r:0,g:0,b:0,a:0,format:"name"};if(a=E.rgb.exec(r))return{r:a[1],g:a[2],b:a[3]};if(a=E.rgba.exec(r))return{r:a[1],g:a[2],b:a[3],a:a[4]};if(a=E.hsl.exec(r))return{h:a[1],s:a[2],l:a[3]};if(a=E.hsla.exec(r))return{h:a[1],s:a[2],l:a[3],a:a[4]};if(a=E.hsv.exec(r))return{h:a[1],s:a[2],v:a[3]};if(a=E.hsva.exec(r))return{h:a[1],s:a[2],v:a[3],a:a[4]};if(a=E.hex8.exec(r))return{a:(i=a[1],F(i)/255),r:F(a[2]),g:F(a[3]),b:F(a[4]),format:n?"name":"hex8"};var i;if(a=E.hex6.exec(r))return{r:F(a[1]),g:F(a[2]),b:F(a[3]),format:n?"name":"hex"};if(a=E.hex3.exec(r))return{r:F(a[1]+""+a[1]),g:F(a[2]+""+a[2]),b:F(a[3]+""+a[3]),format:n?"name":"hex"};return!1}(r));"object"==typeof r&&(r.hasOwnProperty("r")&&r.hasOwnProperty("g")&&r.hasOwnProperty("b")?(f=r.r,u=r.g,h=r.b,n={r:255*R(f,255),g:255*R(u,255),b:255*R(h,255)},l=!0,c="%"===String(r.r).substr(-1)?"prgb":"rgb"):r.hasOwnProperty("h")&&r.hasOwnProperty("s")&&r.hasOwnProperty("v")?(r.s=O(r.s),r.v=O(r.v),n=function(t,e,r){t=6*R(t,360),e=R(e,100),r=R(r,100);var n=a.floor(t),i=t-n,o=r*(1-e),s=r*(1-i*e),l=r*(1-(1-i)*e),c=n%6;return{r:255*[r,s,o,o,l,r][c],g:255*[l,r,r,s,o,o][c],b:255*[o,o,l,r,r,s][c]}}(r.h,r.s,r.v),l=!0,c="hsv"):r.hasOwnProperty("h")&&r.hasOwnProperty("s")&&r.hasOwnProperty("l")&&(r.s=O(r.s),r.l=O(r.l),n=function(t,e,r){var a,n,i;function o(t,e,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?t+6*(e-t)*r:r<.5?e:r<2/3?t+(e-t)*(2/3-r)*6:t}if(t=R(t,360),e=R(e,100),r=R(r,100),0===e)a=n=i=r;else{var s=r<.5?r*(1+e):r+e-r*e,l=2*r-s;a=o(l,s,t+1/3),n=o(l,s,t),i=o(l,s,t-1/3)}return{r:255*a,g:255*n,b:255*i}}(r.h,r.s,r.l),l=!0,c="hsl"),r.hasOwnProperty("a")&&(s=r.a));var f,u,h;return s=M(s),{ok:l,format:r.format||c,r:i(255,o(n.r,0)),g:i(255,o(n.g,0)),b:i(255,o(n.b,0)),a:s}}(s);this._originalInput=s,this._r=f.r,this._g=f.g,this._b=f.b,this._a=f.a,this._roundA=n(1e3*this._a)/1e3,this._format=c.format||f.format,this._gradientType=c.gradientType,this._r<1&&(this._r=n(this._r)),this._g<1&&(this._g=n(this._g)),this._b<1&&(this._b=n(this._b)),this._ok=f.ok,this._tc_id=r++};function c(t,e,r){t=R(t,255),e=R(e,255),r=R(r,255);var a,n,s=o(t,e,r),l=i(t,e,r),c=(s+l)/2;if(s==l)a=n=0;else{var f=s-l;switch(n=c>.5?f/(2-s-l):f/(s+l),s){case t:a=(e-r)/f+(e<r?6:0);break;case e:a=(r-t)/f+2;break;case r:a=(t-e)/f+4}a/=6}return{h:a,s:n,l:c}}function f(t,e,r){t=R(t,255),e=R(e,255),r=R(r,255);var a,n,s=o(t,e,r),l=i(t,e,r),c=s,f=s-l;if(n=0===s?0:f/s,s==l)a=0;else{switch(s){case t:a=(e-r)/f+(e<r?6:0);break;case e:a=(r-t)/f+2;break;case r:a=(t-e)/f+4}a/=6}return{h:a,s:n,v:c}}function u(t,e,r,a){var i=[T(n(t).toString(16)),T(n(e).toString(16)),T(n(r).toString(16))];return a&&i[0].charAt(0)==i[0].charAt(1)&&i[1].charAt(0)==i[1].charAt(1)&&i[2].charAt(0)==i[2].charAt(1)?i[0].charAt(0)+i[1].charAt(0)+i[2].charAt(0):i.join("")}function h(t,e,r,a){var i;return[T((i=a,Math.round(255*parseFloat(i)).toString(16))),T(n(t).toString(16)),T(n(e).toString(16)),T(n(r).toString(16))].join("")}function d(t,e){e=0===e?0:e||10;var r=l(t).toHsl();return r.s-=e/100,r.s=H(r.s),l(r)}function p(t,e){e=0===e?0:e||10;var r=l(t).toHsl();return r.s+=e/100,r.s=H(r.s),l(r)}function g(t){return l(t).desaturate(100)}function b(t,e){e=0===e?0:e||10;var r=l(t).toHsl();return r.l+=e/100,r.l=H(r.l),l(r)}function v(t,e){e=0===e?0:e||10;var r=l(t).toRgb();return r.r=o(0,i(255,r.r-n(-e/100*255))),r.g=o(0,i(255,r.g-n(-e/100*255))),r.b=o(0,i(255,r.b-n(-e/100*255))),l(r)}function m(t,e){e=0===e?0:e||10;var r=l(t).toHsl();return r.l-=e/100,r.l=H(r.l),l(r)}function y(t,e){var r=l(t).toHsl(),a=(n(r.h)+e)%360;return r.h=a<0?360+a:a,l(r)}function w(t){var e=l(t).toHsl();return e.h=(e.h+180)%360,l(e)}function _(t){var e=l(t).toHsl(),r=e.h;return[l(t),l({h:(r+120)%360,s:e.s,l:e.l}),l({h:(r+240)%360,s:e.s,l:e.l})]}function x(t){var e=l(t).toHsl(),r=e.h;return[l(t),l({h:(r+90)%360,s:e.s,l:e.l}),l({h:(r+180)%360,s:e.s,l:e.l}),l({h:(r+270)%360,s:e.s,l:e.l})]}function k(t){var e=l(t).toHsl(),r=e.h;return[l(t),l({h:(r+72)%360,s:e.s,l:e.l}),l({h:(r+216)%360,s:e.s,l:e.l})]}function S(t,e,r){e=e||6,r=r||30;var a=l(t).toHsl(),n=360/r,i=[l(t)];for(a.h=(a.h-(n*e>>1)+720)%360;--e;)a.h=(a.h+n)%360,i.push(l(a));return i}function C(t,e){e=e||6;for(var r=l(t).toHsv(),a=r.h,n=r.s,i=r.v,o=[],s=1/e;e--;)o.push(l({h:a,s:n,v:i})),i=(i+s)%1;return o}l.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3},setAlpha:function(t){return this._a=M(t),this._roundA=n(1e3*this._a)/1e3,this},toHsv:function(){var t=f(this._r,this._g,this._b);return{h:360*t.h,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=f(this._r,this._g,this._b),e=n(360*t.h),r=n(100*t.s),a=n(100*t.v);return 1==this._a?"hsv("+e+", "+r+"%, "+a+"%)":"hsva("+e+", "+r+"%, "+a+"%, "+this._roundA+")"},toHsl:function(){var t=c(this._r,this._g,this._b);return{h:360*t.h,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=c(this._r,this._g,this._b),e=n(360*t.h),r=n(100*t.s),a=n(100*t.l);return 1==this._a?"hsl("+e+", "+r+"%, "+a+"%)":"hsla("+e+", "+r+"%, "+a+"%, "+this._roundA+")"},toHex:function(t){return u(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(){return h(this._r,this._g,this._b,this._a)},toHex8String:function(){return"#"+this.toHex8()},toRgb:function(){return{r:n(this._r),g:n(this._g),b:n(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+n(this._r)+", "+n(this._g)+", "+n(this._b)+")":"rgba("+n(this._r)+", "+n(this._g)+", "+n(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:n(100*R(this._r,255))+"%",g:n(100*R(this._g,255))+"%",b:n(100*R(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+n(100*R(this._r,255))+"%, "+n(100*R(this._g,255))+"%, "+n(100*R(this._b,255))+"%)":"rgba("+n(100*R(this._r,255))+"%, "+n(100*R(this._g,255))+"%, "+n(100*R(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(A[u(this._r,this._g,this._b,!0)]||!1)},toFilter:function(t){var e="#"+h(this._r,this._g,this._b,this._a),r=e,a=this._gradientType?"GradientType = 1, ":"";t&&(r=l(t).toHex8String());return"progid:DXImageTransform.Microsoft.gradient("+a+"startColorstr="+e+",endColorstr="+r+")"},toString:function(t){var e=!!t;t=t||this._format;var r=!1,a=this._a<1&&this._a>=0;return e||!a||"hex"!==t&&"hex6"!==t&&"hex3"!==t&&"name"!==t?("rgb"===t&&(r=this.toRgbString()),"prgb"===t&&(r=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(r=this.toHexString()),"hex3"===t&&(r=this.toHexString(!0)),"hex8"===t&&(r=this.toHex8String()),"name"===t&&(r=this.toName()),"hsl"===t&&(r=this.toHslString()),"hsv"===t&&(r=this.toHsvString()),r||this.toHexString()):"name"===t&&0===this._a?this.toName():this.toRgbString()},_applyModification:function(t,e){var r=t.apply(null,[this].concat([].slice.call(e)));return this._r=r._r,this._g=r._g,this._b=r._b,this.setAlpha(r._a),this},lighten:function(){return this._applyModification(b,arguments)},brighten:function(){return this._applyModification(v,arguments)},darken:function(){return this._applyModification(m,arguments)},desaturate:function(){return this._applyModification(d,arguments)},saturate:function(){return this._applyModification(p,arguments)},greyscale:function(){return this._applyModification(g,arguments)},spin:function(){return this._applyModification(y,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(S,arguments)},complement:function(){return this._applyCombination(w,arguments)},monochromatic:function(){return this._applyCombination(C,arguments)},splitcomplement:function(){return this._applyCombination(k,arguments)},triad:function(){return this._applyCombination(_,arguments)},tetrad:function(){return this._applyCombination(x,arguments)}},l.fromRatio=function(t,e){if("object"==typeof t){var r={};for(var a in t)t.hasOwnProperty(a)&&(r[a]="a"===a?t[a]:O(t[a]));t=r}return l(t,e)},l.equals=function(t,e){return!(!t||!e)&&l(t).toRgbString()==l(e).toRgbString()},l.random=function(){return l.fromRatio({r:s(),g:s(),b:s()})},l.mix=function(t,e,r){r=0===r?0:r||50;var a,n=l(t).toRgb(),i=l(e).toRgb(),o=r/100,s=2*o-1,c=i.a-n.a,f=1-(a=((a=s*c==-1?s:(s+c)/(1+s*c))+1)/2),u={r:i.r*a+n.r*f,g:i.g*a+n.g*f,b:i.b*a+n.b*f,a:i.a*o+n.a*(1-o)};return l(u)},l.readability=function(t,e){var r=l(t),a=l(e),n=r.toRgb(),i=a.toRgb(),o=r.getBrightness(),s=a.getBrightness(),c=Math.max(n.r,i.r)-Math.min(n.r,i.r)+Math.max(n.g,i.g)-Math.min(n.g,i.g)+Math.max(n.b,i.b)-Math.min(n.b,i.b);return{brightness:Math.abs(o-s),color:c}},l.isReadable=function(t,e){var r=l.readability(t,e);return r.brightness>125&&r.color>500},l.mostReadable=function(t,e){for(var r=null,a=0,n=!1,i=0;i<e.length;i++){var o=l.readability(t,e[i]),s=o.brightness>125&&o.color>500,c=o.brightness/125*3+o.color/500;(s&&!n||s&&n&&c>a||!s&&!n&&c>a)&&(n=s,a=c,r=l(e[i]))}return r};var P=l.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},A=l.hexNames=function(t){var e={};for(var r in t)t.hasOwnProperty(r)&&(e[t[r]]=r);return e}(P);function M(t){return t=parseFloat(t),(isNaN(t)||t<0||t>1)&&(t=1),t}function R(t,e){(function(t){return"string"==typeof t&&-1!=t.indexOf(".")&&1===parseFloat(t)})(t)&&(t="100%");var r=function(t){return"string"==typeof t&&-1!=t.indexOf("%")}(t);return t=i(e,o(0,parseFloat(t))),r&&(t=parseInt(t*e,10)/100),a.abs(t-e)<1e-6?1:t%e/parseFloat(e)}function H(t){return i(1,o(0,t))}function F(t){return parseInt(t,16)}function T(t){return 1==t.length?"0"+t:""+t}function O(t){return t<=1&&(t=100*t+"%"),t}var q,N,j,E=(N="[\\s|\\(]+("+(q="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)")+")[,|\\s]+("+q+")[,|\\s]+("+q+")\\s*\\)?",j="[\\s|\\(]+("+q+")[,|\\s]+("+q+")[,|\\s]+("+q+")[,|\\s]+("+q+")\\s*\\)?",{rgb:new RegExp("rgb"+N),rgba:new RegExp("rgba"+j),hsl:new RegExp("hsl"+N),hsla:new RegExp("hsla"+j),hsv:new RegExp("hsv"+N),hsva:new RegExp("hsva"+j),hex3:/^([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex8:/^([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/});window.tinycolor=l}(),t(function(){t.fn.spectrum.load&&t.fn.spectrum.processNativeColorInputs()})});
|
1 |
+
!function(t){"use strict";"function"==typeof define&&define.amd?define(["jquery"],t):"object"==typeof exports&&"object"==typeof module?module.exports=t(require("jquery")):t(jQuery)}(function(t,e){"use strict";var r={beforeShow:f,move:f,change:f,show:f,hide:f,color:!1,flat:!1,showInput:!1,allowEmpty:!1,showButtons:!0,clickoutFiresChange:!0,showInitial:!1,showPalette:!1,showPaletteOnly:!1,hideAfterPaletteSelect:!1,togglePaletteOnly:!1,showSelectionPalette:!0,localStorageKey:!1,appendTo:"body",maxSelectionSize:7,cancelText:"cancel",chooseText:"choose",togglePaletteMoreText:"more",togglePaletteLessText:"less",clearText:"Clear Color Selection",noColorSelectedText:"No Color Selected",preferredFormat:!1,className:"",containerClassName:"",replacerClassName:"",showAlpha:!1,theme:"sp-light",palette:[["#ffffff","#000000","#ff0000","#ff8000","#ffff00","#008000","#0000ff","#4b0082","#9400d3"]],selectionPalette:[],disabled:!1,offset:null},n=[],a=!!/msie/i.exec(window.navigator.userAgent),i=function(){function t(t,e){return!!~(""+t).indexOf(e)}var e=document.createElement("div").style;return e.cssText="background-color:rgba(0,0,0,.5)",t(e.backgroundColor,"rgba")||t(e.backgroundColor,"hsla")}(),o=["<div class='sp-replacer'>","<div class='sp-preview'><div class='sp-preview-inner'></div></div>","<div class='sp-dd'>▼</div>","</div>"].join(""),s=function(){var t="";if(a)for(var e=1;e<=6;e++)t+="<div class='sp-"+e+"'></div>";return["<div class='sp-container sp-hidden'>","<div class='sp-palette-container'>","<div class='sp-palette sp-thumb sp-cf'></div>","<div class='sp-palette-button-container sp-cf'>","<button type='button' class='sp-palette-toggle'></button>","</div>","</div>","<div class='sp-picker-container'>","<div class='sp-top sp-cf'>","<div class='sp-fill'></div>","<div class='sp-top-inner'>","<div class='sp-color'>","<div class='sp-sat'>","<div class='sp-val'>","<div class='sp-dragger'></div>","</div>","</div>","</div>","<div class='sp-clear sp-clear-display'>","</div>","<div class='sp-hue'>","<div class='sp-slider'></div>",t,"</div>","</div>","<div class='sp-alpha'><div class='sp-alpha-inner'><div class='sp-alpha-handle'></div></div></div>","</div>","<div class='sp-input-container sp-cf'>","<input class='sp-input' type='text' spellcheck='false' />","</div>","<div class='sp-initial sp-thumb sp-cf'></div>","<div class='sp-button-container sp-cf'>","<a class='sp-cancel' href='#'></a>","<button type='button' class='sp-choose'></button>","</div>","</div>","</div>"].join("")}();function l(e,r,n,a){for(var o=[],s=0;s<e.length;s++){var l=e[s];if(l){var c=tinycolor(l),f=c.toHsl().l<.5?"sp-thumb-el sp-thumb-dark":"sp-thumb-el sp-thumb-light";f+=tinycolor.equals(r,l)?" sp-thumb-active":"";var u=c.toString(a.preferredFormat||"rgb"),h=i?"background-color:"+c.toRgbString():"filter:"+c.toFilter();o.push('<span title="'+u+'" data-color="'+c.toRgbString()+'" class="'+f+'"><span class="sp-thumb-inner" style="'+h+';"></span></span>')}else{o.push(t("<div />").append(t('<span data-color="" style="background-color:transparent;" class="sp-clear-display"></span>').attr("title",a.noColorSelectedText)).html())}}return"<div class='sp-cf "+n+"'>"+o.join("")+"</div>"}function c(c,f){var g,b,v,m,y=function(e,n){var a=t.extend({},r,e);return a.callbacks={move:h(a.move,n),change:h(a.change,n),show:h(a.show,n),hide:h(a.hide,n),beforeShow:h(a.beforeShow,n)},a}(f,c),w=y.flat,_=y.showSelectionPalette,x=y.localStorageKey,k=y.theme,S=y.callbacks,C=(g=Kt,b=10,function(){var t=this,e=arguments;v&&clearTimeout(m),!v&&m||(m=setTimeout(function(){m=null,g.apply(t,e)},b))}),P=!1,A=!1,M=0,R=0,H=0,F=0,T=0,O=0,E=0,I=0,q=0,N=0,j=1,D=[],$=[],z={},B=y.selectionPalette.slice(0),L=y.maxSelectionSize,K="sp-dragging",V=null,X=c.ownerDocument,W=(X.body,t(c)),Y=!1,G=t(s,X).addClass(k),Q=G.find(".sp-picker-container"),J=G.find(".sp-color"),U=G.find(".sp-dragger"),Z=G.find(".sp-hue"),tt=G.find(".sp-slider"),et=G.find(".sp-alpha-inner"),rt=G.find(".sp-alpha"),nt=G.find(".sp-alpha-handle"),at=G.find(".sp-input"),it=G.find(".sp-palette"),ot=G.find(".sp-initial"),st=G.find(".sp-cancel"),lt=G.find(".sp-clear"),ct=G.find(".sp-choose"),ft=G.find(".sp-palette-toggle"),ut=W.is("input"),ht=ut&&"color"===W.attr("type")&&p(),dt=ut&&!w,pt=dt?t(o).addClass(k).addClass(y.className).addClass(y.replacerClassName):t([]),gt=dt?pt:W,bt=pt.find(".sp-preview-inner"),vt=y.color||ut&&W.val(),mt=!1,yt=y.preferredFormat,wt=!y.showButtons||y.clickoutFiresChange,_t=!vt,xt=y.allowEmpty&&!ht;function kt(){if(y.showPaletteOnly&&(y.showPalette=!0),ft.text(y.showPaletteOnly?y.togglePaletteMoreText:y.togglePaletteLessText),y.palette){D=y.palette.slice(0),$=t.isArray(D[0])?D:[D],z={};for(var e=0;e<$.length;e++)for(var r=0;r<$[e].length;r++){var n=tinycolor($[e][r]).toRgbString();z[n]=!0}}G.toggleClass("sp-flat",w),G.toggleClass("sp-input-disabled",!y.showInput),G.toggleClass("sp-alpha-enabled",y.showAlpha),G.toggleClass("sp-clear-enabled",xt),G.toggleClass("sp-buttons-disabled",!y.showButtons),G.toggleClass("sp-palette-buttons-disabled",!y.togglePaletteOnly),G.toggleClass("sp-palette-disabled",!y.showPalette),G.toggleClass("sp-palette-only",y.showPaletteOnly),G.toggleClass("sp-initial-disabled",!y.showInitial),G.addClass(y.className).addClass(y.containerClassName),Kt()}function St(){if(x&&window.localStorage){try{var e=window.localStorage[x].split(",#");e.length>1&&(delete window.localStorage[x],t.each(e,function(t,e){Ct(e)}))}catch(t){}try{B=window.localStorage[x].split(";")}catch(t){}}}function Ct(e){if(_){var r=tinycolor(e).toRgbString();if(!z[r]&&-1===t.inArray(r,B))for(B.push(r);B.length>L;)B.shift();if(x&&window.localStorage)try{window.localStorage[x]=B.join(";")}catch(t){}}}function Pt(){var e=jt(),r=t.map($,function(t,r){return l(t,e,"sp-palette-row sp-palette-row-"+r,y)});St(),B&&r.push(l(function(){var t=[];if(y.showPalette)for(var e=0;e<B.length;e++){var r=tinycolor(B[e]).toRgbString();z[r]||t.push(B[e])}return t.reverse().slice(0,y.maxSelectionSize)}(),e,"sp-palette-row sp-palette-row-selection",y)),it.html(r.join(""))}function At(){if(y.showInitial){var t=mt,e=jt();ot.html(l([t,e],e,"sp-palette-row-initial",y))}}function Mt(){(R<=0||M<=0||F<=0)&&Kt(),A=!0,G.addClass(K),V=null,W.trigger("dragstart.spectrum",[jt()])}function Rt(){A=!1,G.removeClass(K),W.trigger("dragstop.spectrum",[jt()])}function Ht(){var t=at.val();if(null!==(t=function(t,e){""!=t&&(t=t.toLowerCase());var r=t.substring(0,3);if("rgb"==r)return t;"#"!=(r=t.substring(0,1))&&(t="#"+t);if(!function(t){return/^#([A-Fa-f0-9]{3,4}){1,2}$/.test(t)}(t))throw new Error("Invalid HEX");const n=Math.floor((t.length-1)/3),a=function(t,e){return t.match(new RegExp(`.{${e}}`,"g"))}(t.slice(1),n),[i,o,s,l]=a.map(zt);return`rgba(${i}, ${o}, ${s}, ${function(t,e){if(void 0!==t)return t/255;if("number"!=typeof e||e<0||e>1)return 1;return e}(l,e)})`}(t))&&""!==t||!xt){var e=tinycolor(t);e.isValid()?(Nt(e),Dt(),Lt()):at.addClass("sp-validation-error")}else Nt(null),Dt(),Lt()}function Ft(){P?It():Tt()}function Tt(){var e=t.Event("beforeShow.spectrum");P?Kt():(W.trigger(e,[jt()]),!1===S.beforeShow(jt())||e.isDefaultPrevented()||(!function(){for(var t=0;t<n.length;t++)n[t]&&n[t].hide()}(),P=!0,t(X).on("keydown.spectrum",Ot),t(X).on("click.spectrum",Et),t(window).on("resize.spectrum",C),pt.addClass("sp-active"),G.removeClass("sp-hidden"),Kt(),$t(),mt=jt(),At(),S.show(mt),W.trigger("show.spectrum",[mt])))}function Ot(t){27===t.keyCode&&It()}function Et(t){2!=t.button&&(A||(wt?Lt(!0):qt(),It()))}function It(){P&&!w&&(P=!1,t(X).off("keydown.spectrum",Ot),t(X).off("click.spectrum",Et),t(window).off("resize.spectrum",C),pt.removeClass("sp-active"),G.addClass("sp-hidden"),S.hide(jt()),W.trigger("hide.spectrum",[jt()]))}function qt(){Nt(mt,!0),Lt(!0)}function Nt(t,e){var r,n;tinycolor.equals(t,jt())?$t():(!t&&xt?_t=!0:(_t=!1,n=(r=tinycolor(t)).toHsv(),I=n.h%360/360,q=n.s,N=n.v,j=n.a),$t(),r&&r.isValid()&&!e&&(yt=y.preferredFormat||r.getFormat()))}function jt(t){return t=t||{},xt&&_t?null:tinycolor.fromRatio({h:I,s:q,v:N,a:Math.round(1e3*j)/1e3},{format:t.format||yt})}function Dt(){$t(),S.move(jt()),W.trigger("move.spectrum",[jt()])}function $t(){at.removeClass("sp-validation-error"),Bt();var t=tinycolor.fromRatio({h:I,s:1,v:1});J.css("background-color",t.toHexString());var e=yt;j<1&&(0!==j||"name"!==e)&&("hex"!==e&&"hex3"!==e&&"hex6"!==e&&"name"!==e||(e="rgb"));var r=jt({format:e}),n="";if(bt.removeClass("sp-clear-display"),bt.css("background-color","transparent"),!r&&xt)bt.addClass("sp-clear-display");else{var o=r.toHexString(),s=r.toRgbString();if(i||1===r.alpha?bt.css("background-color",s):(bt.css("background-color","transparent"),bt.css("filter",r.toFilter())),y.showAlpha){var l=r.toRgb();l.a=0;var c=tinycolor(l).toRgbString(),f="linear-gradient(left, "+c+", "+o+")";a?et.css("filter",tinycolor(c).toFilter({gradientType:1},o)):(et.css("background","-webkit-"+f),et.css("background","-moz-"+f),et.css("background","-ms-"+f),et.css("background","linear-gradient(to right, "+c+", "+o+")"))}n=r.toString(e)}y.showInput&&(n=function(t){var e,r=t.replace(/\s/g,"").match(/^rgba?\((\d+),(\d+),(\d+),?([^,\s)]+)?/i),n=(r&&r[4]||"").trim(),a=r?(256|r[1]).toString(16).slice(1)+(256|r[2]).toString(16).slice(1)+(256|r[3]).toString(16).slice(1):t;e=""!==n?n:parseInt("01",8);return e=(255*e|256).toString(16).slice(1),a+=e}(n),at.val(n)),y.showPalette&&Pt(),At()}function zt(t){return parseInt(t.repeat(2/t.length),16)}function Bt(){var t=q,e=N;if(xt&&_t)nt.hide(),tt.hide(),U.hide();else{nt.show(),tt.show(),U.show();var r=t*M,n=R-e*R;r=Math.max(-H,Math.min(M-H,r-H)),n=Math.max(-H,Math.min(R-H,n-H)),U.css({top:n+"px",left:r+"px"});var a=j*T;nt.css({left:a-O/2+"px"});var i=I*F;tt.css({top:i-E+"px"})}}function Lt(t){var e=jt(),r="",n=!tinycolor.equals(e,mt);e&&(r=e.toString(yt),Ct(e)),ut&&W.val(r),t&&n&&(S.change(e),W.trigger("change",[e]))}function Kt(){var e,r,n,a,i,o,s,l,c,f,u,h;P&&(M=J.width(),R=J.height(),H=U.height(),Z.width(),F=Z.height(),E=tt.height(),T=rt.width(),O=nt.width(),w||(G.css("position","absolute"),y.offset?G.offset(y.offset):G.offset((r=gt,n=(e=G).outerWidth(),a=e.outerHeight(),i=r.outerHeight(),o=e[0].ownerDocument,s=o.documentElement,l=s.clientWidth+t(o).scrollLeft(),c=s.clientHeight+t(o).scrollTop(),f=r.offset(),u=f.left,h=f.top,h+=i,u-=Math.min(u,u+n>l&&l>n?Math.abs(u+n-l):0),{top:h-=Math.min(h,h+a>c&&c>a?Math.abs(a+i-0):0),bottom:f.bottom,left:u,right:f.right,width:f.width,height:f.height}))),Bt(),y.showPalette&&Pt(),W.trigger("reflow.spectrum"))}function Vt(){It(),Y=!0,W.attr("disabled",!0),gt.addClass("sp-disabled")}!function(){if(a&&G.find("*:not(input)").attr("unselectable","on"),kt(),dt&&W.after(pt).hide(),xt||lt.hide(),w)W.after(G).hide();else{var e="parent"===y.appendTo?W.parent():t(y.appendTo);1!==e.length&&(e=t("body")),e.append(G)}function r(e){return e.data&&e.data.ignore?(Nt(t(e.target).closest(".sp-thumb-el").data("color")),Dt()):(Nt(t(e.target).closest(".sp-thumb-el").data("color")),Dt(),y.hideAfterPaletteSelect?(Lt(!0),It()):Lt()),!1}St(),gt.on("click.spectrum touchstart.spectrum",function(e){Y||Ft(),e.stopPropagation(),t(e.target).is("input")||e.preventDefault()}),(W.is(":disabled")||!0===y.disabled)&&Vt(),G.click(u),at.change(Ht),at.on("paste",function(){setTimeout(Ht,1)}),at.keydown(function(t){13==t.keyCode&&Ht()}),st.text(y.cancelText),st.on("click.spectrum",function(t){t.stopPropagation(),t.preventDefault(),qt(),It()}),lt.attr("title",y.clearText),lt.on("click.spectrum",function(t){t.stopPropagation(),t.preventDefault(),_t=!0,Dt(),w&&Lt(!0)}),ct.text(y.chooseText),ct.on("click.spectrum",function(t){t.stopPropagation(),t.preventDefault(),a&&at.is(":focus")&&at.trigger("change"),at.hasClass("sp-validation-error")||(Lt(!0),It())}),ft.text(y.showPaletteOnly?y.togglePaletteMoreText:y.togglePaletteLessText),ft.on("click.spectrum",function(t){t.stopPropagation(),t.preventDefault(),y.showPaletteOnly=!y.showPaletteOnly,y.showPaletteOnly||w||G.css("left","-="+(Q.outerWidth(!0)+5)),kt()}),d(rt,function(t,e,r){j=t/T,_t=!1,r.shiftKey&&(j=Math.round(10*j)/10),Dt()},Mt,Rt),d(Z,function(t,e){I=parseFloat(e/F),_t=!1,y.showAlpha||(j=1),Dt()},Mt,Rt),d(J,function(t,e,r){if(r.shiftKey){if(!V){var n=q*M,a=R-N*R,i=Math.abs(t-n)>Math.abs(e-a);V=i?"x":"y"}}else V=null;var o=!V||"y"===V;(!V||"x"===V)&&(q=parseFloat(t/M)),o&&(N=parseFloat((R-e)/R)),_t=!1,y.showAlpha||(j=1),Dt()},Mt,Rt),vt?(Nt(vt),$t(),yt=y.preferredFormat||tinycolor(vt).format,Ct(vt)):$t(),w&&Tt();var n=a?"mousedown.spectrum":"click.spectrum touchstart.spectrum";it.on(n,".sp-thumb-el",r),ot.on(n,".sp-thumb-el:nth-child(1)",{ignore:!0},r)}();var Xt={show:Tt,hide:It,toggle:Ft,reflow:Kt,option:function(r,n){return r===e?t.extend({},y):n===e?y[r]:(y[r]=n,"preferredFormat"===r&&(yt=y.preferredFormat),void kt())},enable:function(){Y=!1,W.attr("disabled",!1),gt.removeClass("sp-disabled")},disable:Vt,offset:function(t){y.offset=t,Kt()},set:function(t){Nt(t),Lt()},get:jt,destroy:function(){W.show(),gt.off("click.spectrum touchstart.spectrum"),G.remove(),pt.remove(),n[Xt.id]=null},container:G};return Xt.id=n.push(Xt)-1,Xt}function f(){}function u(t){t.stopPropagation()}function h(t,e){var r=Array.prototype.slice,n=r.call(arguments,2);return function(){return t.apply(e,n.concat(r.call(arguments)))}}function d(e,r,n,i){r=r||function(){},n=n||function(){},i=i||function(){};var o=document,s=!1,l={},c=0,f=0,u="ontouchstart"in window,h={};function d(t){t.stopPropagation&&t.stopPropagation(),t.preventDefault&&t.preventDefault(),t.returnValue=!1}function p(t){if(s){if(a&&o.documentMode<9&&!t.button)return g();var n=t.originalEvent&&t.originalEvent.touches&&t.originalEvent.touches[0],i=n&&n.pageX||t.pageX,h=n&&n.pageY||t.pageY,p=Math.max(0,Math.min(i-l.left,f)),b=Math.max(0,Math.min(h-l.top,c));u&&d(t),r.apply(e,[p,b,t])}}function g(){s&&(t(o).off(h),t(o.body).removeClass("sp-dragging"),setTimeout(function(){i.apply(e,arguments)},0)),s=!1}h.selectstart=d,h.dragstart=d,h["touchmove mousemove"]=p,h["touchend mouseup"]=g,t(e).on("touchstart mousedown",function(r){(r.which?3==r.which:2==r.button)||s||!1!==n.apply(e,arguments)&&(s=!0,c=t(e).height(),f=t(e).width(),l=t(e).offset(),t(o).on(h),t(o.body).addClass("sp-dragging"),p(r),d(r))})}function p(){return t.fn.spectrum.inputTypeColorSupport()}t.fn.spectrum=function(e,r){if("string"==typeof e){var a=this,i=Array.prototype.slice.call(arguments,1);return this.each(function(){var r=n[t(this).data("spectrum.id")];if(r){var o=r[e];if(!o)throw new Error("Spectrum: no such method: '"+e+"'");"get"==e?a=r.get():"container"==e?a=r.container:"option"==e?a=r.option.apply(r,i):"destroy"==e?(r.destroy(),t(this).removeData("spectrum.id")):o.apply(r,i)}}),a}return this.spectrum("destroy").each(function(){var r=c(this,t.extend({},t(this).data(),e));t(this).data("spectrum.id",r.id)})},t.fn.spectrum.load=!0,t.fn.spectrum.loadOpts={},t.fn.spectrum.draggable=d,t.fn.spectrum.defaults=r,t.fn.spectrum.inputTypeColorSupport=function e(){if(void 0===e._cachedResult){var r=t("<input type='color'/>")[0];e._cachedResult="color"===r.type&&""!==r.value}return e._cachedResult},t.spectrum={},t.spectrum.localization={},t.spectrum.palettes={},t.fn.spectrum.processNativeColorInputs=function(){var e=t("input[type=color]");e.length&&!p()&&e.spectrum({preferredFormat:"hex6"})},function(){var t=/^[\s,#]+/,e=/\s+$/,r=0,n=Math,a=n.round,i=n.min,o=n.max,s=n.random,l=function(s,c){if(c=c||{},(s=s||"")instanceof l)return s;if(!(this instanceof l))return new l(s,c);var f=function(r){var a={r:0,g:0,b:0},s=1,l=!1,c=!1;"string"==typeof r&&(r=function(r){r=r.replace(t,"").replace(e,"").toLowerCase();var n,a=!1;if(P[r])r=P[r],a=!0;else if("transparent"==r)return{r:0,g:0,b:0,a:0,format:"name"};if(n=N.rgb.exec(r))return{r:n[1],g:n[2],b:n[3]};if(n=N.rgba.exec(r))return{r:n[1],g:n[2],b:n[3],a:n[4]};if(n=N.hsl.exec(r))return{h:n[1],s:n[2],l:n[3]};if(n=N.hsla.exec(r))return{h:n[1],s:n[2],l:n[3],a:n[4]};if(n=N.hsv.exec(r))return{h:n[1],s:n[2],v:n[3]};if(n=N.hsva.exec(r))return{h:n[1],s:n[2],v:n[3],a:n[4]};if(n=N.hex8.exec(r))return{a:(i=n[1],F(i)/255),r:F(n[2]),g:F(n[3]),b:F(n[4]),format:a?"name":"hex8"};var i;if(n=N.hex6.exec(r))return{r:F(n[1]),g:F(n[2]),b:F(n[3]),format:a?"name":"hex"};if(n=N.hex3.exec(r))return{r:F(n[1]+""+n[1]),g:F(n[2]+""+n[2]),b:F(n[3]+""+n[3]),format:a?"name":"hex"};return!1}(r));"object"==typeof r&&(r.hasOwnProperty("r")&&r.hasOwnProperty("g")&&r.hasOwnProperty("b")?(f=r.r,u=r.g,h=r.b,a={r:255*R(f,255),g:255*R(u,255),b:255*R(h,255)},l=!0,c="%"===String(r.r).substr(-1)?"prgb":"rgb"):r.hasOwnProperty("h")&&r.hasOwnProperty("s")&&r.hasOwnProperty("v")?(r.s=O(r.s),r.v=O(r.v),a=function(t,e,r){t=6*R(t,360),e=R(e,100),r=R(r,100);var a=n.floor(t),i=t-a,o=r*(1-e),s=r*(1-i*e),l=r*(1-(1-i)*e),c=a%6;return{r:255*[r,s,o,o,l,r][c],g:255*[l,r,r,s,o,o][c],b:255*[o,o,l,r,r,s][c]}}(r.h,r.s,r.v),l=!0,c="hsv"):r.hasOwnProperty("h")&&r.hasOwnProperty("s")&&r.hasOwnProperty("l")&&(r.s=O(r.s),r.l=O(r.l),a=function(t,e,r){var n,a,i;function o(t,e,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?t+6*(e-t)*r:r<.5?e:r<2/3?t+(e-t)*(2/3-r)*6:t}if(t=R(t,360),e=R(e,100),r=R(r,100),0===e)n=a=i=r;else{var s=r<.5?r*(1+e):r+e-r*e,l=2*r-s;n=o(l,s,t+1/3),a=o(l,s,t),i=o(l,s,t-1/3)}return{r:255*n,g:255*a,b:255*i}}(r.h,r.s,r.l),l=!0,c="hsl"),r.hasOwnProperty("a")&&(s=r.a));var f,u,h;return s=M(s),{ok:l,format:r.format||c,r:i(255,o(a.r,0)),g:i(255,o(a.g,0)),b:i(255,o(a.b,0)),a:s}}(s);this._originalInput=s,this._r=f.r,this._g=f.g,this._b=f.b,this._a=f.a,this._roundA=a(1e3*this._a)/1e3,this._format=c.format||f.format,this._gradientType=c.gradientType,this._r<1&&(this._r=a(this._r)),this._g<1&&(this._g=a(this._g)),this._b<1&&(this._b=a(this._b)),this._ok=f.ok,this._tc_id=r++};function c(t,e,r){t=R(t,255),e=R(e,255),r=R(r,255);var n,a,s=o(t,e,r),l=i(t,e,r),c=(s+l)/2;if(s==l)n=a=0;else{var f=s-l;switch(a=c>.5?f/(2-s-l):f/(s+l),s){case t:n=(e-r)/f+(e<r?6:0);break;case e:n=(r-t)/f+2;break;case r:n=(t-e)/f+4}n/=6}return{h:n,s:a,l:c}}function f(t,e,r){t=R(t,255),e=R(e,255),r=R(r,255);var n,a,s=o(t,e,r),l=i(t,e,r),c=s,f=s-l;if(a=0===s?0:f/s,s==l)n=0;else{switch(s){case t:n=(e-r)/f+(e<r?6:0);break;case e:n=(r-t)/f+2;break;case r:n=(t-e)/f+4}n/=6}return{h:n,s:a,v:c}}function u(t,e,r,n){var i=[T(a(t).toString(16)),T(a(e).toString(16)),T(a(r).toString(16))];return n&&i[0].charAt(0)==i[0].charAt(1)&&i[1].charAt(0)==i[1].charAt(1)&&i[2].charAt(0)==i[2].charAt(1)?i[0].charAt(0)+i[1].charAt(0)+i[2].charAt(0):i.join("")}function h(t,e,r,n){var i;return[T((i=n,Math.round(255*parseFloat(i)).toString(16))),T(a(t).toString(16)),T(a(e).toString(16)),T(a(r).toString(16))].join("")}function d(t,e){e=0===e?0:e||10;var r=l(t).toHsl();return r.s-=e/100,r.s=H(r.s),l(r)}function p(t,e){e=0===e?0:e||10;var r=l(t).toHsl();return r.s+=e/100,r.s=H(r.s),l(r)}function g(t){return l(t).desaturate(100)}function b(t,e){e=0===e?0:e||10;var r=l(t).toHsl();return r.l+=e/100,r.l=H(r.l),l(r)}function v(t,e){e=0===e?0:e||10;var r=l(t).toRgb();return r.r=o(0,i(255,r.r-a(-e/100*255))),r.g=o(0,i(255,r.g-a(-e/100*255))),r.b=o(0,i(255,r.b-a(-e/100*255))),l(r)}function m(t,e){e=0===e?0:e||10;var r=l(t).toHsl();return r.l-=e/100,r.l=H(r.l),l(r)}function y(t,e){var r=l(t).toHsl(),n=(a(r.h)+e)%360;return r.h=n<0?360+n:n,l(r)}function w(t){var e=l(t).toHsl();return e.h=(e.h+180)%360,l(e)}function _(t){var e=l(t).toHsl(),r=e.h;return[l(t),l({h:(r+120)%360,s:e.s,l:e.l}),l({h:(r+240)%360,s:e.s,l:e.l})]}function x(t){var e=l(t).toHsl(),r=e.h;return[l(t),l({h:(r+90)%360,s:e.s,l:e.l}),l({h:(r+180)%360,s:e.s,l:e.l}),l({h:(r+270)%360,s:e.s,l:e.l})]}function k(t){var e=l(t).toHsl(),r=e.h;return[l(t),l({h:(r+72)%360,s:e.s,l:e.l}),l({h:(r+216)%360,s:e.s,l:e.l})]}function S(t,e,r){e=e||6,r=r||30;var n=l(t).toHsl(),a=360/r,i=[l(t)];for(n.h=(n.h-(a*e>>1)+720)%360;--e;)n.h=(n.h+a)%360,i.push(l(n));return i}function C(t,e){e=e||6;for(var r=l(t).toHsv(),n=r.h,a=r.s,i=r.v,o=[],s=1/e;e--;)o.push(l({h:n,s:a,v:i})),i=(i+s)%1;return o}l.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3},setAlpha:function(t){return this._a=M(t),this._roundA=a(1e3*this._a)/1e3,this},toHsv:function(){var t=f(this._r,this._g,this._b);return{h:360*t.h,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=f(this._r,this._g,this._b),e=a(360*t.h),r=a(100*t.s),n=a(100*t.v);return 1==this._a?"hsv("+e+", "+r+"%, "+n+"%)":"hsva("+e+", "+r+"%, "+n+"%, "+this._roundA+")"},toHsl:function(){var t=c(this._r,this._g,this._b);return{h:360*t.h,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=c(this._r,this._g,this._b),e=a(360*t.h),r=a(100*t.s),n=a(100*t.l);return 1==this._a?"hsl("+e+", "+r+"%, "+n+"%)":"hsla("+e+", "+r+"%, "+n+"%, "+this._roundA+")"},toHex:function(t){return u(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(){return h(this._r,this._g,this._b,this._a)},toHex8String:function(){return"#"+this.toHex8()},toRgb:function(){return{r:a(this._r),g:a(this._g),b:a(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+a(this._r)+", "+a(this._g)+", "+a(this._b)+")":"rgba("+a(this._r)+", "+a(this._g)+", "+a(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:a(100*R(this._r,255))+"%",g:a(100*R(this._g,255))+"%",b:a(100*R(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+a(100*R(this._r,255))+"%, "+a(100*R(this._g,255))+"%, "+a(100*R(this._b,255))+"%)":"rgba("+a(100*R(this._r,255))+"%, "+a(100*R(this._g,255))+"%, "+a(100*R(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(A[u(this._r,this._g,this._b,!0)]||!1)},toFilter:function(t){var e="#"+h(this._r,this._g,this._b,this._a),r=e,n=this._gradientType?"GradientType = 1, ":"";t&&(r=l(t).toHex8String());return"progid:DXImageTransform.Microsoft.gradient("+n+"startColorstr="+e+",endColorstr="+r+")"},toString:function(t){var e=!!t;t=t||this._format;var r=!1,n=this._a<1&&this._a>=0;return e||!n||"hex"!==t&&"hex6"!==t&&"hex3"!==t&&"name"!==t?("rgb"===t&&(r=this.toRgbString()),"prgb"===t&&(r=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(r=this.toHexString()),"hex3"===t&&(r=this.toHexString(!0)),"hex8"===t&&(r=this.toHex8String()),"name"===t&&(r=this.toName()),"hsl"===t&&(r=this.toHslString()),"hsv"===t&&(r=this.toHsvString()),r||this.toHexString()):"name"===t&&0===this._a?this.toName():this.toRgbString()},_applyModification:function(t,e){var r=t.apply(null,[this].concat([].slice.call(e)));return this._r=r._r,this._g=r._g,this._b=r._b,this.setAlpha(r._a),this},lighten:function(){return this._applyModification(b,arguments)},brighten:function(){return this._applyModification(v,arguments)},darken:function(){return this._applyModification(m,arguments)},desaturate:function(){return this._applyModification(d,arguments)},saturate:function(){return this._applyModification(p,arguments)},greyscale:function(){return this._applyModification(g,arguments)},spin:function(){return this._applyModification(y,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(S,arguments)},complement:function(){return this._applyCombination(w,arguments)},monochromatic:function(){return this._applyCombination(C,arguments)},splitcomplement:function(){return this._applyCombination(k,arguments)},triad:function(){return this._applyCombination(_,arguments)},tetrad:function(){return this._applyCombination(x,arguments)}},l.fromRatio=function(t,e){if("object"==typeof t){var r={};for(var n in t)t.hasOwnProperty(n)&&(r[n]="a"===n?t[n]:O(t[n]));t=r}return l(t,e)},l.equals=function(t,e){return!(!t||!e)&&l(t).toRgbString()==l(e).toRgbString()},l.random=function(){return l.fromRatio({r:s(),g:s(),b:s()})},l.mix=function(t,e,r){r=0===r?0:r||50;var n,a=l(t).toRgb(),i=l(e).toRgb(),o=r/100,s=2*o-1,c=i.a-a.a,f=1-(n=((n=s*c==-1?s:(s+c)/(1+s*c))+1)/2),u={r:i.r*n+a.r*f,g:i.g*n+a.g*f,b:i.b*n+a.b*f,a:i.a*o+a.a*(1-o)};return l(u)},l.readability=function(t,e){var r=l(t),n=l(e),a=r.toRgb(),i=n.toRgb(),o=r.getBrightness(),s=n.getBrightness(),c=Math.max(a.r,i.r)-Math.min(a.r,i.r)+Math.max(a.g,i.g)-Math.min(a.g,i.g)+Math.max(a.b,i.b)-Math.min(a.b,i.b);return{brightness:Math.abs(o-s),color:c}},l.isReadable=function(t,e){var r=l.readability(t,e);return r.brightness>125&&r.color>500},l.mostReadable=function(t,e){for(var r=null,n=0,a=!1,i=0;i<e.length;i++){var o=l.readability(t,e[i]),s=o.brightness>125&&o.color>500,c=o.brightness/125*3+o.color/500;(s&&!a||s&&a&&c>n||!s&&!a&&c>n)&&(a=s,n=c,r=l(e[i]))}return r};var P=l.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},A=l.hexNames=function(t){var e={};for(var r in t)t.hasOwnProperty(r)&&(e[t[r]]=r);return e}(P);function M(t){return t=parseFloat(t),(isNaN(t)||t<0||t>1)&&(t=1),t}function R(t,e){(function(t){return"string"==typeof t&&-1!=t.indexOf(".")&&1===parseFloat(t)})(t)&&(t="100%");var r=function(t){return"string"==typeof t&&-1!=t.indexOf("%")}(t);return t=i(e,o(0,parseFloat(t))),r&&(t=parseInt(t*e,10)/100),n.abs(t-e)<1e-6?1:t%e/parseFloat(e)}function H(t){return i(1,o(0,t))}function F(t){return parseInt(t,16)}function T(t){return 1==t.length?"0"+t:""+t}function O(t){return t<=1&&(t=100*t+"%"),t}var E,I,q,N=(I="[\\s|\\(]+("+(E="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)")+")[,|\\s]+("+E+")[,|\\s]+("+E+")\\s*\\)?",q="[\\s|\\(]+("+E+")[,|\\s]+("+E+")[,|\\s]+("+E+")[,|\\s]+("+E+")\\s*\\)?",{rgb:new RegExp("rgb"+I),rgba:new RegExp("rgba"+q),hsl:new RegExp("hsl"+I),hsla:new RegExp("hsla"+q),hsv:new RegExp("hsv"+I),hsva:new RegExp("hsva"+q),hex3:/^([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex8:/^([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/});window.tinycolor=l}(),t(function(){t.fn.spectrum.load&&t.fn.spectrum.processNativeColorInputs()})});
|
cht-icons.php
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
Author URI: https://premio.io/downloads/chaty/
|
8 |
Text Domain: chaty
|
9 |
Domain Path: /languages
|
10 |
-
Version: 2.8
|
11 |
License: GPL2
|
12 |
*/
|
13 |
|
@@ -27,7 +27,7 @@ define('CHT_INC', CHT_DIR . '/includes');
|
|
27 |
define('CHT_PRO_URL', admin_url("admin.php?page=chaty-app-upgrade"));
|
28 |
define('CHT_PLUGIN_URL', plugin_dir_url(__FILE__));
|
29 |
define('CHT_PLUGIN_BASE', plugin_basename(CHT_FILE));
|
30 |
-
define('CHT_VERSION', "2.8");
|
31 |
|
32 |
if (!function_exists('wp_doing_ajax')) {
|
33 |
function wp_doing_ajax()
|
@@ -49,6 +49,7 @@ if(!function_exists("cht_clear_all_caches")) {
|
|
49 |
/* Clear cookies from browser */
|
50 |
if (isset($_COOKIE['chaty_settings'])) {
|
51 |
setcookie("chaty_settings", '', time() - 3600, "/");
|
|
|
52 |
}
|
53 |
try {
|
54 |
global $wp_fastest_cache;
|
7 |
Author URI: https://premio.io/downloads/chaty/
|
8 |
Text Domain: chaty
|
9 |
Domain Path: /languages
|
10 |
+
Version: 2.8.1
|
11 |
License: GPL2
|
12 |
*/
|
13 |
|
27 |
define('CHT_PRO_URL', admin_url("admin.php?page=chaty-app-upgrade"));
|
28 |
define('CHT_PLUGIN_URL', plugin_dir_url(__FILE__));
|
29 |
define('CHT_PLUGIN_BASE', plugin_basename(CHT_FILE));
|
30 |
+
define('CHT_VERSION', "2.8.1");
|
31 |
|
32 |
if (!function_exists('wp_doing_ajax')) {
|
33 |
function wp_doing_ajax()
|
49 |
/* Clear cookies from browser */
|
50 |
if (isset($_COOKIE['chaty_settings'])) {
|
51 |
setcookie("chaty_settings", '', time() - 3600, "/");
|
52 |
+
setcookie("cta_exit_intent_shown", '', time() - 3600, "/");
|
53 |
}
|
54 |
try {
|
55 |
global $wp_fastest_cache;
|
includes/class-frontend.php
CHANGED
@@ -421,14 +421,14 @@ class CHT_Frontend extends CHT_Admin_Base
|
|
421 |
ob_start();
|
422 |
?>
|
423 |
<?php if($position == "left") { ?>
|
424 |
-
#wechat-qr-code{left:
|
425 |
<?php } else if($position == "right") { ?>
|
426 |
-
#wechat-qr-code{right:
|
427 |
<?php } else if($position == "custom") { ?>
|
428 |
<?php if($positionSide == "left") { ?>
|
429 |
-
#wechat-qr-code{left:
|
430 |
<?php } else { ?>
|
431 |
-
#wechat-qr-code{right:
|
432 |
<?php } ?>
|
433 |
<?php } ?>
|
434 |
.chaty-widget-is a{display: block; margin:0; padding:0;border-radius: 50%;-webkit-border-radius: 50%;-moz-border-radius: 50%; }
|
@@ -454,7 +454,8 @@ class CHT_Frontend extends CHT_Admin_Base
|
|
454 |
body div.chaty-widget.hide-widget { display: none !important; }
|
455 |
<?php
|
456 |
echo ".i-trigger .chaty-widget-i-title, .chaty-widget-i .chaty-widget-i-title {color:".esc_attr($cht_cta_text_color)." !important; background:".esc_attr($cht_cta_bg_color)." !important;}";
|
457 |
-
echo ".i-trigger .chaty-widget-i-title p, .chaty-widget-i.chaty-main-widget .chaty-widget-i-title p {color:".esc_attr($cht_cta_text_color)." !important; background:".esc_attr($cht_cta_bg_color)." !important;}";
|
|
|
458 |
echo ".i-trigger .chaty-widget-i:not(.no-tooltip):before, .chaty-widget-i.chaty-main-widget:before { border-color: transparent transparent transparent ".esc_attr($cht_cta_bg_color)." !important;}";
|
459 |
echo ".chaty-widget.chaty-widget-is-right .i-trigger .i-trigger-open.chaty-widget-i:before, .chaty-widget.chaty-widget-is-right .chaty-widget-i:before { border-color: transparent ".esc_attr($cht_cta_bg_color)." transparent transparent !important;}";
|
460 |
echo ".chaty-widget.chaty-widget-is-right .i-trigger .chaty-widget-i:before, .chaty-widget.chaty-widget-is-right .chaty-widget-i:before {border-color: transparent ".esc_attr($cht_cta_bg_color)." transparent transparent !important; }";
|
@@ -476,7 +477,7 @@ class CHT_Frontend extends CHT_Admin_Base
|
|
476 |
/* WP change this */
|
477 |
wp_enqueue_style( 'chaty-front-css', CHT_PLUGIN_URL."css/chaty-front.min.css", array(), $chaty_updated_on);
|
478 |
wp_add_inline_style('chaty-front-css', $chaty_css);
|
479 |
-
wp_enqueue_script( "chaty-front-end", CHT_PLUGIN_URL."js/cht-front-script.
|
480 |
wp_localize_script('chaty-front-end', 'chaty_settings', $data);
|
481 |
}
|
482 |
endif;
|
@@ -554,7 +555,7 @@ class CHT_Frontend extends CHT_Admin_Base
|
|
554 |
if(!isset($value['image_id'])) {
|
555 |
$value['image_id'] = ''; // Initialize custom image id if not exists. 2.1.0 change
|
556 |
}
|
557 |
-
if(!isset($value['title'])
|
558 |
$value['title'] = $social['title']; // Initialize title if not exists. 2.1.0 change
|
559 |
}
|
560 |
if(!isset($value['fa_icon'])) {
|
@@ -1388,7 +1389,7 @@ class CHT_Frontend extends CHT_Admin_Base
|
|
1388 |
} else {
|
1389 |
$val = $value['value'];
|
1390 |
}
|
1391 |
-
if(!isset($value['title'])
|
1392 |
$value['title'] = $social['title']; // Initialize title with default title if not exists. version 2.1.0 change
|
1393 |
}
|
1394 |
$image_url = "";
|
@@ -1499,7 +1500,11 @@ class CHT_Frontend extends CHT_Admin_Base
|
|
1499 |
}else if($channel_type == "wechat") {
|
1500 |
/* setting for WeChat */
|
1501 |
$url = "javascript:;";
|
1502 |
-
$value['title']
|
|
|
|
|
|
|
|
|
1503 |
$qr_code = isset($value['qr_code'])?$value['qr_code']:"";
|
1504 |
if(!empty($qr_code)) {
|
1505 |
$image_data = wp_get_attachment_image_src($qr_code, "full");
|
421 |
ob_start();
|
422 |
?>
|
423 |
<?php if($position == "left") { ?>
|
424 |
+
#wechat-qr-code{left: <?php esc_attr_e($total) ?>px; right:auto;}
|
425 |
<?php } else if($position == "right") { ?>
|
426 |
+
#wechat-qr-code{right: <?php esc_attr_e($total) ?>px; left:auto;}
|
427 |
<?php } else if($position == "custom") { ?>
|
428 |
<?php if($positionSide == "left") { ?>
|
429 |
+
#wechat-qr-code{left: <?php esc_attr_e($total) ?>px; right:auto;}
|
430 |
<?php } else { ?>
|
431 |
+
#wechat-qr-code{right: <?php esc_attr_e($total) ?>px; left:auto;}
|
432 |
<?php } ?>
|
433 |
<?php } ?>
|
434 |
.chaty-widget-is a{display: block; margin:0; padding:0;border-radius: 50%;-webkit-border-radius: 50%;-moz-border-radius: 50%; }
|
454 |
body div.chaty-widget.hide-widget { display: none !important; }
|
455 |
<?php
|
456 |
echo ".i-trigger .chaty-widget-i-title, .chaty-widget-i .chaty-widget-i-title {color:".esc_attr($cht_cta_text_color)." !important; background:".esc_attr($cht_cta_bg_color)." !important;}";
|
457 |
+
//echo ".i-trigger .chaty-widget-i-title p, .chaty-widget-i.chaty-main-widget .chaty-widget-i-title p {color:".esc_attr($cht_cta_text_color)." !important; background:".esc_attr($cht_cta_bg_color)." !important;}";
|
458 |
+
echo ".i-trigger .chaty-widget-i-title p, .chaty-widget-i.chaty-main-widget .chaty-widget-i-title p {color:".esc_attr($cht_cta_text_color)." !important; }";
|
459 |
echo ".i-trigger .chaty-widget-i:not(.no-tooltip):before, .chaty-widget-i.chaty-main-widget:before { border-color: transparent transparent transparent ".esc_attr($cht_cta_bg_color)." !important;}";
|
460 |
echo ".chaty-widget.chaty-widget-is-right .i-trigger .i-trigger-open.chaty-widget-i:before, .chaty-widget.chaty-widget-is-right .chaty-widget-i:before { border-color: transparent ".esc_attr($cht_cta_bg_color)." transparent transparent !important;}";
|
461 |
echo ".chaty-widget.chaty-widget-is-right .i-trigger .chaty-widget-i:before, .chaty-widget.chaty-widget-is-right .chaty-widget-i:before {border-color: transparent ".esc_attr($cht_cta_bg_color)." transparent transparent !important; }";
|
477 |
/* WP change this */
|
478 |
wp_enqueue_style( 'chaty-front-css', CHT_PLUGIN_URL."css/chaty-front.min.css", array(), $chaty_updated_on);
|
479 |
wp_add_inline_style('chaty-front-css', $chaty_css);
|
480 |
+
wp_enqueue_script( "chaty-front-end", CHT_PLUGIN_URL."js/cht-front-script.js", array( 'jquery' ), $chaty_updated_on, false);
|
481 |
wp_localize_script('chaty-front-end', 'chaty_settings', $data);
|
482 |
}
|
483 |
endif;
|
555 |
if(!isset($value['image_id'])) {
|
556 |
$value['image_id'] = ''; // Initialize custom image id if not exists. 2.1.0 change
|
557 |
}
|
558 |
+
if(!isset($value['title'])) {
|
559 |
$value['title'] = $social['title']; // Initialize title if not exists. 2.1.0 change
|
560 |
}
|
561 |
if(!isset($value['fa_icon'])) {
|
1389 |
} else {
|
1390 |
$val = $value['value'];
|
1391 |
}
|
1392 |
+
if(!isset($value['title'])) {
|
1393 |
$value['title'] = $social['title']; // Initialize title with default title if not exists. version 2.1.0 change
|
1394 |
}
|
1395 |
$image_url = "";
|
1500 |
}else if($channel_type == "wechat") {
|
1501 |
/* setting for WeChat */
|
1502 |
$url = "javascript:;";
|
1503 |
+
if(!empty($value['title'])) {
|
1504 |
+
$value['title'] .= ": ".$val;
|
1505 |
+
} else {
|
1506 |
+
$value['title'] = $val;
|
1507 |
+
}
|
1508 |
$qr_code = isset($value['qr_code'])?$value['qr_code']:"";
|
1509 |
if(!empty($qr_code)) {
|
1510 |
$image_data = wp_get_attachment_image_src($qr_code, "full");
|
includes/class-review-box.php
CHANGED
@@ -158,7 +158,7 @@ class Chaty_free_review_box {
|
|
158 |
<div class="notice notice-info chaty-notice <?php echo $this->plugin_slug ?>-premio-review-box <?php echo $this->plugin_slug ?>-premio-review-box">
|
159 |
<p>
|
160 |
Hi there, it seems like <b><?php echo $this->plugin_name ?></b> is bringing you some value, and that's pretty awesome! Can you please show us some love and rate <?php echo $this->plugin_name ?> on WordPress? It'll only take 2 minutes of your time, and will really help us spread the word
|
161 |
-
- <b>Gal Dubinski</b>, Co-founder <img width="30px" src="<?php echo esc_url(CHT_PLUGIN_URL."assets/images/
|
162 |
<a href="javascript:;" class="dismiss-btn <?php echo $this->plugin_slug ?>-premio-review-dismiss-btn"><span class="dashicons dashicons-no-alt"></span></a>
|
163 |
</p>
|
164 |
<div class="clear clearfix"></div>
|
158 |
<div class="notice notice-info chaty-notice <?php echo $this->plugin_slug ?>-premio-review-box <?php echo $this->plugin_slug ?>-premio-review-box">
|
159 |
<p>
|
160 |
Hi there, it seems like <b><?php echo $this->plugin_name ?></b> is bringing you some value, and that's pretty awesome! Can you please show us some love and rate <?php echo $this->plugin_name ?> on WordPress? It'll only take 2 minutes of your time, and will really help us spread the word
|
161 |
+
- <b>Gal Dubinski</b>, Co-founder <img width="30px" src="<?php echo esc_url(CHT_PLUGIN_URL."admin/assets/images/owner.png") ?>" />
|
162 |
<a href="javascript:;" class="dismiss-btn <?php echo $this->plugin_slug ?>-premio-review-dismiss-btn"><span class="dashicons dashicons-no-alt"></span></a>
|
163 |
</p>
|
164 |
<div class="clear clearfix"></div>
|
js/cht-front-script.js
CHANGED
@@ -133,13 +133,13 @@
|
|
133 |
case"chat-image":
|
134 |
if (t.object_settings.widget_img.length > 1) return '<div class="widget-img" style="background-color:' + t.object_settings.color + '"><img src="' + t.object_settings.widget_img + '"/></div>';
|
135 |
case"chat-smile":
|
136 |
-
return '<svg version="1.1" id="smile" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="-496.8 507.1 54 54" style="enable-background:new -496.8 507.1 54 54;" xml:space="preserve"><style type="text/css">.
|
137 |
case"chat-bubble":
|
138 |
-
return '<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="-496.9 507.1 54 54" style="enable-background:new -496.9 507.1 54 54;" xml:space="preserve"><style type="text/css">.
|
139 |
case"chat-db":
|
140 |
-
return '<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="-496 507.1 54 54" style="enable-background:new -496 507.1 54 54;" xml:space="preserve"><style type="text/css">.
|
141 |
default:
|
142 |
-
return '<svg version="1.1" id="ch" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="-496 507.7 54 54" style="enable-background:new -496 507.7 54 54;" xml:space="preserve"><style type="text/css">.
|
143 |
}
|
144 |
}(e), h = i("display_cta"), "" != g && "none" != h && (d += ' <div class="chaty-widget-i-title true"> ', d += g, d += "</div>"), d += "</div>", d += '<div class="chaty-widget-i chaty-close-settings i-trigger-close" data-title="' + e.object_settings.close_text + '" style="background-color:' + e.object_settings.color + '">', "" == e.object_settings.close_img ? (d += '<svg viewBox="0 0 54 54" fill="none" xmlns="http://www.w3.org/2000/svg">', d += '<ellipse cx="26" cy="26" rx="26" ry="26" fill="' + e.object_settings.color + '"/>', d += '<rect width="27.1433" height="3.89857" rx="1.94928" transform="translate(18.35 15.6599) scale(0.998038 1.00196) rotate(45)" fill="white"/>', d += '<rect width="27.1433" height="3.89857" rx="1.94928" transform="translate(37.5056 18.422) scale(0.998038 1.00196) rotate(135)" fill="white"/>', d += "</svg>") : d += "<span class='chaty-social-img'><img alt='" + e.object_settings.close_text + "' src='" + e.object_settings.close_img + "' /></span>", d += '<div class="chaty-widget-i-title">', d += e.object_settings.close_text, d += "</div>", d += "</div>", d += " </div>", 0 === n.length && !e.object_settings.isPRO && (d += ''), d += "</div>"
|
145 |
} else ;
|
@@ -572,12 +572,17 @@
|
|
572 |
} else {
|
573 |
jQuery(".chaty-widget").addClass("hide-widget");
|
574 |
if (chaty_settings.object_settings.time_trigger == "yes") {
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
|
|
|
|
|
|
|
|
|
|
581 |
}
|
582 |
if (chaty_settings.object_settings.exit_intent == "yes") {
|
583 |
function addEvent(obj, evt, fn) {
|
@@ -640,6 +645,9 @@
|
|
640 |
}
|
641 |
}
|
642 |
});
|
|
|
|
|
|
|
643 |
}
|
644 |
}
|
645 |
}
|
133 |
case"chat-image":
|
134 |
if (t.object_settings.widget_img.length > 1) return '<div class="widget-img" style="background-color:' + t.object_settings.color + '"><img src="' + t.object_settings.widget_img + '"/></div>';
|
135 |
case"chat-smile":
|
136 |
+
return '<svg version="1.1" id="smile" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="-496.8 507.1 54 54" style="enable-background:new -496.8 507.1 54 54;" xml:space="preserve"><style type="text/css">.sts1{fill:#FFFFFF;} .sts2{fill:none;stroke:#808080;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round;}</style><g><circle cx="-469.8" cy="534.1" r="27" fill="' + t.object_settings.color + '"/></g><path class="sts1" d="M-459.5,523.5H-482c-2.1,0-3.7,1.7-3.7,3.7v13.1c0,2.1,1.7,3.7,3.7,3.7h19.3l5.4,5.4c0.2,0.2,0.4,0.2,0.7,0.2c0.2,0,0.2,0,0.4,0c0.4-0.2,0.6-0.6,0.6-0.9v-21.5C-455.8,525.2-457.5,523.5-459.5,523.5z"/><path class="sts2" d="M-476.5,537.3c2.5,1.1,8.5,2.1,13-2.7"/><path class="sts2" d="M-460.8,534.5c-0.1-1.2-0.8-3.4-3.3-2.8"/></svg>';
|
137 |
case"chat-bubble":
|
138 |
+
return '<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="-496.9 507.1 54 54" style="enable-background:new -496.9 507.1 54 54;" xml:space="preserve"><style type="text/css">.sts1{fill:#FFFFFF;}</style><g><circle cx="-469.9" cy="534.1" r="27" fill="' + t.object_settings.color + '"/></g><path class="sts1" d="M-472.6,522.1h5.3c3,0,6,1.2,8.1,3.4c2.1,2.1,3.4,5.1,3.4,8.1c0,6-4.6,11-10.6,11.5v4.4c0,0.4-0.2,0.7-0.5,0.9 c-0.2,0-0.2,0-0.4,0c-0.2,0-0.5-0.2-0.7-0.4l-4.6-5c-3,0-6-1.2-8.1-3.4s-3.4-5.1-3.4-8.1C-484.1,527.2-478.9,522.1-472.6,522.1z M-462.9,535.3c1.1,0,1.8-0.7,1.8-1.8c0-1.1-0.7-1.8-1.8-1.8c-1.1,0-1.8,0.7-1.8,1.8C-464.6,534.6-463.9,535.3-462.9,535.3z M-469.9,535.3c1.1,0,1.8-0.7,1.8-1.8c0-1.1-0.7-1.8-1.8-1.8c-1.1,0-1.8,0.7-1.8,1.8C-471.7,534.6-471,535.3-469.9,535.3z M-477,535.3c1.1,0,1.8-0.7,1.8-1.8c0-1.1-0.7-1.8-1.8-1.8c-1.1,0-1.8,0.7-1.8,1.8C-478.8,534.6-478.1,535.3-477,535.3z"/></svg>';
|
139 |
case"chat-db":
|
140 |
+
return '<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="-496 507.1 54 54" style="enable-background:new -496 507.1 54 54;" xml:space="preserve"><style type="text/css">.sts1{fill:#FFFFFF;}</style><g><circle cx="-469" cy="534.1" r="27" fill="' + t.object_settings.color + '"/></g><path class="sts1" d="M-464.6,527.7h-15.6c-1.9,0-3.5,1.6-3.5,3.5v10.4c0,1.9,1.6,3.5,3.5,3.5h12.6l5,5c0.2,0.2,0.3,0.2,0.7,0.2c0.2,0,0.2,0,0.3,0c0.3-0.2,0.5-0.5,0.5-0.9v-18.2C-461.1,529.3-462.7,527.7-464.6,527.7z"/><path class="sts1" d="M-459.4,522.5H-475c-1.9,0-3.5,1.6-3.5,3.5h13.9c2.9,0,5.2,2.3,5.2,5.2v11.6l1.9,1.9c0.2,0.2,0.3,0.2,0.7,0.2c0.2,0,0.2,0,0.3,0c0.3-0.2,0.5-0.5,0.5-0.9v-18C-455.9,524.1-457.5,522.5-459.4,522.5z"/></svg>';
|
141 |
default:
|
142 |
+
return '<svg version="1.1" id="ch" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="-496 507.7 54 54" style="enable-background:new -496 507.7 54 54;" xml:space="preserve"><style type="text/css">.sts1 {fill: #FFFFFF;}.st0{fill: #808080;}</style><g><circle cx="-469" cy="534.7" r="27" fill="' + t.object_settings.color + '"/></g><path class="sts1" d="M-459.9,523.7h-20.3c-1.9,0-3.4,1.5-3.4,3.4v15.3c0,1.9,1.5,3.4,3.4,3.4h11.4l5.9,4.9c0.2,0.2,0.3,0.2,0.5,0.2 h0.3c0.3-0.2,0.5-0.5,0.5-0.8v-4.2h1.7c1.9,0,3.4-1.5,3.4-3.4v-15.3C-456.5,525.2-458,523.7-459.9,523.7z"/><path class="st0" d="M-477.7,530.5h11.9c0.5,0,0.8,0.4,0.8,0.8l0,0c0,0.5-0.4,0.8-0.8,0.8h-11.9c-0.5,0-0.8-0.4-0.8-0.8l0,0C-478.6,530.8-478.2,530.5-477.7,530.5z"/><path class="st0" d="M-477.7,533.5h7.9c0.5,0,0.8,0.4,0.8,0.8l0,0c0,0.5-0.4,0.8-0.8,0.8h-7.9c-0.5,0-0.8-0.4-0.8-0.8l0,0C-478.6,533.9-478.2,533.5-477.7,533.5z"/></svg>'
|
143 |
}
|
144 |
}(e), h = i("display_cta"), "" != g && "none" != h && (d += ' <div class="chaty-widget-i-title true"> ', d += g, d += "</div>"), d += "</div>", d += '<div class="chaty-widget-i chaty-close-settings i-trigger-close" data-title="' + e.object_settings.close_text + '" style="background-color:' + e.object_settings.color + '">', "" == e.object_settings.close_img ? (d += '<svg viewBox="0 0 54 54" fill="none" xmlns="http://www.w3.org/2000/svg">', d += '<ellipse cx="26" cy="26" rx="26" ry="26" fill="' + e.object_settings.color + '"/>', d += '<rect width="27.1433" height="3.89857" rx="1.94928" transform="translate(18.35 15.6599) scale(0.998038 1.00196) rotate(45)" fill="white"/>', d += '<rect width="27.1433" height="3.89857" rx="1.94928" transform="translate(37.5056 18.422) scale(0.998038 1.00196) rotate(135)" fill="white"/>', d += "</svg>") : d += "<span class='chaty-social-img'><img alt='" + e.object_settings.close_text + "' src='" + e.object_settings.close_img + "' /></span>", d += '<div class="chaty-widget-i-title">', d += e.object_settings.close_text, d += "</div>", d += "</div>", d += " </div>", 0 === n.length && !e.object_settings.isPRO && (d += ''), d += "</div>"
|
145 |
} else ;
|
572 |
} else {
|
573 |
jQuery(".chaty-widget").addClass("hide-widget");
|
574 |
if (chaty_settings.object_settings.time_trigger == "yes") {
|
575 |
+
if(parseInt(chaty_settings.object_settings.trigger_time) > 0) {
|
576 |
+
setTimeout(function () {
|
577 |
+
if (!isWidgetEnabled) {
|
578 |
+
jQuery(".chaty-widget").removeClass("hide-widget");
|
579 |
+
show_chaty_widget();
|
580 |
+
}
|
581 |
+
}, parseInt(chaty_settings.object_settings.trigger_time) * 1000);
|
582 |
+
} else {
|
583 |
+
jQuery(".chaty-widget").removeClass("hide-widget");
|
584 |
+
show_chaty_widget();
|
585 |
+
}
|
586 |
}
|
587 |
if (chaty_settings.object_settings.exit_intent == "yes") {
|
588 |
function addEvent(obj, evt, fn) {
|
645 |
}
|
646 |
}
|
647 |
});
|
648 |
+
} else {
|
649 |
+
jQuery(".chaty-widget").removeClass("hide-widget");
|
650 |
+
show_chaty_widget();
|
651 |
}
|
652 |
}
|
653 |
}
|
js/cht-front-script.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
function launch_chaty(){jQuery(".chaty-widget").hasClass("one_widget")||jQuery(".trigger-chaty-button").trigger("click")}function close_chaty(){jQuery("#chaty-inline-popup").hasClass("active")&&jQuery("#chaty-inline-popup .close-chaty-popup").trigger("click"),jQuery(".chaty-widget.chaty-widget-show").length&&jQuery(".chaty-widget.chaty-widget-show").each(function(){jQuery(this).find(".chaty-close-settings").length&&jQuery(this).find(".chaty-close-settings").trigger("click")})}!function(t){var e={};function i(s){if(e[s])return e[s].exports;var a=e[s]={i:s,l:!1,exports:{}};return t[s].call(a.exports,a,a.exports,i),a.l=!0,a.exports}i.m=t,i.c=e,i.d=function(t,e,s){i.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:s})},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="/",i(i.s=10)}({10:function(t,e,i){i(11),t.exports=i(12)},11:function(t,e){!function(t){var e,i=0,s=".i-trigger .chaty-widget-i .svg, .i-trigger .chaty-widget-i .widget-img, .i-trigger .chaty-widget-i .facustom-icon",a=!1;function c(t){return r()&&"click"==chaty_settings.object_settings.click_setting?"none":""}(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(navigator.userAgent.substr(0,4)))&&(a=!0);new Date;function n(){jQuery(".chaty-widget").hasClass("one_widget")&&jQuery(".chaty-widget").removeClass("chaty-widget-show")}function o(t){var e="@-webkit-keyframes chaty-animation-shockwave { 0% { transform: scale(1); box-shadow: 0 0 2px rgba("+t+", 0.30), inset 0 0 1px rgba("+t+", 0.30); } 95% { box-shadow: 0 0 50px rgba("+t+", 0), inset 0 0 30px rgba("+t+", 0); } 100% { transform: scale(2.25); } } @keyframes chaty-animation-shockwave { 0% { transform: scale(1); box-shadow: 0 0 2px rgba("+t+", 0.30), inset 0 0 1px rgba("+t+", 0.30); } 95% { box-shadow: 0 0 50px rgba("+t+", 0), inset 0 0 30px rgba("+t+", 0); } 100% { transform: scale(2.25); } }";jQuery("#chaty-advance-css").length||jQuery("body").append("<div id='chaty-advance-css'></div>"),jQuery("#chaty-advance-css").append("<style>"+e+"</style>")}function r(){var t=g("cta");if(null!=t&&""!=t){t=new Date(t);var e=Math.abs(new Date-t);return Math.floor(e/6e4)<=10}return!1}function g(t){var e=u("chaty_settings"),i=[];if(null!=e&&""!=e&&(i=JSON.parse(e)),i.length>0)for(var s=0;s<i.length;s++)if(i[s].k==t)return i[s].v;return null}function l(t){var e=u("chaty_settings"),i=[];null!=e&&""!=e&&(i=JSON.parse(e));var s=!1;if(i.length>0)for(var a=0;a<i.length;a++)i[a].k==t&&(s=!0,i[a].v=new Date);s||i.push({k:t,v:new Date}),y("chaty_settings",e=JSON.stringify(i),"7")}function h(t){var e=g(t);if(null!=e&&""!=e){e=new Date(e);var i=Math.abs(new Date-e);return Math.floor(i/864e5)>=1}return!0}function d(){var t=u("chaty_settings"),e=[];null!=t&&""!=t&&(e=JSON.parse(t));var i=!1;if(e.length>0)for(var s=0;s<e.length;s++)"cta"==e[s].k&&(i=!0,e[s].v=new Date);i||e.push({k:"cta",v:new Date}),y("chaty_settings",t=JSON.stringify(e),"7")}function y(t,e,i){var s="";if(i){var a=new Date;a.setTime(a.getTime()+24*i*60*60*1e3),s="; expires="+a.toUTCString()}document.cookie=t+"="+(e||"")+s+"; path=/"}function u(t){for(var e=t+"=",i=document.cookie.split(";"),s=0;s<i.length;s++){for(var a=i[s];" "==a.charAt(0);)a=a.substring(1,a.length);if(0==a.indexOf(e))return a.substring(e.length,a.length)}return null}function w(){l("cta_widget_status"),i=1;var t=0;t=jQuery("body").hasClass("chaty-in-desktop")?jQuery(".chaty-widget-is .chaty-widget-i.is-in-desktop").length:jQuery(".chaty-widget-is .chaty-widget-i.is-in-mobile").length,h("chaty-animation")||(chaty_settings.object_settings.animation_class=""),""!=chaty_settings.object_settings.animation_class&&("sheen"!=chaty_settings.object_settings.animation_class?t>1?jQuery(s).addClass("chaty-animation-"+chaty_settings.object_settings.animation_class).addClass("start-now"):1==t&&(s=".chaty-main-widget .svg, .chaty-main-widget img, .chaty-main-widget .facustom-icon",jQuery(s).removeClass("chaty-animation-"+chaty_settings.object_settings.animation_class).removeClass("start-now"),jQuery(s).addClass("chaty-animation-"+chaty_settings.object_settings.animation_class).addClass("start-now")):(s=".i-trigger .chaty-widget-i .wrap-svg",jQuery(".i-trigger .chaty-widget-i .wrap-svg").length,jQuery(s).removeClass("chaty-animation-sheen").removeClass("start-now"),jQuery(s).addClass("chaty-animation-sheen").addClass("start-now"))),"open"==chaty_settings.object_settings.display_state&&("no"==chaty_settings.object_settings.has_close_button?t>1&&(p(),jQuery(".chaty-widget").find(".i-trigger-open").removeClass("active_clos"),jQuery(".chaty-widget").find(".i-trigger-open").trigger("click"),jQuery(".chaty-widget-is").addClass("has-no-close-btn"),jQuery(".i-trigger").remove()):t>1&&(p(),jQuery(".chaty-widget").find(".i-trigger-open").removeClass("active_clos"),jQuery(".chaty-widget").find(".i-trigger-open").trigger("click"))),jQuery(".chaty-widget").hasClass("one_widget")&&jQuery(".chaty-widget").removeClass("chaty-widget-show")}function p(){l("chaty-animation"),jQuery(".chaty-animation-"+chaty_settings.object_settings.animation_class).removeClass("chaty-animation-"+chaty_settings.object_settings.animation_class).removeClass("start-now"),jQuery(".start-now").removeClass("start-now"),chaty_settings.object_settings.animation_class=""}jQuery(document).ready(function(){a?jQuery("body").addClass("chaty-in-mobile"):jQuery("body").addClass("chaty-in-desktop"),c(),token="",jQuery(document).ready(function(){"true"==(e=chaty_settings).object_settings.active&&function(e,i){var s=e.object_settings.device,a="";if("right"==e.object_settings.position)a="left: auto;bottom: 25px; right: 25px;";else if("left"==e.object_settings.position)a="right: auto; bottom: 25px; left: 25px;";else if("custom"==e.object_settings.position){var n=e.object_settings.pos_side,o=e.object_settings.bot,r=e.object_settings.side;a="right"===n?"left: auto; bottom: "+o+"px; right: "+r+"px":"left: "+r+"px; bottom: "+o+"px; right: auto"}var g=e.object_settings.cta,l="",d=e.object_settings.social;if(Object.keys(d).length>=1&&(l='<div class="chaty-widget hide-widget '+i+" "+s+' " style="display:block; '+a+'" dir="ltr">',l+='<div class="chaty-widget-is" id="transition_disabled">'),l+=function(e){var i="",s=0;return t.each(e.object_settings.social,function(t,a){if(e.object_settings.isPRO&&jQuery("body").addClass("has-pro-version"),!e.object_settings.isPRO&&"3"==++s)return!1;extra_class="","1"!=e.object_settings.analytics&&1!=e.object_settings.analytics||(extra_class+=" update-analytics ");var c=1==e.object_settings.social[t].is_desktop?"is-in-desktop":"",n=1==e.object_settings.social[t].is_mobile?"is-in-mobile":"",o=1==e.object_settings.is_mobile?e.object_settings.social[t].mobile_target:e.object_settings.social[t].desktop_target;if(jQuery("body").hasClass("chaty-in-mobile")&&(e.object_settings.social[t].href_url=e.object_settings.social[t].mobile_url),"viber"==e.object_settings.social[t].social_channel){if(jQuery("body").hasClass("chaty-in-mobile")){var r=e.object_settings.social[t].href_url;isNaN(r)||(r=r.replace("+",""),navigator.userAgent.match(/(iPod|iPhone|iPad)/)&&(r="+"+r)),e.object_settings.social[t].href_url=r}e.object_settings.social[t].href_url="viber://chat?number="+e.object_settings.social[t].href_url}1==parseInt(e.object_settings.social[t].has_custom_popup)&&("whatsapp"==e.object_settings.social[t].channel_type?(e.object_settings.social[t].is_default_open&&h("cht_whatsapp_window")&&(extra_class+=" open-it-by-default"),o="",e.object_settings.social[t].mobile_target="",e.object_settings.social[t].desktop_target="",extra_class+=" has-custom-chaty-popup whatsapp-button"):"contact_us"==e.object_settings.social[t].channel_type&&(extra_class+=" has-custom-chaty-popup whatsapp-button"));var g="";""!=e.object_settings.social[t].on_click&&(g=' onclick="'+e.object_settings.social[t].on_click+'"'),socialString='<div data-popup="'+e.object_settings.social[t].popup_html+'" data-rgb="'+e.object_settings.social[t].rbg_color+'" class="chaty-widget-i chaty-main-widget '+c+" "+n+" "+extra_class+" channel-"+e.object_settings.social[t].social_channel+'" data-title="'+e.object_settings.social[t].val+'" id="chaty-channel-'+e.object_settings.social[t].social_channel+'" data-channel="'+e.object_settings.social[t].social_channel+'" data-code="'+e.object_settings.social[t].qr_code_image+'">',bgColor="",""!=e.object_settings.social[t].bg_color&&(socialString+="<style>#chaty-channel-"+e.object_settings.social[t].social_channel+" .color-element {fill: "+e.object_settings.social[t].bg_color+"; background: "+e.object_settings.social[t].bg_color+"}</style>",bgColor="style='background-color: "+e.object_settings.social[t].bg_color+";'"),socialString+="<a class='set-url-target' "+g+" rel='noopener' data-mobile-target='"+e.object_settings.social[t].mobile_target+"' data-desktop-target='"+e.object_settings.social[t].desktop_target+"' target='"+o+"' href='"+e.object_settings.social[t].href_url+"' >",socialString+="<span class='sr-only'>"+e.object_settings.social[t].title+"</span>",""!=e.object_settings.social[t].img_url?socialString+="<span "+bgColor+" class='chaty-social-img'><img src='"+e.object_settings.social[t].img_url+"' alt='"+e.object_settings.social[t].title+"' /></span>":socialString+=e.object_settings.social[t].default_icon,socialString+="</a>",socialString+="<div class='chaty-widget-i-title'><p>"+e.object_settings.social[t].title+"</p></div>",socialString+="</div>",i+=socialString}),i}(e),d=e.object_settings.social,Object.keys(d).length>=1){l+="</div>",l+='<div class="i-trigger">';var y=c(),u=current_url=window.location.origin;if(u=(u=u.replace("https://","")).replace("http://",""),""!=g&&"none"!=y);else"no-tooltip";"click"!=chaty_settings.object_settings.click_setting&&!0,l+='<div class="chaty-widget-i chaty-close-settings i-trigger-open '+!0+' ">',l+=function(t){switch(t.object_settings.widget_type){case"chat-image":if(t.object_settings.widget_img.length>1)return'<div class="widget-img" style="background-color:'+t.object_settings.color+'"><img src="'+t.object_settings.widget_img+'"/></div>';case"chat-smile":return'<svg version="1.1" id="smile" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="-496.8 507.1 54 54" style="enable-background:new -496.8 507.1 54 54;" xml:space="preserve"><style type="text/css">.st1{fill:#FFFFFF;} .st2{fill:none;stroke:#808080;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round;}</style><g><circle cx="-469.8" cy="534.1" r="27" fill="'+t.object_settings.color+'"/></g><path class="st1" d="M-459.5,523.5H-482c-2.1,0-3.7,1.7-3.7,3.7v13.1c0,2.1,1.7,3.7,3.7,3.7h19.3l5.4,5.4c0.2,0.2,0.4,0.2,0.7,0.2c0.2,0,0.2,0,0.4,0c0.4-0.2,0.6-0.6,0.6-0.9v-21.5C-455.8,525.2-457.5,523.5-459.5,523.5z"/><path class="st2" d="M-476.5,537.3c2.5,1.1,8.5,2.1,13-2.7"/><path class="st2" d="M-460.8,534.5c-0.1-1.2-0.8-3.4-3.3-2.8"/></svg>';case"chat-bubble":return'<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="-496.9 507.1 54 54" style="enable-background:new -496.9 507.1 54 54;" xml:space="preserve"><style type="text/css">.st1{fill:#FFFFFF;}</style><g><circle cx="-469.9" cy="534.1" r="27" fill="'+t.object_settings.color+'"/></g><path class="st1" d="M-472.6,522.1h5.3c3,0,6,1.2,8.1,3.4c2.1,2.1,3.4,5.1,3.4,8.1c0,6-4.6,11-10.6,11.5v4.4c0,0.4-0.2,0.7-0.5,0.9 c-0.2,0-0.2,0-0.4,0c-0.2,0-0.5-0.2-0.7-0.4l-4.6-5c-3,0-6-1.2-8.1-3.4s-3.4-5.1-3.4-8.1C-484.1,527.2-478.9,522.1-472.6,522.1z M-462.9,535.3c1.1,0,1.8-0.7,1.8-1.8c0-1.1-0.7-1.8-1.8-1.8c-1.1,0-1.8,0.7-1.8,1.8C-464.6,534.6-463.9,535.3-462.9,535.3z M-469.9,535.3c1.1,0,1.8-0.7,1.8-1.8c0-1.1-0.7-1.8-1.8-1.8c-1.1,0-1.8,0.7-1.8,1.8C-471.7,534.6-471,535.3-469.9,535.3z M-477,535.3c1.1,0,1.8-0.7,1.8-1.8c0-1.1-0.7-1.8-1.8-1.8c-1.1,0-1.8,0.7-1.8,1.8C-478.8,534.6-478.1,535.3-477,535.3z"/></svg>';case"chat-db":return'<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="-496 507.1 54 54" style="enable-background:new -496 507.1 54 54;" xml:space="preserve"><style type="text/css">.st1{fill:#FFFFFF;}</style><g><circle cx="-469" cy="534.1" r="27" fill="'+t.object_settings.color+'"/></g><path class="st1" d="M-464.6,527.7h-15.6c-1.9,0-3.5,1.6-3.5,3.5v10.4c0,1.9,1.6,3.5,3.5,3.5h12.6l5,5c0.2,0.2,0.3,0.2,0.7,0.2c0.2,0,0.2,0,0.3,0c0.3-0.2,0.5-0.5,0.5-0.9v-18.2C-461.1,529.3-462.7,527.7-464.6,527.7z"/><path class="st1" d="M-459.4,522.5H-475c-1.9,0-3.5,1.6-3.5,3.5h13.9c2.9,0,5.2,2.3,5.2,5.2v11.6l1.9,1.9c0.2,0.2,0.3,0.2,0.7,0.2c0.2,0,0.2,0,0.3,0c0.3-0.2,0.5-0.5,0.5-0.9v-18C-455.9,524.1-457.5,522.5-459.4,522.5z"/></svg>';default:return'<svg version="1.1" id="ch" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="-496 507.7 54 54" style="enable-background:new -496 507.7 54 54;" xml:space="preserve"><style type="text/css">.st1 {fill: #FFFFFF;}.st0{fill: #808080;}</style><g><circle cx="-469" cy="534.7" r="27" fill="'+t.object_settings.color+'"/></g><path class="st1" d="M-459.9,523.7h-20.3c-1.9,0-3.4,1.5-3.4,3.4v15.3c0,1.9,1.5,3.4,3.4,3.4h11.4l5.9,4.9c0.2,0.2,0.3,0.2,0.5,0.2 h0.3c0.3-0.2,0.5-0.5,0.5-0.8v-4.2h1.7c1.9,0,3.4-1.5,3.4-3.4v-15.3C-456.5,525.2-458,523.7-459.9,523.7z"/><path class="st0" d="M-477.7,530.5h11.9c0.5,0,0.8,0.4,0.8,0.8l0,0c0,0.5-0.4,0.8-0.8,0.8h-11.9c-0.5,0-0.8-0.4-0.8-0.8l0,0C-478.6,530.8-478.2,530.5-477.7,530.5z"/><path class="st0" d="M-477.7,533.5h7.9c0.5,0,0.8,0.4,0.8,0.8l0,0c0,0.5-0.4,0.8-0.8,0.8h-7.9c-0.5,0-0.8-0.4-0.8-0.8l0,0C-478.6,533.9-478.2,533.5-477.7,533.5z"/></svg>'}}(e),y=c(),""!=g&&"none"!=y&&(l+=' <div class="chaty-widget-i-title true"> ',l+=g,l+="</div>"),l+="</div>",l+='<div class="chaty-widget-i chaty-close-settings i-trigger-close" data-title="'+e.object_settings.close_text+'" style="background-color:'+e.object_settings.color+'">',""==e.object_settings.close_img?(l+='<svg viewBox="0 0 54 54" fill="none" xmlns="http://www.w3.org/2000/svg">',l+='<ellipse cx="26" cy="26" rx="26" ry="26" fill="'+e.object_settings.color+'"/>',l+='<rect width="27.1433" height="3.89857" rx="1.94928" transform="translate(18.35 15.6599) scale(0.998038 1.00196) rotate(45)" fill="white"/>',l+='<rect width="27.1433" height="3.89857" rx="1.94928" transform="translate(37.5056 18.422) scale(0.998038 1.00196) rotate(135)" fill="white"/>',l+="</svg>"):l+="<span class='chaty-social-img'><img alt='"+e.object_settings.close_text+"' src='"+e.object_settings.close_img+"' /></span>",l+='<div class="chaty-widget-i-title">',l+=e.object_settings.close_text,l+="</div>",l+="</div>",l+=" </div>",0===i.length&&!e.object_settings.isPRO&&(l+=""),l+="</div>"}t("body").append(l)}(e,token),function(){var i=t(".chaty-widget"),s=e.object_settings.widget_size?e.object_settings.widget_size:54,a=+e.object_settings.widget_size+8;function o(){i.position().top;var t=i.find(".chaty-widget-is .chaty-widget-i").length;if((t=jQuery("body").hasClass("chaty-in-desktop")?i.find(".chaty-widget-is .chaty-widget-i.is-in-desktop").length:i.find(".chaty-widget-is .chaty-widget-i.is-in-mobile").length)*a>jQuery(window).height()-(chaty_settings.object_settings.widget_size+8)){var e=Math.round(Math.sqrt(t)),s=Math.ceil(Math.sqrt(t));i.find(".chaty-widget-is").css({height:s*a,width:e*a}),g(s),i.find("span:not(.cht-pending-message)").css({height:s*a,width:e*a}),g(s),i.find("img").css({height:s*a,width:e*a}),g(s)}else g()}function r(){"left"===e.object_settings.position&&i.addClass("chaty-widget-is-right"),"custom"===e.object_settings.position&&"left"===e.object_settings.pos_side&&i.addClass("chaty-widget-is-right")}function g(t){var e;e=jQuery("body").hasClass("chaty-in-desktop")?i.find(".chaty-widget-is .chaty-widget-i.is-in-desktop").length:i.find(".chaty-widget-is .chaty-widget-i.is-in-mobile").length,i.find(".chaty-widget-i").css({height:s+"px",width:s+"px"}),i.find("img").css({height:s+"px",width:s+"px"}),i.find("span:not(.cht-pending-message)").css({height:s+"px",width:s+"px"}),i.find(".chaty-widget-is").css({top:"-"+100*e+"%"}),i.find(".chaty-widget-is").height(e*(parseInt(s)+8)),i.find(".chaty-widget-is").width(parseInt(s)+8),"horizontal"==chaty_settings.object_settings.mode?(i.find(".chaty-widget-is").css({top:"0"}),i.find(".chaty-widget-is").width(e*(parseInt(s)+8)),i.find(".chaty-widget-is").height(parseInt(s)+8)):(i.find(".chaty-widget-is").height(e*(parseInt(s)+8)),i.find(".chaty-widget-is").width(parseInt(s)+8))}jQuery(".open-it-by-default").length&&jQuery(".open-it-by-default").trigger("click"),r(),o(),jQuery(window).resize(function(){o(),1==Object.keys(e.object_settings.social).length&&(jQuery(".chaty-widget").addClass("chaty-widget-show"),jQuery(".chaty-widget-is").css("top","auto")),jQuery(".chaty-widget").hasClass("one_widget")&&jQuery(".chaty-widget").removeClass("chaty-widget-show")}),t(".chaty-widget-i.facebook").mouseenter(function(){t(".facebook_two_mess").css({opacity:"1","z-index":"1"}),t(this).addClass("before")}),t(".chaty-widget-i.facebook").mouseleave(function(){t(".facebook_two_mess").css({opacity:"0","z-index":"1"}),t(this).removeClass("before")}),t(".chaty-widget-i.facebook").on("click",function(){t(this).addClass("active"),t(".facebook_two_mess").hide(),jQuery(".chaty-widget .get a").hide(),t(this).children(".face_title").css({opacity:"1","z-index":"2"}).show(),t(".chaty-widget").hasClass("one_widget")?t(".chaty-widget").hasClass("chaty-widget-is-right")?t(".face_title").css({top:"calc(100% - 447px)",left:"20px"}):t(".face_title").css({top:"calc(100% - 447px)",left:"auto",right:"20px"}):(t(".facebook_two_mess").css({opacity:"0","z-index":"10001"}),t(".ico_d").hide(),t(".chaty-widget .chaty-widget-i").css({"box-shadow":"0px 3px 6px rgba(0,0,0,0)"}),t(".chaty-widget").hasClass("one_widget")||t(".i-trigger").hide())}),t(".i-trigger-close").on("click",function(e){e.preventDefault(),t(".chaty-widget-i.facebook").hasClass("active")||(i.removeClass("chaty-widget-show"),i.addClass("none-widget-show"))}),t("body").on("click",".close_facebook",function(){t(".facebook_two_mess").show(),jQuery(".chaty-widget .get a").show(),t(".chaty-widget-i.facebook").removeClass("active"),t(this).parent().parent().css({opacity:"1"}).hide(),t(".i-trigger").show(),t(".chaty-widget-is .chaty-widget-i svg").show()}),t(".i-trigger-close").on("click",function(e){t(".i-trigger-open").addClass("active_clos"),e.preventDefault(),t(".chaty-widget-i.facebook").hasClass("active")||(i.removeClass("chaty-widget-show"),i.addClass("none-widget-show"))}),t("body").on("click",".update-analytics",function(t){if(channelName=jQuery(this).attr("data-channel"),null!=channelName&&""!=channelName)if(window.hasOwnProperty("gtag"))gtag("event","chaty_"+channelName,{eventCategory:"chaty_"+channelName,event_action:"chaty_"+channelName});else if(window.hasOwnProperty("ga")){var e=window.ga.getAll()[0];e&&e.send("event","click",{eventCategory:"chaty_"+channelName,eventAction:"chaty_"+channelName})}}),t("body").on("click",".wechat",function(){var t=jQuery(".chaty-widget .chaty-widget-i.wechat").attr("data-code");null!=t&&""!=t&&(jQuery("#wechat-qr-code").length||(htmlString="<div id='wechat-qr-code' class='wechat-qr-code'>",htmlString+='<div class="wechat-box-head">WeChat<svg xmlns="http://www.w3.org/2000/svg" class="close_facebook" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Capa_1" x="0px" y="0px" width="612px" height="612px" viewBox="0 0 612 612" style="fill: #fff; float: right; margin-top: 4px;" xml:space="preserve"><path xmlns="http://www.w3.org/2000/svg" d="M268.064,256.75l138.593-138.593c3.124-3.124,3.124-8.189,0-11.313c-3.125-3.124-8.189-3.124-11.314,0L256.75,245.436 L118.157,106.843c-3.124-3.124-8.189-3.124-11.313,0c-3.125,3.124-3.125,8.189,0,11.313L245.436,256.75L106.843,395.343 c-3.125,3.125-3.125,8.189,0,11.314c1.562,1.562,3.609,2.343,5.657,2.343s4.095-0.781,5.657-2.343L256.75,268.064l138.593,138.593 c1.563,1.562,3.609,2.343,5.657,2.343s4.095-0.781,5.657-2.343c3.124-3.125,3.124-8.189,0-11.314L268.064,256.75z"></path></svg></div>',htmlString+="<div class='wechat-box'><img src='"+t+"' alt='QR Code' /><a href='javascript:;'>",htmlString+="</a></div></div>",jQuery("body").append(htmlString)),jQuery("#wechat-qr-code").show())});var l=c();"hover"==chaty_settings.object_settings.display_state?i.find(".i-trigger-open").mouseenter(function(e){e.stopPropagation(),n(),t(".chaty-widget-is").removeAttr("id"),t(this).hasClass("active_clos")||t(".chaty-widget-i.facebook").hasClass("active")||i.hasClass("one_widget")||(r(),t(i).hasClass("chaty-widget-show")||(i.addClass("chaty-widget-show"),i.removeClass("none-widget-show"))),jQuery(".chaty-widget").hasClass("one_widget")&&jQuery(".chaty-widget").removeClass("chaty-widget-show"),"click"==chaty_settings.object_settings.click_setting&&(jQuery(".i-trigger").hasClass("one-widget")||(jQuery(this).closest(".chaty-widget-i").addClass("hide-chaty-arrow"),jQuery("body .chaty-widget-i-title.true").remove()))}):i.find(".i-trigger-open").click(function(e){e.stopPropagation(),p(),n(),t(".chaty-widget-is").removeAttr("id"),t(this).hasClass("active_clos")||t(".chaty-widget-i.facebook").hasClass("active")||i.hasClass("one_widget")||(r(),t(i).hasClass("chaty-widget-show")||(i.addClass("chaty-widget-show"),i.removeClass("none-widget-show"))),n(),"click"==chaty_settings.object_settings.click_setting&&(jQuery(".i-trigger").hasClass("one-widget")||(jQuery(this).closest(".chaty-widget-i").addClass("hide-chaty-arrow"),jQuery("body .chaty-widget-i-title.true").remove())),jQuery(".cht-pending-message").remove()}),t(".one_widget").on("click",function(){p(),jQuery(".cht-pending-message").remove()}),i.find(".i-trigger-open").on("click",function(){jQuery(".cht-pending-message").remove(),"none"!=l&&(t(".chaty-widget").hasClass(".one_widget")||t(".i-trigger-open .chaty-widget-i-title1").detach()),"click"==chaty_settings.object_settings.click_setting&&t(".i-trigger-open").addClass("no-tooltip"),t(this).hasClass("active_clos")||t(".chaty-widget-i.facebook").hasClass("active")||i.hasClass("one_widget")||(r(),t(i).hasClass("chaty-widget-show")||(i.addClass("chaty-widget-show"),i.removeClass("none-widget-show"))),p()}),i.find(".i-trigger-open").mouseenter(function(){"click"==chaty_settings.object_settings.click_setting&&t(this).addClass("no-tooltip"),t(".i-trigger-open").removeClass("active_clos"),o()}),i.find(".chaty-widget-is").mouseleave(function(){t(".i-trigger-open").removeClass("active_clos"),t(".chaty-widget-i.facebook").hasClass("active")}),1===Object.keys(e.object_settings.social).length&&i.find(".i-trigger-open").on("touchstart",function(e){"use strict";t(this).find(".chaty-widget-i").toggleClass("hover")}),1==Object.keys(e.object_settings.social).length&&(jQuery(".chaty-widget").addClass("chaty-widget-show"),jQuery(".chaty-widget-is").css("top","auto"),jQuery(".chaty-widget-is").css("z-index","10001"),jQuery(".chaty-widget-i.i-trigger-close, .i-trigger.chaty-widget-i").remove(),jQuery(".chaty-widget .get a").css("top","-10px"),jQuery(".chaty-widget").addClass("one_widget"),jQuery(document).on("click",".chaty-widget-i",function(){jQuery(".i-trigger").hasClass("one-widget")||(jQuery(".chaty-widget-i:first .chaty-widget-i-title:last").hide(),jQuery("body").addClass("hide-cht-widget"))}),jQuery("body").append("<style>.chaty-widget-is{top:0!important;}</style>"))}(),t(document).ready(function(){1!==Object.keys(e.object_settings.social).length||!e.object_settings.social.snapchat&&!e.object_settings.social.wechat||e.object_settings.cta||(t(".chaty-widget-i-1title").detach(),t(".chaty-widget-i").addClass("bofore_del")),t(".chaty-widget-i-title").hasClass("one_go")&&(t(".chaty-widget-i-title p").html(t(".chaty-widget-i-title.one_go").html()),"none"==c()&&(t(".chaty-widget-i-title").hasClass("face_title")?(t(".facebook_two_mess").detach(),t(".chaty-widget-i").addClass("bofore_del")):(t(".chaty-widget-i-title11").detach(),t(".chaty-widget-i").addClass("bofore_del")))),window.matchMedia("only screen and (max-width: 760px)").matches&&t(".i-trigger-open").addClass("active_clos"),jQuery(".chaty-widget-i-title").each(function(){""==jQuery(this).text()&&jQuery(this).remove()})}),t(document).ready(function(){var s=0;0==(s=jQuery("body").hasClass("chaty-in-desktop")?jQuery(".chaty-widget-is .chaty-widget-i.is-in-desktop").length:jQuery(".chaty-widget-is .chaty-widget-i.is-in-mobile").length)?jQuery(".chaty-widget").addClass("hide-widget").removeClass("desktop_active").removeClass("mobile_active"):(jQuery("body").hasClass("chaty-in-desktop")?jQuery(".chaty-widget").removeClass("hide-widget").addClass("desktop_active"):jQuery(".chaty-widget").removeClass("hide-widget").addClass("mobile_active"),1==s?(jQuery(".chaty-close-settings").hide(),jQuery("body").hasClass("chaty-in-desktop")?(htmlToAdd=jQuery(".chaty-widget-is .chaty-widget-i.is-in-desktop:first").clone(),jQuery(".i-trigger").html(htmlToAdd)):(htmlToAdd=jQuery(".chaty-widget-is .chaty-widget-i.is-in-mobile:first").clone(),jQuery(".i-trigger").html(htmlToAdd)),r()?"all_time"!=chaty_settings.object_settings.click_setting?(jQuery(".i-trigger").addClass("show-channel"),jQuery(".i-trigger").attr("data-title",jQuery(".chaty-widget-is .chaty-widget-i-title p").html())):jQuery(".i-trigger .chaty-widget-i-title p").html(chaty_settings.object_settings.cta):"all_time"!=chaty_settings.object_settings.click_setting&&(jQuery(".i-trigger").attr("data-title",jQuery(".chaty-widget-is .chaty-widget-i-title p").html()),jQuery(".i-trigger .chaty-widget-i-title p").html(chaty_settings.object_settings.cta)),jQuery(".chaty-widget").addClass("one_widget"),jQuery(".chaty-widget.one_widget, .i-trigger, .chaty-widget-i").mouseenter(function(){n(),"click"==chaty_settings.object_settings.click_setting&&(jQuery(".i-trigger").hasClass("one-widget")||(jQuery(".chaty-widget-i-title").remove(),jQuery(".chaty-widget").addClass("hide-tooltip-arrow")),jQuery(".chaty-widget").removeClass("chaty-widget-show")),jQuery(".i-trigger").hasClass("one-widget")||d()}),jQuery(".chaty-widget").removeClass("chaty-widget-show"),jQuery(".i-trigger").addClass("one-widget"),r(),o(jQuery(".i-trigger .chaty-widget-i:first").data("rgb"))):(jQuery(".chaty-widget").removeClass("one_widget"),"click"==chaty_settings.object_settings.click_setting&&jQuery(".i-trigger .chaty-main-widget").remove(),jQuery(".chaty-close-settings").show(),jQuery(".chaty-widget-i-title").removeClass("hide-it"),jQuery(".chaty-widget.one_widget, .i-trigger, .chaty-widget-i").mouseenter(function(){n(),jQuery(".i-trigger").hasClass("one-widget")||(d(),jQuery(".i-trigger").hasClass("one-widget")||jQuery(".i-trigger .chaty-widget-i-title").addClass("hide-it")),p()}),"open"==chaty_settings.object_settings.display_state&&t(".i-trigger-open").addClass("no-tooltip"),o(chaty_settings.object_settings.rgb_color))),jQuery(document).on("click",".i-trigger.one-widget",function(){d()});var a,g,l,_=0;if(1==parseInt(chaty_settings.object_settings.display_conditions)){var j=chaty_settings.object_settings.display_rules;if(j.length>0){var m=new Date;m.setHours(m.getHours()+chaty_settings.object_settings.gmt);for(var b=m.getUTCHours(),f=m.getUTCMinutes(),v=m.getUTCDay(),Q=0;Q<j.length;Q++){var C=0,k=0;-1==j[Q].days?k=1:j[Q].days>=0&&j[Q].days<=6?j[Q].days==v&&(k=1):7==j[Q].days?v>=0&&v<=4&&(k=1):8==j[Q].days?v>=1&&v<=5&&(k=1):9==j[Q].days&&(5!=v&&6!=v||(k=1)),1==k&&(b>j[Q].start_hours&&b<j[Q].end_hours?C=1:b==j[Q].start_hours&&b<j[Q].end_hours?f>=j[Q].start_min&&(C=1):b>j[Q].start_hours&&b==j[Q].end_hours?f<=j[Q].end_min&&(C=1):b==j[Q].start_hours&&b==j[Q].end_hours&&f>=j[Q].start_min&&f<=j[Q].end_min&&(C=1),1==C&&f>=j[Q].start_min&&f<=j[Q].end_min&&1),1==C&&1==k&&(_=1),1==_&&(Q=j.length+1)}}else _=1}else _=1;if(1==s&&(""!=c()&&("click"==chaty_settings.object_settings.click_setting&&(jQuery(".i-trigger").hasClass("one-widget")||(jQuery(".chaty-widget-i-title").remove(),jQuery(".chaty-widget").addClass("hide-tooltip-arrow"))),setInterval(function(){},1e4)),jQuery(".chaty-main-widget").addClass("i-trigger-open").addClass("single-button"),jQuery(".chaty-widget-show .i-trigger-open svg").css("transform","rotate(0deg)"),jQuery(".chaty-widget").removeClass("chaty-widget-show")),""!=chaty_settings.object_settings.animation_class&&("sheen"!=chaty_settings.object_settings.animation_class?jQuery(".i-trigger .chaty-widget-i svg").wrap(function(){return"<div class='svg'></div>"}):jQuery(".i-trigger .chaty-widget-i .wrap-svg").length||jQuery(".i-trigger .chaty-widget-i svg").wrap(function(){return"<div class='wrap-svg'></div>"})),r()||("on"==chaty_settings.object_settings.pending_messages&&("sheen"!=chaty_settings.object_settings.animation_class?jQuery(".i-trigger .i-trigger-open .svg, .i-trigger .i-trigger-open.single-button .svg").length?jQuery(".i-trigger .i-trigger-open .svg, .i-trigger .i-trigger-open.single-button .svg").append("<span class='cht-pending-message'>"+chaty_settings.object_settings.number_of_messages+"</span>"):jQuery(".i-trigger .i-trigger-open.single-button svg").length?jQuery(".i-trigger .i-trigger-open.single-button svg").after("<span class='cht-pending-message'>"+chaty_settings.object_settings.number_of_messages+"</span>"):jQuery(".i-trigger .i-trigger-open, .i-trigger .i-trigger-open.single-button svg").after("<span class='cht-pending-message'>"+chaty_settings.object_settings.number_of_messages+"</span>"):jQuery(".i-trigger .i-trigger-open, .i-trigger .i-trigger-open.single-button").after("<span class='cht-pending-message'>"+chaty_settings.object_settings.number_of_messages+"</span>"),jQuery(".cht-pending-message").css("color",chaty_settings.object_settings.number_color),jQuery(".cht-pending-message").css("background",chaty_settings.object_settings.number_bg_color)),jQuery(document).on("click",".i-trigger .i-trigger-open, .i-trigger.one-widget",function(){if(jQuery(".cht-pending-message").remove(),"all_time"!=chaty_settings.object_settings.click_setting&&jQuery(this).hasClass("one-widget")){jQuery(this).addClass("show-channel");var t=jQuery(this).data("title");jQuery(this).find(".chaty-widget-i-title").find("p").html(t)}})),jQuery(document).on("click",".i-trigger.one-widget",function(){if("all_time"!=chaty_settings.object_settings.click_setting&&jQuery(this).hasClass("one-widget")){jQuery(this).addClass("show-channel");var t=jQuery(this).data("title");jQuery(this).find(".chaty-widget-i-title").find("p").html(t)}}),jQuery("chaty-main-widget").mouseenter(function(){jQuery(".i-trigger").hasClass("one-widget")||d()}),1==_)if(h("cta_widget_status"))if("no"==chaty_settings.object_settings.time_trigger&&"no"==chaty_settings.object_settings.exit_intent&&"no"==chaty_settings.object_settings.on_page_scroll)jQuery(".chaty-widget").removeClass("hide-widget"),"open"==chaty_settings.object_settings.display_state&&"no"==chaty_settings.object_settings.has_close_button?chaty_settings.object_settings.has_close_button="no":(chaty_settings.object_settings.display_state="hover",chaty_settings.object_settings.has_close_button="yes"),w();else{if(jQuery(".chaty-widget").addClass("hide-widget"),"yes"==chaty_settings.object_settings.time_trigger&&setTimeout(function(){i||(jQuery(".chaty-widget").removeClass("hide-widget"),w())},1e3*parseInt(chaty_settings.object_settings.trigger_time)),"yes"==chaty_settings.object_settings.exit_intent){a=document,g="mouseout",l=function(t){null==t.toElement&&null==t.relatedTarget&&null==u("cta_exit_intent_shown")&&(y("cta_exit_intent_shown","yes",1),i=!0,jQuery(".chaty-widget").removeClass("hide-widget"),jQuery(".chaty-widget").addClass("chaty-animation-widget"),jQuery(".chaty-animation-widget").append("<div class='chaty-nav'></div>"),"open"==chaty_settings.object_settings.display_state&&"no"==chaty_settings.object_settings.has_close_button?chaty_settings.object_settings.has_close_button="no":(chaty_settings.object_settings.display_state="open",chaty_settings.object_settings.has_close_button="yes"),w(),"left"==chaty_settings.object_settings.position?jQuery(".chaty-widget").addClass("left-position"):"right"==chaty_settings.object_settings.position?jQuery(".chaty-widget").addClass("right-position"):"custom"==chaty_settings.object_settings.position&&("left"==e.object_settings.pos_side?jQuery(".chaty-widget").addClass("left-position"):jQuery(".chaty-widget").addClass("right-position")),p(),setTimeout(function(){jQuery(".chaty-animation-widget").addClass("active")},100),setTimeout(function(){jQuery(".chaty-nav").remove()},2500))},a.addEventListener?a.addEventListener(g,l,!1):a.attachEvent&&a.attachEvent("on"+g,l)}"yes"==chaty_settings.object_settings.on_page_scroll&&parseInt(chaty_settings.object_settings.page_scroll)>0&&jQuery(window).scroll(function(){if(!i){var t=jQuery(document).height()-jQuery(window).height(),e=jQuery(window).scrollTop();0!=e&&e/t*100>=parseInt(chaty_settings.object_settings.page_scroll)&&(jQuery(".chaty-widget").removeClass("hide-widget"),w())}})}else jQuery(".chaty-widget").removeClass("hide-widget"),w();else jQuery(".chaty-widget").addClass("hide-widget");jQuery(".chaty-widget-i-title").length&&jQuery(".chaty-widget-i-title").each(function(){""==jQuery.trim(jQuery(this).text())&&(jQuery(this).closest(".chaty-widget-i").addClass("hide-chaty-arrow"),jQuery(this).remove())}),jQuery(".chaty-widget-i.true.chaty-widget-i-title").length||""==jQuery(".chaty-widget-i-title").text()&&jQuery(".chaty-widget-i").addClass("hide-chaty-arrow"),jQuery(".i-trigger-open .chaty-widget-i-title").length?""==jQuery(".i-trigger-open .chaty-widget-i-title").text()&&jQuery(".i-trigger-open").addClass("hide-chaty-arrow"):jQuery(".i-trigger .i-trigger-open").addClass("hide-chaty-arrow")}),jQuery(".chaty-widget-i-title").each(function(){""==jQuery(this).text()&&(jQuery(this).closest(".chaty-widget-i").addClass("hide-chaty-arrow"),jQuery(this).remove())}),jQuery(".chaty-widget").hasClass("one_widget")||jQuery("body").append("<div class='trigger-chaty-button'></div>"),jQuery("body").addClass(chaty_settings.object_settings.mode+"-cht-menu"),jQuery("body").addClass(chaty_settings.object_settings.position+"-cht-position")})}),jQuery(document).on("click",".trigger-chaty-button",function(){jQuery(".chaty-widget").removeClass("hide-widget"),w(),!jQuery(".chaty-widget").hasClass("none-widget-show")&&jQuery(".chaty-widget").hasClass("chaty-widget-show")||jQuery(".i-trigger-open").trigger("click")}),jQuery(document).on("click",".has-custom-chaty-popup.whatsapp-button",function(t){if(jQuery("#chaty-inline-popup").length){var e=jQuery(this).data("data-index");jQuery("#chaty-widget-"+e).removeClass("chaty-popup-open"),jQuery(".chaty-popup-open").removeClass("chaty-popup-open"),jQuery(".chaty-widget.hide-block").removeClass("active")}if(jQuery(this).hasClass("open-it-by-default")&&t.preventDefault(),jQuery("#chaty-inline-popup").remove(),null!=jQuery(this).attr("data-popup")&&""!=jQuery(this).attr("data-popup")){e="";jQuery(".chaty-widget").addClass("hide-block"),jQuery(".chaty-widget").addClass("chaty-popup-open");var i="<div data-index='"+e+"' id='chaty-inline-popup' class='chaty-inline-popup chaty-popup-form "+jQuery(this).data("channel")+"-channel'>";i+=jQuery(this).attr("data-popup"),jQuery("body").append(i),jQuery(".chaty-inline-popup .default-value").length&&(thisHref=jQuery(".chaty-inline-popup .default-value").text(),thisHref=decodeURI(thisHref),thisHref=thisHref.replace(/{title}/g,jQuery("title").text()),thisHref=thisHref.replace(/{url}/g,window.location.href),jQuery(".chaty-whatsapp-msg").val(jQuery(".chaty-inline-popup .default-value").text()),jQuery(".chaty-whatsapp-phone").val(jQuery(".chaty-inline-popup .default-msg-phone").text()),chatyHtml=jQuery(".chaty-inline-popup .default-msg-value").html(),chatyHtml=chatyHtml.replace(/{title}/g,jQuery("title").text()),chatyHtml=chatyHtml.replace(/{url}/g,window.location.href),jQuery(".chaty-whatsapp-message").html(chatyHtml)),jQuery(".chaty-widget").addClass("active"),setTimeout(function(){jQuery("#chaty-inline-popup").addClass("active")},150),jQuery("body").hasClass("chaty-in-mobile")||jQuery(".chaty-whatsapp-msg").focus()}a&&jQuery(".whatsapp-chaty-form").prop("target","")}),jQuery(document).on("click",".close-chaty-popup, .close-chaty-box",function(){jQuery(this).hasClass("is-whatsapp-btn")&&l("cht_whatsapp_window"),jQuery("#chaty-inline-popup").removeClass("active"),jQuery(".chaty-widget").removeClass("chaty-popup-open"),setTimeout(function(){jQuery(".chaty-widget.hide-block").removeClass("active")},250)}),jQuery(document).on("submit",".whatsapp-chaty-form",function(t){if(l("cht_whatsapp_window"),jQuery("#chaty-inline-popup").removeClass("active"),jQuery(".chaty-widget").removeClass("chaty-popup-open"),setTimeout(function(){jQuery(".chaty-widget.hide-block").removeClass("active")},250),jQuery("body").hasClass("chaty-in-mobile"))return t.preventDefault(),window.location="https://wa.me/"+jQuery(this).find(".chaty-whatsapp-phone").val()+"?text="+jQuery(this).find(".chaty-whatsapp-msg").val(),!1}),jQuery(document).on("submit",".chaty-contact-form-data",function(t){var e=0;if(jQuery(".has-chaty-error").removeClass("has-chaty-error"),jQuery(".chaty-error-msg").remove(),jQuery(".chaty-ajax-error-message").remove(),jQuery(".chaty-ajax-success-message").remove(),jQuery(this).find(".is-required").each(function(){""==jQuery.trim(jQuery(this).val())&&(e++,jQuery(this).addClass("has-chaty-error"))}),0==e){var i=jQuery(this);jQuery(".chaty-contact-submit-btn").attr("disabled",!0),jQuery.ajax({url:chaty_settings.ajax_url,data:{action:"chaty_front_form_save_data",name:i.find(".chaty-field-name").length?i.find(".chaty-field-name").val():"",email:i.find(".chaty-field-email").length?i.find(".chaty-field-email").val():"",phone:i.find(".chaty-field-phone").length?i.find(".chaty-field-phone").val():"",message:i.find(".chaty-field-message").length?i.find(".chaty-field-message").val():"",nonce:i.find(".chaty-field-nonce").length?i.find(".chaty-field-nonce").val():"",channel:i.find(".chaty-field-channel").length?i.find(".chaty-field-channel").val():"",widget:i.find(".chaty-field-widget").length?i.find(".chaty-field-widget").val():"",ref_url:window.location.href},type:"post",async:!0,defer:!0,success:function(t){if(t=jQuery.parseJSON(t),jQuery(".chaty-ajax-error-message").remove(),jQuery(".chaty-ajax-success-message").remove(),jQuery(".chaty-contact-submit-btn").attr("disabled",!1),1==t.status)jQuery(".chaty-contact-footer").append("<div class='chaty-ajax-success-message'>"+t.message+"</div>"),jQuery(".chaty-field-name, .chaty-field-email, .chaty-field-message").val(""),"yes"==t.redirect_action&&("yes"==t.link_in_new_tab?window.open(t.redirect_link,"_blank"):window.location=t.redirect_link),"yes"==t.close_form_after&&setTimeout(function(){jQuery("#chaty-inline-popup").removeClass("active"),jQuery(".chaty-widget").removeClass("chaty-popup-open"),setTimeout(function(){jQuery(".chaty-widget.hide-block").removeClass("active")},250)},1e3*parseInt(t.close_form_after_seconds));else if(1==t.error){if(t.errors.length)for(var e=0;e<t.errors.length;e++)jQuery("."+t.errors[e].field).addClass("has-chaty-error"),jQuery("."+t.errors[e].field).after("<span class='chaty-error-msg'>"+t.errors[e].message+"</span>")}else jQuery(".chaty-contact-footer").append("<div class='chaty-ajax-error-message'>"+t.message+"</div>")}})}else jQuery(".has-chaty-error:first").focus();return!1})}(jQuery)},12:function(t,e){}});
|
1 |
+
function launch_chaty(){jQuery(".chaty-widget").hasClass("one_widget")||jQuery(".trigger-chaty-button").trigger("click")}function close_chaty(){jQuery("#chaty-inline-popup").hasClass("active")&&jQuery("#chaty-inline-popup .close-chaty-popup").trigger("click"),jQuery(".chaty-widget.chaty-widget-show").length&&jQuery(".chaty-widget.chaty-widget-show").each(function(){jQuery(this).find(".chaty-close-settings").length&&jQuery(this).find(".chaty-close-settings").trigger("click")})}!function(t){var e={};function i(s){if(e[s])return e[s].exports;var a=e[s]={i:s,l:!1,exports:{}};return t[s].call(a.exports,a,a.exports,i),a.l=!0,a.exports}i.m=t,i.c=e,i.d=function(t,e,s){i.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:s})},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="/",i(i.s=10)}({10:function(t,e,i){i(11),t.exports=i(12)},11:function(t,e){!function(t){var e,i=0,s=".i-trigger .chaty-widget-i .svg, .i-trigger .chaty-widget-i .widget-img, .i-trigger .chaty-widget-i .facustom-icon",a=!1;function c(t){return r()&&"click"==chaty_settings.object_settings.click_setting?"none":""}(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(navigator.userAgent.substr(0,4)))&&(a=!0);new Date;function n(){jQuery(".chaty-widget").hasClass("one_widget")&&jQuery(".chaty-widget").removeClass("chaty-widget-show")}function o(t){var e="@-webkit-keyframes chaty-animation-shockwave { 0% { transform: scale(1); box-shadow: 0 0 2px rgba("+t+", 0.30), inset 0 0 1px rgba("+t+", 0.30); } 95% { box-shadow: 0 0 50px rgba("+t+", 0), inset 0 0 30px rgba("+t+", 0); } 100% { transform: scale(2.25); } } @keyframes chaty-animation-shockwave { 0% { transform: scale(1); box-shadow: 0 0 2px rgba("+t+", 0.30), inset 0 0 1px rgba("+t+", 0.30); } 95% { box-shadow: 0 0 50px rgba("+t+", 0), inset 0 0 30px rgba("+t+", 0); } 100% { transform: scale(2.25); } }";jQuery("#chaty-advance-css").length||jQuery("body").append("<div id='chaty-advance-css'></div>"),jQuery("#chaty-advance-css").append("<style>"+e+"</style>")}function r(){var t=g("cta");if(null!=t&&""!=t){t=new Date(t);var e=Math.abs(new Date-t);return Math.floor(e/6e4)<=10}return!1}function g(t){var e=u("chaty_settings"),i=[];if(null!=e&&""!=e&&(i=JSON.parse(e)),i.length>0)for(var s=0;s<i.length;s++)if(i[s].k==t)return i[s].v;return null}function l(t){var e=u("chaty_settings"),i=[];null!=e&&""!=e&&(i=JSON.parse(e));var s=!1;if(i.length>0)for(var a=0;a<i.length;a++)i[a].k==t&&(s=!0,i[a].v=new Date);s||i.push({k:t,v:new Date}),y("chaty_settings",e=JSON.stringify(i),"7")}function h(t){var e=g(t);if(null!=e&&""!=e){e=new Date(e);var i=Math.abs(new Date-e);return Math.floor(i/864e5)>=1}return!0}function d(){var t=u("chaty_settings"),e=[];null!=t&&""!=t&&(e=JSON.parse(t));var i=!1;if(e.length>0)for(var s=0;s<e.length;s++)"cta"==e[s].k&&(i=!0,e[s].v=new Date);i||e.push({k:"cta",v:new Date}),y("chaty_settings",t=JSON.stringify(e),"7")}function y(t,e,i){var s="";if(i){var a=new Date;a.setTime(a.getTime()+24*i*60*60*1e3),s="; expires="+a.toUTCString()}document.cookie=t+"="+(e||"")+s+"; path=/"}function u(t){for(var e=t+"=",i=document.cookie.split(";"),s=0;s<i.length;s++){for(var a=i[s];" "==a.charAt(0);)a=a.substring(1,a.length);if(0==a.indexOf(e))return a.substring(e.length,a.length)}return null}function w(){l("cta_widget_status"),i=1;var t=0;t=jQuery("body").hasClass("chaty-in-desktop")?jQuery(".chaty-widget-is .chaty-widget-i.is-in-desktop").length:jQuery(".chaty-widget-is .chaty-widget-i.is-in-mobile").length,h("chaty-animation")||(chaty_settings.object_settings.animation_class=""),""!=chaty_settings.object_settings.animation_class&&("sheen"!=chaty_settings.object_settings.animation_class?t>1?jQuery(s).addClass("chaty-animation-"+chaty_settings.object_settings.animation_class).addClass("start-now"):1==t&&(s=".chaty-main-widget .svg, .chaty-main-widget img, .chaty-main-widget .facustom-icon",jQuery(s).removeClass("chaty-animation-"+chaty_settings.object_settings.animation_class).removeClass("start-now"),jQuery(s).addClass("chaty-animation-"+chaty_settings.object_settings.animation_class).addClass("start-now")):(s=".i-trigger .chaty-widget-i .wrap-svg",jQuery(".i-trigger .chaty-widget-i .wrap-svg").length,jQuery(s).removeClass("chaty-animation-sheen").removeClass("start-now"),jQuery(s).addClass("chaty-animation-sheen").addClass("start-now"))),"open"==chaty_settings.object_settings.display_state&&("no"==chaty_settings.object_settings.has_close_button?t>1&&(p(),jQuery(".chaty-widget").find(".i-trigger-open").removeClass("active_clos"),jQuery(".chaty-widget").find(".i-trigger-open").trigger("click"),jQuery(".chaty-widget-is").addClass("has-no-close-btn"),jQuery(".i-trigger").remove()):t>1&&(p(),jQuery(".chaty-widget").find(".i-trigger-open").removeClass("active_clos"),jQuery(".chaty-widget").find(".i-trigger-open").trigger("click"))),jQuery(".chaty-widget").hasClass("one_widget")&&jQuery(".chaty-widget").removeClass("chaty-widget-show")}function p(){l("chaty-animation"),jQuery(".chaty-animation-"+chaty_settings.object_settings.animation_class).removeClass("chaty-animation-"+chaty_settings.object_settings.animation_class).removeClass("start-now"),jQuery(".start-now").removeClass("start-now"),chaty_settings.object_settings.animation_class=""}jQuery(document).ready(function(){a?jQuery("body").addClass("chaty-in-mobile"):jQuery("body").addClass("chaty-in-desktop"),c(),token="",jQuery(document).ready(function(){"true"==(e=chaty_settings).object_settings.active&&function(e,i){var s=e.object_settings.device,a="";if("right"==e.object_settings.position)a="left: auto;bottom: 25px; right: 25px;";else if("left"==e.object_settings.position)a="right: auto; bottom: 25px; left: 25px;";else if("custom"==e.object_settings.position){var n=e.object_settings.pos_side,o=e.object_settings.bot,r=e.object_settings.side;a="right"===n?"left: auto; bottom: "+o+"px; right: "+r+"px":"left: "+r+"px; bottom: "+o+"px; right: auto"}var g=e.object_settings.cta,l="",d=e.object_settings.social;if(Object.keys(d).length>=1&&(l='<div class="chaty-widget hide-widget '+i+" "+s+' " style="display:block; '+a+'" dir="ltr">',l+='<div class="chaty-widget-is" id="transition_disabled">'),l+=function(e){var i="",s=0;return t.each(e.object_settings.social,function(t,a){if(e.object_settings.isPRO&&jQuery("body").addClass("has-pro-version"),!e.object_settings.isPRO&&"3"==++s)return!1;extra_class="","1"!=e.object_settings.analytics&&1!=e.object_settings.analytics||(extra_class+=" update-analytics ");var c=1==e.object_settings.social[t].is_desktop?"is-in-desktop":"",n=1==e.object_settings.social[t].is_mobile?"is-in-mobile":"",o=1==e.object_settings.is_mobile?e.object_settings.social[t].mobile_target:e.object_settings.social[t].desktop_target;if(jQuery("body").hasClass("chaty-in-mobile")&&(e.object_settings.social[t].href_url=e.object_settings.social[t].mobile_url),"viber"==e.object_settings.social[t].social_channel){if(jQuery("body").hasClass("chaty-in-mobile")){var r=e.object_settings.social[t].href_url;isNaN(r)||(r=r.replace("+",""),navigator.userAgent.match(/(iPod|iPhone|iPad)/)&&(r="+"+r)),e.object_settings.social[t].href_url=r}e.object_settings.social[t].href_url="viber://chat?number="+e.object_settings.social[t].href_url}1==parseInt(e.object_settings.social[t].has_custom_popup)&&("whatsapp"==e.object_settings.social[t].channel_type?(e.object_settings.social[t].is_default_open&&h("cht_whatsapp_window")&&(extra_class+=" open-it-by-default"),o="",e.object_settings.social[t].mobile_target="",e.object_settings.social[t].desktop_target="",extra_class+=" has-custom-chaty-popup whatsapp-button"):"contact_us"==e.object_settings.social[t].channel_type&&(extra_class+=" has-custom-chaty-popup whatsapp-button"));var g="";""!=e.object_settings.social[t].on_click&&(g=' onclick="'+e.object_settings.social[t].on_click+'"'),socialString='<div data-popup="'+e.object_settings.social[t].popup_html+'" data-rgb="'+e.object_settings.social[t].rbg_color+'" class="chaty-widget-i chaty-main-widget '+c+" "+n+" "+extra_class+" channel-"+e.object_settings.social[t].social_channel+'" data-title="'+e.object_settings.social[t].val+'" id="chaty-channel-'+e.object_settings.social[t].social_channel+'" data-channel="'+e.object_settings.social[t].social_channel+'" data-code="'+e.object_settings.social[t].qr_code_image+'">',bgColor="",""!=e.object_settings.social[t].bg_color&&(socialString+="<style>#chaty-channel-"+e.object_settings.social[t].social_channel+" .color-element {fill: "+e.object_settings.social[t].bg_color+"; background: "+e.object_settings.social[t].bg_color+"}</style>",bgColor="style='background-color: "+e.object_settings.social[t].bg_color+";'"),socialString+="<a class='set-url-target' "+g+" rel='noopener' data-mobile-target='"+e.object_settings.social[t].mobile_target+"' data-desktop-target='"+e.object_settings.social[t].desktop_target+"' target='"+o+"' href='"+e.object_settings.social[t].href_url+"' >",socialString+="<span class='sr-only'>"+e.object_settings.social[t].title+"</span>",""!=e.object_settings.social[t].img_url?socialString+="<span "+bgColor+" class='chaty-social-img'><img src='"+e.object_settings.social[t].img_url+"' alt='"+e.object_settings.social[t].title+"' /></span>":socialString+=e.object_settings.social[t].default_icon,socialString+="</a>",socialString+="<div class='chaty-widget-i-title'><p>"+e.object_settings.social[t].title+"</p></div>",socialString+="</div>",i+=socialString}),i}(e),d=e.object_settings.social,Object.keys(d).length>=1){l+="</div>",l+='<div class="i-trigger">';var y=c(),u=current_url=window.location.origin;if(u=(u=u.replace("https://","")).replace("http://",""),""!=g&&"none"!=y);else"no-tooltip";"click"!=chaty_settings.object_settings.click_setting&&!0,l+='<div class="chaty-widget-i chaty-close-settings i-trigger-open '+!0+' ">',l+=function(t){switch(t.object_settings.widget_type){case"chat-image":if(t.object_settings.widget_img.length>1)return'<div class="widget-img" style="background-color:'+t.object_settings.color+'"><img src="'+t.object_settings.widget_img+'"/></div>';case"chat-smile":return'<svg version="1.1" id="smile" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="-496.8 507.1 54 54" style="enable-background:new -496.8 507.1 54 54;" xml:space="preserve"><style type="text/css">.sts1{fill:#FFFFFF;} .sts2{fill:none;stroke:#808080;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round;}</style><g><circle cx="-469.8" cy="534.1" r="27" fill="'+t.object_settings.color+'"/></g><path class="sts1" d="M-459.5,523.5H-482c-2.1,0-3.7,1.7-3.7,3.7v13.1c0,2.1,1.7,3.7,3.7,3.7h19.3l5.4,5.4c0.2,0.2,0.4,0.2,0.7,0.2c0.2,0,0.2,0,0.4,0c0.4-0.2,0.6-0.6,0.6-0.9v-21.5C-455.8,525.2-457.5,523.5-459.5,523.5z"/><path class="sts2" d="M-476.5,537.3c2.5,1.1,8.5,2.1,13-2.7"/><path class="sts2" d="M-460.8,534.5c-0.1-1.2-0.8-3.4-3.3-2.8"/></svg>';case"chat-bubble":return'<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="-496.9 507.1 54 54" style="enable-background:new -496.9 507.1 54 54;" xml:space="preserve"><style type="text/css">.sts1{fill:#FFFFFF;}</style><g><circle cx="-469.9" cy="534.1" r="27" fill="'+t.object_settings.color+'"/></g><path class="sts1" d="M-472.6,522.1h5.3c3,0,6,1.2,8.1,3.4c2.1,2.1,3.4,5.1,3.4,8.1c0,6-4.6,11-10.6,11.5v4.4c0,0.4-0.2,0.7-0.5,0.9 c-0.2,0-0.2,0-0.4,0c-0.2,0-0.5-0.2-0.7-0.4l-4.6-5c-3,0-6-1.2-8.1-3.4s-3.4-5.1-3.4-8.1C-484.1,527.2-478.9,522.1-472.6,522.1z M-462.9,535.3c1.1,0,1.8-0.7,1.8-1.8c0-1.1-0.7-1.8-1.8-1.8c-1.1,0-1.8,0.7-1.8,1.8C-464.6,534.6-463.9,535.3-462.9,535.3z M-469.9,535.3c1.1,0,1.8-0.7,1.8-1.8c0-1.1-0.7-1.8-1.8-1.8c-1.1,0-1.8,0.7-1.8,1.8C-471.7,534.6-471,535.3-469.9,535.3z M-477,535.3c1.1,0,1.8-0.7,1.8-1.8c0-1.1-0.7-1.8-1.8-1.8c-1.1,0-1.8,0.7-1.8,1.8C-478.8,534.6-478.1,535.3-477,535.3z"/></svg>';case"chat-db":return'<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="-496 507.1 54 54" style="enable-background:new -496 507.1 54 54;" xml:space="preserve"><style type="text/css">.sts1{fill:#FFFFFF;}</style><g><circle cx="-469" cy="534.1" r="27" fill="'+t.object_settings.color+'"/></g><path class="sts1" d="M-464.6,527.7h-15.6c-1.9,0-3.5,1.6-3.5,3.5v10.4c0,1.9,1.6,3.5,3.5,3.5h12.6l5,5c0.2,0.2,0.3,0.2,0.7,0.2c0.2,0,0.2,0,0.3,0c0.3-0.2,0.5-0.5,0.5-0.9v-18.2C-461.1,529.3-462.7,527.7-464.6,527.7z"/><path class="sts1" d="M-459.4,522.5H-475c-1.9,0-3.5,1.6-3.5,3.5h13.9c2.9,0,5.2,2.3,5.2,5.2v11.6l1.9,1.9c0.2,0.2,0.3,0.2,0.7,0.2c0.2,0,0.2,0,0.3,0c0.3-0.2,0.5-0.5,0.5-0.9v-18C-455.9,524.1-457.5,522.5-459.4,522.5z"/></svg>';default:return'<svg version="1.1" id="ch" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="-496 507.7 54 54" style="enable-background:new -496 507.7 54 54;" xml:space="preserve"><style type="text/css">.sts1 {fill: #FFFFFF;}.st0{fill: #808080;}</style><g><circle cx="-469" cy="534.7" r="27" fill="'+t.object_settings.color+'"/></g><path class="sts1" d="M-459.9,523.7h-20.3c-1.9,0-3.4,1.5-3.4,3.4v15.3c0,1.9,1.5,3.4,3.4,3.4h11.4l5.9,4.9c0.2,0.2,0.3,0.2,0.5,0.2 h0.3c0.3-0.2,0.5-0.5,0.5-0.8v-4.2h1.7c1.9,0,3.4-1.5,3.4-3.4v-15.3C-456.5,525.2-458,523.7-459.9,523.7z"/><path class="st0" d="M-477.7,530.5h11.9c0.5,0,0.8,0.4,0.8,0.8l0,0c0,0.5-0.4,0.8-0.8,0.8h-11.9c-0.5,0-0.8-0.4-0.8-0.8l0,0C-478.6,530.8-478.2,530.5-477.7,530.5z"/><path class="st0" d="M-477.7,533.5h7.9c0.5,0,0.8,0.4,0.8,0.8l0,0c0,0.5-0.4,0.8-0.8,0.8h-7.9c-0.5,0-0.8-0.4-0.8-0.8l0,0C-478.6,533.9-478.2,533.5-477.7,533.5z"/></svg>'}}(e),y=c(),""!=g&&"none"!=y&&(l+=' <div class="chaty-widget-i-title true"> ',l+=g,l+="</div>"),l+="</div>",l+='<div class="chaty-widget-i chaty-close-settings i-trigger-close" data-title="'+e.object_settings.close_text+'" style="background-color:'+e.object_settings.color+'">',""==e.object_settings.close_img?(l+='<svg viewBox="0 0 54 54" fill="none" xmlns="http://www.w3.org/2000/svg">',l+='<ellipse cx="26" cy="26" rx="26" ry="26" fill="'+e.object_settings.color+'"/>',l+='<rect width="27.1433" height="3.89857" rx="1.94928" transform="translate(18.35 15.6599) scale(0.998038 1.00196) rotate(45)" fill="white"/>',l+='<rect width="27.1433" height="3.89857" rx="1.94928" transform="translate(37.5056 18.422) scale(0.998038 1.00196) rotate(135)" fill="white"/>',l+="</svg>"):l+="<span class='chaty-social-img'><img alt='"+e.object_settings.close_text+"' src='"+e.object_settings.close_img+"' /></span>",l+='<div class="chaty-widget-i-title">',l+=e.object_settings.close_text,l+="</div>",l+="</div>",l+=" </div>",0===i.length&&!e.object_settings.isPRO&&(l+=""),l+="</div>"}t("body").append(l)}(e,token),function(){var i=t(".chaty-widget"),s=e.object_settings.widget_size?e.object_settings.widget_size:54,a=+e.object_settings.widget_size+8;function o(){i.position().top;var t=i.find(".chaty-widget-is .chaty-widget-i").length;if((t=jQuery("body").hasClass("chaty-in-desktop")?i.find(".chaty-widget-is .chaty-widget-i.is-in-desktop").length:i.find(".chaty-widget-is .chaty-widget-i.is-in-mobile").length)*a>jQuery(window).height()-(chaty_settings.object_settings.widget_size+8)){var e=Math.round(Math.sqrt(t)),s=Math.ceil(Math.sqrt(t));i.find(".chaty-widget-is").css({height:s*a,width:e*a}),g(s),i.find("span:not(.cht-pending-message)").css({height:s*a,width:e*a}),g(s),i.find("img").css({height:s*a,width:e*a}),g(s)}else g()}function r(){"left"===e.object_settings.position&&i.addClass("chaty-widget-is-right"),"custom"===e.object_settings.position&&"left"===e.object_settings.pos_side&&i.addClass("chaty-widget-is-right")}function g(t){var e;e=jQuery("body").hasClass("chaty-in-desktop")?i.find(".chaty-widget-is .chaty-widget-i.is-in-desktop").length:i.find(".chaty-widget-is .chaty-widget-i.is-in-mobile").length,i.find(".chaty-widget-i").css({height:s+"px",width:s+"px"}),i.find("img").css({height:s+"px",width:s+"px"}),i.find("span:not(.cht-pending-message)").css({height:s+"px",width:s+"px"}),i.find(".chaty-widget-is").css({top:"-"+100*e+"%"}),i.find(".chaty-widget-is").height(e*(parseInt(s)+8)),i.find(".chaty-widget-is").width(parseInt(s)+8),"horizontal"==chaty_settings.object_settings.mode?(i.find(".chaty-widget-is").css({top:"0"}),i.find(".chaty-widget-is").width(e*(parseInt(s)+8)),i.find(".chaty-widget-is").height(parseInt(s)+8)):(i.find(".chaty-widget-is").height(e*(parseInt(s)+8)),i.find(".chaty-widget-is").width(parseInt(s)+8))}jQuery(".open-it-by-default").length&&jQuery(".open-it-by-default").trigger("click"),r(),o(),jQuery(window).resize(function(){o(),1==Object.keys(e.object_settings.social).length&&(jQuery(".chaty-widget").addClass("chaty-widget-show"),jQuery(".chaty-widget-is").css("top","auto")),jQuery(".chaty-widget").hasClass("one_widget")&&jQuery(".chaty-widget").removeClass("chaty-widget-show")}),t(".chaty-widget-i.facebook").mouseenter(function(){t(".facebook_two_mess").css({opacity:"1","z-index":"1"}),t(this).addClass("before")}),t(".chaty-widget-i.facebook").mouseleave(function(){t(".facebook_two_mess").css({opacity:"0","z-index":"1"}),t(this).removeClass("before")}),t(".chaty-widget-i.facebook").on("click",function(){t(this).addClass("active"),t(".facebook_two_mess").hide(),jQuery(".chaty-widget .get a").hide(),t(this).children(".face_title").css({opacity:"1","z-index":"2"}).show(),t(".chaty-widget").hasClass("one_widget")?t(".chaty-widget").hasClass("chaty-widget-is-right")?t(".face_title").css({top:"calc(100% - 447px)",left:"20px"}):t(".face_title").css({top:"calc(100% - 447px)",left:"auto",right:"20px"}):(t(".facebook_two_mess").css({opacity:"0","z-index":"10001"}),t(".ico_d").hide(),t(".chaty-widget .chaty-widget-i").css({"box-shadow":"0px 3px 6px rgba(0,0,0,0)"}),t(".chaty-widget").hasClass("one_widget")||t(".i-trigger").hide())}),t(".i-trigger-close").on("click",function(e){e.preventDefault(),t(".chaty-widget-i.facebook").hasClass("active")||(i.removeClass("chaty-widget-show"),i.addClass("none-widget-show"))}),t("body").on("click",".close_facebook",function(){t(".facebook_two_mess").show(),jQuery(".chaty-widget .get a").show(),t(".chaty-widget-i.facebook").removeClass("active"),t(this).parent().parent().css({opacity:"1"}).hide(),t(".i-trigger").show(),t(".chaty-widget-is .chaty-widget-i svg").show()}),t(".i-trigger-close").on("click",function(e){t(".i-trigger-open").addClass("active_clos"),e.preventDefault(),t(".chaty-widget-i.facebook").hasClass("active")||(i.removeClass("chaty-widget-show"),i.addClass("none-widget-show"))}),t("body").on("click",".update-analytics",function(t){if(channelName=jQuery(this).attr("data-channel"),null!=channelName&&""!=channelName)if(window.hasOwnProperty("gtag"))gtag("event","chaty_"+channelName,{eventCategory:"chaty_"+channelName,event_action:"chaty_"+channelName});else if(window.hasOwnProperty("ga")){var e=window.ga.getAll()[0];e&&e.send("event","click",{eventCategory:"chaty_"+channelName,eventAction:"chaty_"+channelName})}}),t("body").on("click",".wechat",function(){var t=jQuery(".chaty-widget .chaty-widget-i.wechat").attr("data-code");null!=t&&""!=t&&(jQuery("#wechat-qr-code").length||(htmlString="<div id='wechat-qr-code' class='wechat-qr-code'>",htmlString+='<div class="wechat-box-head">WeChat<svg xmlns="http://www.w3.org/2000/svg" class="close_facebook" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Capa_1" x="0px" y="0px" width="612px" height="612px" viewBox="0 0 612 612" style="fill: #fff; float: right; margin-top: 4px;" xml:space="preserve"><path xmlns="http://www.w3.org/2000/svg" d="M268.064,256.75l138.593-138.593c3.124-3.124,3.124-8.189,0-11.313c-3.125-3.124-8.189-3.124-11.314,0L256.75,245.436 L118.157,106.843c-3.124-3.124-8.189-3.124-11.313,0c-3.125,3.124-3.125,8.189,0,11.313L245.436,256.75L106.843,395.343 c-3.125,3.125-3.125,8.189,0,11.314c1.562,1.562,3.609,2.343,5.657,2.343s4.095-0.781,5.657-2.343L256.75,268.064l138.593,138.593 c1.563,1.562,3.609,2.343,5.657,2.343s4.095-0.781,5.657-2.343c3.124-3.125,3.124-8.189,0-11.314L268.064,256.75z"></path></svg></div>',htmlString+="<div class='wechat-box'><img src='"+t+"' alt='QR Code' /><a href='javascript:;'>",htmlString+="</a></div></div>",jQuery("body").append(htmlString)),jQuery("#wechat-qr-code").show())});var l=c();"hover"==chaty_settings.object_settings.display_state?i.find(".i-trigger-open").mouseenter(function(e){e.stopPropagation(),n(),t(".chaty-widget-is").removeAttr("id"),t(this).hasClass("active_clos")||t(".chaty-widget-i.facebook").hasClass("active")||i.hasClass("one_widget")||(r(),t(i).hasClass("chaty-widget-show")||(i.addClass("chaty-widget-show"),i.removeClass("none-widget-show"))),jQuery(".chaty-widget").hasClass("one_widget")&&jQuery(".chaty-widget").removeClass("chaty-widget-show"),"click"==chaty_settings.object_settings.click_setting&&(jQuery(".i-trigger").hasClass("one-widget")||(jQuery(this).closest(".chaty-widget-i").addClass("hide-chaty-arrow"),jQuery("body .chaty-widget-i-title.true").remove()))}):i.find(".i-trigger-open").click(function(e){e.stopPropagation(),p(),n(),t(".chaty-widget-is").removeAttr("id"),t(this).hasClass("active_clos")||t(".chaty-widget-i.facebook").hasClass("active")||i.hasClass("one_widget")||(r(),t(i).hasClass("chaty-widget-show")||(i.addClass("chaty-widget-show"),i.removeClass("none-widget-show"))),n(),"click"==chaty_settings.object_settings.click_setting&&(jQuery(".i-trigger").hasClass("one-widget")||(jQuery(this).closest(".chaty-widget-i").addClass("hide-chaty-arrow"),jQuery("body .chaty-widget-i-title.true").remove())),jQuery(".cht-pending-message").remove()}),t(".one_widget").on("click",function(){p(),jQuery(".cht-pending-message").remove()}),i.find(".i-trigger-open").on("click",function(){jQuery(".cht-pending-message").remove(),"none"!=l&&(t(".chaty-widget").hasClass(".one_widget")||t(".i-trigger-open .chaty-widget-i-title1").detach()),"click"==chaty_settings.object_settings.click_setting&&t(".i-trigger-open").addClass("no-tooltip"),t(this).hasClass("active_clos")||t(".chaty-widget-i.facebook").hasClass("active")||i.hasClass("one_widget")||(r(),t(i).hasClass("chaty-widget-show")||(i.addClass("chaty-widget-show"),i.removeClass("none-widget-show"))),p()}),i.find(".i-trigger-open").mouseenter(function(){"click"==chaty_settings.object_settings.click_setting&&t(this).addClass("no-tooltip"),t(".i-trigger-open").removeClass("active_clos"),o()}),i.find(".chaty-widget-is").mouseleave(function(){t(".i-trigger-open").removeClass("active_clos"),t(".chaty-widget-i.facebook").hasClass("active")}),1===Object.keys(e.object_settings.social).length&&i.find(".i-trigger-open").on("touchstart",function(e){"use strict";t(this).find(".chaty-widget-i").toggleClass("hover")}),1==Object.keys(e.object_settings.social).length&&(jQuery(".chaty-widget").addClass("chaty-widget-show"),jQuery(".chaty-widget-is").css("top","auto"),jQuery(".chaty-widget-is").css("z-index","10001"),jQuery(".chaty-widget-i.i-trigger-close, .i-trigger.chaty-widget-i").remove(),jQuery(".chaty-widget .get a").css("top","-10px"),jQuery(".chaty-widget").addClass("one_widget"),jQuery(document).on("click",".chaty-widget-i",function(){jQuery(".i-trigger").hasClass("one-widget")||(jQuery(".chaty-widget-i:first .chaty-widget-i-title:last").hide(),jQuery("body").addClass("hide-cht-widget"))}),jQuery("body").append("<style>.chaty-widget-is{top:0!important;}</style>"))}(),t(document).ready(function(){1!==Object.keys(e.object_settings.social).length||!e.object_settings.social.snapchat&&!e.object_settings.social.wechat||e.object_settings.cta||(t(".chaty-widget-i-1title").detach(),t(".chaty-widget-i").addClass("bofore_del")),t(".chaty-widget-i-title").hasClass("one_go")&&(t(".chaty-widget-i-title p").html(t(".chaty-widget-i-title.one_go").html()),"none"==c()&&(t(".chaty-widget-i-title").hasClass("face_title")?(t(".facebook_two_mess").detach(),t(".chaty-widget-i").addClass("bofore_del")):(t(".chaty-widget-i-title11").detach(),t(".chaty-widget-i").addClass("bofore_del")))),window.matchMedia("only screen and (max-width: 760px)").matches&&t(".i-trigger-open").addClass("active_clos"),jQuery(".chaty-widget-i-title").each(function(){""==jQuery(this).text()&&jQuery(this).remove()})}),t(document).ready(function(){var s=0;0==(s=jQuery("body").hasClass("chaty-in-desktop")?jQuery(".chaty-widget-is .chaty-widget-i.is-in-desktop").length:jQuery(".chaty-widget-is .chaty-widget-i.is-in-mobile").length)?jQuery(".chaty-widget").addClass("hide-widget").removeClass("desktop_active").removeClass("mobile_active"):(jQuery("body").hasClass("chaty-in-desktop")?jQuery(".chaty-widget").removeClass("hide-widget").addClass("desktop_active"):jQuery(".chaty-widget").removeClass("hide-widget").addClass("mobile_active"),1==s?(jQuery(".chaty-close-settings").hide(),jQuery("body").hasClass("chaty-in-desktop")?(htmlToAdd=jQuery(".chaty-widget-is .chaty-widget-i.is-in-desktop:first").clone(),jQuery(".i-trigger").html(htmlToAdd)):(htmlToAdd=jQuery(".chaty-widget-is .chaty-widget-i.is-in-mobile:first").clone(),jQuery(".i-trigger").html(htmlToAdd)),r()?"all_time"!=chaty_settings.object_settings.click_setting?(jQuery(".i-trigger").addClass("show-channel"),jQuery(".i-trigger").attr("data-title",jQuery(".chaty-widget-is .chaty-widget-i-title p").html())):jQuery(".i-trigger .chaty-widget-i-title p").html(chaty_settings.object_settings.cta):"all_time"!=chaty_settings.object_settings.click_setting&&(jQuery(".i-trigger").attr("data-title",jQuery(".chaty-widget-is .chaty-widget-i-title p").html()),jQuery(".i-trigger .chaty-widget-i-title p").html(chaty_settings.object_settings.cta)),jQuery(".chaty-widget").addClass("one_widget"),jQuery(".chaty-widget.one_widget, .i-trigger, .chaty-widget-i").mouseenter(function(){n(),"click"==chaty_settings.object_settings.click_setting&&(jQuery(".i-trigger").hasClass("one-widget")||(jQuery(".chaty-widget-i-title").remove(),jQuery(".chaty-widget").addClass("hide-tooltip-arrow")),jQuery(".chaty-widget").removeClass("chaty-widget-show")),jQuery(".i-trigger").hasClass("one-widget")||d()}),jQuery(".chaty-widget").removeClass("chaty-widget-show"),jQuery(".i-trigger").addClass("one-widget"),r(),o(jQuery(".i-trigger .chaty-widget-i:first").data("rgb"))):(jQuery(".chaty-widget").removeClass("one_widget"),"click"==chaty_settings.object_settings.click_setting&&jQuery(".i-trigger .chaty-main-widget").remove(),jQuery(".chaty-close-settings").show(),jQuery(".chaty-widget-i-title").removeClass("hide-it"),jQuery(".chaty-widget.one_widget, .i-trigger, .chaty-widget-i").mouseenter(function(){n(),jQuery(".i-trigger").hasClass("one-widget")||(d(),jQuery(".i-trigger").hasClass("one-widget")||jQuery(".i-trigger .chaty-widget-i-title").addClass("hide-it")),p()}),"open"==chaty_settings.object_settings.display_state&&t(".i-trigger-open").addClass("no-tooltip"),o(chaty_settings.object_settings.rgb_color))),jQuery(document).on("click",".i-trigger.one-widget",function(){d()});var a,g,l,_=0;if(1==parseInt(chaty_settings.object_settings.display_conditions)){var j=chaty_settings.object_settings.display_rules;if(j.length>0){var m=new Date;m.setHours(m.getHours()+chaty_settings.object_settings.gmt);for(var b=m.getUTCHours(),f=m.getUTCMinutes(),v=m.getUTCDay(),Q=0;Q<j.length;Q++){var C=0,k=0;-1==j[Q].days?k=1:j[Q].days>=0&&j[Q].days<=6?j[Q].days==v&&(k=1):7==j[Q].days?v>=0&&v<=4&&(k=1):8==j[Q].days?v>=1&&v<=5&&(k=1):9==j[Q].days&&(5!=v&&6!=v||(k=1)),1==k&&(b>j[Q].start_hours&&b<j[Q].end_hours?C=1:b==j[Q].start_hours&&b<j[Q].end_hours?f>=j[Q].start_min&&(C=1):b>j[Q].start_hours&&b==j[Q].end_hours?f<=j[Q].end_min&&(C=1):b==j[Q].start_hours&&b==j[Q].end_hours&&f>=j[Q].start_min&&f<=j[Q].end_min&&(C=1),1==C&&f>=j[Q].start_min&&f<=j[Q].end_min&&1),1==C&&1==k&&(_=1),1==_&&(Q=j.length+1)}}else _=1}else _=1;if(1==s&&(""!=c()&&("click"==chaty_settings.object_settings.click_setting&&(jQuery(".i-trigger").hasClass("one-widget")||(jQuery(".chaty-widget-i-title").remove(),jQuery(".chaty-widget").addClass("hide-tooltip-arrow"))),setInterval(function(){},1e4)),jQuery(".chaty-main-widget").addClass("i-trigger-open").addClass("single-button"),jQuery(".chaty-widget-show .i-trigger-open svg").css("transform","rotate(0deg)"),jQuery(".chaty-widget").removeClass("chaty-widget-show")),""!=chaty_settings.object_settings.animation_class&&("sheen"!=chaty_settings.object_settings.animation_class?jQuery(".i-trigger .chaty-widget-i svg").wrap(function(){return"<div class='svg'></div>"}):jQuery(".i-trigger .chaty-widget-i .wrap-svg").length||jQuery(".i-trigger .chaty-widget-i svg").wrap(function(){return"<div class='wrap-svg'></div>"})),r()||("on"==chaty_settings.object_settings.pending_messages&&("sheen"!=chaty_settings.object_settings.animation_class?jQuery(".i-trigger .i-trigger-open .svg, .i-trigger .i-trigger-open.single-button .svg").length?jQuery(".i-trigger .i-trigger-open .svg, .i-trigger .i-trigger-open.single-button .svg").append("<span class='cht-pending-message'>"+chaty_settings.object_settings.number_of_messages+"</span>"):jQuery(".i-trigger .i-trigger-open.single-button svg").length?jQuery(".i-trigger .i-trigger-open.single-button svg").after("<span class='cht-pending-message'>"+chaty_settings.object_settings.number_of_messages+"</span>"):jQuery(".i-trigger .i-trigger-open, .i-trigger .i-trigger-open.single-button svg").after("<span class='cht-pending-message'>"+chaty_settings.object_settings.number_of_messages+"</span>"):jQuery(".i-trigger .i-trigger-open, .i-trigger .i-trigger-open.single-button").after("<span class='cht-pending-message'>"+chaty_settings.object_settings.number_of_messages+"</span>"),jQuery(".cht-pending-message").css("color",chaty_settings.object_settings.number_color),jQuery(".cht-pending-message").css("background",chaty_settings.object_settings.number_bg_color)),jQuery(document).on("click",".i-trigger .i-trigger-open, .i-trigger.one-widget",function(){if(jQuery(".cht-pending-message").remove(),"all_time"!=chaty_settings.object_settings.click_setting&&jQuery(this).hasClass("one-widget")){jQuery(this).addClass("show-channel");var t=jQuery(this).data("title");jQuery(this).find(".chaty-widget-i-title").find("p").html(t)}})),jQuery(document).on("click",".i-trigger.one-widget",function(){if("all_time"!=chaty_settings.object_settings.click_setting&&jQuery(this).hasClass("one-widget")){jQuery(this).addClass("show-channel");var t=jQuery(this).data("title");jQuery(this).find(".chaty-widget-i-title").find("p").html(t)}}),jQuery("chaty-main-widget").mouseenter(function(){jQuery(".i-trigger").hasClass("one-widget")||d()}),1==_)if(h("cta_widget_status"))if("no"==chaty_settings.object_settings.time_trigger&&"no"==chaty_settings.object_settings.exit_intent&&"no"==chaty_settings.object_settings.on_page_scroll)jQuery(".chaty-widget").removeClass("hide-widget"),"open"==chaty_settings.object_settings.display_state&&"no"==chaty_settings.object_settings.has_close_button?chaty_settings.object_settings.has_close_button="no":(chaty_settings.object_settings.display_state="hover",chaty_settings.object_settings.has_close_button="yes"),w();else{if(jQuery(".chaty-widget").addClass("hide-widget"),"yes"==chaty_settings.object_settings.time_trigger&&(parseInt(chaty_settings.object_settings.trigger_time)>0?setTimeout(function(){i||(jQuery(".chaty-widget").removeClass("hide-widget"),w())},1e3*parseInt(chaty_settings.object_settings.trigger_time)):(jQuery(".chaty-widget").removeClass("hide-widget"),w())),"yes"==chaty_settings.object_settings.exit_intent){a=document,g="mouseout",l=function(t){null==t.toElement&&null==t.relatedTarget&&null==u("cta_exit_intent_shown")&&(y("cta_exit_intent_shown","yes",1),i=!0,jQuery(".chaty-widget").removeClass("hide-widget"),jQuery(".chaty-widget").addClass("chaty-animation-widget"),jQuery(".chaty-animation-widget").append("<div class='chaty-nav'></div>"),"open"==chaty_settings.object_settings.display_state&&"no"==chaty_settings.object_settings.has_close_button?chaty_settings.object_settings.has_close_button="no":(chaty_settings.object_settings.display_state="open",chaty_settings.object_settings.has_close_button="yes"),w(),"left"==chaty_settings.object_settings.position?jQuery(".chaty-widget").addClass("left-position"):"right"==chaty_settings.object_settings.position?jQuery(".chaty-widget").addClass("right-position"):"custom"==chaty_settings.object_settings.position&&("left"==e.object_settings.pos_side?jQuery(".chaty-widget").addClass("left-position"):jQuery(".chaty-widget").addClass("right-position")),p(),setTimeout(function(){jQuery(".chaty-animation-widget").addClass("active")},100),setTimeout(function(){jQuery(".chaty-nav").remove()},2500))},a.addEventListener?a.addEventListener(g,l,!1):a.attachEvent&&a.attachEvent("on"+g,l)}"yes"==chaty_settings.object_settings.on_page_scroll&&(parseInt(chaty_settings.object_settings.page_scroll)>0?jQuery(window).scroll(function(){if(!i){var t=jQuery(document).height()-jQuery(window).height(),e=jQuery(window).scrollTop();0!=e&&e/t*100>=parseInt(chaty_settings.object_settings.page_scroll)&&(jQuery(".chaty-widget").removeClass("hide-widget"),w())}}):(jQuery(".chaty-widget").removeClass("hide-widget"),w()))}else jQuery(".chaty-widget").removeClass("hide-widget"),w();else jQuery(".chaty-widget").addClass("hide-widget");jQuery(".chaty-widget-i-title").length&&jQuery(".chaty-widget-i-title").each(function(){""==jQuery.trim(jQuery(this).text())&&(jQuery(this).closest(".chaty-widget-i").addClass("hide-chaty-arrow"),jQuery(this).remove())}),jQuery(".chaty-widget-i.true.chaty-widget-i-title").length||""==jQuery(".chaty-widget-i-title").text()&&jQuery(".chaty-widget-i").addClass("hide-chaty-arrow"),jQuery(".i-trigger-open .chaty-widget-i-title").length?""==jQuery(".i-trigger-open .chaty-widget-i-title").text()&&jQuery(".i-trigger-open").addClass("hide-chaty-arrow"):jQuery(".i-trigger .i-trigger-open").addClass("hide-chaty-arrow")}),jQuery(".chaty-widget-i-title").each(function(){""==jQuery(this).text()&&(jQuery(this).closest(".chaty-widget-i").addClass("hide-chaty-arrow"),jQuery(this).remove())}),jQuery(".chaty-widget").hasClass("one_widget")||jQuery("body").append("<div class='trigger-chaty-button'></div>"),jQuery("body").addClass(chaty_settings.object_settings.mode+"-cht-menu"),jQuery("body").addClass(chaty_settings.object_settings.position+"-cht-position")})}),jQuery(document).on("click",".trigger-chaty-button",function(){jQuery(".chaty-widget").removeClass("hide-widget"),w(),!jQuery(".chaty-widget").hasClass("none-widget-show")&&jQuery(".chaty-widget").hasClass("chaty-widget-show")||jQuery(".i-trigger-open").trigger("click")}),jQuery(document).on("click",".has-custom-chaty-popup.whatsapp-button",function(t){if(jQuery("#chaty-inline-popup").length){var e=jQuery(this).data("data-index");jQuery("#chaty-widget-"+e).removeClass("chaty-popup-open"),jQuery(".chaty-popup-open").removeClass("chaty-popup-open"),jQuery(".chaty-widget.hide-block").removeClass("active")}if(jQuery(this).hasClass("open-it-by-default")&&t.preventDefault(),jQuery("#chaty-inline-popup").remove(),null!=jQuery(this).attr("data-popup")&&""!=jQuery(this).attr("data-popup")){e="";jQuery(".chaty-widget").addClass("hide-block"),jQuery(".chaty-widget").addClass("chaty-popup-open");var i="<div data-index='"+e+"' id='chaty-inline-popup' class='chaty-inline-popup chaty-popup-form "+jQuery(this).data("channel")+"-channel'>";i+=jQuery(this).attr("data-popup"),jQuery("body").append(i),jQuery(".chaty-inline-popup .default-value").length&&(thisHref=jQuery(".chaty-inline-popup .default-value").text(),thisHref=decodeURI(thisHref),thisHref=thisHref.replace(/{title}/g,jQuery("title").text()),thisHref=thisHref.replace(/{url}/g,window.location.href),jQuery(".chaty-whatsapp-msg").val(jQuery(".chaty-inline-popup .default-value").text()),jQuery(".chaty-whatsapp-phone").val(jQuery(".chaty-inline-popup .default-msg-phone").text()),chatyHtml=jQuery(".chaty-inline-popup .default-msg-value").html(),chatyHtml=chatyHtml.replace(/{title}/g,jQuery("title").text()),chatyHtml=chatyHtml.replace(/{url}/g,window.location.href),jQuery(".chaty-whatsapp-message").html(chatyHtml)),jQuery(".chaty-widget").addClass("active"),setTimeout(function(){jQuery("#chaty-inline-popup").addClass("active")},150),jQuery("body").hasClass("chaty-in-mobile")||jQuery(".chaty-whatsapp-msg").focus()}a&&jQuery(".whatsapp-chaty-form").prop("target","")}),jQuery(document).on("click",".close-chaty-popup, .close-chaty-box",function(){jQuery(this).hasClass("is-whatsapp-btn")&&l("cht_whatsapp_window"),jQuery("#chaty-inline-popup").removeClass("active"),jQuery(".chaty-widget").removeClass("chaty-popup-open"),setTimeout(function(){jQuery(".chaty-widget.hide-block").removeClass("active")},250)}),jQuery(document).on("submit",".whatsapp-chaty-form",function(t){if(l("cht_whatsapp_window"),jQuery("#chaty-inline-popup").removeClass("active"),jQuery(".chaty-widget").removeClass("chaty-popup-open"),setTimeout(function(){jQuery(".chaty-widget.hide-block").removeClass("active")},250),jQuery("body").hasClass("chaty-in-mobile"))return t.preventDefault(),window.location="https://wa.me/"+jQuery(this).find(".chaty-whatsapp-phone").val()+"?text="+jQuery(this).find(".chaty-whatsapp-msg").val(),!1}),jQuery(document).on("submit",".chaty-contact-form-data",function(t){var e=0;if(jQuery(".has-chaty-error").removeClass("has-chaty-error"),jQuery(".chaty-error-msg").remove(),jQuery(".chaty-ajax-error-message").remove(),jQuery(".chaty-ajax-success-message").remove(),jQuery(this).find(".is-required").each(function(){""==jQuery.trim(jQuery(this).val())&&(e++,jQuery(this).addClass("has-chaty-error"))}),0==e){var i=jQuery(this);jQuery(".chaty-contact-submit-btn").attr("disabled",!0),jQuery.ajax({url:chaty_settings.ajax_url,data:{action:"chaty_front_form_save_data",name:i.find(".chaty-field-name").length?i.find(".chaty-field-name").val():"",email:i.find(".chaty-field-email").length?i.find(".chaty-field-email").val():"",phone:i.find(".chaty-field-phone").length?i.find(".chaty-field-phone").val():"",message:i.find(".chaty-field-message").length?i.find(".chaty-field-message").val():"",nonce:i.find(".chaty-field-nonce").length?i.find(".chaty-field-nonce").val():"",channel:i.find(".chaty-field-channel").length?i.find(".chaty-field-channel").val():"",widget:i.find(".chaty-field-widget").length?i.find(".chaty-field-widget").val():"",ref_url:window.location.href},type:"post",async:!0,defer:!0,success:function(t){if(t=jQuery.parseJSON(t),jQuery(".chaty-ajax-error-message").remove(),jQuery(".chaty-ajax-success-message").remove(),jQuery(".chaty-contact-submit-btn").attr("disabled",!1),1==t.status)jQuery(".chaty-contact-footer").append("<div class='chaty-ajax-success-message'>"+t.message+"</div>"),jQuery(".chaty-field-name, .chaty-field-email, .chaty-field-message").val(""),"yes"==t.redirect_action&&("yes"==t.link_in_new_tab?window.open(t.redirect_link,"_blank"):window.location=t.redirect_link),"yes"==t.close_form_after&&setTimeout(function(){jQuery("#chaty-inline-popup").removeClass("active"),jQuery(".chaty-widget").removeClass("chaty-popup-open"),setTimeout(function(){jQuery(".chaty-widget.hide-block").removeClass("active")},250)},1e3*parseInt(t.close_form_after_seconds));else if(1==t.error){if(t.errors.length)for(var e=0;e<t.errors.length;e++)jQuery("."+t.errors[e].field).addClass("has-chaty-error"),jQuery("."+t.errors[e].field).after("<span class='chaty-error-msg'>"+t.errors[e].message+"</span>")}else jQuery(".chaty-contact-footer").append("<div class='chaty-ajax-error-message'>"+t.message+"</div>")}})}else jQuery(".has-chaty-error:first").focus();return!1})}(jQuery)},12:function(t,e){}});
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: galdub, tomeraharon, premio
|
|
3 |
Tags: whatsapp, whatsapp chat, facebook messenger, click to chat, chat, chat button, call now button, messenger, whatsapp button, chat icon, contact button, click to call
|
4 |
Requires at least: 3.1
|
5 |
Tested up to: 5.7
|
6 |
-
Stable tag: 2.8
|
7 |
Plugin URI: https://premio.io/downloads/chaty/
|
8 |
|
9 |
Whatsapp, Facebook Messenger, Telegram, TikTok Viber, Email, Phone call, SMS and more with customizable chat & call buttons. Chat with your visitors on WhatsApp, Facebook Messenger, and other chat channels!
|
@@ -258,6 +258,9 @@ Yes! You can even decide what chat buttons will show up on each device (desktop/
|
|
258 |
|
259 |
== Changelog ==
|
260 |
|
|
|
|
|
|
|
261 |
= 2.8 =
|
262 |
File upload related bug fixed
|
263 |
|
3 |
Tags: whatsapp, whatsapp chat, facebook messenger, click to chat, chat, chat button, call now button, messenger, whatsapp button, chat icon, contact button, click to call
|
4 |
Requires at least: 3.1
|
5 |
Tested up to: 5.7
|
6 |
+
Stable tag: 2.8.1
|
7 |
Plugin URI: https://premio.io/downloads/chaty/
|
8 |
|
9 |
Whatsapp, Facebook Messenger, Telegram, TikTok Viber, Email, Phone call, SMS and more with customizable chat & call buttons. Chat with your visitors on WhatsApp, Facebook Messenger, and other chat channels!
|
258 |
|
259 |
== Changelog ==
|
260 |
|
261 |
+
= 2.8.1 =
|
262 |
+
Some editing bugs were fixed
|
263 |
+
|
264 |
= 2.8 =
|
265 |
File upload related bug fixed
|
266 |
|
views/admin/channels-section.php
CHANGED
@@ -293,7 +293,7 @@ if (!defined('ABSPATH')) {
|
|
293 |
if(!isset($value['image_id'])) {
|
294 |
$value['image_id'] = ''; // Initialize custom image id if not exists. 2.1.0 change
|
295 |
}
|
296 |
-
if(!isset($value['title'])
|
297 |
$value['title'] = $social['title']; // Initialize title if not exists. 2.1.0 change
|
298 |
}
|
299 |
if(!isset($value['fa_icon'])) {
|
293 |
if(!isset($value['image_id'])) {
|
294 |
$value['image_id'] = ''; // Initialize custom image id if not exists. 2.1.0 change
|
295 |
}
|
296 |
+
if(!isset($value['title'])) {
|
297 |
$value['title'] = $social['title']; // Initialize title if not exists. 2.1.0 change
|
298 |
}
|
299 |
if(!isset($value['fa_icon'])) {
|