1NWS.initNamespace("NWS.Block.Aggregation", function () { 2 var _ = { 3 AjaxCompleteNotifier: new NWS.Util.Notifier("AjaxComplete"), 4 5 ShowHideWaiting: function (blockID, isWaiting) { 6 var prefix = NWS.Block.Aggregation.MakePrefix(blockID), 7 waitingDiv = document.getElementById(prefix + "Waiting"), 8 resultsArea = document.getElementById(prefix + "ResultsDiv"); 9 10 if (resultsArea) { 11 let blockRoot = NWS.Util.GetClosest(resultsArea, ".TitanBlock"); 12 if (blockRoot && !blockRoot.hasAttribute("aria-live")) 13 blockRoot.setAttribute("aria-live", "polite"); 14 } 15 16 if (waitingDiv) 17 waitingDiv.className = isWaiting ? "loading waiting" : "loading"; 18 19 if (resultsArea) 20 resultsArea.style.display = isWaiting ? "none" : "block"; 21 }, 22 23 /* Recursively test a function's caller to see if an Event is the source of the call. 24 As long as the calling function isn't PageEvent, this indicates we need to reset 25 the page to 1. 26 */ 27 DoPageReset: function(caller) { 28 if (!(caller instanceof Function) || caller.name === "PageEvent") 29 return false; 30 31 if ([...caller.arguments].some(arg => arg instanceof Event)) 32 return true; 33 34 return _.DoPageReset(caller.caller); 35 }, 36 37 IsAjax: function (prefix) { 38 var enabledCtl = document.getElementById(prefix + "ajaxEnabled"); 39 if (!enabledCtl) 40 return false; 41 42 return enabledCtl.value === "1"; 43 }, 44 45 DoSubmit: function (submittingBlockID) { 46 location.search = NWS.Block.Aggregation.BuildFullQueryString(submittingBlockID); 47 }, 48 49 HandleAriaExpanded: function (fieldset) { 50 if (!fieldset) 51 return; 52 53 let isCollapsed = fieldset.classList.contains("min"), 54 titleSpan = NWS.Util.QueryGet(".head > span[role='button'][aria-expanded]", fieldset); 55 56 if (titleSpan) 57 titleSpan.setAttribute("aria-expanded", isCollapsed ? "false" : "true"); 58 }, 59 60 AjaxCompleteScrollKey: "AggregationScroll", 61 AjaxCompleteScroll: function (resultsDiv) { 62 NWS.Util.ScrollTo(resultsDiv, { behavior: "smooth", block: "start", inline: "start" }); 63 } 64 }; 65 66 var RequeryTimer = { 67 Timers: [], 68 TimerIDs: [], 69 LastValue: { 70 Set: function (id, value) { 71 var idx = RequeryTimer.TimerIDs.indexOf(id); 72 if (idx === -1) 73 return; 74 75 RequeryTimer.Timers[idx].lastValue = value; 76 }, 77 Get: function (id) { 78 var idx = RequeryTimer.TimerIDs.indexOf(id); 79 return idx === -1 ? "" : RequeryTimer.Timers[idx].lastValue; 80 } 81 }, 82 83 Clear: function (ctl) { 84 var idx = RequeryTimer.TimerIDs.indexOf(ctl.id); 85 if (idx === -1) 86 return; 87 88 window.clearTimeout(RequeryTimer.Timers[idx].timer); 89 }, 90 91 KeyUp: function (ctl, methodToCall, methodArgs, delayMs) { 92 var idx = RequeryTimer.TimerIDs.indexOf(ctl.id); 93 if (idx === -1) { 94 idx = RequeryTimer.Timers.length; 95 RequeryTimer.Timers.push({ id: ctl.id, lastValue: ctl.defaultValue, timer: null }); 96 RequeryTimer.TimerIDs.push(ctl.id); 97 } 98 else { 99 RequeryTimer.Clear(ctl); 100 } 101 102 RequeryTimer.Timers[idx].timer = window.setTimeout(function () { 103 var newValue = ctl.value; 104 if (newValue !== RequeryTimer.LastValue.Get(ctl.id)) { 105 RequeryTimer.LastValue.Set(ctl.id, newValue); 106 ctl.value = newValue; 107 108 methodToCall.apply(methodToCall, methodArgs); 109 } 110 }, !delayMs || isNaN(delayMs) ? 500 : delayMs); 111 } 112 }; 113 114 return { 115 OnAjaxComplete: function (who, callback, callbackArgs, once = false) { 116 _.AjaxCompleteNotifier.Subscribe(who, callback, callbackArgs, once); 117 }, 118 119 /* This function is not called by Base Titan. Left for legacy support, and will be removed in a future version. */ 120 Init: function (jsModules, callbacks) { 121 console.warn("This function is obsolete and will be removed in a future version. Implement ILoadResources on your block processor class instead."); 122 NWS.Modules.LoadResources(jsModules, callbacks); 123 }, 124 125 MakePrefix: function (blockID) { 126 return ["F", String(blockID), "_"].join(""); 127 }, 128 129 MakeFullPrefix: function (blockID, classID) { 130 return [NWS.Block.Aggregation.MakePrefix(blockID), "C", String(classID), "_"].join(""); 131 }, 132 133 GetPageNumCtl: function (prefix) { 134 return document.getElementById(prefix + "PageNum"); 135 }, 136 137 GetSortOrderCtl: function (prefix) { 138 return document.getElementById(prefix + "SortOrder"); 139 }, 140 141 GetKeywordCtl: function (prefix) { 142 return document.getElementById(prefix + "keywordFilter"); 143 }, 144 145 GetFolderIDCtl: function (prefix) { 146 return document.getElementById(prefix + "FolderID"); 147 }, 148 149 GetDocIDCtl: function (prefix) { 150 return document.getElementById(prefix + "DocID"); 151 }, 152 153 GetResultsDiv: function (prefix) { 154 return document.getElementById(prefix + "ResultsDiv"); 155 }, 156 157 GetInputsDiv: function (blockID, classID) { 158 var div = document.getElementById(NWS.Block.Aggregation.MakeFullPrefix(blockID, classID) + "div"); 159 if (div.classList.contains("inputs")) 160 return div; 161 162 return null; 163 }, 164 165 GetTagFieldset: function (blockID, classID) { 166 return document.getElementById(NWS.Block.Aggregation.MakeFullPrefix(blockID, classID) + "fieldset"); 167 }, 168 169 GetFilterDocumentRoot: function (blockPrefix) { 170 var root = document.getElementById("FilterArea_" + blockPrefix); 171 if (!root) 172 return document; 173 174 return root; 175 }, 176 177 BuildFullQueryString: function (submittingBlockID) { 178 var params = window.location.search; 179 if (params.indexOf("?") === 0) 180 params = params.substring(1, params.length); 181 182 params = NWS.Block.Aggregation.RemoveExistingFilterBlockParams(params, false); 183 if (params.length > 0) 184 params += "&"; 185 186 var tagValues = []; 187 var qsParams = []; 188 189 var isSegSearch = false; 190 var allDivs = document.getElementsByTagName("DIV"); 191 for (var ii = 0; ii < allDivs.length; ++ii) { 192 if (!allDivs[ii].id) 193 continue; 194 195 if (allDivs[ii].id.indexOf("FilterArea_F") !== 0) 196 continue; 197 198 var blockID = allDivs[ii].getAttribute("blockID"); 199 if (!blockID) 200 continue; 201 202 if (allDivs[ii].getAttribute("blockPrefix") === "SegmentedSearch_") { 203 isSegSearch = 1; 204 params = NWS.Block.SegmentedSearch.RemoveSegSearchParams(params); 205 } 206 207 /* both of these calls require the less precise comparison using == since there's a mix of 208 * strings and integers being passed 209 */
210 var newTags = NWS.Block.Aggregation.ExtractTagQueryString(blockID, blockID == submittingBlockID); 211 var newQSArgs = NWS.Block.Aggregation.ExtractQSParams(blockID, blockID == submittingBlockID); 212 213 if (newTags.length > 0) 214 tagValues.push(newTags + "!"); 215 if (newQSArgs.length > 0) 216 qsParams.push(newQSArgs + "&"); 217 } 218 219 if (document.getElementById("FilterArea_F" + String(submittingBlockID) + "_") === null) 220 qsParams.push(NWS.Block.Aggregation.ExtractQSParams(submittingBlockID, true) + "&"); 221 222 if (isSegSearch) { 223 var sort = SS_SortOps.GetValues(blockID); 224 if (sort) 225 qsParams.push("SS_Sort=" + sort.sortKey + "&SS_SortDir=" + sort.sortDir); 226 qsParams.push("&SS_MinMax=" + SS_MinMax.Get(blockID)); 227 qsParams.push("&SS_PageNum=" + SS_PageNum.Get(blockID)); 228 qsParams.push("&SS_MinDate=" + SS_DateOps.GetMin(blockID) + "&SS_MaxDate=" + SS_DateOps.GetMax(blockID)); 229 qsParams.push("&SS_Action=" + String(SS_NavOps.SelectedAction(blockID)) + "&SS_Position=" + String(SS_NavOps.SelectedPosition(blockID))); 230 qsParams.push("&SS_Keyword=" + SS_Keyword.Get(blockID)); 231 } 232 233 params += "FB_Values=" + tagValues.join(""); 234 if (qsParams.length) 235 params += "&" + qsParams.join(""); 236 237 return params; 238 }, 239 240 RemoveExistingFilterBlockParams: function (params, removeSearch) { 241 if (!params) 242 return ""; 243 244 var retVal = "&"; 245 var paramArray = params.split("&"); 246 for (var ii = 0; ii < paramArray.length; ++ii) 247 if (paramArray[ii].indexOf("FB_Values") === 0 || 248 paramArray[ii].match(/^F\d*_/)) 249 ; 250 else if (removeSearch && paramArray[ii].indexOf("Search_Keywords") === 0) 251 ; 252 else if (paramArray[ii].length) 253 retVal += paramArray[ii] + "&"; 254 255 return retVal.substring(1); 256 }, 257 258 ClassificationMinMax: function (blockID, classID) { 259 NWS.FilterSupport.FilterBlock.ClassificationMinMax(blockID, classID); 260 }, 261 262 RecalcSeeAllLess: function (blockID, classID) { 263 var fieldset = NWS.Block.Aggregation.GetTagFieldset(blockID, classID); 264 if (!fieldset) 265 return; 266 267 if (!fieldset.getAttribute("limitNum")) 268 return; 269 270 var limit = parseInt(fieldset.getAttribute("limitNum")); 271 if (!limit || limit > 1000) 272 return; 273 274 var inputsDiv = NWS.Block.Aggregation.GetInputsDiv(blockID, classID); 275 if (!inputsDiv) 276 return; 277 278 var hideZeros = fieldset.classList.contains("hideZero"); 279 var prefix = NWS.Block.Aggregation.MakeFullPrefix(blockID, classID); 280 var allInputs = inputsDiv.getElementsByTagName("DIV"); 281 for (var ii = 0; ii < allInputs.length; ++ii) { 282 if (!allInputs[ii].id || allInputs[ii].id.indexOf(prefix) !== 0) 283 continue; 284 285 if (allInputs[ii].classList.contains("selected")) { 286 limit--; 287 allInputs[ii].classList.remove("seeMore"); 288 } 289 } 290 291 var oneHidden = false; 292 for (var jj = 0; jj < allInputs.length; ++jj) { 293 if (!allInputs[jj].id || allInputs[jj].id.indexOf(prefix) !== 0) 294 continue; 295 296 if (allInputs[jj].classList.contains("selected")) 297 continue; 298 299 if (hideZeros && allInputs[jj].classList.contains("zero")) 300 continue; 301 302 if (limit-- <= 0) { 303 allInputs[jj].classList.add("seeMore"); 304 oneHidden = true; 305 } 306 else 307 allInputs[jj].classList.remove("seeMore"); 308 } 309 310 var more = document.getElementById(prefix + "more"); 311 var less = document.getElementById(prefix + "less"); 312 if (more) 313 more.style.display = oneHidden ? "" : "none"; 314 if (less) 315 less.style.display = oneHidden ? "" : "none"; 316 }, 317 318 SeeAllLess: function (blockID, classID, evt) { 319 if (evt && evt.preventDefault) 320 evt.preventDefault(); 321 NWS.FilterSupport.FilterBlock.SeeAllLess(blockID, classID); 322 }, 323 324 CollapseTagSet: function (blockID, classID, turnOn) { 325 var fieldset = NWS.Block.Aggregation.GetTagFieldset(blockID, classID); 326 if (!fieldset) 327 return; 328 329 if (fieldset.getAttribute("runaway") !== "1") 330 return; 331 332 if (turnOn) 333 fieldset.classList.add("min"); 334 else 335 fieldset.classList.remove("min"); 336 337 _.HandleAriaExpanded(fieldset); 338 }, 339 340 SetInputWrapperSelect: function (id) { 341 document.getElementById(id + "_div").classList.add("selected"); 342 }, 343 344 RemoveInputWrapperSelect: function (id) { 345 document.getElementById(id + "_div").classList.remove("selected"); 346 }, 347 348 ResetAllClassifications: function (blockID, docID, evt) { 349 evt.preventDefault(); 350 351 var prefix = NWS.Block.Aggregation.MakePrefix(blockID), 352 filterBlock = document.getElementById("FilterArea_" + prefix), 353 fieldsets = filterBlock.querySelectorAll("fieldset"); 354 355 for (var i = 0; i < fieldsets.length; i++) { 356 var classID = fieldsets[i].getAttribute("classid"); 357 var classes = fieldsets[i].getAttribute("class"); 358 359 // keyword filter 360 if (classes === "keyword") { 361 var keywordInput = fieldsets[i].querySelector(".input input[type='text']"); 362 keywordInput.value = ""; 363 continue; 364 } 365 366 // calendar filter - resets based on current date 367 if (classes === "calendar") { 368 var start = NWS.Util.Get(NWS.Block.Aggregation.MakePrefix(blockID) + "OrigStart"), 369 today = (start && start.value) ? new Date(start.value) : new Date(), 370 firstOfMonth = new Date(today.getFullYear(), today.getMonth(), 1); 371 NWS.Util.Get(NWS.Block.Aggregation.MakePrefix(blockID) + "Start").value =
371String(today.getMonth() + 1) + "/" + today.getDate() + "/" + today.getFullYear(); 372 var calendarWidget = NWS.Util.Get("widget" + blockID); 373 if (calendarWidget) { 374 calendarWidget.setAttribute("selectedDate", today.toString()); 375 NWS.FilterSupport.CalendarFilter.WidgetInit(blockID); 376 } else { 377 var from = NWS.Util.Get("F" + blockID + "_calendarFrom"), 378 to = NWS.Util.Get("F" + blockID + "_calendarTo"); 379 from.value = to.value = ""; 380 NWS.Util.Get(NWS.Block.Aggregation.MakePrefix(blockID) + "Start").value = ""; 381 } 382 NWS.Util.Get(NWS.Block.Aggregation.MakePrefix(blockID) + "End").value = ""; 383 continue; 384 } 385 386 // Legacy Suggestion filter 387 if (classes !== null && classes.indexOf("suggestBox") > -1) { 388 NWS.FilterSupport.TagSuggest.Reset(blockID, classID, "FilterBlock_", evt); 389 continue; 390 } 391 392 if (classID !== null) 393 NWS.Block.Aggregation.ResetSelections(blockID, classID); 394 else { 395 // clear static checkboxes 396 var checkboxes = fieldsets[i].querySelectorAll("input[type='checkbox']"); 397 for (var j = 0; j < checkboxes.length; j++) 398 checkboxes[j].checked = false; 399 400 // clear dropdown filter 401 var select = fieldsets[i].querySelector("select"); 402 if (select) 403 select.selectedIndex = 0; 404 } 405 } 406 407 NWS.Block.Aggregation.Submit(blockID, 1); 408 }, 409 410 ResetSelectClass: function (target, selected, blockID, classID) { 411 if (selected) 412 NWS.Block.Aggregation.SetInputWrapperSelect(target.id); 413 else 414 NWS.Block.Aggregation.RemoveInputWrapperSelect(target.id); 415 416 NWS.Block.Aggregation.CollapseTagSet(blockID, classID, selected); 417 }, 418 419 ResetSelections: function (blockID, classID) { 420 var div = NWS.Block.Aggregation.GetInputsDiv(blockID, classID); 421 if (!div) 422 return; 423 424 var boxes = div.getElementsByTagName("INPUT"); 425 for (var ii = 0; ii < boxes.length; ++ii) 426 if (boxes[ii].checked) { 427 document.getElementById(boxes[ii].id + "_div").classList.remove("selected"); 428 boxes[ii].checked = false; 429 } 430 431 NWS.Block.Aggregation.RecalcSeeAllLess(blockID, classID); 432 433 var fieldset = NWS.Block.Aggregation.GetTagFieldset(blockID, classID); 434 fieldset.classList.remove("min"); 435 if (fieldset.classList.remove("seeMore")) 436 fieldset.classList.add("seeLess"); 437 438 _.HandleAriaExpanded(fieldset); 439 }, 440 441 ResetClassificationLink: function (blockID, classID, evt) { 442 if (evt && evt.preventDefault) 443 evt.preventDefault(); 444 445 NWS.Block.Aggregation.ResetClassificationCheckbox(blockID, classID); 446 var prefix = NWS.Block.Aggregation.MakePrefix(blockID); 447 if (!_.IsAjax(prefix)) 448 NWS.Block.Aggregation.Submit(blockID, 1); 449 }, 450 451 ResetClassificationCheckbox: function (blockID, classID, evt) { 452 if (evt && evt.preventDefault) 453 evt.preventDefault(); 454 455 NWS.Block.Aggregation.ResetSelections(blockID, classID); 456 NWS.Block.Aggregation.ClassificationCheck(blockID); 457 458 var prefix = NWS.Block.Aggregation.MakePrefix(blockID); 459 if (!_.IsAjax(prefix)) 460 NWS.Block.Aggregation.Submit(blockID, 1); 461 }, 462 463 ClassificationSelectChange: function (blockID) { 464 NWS.Block.Aggregation.ClassificationCheck(blockID); 465 }, 466 467 ResetFieldsetState: function (blockID) { 468 var fieldsets = document.getElementsByTagName("FIELDSET"); 469 for (var ii = 0; ii < fieldsets.length; ++ii) { 470 var nonZero = false, hasSelection = false; 471 var allSpans = fieldsets[ii].getElementsByTagName("SPAN"); 472 for (var jj = 0; jj < allSpans.length; ++jj) { 473 if (!allSpans[jj].classList.contains("uses")) 474 continue; 475 476 if (allSpans[jj].getAttribute("uses") !== "0") 477 nonZero = true; 478 else 479 continue; 480 481 var parent = allSpans[jj].parentNode; 482 while (parent && parent.tagName !== "DIV") 483 parent = parent.parentNode; 484 if (parent.classList.contains("selected")) 485 hasSelection = true; 486 487 if (nonZero && hasSelection) 488 break; 489 } 490 491 if (fieldsets[ii].getAttribute("runaway") === "1") { 492 if (hasSelection) 493 fieldsets[ii].classList.add("min"); 494 else 495 fieldsets[ii].classList.remove("min"); 496 497 _.HandleAriaExpanded(fieldsets[ii]); 498 } 499 500 if (fieldsets[ii].classList.contains("hideZero") && !nonZero) 501 fieldsets[ii].style.display = "none"; 502 else { 503 fieldsets[ii].style.display = null; // allow to fall back to default styling 504 505 var blockDataFieldID = blockID; 506 if (fieldsets[ii].getAttribute("dataField")) 507 blockDataFieldID = blockDataFieldID + "_DF" + fieldsets[ii].getAttribute("dataField"); 508 509 NWS.Block.Aggregation.RecalcSeeAllLess(blockDataFieldID, fieldsets[ii].getAttribute("classID")); 510 } 511 } 512 }, 513 514 AjaxComplete: function (ajaxResult, blockID) { 515 if (!ajaxResult) 516 return; 517 var response = ajaxResult.response; 518 if (response && response.javascript) { 519 var arrOfDates = new Function('"use strict"; return (' + response.javascript + ')')(); 520 NWS.FilterSupport.CalendarFilter.SelectDates("widget" + blockID, arrOfDates); 521 } 522 523 var blockPrefix = NWS.Block.Aggregation.MakePrefix(blockID); 524 var resultsArea = NWS.Block.Aggregation.GetResultsDiv(blockPrefix); 525 if (!resultsArea) 526 return; 527 528 if (response && response.htmlData) 529 resultsArea.innerHTML = response.htmlData; 530 if (response && response.suggestionUpdates) 531 NWS.Block.Aggregation.UpdateFilterSuggestions(blockID, response.suggestionUpdates); 532 if (response && response.filterUpdateArray) 533 NWS.Block.Aggregation.UpdateFilterCounts(blockID, response.filterUpdateArray); 534 else 535 NWS.Block.Aggregation.ResetFieldsetState(blockID); 536 537 _.ShowHideWaiting(blockID, false); 538 _.AjaxCompleteNotifier.Notify(resultsArea); 539 }, 540 541 ReCheck: function (blockID, docID) { 542 let calendarWidget = NWS.Util.Get("widget" + blockID); 543 if (calendarWidget && calendarWidget.hasAttribute("doInit")) { 544 NWS.FilterSupport.CalendarFilter.WidgetInit(blockID); 545 calendarWidget.removeAttribute("doInit"); 546 } 547 548 // PENDING additional testing 549 //restore pagination 550 //let hiddenChanged = NWS.HistoryExtensions.HiddenState.Restore(); 551 552 var prefix = NWS.Block.Aggregation.MakePrefix(blockID); 553 var skipResubmit = NWS.Block.Aggregation.GetResultsDiv(prefix) /*&& !hiddenChanged*/ && !NWS.Block.Aggregation.ResubmitCheckForChanges(blockID); 554 555 if (skipResubmit) 556 return NWS.Block.Aggregation.AjaxComplete(null, blockID); 557 else 558 return NWS.Block.Aggregation.ClassificationCheck(blockID); 559 }, 560 561 ResubmitCheckForChanges: function (blockID) { 562 var prefix = NWS.Block.Aggregation.MakePrefix(blockID); 563 var retVal = false; 564 565 var pageNum = NWS.Block.Aggregation.GetPageNumCtl(prefix); 566 if (pageNum && pageNum.value !== pageNum.defaultValue) 567 retVal |= true; 568 569 var sortOrderCtl = NWS.Block.Aggregation.GetSortOrderCtl(prefix); 570 if (sortOrderCtl && sortOrderCtl.value !== sortOrderCtl.defaultValue) 571 retVal |= true; 572 573 var keywordFilterCtl = NWS.Block.Aggregation.GetKeywordCtl(prefix); 574 if (keywordFilterCtl && keywordFilterCtl.value !== keywordFilterCtl.defaultValue) 575 retVal |= true; 576 577 retVal |= NWS.Block.Aggregation.HaveClassificationsChanged(prefix, blockID); 578 579 return retVal; 580 }, 581 582 UpdateFilterSuggestions: function (blockID, suggestionUpdates) { 583 if (!suggestionUpdates || suggestionUpdates.length === 0) 584 return; 585 586 for (var ii = 0; ii < suggestionUpdates.length; ii++) { 587 var attribs = document.getElementById(suggestionUpdates[ii].id + "_attributes"); 588 if (attribs) 589 attribs.value = JSON.stringify(suggestionUpdates[ii]); 590 } 591 }, 592 593 UpdateFilterCounts: function (blockID, filterArray) { 594 if (!filterArray || filterArray.length === 0) 595 return NWS.Block.Aggregation.ResetFieldsetState(blockID); 596 597 for (var ii = 0; ii < filterArray.length; ++ii) { 598 var ctl = document.getElementById(filterArray[ii].i + "_div"); 599 if (!ctl) 600 continue; 601 602 if (filterArray[ii].v === 0) 603 ctl.classList.add("zero"); 604 else 605 ctl.classList.remove("zero"); 606 607 var spans = ctl.getElementsByTagName("SPAN"); 608 for (var jj = 0; jj < spans.length; ++jj) 609 if (spans[jj].classList.contains("uses")) { 610 spans[jj].innerHTML = " (" + String(filterArray[ii].v) + ")"; 611 spans[jj].setAttribute("uses", filterArray[ii].v); 612 break; 613 } 614 } 615 616 NWS.Block.Aggregation.ResetFieldsetState(blockID); 617 }, 618 619 ClassificationLinkSelect: function (blockID, classID, container, evt) { 620 NWS.FilterSupport.FilterBlock.HandleCommonLinkSelect(blockID, classID, container, evt); 621 NWS.Block.Aggregation.Submit(blockID, 1); 622 }, 623 624 KeywordFilter: function (blockID) { 625 var blockPrefix = NWS.Block.Aggregation.MakePrefix(blockID), 626 keywordCtl = NWS.Block.Aggregation.GetKeywordCtl(blockPrefix); 627 628 if (!_.IsAjax(blockPrefix)) 629 return; 630 631 RequeryTimer.KeyUp(keywordCtl, NWS.Block.Aggregation.Submit, [blockID]); 632 }, 633 634 InitPagination: function (blockID) { 635 var prefix = NWS.Block.Aggregation.MakePrefix(blockID); 636 var resultsDiv = NWS.Block.Aggregation.GetResultsDiv(prefix); 637 NWS.Block.UI.InitializePagination(resultsDiv, function(pageNum, evt) { 638 NWS.Block.Aggregation.PageEvent(blockID, pageNum, evt); 639 }) 640 }, 641 642 PageEvent: function (blockID, pageNum, evt) { 643 if (evt && evt.preventDefault) 644 evt.preventDefault(); 645 646 NWS.Block.Aggregation.OnAjaxComplete(_.AjaxCompleteScrollKey, _.AjaxCompleteScroll, [], true); 647 648 NWS.Block.Aggregation.Submit(blockID, pageNum); 649 return false; 650 }, 651 652 Submit: function (blockID, pageNum) { 653 if (!pageNum) 654 pageNum = 1; 655 656 var prefix = NWS.Block.Aggregation.MakePrefix(blockID), 657 pageNumCtl = NWS.Block.Aggregation.GetPageNumCtl(prefix); 658 659 if (pageNumCtl) 660 pageNumCtl.value = pageNum; 661 662 // PENDING additional testing 663 // NWS.HistoryExtensions.HiddenState.Update(); 664 665 if (_.IsAjax(prefix)) 666 return NWS.Block.Aggregation.ClassificationCheck(blockID); 667 else 668 return _.DoSubmit(blockID); 669 }, 670 671 FormatClassifications: function (blockPrefix) { 672 var checkBoxes = [""]; 673 674 var allInputs = NWS.Block.Aggregation.GetFilterDocumentRoot(blockPrefix).getElementsByTagName("INPUT"); 675 for (var ii = 0; ii < allInputs.length; ++ii) { 676 var myId = allInputs[ii].id; 677 678 if (allInputs[ii].type === "checkbox" && // may be a filter checkbox 679 allInputs[ii].checked && // it is checked 680 myId.indexOf(blockPrefix) === 0) // and it is mine, all mine 681 checkBoxes.push(myId); 682 683 if (allInputs[ii].type === "radio" && // may be a filter checkbox 684 allInputs[ii].checked && // it is checked 685 myId.indexOf(blockPrefix) === 0) // and it is mine, all mine 686 checkBoxes.push(myId); 687 } 688 689 var allSelects = NWS.Block.Aggregation.GetFilterDocumentRoot(blockPrefix).getElementsByTagName("SELECT"); 690 for (var jj = 0; jj < allSelects.length; ++jj) { 691 if (!allSelects[jj].value || allSelects[jj].getAttribute("no-tag") === "1") 692 continue; 693 694 // Tag values should be safe, but encode them as a precaution 695 if (allSelects[jj].id.indexOf(blockPrefix) === 0) 696 checkBoxes.push(encodeURIComponent(allSelects[jj].value)); 697 } 698 699 var retVal = checkBoxes.join("!"); 700 return retVal.substring(1, Math.max(0, retVal.length)); 701 }, 702 703 FormatDefaultClassifications: function (blockPrefix) { 704 var root = NWS.Block.Aggregation.GetFilterDocumentRoot(blockPrefix), 705 checkBoxes = [""]; 706 707 var allInputs = root.getElementsByTagName("INPUT"); 708 for (var ii = 0; ii < allInputs.length; ++ii) { 709 var myId = allInputs[ii].id; 710 711 if (allInputs[ii].type === "checkbox" && // may be a filter checkbox 712 allInputs[ii].defaultChecked && // it is checked 713 myId.indexOf(blockPrefix) === 0) // and it is mine, all mine 714 checkBoxes.push(myId); 715 716 if (allInputs[ii].type === "radio" && // may be a filter checkbox 717 allInputs[ii].defaultChecked && // it is checked 718 myId.indexOf(blockPrefix) === 0) // and it is mine, all mine 719 checkBoxes.push(myId); 720 } 721 722 var allSelects = root.getElementsByTagName("SELECT"); 723 for (var jj = 0; jj < allSelects.length; ++jj) { 724 if (!allSelects[jj].value) 725 continue; 726 727 if (allSelects[jj].id.indexOf(blockPrefix) === 0) 728 checkBoxes.push(NWS.FormSupport.SFGetSelectDefaultValue(allSelects[jj].id)); 729 } 730 731 return checkBoxes.join("!"); 732 }, 733 734 HaveClassificationsChanged: function (blockPrefix, blockID) { 735 var hasChanges = false; 736 737 var allInputs = NWS.Block.Aggregation.GetFilterDocumentRoot(blockPrefix).getElementsByTagName("INPUT"); 738 for (var ii = 0; ii < allInputs.length; ++ii) { 739 var myId = allInputs[ii].id; 740 741 if (allInputs[ii].type === "checkbox" && myId.indexOf(blockPrefix) === 0) { 742 hasChanges |= allInputs[ii].checked !== allInputs[ii].defaultChecked; 743 NWS.
743Block.Aggregation.ResetSelectClass(allInputs[ii], allInputs[ii].checked, blockID, parseInt(myId.substring(blockPrefix.length + 1))); 744 } 745 746 if (allInputs[ii].type === "radio" && 747 myId.indexOf(blockPrefix) === 0) { 748 hasChanges |= allInputs[ii].checked !== allInputs[ii].defaultChecked; 749 NWS.Block.Aggregation.ResetSelectClass(allInputs[ii], allInputs[ii].checked, blockID, parseInt(myId.substring(blockPrefix.length + 1))); 750 } 751 } 752 var allSelects = NWS.Block.Aggregation.GetFilterDocumentRoot(blockPrefix).getElementsByTagName("SELECT"); 753 for (var jj = 0; jj < allSelects.length; ++jj) { 754 if (allSelects[jj].id.indexOf(blockPrefix) === 0 && 755 NWS.FormSupport.SFGetSelectValue(allSelects[jj].id) !== NWS.FormSupport.SFGetSelectDefaultValue(allSelects[jj].id)) { 756 return true; 757 } 758 } 759 760 return hasChanges; 761 }, 762 763 ClassificationDynamicCheck: function (blockID, classID, ctl) { 764 NWS.Block.Aggregation.ResetSelectClass(ctl, ctl.checked, classID); 765 NWS.Block.Aggregation.Submit(blockID, 1); 766 }, 767 768 ClassificationCheck: function (blockID) { 769 var prefix = NWS.Block.Aggregation.MakePrefix(blockID); 770 if (!_.IsAjax(prefix)) 771 return; 772 773 /* TITAN-1427 - Static Checkbox (and later found Dropdown) changes aren't resetting the 774 * page number to 1. 775 * 776 * This function was originally intended to be the event handler for user interactions 777 * but over time became the defacto path thru which we call for filtered results, and 778 * needs to keep the page number value as set. 779 * 780 * The _.DoPageReset function tests the arguments up the call chain to locate an Event 781 * not from the PageEvent function. The existance of an Event means that we must reset 782 * the page to 1. If there is no Event, then will use the pageNum set by any preceeding 783 * calls 784 */ 785 let pageNumCtl = NWS.Block.Aggregation.GetPageNumCtl(prefix); 786 if (pageNumCtl && pageNumCtl.value && _.DoPageReset(this.ClassificationCheck.caller)) 787 pageNumCtl.value = 1; 788 789 var docID = document.getElementById(prefix + "DocID").value, 790 keywordCtl = NWS.Block.Aggregation.GetKeywordCtl(prefix), 791 startCtl = document.getElementById(prefix + "Start"), 792 endCtl = document.getElementById(prefix + "End"), 793 queryArgs = { 794 pageNumber: pageNumCtl && pageNumCtl.value ? pageNumCtl.value : "1", 795 keyword: keywordCtl ? keywordCtl.value : "", 796 classifications: NWS.Block.Aggregation.FormatClassifications(prefix), 797 startDate: startCtl ? startCtl.value : "", 798 endDate: endCtl ? endCtl.value : "" 799 }, 800 args = { 801 docID: docID, 802 blockID: blockID, 803 query: JSON.stringify(queryArgs) 804 }, 805 callback = NWS.Ajax.QueuedCallback("FilterBlock_" + blockID, function (result) { NWS.Block.Aggregation.AjaxComplete(result, blockID); }); 806 807 _.ShowHideWaiting(blockID, true); 808 NWS.Ajax.Post("/AggregationV2Ajax/GetFilterResults", args, "json", callback); 809 }, 810 811 ExtractTagQueryString: function (blockID, useCurrent) { 812 var prefix = NWS.Block.Aggregation.MakePrefix(blockID); 813 if (useCurrent || _.IsAjax(prefix)) 814 return NWS.Block.Aggregation.FormatClassifications(prefix); 815 else 816 return NWS.Block.Aggregation.FormatDefaultClassifications(prefix); 817 }, 818 819 ExtractQSParams: function (blockID, useCurrent) { 820 var prefix = NWS.Block.Aggregation.MakePrefix(blockID); 821 if (useCurrent || _.IsAjax(prefix)) 822 return NWS.Block.Aggregation.NonTagQueryStringValues(prefix); 823 else 824 return NWS.Block.Aggregation.NonTagQueryStringDefaultValues(prefix); 825 }, 826 827 NonTagQueryStringValues: function (blockPrefix) { 828 var newQueryString = []; 829 830 newQueryString.push("&"); 831 var allInputs = document.getElementsByTagName("INPUT"); 832 for (var ii = 0; ii < allInputs.length; ++ii) { 833 if (allInputs[ii].getAttribute("no-qs") === "1") 834 continue; 835 836 var myId = allInputs[ii].id; 837 if (allInputs[ii].type === "hidden" && 838 myId.indexOf(blockPrefix) === 0) 839 newQueryString.push(myId + "=" + encodeURIComponent(allInputs[ii].value) + "&"); 840 else if (allInputs[ii].type === "text" && 841 myId.indexOf(blockPrefix) === 0) 842 newQueryString.push(myId + "=" + encodeURIComponent(allInputs[ii].value) + "&"); 843 } 844 845 var allSelects = NWS.Block.Aggregation.GetFilterDocumentRoot(blockPrefix).getElementsByTagName("SELECT"); 846 for (var jj = 0; jj < allSelects.length; ++jj) { 847 if (!allSelects[jj].getAttribute("no-tag") || allSelects[jj].getAttribute("no-tag") !== 1) 848 continue; 849 850 if (!allSelects[jj].value || allSelects[jj].getAttribute("no-qs") === "1") 851 continue; 852 853 var selectID = allSelects[jj].id; 854 if (selectID.indexOf(blockPrefix) === 0) 855 newQueryString.push(selectID + "=" + encodeURIComponent(allSelects[jj].value) + "&"); 856 } 857 858 var retVal = newQueryString.join(""); 859 return retVal.substring(1, Math.max(0, retVal.length - 1)); 860 }, 861 862 NonTagQueryStringDefaultValues: function (blockPrefix) { 863 var newQueryString = ["&"]; 864 865 var allInputs = document.getElementsByTagName("INPUT"); 866 for (var ii = 0; ii < allInputs.length; ++ii) { 867 if (allInputs[ii].getAttribute("no-qs") === "1") 868 continue; 869 870 var myId = allInputs[ii].id; 871 if (allInputs[ii].type === "hidden" && 872 myId.indexOf(blockPrefix) === 0) 873 newQueryString.push(myId + "=" + encodeURIComponent(allInputs[ii].defaultValue) + "&"); 874 else if (allInputs[ii].type === "text" && 875 myId.indexOf(blockPrefix) === 0) 876 newQueryString.push(myId + "=" + encodeURIComponent(allInputs[ii].defaultValue) + "&"); 877 } 878 879 var retVal = newQueryString.join(""); 880 return retVal.substring(1, Math.max(0, retVal.length - 1)); 881 }, 882 883 /* BANNER DISPLAY FUNCTIONS */ 884 Banner: { 885 SmallPrevNext: function (id, dir, numToDisplay, evt) { 886 NWS.Util.Event.Cancel(evt); 887 888 var bigDiv = document.getElementById(id); 889 if (!bigDiv) 890 return; 891 892 var smallKids = bigDiv.smallKids; 893 if (!smallKids || !smallKids.length) 894 return; 895 896 if (!bigDiv.firstSmall) 897 bigDiv.firstSmall = 0; 898 899 var prevButton = document.getElementById(id + "_smallPrev"), 900 nextButton = document.getElementById(id + "_smallNext"); 901 prevButton.classList.remove("disabled"); 902 nextButton.classList.remove("disabled"); 903 var newFirst = bigDiv.firstSmall; 904 newFirst += dir === "prev" ? -1 : 1; 905 if (newFirst <= 0) { 906 newFirst = 0; 907 prevButton.classList.add("disabled"); 908 } 909 else if (newFirst + numToDisplay >= smallKids.length) { 910 newFirst = smallKids.length - numToDisplay; 911 nextButton.classList.add("disabled"); 912 } 913 bigDiv.firstSmall = newFirst; 914 915 for (var ii = 0; ii < smallKids.length; ++ii) 916 if (ii < newFirst || ii >= newFirst + numToDisplay) 917 smallKids[ii].style.display = "none"; 918 else 919 smallKids[ii].style.display = "inline"; 920 }, 921 922 SmallImageClick: function (id, smallDiv, evt) { 923 NWS.Util.Event.Cancel(evt); 924 925 var bigDiv = document.getElementById(id); 926 if (!bigDiv) 927 return; 928 929 var smallKids = bigDiv.smallKids; 930 if (!smallKids || smallKids.length === 0) 931 return; 932 933 var clickedItem = evt.target; 934 while (clickedItem && clickedItem !== smallDiv) 935 if (clickedItem.classList.contains("image")) 936 break; 937 else 938 clickedItem = clickedItem.parentNode; 939 940 if (!clickedItem || clickedItem === smallDiv) 941 return; 942 943 var idx = -1; 944 for (idx = 0; idx < smallKids.length; ++idx) 945 if (smallKids[idx] === clickedItem) 946 break; 947 948 if (idx < 0 || idx >= smallKids.length) 949 return; 950 951 NWS.Block.Aggregation.BannerSetSmallSelect(smallKids, idx); 952 bigDiv.switchFunc(id, bigDiv, bigDiv.kids, idx); 953 }, 954
955 ForceNextPrev: function (id, dir) { 956 var bigDiv = document.getElementById(id); 957 if (!bigDiv) 958 return; 959 960 var newIdx = bigDiv.activeIdx + (dir === "next" ? 1 : -1); 961 if (newIdx >= bigDiv.kids.length) 962 newIdx = 0; 963 else if (newIdx < 0) 964 newIdx = bigDiv.kids.length - 1; 965 966 bigDiv.switchFunc(id, bigDiv, bigDiv.kids, newIdx); 967 }, 968 969 GrindCPU: function (id) { 970 var bigDiv = document.getElementById(id); 971 if (!bigDiv) 972 return; 973 974 var processingTime = bigDiv.processingTime; 975 if (!processingTime) 976 processingTime = bigDiv.imageTime; 977 else if (!bigDiv.isPaused) 978 processingTime = processingTime - bigDiv.sleepTime; 979 bigDiv.processingTime = processingTime; 980 981 if (bigDiv.isPaused || processingTime > bigDiv.transTime) 982 return window.setTimeout("NWS.Block.Aggregation.Banner.GrindCPU('" + id + "')", bigDiv.sleepTime); 983 984 return bigDiv.transFunc(id, bigDiv); 985 }, 986 987 PlayPause: function (id, isPaused) { 988 var bigDiv = document.getElementById(id); 989 if (!bigDiv) 990 return; 991 992 bigDiv.isPaused = isPaused; 993 var playButton = document.getElementById(id + "_PlayButton"), 994 pauseButton = document.getElementById(id + "_PauseButton"); 995 if (isPaused) { 996 pauseButton.classList.add("disabled"); 997 playButton.classList.remove("disabled"); 998 } 999 else { 1000 pauseButton.classList.remove("disabled"); 1001 playButton.classList.add("disabled"); 1002 } 1003 }, 1004 1005 SetSmallSelect: function (smallKids, idx) { 1006 if (!smallKids || smallKids.length === 0) 1007 return; 1008 1009 for (var ii = 0; ii < smallKids.length; ++ii) 1010 smallKids[ii].classList.remove("current"); 1011 1012 smallKids[idx].classList.add("current"); 1013 }, 1014 1015 InitTransition: function (id, transitionType, args) { 1016 var bigDiv = document.getElementById(id); 1017 if (!bigDiv) 1018 return; 1019 1020 var kids = []; 1021 for (var ii = 0; ii < bigDiv.childNodes.length; ++ii) 1022 if (bigDiv.childNodes[ii].tagName === "DIV") 1023 kids[kids.length] = bigDiv.childNodes[ii]; 1024 bigDiv.kids = kids; 1025 1026 var smallKids = []; 1027 var smallDiv = document.getElementById(id + "_smallStuff"); 1028 if (smallDiv) 1029 for (var jj = 0; jj < smallDiv.childNodes.length; ++jj) 1030 if (smallDiv.childNodes[jj].tagName === "DIV") 1031 smallKids[smallKids.length] = smallDiv.childNodes[jj]; 1032 bigDiv.smallKids = smallKids; 1033 1034 bigDiv.activeIdx = kids.length - 1; 1035 bigDiv.isPaused = false; 1036 switch (transitionType) { 1037 case "fade": 1038 bigDiv.switchFunc = this.Banner.SwitchFade; 1039 bigDiv.transFunc = this.Banner.TransitionFade; 1040 this.Banner.InitFade(id, bigDiv, kids, smallKids); 1041 break; 1042 case "fadeImageOnly": 1043 bigDiv.switchFunc = this.Banner.SwitchFadeImageOnly; 1044 bigDiv.transFunc = this.Banner.TransitionFadeImageOnly; 1045 this.Banner.InitFadeImageOnly(id, bigDiv, kids, smallKids); 1046 break; 1047 case "shiftLeft": 1048 bigDiv.switchFunc = this.Banner.SwitchShiftLeft; 1049 bigDiv.transFunc = this.Banner.TransitionShiftLeft; 1050 this.Banner.InitShiftLeft(id, bigDiv, kids, smallKids); 1051 break; 1052 default: 1053 return; 1054 } 1055 1056 for (var arg in args) 1057 bigDiv[arg] = args[arg]; 1058 1059 bigDiv.switchFunc(id, bigDiv, kids, 0); 1060 window.setTimeout("NWS.Block.Aggregation.Banner.GrindCPU('" + bigDiv.id + "')", bigDiv.sleepTime); 1061 }, 1062 1063 /* Banner Shift Left Functions */ 1064 InitShiftLeft: function (id, bigDiv, kids, smallKids) { 1065 for (var ii = 0; ii < kids.length; ++ii) 1066 kids[ii].style.zIndex = -10000; 1067 }, 1068 1069 TransitionShiftLeft: function (id, bigDiv) { 1070 var kids = bigDiv.kids; 1071 var sliderIdx = bigDiv.activeIdx + 1; 1072 if (sliderIdx >= kids.length) 1073 sliderIdx = 0; 1074 var slider = kids[sliderIdx]; 1075 if (!slider) 1076 return; 1077 1078 var currentLeft = bigDiv.currentLeft; 1079 if (!currentLeft) 1080 currentLeft = bigDiv.shiftWidth; 1081 1082 currentLeft -= (bigDiv.shiftWidth * bigDiv.sleepTime) / bigDiv.transTime; 1083 if (currentLeft <= 0) { 1084 bigDiv.switchFunc(id, bigDiv, kids, (bigDiv.activeIdx + 1) >= kids.length ? 0 : (bigDiv.activeIdx + 1)); 1085 return window.setTimeout("NWS.Block.Aggregation.Banner.GrindCPU('" + bigDiv.id + "')", bigDiv.sleepTime); 1086 } 1087 1088 bigDiv.currentLeft = currentLeft; 1089 slider.style.left = currentLeft; 1090 window.setTimeout("NWS.Block.Aggregation.Banner.GrindCPU('" + id + "')", bigDiv.sleepTime); 1091 }, 1092 1093 SwitchShiftLeft: function (id, bigDiv, kids, newIdx) { 1094 var oldIdx = bigDiv.activeIdx; 1095 if (oldIdx >= 0) { 1096 var oldCurrent = kids[oldIdx]; 1097 oldCurrent.classList.remove("ShowMeNow"); 1098 oldCurrent.style.zIndex = -10000; 1099 1100 var oldNext = oldIdx + 1; 1101 if (oldNext >= kids.length) 1102 oldNext = 0; 1103 1104 kids[oldNext].classList.remove("ShowMeNext"); 1105 kids[oldNext].style.left = 0; 1106 kids[oldNext].style.zIndex = newIdx === oldNext ? 0 : -10000; 1107 } 1108 1109 var newNext = newIdx + 1; 1110 if (newNext >= kids.length) 1111 newNext = 0; 1112 1113 kids[newIdx].classList.add("ShowMeNow"); 1114 kids[newNext].classList.add("ShowMeNext"); 1115 1116 bigDiv.processingTime = bigDiv.imageTime; 1117 bigDiv.currentLeft = bigDiv.shiftWidth; 1118 bigDiv.activeIdx = newIdx; 1119 1120 kids[newNext].style.left = bigDiv.currentLeft; 1121 kids[newIdx].style.zIndex = -1; 1122 kids[newNext].style.zIndex = 0; 1123 1124 if (bigDiv.syncSmall) 1125 this.Banner.SetSmallSelect(bigDiv.smallKids, newIdx); 1126 }, 1127 1128 /* Fade Functions */ 1129 InitFade: function () { 1130 for (var ii = 0; ii < kids.length; ++ii) 1131 kids[ii].style.zIndex = -10000; 1132 }, 1133 1134 TransitionFade: function () { 1135 var kids = bigDiv.kids; 1136 var nextIdx = bigDiv.activeIdx + 1; 1137 if (nextIdx >= kids.length) 1138 nextIdx = 0; 1139 var activeKid = kids[nextIdx]; 1140 if (!activeKid) 1141 return; 1142
1143 var currentFade = bigDiv.opacity; 1144 if (!currentFade) 1145 currentFade = 0; 1146 1147 currentFade = Number(currentFade); 1148 if (currentFade >= 100) { 1149 bigDiv.switchFunc(id, bigDiv, kids, nextIdx); // ((activeIdx+1)>=kids.length)?0:(activeIdx+1)); 1150 return window.setTimeout("NWS.Block.Aggregation.Banner.GrindCPU('" + bigDiv.id + "')", bigDiv.sleepTime); 1151 } 1152 1153 currentFade += (100 * bigDiv.sleepTime) / bigDiv.transTime; 1154 bigDiv.opacity = currentFade; 1155 1156 this.Banner.FadeSetOpacity(activeKid, currentFade); 1157 window.setTimeout("NWS.Block.Aggregation.Banner.GrindCPU('" + id + "')", bigDiv.sleepTime); 1158 }, 1159 1160 FadeSetOpacity: function (active, currentFade) { 1161 active.style.opacity = currentFade / 100.0; 1162 if (currentFade < 0) 1163 active.style.filter = 'none'; 1164 else 1165 active.style.filter = 'alpha(opacity = ' + String(currentFade) + ')'; 1166 }, 1167 1168 SwitchFade: function (id, bigDiv, kids, newIdx) { 1169 var oldIdx = bigDiv.activeIdx; 1170 if (oldIdx >= 0) { 1171 var oldCurrent = kids[oldIdx]; 1172 oldCurrent.classList.remove("ShowMeNow"); 1173 oldCurrent.style.zIndex = -10000; 1174 this.Banner.FadeSetOpacity(oldCurrent, -1);// turn filter off 1175 1176 var oldNext = oldIdx + 1; 1177 if (oldNext >= kids.length) 1178 oldNext = 0; 1179 1180 kids[oldNext].classList.remove("ShowMeNext"); 1181 kids[oldNext].style.zIndex = newIdx === oldNext ? -100 : -10000; 1182 this.Banner.FadeSetOpacity(kids[oldNext], -1);// turn filter off 1183 } 1184 1185 var newNext = newIdx + 1; 1186 if (newNext >= kids.length) 1187 newNext = 0; 1188 1189 kids[newIdx].classList.add("ShowMeNow"); 1190 kids[newNext].classList.add("ShowMeNext"); 1191 1192 kids[newIdx].style.zIndex = -100; 1193 kids[newNext].style.zIndex = 0; 1194 this.Banner.FadeSetOpacity(kids[newNext], 0); 1195 bigDiv.processingTime = bigDiv.imageTime; 1196 bigDiv.opacity = 0; 1197 bigDiv.activeIdx = newIdx; 1198 1199 if (bigDiv.syncSmall) 1200 this.Banner.SetSmallSelect(bigDiv.smallKids, newIdx); 1201 }, 1202 1203 /* Fade Image Only Functions */ 1204 InitFadeImageOnly: function (id, bigDiv, kids, smallKids) { 1205 for (var ii = 0; ii < kids.length; ++ii) 1206 kids[ii].style.zIndex = -10000; 1207 }, 1208 1209 TransitionFadeImageOnly: function (id, bigDiv) { 1210 var kids = bigDiv.kids; 1211 var activeIdx = bigDiv.activeIdx; 1212 var activeKid = kids[activeIdx]; 1213 if (!activeKid) 1214 return; 1215 1216 var currentFade = bigDiv.opacity; 1217 if (!currentFade) 1218 currentFade = 100; 1219 1220 currentFade = Number(currentFade); 1221 if (currentFade <= 0.0) { 1222 bigDiv.switchFunc(id, bigDiv, kids, ((activeIdx + 1) >= kids.length) ? 0 : (activeIdx + 1)); 1223 return window.setTimeout("NWS.Block.Aggregation.Banner.GrindCPU('" + bigDiv.id + "')", bigDiv.sleepTime); 1224 } 1225 1226 currentFade -= (100 * bigDiv.sleepTime) / bigDiv.transTime; 1227 bigDiv.opacity = currentFade; 1228 1229 this.Banner.FadeImageOnlySetOpacity(activeKid, currentFade); 1230 window.setTimeout("NWS.Block.Aggregation.Banner.GrindCPU('" + id + "')", bigDiv.sleepTime); 1231 }, 1232 1233 FadeImageOnlySetOpacity: function (active, currentFade) { 1234 var imgs = active.getElementsByTagName("IMG"); 1235 if (imgs.length === 2) { 1236 imgs[1].style.opacity = currentFade / 100.0; 1237 imgs[1].style.filter = 'alpha(opacity = ' + String(currentFade) + ')'; 1238 } 1239 }, 1240 1241 SwitchFadeImageOnly: function (id, bigDiv, kids, newIdx) { 1242 var oldIdx = bigDiv.activeIdx; 1243 if (oldIdx >= 0) { 1244 var oldCurrent = kids[oldIdx]; 1245 oldCurrent.classList.remove("ShowMeNow"); 1246 this.Banner.FadeImageOnlySetOpacity(oldCurrent, bigDiv.doImageOnly, 100); 1247 oldCurrent.style.zIndex = -10000; 1248 1249 var oldNext = oldIdx + 1; 1250 if (oldNext >= kids.length) 1251 oldNext = 0; 1252 1253 kids[oldNext].classList.remove("ShowMeNext"); 1254 kids[oldNext].style.zIndex = newIdx === oldNext ? 0 : -10000; 1255 } 1256 1257 var newNext = newIdx + 1; 1258 if (newNext >= kids.length) 1259 newNext = 0; 1260 1261 kids[newIdx].classList.add("ShowMeNow"); 1262 kids[newNext].classList.add("ShowMeNext"); 1263 1264 kids[newIdx].style.zIndex = 0; 1265 kids[newNext].style.zIndex = -100; 1266 bigDiv.processingTime = bigDiv.imageTime; 1267 bigDiv.opacity = 100; 1268 bigDiv.activeIdx = newIdx; 1269 1270 if (bigDiv.syncSmall) 1271 this.Banner.SetSmallSelect(bigDiv.smallKids, newIdx); 1272 } 1273 } 1274 }; 1275});
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.