1var global = (function () { 2 3 var positionPopup = function () { 4 5 var button = $('.activeButton'); 6 var buttonLeft = button.position().left; 7 var popup = button.closest('.hasPopup').find('.popup'); 8 var popupRight = button.offset().left + popup.outerWidth(); 9 var windowWidth = $(window).width(); 10 11 if (popupRight < windowWidth) { 12 popup.css('left', buttonLeft); 13 } 14 15 // else if outside viewport, reverts to default / css 16 17 // class used once per iteration 18 button.removeClass('activeButton'); 19 } 20 21 var baseChecks = function () { 22 /******************************************************* 23 check if js on 24 *******************************************************/ 25 $('body').addClass('js'); 26 27 /******************************************************* 28 check if touchscreen 29 *******************************************************/ 30 $(window).on('touchstart', function () { 31 $('body').addClass('touchscreen'); 32 }); 33 34 /******************************************************* 35 check if in epi edit mode 36 *******************************************************/ 37 if ($('.epi-editContainer').length) { 38 $('body').addClass('epiEditMode'); 39 } 40 } 41 42 var isEmail = function (email) { 43 var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/; 44 return regex.test(email); 45 } 46 47 var wireEvents = function () { 48 49 $('._jsToggle').on('click', function () { 50 $(this).closest('.item').prop('hidden', true); 51 $(this).closest('.item').siblings('.item').prop('hidden', false).attr('tabindex', '-1').focus(); 52 }); 53 54 //triggers form post 55 56 $('._jsFromTrigger').on('click', function () { 57 $(this).closest('form').submit(); 58 }); 59 60 /******************************************************* 61 close container. generic function 62 ********************************************************/ 63 $('._jsCloseContainer').on('click', function () { 64 $(this).closest('.open').removeClass('open'); 65 }); 66 67 /******************************************************* 68 table: check overflow 69 *******************************************************/ 70 71 function checkTableOverflow() { 72 $('table:visible').each(function () { 73 if ($(this).width() > $(this).parent().width()) { 74 $(this).addClass('overflows'); 75 } 76 }); 77 } 78 79 // used on load. 80 // needs rerun for tables not visible on load, such as in expansions. 81 82 $(window).on('load', function () { 83 checkTableOverflow(); 84 }); 85 86 87 88 89 90 /******************************************************* 91 table: check if scrolled to end 92 *******************************************************/ 93 94 $('table').on('scroll', function () { 95 var totalWidth = $(this).find('tr').width(); 96 var scrollDistance = $(this).width() + $(this).scrollLeft(); 97 if (totalWidth <= scrollDistance) { 98 $(this).addClass('scrollEnd'); 99 } 100 else { 101 $(this).removeClass('scrollEnd'); 102 } 103 }); 104 105 106 107 108 109 /******************************************************* 110 table: check left menu collision (article template) 111 *******************************************************/ 112 113 $(window).on('load', function () { 114 // check if subMenu is present 115 if ($('.subMenu').length) { 116 var subMenuBottom = $('.subMenu').offset().top + $('.subMenu').outerHeight(); 117 } 118 $('table').each(function () { 119 // check if table is next to subMenu 120 if ($(this).offset().top < subMenuBottom) { 121 $(this).addClass('menuCollide'); 122 } 123 }); 124 checkTableOverflow(); 125 }); 126 127 128 129 130 /******************************************************* 131 expand target. example: set data-target="1" on both button and target 132 *******************************************************/ 133 $('._jsExpand').on('click', function (j) { 134 135 if ($(j.target).is('a, a *')) { 136 j.preventDefault(); 137 } 138 if ($(this).hasClass('open')) { 139 $(this).removeClass('open').attr('aria-expanded', false); 140 } 141 else { 142 $(this).addClass('open').attr('aria-expanded', true); 143 } 144 145 // find expandable target 146 147 var targetID = $(this).attr('aria-controls'); 148 var target = $('#' + targetID); 149 if (target.hasClass('open')) { 150 target.removeClass('open'); 151 } 152 else { 153 target.addClass('open').attr('tabindex', '-1'); 154 // seems to need delay before focus can be set 155 setTimeout(function () {
156 target.focus(); 157 }, 250); 158 checkTableOverflow(); 159 } 160 161 162 163 // if belongs to group, close other expands in group 164 165 var group = $(this).attr('data-group'); 166 167 if (group !== undefined) { 168 // button 169 $('._jsExpand').each(function () { 170 // if same group, but different target 171 if ($(this).attr('data-group') === group && $(this).attr('aria-controls') !== targetID) { 172 $(this).removeClass('open').attr('aria-expanded', false); 173 } 174 }); 175 // container 176 $('._jsExpandable').each(function () { 177 // if same group, but different id 178 if ($(this).attr('data-group') === group && $(this).attr('id') !== targetID) { 179 $(this).removeClass('open').attr('aria-expanded', false); 180 } 181 }); 182 } 183 }); 184 185 186 // remove focus after click 187 188 $('._jsExpand').on('mouseup', function () { 189 $(this).blur(); 190 }); 191 192 193 // close button 194 195 196 $('._jsExpandable .close').on('click', function () { 197 198 var target = $(this).closest('.open').attr('id'); 199 200 // find corresponding button 201 202 $('._jsExpand').each(function () { 203 if ($(this).attr('aria-controls') === target) { 204 // close it and set focus back on it 205 $(this).removeClass('open').attr('aria-expanded', false).focus(); 206 } 207 }); 208 209 $(this).closest('.open').removeClass('open'); 210 }); 211 212 //tabs 213 $('._jsTabs li *').on('click', function (j) { 214 j.preventDefault(); 215 216 $(this).parent().addClass('selected'); 217 $(this).parent().siblings().removeClass('selected'); 218 $(this).attr('aria-selected', true); 219 $(this).parent().siblings().children().attr('aria-selected', false); 220 221 var targetID = $(this).attr('aria-controls'); 222 var target = $('#' + targetID); 223 224 target.siblings('[role="tabpanel"]').prop('hidden', true); 225 target.prop('hidden', false).attr('tabindex', '-1').focus(); 226 }); 227 228 229 /******************************************************* 230 popup 231 *******************************************************/ 232 233 // open on click 234 235 $('.showPopup').on('click', 236 function (j) { 237 j.preventDefault(); 238 $(this).closest('.hasPopup').toggleClass('open'); 239 }); 240 241 242 // use positioning for infoPopup 243 244 $('.infoPopup .showPopup').on('click', 245 function (j) { 246 $(this).addClass('activeButton'); 247 global.positionPopup(); 248 }); 249 250 251 // if faux button, enable opening with keyboard enter / space 252 253 $('span.showPopup').on('keydown', 254 function (k) { 255 if (k.keyCode === 13 || k.keyCode === 32) { 256 k.preventDefault(); // prevent scroll with space 257 $(this).closest('.hasPopup').toggleClass('open'); 258 $(this).addClass('activeButton'); 259 global.positionPopup(); 260 } 261 }); 262 263 264 // position popup horizontally 265 266 267 268 // remove focus after click 269 $('.showPopup').on('mouseup', 270 function () { 271 $(this).blur(); 272 }); 273 274 // close on click outside 275 $(window).on('click touchend', 276 function (event) { 277 278 // if not clicking inside actual element.. 279 280 if (!$(event.target).closest('.hasPopup').length) { 281 $('.hasPopup').removeClass('open'); 282 } 283 }); 284 285 $('table').on('scroll', function () { 286 var totalWidth = $(this).find('tr').width(); 287 var scrollDistance = $(this).width() + $(this).scrollLeft(); 288 if (totalWidth <= scrollDistance) { 289 $(this).addClass('scrollEnd'); 290 } 291 else { 292 $(this).removeClass('scrollEnd'); 293 } 294 }); 295 296 }; 297 298 return { 299 wireEvents: wireEvents, 300 positionPopup: positionPopup, 301 isEmail: isEmail, 302 baseChecks: baseChecks 303 }; 304 305 306}()); 307(function () { 308 $(function () { 309 global.baseChecks(); 310 global.wireEvents(); 311 }); 312}());
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.