https://friendsofpatdyer.com/wp-content/themes/candidate-tmp-7/lib/scripts/main.js?ver=1.26.08.25.01
1(function($){ 2 3 $(document).ready(function(){ 4 5 $('a[href^="#"]').smoothScroll({ 6 speed: 400, 7 offset: -$('.site-header').height() 8 }); 9 10 /* = Site Header 11 ---------------------------------------------------- */ 12 13 $('.site-header.splash').adjustSplashHeader(); 14 $('.site-header.landing').adjustDefaultHeader(); 15 $('.site-header.default').adjustDefaultHeader(); 16 17 $('.navigation-button').click(function(){ 18 $('.navigation-button').toggleClass('closed opened'); 19 $('.site-navigation').slideToggle(200); 20 }); 21 22 $('html').click(function(e){ 23 24 if ($('.navigation-button').is(':visible') && 25 $('.navigation-button').hasClass('opened')) { 26 27 if ($(e.target).is('.site-navigation a[href^="#"]') || 28 ($(e.target).closest('.site-navigation').length == 0 && 29 !$(e.target).parent().hasClass('navigation-button') && 30 !$(e.target).hasClass('navigation-button'))) { 31 32 $('.navigation-button').toggleClass('closed opened'); 33 $('.site-navigation').slideUp(200); 34 } 35 } 36 }); 37 38 if ($('.main-nav-bar.use-sticky').length) { 39 var menu_top = $('.main-nav-bar.use-sticky').offset().top; 40 $(window).on('scroll', function() { 41 if ($(window).scrollTop() > menu_top) { 42 $('.main-nav-bar.use-sticky').addClass('sticky'); 43 } else { 44 $('.main-nav-bar.use-sticky').removeClass('sticky'); 45 } 46 }) 47 } 48 49 /* = Shortcuts 50 ---------------------------------------------------- */ 51 52 $('.shortcuts-inner').each(function(){ 53 54 if ($(this).children('.shortcut').css('display') == 'inline-block') { 55 56 var k = $(this).children('.shortcut').length; 57 var r, s = 0; 58 59 if ($(this).children('.shortcut').first().width() / $(this).width() < 0.3) r = 4; 60 else if ($(this).children('.shortcut').first().width() / $(this).width() < 0.4) r = 3; 61 else r = 2; 62 63 while (k > 0) { 64 65 $(this).children('.shortcut').slice(s,s+r).find('.shortcut-inner').equalHeight(); 66 67 k = Math.max(k-r, 0); 68 s = s+r; 69 } 70 } 71 }); 72 73 /* = Popup Images 74 ---------------------------------------------------- */ 75 76 $('a.fancybox').fancybox({ 77 prevEffect: 'fade', 78 nextEffect: 'fade', 79 helpers: { 80 overlay: { 81 locked: false 82 } 83 } 84 }); 85 86 /* = Countdowns initialization 87 ---------------------------------------------------- */ 88 if ($('.box-countdown').length) { 89 $('.box-countdown').each(function() { 90 var offset = new Date().getTimezoneOffset(); 91 var to_date = new Date($(this).data('date').replace(/\+\d{2}:\d{2}/, '')); 92 $('.box-counter-countdown', this).countDown(to_date); 93 }); 94 } 95 96 /* = scroll to Pledge form 97 ---------------------------------------------------- */ 98 $('.button-scroll-to-pledge-form').smoothScroll({ 99 scrollTarget: $('.page-sidebar'), 100 offset: -($('.site-header').offset().top + $('.site-header').height() + 10), 101 speed: 400 102 }); 103 104 105 /* = share popups 106 ---------------------------------------------------- */ 107 $(document).on('click', '.popup-share-open', function(e) { 108 e.preventDefault(); 109 window.open($(this).attr('href'), 'popupShareWindow', 'height=450, width=550, top=' + ($(window).height() / 2 - 275) + ', left=' + ($(window).width() / 2 - 225) + ', toolbar=0, location=0, menubar=0, directories=0, scrollbars=0'); 110 }); 111 112 /* = moneybomb box fixed on screen 113 ---------------------------------------------------- */ 114 if (!('ontouchstart' in window) && $('.moneybomb-ends').length) { 115 var $main = $('.page-content'); 116 var vertical_margins = 200; 117 118 $(window).on('scroll', function() { 119 var $box = $('.moneybomb-ends.active'); 120 if ($box.length) { 121 var scrollTop = $(window).scrollTop(); 122 123 if (scrollTop > 0) { 124 var box_top = $box.offset().top - parseInt($box.css('margin-top')); 125 var box_bottom = box_top + $box.outerHeight(); 126 127 var mt = scrollTop - box_top + vertical_margins; 128 var new_box_bottom = box_bottom + mt; 129 130 var main_bottom = $main.offset().top + $main.outerHeight(); 131 if (new_box_bottom + vertical_margins > main_bottom) { 132 mt -= new_box_bottom + vertical_margins - main_bottom; 133 } 134 } else { 135 mt = 0; 136 } 137 138 if (mt>=0) { 139 $box.css('margin-top', mt); 140 } 141 142 } 143 }).trigger('scroll'); 144 145 } else if ($('.moneybomb-ends').length) { 146 $('.moneybomb-ends.active').css('margin-top', ''); 147 } 148 149 /* = open google map when voting location clicked 150 ---------------------------------------------------- */ 151 $(document).on('click', '.voting-location', function(e) { 152 e.preventDefault(); 153 var address = $(this).data('address'); 154 if (address) { 155 window.open('https://maps.google.com/?daddr='+address, '_blank'); 156 } 157 }) 158 159 }); 160 161 $(window).resize(function(){ 162 163 /* = Site Header 164 ---------------------------------------------------- */ 165 166 $('.site-header.splash').adjustSplashHeader(); 167 $('.site-header.landing').adjustDefaultHeader(); 168 $('.site-header.default').adjustDefaultHeader(); 169 170 /* = Shortcuts 171 ---------------------------------------------------- */ 172 173 $('.shortcuts-inner').each(function(){ 174 175 if ($(this).children('.shortcut').css('display') == 'inline-block') { 176 177 var k = $(this).children('.shortcut').length; 178 var r, s = 0; 179 180 if ($(this).children('.shortcut').first().width() / $(this).width() < 0.3) r = 4; 181 else if ($(this).children('.shortcut').first().width() / $(this).width() < 0.4) r = 3; 182 else r = 2; 183 184 while (k > 0) { 185 186 $(this).children('.shortcut').slice(s,s+r).find('.shortcut-inner') 187 .css('height', 'auto') 188 .equalHeight(); 189 190 k = Math.max(k-r, 0); 191 s = s+r; 192 } 193 194 } else { 195 196 $(this).find('.shortcut-inner') 197 .css('height', 'auto'); 198 } 199 200 }); 201 202 }); 203 204 $(window).scroll(function(){ 205 206 $('.site-header.landing').adjustDefaultHeader(); 207 $('.site-header.default').adjustDefaultHeader(); 208 209 }); 210 211 /* = Helpers 212 ---------------------------------------------------- */ 213 214 $.fn.adjustSplashHeader = function(){ 215 216 $(this).each(function(){ 217 218 var header = $(this); 219 220 header.imagesLoaded(function(){ 221 222 if (window.innerWidth > 767) { 223 224 // remove 'min-height' value which 225 // might have been set in mobile version 226 $('.site-header-banner').removeAttr('style'); 227 228 $('.site-header-banner').height($(window).height()-$('.site-header-main').outerHeight()); 229 230 // splash page 231 if (header.find('.newsletter-form').length) { 232 233 header.find('.site-header-main-top-right.first').append(header.find('.site-header-banner-inner .social-buttons')); 234 header.find('.site-header-main-top-right.second').append(header.find('.site-header-banner-inner .donate-button-container')); 235 236 // petition page 237 } else { 238 239 header.find('.site-header-main-top-right.first').append(header.find('.site-header-banner-inner .essb_links')); 240 header.find('.site-header-main-top-right.second').append(header.find('.site-header-banner-inner .donate-button-container')); 241 } 242 243 } else { 244 245 $('.site-header-banner').css({ 246 'min-height': $(window).height()-$('.site-header-main').height(), 247 'height': 'auto' 248 });
249 250 // splash page 251 if (header.find('.newsletter-form').length) { 252 253 header.find('.site-header-main-top .donate-button-container').insertAfter($('.newsletter-form')); 254 header.find('.site-header-main-top .social-buttons').insertAfter($('.newsletter-form')); 255 256 // petition page 257 } else { 258 259 header.find('.site-header-main-top .donate-button-container').insertAfter($('.petition-form')); 260 header.find('.site-header-main-top .essb_links').insertAfter($('.petition-form')); 261 } 262 } 263 264 if ($('.site-container-loader').is(':visible')) 265 $('.site-container-loader').fadeOut(800); 266 267 }); 268 }); 269 } 270 271 $.fn.adjustDefaultHeader = function(){ 272 273 // -- sticky header 274 275 if ($(this).hasClass('sticky')) { 276 277 // get main container 278 var header = $(this).find('.site-header-main'); 279 280 // get inner container 281 var inner = header.find('.site-header-main-outer'); 282 283 // if we are close to the top 284 if ($(window).scrollTop() < 300) { 285 286 if (inner.css('position') != 'static') { 287 288 inner.stop().css({ 289 position: '', 290 top: '' 291 }); 292 293 header 294 .removeAttr('style') 295 .removeClass('fixed'); 296 } 297 298 } else { 299 300 var height = inner.outerHeight(); 301 302 // add class 303 if (!header.hasClass('fixed')) { 304 305 header 306 .height(height) 307 .addClass('fixed'); 308 } 309 310 // slide up/down 311 if ($(window).scrollTop() < 500) { 312 313 if (inner.css('position') != 'fixed') { 314 315 inner.stop().css({ 316 position: 'fixed', 317 top: '-'+height+'px' 318 }); 319 } 320 321 else inner.stop().animate({'top': '-'+height+'px'}, 300); 322 323 } else { 324 325 var t = 0; 326 327 if ($('body').hasClass('admin-bar')) { 328 if (window.innerWidth > 782) t = 32; 329 else t = 46; 330 } 331 332 if (inner.css('position') != 'fixed') { 333 334 inner.stop().css({ 335 position: 'fixed', 336 top: '-'+height+'px' 337 }); 338 } 339 340 inner.stop().animate({'top': t+'px'}, 300); 341 } 342 } 343 } 344 345 // -- social / donate buttons 346 347 if (window.innerWidth > 767) { 348 349 $('.site-header-main-top-right.first').append($(this).find('.site-header-mobile-panel-inner .social-buttons')); 350 $('.site-header-main-top-right.second').append($(this).find('.site-header-mobile-panel-inner .donate-button-container')); 351 352 } else { 353 354 var container = $('.site-header-mobile-panel-inner'); 355 356 container.append($(this).find('.site-header-main-top .social-buttons')); 357 container.append($(this).find('.site-header-main-top .donate-button-container')); 358 } 359 } 360 361 // set equal columns height 362 $.fn.equalHeight = function(){ 363 var height = 0; 364 var tallest = 0; 365 $(this).each(function(){ 366 height = $(this).outerHeight(); 367 if (height > tallest) 368 tallest = height; 369 }); 370 $(this).outerHeight(tallest); 371 return tallest; 372 } 373 374 $.fn.equalActualHeight = function(){ 375 var height = 0; 376 var tallest = 0; 377 $(this).each(function(){ 378 height = $(this).actual('height'); 379 if (height > tallest) 380 tallest = height; 381 }); 382 $(this).height(tallest); 383 return tallest; 384 } 385 386 // countdown timer 387 $.fn.countDown = function(to_date) { 388 var $elem = $(this); 389 var now_date = new Date(); 390 var countdown_data = {}; 391 var difference = (to_date - now_date); 392 393 if (difference>0) { 394 countdown_data['Day'] = Math.floor(difference/(1000*60*60*24)); 395 difference -= countdown_data['Day']*1000*60*60*24; 396 countdown_data['Hr'] = Math.floor(difference/(1000*60*60)); 397 difference -= countdown_data['Hr']*1000*60*60; 398 countdown_data['Min'] = Math.floor(difference/(1000*60)); 399 difference -= countdown_data['Min']*1000*60; 400 countdown_data['Sec'] = Math.floor(difference/1000); 401 402 var cdn_html = ''; 403 for (var label in countdown_data) { 404 if (countdown_data.hasOwnProperty(label)) { 405 var text_label = (countdown_data[label] == 1) ? label : (label + 's'); 406 cdn_html += '<span class="countdown-' + label + '">' + countdown_data[label] + ' <small class="countdown-label">' + text_label + '</small></span>'; 407 } 408 } 409 410 $elem.html(cdn_html); 411 $elem.parent().addClass('active'); 412 413 setTimeout(function() { 414 $elem.countDown(to_date); 415 }, 1000); 416 } else { 417 $elem.parent().removeClass('active').addClass('inactive'); 418 } 419 } 420 421})(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.