1;(function ($) { 2 "use strict"; 3 4 $.fn.get_transparent_selector = function get_transparent_selector(){ 5 let transparent_header_selector = $(this).closest('.hthb-notification.hthb-pos--top[data-transparent_header_selector]').last().data('transparent_header_selector'); 6 if($(this).closest('.hthb-notification.hthb-pos--top').hasClass('hthb-transparent')){ 7 return transparent_header_selector; 8 } 9 10 return false; 11 } 12 13 $.fn.add_transparent_header_spacing = function add_transparent_header_spacing(top_notification_height){ 14 if( $('body').find('#wpadminbar').length ){ 15 top_notification_height = Number.parseInt(top_notification_height + $('body').find('#wpadminbar').height()); 16 } 17 } 18 19 function calculate_top_zero(){ 20 if( $('body').find('#wpadminbar').length ){ 21 return '32px'; 22 } else{ 23 return '0px'; 24 } 25 } 26 27 var timeout = 400; 28 $(window).on('load',function(){ 29 var top_notification_height = Number.parseInt($('.hthb-notification.hthb-pos--top').last().height()), 30 bottom_notification_height = $('.hthb-notification.hthb-pos--bottom').last().height(), 31 left_wall_notification_width = $('.hthb-notification.hthb-pos--left-wall').last().width(), 32 right_wall_notification_width = $('.hthb-notification.hthb-pos--right-wall').last().width(); 33 34 var position; 35 36 // if load as minimized disabled 37 $('.hthb-notification.hthb-state--open').each(function(){ 38 position = $(this).getPostion(); 39 40 if( position == 'top' ){ 41 $('body').addClass('hthb hthb-pt--' + top_notification_height ); 42 if( $(this).get_transparent_selector() ){ 43 44 $($(this).get_transparent_selector()).addClass('hthb-top-unset'); 45 $($(this).get_transparent_selector()).css( {'top':'unset'} ); 46 47 } 48 } else if( position == 'bottom'){ 49 $('body').css('padding-bottom', bottom_notification_height + 'px'); 50 } 51 52 // Implement how many time to show 53 var time_to_show = $(this).data('time_to_show'), 54 id = $(this).data('id') ? '_' + $(this).data('id') : '', 55 coockie_count = Cookies.get('hashbarpro_cookiecount' + id), 56 hashbarpro_oldcookie = Cookies.get('hashbarpro_oldcookie' + id); 57 58 if( time_to_show && time_to_show > 0 ){ 59 60 if(document.cookie.indexOf("hashbarpro_oldcookie" + id) >= 0){ 61 if(time_to_show == hashbarpro_oldcookie && coockie_count){ 62 coockie_count++; 63 Cookies.set('hashbarpro_cookiecount' + id, coockie_count, { expires: 7 }); 64 } else { 65 Cookies.set('hashbarpro_oldcookie' + id, time_to_show, { expires: 7 }); 66 Cookies.set('hashbarpro_cookiecount' + id, 1, { expires: 7 }); 67 } 68 } else { 69 Cookies.set('hashbarpro_oldcookie' + id, time_to_show, { expires: 7 }); 70 Cookies.set('hashbarpro_cookiecount' + id, 1, { expires: 7 }); 71 } 72 } 73 74 if( coockie_count > time_to_show ){ 75 $(this).css({'display': 'none'}); 76 $(this).removeClass('hthb-state--open').addClass('hthb-state--minimized'); 77 78 if( position == 'top' ){ 79 $('body').removeClass('hthb'); 80 } 81 } 82 83 }); 84 85 // Load as mimimized if option is set to minimized 86 $('.hthb-notification.hthb-state--minimized').each(function(){ 87 var position = $(this).getPostion(); 88 if( position == 'top' || position == 'top-promo' || position == 'bottom' || position == 'bottom-promo' ){ 89 $(this).find('.hthb-row').css('display', 'none'); 90 } 91 92 }); 93 94 // Left/right wall 95 $('.hthb-notification.hthb-state--minimized').each(function(){ 96 var position = $(this).getPostion(); 97 if( position == 'left-wall' ){ 98 $(this).css('left', '-' + left_wall_notification_width + 'px' ); 99 } else if( position == 'right-wall' ){ 100 $(this).css('right', '-' + right_wall_notification_width + 'px' ); 101 } 102 103 }); 104 105 setTimeout(function(){ 106 $('.hthb-notification').addClass('hthb-loaded'); 107 }, timeout ); 108 109 $('.hthb-notification').each(function() { 110 const delay_time = $(this).attr('data-delay_time'); 111 if(+delay_time) { 112 setTimeout(() => { 113 $(this).showNotification( top_notification_height, bottom_notification_height, left_wall_notification_width, right_wall_notification_width ); 114 }, +delay_time*1000); 115 } 116 }) 117 118 // When click close button 119 $('.hthb-close-toggle').on('click', function(){ 120 const $hthb_id = $(this).closest('.hthb-notification')[0].dataset.id; 121 let $expire_time = +hashbar_localize.cookies_expire_time 122 if(hashbar_localize.cookies_expire_type === 'hours') { 123 $expire_time = $expire_time/24; 124 } 125 if(hashbar_localize.cookies_expire_type === 'minutes') { 126 $expire_time = $expire_time/1440; 127 } 128 129 $(this).minimizeNotification( top_notification_height, bottom_notification_height, left_wall_notification_width, right_wall_notification_width); 130 131 // Keep closed 132 if( hashbar_localize.bar_keep_closed == '1' ){ 133 Cookies.set(`keep_closed_bar_${$hthb_id}`, '1', { expires: $expire_time, path: '/' }); 134 } 135 136 // Don't show forever 137 if( hashbar_localize.dont_show_bar_after_close == '1' ) { 138 Cookies.set( `dont_show_bar_${$hthb_id}`, '1', { expires: $expire_time, path: '/' } ); 139 } 140 }); 141 142 // When clicked open button 143 $('.hthb-open-toggle').on('click', function(){ 144 $(this).showNotification( top_notification_height, bottom_notification_height, left_wall_notification_width, right_wall_notification_width ); 145 }); 146 147 // When scroll position matched with a notification 148 // Show the notifications 149 var window_inner_height = $(window).height(), 150 page_height = $('body').height(); 151 152 let current_scroll_position = window.pageYOffset || document.documentElement.scrollTop, 153 current_scroll_position_percent = current_scroll_position / scroll_pos_max * 100; 154 current_scroll_position_percent = Number.parseInt(current_scroll_position_percent); 155 156 var scroll_pos_max = $(document).height() - $(window).height(); 157 158 $(window).on('scroll', function(e){ 159 current_scroll_position = $(window).scrollTop(), 160 current_scroll_position_percent = current_scroll_position / scroll_pos_max * 100; 161 current_scroll_position_percent = Number.parseInt(current_scroll_position_percent); 162 163 $(`.hthb-scroll`).each(function(){ 164 let scroll_to_show = $(this).data('scroll_to_show'), 165 scroll_to_hide = $(this).data('scroll_to_hide'), 166 hthb_id = $(this)[0].dataset.id; 167 168 $(this).trigger_notification_on_scroll(hthb_id, scroll_to_show, scroll_to_hide, current_scroll_position, scroll_pos_max); 169 }); 170 }); 171 }); 172 173 /** 174 * Calculate % of a given value. 175 * For example, If the give value is 1000 & we want to know the 75% of it. 176 * It will return 750 as the result. 177 * 178 * @param number percent_amount, % amount. 179 * @param number percent_of, Total amount from where the % should be calculated. 180 * @return number 181 */ 182 function percent_of(percent_amount, percent_of){ 183 percent_of = Number.parseInt(percent_of); 184 percent_amount = Number.parseInt(percent_amount); 185 186 return percent_of * percent_amount / 100; 187 } 188 189 $.fn.getPostion = function(){ 190 if(this.closest('.hthb-notification').hasClass('hthb-pos--top')){ 191 return 'top'; 192 } 193 194 if(this.closest('.hthb-notification').hasClass('hthb-pos--bottom')){ 195 return 'bottom'; 196 } 197 198 if(this.closest('.hthb-notification').hasClass('hthb-pos--left-wall')){ 199 return 'left-wall'; 200 } 201 202 if(this.closest('.hthb-notification').hasClass('hthb-pos--right-wall')){ 203 return 'right-wall'; 204 } 205 206 if(this.closest('.hthb-notification').hasClass('hthb-pos--bottom-promo')){ 207 return 'bottom-promo'; 208 } 209 210 if(this.closest('.hthb-notification').hasClass('hthb-pos--top-promo')){ 211 return 'top-promo'; 212 } 213 } 214 215 $.fn.minimizeNotification = function(top_notification_height, bottom_notification_height, left_wall_notification_width, right_wall_notification_width){ 216 var postion = this.getPostion(), 217 left_wall_notification_width = this.closest('.hthb-notification').width(), 218 right_wall_notification_width = this.closest('.hthb-notification').width(); 219 220 this.closest('.hthb-notification').removeClass('hthb-state--open'); 221 this.closest('.hthb-notification').addClass('hthb-state--minimized'); 222 223 if(postion != 'left-wall' && postion != 'right-wall'){ 224 this.closest('.hthb-notification').find('.hthb-row').slideToggle(); 225 } 226 227 if( postion == 'top' ){ 228 $('body').removeClass('hthb'); 229 230 // for sticky 231 if( this.get_transparent_selector() ){ 232 $(this.get_transparent_selector()).addClass('hthb-top-unset'); 233 $(this.get_transparent_selector()).css({'top': calculate_top_zero()}); 234 } 235 } else if( postion == 'bottom' ){ 236 $('body').css('padding-bottom', ''); 237 } else if( postion == 'left-wall' ){ 238 this.closest('.hthb-notification').css('left', '-' + left_wall_notification_width + 'px' ); 239 } else if( postion == 'right-wall' ){ 240 this.closest('.hthb-notification').css('right', '-' + right_wall_notification_width + 'px' ); 241 } 242 } 243 244 $.fn.showNotification = function(top_notification_height, bottom_notification_height, left_wall_notification_width, right_wall_notification_width){ 245 var postion = this.getPostion(), 246 left_wall_notification_width = this.closest('.hthb-notification').width(), 247 right_wall_notification_width = this.closest('.hthb-notification').width(); 248 249 this.closest('.hthb-notification').removeClass('hthb-state--minimized'); 250 this.closest('.hthb-notification').addClass('hthb-state--open'); 251 252 if(postion != 'left-wall' && postion != 'right-wall'){ 253 this.closest('.hthb-notification').find('.hthb-row').slideToggle(); 254 } 255 256 if( postion == 'top' ){ 257 $('body').addClass('hthb hthb-pt--'+ top_notification_height ); 258 259 // for sticky 260 if( this.get_transparent_selector() ){ 261 $(this.get_transparent_selector()).addClass('hthb-top-unset'); 262 $(this.get_transparent_selector()).css({'top': 'unset'}); 263 } 264 } else if( postion == 'bottom' ){ 265 $('body').css('padding-bottom', bottom_notification_height + 'px'); 266 } else if( postion == 'left-wall' ){ 267 this.closest('.hthb-notification').css('left', ''); 268 } else if( postion == 'right-wall' ){ 269 this.closest('.hthb-notification').css('right', ''); 270 } 271 } 272 273 $.fn.trigger_click_on_open_button = function(){ 274 $(this).addClass('hthb-trigger-open-clicked').removeClass('hthb-trigger-close-clicked'); 275 $(this).find('.hthb-open-toggle').trigger('click'); 276 } 277 278 $.fn.trigger_click_on_close_button = function(){ 279 $(this).removeClass('hthb-trigger-open-clicked').addClass('hthb-trigger-close-clicked'); 280 $(this).find('.hthb-close-toggle').trigger('click'); 281 } 282 283 $.fn.check_keep_close_bar = function(id){ 284 var keep_closed_bar = Cookies.get(`keep_closed_bar_${id}`); 285 if( hashbar_localize.bar_keep_closed === '1' && keep_closed_bar){ 286 return false;
287 }else{ 288 return true; 289 } 290 } 291 292 $.fn.trigger_notification_on_scroll = function( id, scroll_to_show, scroll_to_hide, current_scroll_position, scroll_pos_max ){ 293 if( (scroll_to_show && typeof scroll_to_show == 'string' && scroll_to_show.indexOf('%')) > 0 && (scroll_to_hide && typeof scroll_to_hide == 'string' && scroll_to_hide.indexOf('%')) > 1 ){ 294 scroll_to_show = Number.parseInt(scroll_to_show); 295 scroll_to_hide = Number.parseInt(scroll_to_hide); 296 // 20% , 80% 297 // console.log(1,scroll_to_show,scroll_to_hide,current_scroll_position, percent_of(scroll_to_hide, scroll_pos_max)); 298 299 if(current_scroll_position > percent_of(scroll_to_show, scroll_pos_max) && current_scroll_position < percent_of(scroll_to_hide, scroll_pos_max) ){ 300 if( !$(this).is('.hthb-state--open') && !$(this).is('.hthb-trigger-open-clicked') ){ 301 if($(this).check_keep_close_bar(id)){ 302 $(this).trigger_click_on_open_button(); // show 303 } 304 } 305 } else{ 306 if( !$(this).is('.hthb-state--minimized') ){ 307 $(this).trigger_click_on_close_button(); // hide 308 } 309 } 310 } else if( (scroll_to_show && typeof scroll_to_show == 'string' && scroll_to_show.indexOf('%')) && (scroll_to_hide === '' || scroll_to_hide == undefined) ){ 311 scroll_to_show = Number.parseInt(scroll_to_show); 312 // 20% , ''/undefined 313 // console.log(2,scroll_to_show,scroll_to_hide,current_scroll_position, percent_of(scroll_to_hide, scroll_pos_max)); 314 315 if( current_scroll_position > percent_of(scroll_to_show, scroll_pos_max) ){ 316 if( !$(this).is('.hthb-state--open') && !$(this).is('.hthb-trigger-open-clicked') ){ 317 if($(this).check_keep_close_bar(id)){ 318 $(this).trigger_click_on_open_button(); // show 319 } 320 } 321 } else { 322 if( !$(this).is('.hthb-state--minimized') ){ 323 $(this).trigger_click_on_close_button(); // hide 324 } 325 } 326 } else if( (scroll_to_show && typeof scroll_to_show == 'number') && (scroll_to_hide && typeof scroll_to_hide == 'string')){ 327 // 300 , 80% 328 // console.log(3,scroll_to_show,scroll_to_hide,current_scroll_position, percent_of(scroll_to_hide, scroll_pos_max)); 329 330 if( current_scroll_position > scroll_to_show && current_scroll_position < percent_of(scroll_to_hide, scroll_pos_max) ){ 331 if( !$(this).is('.hthb-state--open') && !$(this).is('.hthb-trigger-open-clicked') ){ 332 if($(this).check_keep_close_bar(id)){ 333 $(this).trigger_click_on_open_button(); // show 334 } 335 } 336 } else{ 337 if( !$(this).is('.hthb-state--minimized') ){ 338 $(this).trigger_click_on_close_button(); // hide 339 } 340 } 341 342 } else if( (scroll_to_show === '' || scroll_to_show == undefined) && (scroll_to_hide && typeof scroll_to_hide == 'string' && scroll_to_hide.indexOf('%')) ){ 343 scroll_to_hide = Number.parseInt(scroll_to_hide); 344 // empty / undefined , 90% 345 // console.log(4,scroll_to_show,scroll_to_hide,current_scroll_position, percent_of(scroll_to_hide, scroll_pos_max)); 346 347 if( current_scroll_position > percent_of(scroll_to_hide, scroll_pos_max) ){ 348 if( !$(this).is('.hthb-state--minimized') ){ 349 $(this).trigger_click_on_close_button(); // hide 350 } 351 } else{ 352 if( !$(this).is('.hthb-state--open') && !$(this).is('.hthb-trigger-open-clicked') ){ 353 if($(this).check_keep_close_bar(id)){ 354 $(this).trigger_click_on_open_button(); // show 355 } 356 } 357 } 358 359 } else if( (scroll_to_show && typeof scroll_to_show == 'number') && (scroll_to_hide === '' || scroll_to_hide == undefined) ){ 360 // 300 , empty/undefined 361 // console.log(5,scroll_to_show,scroll_to_hide,current_scroll_position, percent_of(scroll_to_hide, scroll_pos_max)); 362 if( current_scroll_position < scroll_to_show ){ 363 if( !$(this).is('.hthb-state--minimized') ){ 364 $(this).trigger_click_on_close_button(); // hide 365 } 366 367 } else{ 368 if( !$(this).is('.hthb-state--open') && !$(this).is('.hthb-trigger-open-clicked') ){ 369 if($(this).check_keep_close_bar(id)){ 370 $(this).trigger_click_on_open_button(); // show 371 } 372 } 373 } 374 375 } else { 376 console.log(`Invalid formate Scroll to show=${typeof scroll_to_show} ${scroll_to_show } scroll_to_hide=${typeof scroll_to_hide} ${scroll_to_hide}`); 377 } 378 } 379 380 $(document).ready(function(){ 381 $(".hthb-countdown").each(function(){ 382 var countdown_id = "#"+$(this).attr('id')+" .hthb-countdown-section .hthb-countdown-wrap", 383 finalDate = $(countdown_id).data('countdown'), 384 customLabel = $(countdown_id).data('custom_label'); 385 $(countdown_id).countdown(finalDate, function (event) { 386 $(countdown_id+' .countdown-day').html(event.strftime('%D')); 387 $(countdown_id+' .countdown-day-text').html(customLabel.day); 388 $(countdown_id+' .countdown-hour').html(event.strftime('%H')); 389 $(countdown_id+' .countdown-hour-text').html(customLabel.hour); 390 $(countdown_id+' .countdown-minute').html(event.strftime('%M')); 391 $(countdown_id+' .countdown-minite-text').html(customLabel.min); 392 $(countdown_id+' .countdown-second').html(event.strftime('%S')); 393 $(countdown_id+' .countdown-second-text').html(customLabel.sec); 394 }); 395 }); 396 397 }); 398})(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.