1// Reset Select2 Menus - will remove properly from jsa_scripts.js eventually 2$(document).ready(function() { 3 const howButton = $("#howButton"); 4 const toolTip = $(".tool-tip"); 5 $('select').select2(); 6 $('select').select2('destroy'); 7 8 var navOpen = $('.jsa_content-wrap').hasClass('jsa_mobile-nav-open'); 9 console.log('navOpen' + navOpen); 10 if(navOpen) { 11 $("#leftMenuButton").attr("aria-expanded","true"); 12 } else { 13 $("#leftMenuButton").attr("aria-expanded","false"); 14 } 15 16 howButton.on("click", function(event) { 17 const isExpanded = howButton.attr("aria-expanded") === "true" ? false : true; 18 howButton.attr("aria-expanded", isExpanded); 19 toolTip.toggle("fast", "swing").attr("aria-expanded", isExpanded); 20 }).on("keydown", function(event) { 21 if (event.key.toUpperCase() === "ENTER") { 22 howButton.trigger("click"); 23 } 24 }).on("blur", function(event) { 25 const isExpanded = howButton.attr("aria-expanded") === "true"; 26 if (isExpanded) { 27 howButton.trigger("click"); 28 } 29 }); 30 31 $('.js-menu-trigger').on('click', function(){ 32 console.log('left menu button clicked'); 33 var leftMenuButtonStatus = $("#leftMenuButton").attr('aria-expanded'); 34 if (leftMenuButtonStatus == 'false'){ 35 $("#leftMenuButton").attr("aria-expanded","true"); 36 } else { 37 $("#leftMenuButton").attr("aria-expanded","false"); 38 } 39 }); 40 41}); 42 43$('select').on('focus', function() { 44 $(this).addClass('highlight').find('option').css('color', '#000'); 45}).on('blur', function() { 46 $(this).removeClass('highlight'); 47 if (this.value.length) $(this).addClass('highlight'); 48}).on('change', function() { 49 if (this.value.length) $(this).addClass('highlight'); 50 else $(this).removeClass('highlight'); 51}); 52 53 54// 55// EXAMPLE Datepicker configuration 56// 57////$(function () { 58// $('#datepicker').datepicker({ 59// showOn: 'button', 60// buttonImage: 'https://dequeuniversity.com/assets/images/calendar.png', // File (and file path) for the calendar image 61// buttonImageOnly: false, 62// buttonText: 'Calendar View', 63// dayNamesShort: [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ], 64// showButtonPanel: true, 65// closeText: 'Close', 66// onClose: removeAria 67// }); 68// 69// // Add aria-describedby to the button referring to the label 70// $('.ui-datepicker-trigger').attr('aria-describedby', 'datepickerLabel'); 71// 72// makeDatepickerAccessible(); 73// 74//}); 75 76 77function makeDatepickerAccessible(dpControlName) { 78 79 $('.input_row_'+dpControlName+' .ui-datepicker-trigger').click(function () { 80 setTimeout(function () { 81 var today = $('.ui-datepicker-today a')[0]; 82 83 if (!today) { 84 today = $('.ui-state-active')[0] || 85 $('.ui-state-default')[0]; 86 } 87 88 89 // Hide the entire page (except the date picker) 90 // from screen readers to prevent document navigation 91 // (by headings, etc.) while the popup is open 92 $("main").attr('id','dp-container'); 93 $("#dp-container").attr('aria-hidden','true'); 94 $("#skipnav").attr('aria-hidden','true'); 95 96 // Hide the "today" button because it doesn't do what 97 // you think it is supposed to do 98 $(".ui-datepicker-current").hide(); 99 100 today.focus(); 101 datePickHandler(dpControlName); 102 //console.log("click triggered"); 103 104 var click_count = 0; 105 $(document).on('click', '#ui-datepicker-div .ui-datepicker-close', function () { 106 if (click_count < 1){ 107 //console.log("Click count: "+click_count); 108 closeCalendar(dpControlName); 109 } 110 click_count = 1; 111 }); 112 }, 0); 113 }); 114} 115 116function datePickHandler(dpControlName) { 117 var activeDate; 118 var container = document.getElementById('ui-datepicker-div'); 119 var input = document.getElementById(dpControlName); 120 121 if (!container || !input) { 122 return; 123 } 124 125 // $(container).find('table').first().attr('role', 'grid'); 126 127 container.setAttribute('role', 'application'); 128 container.setAttribute('aria-label', 'Calendar view date-picker'); 129 130 // the top controls: 131 var prev = $('.ui-datepicker-prev', container)[0], 132 next = $('.ui-datepicker-next', container)[0]; 133 134 135// This is the line that needs to be fixed for use on pages with base URL set in head 136 next.href = 'javascript:void(0)'; 137 prev.href = 'javascript:void(0)'; 138 139 next.setAttribute('role', 'button'); 140 next.removeAttribute('title'); 141 prev.setAttribute('role', 'button'); 142 prev.removeAttribute('title'); 143 144 appendOffscreenMonthText(next); 145 appendOffscreenMonthText(prev); 146 147 // delegation won't work here for whatever reason, so we are 148 // forced to attach individual click listeners to the prev / 149 // next month buttons each time they are added to the DOM 150 $(next).on('click', handleNextClicks); 151 $(prev).on('click', handlePrevClicks); 152 153 monthDayYearText(dpControlName); 154 155 $(container).on('keydown', function calendarKeyboardListener(keyVent) { 156 var which = keyVent.which; 157 var target = keyVent.target; 158 var keyCode = keyVent.keyCode; 159 160 var dateCurrent = getCurrentDate(container); 161 162 if (!dateCurrent) { 163 dateCurrent = $('a.ui-state-default')[0]; 164 setHighlightState(dateCurrent, container); 165 } 166 167 if (27 === which || keyCode === 27) { 168 keyVent.stopPropagation(); 169 return closeCalendar(dpControlName); 170 } else if (which === 9 && keyVent.shiftKey) { // SHIFT + TAB 171 keyVent.preventDefault(); 172 if ($(target).hasClass('ui-datepicker-close')) { // close button 173 $('.ui-datepicker-prev')[0].focus(); 174 } else if ($(target).hasClass('ui-state-default')) { // a date link 175 $('.ui-datepicker-close')[0].focus(); 176 } else if ($(target).hasClass('ui-datepicker-prev')) { // the prev link 177 $('.ui-datepicker-next')[0].focus(); 178 } else if ($(target).hasClass('ui-datepicker-next')) { // the next link 179 activeDate = $('.ui-state-highlight') || 180 $('.ui-state-active')[0]; 181 if (activeDate) { 182 activeDate.focus(); 183 } 184 } 185 } else if (which === 9) { // TAB 186 keyVent.preventDefault(); 187 if ($(target).hasClass('ui-datepicker-close')) { // close button 188 activeDate = $('.ui-state-highlight') || 189 $('.ui-state-active')[0]; 190 if (activeDate) { 191 activeDate.focus(); 192 } 193 } else if ($(target).hasClass('ui-state-default')) { 194 $('.ui-datepicker-next')[0].focus(); 195 } else if ($(target).hasClass('ui-datepicker-next')) { 196 $('.ui-datepicker-prev')[0].focus(); 197 } else if ($(target).hasClass('ui-datepicker-prev')) { 198 $('.ui-datepicker-close')[0].focus(); 199 } 200 $('.ui-datepicker-close').focusin(function() { 201 console.log("close button takes focus"); 202 $('.ui-datepicker-close').addClass('ui-state-hover'); 203 }); 204 $('.ui-datepicker-close').focusout(function() { 205 console.log("close button takes focus"); 206 $('.ui-datepicker-close').removeClass('ui-state-hover'); 207 }); 208 } else if (which === 37) { // LEFT arrow key 209 // if we're on a date link... 210 if (!$(target).hasClass('ui-datepicker-close') && $(target).hasClass('ui-state-default')) { 211 keyVent.preventDefault(); 212 previousDay(target); 213 } 214 } else if (which === 39) { // RIGHT arrow key 215 // if we're on a date link... 216 if (!$(target).hasClass('ui-datepicker-close') && $(target).hasClass('ui-state-default')) { 217 keyVent.preventDefault(); 218 nextDay(target); 219 } 220 } else if (which === 38) { // UP arrow key 221 if (!$(target).hasClass('ui-datepicker-close') && $(target).hasClass('ui-state-default')) { 222 keyVent.preventDefault(); 223 upHandler(target, container, prev); 224 } 225 } else if (which === 40) { // DOWN arrow key 226 if (!$(target).hasClass('ui-datepicker-close') && $(target).hasClass('ui-state-default')) { 227 keyVent.preventDefault(); 228 downHandler(target, container, next); 229 } 230 } else if (which === 13) { // ENTER 231 if ($(target).hasClass('ui-state-default')) { 232 setTimeout(function () { 233 closeCalendar(dpControlName); 234 }, 100); 235 } else if ($(target).hasClass('ui-datepicker-prev')) { 236 handlePrevClicks(); 237 } else if ($(target).hasClass('ui-datepicker-next')) { 238 handleNextClicks(); 239 } 240 } else if (32 === which) { 241 if ($(target).hasClass('ui-datepicker-prev') || $(target).hasClass('ui-datepicker-next')) { 242 target.click(); 243 } 244 } else if (33 === which) { // PAGE UP 245 moveOneMonth(target, 'prev', dpControlName); 246 } else if (34 === which) { // PAGE DOWN 247 moveOneMonth(target, 'next', dpControlName); 248 } else if (36 === which) { // HOME 249 var firstOfMonth = $(target).closest('tbody').find('.ui-state-default')[0]; 250 if (firstOfMonth) { 251 firstOfMonth.focus(); 252 setHighlightState(firstOfMonth, $('#ui-datepicker-div')[0]); 253 } 254 } else if (35 === which) { // END 255 var $daysOfMonth = $(target).closest('tbody').find('.ui-state-default'); 256 var lastDay = $daysOfMonth[$daysOfMonth.length - 1]; 257 if (lastDay) { 258 lastDay.focus(); 259 setHighlightState(lastDay, $('#ui-datepicker-div')[0]); 260 } 261 } 262 $(".ui-datepicker-current").hide(); 263 }); 264} 265 266function closeCalendar(dpControlName) { 267 var container = $('#ui-datepicker-div'); 268 $(container).off('keydown'); 269// var input = $(dpControlName)[0]; 270 var input = $("#"+dpControlName); 271 $(input).datepicker('hide'); 272console.log(dpControlName); 273 //input.focus(); 274 $("#"+dpControlName).focus(); 275 276} 277 278function removeAria() { 279 // make the rest of the page accessible again: 280 $("#dp-container").removeAttr('aria-hidden'); 281 $("#skipnav").removeAttr('aria-hidden'); 282} 283
284/////////////////////////////// 285//////////////////////////// // 286///////////////////////// // // 287// UTILITY-LIKE THINGS // // // 288///////////////////////// // // 289//////////////////////////// // 290/////////////////////////////// 291function isOdd(num) { 292 return num % 2; 293} 294 295function moveOneMonth(currentDate, dir, dpControlName) { 296 var button = (dir === 'next') 297 ? $('.ui-datepicker-next')[0] 298 : $('.ui-datepicker-prev')[0]; 299 300 if (!button) { 301 return; 302 } 303 304 var ENABLED_SELECTOR = '#ui-datepicker-div tbody td:not(.ui-state-disabled)'; 305 var $currentCells = $(ENABLED_SELECTOR); 306 var currentIdx = $.inArray(currentDate.parentNode, $currentCells); 307 308 button.click(); 309 setTimeout(function () { 310 updateHeaderElements(dpControlName); 311 312 var $newCells = $(ENABLED_SELECTOR); 313 var newTd = $newCells[currentIdx]; 314 var newAnchor = newTd && $(newTd).find('a')[0]; 315 316 while (!newAnchor) { 317 currentIdx--; 318 newTd = $newCells[currentIdx]; 319 newAnchor = newTd && $(newTd).find('a')[0]; 320 } 321 322 setHighlightState(newAnchor, $('#ui-datepicker-div')[0]); 323 newAnchor.focus(); 324 325 }, 0); 326 327} 328 329function handleNextClicks() { 330 setTimeout(function () { 331 updateHeaderElements(); 332 prepHighlightState(); 333 $('.ui-datepicker-next').focus(); 334 $(".ui-datepicker-current").hide(); 335 }, 0); 336} 337 338function handlePrevClicks() { 339 setTimeout(function () { 340 updateHeaderElements(); 341 prepHighlightState(); 342 $('.ui-datepicker-prev').focus(); 343 $(".ui-datepicker-current").hide(); 344 }, 0); 345} 346 347function previousDay(dateLink) { 348 var container = document.getElementById('ui-datepicker-div'); 349 if (!dateLink) { 350 return; 351 } 352 var td = $(dateLink).closest('td'); 353 if (!td) { 354 return; 355 } 356 357 var prevTd = $(td).prev(), 358 prevDateLink = $('a.ui-state-default', prevTd)[0]; 359 360 if (prevTd && prevDateLink) { 361 setHighlightState(prevDateLink, container); 362 prevDateLink.focus(); 363 } else { 364 handlePrevious(dateLink); 365 } 366} 367 368 369function handlePrevious(target) { 370 var container = document.getElementById('ui-datepicker-div'); 371 if (!target) { 372 return; 373 } 374 var currentRow = $(target).closest('tr'); 375 if (!currentRow) { 376 return; 377 } 378 var previousRow = $(currentRow).prev(); 379 380 if (!previousRow || previousRow.length === 0) { 381 // there is not previous row, so we go to previous month... 382 previousMonth(); 383 } else { 384 var prevRowDates = $('td a.ui-state-default', previousRow); 385 var prevRowDate = prevRowDates[prevRowDates.length - 1]; 386 387 if (prevRowDate) { 388 setTimeout(function () { 389 setHighlightState(prevRowDate, container); 390 prevRowDate.focus(); 391 }, 0); 392 } 393 } 394} 395 396function previousMonth() { 397 var prevLink = $('.ui-datepicker-prev')[0]; 398 var container = document.getElementById('ui-datepicker-div'); 399 prevLink.click(); 400 // focus last day of new month 401 setTimeout(function () { 402 var trs = $('tr', container), 403 lastRowTdLinks = $('td a.ui-state-default', trs[trs.length - 1]), 404 lastDate = lastRowTdLinks[lastRowTdLinks.length - 1]; 405 406 // updating the cached header elements 407 updateHeaderElements(); 408 409 setHighlightState(lastDate, container); 410 lastDate.focus(); 411 412 }, 0); 413} 414 415///////////////// NEXT ///////////////// 416/** 417 * Handles right arrow key navigation 418 * @param {HTMLElement} dateLink The target of the keyboard event 419 */ 420function nextDay(dateLink) { 421 var container = document.getElementById('ui-datepicker-div'); 422 if (!dateLink) { 423 return; 424 } 425 var td = $(dateLink).closest('td'); 426 if (!td) { 427 return; 428 } 429 var nextTd = $(td).next(), 430 nextDateLink = $('a.ui-state-default', nextTd)[0]; 431 432 if (nextTd && nextDateLink) { 433 setHighlightState(nextDateLink, container); 434 nextDateLink.focus(); // the next day (same row) 435 } else { 436 handleNext(dateLink); 437 } 438} 439 440function handleNext(target) { 441 var container = document.getElementById('ui-datepicker-div'); 442 if (!target) { 443 return; 444 } 445 var currentRow = $(target).closest('tr'), 446 nextRow = $(currentRow).next(); 447 448 if (!nextRow || nextRow.length === 0) { 449 nextMonth(); 450 } else { 451 var nextRowFirstDate = $('a.ui-state-default', nextRow)[0]; 452 if (nextRowFirstDate) { 453 setHighlightState(nextRowFirstDate, container); 454 nextRowFirstDate.focus(); 455 } 456 } 457} 458 459function nextMonth() { 460 nextMon = $('.ui-datepicker-next')[0]; 461 var container = document.getElementById('ui-datepicker-div'); 462 nextMon.click(); 463 // focus the first day of the new month 464 setTimeout(function () { 465 // updating the cached header elements 466 updateHeaderElements(); 467 468 var firstDate = $('a.ui-state-default', container)[0]; 469 setHighlightState(firstDate, container); 470 firstDate.focus(); 471 }, 0); 472} 473
474/////////// UP /////////// 475/** 476 * Handle the up arrow navigation through dates 477 * @param {HTMLElement} target The target of the keyboard event (day) 478 * @param {HTMLElement} cont The calendar container 479 * @param {HTMLElement} prevLink Link to navigate to previous month 480 */ 481function upHandler(target, cont, prevLink) { 482 prevLink = $('.ui-datepicker-prev')[0]; 483 var rowContext = $(target).closest('tr'); 484 if (!rowContext) { 485 return; 486 } 487 var rowTds = $('td', rowContext), 488 rowLinks = $('a.ui-state-default', rowContext), 489 targetIndex = $.inArray(target, rowLinks), 490 prevRow = $(rowContext).prev(), 491 prevRowTds = $('td', prevRow), 492 parallel = prevRowTds[targetIndex], 493 linkCheck = $('a.ui-state-default', parallel)[0]; 494 495 if (prevRow && parallel && linkCheck) { 496 // there is a previous row, a td at the same index 497 // of the target AND theres a link in that td 498 setHighlightState(linkCheck, cont); 499 linkCheck.focus(); 500 } else { 501 // we're either on the first row of a month, or we're on the 502 // second and there is not a date link directly above the target 503 prevLink.click(); 504 setTimeout(function () { 505 // updating the cached header elements 506 updateHeaderElements(); 507 var newRows = $('tr', cont), 508 lastRow = newRows[newRows.length - 1], 509 lastRowTds = $('td', lastRow), 510 tdParallelIndex = $.inArray(target.parentNode, rowTds), 511 newParallel = lastRowTds[tdParallelIndex], 512 newCheck = $('a.ui-state-default', newParallel)[0]; 513 514 if (lastRow && newParallel && newCheck) { 515 setHighlightState(newCheck, cont); 516 newCheck.focus(); 517 } else { 518 // theres no date link on the last week (row) of the new month 519 // meaning its an empty cell, so we'll try the 2nd to last week 520 var secondLastRow = newRows[newRows.length - 2], 521 secondTds = $('td', secondLastRow), 522 targetTd = secondTds[tdParallelIndex], 523 linkCheck = $('a.ui-state-default', targetTd)[0]; 524 525 if (linkCheck) { 526 setHighlightState(linkCheck, cont); 527 linkCheck.focus(); 528 } 529 530 } 531 }, 0); 532 } 533} 534 535//////////////// DOWN //////////////// 536/** 537 * Handles down arrow navigation through dates in calendar 538 * @param {HTMLElement} target The target of the keyboard event (day) 539 * @param {HTMLElement} cont The calendar container 540 * @param {HTMLElement} nextLink Link to navigate to next month 541 */ 542function downHandler(target, cont, nextLink) { 543 nextLink = $('.ui-datepicker-next')[0]; 544 var targetRow = $(target).closest('tr'); 545 if (!targetRow) { 546 return; 547 } 548 var targetCells = $('td', targetRow), 549 cellIndex = $.inArray(target.parentNode, targetCells), // the td (parent of target) index 550 nextRow = $(targetRow).next(), 551 nextRowCells = $('td', nextRow), 552 nextWeekTd = nextRowCells[cellIndex], 553 nextWeekCheck = $('a.ui-state-default', nextWeekTd)[0]; 554 555 if (nextRow && nextWeekTd && nextWeekCheck) { 556 // theres a next row, a TD at the same index of `target`, 557 // and theres an anchor within that td 558 setHighlightState(nextWeekCheck, cont); 559 nextWeekCheck.focus(); 560 } else { 561 nextLink.click(); 562 563 setTimeout(function () { 564 // updating the cached header elements 565 updateHeaderElements(); 566 567 var nextMonthTrs = $('tbody tr', cont), 568 firstTds = $('td', nextMonthTrs[0]), 569 firstParallel = firstTds[cellIndex], 570 firstCheck = $('a.ui-state-default', firstParallel)[0]; 571 572 if (firstParallel && firstCheck) { 573 setHighlightState(firstCheck, cont); 574 firstCheck.focus(); 575 } else { 576 // lets try the second row b/c we didnt find a 577 // date link in the first row at the target's index 578 var secondRow = nextMonthTrs[1], 579 secondTds = $('td', secondRow), 580 secondRowTd = secondTds[cellIndex], 581 secondCheck = $('a.ui-state-default', secondRowTd)[0]; 582 583 if (secondRow && secondCheck) { 584 setHighlightState(secondCheck, cont); 585 secondCheck.focus(); 586 } 587 } 588 }, 0); 589 } 590} 591 592 593function onCalendarHide(dpControlName) { 594 closeCalendar(dpControlName); 595} 596 597// add an aria-label to the date link indicating the currently focused date 598// (formatted identically to the required format: mm/dd/yyyy) 599function monthDayYearText(dpControlName) { 600 var cleanUps = $('.amaze-date'); 601 602 $(cleanUps).each(function (clean) { 603 // each(cleanUps, function (clean) { 604 clean.parentNode.removeChild(clean); 605 }); 606 607 var datePickDiv = document.getElementById('ui-datepicker-div'); 608 // in case we find no datepick div 609 if (!datePickDiv) { 610 return; 611 } 612 613 var dates = $('a.ui-state-default', datePickDiv); 614 $(dates).attr('role', 'button').on('keydown', function (e) { 615 if (e.which === 32) { 616 e.preventDefault(); 617 e.target.click(); 618 setTimeout(function () { 619 closeCalendar(dpControlName); 620 }, 100); 621 } 622 }); 623 $(dates).each(function (index, date) { 624 var currentRow = $(date).closest('tr'), 625 currentTds = $('td', currentRow), 626 currentIndex = $.inArray(date.parentNode, currentTds), 627 headThs = $('thead tr th', datePickDiv), 628 dayIndex = headThs[currentIndex], 629 daySpan = $('span', dayIndex)[0], 630 monthName = $('.ui-datepicker-month', datePickDiv)[0].innerHTML, 631 year = $('.ui-datepicker-year', datePickDiv)[0].innerHTML, 632 number = date.innerHTML; 633 634 if (!daySpan || !monthName || !number || !year) { 635 return; 636 } 637 638 // AT Reads: {month} {date} {year} {day} 639 // "December 18 2014 Thursday" 640 var dateText = date.innerHTML + ' ' + monthName + ' ' + year + ' ' + daySpan.title; 641 // AT Reads: {date(number)} {name of day} {name of month} {year(number)} 642 // var dateText = date.innerHTML + ' ' + daySpan.title + ' ' + monthName + ' ' + year; 643 // add an aria-label to the date link reading out the currently focused date 644 date.setAttribute('aria-label', dateText); 645 }); 646} 647 648 649 650// update the cached header elements because we're in a new month or year 651function updateHeaderElements(dpControlName) { 652 var context = document.getElementById('ui-datepicker-div'); 653 if (!context) { 654 return; 655 } 656 657// $(context).find('table').first().attr('role', 'grid'); 658 659 prev = $('.ui-datepicker-prev', context)[0]; 660 next = $('.ui-datepicker-next', context)[0]; 661 662 //make them click/focus - able 663 next.href = 'javascript:void(0)'; 664 prev.href = 'javascript:void(0)'; 665 666 next.setAttribute('role', 'button'); 667 prev.setAttribute('role', 'button'); 668 appendOffscreenMonthText(next); 669 appendOffscreenMonthText(prev); 670 671 $(next).on('click', handleNextClicks); 672 $(prev).on('click', handlePrevClicks); 673 674 // add month day year text 675 monthDayYearText(dpControlName); 676} 677 678 679function prepHighlightState() { 680 var highlight; 681 var cage = document.getElementById('ui-datepicker-div'); 682 highlight = $('.ui-state-highlight', cage)[0] || 683 $('.ui-state-default', cage)[0]; 684 if (highlight && cage) { 685 setHighlightState(highlight, cage); 686 } 687} 688
689// Set the highlighted class to date elements, when focus is recieved 690function setHighlightState(newHighlight, container) { 691 var prevHighlight = getCurrentDate(container); 692 // remove the highlight state from previously 693 // highlighted date and add it to our newly active date 694 $(prevHighlight).removeClass('ui-state-highlight'); 695 $(newHighlight).addClass('ui-state-highlight'); 696} 697 698 699// grabs the current date based on the hightlight class 700function getCurrentDate(container) { 701 var currentDate = $('.ui-state-highlight', container)[0]; 702 return currentDate; 703} 704 705/** 706 * Appends logical next/prev month text to the buttons 707 * - ex: Next Month, January 2015 708 * Previous Month, November 2014 709 */ 710function appendOffscreenMonthText(button) { 711 var buttonText; 712 var isNext = $(button).hasClass('ui-datepicker-next'); 713 var months = [ 714 'january', 'february', 715 'march', 'april', 716 'may', 'june', 'july', 717 'august', 'september', 718 'october', 719 'november', 'december' 720 ]; 721 722 var currentMonth = $('.ui-datepicker-title .ui-datepicker-month').text().toLowerCase(); 723 var monthIndex = $.inArray(currentMonth.toLowerCase(), months); 724 var currentYear = $('.ui-datepicker-title .ui-datepicker-year').text().toLowerCase(); 725 var adjacentIndex = (isNext) ? monthIndex + 1 : monthIndex - 1; 726 727 if (isNext && currentMonth === 'december') { 728 currentYear = parseInt(currentYear, 10) + 1; 729 adjacentIndex = 0; 730 } else if (!isNext && currentMonth === 'january') { 731 currentYear = parseInt(currentYear, 10) - 1; 732 adjacentIndex = months.length - 1; 733 } 734 735 buttonText = (isNext) 736 ? 'Next Month, ' + firstToCap(months[adjacentIndex]) + ' ' + currentYear 737 : 'Previous Month, ' + firstToCap(months[adjacentIndex]) + ' ' + currentYear; 738 739 $(button).find('.ui-icon').html(buttonText); 740 741} 742 743// Returns the string with the first letter capitalized 744function firstToCap(s) { 745 return s.charAt(0).toUpperCase() + s.slice(1); 746}
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.