1jQuery(function($) { 2 3 'use strict'; 4 5 6 /** 7 * jQuery Tiny Pub/Sub 8 * https://github.com/cowboy/jquery-tiny-pubsub 9 * 10 * Copyright (c) 2013 "Cowboy" Ben Alman 11 * Licensed under the MIT license. 12 **********************************************************************/ 13 var o = $({}); 14 $.subscribe = function() {o.on.apply(o, arguments);}; 15 $.unsubscribe = function() {o.off.apply(o, arguments);}; 16 $.publish = function() {o.trigger.apply(o, arguments);}; 17 18 /** 19 * Save the main building block of DOM elements; for the 20 * sake of succinctness 21 **********************************************************************/ 22 var DOM = (function ( dom ) { 23 24 var dom = dom || {}; 25 26 dom.body = $('body:eq(0)'); 27 28 29 return dom; 30 31 }( DOM ) ); 32 33 /** 34 * Simple cookie utilities 35 **********************************************************************/ 36 var COOKIES = (function ( cookies ) { 37 38 var cookies = cookies || {}; 39 40 cookies.setItem = function ( name, value, durationInDays ) { 41 var d = new Date(); 42 d.setTime( d.getTime() + ( durationInDays * 24 * 60 * 60 * 1000 ) ); 43 var expires = 'expires=' + d.toUTCString(); 44 document.cookie = name + '=' + value + ';' + expires + ';path=/'; 45 }; 46 47 cookies.getItem = function ( name ) { 48 var name = name + '=', 49 decodedCookie = decodeURIComponent( document.cookie ), 50 ca = decodedCookie.split(';'); 51 52 for ( var i = 0; i < ca.length; i++ ) { 53 54 var c = ca[ i ]; 55 56 while ( c.charAt( 0 ) == ' ' ) { 57 c = c.substring(1); 58 } 59 60 if ( c.indexOf( name ) == 0 ) { 61 return c.substring( name.length, c.length ); 62 } 63 } 64 return null; 65 } 66 67 cookies.deleteItem = function ( name ) { 68 document.cookie = name + '=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;'; 69 }; 70 71 return cookies; 72 73 }( COOKIES ) ); 74 75 /** 76 * We need to trigger WhatsApp application if it exists. Fall back to 77 * web if it doesn't. 78 **********************************************************************/ 79 (function () { 80 81 82 83 }()); 84 85 /** 86 * Centralize the process of hide/show of the box. 87 **********************************************************************/ 88 (function () { 89 90 var wptwa = DOM.body.find( '.wptwa-container' ), 91 box = wptwa.find( '.wptwa-box' ), 92 toggleBox = function ( e ) { 93 box.toggleClass( 'show' ); 94 if ( ! COOKIES.getItem( 'wptwa' ) ) { 95 COOKIES.setItem( 'wptwa', 'toggled', 1 ); 96 } 97 }; 98 99 $.subscribe('wptwa-toggle-box', toggleBox); 100 101 }()); 102 103 /** 104 * Show and hide the box. 105 **********************************************************************/ 106 (function () { 107 108 var wptwa = DOM.body.find( '.wptwa-container' ), 109 delayTime = parseInt( wptwa.data( 'delay-time' ) ), 110 inactiveTime = parseInt( wptwa.data( 'inactive-time' ) ), 111 scrollLength = parseInt( wptwa.data( 'scroll-length' ) ), 112 autoDisplayOnMobile = wptwa.data( 'auto-display-on-mobile' ), 113 box = wptwa.find( '.wptwa-box' ), 114 handler = wptwa.find( '.wptwa-handler' ), 115 close = wptwa.find( '.wptwa-close' ), 116 autoShow 117 ; 118 119 if ( ! wptwa.length ) { 120 return; 121 } 122 123 /* Toggle box on handler's (or close's) click */ 124 handler.add( close ).on( 'click', function () { 125 $.publish('wptwa-toggle-box'); 126 } ); 127 128 /* Check if we should also use auto display on mobile. */ 129 if ( 'on' !== autoDisplayOnMobile && window.getComputedStyle( wptwa.get(0), ':after' ).content == '"mobile"' ) { 130 return; 131 } 132 133 /* Show box after a delay time on page load and only if it has 134 not been shown before. 135 */ 136 if ( delayTime > 0 ) { 137 autoShow = setTimeout( function () { 138 if ( ! box.is( '.show' ) && ! COOKIES.getItem( 'wptwa' ) ) { 139 $.publish('wptwa-toggle-box'); 140 } 141 }, delayTime * 1000 ); 142 } 143 144 /* Trigger after inactivity and only if it has not been shown 145 before. 146 */ 147 var cb, 148 executed = false, 149 events = 'mousemove mousedown mouseup onkeydown onkeyup focus scroll', 150 showAfterInactivity = function () { 151 clearTimeout( cb ); 152 if ( ! executed ) { 153 cb = setTimeout(function () { 154 if ( ! COOKIES.getItem( 'wptwa' ) && ! box.is( '.show' ) ) { 155 $.publish('wptwa-toggle-box'); 156 } 157 $( document ).off( events, showAfterInactivity ); 158 }, inactiveTime * 1000 ); 159 } 160 }; 161 162 if ( inactiveTime > 0 ) { 163 $( document ).on( events, showAfterInactivity ); 164 } 165 166 /* Trigger after scrolling. 167 Accessing DOM on-scroll is a bad idea. Let's execute the function 168 every half a second during/post scroll instead. 169 */ 170 var percentage = Math.abs( scrollLength ) / 100, 171 scrolling, 172 timing = true, 173 scrollHandler = function() { 174 175 scrolling = true; 176 177 if ( timing ) { 178 179 setTimeout(function () { 180 if ( $( window ).scrollTop() >= ( $( document ).height() - $( window ).height() ) * percentage ){ 181 if ( ! COOKIES.getItem( 'wptwa' ) && ! box.is( '.show' ) ) { 182 $.publish('wptwa-toggle-box'); 183 } 184 $( window ).off( 'scroll', scrollHandler ); 185 } 186 timing = true; 187 scrolling = false;
188 }, 500 ); 189 190 if ( scrolling ) { 191 timing = false; 192 } 193 } 194 } 195 ; 196 197 if ( scrollLength > 0 ) { 198 $( window ).on( 'scroll', scrollHandler ); 199 } 200 201 }()); 202 203 /** 204 * If avatar is not provided or provided but error, add a hint to 205 * .wptwa-face so we can show a default image. 206 **********************************************************************/ 207 (function () { 208 209 DOM.body.find( '.wptwa-container .wptwa-face' ).each(function () { 210 var el = $( this ), 211 img = el.find( 'img' ), 212 noImage = true 213 ; 214 215 if ( img.length ) { 216 var url = img.attr( 'src' ), 217 tester = new Image(); 218 tester.src = url; 219 220 tester.onerror = function () { 221 el.addClass( 'no-image' ); 222 }; 223 224 } 225 else { 226 el.addClass( 'no-image' ); 227 } 228 229 }); 230 231 }()); 232 233 /** 234 * Sniffing USER_AGENT on server doesn't work when the cache system is 235 * enabled, since the server will output the cache while ignoring the 236 * user-agent. Let's sniff it out on the client instead. 237 **********************************************************************/ 238 (function () { 239 240 var mobile = false; 241 (function(a){if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|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|xda|xiino/i.test(a)||/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(a.substr(0,4))) { mobile = true; }})(navigator.userAgent||navigator.vendor||window.opera); 242 243 244 DOM.body.find( 'a.wptwa-account' ).each( function () { 245 var el = $( this ), 246 autoText = '' != el.data( 'auto-text' ) ? '&text=' + el.data( 'auto-text' ) : '', 247 hrefValue 248 ; 249 250 if ( mobile ) { 251 hrefValue = 'https://api.whatsapp.com/send?phone=' + el.data( 'number' ) + autoText; 252 } 253 else { 254 hrefValue = 'https://web.whatsapp.com/send?phone=' + el.data( 'number' ) + autoText; 255 } 256 257 el.attr( 'href', hrefValue ); 258 259 } ); 260 261 }()); 262 263 /** 264 * 265 **********************************************************************/ 266 (function () { 267 268 269 270 }()); 271 272});
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.