1if (typeof AveryDennison === 'undefined') { 2 var AveryDennison = {}; 3} 4 5AveryDennison.Text = { 6 CONST: { 7 HREF: 'href', 8 CLICK: 'onClick', 9 RTE_ANCHOR: '.rte-text-p a', 10 DOC_EXT_FILES: 'pdf|zip' 11 }, 12 13 init: function() { 14 $(AveryDennison.Text.CONST.RTE_ANCHOR).each(function() { 15 var $a = $(this); 16 if (typeof $a.attr(AveryDennison.Text.CONST.HREF) !== 'undefined') { 17 var url = $a.attr(AveryDennison.Text.CONST.HREF); 18 if (typeof $a.attr(AveryDennison.Text.CONST.CLICK) === 'undefined') { 19 var fileExt = url.split('.').pop(); 20 if (fileExt.match(AveryDennison.Text.CONST.DOC_EXT_FILES)) { 21 $a.attr(AveryDennison.Text.CONST.CLICK, "javascript:ga('send', 'event', 'Document', 'Download','" + url + "');"); 22 } else { 23 $a.attr(AveryDennison.Text.CONST.CLICK, "javascript:ga('send', 'event', 'Referral link', 'click','" + url + "');"); 24 } 25 } 26 } 27 }); 28 } 29}; 30 31$(document).ready(function() { 32 AveryDennison.Text.init(); 33}); 34if (typeof AveryDennison === 'undefined') { 35 var AveryDennison = {}; 36} 37 38AveryDennison.WrapTrainingRegisterFormOnc = { 39 init: function() { 40 41 var trainingName = $('#training-name').data('trainingName'); 42 var trainingLocation = $('#training-location').data('trainingLocation'); 43 var postbackUrl = $('#postback-url').data('postbackUrl'); 44 var trainingPrice = $('#training-price').data('trainingPrice'); 45 var trainingDate = $('#training-date').data('trainingDate'); 46 var trainingType = $('#training-type').data('trainingType'); 47 var trainingProvider = $('#training-provider').data('trainingProvider'); 48 var trainingInstructor = $('#training-instructor').data('trainingInstructor'); 49 var trainingPath = $('#training-path').data('trainingPath'); 50 var trainingCapacity = $('#training-capacity').data('trainingCapacity'); 51 var trainingCurrentCount = $('#training-current-count').data('trainingCurrentCount'); 52 53 var emailTemplate = $('#email-template').data('emailTemplate'); 54 var confirmationPath = $('#confirmation-path').data('confirmationPath'); 55 var formID = "wrapTrainingRegistrationForm"; 56 var errorText = "This field is required."; 57 var errorMarkup = "<div class=\"form_row form_error\"><div class=\"form_leftcol\"><div class=\"form_leftcollabel\">"; 58 errorMarkup = errorMarkup + "<span> </span></div><div class=\"form_leftcolmark\"> </div>"; 59 errorMarkup = errorMarkup + "</div><div class=\"form_rightcol form_error\">" + errorText + "</div></div>"; 60 61 var company_name = $("#" + formID + " input[id=company_name]"); 62 63 $("#" + formID).submit(function() { 64 if (!formvalidate()){ 65 return false; 66 } 67 }); 68 69 AveryDennison.WrapTrainingRegisterFormOnc.evalSeatCapacity(trainingCapacity, trainingCurrentCount); 70 71 // Validates all required inputs 72 var formvalidate = function() { 73 var validate = true; 74 var i = 1; 75 var mainName = ""; 76 var mainInfo = ""; 77 var otherInfo = ""; 78 var trainingInfo = ""; 79 var amount; 80 81 trainingInfo = "&trainingName=" + trainingName; 82 trainingInfo = trainingInfo + "&" + "trainingLocation=" + trainingLocation; 83 trainingInfo = trainingInfo + "&" + "trainingDates=" + trainingDate; 84 trainingInfo = trainingInfo + "&" + "trainingType=" + trainingType; 85 trainingInfo = trainingInfo + "&" + "trainingProvider=" + trainingProvider; 86 trainingInfo = trainingInfo + "&" + "trainingInstructor=" + trainingInstructor; 87 trainingInfo = trainingInfo + "&" + "trainingPath=" + trainingPath; 88 trainingInfo = trainingInfo + "&" + "company_name=" + company_name.val(); 89 90 $("#" + formID + " input.required").each(function() { 91 var inputValue = $(this).val(); 92 mainInfo = mainInfo + "&" + $(this).attr("name") + "=" + inputValue ; 93 if (inputValue == null || inputValue == ""){ 94 $(this).parents(".section.text").append($(errorMarkup)); 95 validate = false; 96 }; 97 }); 98 99 // if name[n] is not null, email[n] is required 100 $("#" + formID + " input[id^=name]").each(function(){ 101 var inputValue = $(this).val(); 102 if (inputValue != null && inputValue != ""){ 103 i++; 104 var nameId = $(this).attr("id"); 105 var num = nameId.substr(nameId.length-1,1); 106 if (!isNaN(num)) { 107 var email = $("#" + formID + " input[id=email" + num + "]"); 108 otherInfo = otherInfo + "&name" + i + "=" + inputValue + "&email" + i + "=" + email.val(); 109 if (email != null && email != "" ) { 110 if (email.val() == "") { 111 email.parents(".wt-form-input").append($(errorMarkup)); 112 validate = false; 113 } 114 } 115 } 116 } 117 }); 118 119 amount = "&amount=" + trainingPrice * i; 120 var urlWithParams = postbackUrl + emailTemplate + confirmationPath + trainingInfo + amount + mainInfo + otherInfo; 121 $("#" + formID + " input[name=ccPostbackUrl]").val(urlWithParams); 122 $("#" + formID + " input[name=ccAmount]").val(trainingPrice * i); 123 return validate; 124 }; 125 }, 126 127 evalSeatCapacity: function(trainingCapacity, trainingCurrentCount) { 128 var additionalRegistrantContainer = '.additional-registrations-container'; 129 var additionalRegistrantTitle = additionalRegistrantContainer + ' div.noBullet.short.space'; 130 var additionalRegistrantFields = additionalRegistrantContainer + ' div.row'; 131 var one_registrant = 1; 132 var additional_reg_count = parseInt(one_registrant) + parseInt(trainingCurrentCount); 133 134 if (trainingCapacity === additional_reg_count) { // at capacity, additional registrants not allowed 135 $(additionalRegistrantTitle).hide(); 136 } 137 138 // Compute additional registrant fields 139 $(additionalRegistrantFields).each(function() { 140 if (parseInt(additional_reg_count) < parseInt(trainingCapacity)) { 141 ++additional_reg_count; 142 } else { 143 $(this).hide(); // hide the registrant fields 144 } 145 }); 146 } 147}; 148 149$(document).ready(function() { 150 AveryDennison.WrapTrainingRegisterFormOnc.init(); 151}); 152 153if (typeof AveryDennison === 'undefined') { 154 var AveryDennison = {}; 155} 156 157AveryDennison.WrapTrainingRegisterForm = { 158 init: function() { 159 160 var trainingName = $('#training-name').data('trainingName'); 161 var trainingLocation = $('#training-location').data('trainingLocation'); 162 var postbackUrl = $('#postback-url').data('postbackUrl'); 163 var trainingPrice = $('#training-price').data('trainingPrice'); 164 var trainingDate = $('#training-date').data('trainingDate'); 165 var trainingType = $('#training-type').data('trainingType'); 166 var trainingProvider = $('#training-provider').data('trainingProvider'); 167 var trainingInstructor = $('#training-instructor').data('trainingInstructor'); 168 var trainingPath = $('#training-path').data('trainingPath'); 169 var trainingCapacity = $('#training-capacity').data('trainingCapacity'); 170 var trainingCurrentCount = $('#training-current-count').data('trainingCurrentCount'); 171 172 var emailTemplate = $('#email-template').data('emailTemplate'); 173 var confirmationPath = $('#confirmation-path').data('confirmationPath'); 174 var formID = "wrapTrainingRegistrationForm"; 175 var errorText = "This field is required."; 176 var errorMarkup = "<div class=\"form_row form_error\"><div class=\"form_leftcol\"><div class=\"form_leftcollabel\">"; 177 errorMarkup = errorMarkup + "<span> </span></div><div class=\"form_leftcolmark\">
177 </div>"; 178 errorMarkup = errorMarkup + "</div><div class=\"form_rightcol form_error\">" + errorText + "</div></div>"; 179 180 var company_name = $("#" + formID + " input[id=company_name]"); 181 182 $("#" + formID).submit(function() { 183 if (!formvalidate()){ 184 return false; 185 } 186 }); 187 188 AveryDennison.WrapTrainingRegisterForm.evalSeatCapacity(trainingCapacity, trainingCurrentCount); 189 190 // Validates all required inputs 191 var formvalidate = function() { 192 var validate = true; 193 var i = 1; 194 var mainName = ""; 195 var mainInfo = ""; 196 var otherInfo = ""; 197 var trainingInfo = ""; 198 var amount; 199 200 trainingInfo = "&trainingName=" + trainingName; 201 trainingInfo = trainingInfo + "&" + "trainingLocation=" + trainingLocation; 202 trainingInfo = trainingInfo + "&" + "trainingDates=" + trainingDate; 203 trainingInfo = trainingInfo + "&" + "trainingType=" + trainingType; 204 trainingInfo = trainingInfo + "&" + "trainingProvider=" + trainingProvider; 205 trainingInfo = trainingInfo + "&" + "trainingInstructor=" + trainingInstructor; 206 trainingInfo = trainingInfo + "&" + "trainingPath=" + trainingPath; 207 trainingInfo = trainingInfo + "&" + "company_name=" + company_name.val(); 208 209 $("#" + formID + " input.required").each(function() { 210 var inputValue = $(this).val(); 211 mainInfo = mainInfo + "&" + $(this).attr("name") + "=" + inputValue ; 212 if (inputValue == null || inputValue == ""){ 213 $(this).parents(".section.text").append($(errorMarkup)); 214 validate = false; 215 }; 216 }); 217 218 // if name[n] is not null, email[n] is required 219 $("#" + formID + " input[id^=name]").each(function(){ 220 var inputValue = $(this).val(); 221 if (inputValue != null && inputValue != ""){ 222 i++; 223 var nameId = $(this).attr("id"); 224 var num = nameId.substr(nameId.length-1,1); 225 if (!isNaN(num)) { 226 var email = $("#" + formID + " input[id=email" + num + "]"); 227 otherInfo = otherInfo + "&name" + i + "=" + inputValue + "&email" + i + "=" + email.val(); 228 if (email != null && email != "" ) { 229 if (email.val() == "") { 230 email.parents(".wt-form-input").append($(errorMarkup)); 231 validate = false; 232 } 233 } 234 } 235 } 236 }); 237 238 amount = "&amount=" + trainingPrice * i; 239 var urlWithParams = postbackUrl + emailTemplate + confirmationPath + trainingInfo + amount + mainInfo + otherInfo; 240 $("#" + formID + " input[name=ccPostbackUrl]").val(urlWithParams); 241 $("#" + formID + " input[name=ccAmount]").val(trainingPrice * i); 242 return validate; 243 }; 244 }, 245 246 evalSeatCapacity: function(trainingCapacity, trainingCurrentCount) { 247 var additionalRegistrantContainer = '.additional-registrations-container'; 248 var additionalRegistrantTitle = additionalRegistrantContainer + ' div.noBullet.short.space'; 249 var additionalRegistrantFields = additionalRegistrantContainer + ' div.row'; 250 var one_registrant = 1; 251 var additional_reg_count = parseInt(one_registrant) + parseInt(trainingCurrentCount); 252 253 if (trainingCapacity === additional_reg_count) { // at capacity, additional registrants not allowed 254 $(additionalRegistrantTitle).hide(); 255 } 256 257 // Compute additional registrant fields 258 $(additionalRegistrantFields).each(function() { 259 if (parseInt(additional_reg_count) < parseInt(trainingCapacity)) { 260 ++additional_reg_count; 261 } else { 262 $(this).hide(); // hide the registrant fields 263 } 264 }); 265 } 266}; 267 268$(document).ready(function() {
269 AveryDennison.WrapTrainingRegisterForm.init(); 270}); 271 272if (typeof AveryDennison === 'undefined') { 273 var AveryDennison = {}; 274} 275 276AveryDennison.WrapTrainingRegisterForm = { 277 init: function() { 278 279 var trainingName = $('#training-name').data('trainingName'); 280 var trainingLocation = $('#training-location').data('trainingLocation'); 281 var postbackUrl = $('#postback-url').data('postbackUrl'); 282 var trainingPrice = $('#training-price').data('trainingPrice'); 283 var trainingDate = $('#training-date').data('trainingDate'); 284 var trainingType = $('#training-type').data('trainingType'); 285 var trainingProvider = $('#training-provider').data('trainingProvider'); 286 var trainingInstructor = $('#training-instructor').data('trainingInstructor'); 287 var trainingPath = $('#training-path').data('trainingPath'); 288 var trainingCapacity = $('#training-capacity').data('trainingCapacity'); 289 var trainingCurrentCount = $('#training-current-count').data('trainingCurrentCount'); 290 291 var emailTemplate = $('#email-template').data('emailTemplate'); 292 var confirmationPath = $('#confirmation-path').data('confirmationPath'); 293 var formID = "wrapTrainingRegistrationForm"; 294 var errorText = "This field is required."; 295 var errorMarkup = "<div class=\"form_row form_error\"><div class=\"form_leftcol\"><div class=\"form_leftcollabel\">"; 296 errorMarkup = errorMarkup + "<span> </span></div><div class=\"form_leftcolmark\"> </div>"; 297 errorMarkup = errorMarkup + "</div><div class=\"form_rightcol form_error\">" + errorText + "</div></div>"; 298 299 var company_name = $("#" + formID + " input[id=company_name]"); 300 301 $("#" + formID).submit(function() { 302 if (!formvalidate()){ 303 return false; 304 } 305 }); 306 307 AveryDennison.WrapTrainingRegisterForm.evalSeatCapacity(trainingCapacity, trainingCurrentCount); 308 309 // Validates all required inputs 310 var formvalidate = function() { 311 var validate = true; 312 var i = 1; 313 var mainName = ""; 314 var mainInfo = ""; 315 var otherInfo = ""; 316 var trainingInfo = ""; 317 var amount; 318 319 trainingInfo = "&trainingName=" + trainingName; 320 trainingInfo = trainingInfo + "&" + "trainingLocation=" + trainingLocation; 321 trainingInfo = trainingInfo + "&" + "trainingDates=" + trainingDate; 322 trainingInfo = trainingInfo + "&" + "trainingType=" + trainingType; 323 trainingInfo = trainingInfo + "&" + "trainingProvider=" + trainingProvider; 324 trainingInfo = trainingInfo + "&" + "trainingInstructor=" + trainingInstructor; 325 trainingInfo = trainingInfo + "&" + "trainingPath=" + trainingPath; 326 trainingInfo = trainingInfo + "&" + "company_name=" + company_name.val(); 327 328 $("#" + formID + " input.required").each(function() { 329 var inputValue = $(this).val(); 330 mainInfo = mainInfo + "&" + $(this).attr("name") + "=" + inputValue ; 331 if (inputValue == null || inputValue == ""){ 332 $(this).parents(".section.text").append($(errorMarkup)); 333 validate = false; 334 }; 335 }); 336 337 // if name[n] is not null, email[n] is required 338 $("#" + formID + " input[id^=name]").each(function(){ 339 var inputValue = $(this).val(); 340 if (inputValue != null && inputValue != ""){ 341 i++; 342 var nameId = $(this).attr("id"); 343 var num = nameId.substr(nameId.length-1,1); 344 if (!isNaN(num)) { 345 var email = $("#" + formID + " input[id=email" + num + "]"); 346 otherInfo = otherInfo + "&name" + i + "=" + inputValue + "&email" + i + "=" + email.val(); 347 if (email != null && email != "" ) { 348 if (email.val() == "") { 349 email.parents(".wt-form-input").append($(errorMarkup)); 350 validate = false; 351 } 352 } 353 } 354 } 355 }); 356 357 amount = "&amount=" + trainingPrice * i; 358 var urlWithParams = postbackUrl + emailTemplate + confirmationPath + trainingInfo + amount + mainInfo + otherInfo; 359 $("#" + formID + " input[name=ccPostbackUrl]").val(urlWithParams); 360 $("#" + formID + " input[name=ccAmount]").val(trainingPrice * i); 361 return validate; 362 }; 363 }, 364 365 evalSeatCapacity: function(trainingCapacity, trainingCurrentCount) { 366 var additionalRegistrantContainer = '.additional-registrations-container'; 367 var additionalRegistrantTitle = additionalRegistrantContainer + ' div.noBullet.short.space'; 368 var additionalRegistrantFields = additionalRegistrantContainer + ' div.row'; 369 var one_registrant = 1; 370 var additional_reg_count = parseInt(one_registrant) + parseInt(trainingCurrentCount); 371 372 if (trainingCapacity === additional_reg_count) { // at capacity, additional registrants not allowed 373 $(additionalRegistrantTitle).hide(); 374 } 375 376 // Compute additional registrant fields 377 $(additionalRegistrantFields).each(function() { 378 if (parseInt(additional_reg_count) < parseInt(trainingCapacity)) { 379 ++additional_reg_count; 380 } else { 381 $(this).hide(); // hide the registrant fields 382 } 383 }); 384 } 385}; 386 387$(document).ready(function() {
388 AveryDennison.WrapTrainingRegisterForm.init(); 389}); 390 391$.fn.startCarousel = function(element) { 392 393 var enableAutoScroll = element.find("#lpm-autoScroll").text(); 394 var autoScrollSeconds = Number(element.find("#lpm-autoScroll-seconds").text()) * 1000; 395 396 if (autoScrollSeconds < 1000) { 397 autoScrollSeconds = 2000; 398 } 399 400 if (enableAutoScroll === 'true') { 401 402 var currentPage = 1; 403 var autoScroll = setInterval(function() { carousel(currentPage, element) }, autoScrollSeconds); 404 405 function carousel(index, element) { 406 var slideIndex = index; 407 var slides = element.find(".lpm-photoset .lpm-dots li").length; 408 409 //remove active from dots 410 element.find(".lpm-dots").children().removeClass('unslider-active'); 411 412 //remove active from image containers 413 element.find('.unslider-carousel').children().removeClass("unslider-active"); 414 415 //hide all images and overlays 416 element.find(".photoset-img").css("display", "none"); 417 element.find(".photoset-overlay").css("display", "none"); 418 419 //check if page is out of bounds 420 if (slideIndex > slides) { slideIndex = 1; 421 currentPage = 1; } 422 423 //set dot to active 424 element.find(".lpm-dots li:nth-child(" + slideIndex + ")").addClass('unslider-active'); 425 426 //set image container to active 427 element.find('#photoset-' + (slideIndex - 1)).parent().addClass("unslider-active"); 428 429 //show image 430 element.find('#photoset-' + (slideIndex - 1)).css("display", "block"); 431 element.find('#overlay-' + (slideIndex - 1)).css("display", "block"); 432 433 currentPage++; 434 } 435 } 436} 437 438$(document).ready(function() { 439 440 // automatic z-index assignment 441 if ($("#worldwideSites_mainContainer").length) { 442 var zIndexNumber = 1000; 443 $('#worldwideSites_sectionLinks li').each(function() { 444 $(this).css('zIndex', zIndexNumber); 445 zIndexNumber -= 10; 446 }); 447 } 448 449 /*Start WORLDWIDE SITES TOGGLE*/ 450 $('#lpmtoggleMenu2').click(function(e) { 451 console.log("click " + $('#lpmCustomerLinks').is(':visible')); 452 if ($(this).attr('href') === '#') { 453 e.preventDefault(); 454 if ($('#lpmCustomerLinks').is(':visible')) { 455 $('#lpmtoggleMenu2').css('background-image', 'url("../resources/img/icons/triangle-right.png")'); 456 457 $('#lpmCustomerLinks').slideUp('slow', function() { // Animation complete. 458 }); 459 $("#lpmoverlay").fadeTo("slow", 0, function() { $("#lpmoverlay").hide(); }); 460 } else { 461 $('#lpmtoggleMenu2').css('background-image', 'url("../resources/img/icons/triangle-down.png")'); 462 463 $('#lpmCustomerLinks').slideDown('slow', function() { // Animation complete. 464 }); 465 $("#lpmoverlay").show(); 466 $("#lpmoverlay").fadeTo("slow", 0.5); 467 } 468 } 469 470 }); 471 472 $('#toggleClose').click(function() { 473 $('#worldwideSites_mainContainer').slideUp('slow', function() { // Animation complete. 474 }); 475 $('#lpmCustomerLinks').slideUp('slow', function() { // Animation complete. 476 }); 477 $("#lpmoverlay").fadeTo("slow", 0); 478 $("#lpmoverlay").hide(); 479 }); 480 481 $("#lpmtoggleMenu").click(function() { 482 $(this).toggleClass("selected"); 483 }); 484 485 $("#lpmtoggleMenu2").click(function() { 486 var containerLocation = $(".avd-legacy .globalheader").offset(); 487 var leftAnchor = $(".lpm-nav-link").first(); 488 var leftAnchorPosition = leftAnchor.offset(); 489 var rightAnchor = $(this); 490 var rightAnchorPosition = rightAnchor.offset(); 491 var rightAnchorSize = rightAnchor.outerWidth(true); 492 var modalSize = (rightAnchorPosition.left - leftAnchorPosition.left + rightAnchorSize - 60 + 8); 493 $("#lpmCustomerLinks").css("width", modalSize + "px"); 494 $(this).toggleClass("selected"); 495 });
496 497 $("#toggleClose").click(function() { 498 $('#lpmtoggleMenu, #lpmtoggleMenu2').toggleClass("selected"); 499 }); 500 501 $('#toggleMenu').click(function() { 502 $('#lpmtoggleMenu2').css('background-image', 'url("../resources/img/icons/triangle-right.png")'); 503 504 $('#lpmCustomerLinks').slideUp('slow', function() { // Animation complete. 505 }); 506 $("#lpmoverlay").fadeTo("slow", 0, function() { $("#lpmoverlay").hide(); }); 507 }); 508 509 510 511 $('#lpmoverlay').click(function() { 512 console.log("click " + $('#lpmCustomerLinks').is(':visible')); 513 514 if ($('.searchIcon-modal').is(':visible')) { 515 $('.searchIcon-modal').css("display", "none"); 516 $("#lpmoverlay").hide(); 517 $('#lpmoverlay').css("opacity", "0"); 518 $('#lpmoverlay').css("z-index", "50"); 519 520 } else if ($('#lpmCustomerLinks').is(':visible')) { 521 $('#lpmtoggleMenu2').css('background-image', 'url("../resources/img/icons/triangle-right.png")'); 522 523 $('#lpmCustomerLinks').slideUp('slow', function() { // Animation complete. 524 }); 525 $("#lpmoverlay").fadeTo("slow", 0, function() { $("#lpmoverlay").hide(); }); 526 } else { 527 $('#lpmtoggleMenu2').css('background-image', 'url("../resources/img/icons/triangle-down.png")'); 528 529 $('#lpmCustomerLinks').slideDown('slow', function() { // Animation complete. 530 }); 531 $("#lpmoverlay").show(); 532 $("#lpmoverlay").fadeTo("slow", 0.5); 533 } 534 535 }); 536 537 /* SEARCH MODAL JS*/ 538 $('.searchIcon').click(function() { 539 var position = $(this).offset(); 540 var modalWidth = $('.searchIcon-modal .modal-content').width(); 541 var iconWidth = $(this).outerWidth(true); 542 var left = ((position.left - modalWidth) + iconWidth); 543 544 545 //$('.searchIcon-modal .modal-content').css("left",left); 546 //$('.searchIcon-modal .modal-content').css("top",position.top); 547 $('.searchIcon-modal').css("display", "block"); 548 $('#lpmoverlay').css("z-index", "70"); 549 $('#lpmoverlay').css("opacity", "0.5"); 550 $("#lpmoverlay").show(); 551 $("#headersearch input[name='q']").focus(); 552 }); 553 554 $('.modal-header-close').click(function() { 555 $('.searchIcon-modal').css("display", "none"); 556 $("#lpmoverlay").hide(); 557 $('#lpmoverlay').css("z-index", "50"); 558 }); 559 560 $('.searchIcon-modal').click(function(e) { 561 //$('.searchIcon-modal').css("display","none"); 562 //e.stopPropagation(); 563 }); 564 565 /*ADJUST MAX WITH FOR LINKS */ 566 $(".navmenu").each(function() { 567 var headerSize = $(".globalheader").width(); 568 console.log("headerSize: " + headerSize); 569 var headerLocation = $(".globalheader").offset(); 570 console.log("headerLocation: " + headerLocation.left); 571 var menuLocation = $(this).offset(); 572 console.log("menuLocation: " + menuLocation.left); 573 var maxSize = headerSize - (menuLocation.left - headerLocation.left) - 13; 574 $(this).find(".mainNavDrop ul").css("max-width", maxSize + "px"); 575 }); 576 577 /* CAROUSEL JS*/ 578 579 $(".photoset .lpm-photoset .unslider-nav ul li").each(function() { 580 $(this).css('width', '10px'); 581 }); 582 583 $(window).resize(function() { 584 var viewport = $(window).width(); 585 if (viewport < 768) { 586 $('.photoset').each(function() { 587 var container = $(this); 588 var dotsContainer = container.find(".unslider"); 589 var dotsContainerWidth = dotsContainer.outerWidth(true); 590 var dotSize = container.find(".lpm-dots li").first().outerWidth(true); 591 var dots = container.find(".lpm-dots li").length; 592 var offset = ((dotsContainerWidth - (dotSize * dots)) / 2); 593 container.find(".unslider").css("padding-left", offset + "px"); 594 }); 595 } else { 596 $(".unslider").css("padding-left", 0 + "px"); 597 } 598 }); 599 600 601 $('.photoset').each(function() { 602 var container = $(this); 603 604 container.find(".lpm-dots li").click({ param1: container }, function(e) { 605 606 var container = e.data.param1; 607 608 var imageId = $(this).attr('id'); 609 610 container.find(".lpm-dots").children().removeClass('unslider-active'); 611 612 //remove active from image containers 613 container.find('.unslider-carousel').children().removeClass("unslider-active"); 614 615 //hide all images and overlays 616 container.find(".photoset-img").css("display", "none"); 617 container.find(".photoset-overlay").css("display", "none"); 618 619 $(this).addClass('unslider-active'); 620 621 //set image container to active 622 container.find('#photoset-' + imageId).parent().addClass("unslider-active"); 623 624 //show image and overlay 625 container.find('#photoset-' + imageId).css("display", "block"); 626 container.find('#overlay-' + imageId).css("display", "block"); 627 628 }); 629 630 $('.infiniteCarousel').startCarousel(container); 631 });
632 633 $('.subnavtoggle').click(function(event) { 634 635 var subnavOpen = $(event.target); 636 var subnav = subnavOpen.parent().find(".subnav"); 637 638 if (subnav.is(':visible')) { 639 subnav.slideUp('fast', function() { // Animation complete. 640 $(event.target).html("+"); 641 }); 642 } else { 643 subnav.slideDown('fast', function() { // Animation complete. 644 $(event.target).html("-"); 645 }); 646 } 647 648 }); 649 650 651 $('button.avd-navbar').click(function(event) { 652 console.log("clicked navbar"); 653 if ($("#avd-worldwide-collapse").is(':visible')) { 654 console.log("clicking worldwide"); 655 $("button.avd-worldwide").click(); 656 } 657 }); 658 659 $('button.avd-worldwide').click(function(event) { 660 console.log("clicked worldwide"); 661 if ($("#avd-navbar-collapse").is(':visible')) { 662 console.log("clicking navbar"); 663 $("button.avd-navbar").click(); 664 } 665 }); 666 667}); 668window.AD_UTILS = window.AD_UTILS || {}; 669 670window.AD_UTILS.setCookie = function (name, value, days) { 671 672 var expires = ""; 673 674 if (days) { 675 var date = new Date(); 676 date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); 677 expires = "; expires=" + date.toUTCString(); 678 } 679 680 document.cookie = name + "=" + value + expires + "; path=/"; 681 682}; 683 684window.AD_UTILS.getCookie = function (name) { 685 686 var nameEQ = name + "="; 687 var ca = document.cookie.split(';'); 688 689 for (var i = 0; i < ca.length; i++) { 690 var c = ca[i]; 691 while (c.charAt(0) == ' ') c = c.substring(1, c.length); 692 if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length); 693 } 694 695 return null; 696 697}; 698 699(function($) { 700 $.fn.responsiveImageMaps = function() { 701 var $img = this; 702 703 var rwdImageMap = function() { 704 $img.each(function() { 705 if (typeof($(this).attr('usemap')) == 'undefined') 706 return; 707 708 var self = this, 709 $self = $(self); 710 711 $('<img />').on('load', function() { 712 var attrW = 'width', 713 attrH = 'height', 714 w = $self.attr(attrW), 715 h = $self.attr(attrH); 716 717 if (!w || !h) { 718 var temp = new Image(); 719 temp.src = $self.attr('src'); 720 if (!w) 721 w = temp.width; 722 if (!h) 723 h = temp.height; 724 } 725 726 var wPercent = $self.width()/100, 727 hPercent = $self.height()/100, 728 map = $self.attr('usemap').replace('#', ''), 729 c = 'coords'; 730 731 $('map[name="' + map + '"]').find('area').each(function() { 732 var $this = $(this); 733 if (!$this.data(c)) 734 $this.data(c, $this.attr(c)); 735 736 var coords = $this.data(c).split(','), 737 coordsPercent = new Array(coords.length); 738 739 for (var i = 0; i < coordsPercent.length; ++i) { 740 if (i % 2 === 0) 741 coordsPercent[i] = parseInt(((coords[i]/w)*100)*wPercent); 742 else 743 coordsPercent[i] = parseInt(((coords[i]/h)*100)*hPercent); 744 } 745 $this.attr(c, coordsPercent.toString()); 746 }); 747 }).attr('src', $self.attr('src')); 748 }); 749 }; 750 $(window).resize(rwdImageMap).trigger('resize'); 751 752 return this; 753 }; 754})(jQuery); 755 756(function ($) { 757 $.fn.lowFloat = function (options) { 758 var opts = $.extend({}, $.fn.lowFloat.defaultOptions, options); 759 this.each(function () { 760 var container = $(this).parent().closest(opts.container); 761 container.prepend(this); 762 $(this).css({'float': opts.cssFloat, 'clear': opts.cssFloat}); 763 $("<div>").addClass("lowFloat-spacer").css({'width': 0, 'float': opts.cssFloat}).insertBefore(this); 764 }); 765 var floaters = this; 766 $(window).on("resize resetLoaters", function () { 767 floaters.each(function () { 768 var floater = $(this); 769 var spacer = floater.prev(".lowFloat-spacer"); 770 if (spacer.css("display") === "block") { 771 var container = floater.parent(); 772 var lastContent = opts.bottomContent; 773 var floaterHeight = this.offsetHeight; 774 var h = Math.max(0, container.height() - floaterHeight); 775 spacer.height(h); 776 while (h > 0 && floater.offset().top + floaterHeight >
776 lastContent.offset().top + lastContent.height()) { 777 spacer.height(--h); 778 } 779 while (floater.offset().top + floaterHeight < lastContent.offset().top + lastContent.height()) { 780 spacer.height(++h); 781 } 782 } 783 }); 784 }).trigger("resize"); 785 return this; 786 }; 787 $.fn.lowFloat.defaultOptions = {container: "*", bottomContent: "> :last-child", cssFloat: "right"}; 788})(jQuery); 789 790$(function () { 791 $('img[usemap]').responsiveImageMaps(); 792}); 793var regionSelector = (function () { 794 var CONSTANTS = { 795 $AVAILABLE_LANGUAGES: '.available-languages', 796 $DROPDOWN_PANEL: '.dropdown-panel', 797 $DROPDOWN_PANEL_LANGUAGES: '.region-languages .dropdown-panel', 798 $DROPDOWN_TOGGLE: '.dropdown-toggle', 799 $DROPDOWN_TOGGLE_ICON: '.dropdown-toggle-icon', 800 $LANGUAGE_LINK: '.region-languages .link-container a', 801 $NAVBAR_TOGGLE: '.navbar-toggle.avd-navbar', 802 $REGION_SELECTOR: '.region-selector', 803 $REGION_SELECTOR_CLOSE: '.close-regional-selector', 804 $REGION_SELECTOR_TOGGLE: '.region-selector-toggle', 805 $REGION_TOGGLE: '.region-toggle', 806 COLLAPSED: 'collapsed', 807 COOKIE_REGION: 'region', 808 HIDE: 'hide', 809 REGION_TARGET: 'regionTarget', 810 WCMMODE_EDIT: 'wcmmode-edit' 811 }; 812 var regionSelectorToggle = function (rsElement) { 813 if ( $(rsElement).hasClass(CONSTANTS.HIDE) ) { 814 $('body').css('overflow-y', 'hidden'); 815 } else { 816 $('body').css('overflow-y', 'auto'); 817 } 818 $(rsElement).toggleClass(CONSTANTS.HIDE); 819 $(CONSTANTS.$REGION_SELECTOR_CLOSE).removeClass(CONSTANTS.HIDE); 820 }; 821 var openDropdown = function (panelTarget) { 822 $(panelTarget).slideDown(); 823 $(panelTarget).removeClass(CONSTANTS.COLLAPSED); 824 }; 825 var closeDropdowns = function (sp) { 826 $(CONSTANTS.$DROPDOWN_PANEL).slideUp(sp); 827 $(CONSTANTS.$DROPDOWN_PANEL).addClass(CONSTANTS.COLLAPSED); 828 $(CONSTANTS.$DROPDOWN_TOGGLE_ICON).text('+'); 829 }; 830 var openDropdowns = function (sp) { 831 $(CONSTANTS.$DROPDOWN_PANEL).slideDown(sp); 832 $(CONSTANTS.$DROPDOWN_PANEL).removeClass(CONSTANTS.COLLAPSED); 833 $(CONSTANTS.$DROPDOWN_TOGGLE_ICON).text('-'); 834 }; 835 var resizeControlDropdowns = function () { 836 var resizeTimer; 837 var oneFlag = false; 838 $(window).on('resize', function (e) { 839 var $window = $(this); 840 clearTimeout(resizeTimer); 841 resizeTimer = setTimeout(function () { 842 if ($window.width() > 768) { 843 openDropdowns(10); 844 oneFlag = true; 845 } else { 846 if (oneFlag) { 847 closeDropdowns(10); 848 oneFlag = false; 849 } 850 } 851 }, 10); 852 }); 853 }; 854 var hideLanguages = function () { 855 var $availableLanguages = $(CONSTANTS.$AVAILABLE_LANGUAGES); 856 $availableLanguages.addClass(CONSTANTS.HIDE); 857 }; 858 var showAvailableRegionLanguages = function (regionTarget) { 859 var $regionTarget = $(regionTarget); 860 $regionTarget.removeClass(CONSTANTS.HIDE); 861 }; 862 var setRegionCookie = function (region) { 863 var name = 'region'; 864 var value = region; 865 AD_UTILS.setCookie(name, value); 866 }; 867 var akamaiFlagCheck = function (element) { 868 var cookieRegion = AD_UTILS.getCookie(CONSTANTS.COOKIE_REGION); 869 var $regionSelector = $(element); 870 $.ajax({
871 url: '/bin/avery-lpm/akamai-header-check', 872 type: 'get', 873 async: false, 874 data: { 875 }, 876 success: function(data) { 877 if(!cookieRegion && data === 'false' ) { 878 regionSelectorToggle($regionSelector); 879 $(CONSTANTS.$REGION_SELECTOR_CLOSE).addClass(CONSTANTS.HIDE); 880 //Hide navigation hamburger icon 881 $(CONSTANTS.$NAVBAR_TOGGLE).addClass(CONSTANTS.HIDE); 882 } 883 } 884 }); 885 }; 886 var bindElements = function () { 887 $(CONSTANTS.$REGION_SELECTOR).each(function (index, element) { 888 var $regionSelector = $(element); 889 var $regionToggle = $regionSelector.find(CONSTANTS.$REGION_TOGGLE); 890 var $regionSelectorToggle = $(CONSTANTS.$REGION_SELECTOR_TOGGLE + ', ' + CONSTANTS.$REGION_SELECTOR_CLOSE); 891 var $languageLinks = $regionSelector.find(CONSTANTS.$LANGUAGE_LINK); 892 var cookieRegion = AD_UTILS.getCookie(CONSTANTS.COOKIE_REGION); 893 var $window = $(window); 894 var resizeTimer, windowHeight; 895 896 if (!$regionSelector.hasClass(CONSTANTS.WCMMODE_EDIT)) { 897 akamaiFlagCheck($regionSelector); 898 } 899 $regionSelectorToggle.on('click', function () { 900 regionSelectorToggle($regionSelector); 901 }); 902 $regionToggle.on('click', function (e) { 903 e.preventDefault(); 904 var regionTarget = "." + $(this).data(CONSTANTS.REGION_TARGET); 905 hideLanguages(); 906 if ($(window).width() < 768) { 907 closeDropdowns(); 908 openDropdown(CONSTANTS.$DROPDOWN_PANEL_LANGUAGES); 909 } 910 showAvailableRegionLanguages(regionTarget); 911 }); 912 $languageLinks.on('click', function () { 913 setRegionCookie($(this).attr('href')); 914 }); 915 $window.on('resize', function () { 916 windowHeight = $(window.top).outerHeight(); 917 clearTimeout(resizeTimer); 918 resizeTimer = setTimeout(function () { 919 if ($window.width() < 768) { 920 $regionSelector.css('height', '100%'); 921 } else { 922 $regionSelector.css('height', windowHeight); 923 } 924 }, 5); 925 }); 926 $(CONSTANTS.$DROPDOWN_TOGGLE).on('click', function () { 927 var $this = $(this); 928 var $nextPanel = $(this).next(CONSTANTS.$DROPDOWN_PANEL); 929 if ($nextPanel.hasClass(CONSTANTS.COLLAPSED)) { 930 closeDropdowns(); 931 $this.find(CONSTANTS.$DROPDOWN_TOGGLE_ICON).text('-'); 932 $nextPanel.slideDown(); 933 $nextPanel.removeClass(CONSTANTS.COLLAPSED); 934 } else { 935 $this.find(CONSTANTS.$DROPDOWN_TOGGLE_ICON).text('+'); 936 $nextPanel.slideUp(); 937 $nextPanel.addClass(CONSTANTS.COLLAPSED); 938 } 939 }); 940 resizeControlDropdowns(); 941 }) 942 }; 943 return { 944 initialize: function () { 945 bindElements(); 946 } 947 }; 948})(); 949$(function () { 950 regionSelector.initialize(); 951}); 952var newsRoom = (function () { 953 var CONSTANTS = { 954 $DROPDOWN_PANEL: '.nr-dropdown-panel', 955 $DROPDOWN_TOGGLE: '.dropdown-toggle', 956 $CLEAR_FILTER: '.clear-filter', 957 $NEWSROOM_ARTICLE_ITEM: '.article-item', 958 $NEWSROOM_LIST: '.news-list', 959 $NEWSROOM_COMPONENT: '.newsroom-component', 960 $SEARCH_INPUT: 'input', 961 $SUBMIT_BUTTON: '.submit-button', 962 $NO_RESULTS_MESSAGE: '.no-results-message', 963 $LOAD_MORE: '.load-more', 964 $NEWSROOM_PAGE_PATH: '#newsroom-page-path', 965 $NEWSROOM_ART_LIMIT: '#newsroom-article-limit' 966 }; 967 968 var TEMPLATE = { 969 ARTICLE_ITEM: '<div class="article-item row"><div class="col-sm-12"><div class="row"><div class="article-header col-sm-12"><span class="article-item-date">{{articleDate}}</span><h3 class="article-item-title">{{articleHeadline}}</h3></div><div class="col-sm-6">{{articleSummary}}</div><div class="col-sm-6 hidden-xs"><div class="main-image-container">{{articleDisplayContent}}</div></div></div><a href="#" class="dropdown-toggle fa fa-caret-right"></a></div><div class="nr-dropdown-panel"><div class="col-sm-12"><div class="row"><div class="col-sm-6">{{articleDescription}}<div class="article-share hidden-xs"><span class="share-label">{{articleShareLabel}}</span>{{articleShareLinks}}</div></div><div class="col-sm-6">{{articlePanelImages}}</div></div><div class="row"><div class="col-sm-12 article-share visible-xs"><span class="share-label">{{articleShareLabel}}</span>{{articleShareLinks}}</div></div></div></div></div>', 970 IMAGE: '<img src="{{imageSource}}" alt="">', 971 SHARE_LINKS: '<a class="{{network}}" st_url="{{artUrl}}" st_title="{{artTitle}}" st_description="{{artSummary}}" st_image="{{artImage}}">{{networkName}}</a>', 972 WECHAT_SHARE_LINK: '<a data-network="wechat" class="st-custom-button" data-url="{{artUrl}}" data-title="{{artTitle}}" data-description="{{artSummary}}" data-image="{{artImage}}">WeChat</a>' 973 }; 974 975 var networkhash = new Object(); 976 networkhash["facebook"] = "st_facebook"; 977 networkhash["twitter"] = "st_twitter"; 978 networkhash["linkedin"] = "st_linkedin"; 979 networkhash["instagram"] = "st_instagram"; 980 networkhash["sina"] = "st_sina"; 981 networkhash["wechat"] = "st_wechat"; 982 983 var shareThis = []; 984 var fetchArticles = function (text, offset, pagePath, articleLimit, callback) { 985 var data = { 986 text: text || '', 987 offset: offset || '', 988 newspath: pagePath, 989 articlelimit: articleLimit 990 }; 991 992 $.ajax({
993 url: '/bin/avery-lpm/news-filtering', 994 data: data, 995 type: 'get', 996 success: function (results) { 997 callback(JSON.parse(JSON.stringify(results))); 998 }, 999 cache: false 1000 }); 1001 }; 1002 1003 var buildArticleItem = function (articleItem,position) { 1004 var articleTemplate = TEMPLATE.ARTICLE_ITEM; 1005 var articleShareLinks = []; 1006 var articlePanelImages = []; 1007 var articleDate = articleItem.articleDate.split('T')[0].split('-').reverse(); 1008 var dd = articleDate[0] || ''; 1009 var mm = articleDate[1] || ''; 1010 var yyyy = articleDate[2] || ''; 1011 var index, date; 1012 var shareText = $(CONSTANTS.$NEWSROOM_COMPONENT).data('shareLabel') || 'Share'; 1013 var dateFormat = $(CONSTANTS.$NEWSROOM_COMPONENT).data('dateFormat') || 'dd.mm.yyyy'; 1014 1015 switch(dateFormat) { 1016 case 'dd.mm.yyyy': 1017 date = dd + '.' + mm + '.' + yyyy; 1018 break; 1019 case 'dd-mm-yyyy': 1020 date = dd + '-' + mm + '-' + yyyy; 1021 break; 1022 case 'dd/mm/yyyy': 1023 date = dd + '/' + mm + '/' + yyyy; 1024 break; 1025 case 'mm.dd.yyyy': 1026 date = mm + '.' + dd + '.' + yyyy; 1027 break; 1028 case 'mm-dd-yyyy': 1029 date = mm + '-' + dd + '-' + yyyy; 1030 break; 1031 case 'mm/dd/yyyy': 1032 date = mm + '/' + dd + '/' + yyyy; 1033 break; 1034 } 1035 1036 if (articleItem.articleImages && articleItem.articleImages.length > 0) { 1037 for (index = 0; index < articleItem.articleImages.length; index++) { 1038 var articleImageTemplate = TEMPLATE.IMAGE; 1039 articleImageTemplate = articleImageTemplate.replace('{{imageSource}}', articleItem.articleImages[index]); 1040 articlePanelImages.push(articleImageTemplate); 1041 } 1042 } 1043 1044 if (shareThis && shareThis.length > 0) { 1045 for (index = 0; index < shareThis.length; index++) { 1046 var articleShareLinksTemplate = TEMPLATE.SHARE_LINKS; 1047 var networkName = shareThis[index].substring(3); 1048 if (shareThis[index] !== "st_wechat") { 1049 1050 if (shareThis[index] === "st_linkedin") { 1051 networkName = "LinkedIn"; 1052 } 1053 1054 if (shareThis[index] === "st_sina") { 1055 networkName = "Sina Weibo"; 1056 } 1057 1058 articleShareLinksTemplate = articleShareLinksTemplate.replace(/{{network}}/ig, shareThis[index]); 1059 articleShareLinksTemplate = articleShareLinksTemplate.replace('{{networkName}}', capitalizeFirstLetter(networkName)); 1060 articleShareLinksTemplate = articleShareLinksTemplate.replace(/{{artUrl}}/ig, articleItem.pageUrl); 1061 articleShareLinksTemplate = articleShareLinksTemplate.replace('{{artTitle}}', articleItem.title); 1062 articleShareLinksTemplate = articleShareLinksTemplate.replace('{{artSummary}}', articleItem.summary); 1063 articleShareLinksTemplate = articleShareLinksTemplate.replace('{{artImage}}', articleItem.primaryImageUrl); 1064 articleShareLinks.push(articleShareLinksTemplate); 1065 } else { 1066 var wechatShareLinkTemplate = TEMPLATE.WECHAT_SHARE_LINK; 1067 wechatShareLinkTemplate = wechatShareLinkTemplate.replace(/{{artUrl}}/ig, articleItem.pageUrl); 1068 wechatShareLinkTemplate = wechatShareLinkTemplate.replace('{{artTitle}}', articleItem.title); 1069 wechatShareLinkTemplate = wechatShareLinkTemplate.replace('{{artSummary}}', articleItem.summary); 1070 wechatShareLinkTemplate = wechatShareLinkTemplate.replace('{{artImage}}', articleItem.primaryImageUrl); 1071 articleShareLinks.push(wechatShareLinkTemplate); 1072 } 1073 } 1074 } 1075 1076 articleTemplate = articleTemplate.replace('{{articleDate}}', date); 1077 articleTemplate = articleTemplate.replace('{{articleHeadline}}', articleItem.title || ''); 1078 articleTemplate = articleTemplate.replace('{{articleSummary}}', articleItem.summary) || ''; 1079 articleTemplate = articleTemplate.replace('{{articleMainImage}}', articleItem.primaryImage) || ''; 1080 articleTemplate = articleTemplate.replace('{{articleDescription}}', articleItem.description || ''); 1081 articleTemplate = articleTemplate.replace('{{articlePanelImages}}', articlePanelImages.join(''));
1082 articleTemplate = articleTemplate.replace(/{{articleShareLabel}}/ig, shareText); 1083 articleTemplate = articleTemplate.replace(/{{articleShareLinks}}/ig, articleShareLinks.join('')); 1084 1085 var articleImageTemplate = '<img class="" src="'+articleItem.primaryImageUrl+'" alt="">'; 1086 1087 var articleVideoTemplate = 1088 '<div class="lpm-video video-modal">'+ 1089 '<div class="image">'+ 1090 '<a href="#" data-toggle="modal" data-target="#video-modal-'+position+'" onclick="ga(\'send\', \'event\', \'Videos\', \'Play\', \'\');">'+ 1091 '<img src="'+articleItem.primaryImageUrl+'" alt="">'+ 1092 '<div class="overlay">'+ 1093 '<i class="fa fa-play" aria-hidden="true" style="opacity: 0.8; transform: translatey(50); margin-left: calc(50% - 12px); margin-top: calc(30%); color: #fff;"></i>'+ 1094 '</div>'+ 1095 '</a>'+ 1096 '</div>'+ 1097 1098 '<div class="modal" id="video-modal-'+position+'" tabindex="-1" role="dialog">'+ 1099 '<div class="modal-dialog" role="document">'+ 1100 '<div class="modal-content">'+ 1101 '<div class="modal-header">'+ 1102 '<button type="button" class="close" data-dismiss="modal" aria-label="Close">'+ 1103 '<i class="fa fa-times-circle" aria-hidden="true"></i>'+ 1104 '</button>'+ 1105 '</div>'+ 1106 1107 '<div class="modal-body">'+ 1108 '<div class="lpm-video video-embed" >'+ 1109 '<div class="avd-jw-video-player" id="video-embed-'+position+'"'+ 1110 'data-file="'+articleItem.shareVideo+'"'+ 1111 'data-preview="'+articleItem.primaryImageUrl+'">'+ 1112 '<span class="sr-only">Loading...</span>'+ 1113 '</div>'+ 1114 '</div>'+ 1115 '</div>'+ 1116 '</div>'+ 1117 '</div>'+ 1118 '</div>'+ 1119 '</div>'; 1120 1121 if (articleItem.primaryImageUrl && 1122 articleItem.primaryImageUrl !==' ' && 1123 articleItem.shareVideo && 1124 articleItem.shareVideo !== ' '){ 1125 articleTemplate = articleTemplate.replace('{{articleDisplayContent}}', articleVideoTemplate || ''); 1126 } else { 1127 articleTemplate = articleTemplate.replace('{{articleDisplayContent}}', articleImageTemplate || ''); 1128 } 1129 1130 1131 1132 return articleTemplate; 1133 }; 1134 1135 var renderArticles = function ($newsroomComponent, queryOffset) { 1136 1137 var $articleItems = $newsroomComponent.find(CONSTANTS.$NEWSROOM_ARTICLE_ITEM); 1138 var $searchInput = $newsroomComponent.find(CONSTANTS.$SEARCH_INPUT); 1139 var $noResultsMessage = $newsroomComponent.find(CONSTANTS.$NO_RESULTS_MESSAGE); 1140 var $loadMoreButton = $newsroomComponent.find(CONSTANTS.$LOAD_MORE); 1141 var queryValue = $searchInput.val() || ''; 1142 var articleOffset = queryOffset || ''; 1143 var pagePath = $(CONSTANTS.$NEWSROOM_PAGE_PATH).data("pagePath"); 1144 var articleLimit = $(CONSTANTS.$NEWSROOM_ART_LIMIT).data("limit"); 1145 var articles = []; 1146 var index; 1147 1148 fetchArticles(queryValue, articleOffset, pagePath, articleLimit, function (data) { 1149 var renderedArticles; 1150 var totalStoredArticles = data.totalResults; 1151 1152 articles = data.results; 1153 if (!articleOffset) { 1154 $articleItems.remove(); 1155 } 1156 1157 if (articles.length > 0) { 1158 $noResultsMessage.addClass('hide'); 1159 for (index = 0; index < articles.length; index++) { 1160 var articleItem = buildArticleItem(articles[index],index); 1161 $(articleItem).appendTo(CONSTANTS.$NEWSROOM_LIST); 1162 } 1163 } else { 1164 $noResultsMessage.removeClass('hide'); 1165 } 1166 //Hide or show Load More button depending on how many articles are stored for this query and how many articles are rendered 1167 renderedArticles = $newsroomComponent.find(CONSTANTS.$NEWSROOM_ARTICLE_ITEM).length; 1168 (renderedArticles < totalStoredArticles) ?
1169 $loadMoreButton.removeClass('hide') : 1170 $loadMoreButton.addClass('hide'); 1171 1172 //bind share buttons 1173 if (window.__sharethis__) { 1174 window.__sharethis__.initialize(); 1175 stButtons.locateElements(); 1176 } 1177 1178 bindElements($newsroomComponent); 1179 $('.avd-jw-video-player').each(function() { 1180 $(this).avdJwVideoPlayer(); 1181 }); 1182 1183 }); 1184 }; 1185 1186 var bindElements = function ($newsroomComponent) { 1187 var $dropdownToggle = $newsroomComponent.find(CONSTANTS.$DROPDOWN_TOGGLE); 1188 var $loadMoreButton = $newsroomComponent.find(CONSTANTS.$LOAD_MORE); 1189 var queryOffset = $newsroomComponent.find(CONSTANTS.$NEWSROOM_ARTICLE_ITEM).length; 1190 1191 $dropdownToggle.off().on('click', function (e) { 1192 e.preventDefault(); 1193 $(this).toggleClass('expanded'); 1194 $(this).parent().next(CONSTANTS.$DROPDOWN_PANEL).slideToggle('slow'); 1195 }); 1196 1197 $loadMoreButton.off().on('click', function (e) { 1198 e.preventDefault(); 1199 renderArticles($newsroomComponent, queryOffset); 1200 }); 1201 }; 1202 1203 var capitalizeFirstLetter = function(string) { 1204 return string.charAt(0).toUpperCase() + string.slice(1); 1205 }; 1206 1207 return { 1208 initialize: function () { 1209 1210 $(CONSTANTS.$NEWSROOM_COMPONENT).each(function (i, element) { 1211 var $newsroomComponent = $(element); 1212 var $searchInput = $newsroomComponent.find(CONSTANTS.$SEARCH_INPUT); 1213 var $clearFilter = $newsroomComponent.find(CONSTANTS.$CLEAR_FILTER); 1214 var $submitButton = $newsroomComponent.find(CONSTANTS.$SUBMIT_BUTTON); 1215 var initYear = $newsroomComponent.data('initialYear') || 2000; 1216 var currentYear = (new Date()).getFullYear(); 1217 1218 Object.keys($newsroomComponent.data()).forEach(function (key) { 1219 if (networkhash[key]) { 1220 shareThis.push(networkhash[key]); 1221 } 1222 }); 1223 1224 $searchInput.on('change keyup', function () { 1225 var $this = $(this); 1226 $this.val() ? $clearFilter.removeClass('hide') : $clearFilter.addClass('hide'); 1227 }); 1228 1229 $searchInput.on('keypress', function (e) { 1230 if (e.which === 13) { 1231 e.preventDefault(); 1232 $submitButton.click(); 1233 } 1234 }); 1235 1236 $clearFilter.on('click', function (e) { 1237 e.preventDefault(); 1238 $searchInput.val(''); 1239 $(this).addClass('hide'); 1240 renderArticles($newsroomComponent); 1241 }); 1242 1243 $submitButton.on('click', function () { 1244 renderArticles($newsroomComponent); 1245 }); 1246 1247 renderArticles($newsroomComponent); 1248 }); 1249 } 1250 }; 1251})(); 1252 1253 1254$(function () { 1255 newsRoom.initialize(); 1256}); 1257 1258var peopleSpotlight = (function () { 1259 1260 var CONSTANTS = { 1261 $BANNER_DROPDOWN_CLOSE: '.banner-dropdown-close', 1262 $BANNER_DROPDOWN_PANEL: '.banner-dropdown-panel', 1263 $BANNER_DROPDOWN_TOGGLE: '.banner-dropdown-toggle', 1264 $SPOTLIGHT_BANNER: '.spotlight-banner', 1265 $ROW: '.row', 1266 DATA_DROPDOWN_VISIBILITY: 'dropdown-visibility' 1267 }; 1268 1269 var bindElements = function () { 1270 1271 $(CONSTANTS.$SPOTLIGHT_BANNER).each(function (index, element) { 1272 var $spotLightBanner = $(element); 1273 var $dropdownToggle = $spotLightBanner.prev(CONSTANTS.$BANNER_DROPDOWN_TOGGLE); 1274 var $dropdownClose = $spotLightBanner.find(CONSTANTS.$BANNER_DROPDOWN_CLOSE); 1275 var $dropdownPanel = $spotLightBanner.find(CONSTANTS.$BANNER_DROPDOWN_PANEL); 1276 var dropdownVisibility = $dropdownToggle.data(CONSTANTS.DATA_DROPDOWN_VISIBILITY); 1277 1278 $dropdownToggle.on('click', function (e) { 1279 1280 var windowWidth = $(window).width(); 1281 1282 if ((dropdownVisibility === 'visible-xs visible-sm visible-md') || (dropdownVisibility === 'visible-xs' && windowWidth < 768) || (dropdownVisibility === 'visible-sm visible-md' && windowWidth > 768)) { 1283 e.preventDefault(); 1284 $dropdownPanel.slideToggle(); 1285 } else if ($(this).attr('href') === '#') { 1286 e.preventDefault(); 1287 } 1288 1289 $(this).blur(); 1290 }); 1291 1292 $dropdownClose.on('click', function (e) { 1293 e.preventDefault(); 1294 $dropdownPanel.slideUp(); 1295 }); 1296 1297 }) 1298 }; 1299 1300 var spotlightMatchHeight =function () { 1301 $(CONSTANTS.$ROW).each(function (index, row) { 1302 var bannersInsideRow = $(row).find(CONSTANTS.$SPOTLIGHT_BANNER); 1303 bannersInsideRow.matchHeight({ 1304 byRow: false, 1305 property: 'min-height' 1306 }); 1307 });
1308 }; 1309 1310 return { 1311 initialize: function () { 1312 bindElements(); 1313 spotlightMatchHeight(); 1314 } 1315 }; 1316 1317})(); 1318 1319 1320$(function () { 1321 peopleSpotlight.initialize(); 1322}); 1323 1324var newsletter = (function () { 1325 1326 var CONSTANTS = { 1327 $NEWSLETTER_CTA: '.newsletter-cta', 1328 $FOOTER_EMAIL: '.newsletter-email', 1329 $SUBSCRIBE_BUTTON: '.btn', 1330 COOKIE_EMAIL: 'email', 1331 $FORM: '.avd-form', 1332 $EMAIL_FIELD_NAME: 'Email_Address', 1333 EMAIL_ERROR: 'emailerror', 1334 WCMMODE_EDIT: 'wcmmode-edit' 1335 }; 1336 1337 var setEmailCookie = function (email) { 1338 1339 var name = CONSTANTS.COOKIE_EMAIL; 1340 var value = email; 1341 1342 AD_UTILS.setCookie(name, value); 1343 }; 1344 1345 var validateEMail = function (email) { 1346 1347 if(email === "") { 1348 return false; 1349 } 1350 var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/; 1351 return regex.test(email); 1352 }; 1353 1354 var bindElements = function () { 1355 1356 var cookieEmail = AD_UTILS.getCookie(CONSTANTS.COOKIE_EMAIL); 1357 1358 $(CONSTANTS.$FOOTER_EMAIL).keypress(function() { 1359 $(CONSTANTS.$FOOTER_EMAIL).removeClass(CONSTANTS.EMAIL_ERROR); 1360 }); 1361 1362 $(CONSTANTS.$NEWSLETTER_CTA).find(CONSTANTS.$SUBSCRIBE_BUTTON).click(function (event) { 1363 var email = $(CONSTANTS.$FOOTER_EMAIL).val(); 1364 if(validateEMail(email)){ 1365 setEmailCookie(email); 1366 } 1367 else{ 1368 $(CONSTANTS.$FOOTER_EMAIL).addClass(CONSTANTS.EMAIL_ERROR); 1369 event.preventDefault(); 1370 } 1371 }); 1372 1373 if(cookieEmail){ 1374 var form = $(CONSTANTS.$FORM) 1375 1376 if (form){ 1377 $(CONSTANTS.$FORM).find("input[name="+CONSTANTS.$EMAIL_FIELD_NAME+"]").val(cookieEmail); 1378 } 1379 } 1380 1381 }; 1382 1383 return { 1384 initialize: function () { 1385 bindElements(); 1386 } 1387 }; 1388 1389})(); 1390 1391 1392$(function () { 1393 newsletter.initialize(); 1394}); 1395 1396var sustainabilityTiles = (function () { 1397 1398 var CONSTANTS = { 1399 $SUSTAINABILITY_TILE: '.sustainability-tile-container', 1400 $SUSTAINABILITY_TILE_SPACER: '.spacer', 1401 $SUSTAINABILITY_TILE_TITLE: '.st-title', 1402 $SUSTAINABILITY_TILE_BODY: '.st-body', 1403 $SUSTAINABILITY_TILE_BODY_TEXT: '.st-body p', 1404 $SUSTAINABILITY_IMAGE_ICON: '.image-icon', 1405 $AVD_ROWS: '.column-control .row', 1406 $SUSTAINABILITY_TILE_IMAGE_ICON_HEIGHT: $('.sustainability-tile-container .image-icon').outerHeight(true) 1407 }; 1408 1409 var setRowSTHeight = function () { 1410 $(CONSTANTS.$AVD_ROWS).each(function (index, element) { 1411 var $row = $(element); 1412 var $sustainabilityTiles = $row.find(CONSTANTS.$SUSTAINABILITY_TILE); 1413 var $stTitle = $sustainabilityTiles.find(CONSTANTS.$SUSTAINABILITY_TILE_TITLE); 1414 var $stBody = $sustainabilityTiles.find(CONSTANTS.$SUSTAINABILITY_TILE_BODY); 1415 var $stBodyText = $sustainabilityTiles.find(CONSTANTS.$SUSTAINABILITY_TILE_BODY_TEXT); 1416 var stTitleMaxHeight = Math.max.apply(null, $stTitle.map(function () 1417 { 1418 return $(this).outerHeight(); 1419 }).get()); 1420 var stBodyMaxHeight = Math.max.apply(null, $stBodyText.map(function () 1421 { 1422 return $(this).outerHeight(); 1423 }).get()); 1424 1425 1426 $stTitle.css('min-height', stTitleMaxHeight + 'px'); 1427 $stBody.css('min-height', stBodyMaxHeight + 'px'); 1428 }); 1429 $(window).trigger('resetLoaters'); 1430 }; 1431 1432 var setRowSTHeightDefault = function () { 1433 $(CONSTANTS.$AVD_ROWS).each(function (index, element) { 1434 var $row = $(element); 1435 var $sustainabilityTiles = $row.find(CONSTANTS.$SUSTAINABILITY_TILE); 1436 var $stTitle = $sustainabilityTiles.find(CONSTANTS.$SUSTAINABILITY_TILE_TITLE); 1437 var $stBody = $sustainabilityTiles.find(CONSTANTS.$SUSTAINABILITY_TILE_BODY); 1438 $stTitle.css('min-height', '0'); 1439 $stBody.css('min-height', '0'); 1440 }); 1441 }; 1442 1443 var bindElements = function () { 1444 1445 var resizeTimer; 1446 1447 $(window).on('resize resizeSustainabilityTiles', function () { 1448 1449 var $window = $(this); 1450 var mobileFlag = true; 1451 1452 clearTimeout(resizeTimer); 1453 resizeTimer = setTimeout(function () { 1454 1455 if ($window.width() < 768 && mobileFlag) { 1456 setRowSTHeightDefault(); 1457 mobileFlag = false; 1458 } else { 1459 setRowSTHeight(); 1460 mobileFlag = true; 1461 } 1462 1463 }, 0); 1464 1465 });
1466 1467 $(CONSTANTS.$SUSTAINABILITY_TILE).each(function (index, element) { 1468 var sustainabilityTile = $(element); 1469 var $stBody = sustainabilityTile.find(CONSTANTS.$SUSTAINABILITY_TILE_BODY); 1470 var $imageIcon = sustainabilityTile.find(CONSTANTS.$SUSTAINABILITY_IMAGE_ICON); 1471 1472 $imageIcon.lowFloat({bottomContent: $stBody, cssFloat: 'right'}); 1473 }); 1474 1475 /*setTimeout(function () { 1476 $(window).trigger('resize'); 1477 }, 0); 1478 $(window).trigger('resize');*/ 1479 1480 }; 1481 1482 return { 1483 initialize: function () { 1484 bindElements(); 1485 }, 1486 setRowSTHeightDefault: function () { 1487 setRowSTHeight(); 1488 } 1489 } 1490 1491})(); 1492 1493 1494$(function () { 1495 sustainabilityTiles.initialize(); 1496}); 1497 1498var lpmTabs = (function () { 1499 1500 var CONSTANTS = { 1501 $LPM_TAB_NAV: '.lpm-tab-nav', 1502 $LPM_TAN_NAV_BUTTON: '.tab-nav-btn' 1503 }; 1504 1505 var sustainabilityTilesModule = sustainabilityTiles; 1506 1507 var bindElements = function () { 1508 $(CONSTANTS.$LPM_TAB_NAV).each(function (index, element) { 1509 var $lpmTab = $(element); 1510 var $navButton = $lpmTab.find(CONSTANTS.$LPM_TAN_NAV_BUTTON); 1511 1512 $navButton.on('click', function () { 1513 setTimeout(function () { 1514 sustainabilityTilesModule.setRowSTHeightDefault(); 1515 $(window).trigger('resize') 1516 }, 10); 1517 }) 1518 }) 1519 }; 1520 1521 return { 1522 initialize: function () { 1523 bindElements(); 1524 } 1525 } 1526 1527})(); 1528 1529 1530$(function () { 1531 lpmTabs.initialize(); 1532}); 1533 1534$(function () { 1535 1536 var banner = $("#cookie-banner"); 1537 var closeButton = $("#cookie-banner .close"); 1538 var footerRedesign = $("footer.footer-redesign"); 1539 1540 var COOKIE_BANNER_NAME = "cookie-banner"; 1541 1542 function setCookie(cookieName, cookieValue){ 1543 localStorage.setItem(cookieName, cookieValue); 1544 } 1545 1546 function getCookie(cookieName){ 1547 1548 return localStorage.getItem(cookieName); 1549 1550 } 1551 1552 function removeCookie(){ 1553 localStorage.removeItem(COOKIE_BANNER_NAME); 1554 } 1555 1556 function checkCookie() { 1557 var cookie = getCookie(COOKIE_BANNER_NAME); 1558 if (cookie){ 1559 banner.hide(); 1560 footerRedesign.removeClass('cookiesOn'); 1561 } else{ 1562 banner.show(); 1563 footerRedesign.addClass('cookiesOn'); 1564 } 1565 } 1566 1567 checkCookie(); 1568 1569 closeButton.click(function(){ 1570 banner.hide(); 1571 footerRedesign.removeClass('cookiesOn'); 1572 setCookie(COOKIE_BANNER_NAME, "true"); 1573 }); 1574}); 1575$(document).ready(function() { 1576 const moveModal = $('#moveConfirmationModal'); 1577 const responseArea = $('#responseArea'); 1578 const deleteModal = $('#deleteConfirmationModal'); 1579 const responseTimeArea = $('#responseTimeArea'); 1580 const assetForm = $('#assetForm'); 1581 const operationButtons = $('button[id$="Button"]'); // Selects all buttons ending with "Button" 1582 1583 // --- HIDE THE MOVE BUTTON ON PAGE LOAD --- 1584 // If you don't have this functionality, it's best to hide the button. 1585 $('#moveButton').hide(); 1586 1587 let currentOperationId = null; 1588 let pollingInterval = null; 1589 1590 // --- Helper Functions --- 1591 1592 /** 1593 * Shows a loading indicator and disables operation buttons. 1594 * @param {string} message - The loading message to display. 1595 */ 1596 function showLoading(message) { 1597 responseArea.html(`<div class="loading-indicator">${message || 'Loading...'}</div>`); 1598 responseTimeArea.html(""); // Clear response time display 1599 operationButtons.prop('disabled', true); // Disable all operation buttons 1600 } 1601 1602 /** 1603 * Hides the loading indicator and re-enables operation buttons. 1604 * This function is primarily used for immediate error responses from the *initial* POST, 1605 * not for polled updates. 1606 * @param {string} data - The HTML content to display in the response area. 1607 * @param {string} responseTime - The response time string. 1608 */ 1609 function hideLoading(data, responseTime) { 1610 if (responseTime) { 1611 responseTimeArea.html(`<div class='response-time-display'>Initial Response: ${responseTime} ms</div>`); 1612 } else { 1613 responseTimeArea.html(""); 1614 } 1615 responseArea.html(data); 1616 operationButtons.prop('disabled', false); // Re-enable all operation buttons 1617 } 1618 1619 /** 1620 * Safely gets a value from an object, handling undefined/null cases. 1621 * @param {object} data - The object to retrieve the value from. 1622 * @param {string} key - The key of the property to retrieve. 1623 * @param {any} defaultValue - The default value to return if the key is not found or is undefined. 1624 * @returns {any} The value of the property or the defaultValue. 1625 */ 1626 function getValue(data, key, defaultValue = '') { 1627 return data && data[key] !== undefined ? data[key] : defaultValue; 1628 } 1629 1630 /** 1631 * Updates the progress display based on the data received from the polling servlet. 1632 * Handles different operation statuses and displays relevant information. 1633 * @param {object} data - The JSON data received from the status servlet. 1634 */ 1635 function updateProgress(data) { 1636 // Log the full data object for debugging purposes 1637 console.log("updateProgress function called:", data); 1638 1639 const processedCount = parseInt(getValue(data, 'processed', 0), 10); 1640 const totalCount = parseInt(getValue(data, 'total', 0), 10); 1641 1642 // Retrieve the asynchronously estimated total count 1643 const estimatedTotalCount = parseInt(getValue(data, 'estimatedTotalAssets', 0), 10); 1644 1645 const status = getValue(data, 'status', 'processing'); 1646 const action = getValue(data, 'action'); // Get the explicit action from the response 1647 1648 // Determine which total to use for display. Use estimated total if available and greater than 0. 1649 const displayTotal = estimatedTotalCount > 0 ? estimatedTotalCount : processedCount; 1650
1651 // --- REMOVED: Percentage calculation for progress bar --- 1652 // const percentage = displayTotal > 0 ? Math.min(100, Math.floor((processedCount / displayTotal) * 100)) : 0; 1653 1654 1655 // Build the basic progress HTML 1656 let progressHtml = `<h3>Operation Status: ${status}</h3>`; 1657 // Display progress using the estimated total 1658 progressHtml += `<p>Processed Nodes: ${processedCount} / ${displayTotal}</p>`; // Removed percentage display 1659 1660 // --- REMOVED: Simple progress bar HTML --- 1661 /* 1662 progressHtml += ` 1663 <div class="progress-bar" style="width: 100%; background-color: #f0f0f0; border-radius: 5px;"> 1664 <div style="width: ${percentage}%; background-color: #4CAF50; height: 20px; border-radius: 5px; text-align: center; color: white;"> 1665 ${percentage}% 1666 </div> 1667 </div>`; 1668 */ 1669 1670 1671 // Only display logs if the status is 'error' 1672 if (status === 'error' && data.logs && Array.isArray(data.logs) && data.logs.length > 0) { 1673 progressHtml += "<h4>Logs:</h4><div class='log-area'>"; 1674 progressHtml += data.logs.join("<br>"); 1675 progressHtml += "</div>"; 1676 } 1677 1678 // Use the 'action' property to conditionally render the correct summary 1679 if (action === 'details') { 1680 const totalDeactivated = parseInt(getValue(data, 'totalDeactivatedUnpublishedAssets', 0), 10); 1681 const referenced = parseInt(getValue(data, 'referencedDeactivatedUnpublishedAssets', 0), 10); 1682 const unreferenced = parseInt(getValue(data, 'unreferencedDeactivatedUnpublishedAssets', 0), 10); 1683 1684 let detailsListHtml = ''; 1685 if (data.referencedDetails && Array.isArray(data.referencedDetails) && data.referencedDetails.length > 0) { 1686 detailsListHtml += "<h4>Referenced Assets:</h4><ul>"; 1687 data.referencedDetails.forEach(detail => { 1688 detailsListHtml += `<li><strong>Path:</strong> ${getValue(detail, 'path')}<br>`; 1689 if (detail.referencingPages && Array.isArray(detail.referencingPages) && detail.referencingPages.length > 0) { 1690 detailsListHtml += ` <strong>Referenced In:</strong> ${detail.referencingPages.join(', ')}</li>`; 1691 } else { 1692 detailsListHtml += ` <strong>Referenced In:</strong> (No specific pages found)</li>`; 1693 } 1694 }); 1695 detailsListHtml += "</ul>"; 1696 } 1697 progressHtml += detailsListHtml; 1698 1699 progressHtml += `<h4>Unpublished/Deactivated Assets Summary:</h4> 1700 <p>Total Main Assets Found: ${totalDeactivated}</p> 1701 <p>Referenced: ${referenced}</p> 1702 <p>Unreferenced: ${unreferenced}</p>`; 1703 1704 } else if (action === 'move') { 1705 const movedCount = parseInt(getValue(data, 'movedCount', 0), 10); 1706 const skippedCount = parseInt(getValue(data, 'skippedCount', 0), 10); 1707 const skippedReferencedCount = parseInt(getValue(data, 'skippedReferencedCount', 0), 10); 1708 1709 let moveListHtml = ''; 1710 if (data.movedAssets && Array.isArray(data.movedAssets) && data.movedAssets.length > 0) { 1711 moveListHtml += "<h5>Successfully Moved Assets:</h5><ul>"; 1712 data.movedAssets.forEach(asset => { 1713 moveListHtml += `<li><strong>Original:</strong> ${getValue(asset, 'originalPath')}<br> 1714 <strong>Archive:</strong> ${getValue(asset, 'archivePath')}</li>`; 1715 }); 1716 moveListHtml += "</ul>"; 1717 } 1718 if (data.skippedAssets && Array.isArray(data.skippedAssets) && data.skippedAssets.length > 0) { 1719 moveListHtml += "<h5>Skipped Assets (Already in Archive):</h5><ul>"; 1720 data.skippedAssets.forEach(path => { 1721 moveListHtml += `<li>${path}</li>`; 1722 }); 1723 moveListHtml += "</ul>"; 1724 } 1725 progressHtml += moveListHtml; 1726 1727 progressHtml += `<h4>Move Operation Summary:</h4> 1728 <p>Moved: ${movedCount}</p> 1729 <p>Skipped (Already Present): ${skippedCount}</p> 1730 <p>Skipped (Referenced): ${skippedReferencedCount}</p>`; 1731 1732 } else if (action === 'delete') { 1733 const deletedCount = parseInt(getValue(data, 'deletedCount', 0), 10); 1734 const notDeletedCount = parseInt(getValue(data, 'notDeletedCount', 0), 10); 1735 const skippedCount = parseInt(getValue(data, 'skippedCount', 0), 10); 1736 const skippedReferencedCount = parseInt(getValue(data, 'skippedReferencedCount', 0), 10); 1737 1738 let deleteListHtml = ''; 1739 if (data.deletedAssets && Array.isArray(data.deletedAssets) && data.deletedAssets.length > 0) { 1740 deleteListHtml += "<h5>Successfully Deleted Assets:</h5><ul>";
1741 data.deletedAssets.forEach(path => { 1742 deleteListHtml += `<li>${path}</li>`; 1743 }); 1744 deleteListHtml += "</ul>"; 1745 } 1746 if (data.notDeletedAssets && Array.isArray(data.notDeletedAssets) && data.notDeletedAssets.length > 0) { 1747 deleteListHtml += "<h5>Assets Not Deleted (Possibly Referenced or Error):</h5><ul>"; 1748 data.notDeletedAssets.forEach(path => { 1749 deleteListHtml += `<li>${path}</li>`; 1750 }); 1751 deleteListHtml += "</ul>"; 1752 } 1753 progressHtml += deleteListHtml; 1754 1755 progressHtml += `<h4>Delete Operation Summary:</h4> 1756 <p>Deleted: ${deletedCount}</p> 1757 <p>Not Deleted: ${notDeletedCount}</p> 1758 <p>Skipped (Concurrent Modification): ${skippedCount}</p> 1759 <p>Skipped (Referenced): ${skippedReferencedCount}</p>`; 1760 } 1761 1762 // Update the display with the final HTML 1763 responseArea.html(progressHtml); 1764 1765 // Handle terminal states: stop polling and re-enable buttons 1766 if (status === 'completed' || status === 'error' || status === 'partially_completed') { 1767 clearInterval(pollingInterval); 1768 pollingInterval = null; 1769 currentOperationId = null; 1770 operationButtons.prop('disabled', false); 1771 1772 if (status === 'completed') { 1773 responseArea.prepend("<div class='success-message'>Operation completed successfully.</div>"); 1774 } else if (status === 'error') { 1775 let errorMessage = "<div class='error-message'>Operation encountered an error.</div>"; 1776 if (data.error) { 1777 errorMessage += `<br>Error details: ${getValue(data, 'error')}`; 1778 } 1779 responseArea.prepend(errorMessage); 1780 } else if (status === 'partially_completed') { 1781 responseArea.prepend("<div class='info-message'>Operation partially completed. More assets may be available for processing. Click the button again to continue.</div>"); 1782 } 1783 1784 if (data.finishedTime) { 1785 responseTimeArea.html(`<div class='response-time-display'>Operation Finished: ${new Date(data.finishedTime).toLocaleString()}</div>`); 1786 } 1787 } 1788 } 1789 1790 /** 1791 * Periodically polls the status servlet for updates on the current operation. 1792 */ 1793 function pollStatus() { 1794 // Only poll if there's an active operation ID 1795 if (currentOperationId) { 1796 console.log("Polling status for operation ID:", currentOperationId); 1797 $.ajax({
1798 url: '/bin/assetreport/move/status/res', // The status servlet endpoint 1799 type: 'GET', 1800 data: { 1801 operationId: currentOperationId // Pass the active operation ID 1802 }, 1803 dataType: 'json', 1804 success: updateProgress, // On success, update the UI 1805 error: function(jqXHR, textStatus, errorThrown) { 1806 // Check if the error is a 404 Not Found. 1807 if (jqXHR.status === 404) { 1808 // This is the expected behavior for a completed/cleaned up job. 1809 // Stop polling and re-enable buttons. 1810 console.log(`Operation ID ${currentOperationId} not found on the server. Assuming it's complete and has been cleaned up.`); 1811 1812 // You can optionally display a final message here or rely on the previous successful poll's state. 1813 responseArea.append(`<div class='info-message'>Operation has been completed and is no longer being tracked.</div>`); 1814 1815 clearInterval(pollingInterval); 1816 pollingInterval = null; 1817 currentOperationId = null; 1818 operationButtons.prop('disabled', false); 1819 } else { 1820 // For other, unexpected errors (e.g., 500 Internal Server Error), 1821 // stop polling and display a generic error message. 1822 console.error("Error polling status:", textStatus, errorThrown, jqXHR.responseText); 1823 responseArea.html(`<div class='error-message'>Error checking status. Please check the console for details.</div>`); 1824 1825 clearInterval(pollingInterval); // Stop polling on error 1826 pollingInterval = null; 1827 currentOperationId = null; 1828 operationButtons.prop('disabled', false); // Re-enable buttons on polling error 1829 } 1830 } 1831 }); 1832 } else { 1833 // If currentOperationId is null, polling should not occur. 1834 // This is a safety check to ensure intervals are cleared. 1835 console.log("currentOperationId is null. Ensuring polling attempts are stopped."); 1836 clearInterval(pollingInterval); 1837 pollingInterval = null; 1838 } 1839 } 1840 1841 // --- Event Handlers for starting operations --- 1842 1843 $('#moveButton').click(function() { 1844 moveModal.show(); // Show confirmation modal for move 1845 }); 1846 1847 $('#cancelMove').click(function() { 1848 moveModal.hide(); // Hide move modal 1849 }); 1850 1851 $('#confirmMove').click(function() { 1852 moveModal.hide(); // Hide move modal 1853 showLoading("Starting move operation..."); // Show loading indicator 1854 const startTime = performance.now(); // Capture start time for initial response calculation 1855 1856 // Send AJAX POST request to start the move operation 1857 $.ajax({
1858 url: '/bin/assetreport/move/thread/res', // The servlet to initiate the operation 1859 type: 'POST', 1860 data: assetForm.serialize() + '&action=move', 1861 dataType: 'json', 1862 success: function(data) { 1863 const endTime = performance.now(); 1864 const responseTimeInitial = (endTime - startTime).toFixed(2); 1865 responseTimeArea.html(`<div class='response-time-display'>Initial Response: ${responseTimeInitial} ms</div>`); 1866 responseArea.html("Move operation started. Tracking progress..."); 1867 1868 if (data && data.operationId) { 1869 currentOperationId = data.operationId; // Store the operation ID 1870 pollingInterval = setInterval(pollStatus, 10000); // Start polling every 10 seconds 1871 } else { 1872 // Handle case where no operation ID is returned 1873 hideLoading(`<div class='error-message'>Failed to start operation or retrieve operation ID. No ID returned.</div>`, responseTimeInitial); 1874 } 1875 }, 1876 error: function(jqXHR, textStatus, errorThrown) { 1877 const endTime = performance.now(); 1878 const responseTime = (endTime - startTime).toFixed(2); 1879 let errorMsg = "An unknown error occurred."; 1880 if (jqXHR.responseJSON && jqXHR.responseJSON.error) { 1881 errorMsg = jqXHR.responseJSON.error; 1882 } else if (jqXHR.responseText) { 1883 errorMsg = jqXHR.responseText; // Fallback for non-JSON errors 1884 } else { 1885 errorMsg = `Error: ${textStatus} - ${errorThrown}`; 1886 } 1887 hideLoading(`<div class='error-message'>Error starting move: ${errorMsg}</div>`, responseTime); 1888 } 1889 }); 1890 }); 1891 1892 $('#rollbackButton').hide(); // This button is currently hidden and has no implemented functionality 1893 1894 $('#detailsButton').click(function() { 1895 showLoading("Retrieving details..."); 1896 const startTime = performance.now(); 1897 1898 // Send AJAX POST request to start the details operation 1899 $.ajax({
1900 url: '/bin/assetreport/move/thread/res', 1901 type: 'POST', 1902 data: assetForm.serialize() + '&action=details', 1903 dataType: 'json', 1904 success: function(data) { 1905 const endTime = performance.now(); 1906 const responseTime = (endTime - startTime).toFixed(2); 1907 responseTimeArea.html(`<div class='response-time-display'>Initial Response: ${responseTime} ms</div>`); 1908 responseArea.html("Retrieving details. Tracking progress..."); 1909 1910 if (data && data.operationId) { 1911 currentOperationId = data.operationId; 1912 pollingInterval = setInterval(pollStatus, 10000); 1913 } else { 1914 hideLoading(`<div class='error-message'>Failed to start operation or retrieve operation ID. No ID returned.</div>`, responseTime); 1915 } 1916 }, 1917 error: function(jqXHR, textStatus, errorThrown) { 1918 const endTime = performance.now(); 1919 const responseTime = (endTime - startTime).toFixed(2); 1920 let errorMsg = "An unknown error occurred."; 1921 if (jqXHR.responseJSON && jqXHR.responseJSON.error) { 1922 errorMsg = jqXHR.responseJSON.error; 1923 } else if (jqXHR.responseText) { 1924 errorMsg = jqXHR.responseText; 1925 } else { 1926 errorMsg = `Error: ${textStatus} - ${errorThrown}`; 1927 } 1928 hideLoading(`<div class='error-message'>Error getting asset details: ${errorMsg}</div>`, responseTime); 1929 } 1930 }); 1931 }); 1932 1933 $('#deleteButton').click(function() { 1934 deleteModal.show(); // Show confirmation modal for delete 1935 }); 1936 1937 $('#cancelDelete').click(function() { 1938 deleteModal.hide(); // Hide delete modal 1939 }); 1940 1941 $('#confirmDelete').click(function() { 1942 deleteModal.hide(); // Hide delete modal 1943 showLoading("Deleting assets..."); 1944 const startTime = performance.now(); 1945 1946 // Send AJAX POST request to start the delete operation 1947 $.ajax({
1948 url: '/bin/assetreport/move/thread/res', 1949 type: 'POST', 1950 data: assetForm.serialize() + '&action=delete', 1951 dataType: 'json', 1952 success: function(data) { 1953 const endTime = performance.now(); 1954 const responseTime = (endTime - startTime).toFixed(2); 1955 responseTimeArea.html(`<div class='response-time-display'>Initial Response: ${responseTime} ms</div>`); 1956 responseArea.html("Deletion operation started. Tracking progress..."); 1957 1958 if (data && data.operationId) { 1959 currentOperationId = data.operationId; 1960 pollingInterval = setInterval(pollStatus, 10000); 1961 } else { 1962 hideLoading(`<div class='error-message'>Failed to start operation or retrieve operation ID. No ID returned.</div>`, responseTime); 1963 } 1964 }, 1965 error: function(jqXHR, textStatus, errorThrown) { 1966 const endTime = performance.now(); 1967 const responseTime = (endTime - startTime).toFixed(2); 1968 let errorMsg = "An unknown error occurred."; 1969 if (jqXHR.responseJSON && jqXHR.responseJSON.error) { 1970 errorMsg = jqXHR.responseJSON.error; 1971 } else if (jqXHR.responseText) { 1972 errorMsg = jqXHR.responseText; 1973 } else { 1974 errorMsg = `Error: ${textStatus} - ${errorThrown}`; 1975 } 1976 hideLoading(`<div class='error-message'>Error deleting assets: ${errorMsg}</div>`, responseTime); 1977 } 1978 }); 1979 }); 1980 1981 // Close modals when clicking outside of them 1982 $(window).click(function(event) { 1983 if (event.target === moveModal[0]) { 1984 moveModal.hide(); 1985 } 1986 if (event.target === deleteModal[0]) { 1987 deleteModal.hide(); 1988 } 1989 }); 1990 1991 // Initial state setup when the page loads 1992 responseArea.html("Ready to start an asset operation. Please enter folder paths above."); 1993 operationButtons.prop('disabled', false); // Ensure all buttons are enabled on initial page load 1994});
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.