Last active
August 24, 2017 17:11
-
-
Save JarrydLong/7041b064300d5f55ff410200277f3c57 to your computer and use it in GitHub Desktop.
Render a popup on the page. Choose weather to open or close the chat from the popup.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(document).ready(function(){ | |
var popup_string = "<div class='wplc_custom_popup'>"; | |
popup_string = popup_string + "<p>Can we help you?</p>"; | |
popup_string = popup_string + "<button class='custom_popup_open_chat'>Yes</button>"; | |
popup_string = popup_string + "<button class='custom_popup_close_chat'>No</button>"; | |
popup_string = popup_string + "</div>"; | |
var show_popup = Cookies.get( 'wplc_chat_popup_window' ); | |
if( typeof show_popup === 'undefined' ){ | |
jQuery("body").append(popup_string); | |
} | |
jQuery("body").on("click", ".custom_popup_open_chat", function(){ | |
console.log('Opening the chat'); | |
jQuery("#wp-live-chat-header").click(); | |
jQuery(".wplc_custom_popup").css('display','none') | |
}); | |
jQuery("body").on("click", ".custom_popup_close_chat", function(){ | |
console.log('Closing the chat'); | |
jQuery(".wplc_custom_popup").css('display','none'); | |
Cookies.set('wplc_chat_popup_window', 1, { expires: 1, path: '/' }); | |
}); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment