1(function($) { 2 3 'use strict'; 4 5 jQuery( document ).ready(function() { 6 7 // Some defaults 8 var toggleMethod = 'data-onc-toggle', 9 menuState = 'data-onc-state', 10 mainButtonClass = 'onc-cb-menu-start'; 11 12 // Internal references 13 var elemsToClick, 14 elemsToHover, 15 mainButton, 16 target, 17 currentState; 18 19 var onc_cb_menu = document.getElementById('onc-cb-menu'); 20 if (onc_cb_menu) { 21 var toggle_method = onc_cb_menu.getAttribute('data-onc-toggle'); 22 } 23 24 function getElemsByToggleMethod(selector) { 25 return document.querySelectorAll('[' + toggleMethod + '="' + selector + '"]'); 26 } 27 28 // The open/close action is performed by toggling an attribute on the menu main element. 29 function toggleButton(evt) { 30 target = evt.target; 31 while (target && !target.getAttribute(toggleMethod)) { 32 target = target.parentNode; 33 if (!target) { 34 return; 35 } 36 } 37 currentState = target.getAttribute(menuState) === 'open' ? 'closed' : 'open'; 38 target.setAttribute(menuState, currentState); 39 } 40 41 function closePopup(){ 42 // Change bubble icon back to the original icon 43 var ori_icon = jQuery('.onc-icon-chats').find('img').data('ori-src'); 44 jQuery('.onc-icon-chats').find('img').attr('src', ori_icon ).addClass('onc-rotate'); 45 setTimeout(function() { jQuery('.onc-icon-chats').find('img').attr('src', ori_icon ).removeClass('onc-rotate'); }, 500); 46 onc_cb_menu.setAttribute('data-onc-item', ''); 47 // re activate hover if the original trigger method is hover 48 if(onc_cb_menu.getAttribute('data-onc-ori')!='click'){ 49 onc_cb_menu.setAttribute('data-onc-toggle', 'hover'); 50 toggle_method = 'hover'; 51 } 52 53 } 54 55 // if trigger method is click, toggle all bubbles 56 jQuery(document).on('click', '.onc-cb-menu-start', function(evt) { 57 if (toggle_method == 'click') { 58 if (onc_cb_menu.getAttribute('data-onc-state')=='open') { 59 if(!onc_cb_menu.getAttribute('data-onc-ori')=='click'){ 60 onc_cb_menu.setAttribute('data-onc-toggle', 'hover'); 61 toggle_method = 'hover'; 62 } 63 } 64 toggleButton(evt); 65 jQuery('.speechbubble').hide(); 66 } 67 }); 68 69 // if trigger method is hover, show all bubbles 70 jQuery(document).on('mouseenter', '.onc-cb-menu-start', function(evt) { 71 if (toggle_method == 'hover') { 72 toggleButton(evt); 73 jQuery('.speechbubble').hide(); 74 } 75 }); 76 77 // if trigger method is hover, hide all bubbles 78 jQuery(document).on('mouseleave', '.onc-cb-menu-start', function(evt) { 79 if (toggle_method == 'hover') { 80 toggleButton(evt); 81 } 82 }); 83 84 85 // One bubble is clicked 86 jQuery(document).on('click', '.onc-button', function() { 87 88 // close all bubble items when one is clicked 89 onc_cb_menu.setAttribute('data-onc-toggle', 'click'); 90 toggle_method = 'click'; 91 onc_cb_menu.setAttribute('data-onc-state', 'closed'); 92 if (jQuery('#onc-popup').length) { 93 jQuery.fn.ocpopup.popupHide(); 94 } 95 // get & show popup content relevent to the clicked item 96 var clicked_item = jQuery(this).data('onc-item'); 97 var mif = jQuery('#onc-popup-cont-'+clicked_item); 98 if (mif.length) { 99 // Change bubble icon to clicked item icon 100 var clicked_icon = jQuery(this).find('img').attr('src'); 101 jQuery('.onc-icon-chats').find('img').attr('src', clicked_icon ); 102 onc_cb_menu.setAttribute('data-onc-item', clicked_item); 103 104 var onc_popup_position = onc_cb_menu.getAttribute('data-onc-popup-position') 105 var popup_position = 'right'; 106 if(onc_popup_position == 'br'){ 107 popup_position = 'right'; 108 }else if(onc_popup_position == 'bl'){ 109 popup_position = 'left'; 110 } 111 // open popup 112 jQuery.fn.ocpopup({ 113 position: popup_position, 114 content: mif.html(), 115 }); 116 }else if(jQuery(this).attr('data-js')){ 117 118 // Change bubble icon to clicked item icon 119 var clicked_icon = jQuery(this).find('img').attr('src'); 120 jQuery('.onc-icon-chats').find('img').attr('src', clicked_icon ); 121 onc_cb_menu.setAttribute('data-onc-item', clicked_item); 122 123 if(jQuery(this).data('js')=='facebook-cc'){ 124 jQuery('#onc-cb-menu').hide(); 125 jQuery('.fb-root-container').show(); 126 if (typeof FB == 'undefined' || typeof FB.CustomerChat == 'undefined'){ 127 console.error('Facebook customer chat integration is disabled in module configuration'); 128 return false; 129 } 130 if(jQuery('#onc-cb-menu').hasClass('is-mobile')){ 131 //FB.CustomerChat.showDialog(); 132 }else{ 133 //FB.CustomerChat.show(true); 134 FB.CustomerChat.showDialog(); 135 } 136 } 137 138 }else{ 139 var clicked_item_link = jQuery(this).data('href'); 140 if (clicked_item_link.substring(0, 4) == 'http'){ 141 var href_target = "_blank"; 142 }else{ 143 var href_target = "_self"; 144 } 145 // Change bubble icon back to the original icon 146 var ori_icon = jQuery('.onc-icon-chats').find('img').data('ori-src'); 147 jQuery('.onc-icon-chats').find('img').attr('src', ori_icon ).addClass('onc-rotate'); 148 setTimeout(function() { jQuery('.onc-icon-chats').find('img').attr('src', ori_icon ).removeClass('onc-rotate'); }, 500); 149 onc_cb_menu.setAttribute('data-onc-item', ''); 150 if (clicked_item_link) { 151 window.open(clicked_item_link, href_target); 152 } 153 // re activate hover if the original trigger method is hover 154 if(onc_cb_menu.getAttribute('data-onc-ori')!='click'){ 155 onc_cb_menu.setAttribute('data-onc-toggle', 'hover'); 156 toggle_method = 'hover'; 157 } 158 159 } 160 161 // Set popup title 162 if (mif.length) { 163 var clicked_label = jQuery(this).data('onc-label'); 164 jQuery('#onc-popup').addClass('onc-popup-'+clicked_item); 165 jQuery('.onc-title-icon').html('<img src="'+clicked_icon+'">'); 166 jQuery('.onc-title-txt').html(clicked_label); 167 } 168 169 }); 170 171 jQuery(document).on('click', '.onc-close', function() { 172 closePopup(); 173 }); 174 175 if (jQuery('#fb-root').length) { 176 window.fbAsyncInit = function() { 177 FB.init({ 178 xfbml: true, 179 version: 'v11.0' 180 });
181 FB.Event.subscribe('customerchat.dialogHide', function() { 182 jQuery('.fb-root-container').hide(); 183 jQuery('#onc-cb-menu').show(); 184 closePopup(); 185 //FB.CustomerChat.hide(); 186 if(jQuery('#onc-cb-menu').hasClass('is-mobile')){ 187 //FB.CustomerChat.showDialog(); 188 }else{ 189 FB.CustomerChat.showDialog(); 190 } 191 192 }); 193 }; 194 195 (function(d, s, id) { 196 var js, fjs = d.getElementsByTagName(s)[0]; 197 if (d.getElementById(id)) return; 198 js = d.createElement(s); 199 js.id = id; 200 js.src = 'https://connect.facebook.net/en_US/sdk/xfbml.customerchat.js'; 201 fjs.parentNode.insertBefore(js, fjs); 202 }(document, 'script', 'facebook-jssdk')); 203 } 204 205 }); 206})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.