Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Set the Olark chatbox to appear inline
- olark.configure('box.inline', true);
- // Keep things from polluting the global namespace, except changeClass, which we want accessible
- var changeClass;
- (function (d, olk) {
- // These functions are helpers for the below
- function getOlarkWrapper() {
- return d.getElementById("olark-box-wrapper");
- }
- function setOlarkVisible(olark_wrapper) {
- olark_wrapper.className = "chatbox-open";
- }
- function setOlarkHidden(olark_wrapper) {
- olark_wrapper.className = "chatbox-closed";
- }
- function olarkIsVisible(olark_wrapper) {
- return olark_wrapper.className.match(/(?:^|\s)chatbox-open(?!\S)/);
- }
- // This is used by the link to show/hide the inline page element
- changeClass = function() {
- var olark_wrapper = getOlarkWrapper();
- // Get the HTML object containing the Olark chat box
- // If the chat box is already open, close id
- if (olarkIsVisible(olark_wrapper)) {
- setOlarkHidden(olark_wrapper);
- } else {
- setOlarkVisible(olark_wrapper);
- }
- }
- // This is used to cause the box to auto-open if a visitor is already in conversation
- olk('api.visitor.getDetails', function (details) {
- if (details.isConversing) {
- setOlarkVisible(getOlarkWrapper());
- }
- });
- }(document, olark));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement