1$(window).on('pageshow', function(event) { 2 3 var blnRefreshOnReturn = sessionStorage.getItem('hi5-refresh-on-return'); 4 5 if(blnRefreshOnReturn) { 6 7 sessionStorage.removeItem('hi5-refresh-on-return'); 8 9 if(event.originalEvent && event.originalEvent.persisted) { 10 window.location.reload(); 11 } 12 13 } 14 15}); 16 17/** 18 * Checks if the element has a specific attribute. 19 * @param {string} name - The name of the attribute to check. 20 * @returns {boolean} - True if the element has the attribute, otherwise false. 21 */ 22$.fn.hasAttr = function(name) { 23 return this.attr(name) !== undefined; 24}; 25 26function CSPInit() { 27 28 /*if(window.document.documentMode) { 29 30 var strError = '<br/><br/><table width="100%" border="0" cellpadding="50"><tr><td align="right" width="33%"><img src="_images/_hi5/ie.png?v=1"/></td><td><h2>Oops!</h2>'; 31 32 strError+= '<p>For security reasons, this site cannot be accessed using Internet Explorer. Please use another browser.</p>'; 33 strError+= '</td></tr></table>'; 34 35 document.getElementsByTagName("BODY")[0].innerHTML = strError; 36 return; 37 38 }*/ 39 40 if(!strUID) return; 41 42 $('select, input').each(function(i) { 43 44 if(attrval = $(this).attr('onchange')) { 45 46 var fn_name = attrval.indexOf('(')==-1 ? attrval : attrval.substring(0, attrval.indexOf('(')), args = attrval.substring(attrval.indexOf('(')+1, attrval.lastIndexOf(')')).split(','); 47 for(var i=0; i < args.length; ++i) args[i] = $.trim(args[i]); 48 $(this).removeAttr('onchange').off('change'); 49 50 // =================== CORE FUNCTIONS =================== 51 switch(fn_name) { 52 case 'updateExportMediaCaptionsFrom': $(this).on('change', function() { updateExportMediaCaptionsFrom(this) }); 53 break; 54 case 'switchMonth': $(this).on('change', function() { switchMonth(this); }); 55 break; 56 case 'PagerGoto': $(this).on('change', function() { PagerGoto(args[0]); }); 57 break; 58 case 'fixHttpPrefix': $(this).on('change', function() { fixHttpPrefix(this); }); 59 break; 60 61 // admin 62 63 case 'updateReferenceColumn': $(this).on('change', function() { updateReferenceColumn(this); }); 64 break; 65 case 'updateRelatedTable': $(this).on('change', function() { updateRelatedTable(this); }); 66 break; 67 case 'updateCaptionsFrom': $(this).on('change', function() { updateCaptionsFrom(this); }); 68 break; 69 case 'ToggleProfileSelect': $(this).on('change', function() { ToggleProfileSelect(this); }); 70 break; 71 72 // client portal (spark) 73 74 case 'UpdateTrackers': $(this).on('change', function() { UpdateTrackers(); }); 75 break; 76 77 // pma 78 79 case 'ConditionUpdated': $(this).on('change', function() { ConditionUpdated(this); }); 80 break; 81 case 'chkAmt': $(this).on('change', function() { chkAmt(this); }); 82 break; 83 case 'TargetBuilder': $(this).on('change', function() { TargetBuilder(this); }); 84 break; 85 86 default: CSPError(attrval, 'onchange');/* alert(attrval); */ $(this).attr('onchange', attrval); 87 } 88 89 } 90 91 }); 92 93 $('input').each(function(i) { 94 95 if(attrval = $(this).attr('onkeypress')) { 96 97 var fn_name = attrval.indexOf('(')==-1 ? attrval : attrval.substring(0, attrval.indexOf('(')), args = attrval.substring(attrval.indexOf('(')+1, attrval.lastIndexOf(')')).split(','); 98 for(var i=0; i < args.length; ++i) args[i] = $.trim(args[i]); 99 $(this).removeAttr('onkeypress').off('keypress'); 100 101 switch(fn_name) { 102 103 // =================== CORE FUNCTIONS =================== 104 105 case 'SwitchPage': $(this).on('keypress', function() { SwitchPage(event, this.value) }); 106 break; 107 case 'SwitchReviewPage': $(this).on('keypress', function() { SwitchReviewPage(event, this.value) }); 108 break; 109 110 // pma 111 112 case 'GotoPage': $(this).on('keypress', function() { GotoPage(event, this.value); }); 113 break; 114 115 default: CSPError(attrval, 'onkeypress'); /* alert(attrval); */ $(this).attr('onkeypress', attrval); 116 } 117 118 } 119 120 121 if(attrval = $(this).attr('onfocus')) { 122 123 var fn_name = attrval.indexOf('(')==-1 ? attrval : attrval.substring(0, attrval.indexOf('(')), args = attrval.substring(attrval.indexOf('(')+1, attrval.lastIndexOf(')')).split(','); 124 for(var i=0; i < args.length; ++i) args[i] = $.trim(args[i]); 125 $(this).removeAttr('onfocus').off('focus'); 126 127 // =================== CORE FUNCTIONS =================== 128 switch(fn_name) { 129 case 'this.select': $(this).on('focus', function() { this.select(); }); 130 break; 131 default: CSPError(attrval, 'onfocus'); /* alert(attrval); */ $(this).attr('onfocus', attrval); 132 } 133 134 } 135 136 if(attrval = $(this).attr('onmouseup')) { 137 138 var fn_name = attrval.indexOf('(')==-1 ? attrval : attrval.substring(0, attrval.indexOf('(')), args = attrval.substring(attrval.indexOf('(')+1, attrval.lastIndexOf(')')).split(','); 139 for(var i=0; i < args.length; ++i) args[i] = $.trim(args[i]); 140 $(this).removeAttr('onmouseup').off('mouseup'); 141 142 // =================== CORE FUNCTIONS =================== 143 switch(fn_name) { 144 case 'return false;': case 'return false': case 'javascript:void': $(this).on('mouseup', function(e) { e.preventDefault(); }); 145 break; 146 default: CSPError(attrval, 'onmouseup'); $(this).attr('onmouseup', attrval); 147 } 148 149 } 150 151 }); 152 153 $('form').each(function(i) { 154 155 if(attrval = $(this).attr('onsubmit')) { 156 157 var fn_name = attrval.indexOf('(')==-1 ? attrval : attrval.substring(0, attrval.indexOf('(')), args = attrval.substring(attrval.indexOf('(')+1, attrval.lastIndexOf(')')).split(','); 158 for(var i=0; i < args.length; ++i) args[i] = $.trim(args[i]); 159 $(this).removeAttr('onsubmit').off('submit'); 160 161 // =================== CORE FUNCTIONS =================== 162 switch(fn_name) { 163 case 'return validateFileName': $(this).on('submit', function() { return validateFileName(this.strFileName.value); }); 164 break; 165 case 'return renameFileSubmit': $(this).on('submit', function() { return renameFileSubmit(this); }); 166 break; 167 case 'return renameFolderSubmit': $(this).on('submit', function() { return renameFolderSubmit(this); }); 168 break; 169 case 'createFolderSubmit': $(this).on('submit', function(e) { e.preventDefault(); createFolderSubmit(this); }); 170 break; 171 case 'return submitMoveMedia': $(this).on('submit', function() { return submitMoveMedia(this); }); 172 break; 173 case 'return uploadFiles': $(this).on('submit', function() { return uploadFiles(this, args[1]=='true'); }); 174 break; 175 case 'return updateMedia': $(this).on('submit', function() { return updateMedia(this); }); 176 break; 177 case 'return createFolder': $(this).on('submit', function() { return createFolder(this); }); 178 break; 179 case 'return updateCollectionOptions': $(this).on('submit', function() { return updateCollectionOptions(this); }); 180 break; 181 case 'return ajaxSend': $(this).on('submit', function() { return ajaxSend(this); }); 182 break; 183 case 'return Subscribe': $(this).on('submit', function() { return Subscribe(this); }); 184 break; 185 case 'return exportReportToMSWordDoc': $(this).on('submit', function() { return exportReportToMSWordDoc(this, dequote(args[1]), args[2]=='true'); }); 186 break; 187 case 'return CellEditFormSubmit': $(this).on('submit', function() { return CellEditFormSubmit(this); }); 188 break; 189 190 // old forum 191 case 'return validateCollectionName': $(this).on('submit', function() { return validateCollectionName(this.strCollectionName.value); }); 192 break; 193 194 // pma 195 196 case 'return SubmitConditionUpdate': $(this).on('submit', function() { return SubmitConditionUpdate(this); }); 197 break; 198 case 'return SubmitPriceLabelUpdate': $(this).on('submit', function() { return SubmitPriceLabelUpdate(this); }); 199 break; 200 case 'return deleteSaved': $(this).on('submit', function() { return deleteSaved(this); }); 201 break; 202 case 'return LotFilter': $(this).on('submit', function() { return LotFilter(); }); 203 break; 204 case 'return toggleSave': $(this).on('submit', function() { return toggleSave(this.searchname.value); }); 205 break; 206 case 'return UpdateModelPricing': $(this).on('submit', function() { return UpdateModelPricing(); }); 207 break; 208 case 'return false;': case 'return false': $(this).on('submit', function(e) { e.preventDefault(); }); 209 break; 210 211 // carefor 212 213 case 'submitbtn.disabled = true; return true;': $(this).on('submit', function() { $('button[name="submitbtn"]').prop('disabled', true); return true; }); 214 break; 215 216 default: CSPError(attrval, 'onsubmit'); $(this).attr('onsubmit', attrval); 217 } 218 219 } 220 221 }); 222 223 $('a, button, tr[onclick], input, span[onclick]').each(function(i) { 224 225 if($(this).hasAttr('data-onclick')) { 226 227 $(this).attr('onclick', $(this).attr('data-onclick')).removeAttr('data-onclick').prop('disabled', false); 228 229 } 230 231 attrval = $(this).attr('onclick'); 232 //if(!attrval) attrval = $(this).attr('data-onclick'); 233 234 if(attrval) { 235
236 //var fn_name = attrval.indexOf('(')==-1 ? attrval : attrval.substring(0, attrval.indexOf('(')), args = attrval.substring(attrval.indexOf('(')+1, attrval.lastIndexOf(')')).split(','); 237 //for(var i=0; i < args.length; ++i) args[i] = $.trim(args[i]); 238 239 var fn_name = attrval.indexOf('(') == -1 ? attrval : attrval.substring(0, attrval.indexOf('(')); 240 241 // Extracting the arguments and splitting while ignoring commas within single quotes 242 var argsString = attrval.substring(attrval.indexOf('(') + 1, attrval.lastIndexOf(')')); 243 var args = argsString.split(/,\s*(?=(?:[^']*'[^']*')*[^']*$)/); 244 245 // Trimming whitespace from each argument 246 for (var i = 0; i < args.length; ++i) { 247 args[i] = $.trim(args[i]); 248 } 249 250 $(this).removeAttr('onclick').off('click'); 251 252 // =================== CORE FUNCTIONS =================== 253 254 switch(fn_name) { 255 case 'copyToClip': $(this).click(function() { copyToClip(this, dequote(args[1])); }); 256 break; 257 case 'PrintDiv': $(this).click(function() { PrintDiv(dequote(args[0])); }); 258 break; 259 case 'return false;': case 'return false': case 'javascript:void': $(this).click(function(e) { e.preventDefault(); }); 260 break; 261 case 'window.location.replace': $(this).click(function() { window.location.replace(args[0]); }); 262 break; 263 case 'window.print': $(this).click(function() { window.print(); }); 264 break; 265 case 'PagerPrev': $(this).click(function() { PagerPrev(); }); 266 break; 267 case 'PagerFirst': $(this).click(function() { PagerFirst(); }); 268 break; 269 case 'PagerNext': $(this).click(function() { PagerNext(); }); 270 break; 271 case 'toggleSection': $(this).click(function() { toggleSection(args[0]); }); 272 break; 273 case 'toggleApplyCredit': $(this).click(function() { toggleApplyCredit(this.checked); }); 274 break; 275 case 'showImport': $(this).click(function() { showImport(); }); 276 break; 277 278 // form 279 280 case 'doCancel': $(this).click(function() { doCancel(); }); 281 break; 282 case 'addGridRow': $(this).click(function() { addGridRow(dequote(args[0])); }); 283 break; 284 case 'ResetSignature': $(this).click(function() { ResetSignature(dequote(args[0])); }); 285 break; 286 case 'addColRule': $(this).click(function() { addColRule(args[0]); }); 287 break; 288 case 'showColRulesList': $(this).click(function() { showColRulesList(args[0]); }); 289 break; 290 291 // table 292 293 case 'return ShowImportForm': $(this).click(function() { ShowImportForm(); }); 294 break; 295 case 'HideImportForm': $(this).click(function() { HideImportForm(); }); 296 break; 297 298 // =================== CORE COMPONENTS =================== 299 300 // docs 301 302 case 'downloadCollection': $(this).click(function() { downloadCollection(args[0], dequote(args[1])); }); 303 break; 304 305 // donate 306 307 case 'addFund': $(this).click(function() { addFund(); }); 308 break; 309 case 'clearFunds': $(this).click(function() { clearFunds(); }); 310 break; 311 312 // form builder 313 314 case 'SaveSettings': $(this).click(function() { SaveSettings(this); }); 315 break; 316 case 'SaveApprovals': $(this).click(function() { SaveApprovals(this); }); 317 break; 318 case 'closeColRelated': $(this).click(function() { closeColRelated(args[0]); }); 319 break; 320 case 'closeColRules': $(this).click(function() { closeColRules(args[0]); }); 321 break; 322 case 'return submitColRelated': $(this).click(function() { return submitColRelated(args[0]); }); 323 break; 324 case 'return submitColOptions': $(this).click(function() { return submitColOptions(args[0]); }); 325 break; 326 case 'closeColOptions': $(this).click(function() { closeColOptions(args[0]); }); 327 break; 328 case 'EditRule': $(this).click(function() { EditRule(args[0], args[1]); }); 329 break; 330 case 'DeleteRule': $(this).click(function() { DeleteRule(args[0], args[1]); }); 331 break; 332 case 'submitColRule': $(this).click(function() { submitColRule(args[0], args[1]); }); 333 break; 334 case 'revealNativeControls': $(this).click(function() { revealNativeControls(args[0]); }); 335 break; 336 case 'return submitSectionOptions': $(this).click(function() { return submitSectionOptions(args[0]); }); 337 break; 338 case 'closeSectionOptions': $(this).click(function() { closeSectionOptions(args[0]); }); 339 break; 340 case 'return submitRelatedColOptions': $(this).click(function() { return submitRelatedColOptions(args[0]); }); 341 break; 342 case 'closeRelatedColOptions': $(this).click(function() { closeRelatedColOptions(args[0]); }); 343 break; 344 345 // groups 346 347 case 'toggleRow': $(this).click(function() { toggleRow(this, dequote(args[1])); }); 348 break; 349 case 'downloadMedia': $(this).click(function() { downloadMedia(args[0], dequote(args[1]), dequote(args[2])); }); 350 break; 351 case 'deleteMedia': $(this).click(function() { deleteMedia(dequote(args[0]), args[1], dequote(args[2])); }); 352 break; 353 case 'createFolder': $(this).click(function() { createFolder(args[0], args[1]); }); 354 break; 355 case 'deleteFolder': $(this).click(function() { deleteFolder(args[0]); }); 356 break; 357 case 'renameFile': $(this).click(function() { renameFile(args[0], dequote(args[1])); }); 358 break; 359 case 'deleteFileFromFolder': $(this).click(function() { deleteFileFromFolder(args[0], args[1], args[2]); }); 360 break; 361 case 'moveFile': $(this).click(function() { moveFile(args[0], args[1], dequote(args[2])); }); 362 break; 363 case 'toggleTile': $(this).click(function() { toggleTile(this, args[1]); }); 364 break; 365 case 'moveFolder': $(this).click(function() { moveFolder(args[0], args[1]); }); 366 break; 367 case 'renameFolder': $(this).click(function() { renameFolder(args[0], dequote(args[1])); }); 368 break; 369 case 'deleteFile': $(this).click(function() { deleteFile(args[0], args[1]); }); 370 break; 371 372 // sign in 373 374 case 'toggleRecover': $(this).click(function() { toggleRecover(args[0]=='true'); CSPInit(); }); 375 break; 376 377 // forum 378 379 case 'downloadForumMedia': $(this).click(function() { downloadForumMedia(args[0], args[1]); }); 380 break; 381 case 'deleteForumMedia': $(this).click(function() { deleteForumMedia(args[0], args[1]); }); 382 break; 383 case 'renameMedia': $(this).click(function() { renameMedia(args[0], args[1]); }); 384 break;
385 case 'editCollection': $(this).click(function() { editCollection(args[0]); }); 386 break; 387 case 'newCollection': $(this).click(function() { newCollection(args[0]); }); 388 break; 389 case 'downloadCollection': $(this).click(function() { downloadCollection(args[0], dequote(args[1])); }); 390 break; 391 case 'deleteCollection': $(this).click(function() { deleteCollection(args[0], args[1]); }); 392 break; 393 394 // renew 395 396 case 'removeMember': $(this).click(function() { removeMember(args[0]); }); 397 break; 398 case 'undoRemoveMember': $(this).click(function() { undoRemoveMember(args[0]); }); 399 break; 400 case 'setAsManager': $(this).click(function() { setAsManager(args[0]); }); 401 break; 402 403 // =================== CLIENTS =================== 404 405 // editor (spark) 406 407 case 'clearResults': $(this).click(function() { clearResults(); }); 408 break; 409 case 'gotoResult': $(this).click(function() { gotoResult(this); }); 410 break; 411 412 // ipic 413 414 case 'Show': $(this).click(function() { Show(args[0]); }); 415 break; 416 case 'ViewOptions': $(this).click(function() { ViewOptions(); }); 417 break; 418 case 'gotoTickets': $(this).click(function() { gotoTickets(); }); 419 break; 420 case 'goBack': $(this).click(function() { goBack(); }); 421 break; 422 case 'toggleCommPref': $(this).click(function() { toggleCommPref(); }); 423 break; 424 425 // adultl 426 427 case 'ToggleTag': $(this).click(function() { ToggleTag(this); }); 428 break; 429 430 // calp-portal 431 432 case 'clearFilters': $(this).click(function() { clearFilters(); }); 433 break; 434 case 'Sort': $(this).click(function() { Sort(dequote(args[0])); }); 435 break; 436 case 'resetHistory': $(this).click(function() { resetHistory(); }); 437 break; 438 case 'toggleFAQform': $(this).click(function(e) { e.preventDefault(); toggleFAQform(); }); 439 break; 440 441 // cha 442 443 case 'openNav': $(this).click(function() { openNav(); }); 444 break; 445 case 'closeNav': $(this).click(function() { closeNav(); }); 446 break; 447 448 // capra 449 450 case 'go': $(this).click(function() { go(); }); 451 break; 452 453 // grsi 454 455 case 'window.open': $(this).click(function() { window.open(args[0]); }); 456 break; 457 458 // ipic 459 460 case 'downloadForumMedia': $(this).click(function() { downloadForumMedia(args[0], args[1]); }); 461 break; 462 case 'exportHTML':$(this).click(function() { exportHTML(dequote(args[0])); }); 463 break; 464 case 'return ConfirmCriteria': $(this).click(function() {return ConfirmCriteria(this); }); 465 break; 466 case 'TogglePreference': $(this).click(function() { TogglePreference(dequote(args[0]), dequote(args[1])); }); 467 break; 468 469 // laframboise 470 471 case 'printReport': $(this).click(function() { printReport(dequote(args[0])); }); 472 break; 473 474 // pma 475 476 case 'Print': $(this).click(function() { Print(); }); 477 break; 478 case 'PrintResults': $(this).click(function() { PrintResults(); }); 479 break; 480 case 'ToggleFav': $(this).click(function() { ToggleFav(); }); 481 break; 482 case 'goNext': $(this).click(function() { goNext(); }); 483 break; 484 case 'goPrev': $(this).click(function() { goPrev(); }); 485 break; 486 case 'HideUploadForm': $(this).click(function() { HideUploadForm(); }); 487 break; 488 case 'updateDetails': $(this).click(function() { updateDetails(); }); 489 break; 490 case 'TargetBuilder': $(this).click(function() { TargetBuilder(this); }); 491 break; 492 case 'LotFilter': $(this).click(function() { LotFilter(); }); 493 break; 494 case 'ClearLotFilter': $(this).click(function() { ClearLotFilter(); }); 495 break; 496 case 'toggleReported': $(this).click(function() { toggleReported(); }); 497 break; 498 case 'clearSearchForm': $(this).click(function() { clearSearchForm(); }); 499 break; 500 case 'UpdateCondition': $(this).click(function() { UpdateCondition(this); }); 501 break; 502 case 'deleteSaved': $(this).click(function() { deleteSaved(this); }); 503 break; 504 case 'UpdateModelPricing': $(this).click(function() { UpdateModelPricing(); }); 505 break; 506 case 'Print': $(this).click(function() { Print(); }); 507 break; 508 case 'print': $(this).click(function() { print(); }); 509 break; 510 case 'LotSizeFilter': $(this).click(function() { LotSizeFilter(args[0]); }); 511 break; 512 case 'LotStatusFilter': $(this).click(function() { LotStatusFilter(args[0]); }); 513 break;
514 case 'UpdatePriceLabel': $(this).click(function() { UpdatePriceLabel(this); }); 515 break; 516 case 'unToggleSave': $(this).click(function() { unToggleSave(); }); 517 break; 518 519 // softball 520 521 case 'GoNext': $(this).click(function() { GoNext(); }); 522 break; 523 case 'GoPrev': $(this).click(function() { GoPrev(); }); 524 break; 525 case 'ToggleRecap': $(this).click(function() { ToggleRecap(args[0]); }); 526 break; 527 case 'ShowUploadForm': $(this).click(function() { ShowUploadForm(); }); 528 break; 529 case 'updateGames': $(this).click(function() { updateGames(); }); 530 break; 531 case 'Add': $(this).click(function() { Add(dequote(args[0])); }); 532 break; 533 case 'View': $(this).click(function() { View(dequote(args[0])); }); 534 break; 535 case 'Assign': $(this).click(function() { Assign(args[0], dequote(args[1]), args[2], args[3], dequote(args[4]), dequote(args[5])); }); 536 break; 537 case 'this.select': $(this).click(function() { this.select(); }); 538 break; 539 540 default: CSPError(attrval, 'onclick'); /* alert(attrval); */ $(this).attr('onclick', attrval); 541 } 542 543 } 544 545 if($(this).attr('href')=='javascript:void(0)' && !$(this).attr('data-href')) { 546 547 $(this).click(function(e) { e.preventDefault(); }); 548 $(this).removeAttr('href'); 549 550 } 551 552 553 }); 554 555} 556 557function dequote(str) { 558 559 str = str.trim(); 560 561 if(str.indexOf('\'')==0 && str.lastIndexOf('\'')==str.length-1) return str.substring(1, str.length-1); 562 else return str; 563 564} 565 566function CSPError(attrval, strType, strCSPToken){ 567 568 var baseHref = document.getElementsByTagName('base')[0].href; 569 570 $.post(baseHref + urlAjaxBase + "email/report/", {'token': top.strUID, 'error': attrval + ' is not a validated ' + strType + ' function'}); 571 572} 573 574function copyToClip(objButton, strElementID) { 575 576 var copyText = document.getElementById(strElementID); 577 $(copyText).select(); 578 document.execCommand("copy"); 579 580 $(objButton).find('span:first-of-type').addClass('d-none hidden'); 581 $(objButton).find('span:last-of-type').removeClass('d-none hidden'); 582 583 setTimeout(function(){ 584 585 $(objButton).find('span:first-of-type').removeClass('d-none hidden'); 586 $(objButton).find('span:last-of-type').addClass('d-none hidden'); 587 588 }, 5000); 589 590} 591 592// ================= POP-UP-CONFIMRATION / READMORE ===================== 593 594function br2nl(val) { 595 596 return replaceAll(replaceAll(val, "<br>", "+"), "<br />", "+"); 597 598} 599 600function replaceAll(strTarget, strFind, strReplace) { 601 602 return strTarget.replace(new RegExp(RegExp.quote(strFind), "g"), strReplace); 603 604} 605 606RegExp.quote = function(str) { 607 608 return str.replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1"); 609 610}; 611 612if(strUID) CSPInit(); 613 614$(document).ready(function() { 615 616 // Scroll to the designated page content when requested. 617 618 var $autoScroll = $(".hi5-auto-scroll").first(); 619 620 if($autoScroll.length) { 621 $autoScroll[0].scrollIntoView(); 622 } 623 624 // solution for storing hash tags in links in case there is a redirect encountered 625 626 var baseHref = document.getElementsByTagName('base')[0].href; 627 628 $('body:not(.edit-mode):not(.preview-mode) a[href]').each(function() { 629 630 var strLink = $(this).attr('href'); 631 var strTarget = $(this).attr('target') || "_self"; 632 633 //var fragment = href.split('#')[1]; // Get the fragment if it exists 634 635 if(strLink.includes('#') && strTarget=="_self") { 636 637 var strURL = strLink.split('#')[0]; 638 var strHash = strLink.split('#')[1]; 639 640 if(strURL.length>0 && strHash.length>0) { 641 642 $(this).on('click', function(e) { 643 644 e.preventDefault(); 645 646 var urlAjax = urlAjaxBase + 'ajax/hash-preserve/?url=' + encodeURIComponent(strURL) + '&hash=' + encodeURIComponent(strHash); 647 console.log("AJAX request: " + baseHref + urlAjax); 648 649 $.ajax({ 650 url: urlAjax, 651 complete(xhr,status) { 652 653 // Redirect after storing the fragment 654 window.location.href = strLink; 655 656 657 } 658 }); 659 660 }); 661 662 } else if(strHash.length>0) { 663 664 $(this).on('click', function(e) { 665
666 if($(this).hasAttr('data-slide')) return; 667 if($(this).hasClass('nav-link')) return; 668 if($(this).hasAttr('data-toggle')) return; 669 670 var target = this.hash; 671 var $target = $(target); 672 673 // Prevent default anchor click behavior 674 e.preventDefault(); 675 676 if ($target.length) { 677 678 if($target.offset().top>0) { 679 // Scroll smoothly to the target section 680 $('html, body').animate({ 681 scrollTop: $target.offset().top 682 }, 400); // Duration of animation in milliseconds 683 } 684 685 } else { 686 // Check for anchor tags defined by name attribute 687 var anchorTarget = $('a[name="' + target.substring(1) + '"]'); 688 if (anchorTarget.length) { 689 $('html, body').animate({ 690 scrollTop: anchorTarget.offset().top 691 }, 400); // Duration of animation in milliseconds 692 } else { 693 console.error('Target not found:', target); 694 } 695 } 696 697 }); 698 699 700 } 701 702 } 703 704 }); 705 706 /* Hi5Component Filter Controls */ 707 708 initComponentFilterControls(); 709 710 /* comments */ 711 712 initCommentButtons(); 713 714 // confirmation popup 715 716 if($.fn.tooltip.Constructor != undefined && $.fn.tooltip.Constructor.Default != undefined && $.fn.tooltip.Constructor.Default.whiteList != undefined) $.fn.tooltip.Constructor.Default.whiteList.button = []; 717 718 $('article.readmore').readmore({ 719 selector: 'article.readmore', 720 speed: 150, 721 moreLink: '<button class="btn btn-link fadeout">'+strLang_Readmore+'</button>', 722 lessLink: '<button class="btn btn-link fadeout">'+strLang_Readless+'</button>' 723 }) 724 725 $('article.readmore + button').removeClass('loading').removeAttr('onclick'); 726 727 $('address').each(function () { 728 var link = "<a class='external_link' href='https://maps.google.com/maps?q=" + encodeURIComponent( br2nl($(this).html()) ) + "' target='_blank'>" + $(this).html() + "</a>"; 729 $(this).html(link); 730 }); 731 732 var pathname = window.location.pathname + window.location.search; 733 734 $('a[data-href].loading').each(function() { 735 736 $(this).attr('href', $(this).attr('data-href')).removeClass('loading disabled').removeAttr('data-href'); 737 738 }); 739 740 $('body:not(.edit-mode):not(.preview-mode) a[href^="#"]:not([data-slide]):not([data-toggle]):not([href="#"])').on("click", function(e) { 741 742 var link = $(this).attr('href'); 743 window.location.replace(pathname + link); 744 e.preventDefault(); 745 return false; 746 747 }).removeAttr('onclick').removeClass('disabled').removeClass('loading'); 748 749 $('[data-toggle="tooltip"]').tooltip({container: 'body',html: true, trigger: 'hover'}); 750 $('[data-tooltip="tooltip"]').tooltip({container: 'body',html: true, trigger: 'hover'}); 751 752 $('.carousel-item a[href=""]').on("click", function(e) { 753 754 e.preventDefault(); 755 return false; 756 757 }); 758 759 $('[data-toggle="popover"]').popover({delay: { "show": 600, "hide": 0 }}); 760 761 $('.modal').detach().appendTo('body'); 762 763 // pop ups 764 765 if($('#hi5-popup-share').length) { 766 767 var html = $('#hi5-popup-share').html(); 768 769 html = '<div id="PopupShareDialog" class="modal fade" role="dialog"><div class="modal-dialog"><div class="modal-content"><div class="modal-body">' + html; 770 771 html = html + '</div><div class="modal-footer"><button type="button" class="btn btn-secondary btn-default" data-dismiss="modal">' + strLang_Continue + '</button></div></div></div></div>'; 772 773 $('body').append(html); 774 775 $('[data-onclick]').each(function(i) { 776 777 attrval = $(this).attr('data-onclick'); 778 var fn_name = attrval.indexOf('(')==-1 ? attrval : attrval.substring(0, attrval.indexOf('(')), args = attrval.substring(attrval.indexOf('(')+1, attrval.lastIndexOf(')')).split(','); 779 for(var i=0; i < args.length; ++i) args[i] = $.trim(args[i]); 780 $(this).removeAttr('data-onclick'); 781 switch(fn_name) { 782 case 'copyToClip': $(this).click(function() { copyToClip(this, dequote(args[1])); }); 783 break; 784 default: CSPError(attrval, 'data-onclick'); $(this).attr('onclick', attrval); 785 } 786 787 }); 788 789 $('#hi5-popup-share').remove(); 790 791 } 792 793 $('a.popup-iframe').each(function() { 794 795 $(this).attr('data-fancybox', '').attr('data-src', $(this).attr('href')).attr('data-type', 'iframe'); 796 797 }); 798 799 $('a.popup-window').on('click', function(e) { 800 801 var target = e.currentTarget || e.srcElement; 802 PopupCenter(target.href, target.title, 400, 430, 'menubar=no,status=no,titlebar=no,toolbar=no'); 803 return false;
804 805 }); 806 807 $('a.loading').removeAttr('onclick').removeClass('loading'); 808 $('button.loading').removeClass('loading').prop('disabled', false); 809 810 lightbox.option({ 811 'albumLabel' : strLang_DefaultPhotoCaption 812 }); 813 814 initDropSelect(""); 815 816 $('.share-blog a').on('click', function(e) { 817 818 var target = e.currentTarget || e.srcElement; 819 820 PopupCenter(target.href, 'Share', 400, 430, 'menubar=no,status=no,titlebar=no,toolbar=no'); 821 822 return false; 823 824 }); 825 826 $('.back-btn').click(function(e) { 827 828 if (history.length>1) { 829 e.preventDefault(); 830 history.back(); 831 } 832 833 }); 834 835 initPopper(); 836 837 // cart/add module 838 839 initNumberCtrl(); 840 841 // ajax track view for inline content 842 843 initDataTracker(); 844 845 // auto-open modal with hash tag 846 847 var strHash = window.location.hash; 848 849 if(strHash) { 850 851 if($(strHash).hasClass('modal')) { 852 853 $(strHash).modal('show'); 854 855 } 856 857 } 858 859 // ajax links 860 861 initAJAXLinks(); 862 863 // modal ajax content 864 865 $('.modal[data-content]').on('show.bs.modal', function(e) { 866 867 var intRow = $(e.relatedTarget).attr('data-row'); 868 var strModal = $(e.target).attr('id'); 869 var strTarget = $(e.target).attr('data-content'); 870 871 var urlAjax = urlAjaxBase + strTarget + '&pkRow=' + intRow 872 var baseHref = document.getElementsByTagName('base')[0].href; 873 console.log("AJAX request: " + baseHref + urlAjax); 874 875 $('#' + strModal + ' .modal-body').html('<div id="loading-icon" class="d-block text-center p-5" style="font-size:60px;opacity:0.25;height:100%;padding:25px;"><i class="glyphicon glyphicon-hourglass icon-spinner"></i></div>'); 876 877 $.ajax({ 878 url: urlAjax 879 , success: function(result) { 880 881 $('#' + strModal + ' .modal-body').html(result); 882 883 $.material.init(); 884 885 CSPInit(); 886 887 initFormControls(strModal + ' .Hi5Form'); 888 889 }, error: function(result) { 890 891 $('#' + strModal + ' .modal-body').html('<div class="alert alert-warning"><i style="font-size: 24px;vertical-align: middle;padding: 0 12px 4px 0;" class="glyphicon glyphicon-exclamation-sign"></i>Error: Could not load content</div>'); 892 893 } 894 }); 895 896 }); 897 898 // prevent browser notices about: Blocked aria-hidden on an element because its descendant retained focus. 899 900 let lastFocusedElement; 901 902 $(document).on('show.bs.modal', '.modal', function (event) { 903 lastFocusedElement = document.activeElement; // Store the element that triggered the modal 904 }); 905 906 $(document).on('hide.bs.modal', '.modal', function () { 907 if(lastFocusedElement) { 908 lastFocusedElement.focus(); // Restore focus to the triggering element 909 lastFocusedElement = null; 910 } else { 911 document.body.focus(); // Fallback to body 912 } 913 }); 914 915 /* video background loader */ 916 917 $('div.video-bg:not(.init)').each(function() { 918 919 //$(this).append('<i class="icon-spinner glyphicon glyphicon-hourglass"></i>'); 920 $(this).append('<img class="icon-spinner" src="/_images/svg/hourglass.svg"/>'); 921 922 }); 923 924 /* pager */ 925 926 $('.pager input[type="number"][data-target]').on('keydown', function(event) { 927 928 if (event.key === 'Enter') { 929 930 var urlTarget = decodeURIComponent($(this).attr('data-target')); 931 var intPage = $(this).val(); 932 933 window.location.href = urlTarget + (urlTarget.indexOf('?')==-1 ? '?' : '&' ) + "pager=" + intPage; 934 935 } 936 937 }); 938 939 940 941 /* upvotes */ 942 943 $('button.upvote-btn.btn-loading').each(function(){ 944 945 $(this).click(function(){ 946 947 var objButton = this; 948 949 $(objButton).tooltip('dispose'); 950 951 var htmlOrginalContent = $(objButton).html(); 952 953 // Set the button width explicitly to its current width 954 $(objButton).css('width', $(objButton).outerWidth() + 'px'); 955 $(objButton).html('<i class="glyphicon glyphicon-hourglass icon-spinner"></i>'); 956 957 var fkContentSource = $(objButton).attr('data-content-source'); 958 var fkContent = parseInt($(objButton).attr('data-content-id')); 959 var blnChecked = parseInt($(objButton).attr('data-checked')); 960 var strDefaultCaption = $(objButton).attr('data-default-caption'); 961 var enumLang = $('html')[0].lang; 962 963 if(fkContent<1) return; 964 965 var urlAjax = urlAjaxBase + "ajax/upvote/?lang=" + enumLang + "&content_source=" + encodeURIComponent(fkContentSource) + "&content_id=" + fkContent + '&comaction=' + (blnChecked ? 'remove' : 'add'); 966 var baseHref = document.getElementsByTagName('base')[0].href; 967 console.log("AJAX request: " + baseHref + urlAjax); 968 969 $.ajax({ 970 url: urlAjax 971 , success: function(result) { 972 973 $(objButton).html(result); 974 975 var strTarget = $(objButton).attr('data-target'); 976 var strValue = $(objButton).find('[data-value]').attr('data-value'); 977 978 if(strTarget && strTarget.length && strValue.length) $(strTarget).text(strValue); 979 $(objButton).css('width', 'auto'); 980 $(objButton).removeAttr('data-original-title'); 981 $(objButton).attr('title', blnChecked ? strDefaultCaption : strLang_RemoveUpvote); 982 $(objButton).attr('data-checked', blnChecked ? "0" : "1"); 983 984 $('[data-toggle="tooltip"]:not([data-original-title])').tooltip(); 985 986 }, error: function(result) { 987 988 $(objButton).html(htmlOrginalContent); 989 alert("An error occurred: " + $(result.responseText).text().replace(/[\r\n\t]/g, '')); 990 991 } 992 }); 993 994 }); 995 996 $(this).prop('disabled', false).removeClass('btn-loading'); 997 998 }); 999 1000 /* remove empty p */ 1001 1002 document.querySelectorAll('p').forEach(function(p) { 1003 if (p.innerHTML.trim() === ' ' || p.innerHTML.trim() ==='') p.style.display = 'none'; 1004 }); 1005 1006 initConfirmation(); 1007 1008}); 1009 1010function initAJAXLinks() { 1011 1012 $('a.ajax-submit[data-target]:not(.ajax-init)').each(function() { 1013 1014 var objAnchor = this; 1015 1016 $(objAnchor).on('click', function(e){ 1017 1018 e.preventDefault(); 1019 1020 $(objAnchor).tooltip('dispose'); // destroy any tooltip that is active 1021 1022 var $target = $($(objAnchor).attr('data-target')); 1023 1024 if(typeof tinymce !== 'undefined') { 1025 tinymce.triggerSave(); 1026 } 1027 1028 var strOriginalTargetHtml = $target.html(); 1029 1030 var urlAjax = urlAjaxBase + $(objAnchor).attr('href'); 1031 var baseHref = document.getElementsByTagName('base')[0].href; 1032 console.log("AJAX request: " + baseHref + urlAjax); 1033 1034 $target.html('<div id="loading-icon" class="d-block text-center p-5" style="font-size:60px;opacity:0.25;height:100%;padding:25px;"><i class="glyphicon glyphicon-hourglass icon-spinner"></i></div>'); 1035 1036 setTimeout(function() { 1037 $.ajax({ 1038 url: urlAjax, 1039 async: false, 1040 cache: false, 1041 success: function(result) { 1042 1043 $target.replaceWith(result); 1044 initAJAXLinks(); 1045 CSPInit(); 1046 initFormControls();
1047 initCommentButtons(); 1048 initConfirmation(); 1049 $('[data-toggle="tooltip"]:not([data-original-title])').tooltip(); 1050 1051 }, 1052 error: function(xhr) { 1053 1054 var strErrorMsg = ''; 1055 1056 if(xhr.responseText) { 1057 var $response = $(xhr.responseText); 1058 strErrorMsg = $response.filter('#error-msg').add($response.find('#error-msg')).first().html(); 1059 } 1060 1061 if(!strErrorMsg) { 1062 strErrorMsg = 'Sorry, the content could not be loaded.'; 1063 } 1064 1065 $target.html(strOriginalTargetHtml); 1066 $target.find('form').removeClass('Hi5-init'); 1067 $target.find('select.selectized').removeClass('selectized'); 1068 1069 $target.find('.file-input').each(function() { 1070 var $wrapper = $(this); 1071 var $input = $wrapper.find('input[type="file"]').first(); 1072 if($input.length) { 1073 $wrapper.replaceWith($input); 1074 } 1075 }); 1076 1077 $target.find('input[type="file"]').each(function() { 1078 $(this).removeData('fileinput'); 1079 }); 1080 1081 $target.find('.tox-tinymce, .mce-tinymce, .mce-container, .mce-panel').remove(); 1082 $target.find('textarea').each(function() { 1083 $(this).show().removeAttr('aria-hidden'); 1084 }); 1085 1086 $target.find('textarea.tinymce-basic, textarea.tinymce').each(function() { 1087 $(this) 1088 .removeClass('tinymce-basic') 1089 .addClass('tinymce'); 1090 }); 1091 1092 initAJAXLinks(); 1093 CSPInit(); 1094 initFormControls(); 1095 initCommentButtons(); 1096 initConfirmation(); 1097 $('[data-toggle="tooltip"]:not([data-original-title])').tooltip(); 1098 1099 $('#hi5-popper').remove(); 1100 $('body').append('<div style="display:none;" id="hi5-popper">' + strErrorMsg + '</div>'); 1101 initPopper(); 1102 1103 } 1104 }); 1105 }, 500); // Delay by half second to force a repaint 1106 1107 }); 1108 1109 $(this).addClass('ajax-init'); 1110 1111 }); 1112 1113} 1114 1115function initDataTracker() { 1116 1117 //$('[data-track]:not(.data-track-init)').on('click contextmenu', function(e){ 1118 $('[data-track]:not(.data-track-init)').on('click', function(e){ 1119 1120 var pkItemID = $(this).attr('data-track'); 1121 var enumType = $(this).attr('data-track-type'); 1122 var strURL = ''; 1123 1124 var strTitle = $(this).attr('title'); 1125 1126 switch(enumType) { 1127 case 'faq': strURL = window.location.href + '#' + $(this).attr('id'); break; 1128 case 'document': case 'video': case 'group-resource': strURL = $(this).attr('href'); break; 1129 case 'winner': strURL = window.location.href + $(this).attr('data-target'); break; 1130 default: strURL = window.location.href; 1131 } 1132 1133 if(pkItemID && enumType && strURL && strTitle) { 1134 1135 var urlAjax = urlAjaxBase + 'ajax/activity/?' 1136 + 'type=' + encodeURIComponent(enumType) 1137 + '&id=' + encodeURIComponent(pkItemID) 1138 + '&title=' + encodeURIComponent(strTitle) 1139 + '&url=' + encodeURIComponent(strURL) 1140 + '&eventType=' + encodeURIComponent(e.type); // include click/contextmenu 1141 1142 var baseHref = document.getElementsByTagName('base')[0]?.href || ''; 1143 console.log("Beacon (GET): " + baseHref + urlAjax); 1144 1145 if (navigator.sendBeacon) { 1146 // Beacon only supports POST, but we can trick it by sending an empty body to a GET URL 1147 navigator.sendBeacon(urlAjax, new Blob([], { type: 'application/x-www-form-urlencoded' })); 1148 } else { 1149 // Fallback to standard AJAX GET 1150 $.ajax({ 1151 url: urlAjax, 1152 error: function(result) { 1153 console.log("Error logging activity: " + $(result.responseText).text().replace(/[\r\n\t]/g, '')); 1154 } 1155 }); 1156 } 1157 1158 } 1159 1160 }).addClass('data-track-init'); 1161 1162} 1163 1164$(window).on('load', function() { 1165 1166 /* video background loader */ 1167 1168 $('div.video-bg:not(.init)').each(function() { 1169 1170 var objDiv = this; 1171 1172 var strSrc = $(objDiv).attr('data-src'); 1173 var strType = $(objDiv).attr('data-type'); 1174 1175 if(strSrc && strType) $(objDiv).append('<video autoplay muted loop playsinline class="video-bg fade"><source src="' + strSrc + '" type="' + strType + '"></video>'); 1176 1177 var objVideo = $(objDiv).find('video')[0]; 1178 1179 objVideo.onloadeddata = function() { 1180 $(objDiv).find('video').addClass('show'); 1181 $(objDiv).find('img.icon-spinner').remove(); 1182 }; 1183
1184 $(objDiv).addClass('init'); 1185 1186 }); 1187 1188}); 1189 1190function initPopper() { 1191 1192 if($('#hi5-popper').length) { 1193 1194 $('#PopperDialog').remove(); 1195 1196 var html = $('#hi5-popper').html(); 1197 1198 html = '<div id="PopperDialog" class="modal fade" role="dialog"><div class="modal-dialog"><div class="modal-content"><div class="modal-body">' + html; 1199 1200 html = html + '</div><div class="modal-footer"><button type="button" class="btn btn-secondary btn-default" data-bs-dismiss="modal" data-dismiss="modal">' + strLang_Continue + '</button></div></div></div></div>'; 1201 1202 $('body').append(html); 1203 1204 $('#PopperDialog .popper-footer-btn').each(function() { 1205 1206 $(this).detach().appendTo('#PopperDialog .modal-footer'); 1207 1208 }); 1209 1210 $('#hi5-popper').remove(); 1211 1212 $('#PopperDialog').modal('show'); 1213 1214 } 1215 1216} 1217 1218function initNumberCtrl() { 1219 1220 $(".Hi5Prices button.cart-add-btn:not(.init):not(.btn-disabled)").click(function() { 1221 1222 CartAdd(this); 1223 1224 }) 1225 1226 $(".Hi5Prices button.cart-add-btn:not(.init)").prop('disabled', false).addClass('init'); 1227 1228 $('.btn-number:not(.init)').each(function(){ 1229 1230 var fieldId = $(this).attr('data-field'); 1231 var input = $("#"+fieldId); 1232 var type = $(this).attr('data-type'); 1233 var currentVal = parseInt(input.val()); 1234 1235 if(type == 'minus') { 1236 $(this).attr('disabled', parseInt(input.val()) == input.attr('min')); 1237 } else if(type == 'plus') { 1238 $(this).attr('disabled', parseInt(input.val()) == input.attr('max')); 1239 } 1240 1241 }); 1242 1243 $('.btn-number:not(.init)').click(function(e){ 1244 e.preventDefault(); 1245 1246 var fieldId = $(this).attr('data-field'); 1247 var type = $(this).attr('data-type'); 1248 var input = $("#"+fieldId); 1249 var btnGroup = $("#btn-group-"+fieldId); 1250 var currentVal = parseInt(input.val()); 1251 if (!isNaN(currentVal)) { 1252 if(type == 'minus') { 1253 1254 if(currentVal > input.attr('min')) { 1255 //input.val(currentVal - 1).change(); 1256 CartAdd(btnGroup, currentVal - 1); 1257 } 1258 if(parseInt(input.val()) == input.attr('min')) { 1259 $(this).attr('disabled', true); 1260 } 1261 1262 } else if(type == 'plus') { 1263 1264 if(!input.attr('max') || currentVal < input.attr('max')) { 1265 //input.val(currentVal + 1).change(); 1266 CartAdd(btnGroup, currentVal + 1); 1267 } 1268 if(input.attr('max') && parseInt(input.val()) == input.attr('max')) { 1269 $(this).attr('disabled', true); 1270 } 1271 1272 } 1273 } else { 1274 input.val(0); 1275 } 1276 }); 1277 $(".btn-number:not(.init)").addClass('init'); 1278 1279 $('.input-number:not(.init)').focusin(function(){ 1280 $(this).data('oldValue', $(this).val()); 1281 }); 1282 $('.input-number:not(.init)').change(function() { 1283 1284 var fieldId = $(this).attr('id'); 1285 var btnGroup = $("#btn-group-"+fieldId); 1286 var currentVal = parseInt($(this).val()); 1287 1288 if($(this).attr('max') && currentVal > $(this).attr('max')) currentVal = $(this).attr('max'); 1289 if(currentVal<0) currentVal=0; 1290 1291 CartAdd(btnGroup, currentVal); 1292 1293 }); 1294 $(".input-number:not(.init)").keydown(function (e) { 1295 // Allow: backspace, delete, tab, escape, enter and . 1296 if ($.inArray(e.keyCode, [46, 8, 9, 27, 13, 190]) !== -1 || 1297 // Allow: Ctrl+A 1298 (e.keyCode == 65 && e.ctrlKey === true) || 1299 // Allow: home, end, left, right 1300 (e.keyCode >= 35 && e.keyCode <= 39)) { 1301 // let it happen, don't do anything 1302 return; 1303 } 1304 // Ensure that it is a number and stop the keypress 1305 if ((e.shiftKey || (e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode > 105)) { 1306 e.preventDefault(); 1307 } 1308 }); 1309 1310 $(".input-number:not(.init)").addClass('init'); 1311 1312} 1313 1314/* add-to-cart button */ 1315 1316function CartAdd(objButton, qty) { 1317 1318 qty = typeof qty !== 'undefined' ? qty : 1; 1319 1320 var baseHref = document.getElementsByTagName('base')[0].href; 1321 var enumType = $(objButton).attr('data-type'); 1322 var blnProrate = $(objButton).attr('data-prorate'); 1323 var enumLang = $('html')[0].lang; 1324 var strSKU = $(objButton).attr('data-sku'); 1325 var strFunds = enumType=="donation" ? $('#donation-form').serialize() : ""; 1326 var strButtonType = $(objButton).attr('data-button-type'); 1327 1328 var strRequest = "cart/add/?item=" + strSKU + "&qty=" + qty + (blnProrate ? "&prorate=1" : "") + "&enumLang=" + enumLang + (enumType ? '&type='+enumType+(strFunds ? '&'+strFunds: '') : '') + (strButtonType ? "&button=" + strButtonType : ""); 1329 1330 var htmlButton = $(objButton).html(); 1331 $(objButton).html('<i class="glyphicon glyphicon-hourglass"></i><span class="cart-text-placeholder">' + htmlButton + '</span>'); 1332 $('.Hi5Prices .cart-text-placeholder button, .Hi5Prices .cart-text-placeholder input').prop('disabled', true); 1333 1334 setTimeout(function(){ 1335 if(htmlButton) { 1336 $(objButton).html(htmlButton); 1337 $(objButton).removeClass('init').find('.init').removeClass('init'); 1338 initNumberCtrl(); 1339 } 1340 1341 }, HI5_LOCK_RELEASE * 100); 1342 1343 console.log("AJAX request: " + baseHref + strRequest); 1344 1345 $.ajax({ 1346 1347 url: strRequest 1348 1349 , success: function(result) { 1350 1351 htmlButton = ""; // to cancel lock release 1352 1353 $("#Hi5Cart-Summary").html(result.summary); 1354 $(".Hi5Prices tfoot a.btn").css('opacity', 1); 1355 $(objButton).replaceWith(result.button); 1356 initNumberCtrl(); 1357 1358 } 1359 1360 , error: function(result) { 1361 1362 htmlButton = '<i class="fas fa-triangle-exclamation"></i>'; 1363 1364 var response = JSON.parse(result.responseText); 1365 console.log(response); 1366 alert(response.statusText); 1367 $(objButton).html(htmlButton); 1368 1369 } 1370 1371 }); 1372 1373 1374} 1375 1376/* dropdown-select-btn */ 1377 1378function initDropSelect(strSelector) { 1379 1380 strSelector = (strSelector ? strSelector + " " : "") + ".dropdown-select-btn:not(.dropdown-select-btn-init)"; 1381 1382 $(strSelector).click(function(e) { 1383 refreshDropSelect(this); 1384 }); 1385 1386 $(strSelector).each(function() { 1387 refreshDropSelect(this); 1388 }); 1389 1390 $(strSelector).addClass('dropdown-select-btn-init'); 1391 1392} 1393 1394function refreshDropSelect(obj) { 1395 1396 var val = $(obj).find(".dropdown-item :checked + span + span.radio-label").text(); 1397 1398 if(!val) val = $(obj).find(".dropdown-item :checked + span.radio-label").text(); 1399 1400 $(obj).find("button").text(val); 1401 1402 $(obj).find(".dropdown-item").removeClass("selected"); 1403 1404 $(obj).find(".dropdown-item :checked + span.radio-label").each(function(){ 1405 1406 $(this).parent().addClass('selected'); 1407 1408 }); 1409 1410} 1411 1412function mailTo(obj) { 1413 1414 var url = $(obj).attr('href'); 1415 var baseHref = document.getElementsByTagName('base')[0].href; 1416 var strRequest = url + "&return=mailto"; 1417 1418 var htmlButtonText = $(obj).html(); 1419 $(obj).html('<i class="glyphicon glyphicon-hourglass"></i> Loading...').css('cursor', 'wait'); 1420 1421 console.log("AJAX request: " + baseHref + strRequest); 1422 1423 $.ajax({ 1424 1425 url: strRequest 1426 1427 , success: function(result) { 1428 setTimeout(function() { $(obj).html(htmlButtonText).css('cursor', 'pointer'); }, 2500); 1429 window.location.href = result; 1430 } 1431 , error: function(result) { 1432 $(obj).html('<i class="glyphicon glyphicon-hourglass"></i> Redirecting...').css('cursor', 'wait'); 1433 setTimeout(function() { $(obj).html(htmlButtonText).css('cursor', 'pointer'); }, 5000); 1434 window.location.href=url; 1435 } 1436 1437 }); 1438 1439 return false;
1440 1441} 1442 1443function initConfirmation() { 1444 1445 $("[data-toggle='confirmation'][data-href]").each(function(){ 1446 $(this).attr('href', $(this).attr('data-href')).removeAttr('data-href'); 1447 }); 1448 1449 $("[data-toggle='confirmation']:not([data-original-title])").each(function() { 1450 1451 $(this).removeClass('loading').popConfirm({ 1452 placement: $(this).attr('data-placement') ? $(this).attr('data-placement') : 'top', 1453 yesBtn: strLang_Yes, 1454 noBtn: strLang_No 1455 }); 1456 }); 1457 1458} 1459 1460 1461function initCommentButtons() { 1462 1463 $('button.edit-comment-btn.btn-loading').each(function(){ 1464 1465 $(this).click(function(){ 1466 1467 var objButton = this; 1468 1469 $(objButton).tooltip('dispose'); // destroy any tooltip that is active 1470 1471 var htmlOrginalContent = $(objButton).html(); 1472 1473 // Set the button width explicitly to its current width 1474 $(objButton).css('width', $(objButton).outerWidth() + 'px'); 1475 $(objButton).html('<i class="glyphicon glyphicon-hourglass icon-spinner"></i>'); 1476 1477 var fkContentSource = $(objButton).attr('data-content-source'); 1478 var fkContent = parseInt($(objButton).attr('data-content-id')); 1479 1480 var urlAjax = urlAjaxBase + 'ajax/comments/?comaction=edit&source=' + encodeURIComponent(fkContentSource) + '&id=' + fkContent; 1481 var baseHref = document.getElementsByTagName('base')[0].href; 1482 console.log("AJAX request: " + baseHref + urlAjax); 1483 1484 $.ajax({ 1485 url: urlAjax 1486 , success: function(result) { 1487 1488 $(objButton).closest('.content-comment').find('.comment-block').addClass('d-none').after(result); 1489 $(objButton).closest('.content-comment').find('.btn-toolbar').addClass('d-none'); 1490 $('#edit-comment-'+fkContent + ' #comment').prop('id', 'comment'+fkContent); 1491 initFormControls('edit-comment-'+fkContent); 1492 initConfirmation(); 1493 1494 }, error: function(result) { 1495 1496 $(objButton).html(htmlOrginalContent); 1497 alert("An error occurred: " + $(result.responseText).text().replace(/[\r\n\t]/g, '')); 1498 1499 } 1500 }); 1501 1502 }); 1503 1504 $(this).prop('disabled', false).removeClass('btn-loading'); 1505 1506 }); 1507 1508 $('button.delete-comment-btn.btn-loading').each(function(){ 1509 1510 $(this).click(function(){ 1511 1512 var objButton = this; 1513 1514 var htmlOrginalContent = $(objButton).html(); 1515 1516 // Set the button width explicitly to its current width 1517 $(objButton).css('width', $(objButton).outerWidth() + 'px'); 1518 $(objButton).html('<i class="glyphicon glyphicon-hourglass icon-spinner"></i>'); 1519 1520 var fkContentSource = $(objButton).attr('data-content-source'); 1521 var fkContent = parseInt($(objButton).attr('data-content-id')); 1522 1523 var urlAjax = urlAjaxBase + 'ajax/comments/?comaction=delete&source=' + encodeURIComponent(fkContentSource) + '&id=' + fkContent; 1524 var baseHref = document.getElementsByTagName('base')[0].href; 1525 console.log("AJAX request: " + baseHref + urlAjax); 1526 1527 $.ajax({ 1528 url: urlAjax 1529 , success: function(result) { 1530 1531 $(objButton).closest('.content-comment').remove(); 1532 1533 }, error: function(result) { 1534 1535 $(objButton).html(htmlOrginalContent); 1536 alert("An error occurred: " + $(result.responseText).text().replace(/[\r\n\t]/g, '')); 1537 1538 } 1539 }); 1540 1541 }); 1542 1543 $(this).prop('disabled', false).removeClass('btn-loading'); 1544 1545 }); 1546 1547 1548} 1549 1550function initComponentFilterControls() { 1551 1552 if(window.blnComponentFilterControlsInit) return; 1553 window.blnComponentFilterControlsInit = true; 1554 1555 $(document).off("click", ".alpha-filter button[data-alpha]"); 1556 1557 $(document).on("click", ".alpha-filter button[data-alpha]", function() { 1558 1559 var $button = $(this); 1560 var $filter = $button.closest(".alpha-filter"); 1561 var alpha = $button.attr("data-alpha"); 1562 1563 $filter.find("input[name='alpha']").prop("checked", false); 1564 1565 $filter.find("input[name='alpha']").filter(function() { 1566 return $(this).val() == alpha; 1567 }).prop("checked", true); 1568 1569 $filter.find("button[data-alpha]") 1570 .removeClass("btn-primary") 1571 .addClass("btn-outline-primary"); 1572 1573 $button 1574 .removeClass("btn-outline-primary") 1575 .addClass("btn-primary"); 1576 1577 }); 1578 1579 $(document).off("click", ".hi5_component_filters button[name='view']"); 1580 1581 $(document).on("click", ".hi5_component_filters button[name='view']", function() { 1582 1583 var $form = $(this).closest("form"); 1584 1585 if(!$form.length) return; 1586 1587 $form 1588 .find("input[type='hidden'][name='view']") 1589 .prop("disabled", true); 1590 1591 }); 1592
1593 $(document).off("change", ".hi5_component_filters select, .hi5_component_filters input[type='radio'], .hi5_component_filters input[type='checkbox']"); 1594 1595 $(document).on("change", ".hi5_component_filters select, .hi5_component_filters input[type='radio'], .hi5_component_filters input[type='checkbox']", function() { 1596 1597 var $form = $(this).closest("form"); 1598 1599 if(!$form.length) return; 1600 if($(this).attr("name") == "alpha") return; 1601 1602 var urlAjax = $form.attr("data-ajax-url"); 1603 1604 $.ajax({ 1605 url: urlAjax + "&comaction=filter_options", 1606 type: "POST", 1607 dataType: "json", 1608 data: $form.serialize(), 1609 success: function(response) { 1610 1611 console.log(response); 1612 1613 if(!response || !response.success) { 1614 1615 var strErrorMsg = response && response.message 1616 ? response.message 1617 : "Could not refresh filters."; 1618 1619 $('#hi5-popper').remove(); 1620 $('body').append('<div style="display:none;" id="hi5-popper">' + strErrorMsg + '</div>'); 1621 initPopper(); 1622 1623 return; 1624 1625 } 1626 1627 if(!response.html || !$.trim(response.html.search_form)) { 1628 1629 var strErrorMsg = response.message 1630 ? response.message 1631 : "Filter refresh succeeded, but no updated filter form was returned."; 1632 1633 $('#hi5-popper').remove(); 1634 $('body').append('<div style="display:none;" id="hi5-popper">' + strErrorMsg + '</div>'); 1635 initPopper(); 1636 1637 return; 1638 1639 } 1640 1641 var $newForm = $(response.html.search_form); 1642 1643 if(!$newForm.length) { 1644 1645 $('#hi5-popper').remove(); 1646 $('body').append('<div style="display:none;" id="hi5-popper">Filter refresh returned invalid form markup.</div>'); 1647 initPopper(); 1648 1649 return; 1650 1651 } 1652 1653 $form.replaceWith($newForm); 1654 1655 }, 1656 error: function(xhr, textStatus, errorThrown) { 1657 1658 var strErrorMsg = "Could not refresh filters."; 1659 1660 if(textStatus == "parsererror") { 1661 strErrorMsg = "Filter refresh returned invalid JSON."; 1662 } 1663 1664 if(xhr && xhr.responseText) { 1665 console.log(xhr.responseText); 1666 } 1667 1668 $('#hi5-popper').remove(); 1669 $('body').append('<div style="display:none;" id="hi5-popper">' + strErrorMsg + '</div>'); 1670 initPopper(); 1671 1672 } 1673 }); 1674 1675 }); 1676 1677}
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.