1/* ------------------------------ 2 INIT 3 Initialize system-wide activations here. 4 Any custom (project-specific) inits should be in custom init.js. 5-------------------------------*/ 6 7$(document).ready(function() { 8 // Activate textarea autoresize 9 if($('textarea').length > 0) { 10 activateTextareaExpand(); 11 } 12 13 // Toggle show/hide divs (Basic) 14 if ($('.showToggleDivBasic').length > 0) { 15 $('.showToggleDivBasic').click(function() { toggleDivShowBasic($(this)); return false; }); 16 } 17 18 // Toggle show/hide divs (With Arrow Indicator) 19 if ($('.showToggleDiv').length > 0) { 20 $('.showToggleDiv').click(function() { toggleDivShow($(this)); return false; }); 21 } 22 23 // Activate accordion links 24 if ($(".accordionLink").length > 0) { 25 activateAccordionLinks(); 26 } 27 28 // Activate selectable Divs 29 if ($('.makeDivCheckboxSelectable').length > 0) { 30 makeDivCheckboxSelectable(); 31 } 32 33 // Activate form validation 34 if ($('form').length > 0 && typeof activateBasicFormValidation == 'function') { 35 activateBasicFormValidation(); 36 } 37 38 // Activate Popup boxes 39 if($("a.popup-box").length > 0) { 40 $("a.popup-box").popupbox(); 41 } 42 43 // Activates character limits for inputs 44 if($(".limitCharWrap").length > 0) { 45 activateLimitFormTextInput(); 46 } 47 48 // Activates checkbox toggling of show/hide password 49 if ($(".showPasswordCheckbox").length > 0) { 50 activateShowPasswordCheckbox(); 51 } 52 53 // Text copy 54 if ($(".copyTextInput").length > 0) { 55 activateCopyTextInput(); 56 } 57 58 // Other activations 59 activateSessionChecks(); // Activate session checks 60 activateFacebox(); // Initiate Facebox links 61 activateGenericFormCSRF(); // Activate CSRF for forms with no specific handling 62 activateLinkCSRF(); // Activate CSRF for links 63 activateScrollToLinks(); // Activate scroll to links 64 activateLockHyperlinkButtons(); // Prevent specific hyperlink buttons from double click 65 66 // Init variables 67 initCoreCommonVariable(); 68 69 // Populate current year on page 70 var currentYear = new Date(); 71 currentYear = currentYear.getFullYear(); 72 $(".currentYear").text(currentYear); 73 74 // Activate Ajax helper 75 activateAjaxHelper(); 76 77 // Re-enable disabled buttons 78 activateSubmitButtons(); 79 80 // Set a fresh CSRF token in cookie on page load 81 var random = generateRandomString(8); 82 updateCSRFCookie(random); 83}); 84 85/** 86 * Re-enable buttons that are disabled until page finishes loading 87 */ 88function activateSubmitButtons() { 89 $('button[type="submit"]').each(function() { 90 $(this).removeAttr('disabled'); 91 }); 92 $('input[type="submit"]').each(function() { 93 $(this).removeAttr('disabled'); 94 }); 95 $('.toggleSwitchBtn').each(function() { 96 $(this).removeClass('toggle-switch-disabled'); 97 }); 98} 99 100/** 101 * Activate Facebox plugin 102 */ 103function activateFacebox() { 104 if ($('a[rel*=facebox]').length > 0) { 105 $('a[rel*=facebox]').facebox(); 106 } 107} 108 109/** 110 * Re-initialization of dynamic Ajax/jQuery elements upon Ajax load 111 * 112 * Safety note: 113 * Ensure that any activations call an .unbind() before a subsequent .on() or binding. 114 * This is to prevent double activations. 115 */ 116function activateAjaxHelper() { 117 $(document).ajaxSuccess(function() { 118 if (typeof activatePopoverInfoButtons === "function") { 119 activatePopoverInfoButtons(); 120 } 121 122 // Activate CSRF 123 if (typeof activateGenericFormCSRF === "function") { 124 activateGenericFormCSRF(); 125 } 126 127 // Toggle show/hide divs (With Arrow Indicator) 128 $('.showToggleDiv').unbind(); 129 if ($('.showToggleDiv').length > 0) { 130 $('.showToggleDiv').click(function() { toggleDivShow($(this)); return false; }); 131 } 132 }); 133}
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.