1//setups the registration page on document ready 2$(function () { 3 registrationSearch.ready(); 4 initRoleDescriptionList(); 5}); 6 7class RegistrationModal { 8 constructor() { 9 this.scope = $('#registration-modal'); 10 this.registerStateListChange(); 11 this.registerMasks(); 12 this.registerCustomFieldCheckboxList(); 13 this.registerCustomFieldDropdownList(); 14 this.registerDunsSearchOnEnter(); 15 this.registerFormSubmitOnEnter(); 16 $('button[aria-label="UI Editor"]').remove(); 17 } 18 19 registerStateListChange() { 20 $('#RegistrationRequest_StateSelection', this.scope).change(this.reloadCountyList); 21 } 22 23 reloadCountyList(event) { 24 $.ajax({ 25 type: 'POST', 26 dataType: 'JSON', 27 url: sourcePath + '/RegistrationModal/CountyList', 28 data: { FilterID: $(event.target).val() }, 29 success: (CountyList) => { 30 var prevVal = $('#RegistrationRequest_CountySelection').val(); 31 let generatedOptions = (items) => { 32 let options = ''; 33 34 for (let i = 0; i < items.length; i++) { 35 options += '<option value="' + items[i].Value + '">' + items[i].Text + '</option>'; 36 } 37 38 return options; 39 }; 40 41 $('#RegistrationRequest_CountySelection').html(generatedOptions(CountyList)); 42 $('#RegistrationRequest_CountySelection').val(prevVal); 43 } 44 }); 45 } 46 47 registerMasks() { 48 $("#RegistrationRequest_Phone").inputmask({ 49 mask: [{ "mask": "(###) ###-#### ext. #{0,5}" }], 50 jitMasking: true, 51 skipOptionalPartCharacter: " ", 52 definitions: { '#': { validator: "[0-9]", cardinality: 1 } } 53 }); 54 55 try { 56 $("#RegistrationRequest_Phone2").inputmask({ 57 mask: [{ "mask": "(###) ###-#### ext. #{0,5}" }], 58 jitMasking: true, 59 skipOptionalPartCharacter: " ", 60 definitions: { '#': { validator: "[0-9]", cardinality: 1 } } 61 }); 62 } catch (ex) { 63 console.log(ex); 64 } 65 66 try { 67 $("#RegistrationRequest_Fax").inputmask({ 68 mask: [{ "mask": "(###) ###-#### ext. #{0,5}" }], 69 jitMasking: true, 70 skipOptionalPartCharacter: " ", 71 definitions: { '#': { validator: "[0-9]", cardinality: 1 } } 72 }); 73 } catch (ex) { 74 console.log(ex); 75 } 76 77 try { 78 $("#RegistrationRequest_PhoneCell").inputmask({ 79 mask: [{ "mask": "(###) ###-#### ext. #{0,5}" }], 80 jitMasking: true, 81 skipOptionalPartCharacter: " ", 82 definitions: { '#': { validator: "[0-9]", cardinality: 1 } } 83 }); 84 } catch (ex) { 85 console.log(ex); 86 } 87 $("#RegistrationRequest_DUNS").inputmask({ 88 mask: [{ "mask": "##-###-####" }], 89 definitions: { '#': { validator: "[0-9]", cardinality: 1 } } 90 }); 91 $("#RegistrationRequest_FEIN").inputmask({ 92 mask: [{ "mask": "##-#######" }], 93 definitions: { '#': { validator: "[0-9]", cardinality: 1 } } 94 }); 95 96 initInputMask(); 97 fixURLs(); 98 } 99 100 registerCustomFieldCheckboxList() { 101 //Set ValueText and ValueNText as comma separated string value with each checkbox list option selected 102 $(".customfield-checkboxlist-option").change(function () { 103 //get custom field and its value inputs 104 var csfID = $(this).data('igx-csf'); 105 var cfValueText = $(this).parent().siblings(".cf-cbl-val-text").first(); 106 var cfValueNText = $(this).parent().siblings(".cf-cbl-val-ntext").first(); 107 108 //get all checked options for this custom field 109 var checkedOptions = $('.customfield-checkboxlist-option[data-igx-csf="' + csfID + '"]:checked'); 110 111 //get all selected as comma separated values 112 var valText = checkedOptions.map(function () { 113 return $(this).data('igx-cfl'); 114 }).get().join(','); 115 116 var valNText = checkedOptions.map(function () { 117 return $(this).parent().text(); 118 }).get().join(', '); 119 120 //set the input values 121 cfValueText.val(valText); 122 cfValueNText.val(valNText); 123 }); 124 } 125 126 registerCustomFieldDropdownList() { 127 $(".customfield-dropdownlist").change(function () { 128 var cfDDLTextField = $(".cf-ddl-text" + "[data-igx-csf='" + $(this).attr("data-igx-csf") + "']", $(this).parent()); 129 cfDDLTextField.val(this.options[this.selectedIndex].text); 130 });
131 } 132 133 registerFormSubmitOnEnter() { 134 let submitFunction = this.attemptSubmit; 135 $(document).off('keypress', ".js-register-enter").on('keypress', ".js-register-enter", function (event) { 136 if (event.which === 13) { 137 event.preventDefault(); 138 event.stopPropagation(); 139 submitFunction(); 140 return false; 141 } 142 }); 143 } 144 registerDunsSearchOnEnter() { 145 let searchFunction = searchDUNS; 146 $(document).off('keypress', ".js-duns-enter").on('keypress', ".js-duns-enter", function (event) { 147 if (event.which === 13) { 148 event.preventDefault(); 149 event.stopPropagation(); 150 searchFunction(); 151 return false; 152 } 153 }); 154 } 155 attemptSubmit() { 156 $(".js-validate").valid(); 157 if ($('#modalBaseForm').valid()) { 158 $('#modalBaseForm').trigger("submit"); 159 } 160 } 161 162} 163 164class Registration { 165 constructor() { } 166 167 ready() { 168 this.registerActionSelectionChange(); 169 this.registerStateListChange(); 170 this.registerDatePickers(); 171 this.registerSearchClick(); 172 this.registerExecuteClick(); 173 this.registerClearSearchClick(); 174 this.customFieldConfirm = false; 175 } 176 177 registerActionSelectionChange() { 178 $('input[name="Action"]').change((event) => { 179 $('.action').addClass('hidden'); 180 $('.action-' + $(event.target).val()).removeClass('hidden'); 181 182 let actionText = $(event.target).next().next().text().trim().split(' ')[0] + ' Selected'; 183 $('#btn-approve').closest('#buttonBar').removeClass('hidden'); 184 $('#btn-approve').removeClass('hidden').attr('value', actionText).html(actionText); 185 }); 186 } 187 188 registerStateListChange() { 189 $('#SearchParams_StateSelection').change(this.reloadCountyList); 190 } 191 192 registerDatePickers() { 193 IGXPickers.Init(); 194 } 195 196 registerSearchClick() { 197 $('.btn-search').click(this.search); 198 } 199 200 registerExecuteClick() { 201 $('#btn-approve').closest('#buttonBar').addClass('hidden'); 202 $('#btn-approve').addClass('hidden').click(this.execute); 203 } 204 205 registerClearSearchClick() { 206 //clear out search parameters 207 $("#btnRegistrationSearchClear").click(function () { 208 $('.search-param-container :input').val(''); 209 }); 210 } 211 212 //// POST FUNCTIONS 213 reloadCountyList(event) { 214 $.ajax({
215 type: 'POST', 216 dataType: 'JSON', 217 url: sourcePath + '/RegistrationModal/CountyList', 218 data: { FilterID: $(event.target).val() }, 219 success: (CountyList) => { 220 let generatedOptions = (items) => { 221 let options = ''; 222 223 for (let i = 0; i < items.length; i++) { 224 options += '<option value="' + items[i].Value + '">' + items[i].Text + '</option>'; 225 } 226 227 return options; 228 }; 229 230 $('#SearchParams_CountySelection').html('<option value></option>' + generatedOptions(CountyList)); 231 } 232 }); 233 } 234 235 search() { 236 $.posterSearch({ 237 type: 'POST', 238 data: buildModel('registration-search'), 239 success: (result) => { 240 let $resultTable = $('#_RegistrationRequestTable'); 241 $resultTable.html(result); 242 //$('tbody', $resultTable).remove(); 243 //$resultTable.append(result); 244 //remove previously checked values 245 $('input:checkbox').removeAttr('checked'); 246 $('#lblResults').focus(); 247 initTooltips(); 248 } 249 }); 250 } 251 252 loadCustomField(keyID) { 253 if (this.customFieldConfirm === false) { 254 this.customFieldConfirm = true; 255 256 let that = this; 257 $.post(sourcePath + "/RegistrationSearch/GetRegistrationCustomFields", 258 { "keyID": keyID }).done(function (result) { 259 var JsonObject = JSON.parse(result); 260 var CustomFieldValues = JsonObject.CustomFieldValues; 261 var confirmContent = ""; 262 263 for (var i = 0; i < CustomFieldValues.length; i++) { 264 confirmContent += "<b>" + CustomFieldValues[i].Key + "</b>: " + CustomFieldValues[i].Value + "<br>"; 265 } 266 267 $.confirm({ 268 title: JsonObject.RegisterName, 269 draggable: true, 270 content: confirmContent, 271 buttons: { 272 Close: { 273 btnClass: 'btn-primary', 274 action: function () { 275 } 276 } 277 } 278 }); 279 280 281 }).always(function () { 282 that.customFieldConfirm = false 283 }); 284 } 285 286 } 287 288 execute() { 289 290 } 291 292 //// END POST FUNCTIONS 293 294} 295 296function searchDUNS() { 297 var DUNSNumber = $('#RegistrationRequest_DUNS').val(); 298 299 $.ajax({ 300 url: sourcePath + "/RegistrationModal/DUNSSearch", 301 type: "GET", 302 data: { 303 "DUNSNumber": DUNSNumber 304 }, 305 dataType: "html", 306 beforeSend: function () { 307 poster.on("Searching"); 308 }, 309 success: function (result) { 310 var $targetDiv = $('#_divDUNSdata'); 311 $targetDiv.html(result); 312 }, 313 complete: function () { 314 poster.off(); 315 let registrationModal = new RegistrationModal(); 316 }, 317 error: function (xhr, textStatus, errorThrown) { 318 319 } 320 }); 321 322} 323 324function searchSAM() { 325 var SAMNumber = $('#RegistrationRequest_SAM').val(); 326 327 $.ajax({ 328 url: sourcePath + "/RegistrationModal/SAMSearch", 329 type: "GET", 330 data: { 331 "SAMNumber": SAMNumber 332 }, 333 dataType: "html", 334 beforeSend: function () { 335 poster.on("Searching"); 336 }, 337 success: function (result) { 338 oldDUNS = $("#RegistrationRequest_DUNS").val(); 339 var $targetDiv = $('#_divDUNSdata'); 340 $targetDiv.html(result); 341 $("#RegistrationRequest_DUNS").val(oldDUNS); 342 if ($('').valid == false || $('#SAMValidationError').text() !== '') { 343 $('#RegistrationRequest_SAM').focus(); 344 } 345 else { 346 $('#btnSAMSearch').focus(); 347 } 348 }, 349 complete: function () { 350 poster.off(); 351 let registrationModal = new RegistrationModal(); 352 }, 353 error: function (xhr, textStatus, errorThrown) { 354 355 } 356 }); 357} 358 359//check user limit if checking approve radio buttons 360$(document).on('click', "input[type='radio'][name='Action']", function () { 361 var input = $(this); 362 if (input.val() > 0) validateUserLimit(); 363}); 364 365function validateUserLimit() { 366 $.ajax({ 367 type: 'GET', 368 dataType: 'JSON', 369 url: sourcePath + '/RegistrationModal/ExceedsLimit', 370 success: (License) => { 371 if (License.Exceeds) { 372 $.confirm({ 373 title: 'Active User Limit Reached!', 374 draggable: true, 375 content: License.ExceedsContent, 376 buttons: { 377 Close: { 378 btnClass: 'btn-primary', 379 action: function () {
380 $('[id="Action"]:not([value="0"])').parent().parent().parent().remove(); 381 $('#Action').click(); 382 } 383 } 384 } 385 }); 386 } 387 } 388 }); 389} 390 391 392//Filter Organization List using org Name input text once three or more chars are supplied. Delay search so not ran on every key press. 393$(document).on('keyup', '#OrganizationNameFilter', function (e) { 394 //don't filter when tabbed into 395 let key = e.key; 396 if (key == 'Tab' || key == 'Shift') { 397 return false; 398 } 399 400 delay(function () { 401 var OrgNameFilter = $("#OrganizationNameFilter").val(); 402 if (OrgNameFilter.length >= 3 || OrgNameFilter == '') { 403 filterOrganizationList(OrgNameFilter); 404 } 405 }, 300); 406}); 407 408var delay = (function () { 409 var timer = 0; 410 return function (callback, ms) { 411 clearTimeout(timer); 412 timer = setTimeout(callback, ms); 413 }; 414})(); 415 416//Update Organization drop down list. 417function filterOrganizationList(orgName) { 418 $.getJSON('RegistrationSearch/GetOrganizationList', 419 { orgName: orgName }, 420 function (data) { 421 var selectList = $("#ActionData_OrganizationSelection"); 422 selectList.empty(); 423 selectList.prepend("<option value='' selected='selected'></option>"); 424 425 $.each(data, function (index, optionData) { 426 var option = $('<option>').text(optionData.Text).val(optionData.Value); 427 selectList.append(option); 428 }); 429 }); 430} 431 432function RegistrationSearchSubmit() { 433 let registrationForm = $('#registration-search'); 434 435 if (registrationForm.valid()) { 436 437 //Approve User(s) or Approve User(s) And Organization(s) has been selected 438 if (($("#Action_1")[0] && $("#Action_1")[0].checked) || ($("#Action_2")[0] && $("#Action_2")[0].checked)) { 439 440 //ensure role options has been selected 441 if ($("input:checked[type='checkbox']", "#RoleOptions").length == 0) { 442 $.confirm({ 443 title: 'Role Error', 444 draggable: true, 445 content: 'Please select at least one role', 446 buttons: { 447 confirm: { 448 btnClass: 'btn-primary', 449 action: function () { 450 } 451 } 452 } 453 }); 454 return; //does not post until roles selected 455 } //end role check 456 457 //duplicate email check 458 var checkedWithEmailWarning = $(".registration-request-results input:checked[type='checkbox']").closest('tr').find(".glyphicon-warning-sign"); 459 //warn when users with existing emails are being approved 460 if (false) { 461 $.confirm({ 462 title: 'Confirm', 463 draggable: true, 464 content: 'One or more users you are approving shares an email address with one or more existing users. Select Approve to continue or Cancel to review and update your selections.' 465 + '<br/>The <span class="glyphicon glyphicon-warning-sign"></span> is displayed in the row of each user with a duplicate email address.', 466 buttons: { 467 cancel: { 468 btnClass: 'btn-danger', 469 action: function () { 470 } 471 }, 472 confirm: { 473 text: 'Approve', 474 btnClass: 'btn-primary', 475 action: function () { 476 postRegistrationForm(registrationForm) 477 } 478 } 479 } 480 }); 481 //end duplicate email check 482 } else { 483 //post approvals 484 postRegistrationForm(registrationForm) 485 } 486 } else { 487 //get selected checkboxes 488 let selectedCBs = $('.igx-checkbox-container').find(':checkbox:checked') 489 490 //put selected registration ids into a comma separated string 491 if (selectedCBs.length > 0) { 492 let selectedIDs = selectedCBs.map(function (i, opt) { 493 //return $(opt).parent().next("[id$='RegistrationID']").val(); 494 return $(opt).closest('tr').find("[name$='.RegistrationID']").val(); 495 }).toArray().join(', '); 496 497 //launch deny user modal so user can enter a reason for each denial
498 loadModal("3000146", "RegistrationSearchModal", null, selectedIDs, undefined, "GET", false); 499 } 500 } 501 } else { 502 window.scroll(0, 0); 503 } 504} 505 506function postRegistrationForm(registrationForm) { 507 poster.on("Saving"); 508 //registrationForm.submit(); 509 510 $.ajax({ 511 url: sourcePath + "/RegistrationSearch/ExecuteAction", 512 type: "POST", 513 data: registrationForm.serialize(), 514 dataType: "json", 515 success: function (response) { 516 if (response.redirectUrl) { 517 // Redirect to the specified URL 518 window.location.href = response.redirectUrl; 519 } 520 }, 521 error: function (xhr, status, error) { 522 var data = JSON.parse(xhr.responseJSON.data.Data) //Yo dawg, I heard you like data 523 //so I put data in your data so you can data while you data - Xzibit, 2006 - Per Co-Pilot 524 const results = data.Results.map(result => { 525 const iconClass = result.Type === 'Warning' ? 'glyphicon-warning-sign' : 'glyphicon-ban-circle error'; 526 const title = result.Type === 'Warning' ? 'Warning' : 'Error'; 527 return `<span title="${title}" class="glyphicon ${iconClass}"></span> ${result.Message}`; 528 }).join('<br/>'); 529 530 531 const buttons = { 532 cancel: { 533 text: "Cancel", 534 btnClass: data.Type == 'Errors' ? "hidden btn-danger" : " btn-danger" 535 }, 536 confirm: { 537 text: data.Type == 'Warnings' ? 'Continue' : 'Okay', 538 btnClass: 'btn-primary', 539 action: function () { 540 if (data.Type == 'Warnings') { 541 $('#PreExec_SkipWarnings').val("True"); 542 RegistrationSearchSubmit(); 543 } 544 } 545 } 546 }; 547 548 poster.off(); 549 550 //Display Confirm dialog 551 $.confirm({ 552 title: data.Type === 'Warnings' ? 'Warning' : 'Error(s) Found', 553 onOpen: function () { 554 focusTrapThisB(this); 555 }, 556 content: results, 557 buttons: buttons, 558 columnClass: "col-md-6 col-md-offset-3" 559 }); 560 }, complete: function () { 561 $('#PreExec_SkipWarnings').val("False"); 562 } 563 }); 564} 565 566function registrationTranslate(sender) { 567 //TODO: Update all this, copied from initGoogleTranslate 568 var language = $('#DisplayLanguage').val(); 569 var currentLang = $.cookie("googtrans"); 570 571 if (!currentLang || currentLang == "") { 572 currentLang = "/en/" + language; 573 } 574} 575 576//make person profile organization table scrollable for mobile 577function applyRegistrationMobileStyles() { 578 $("#registration-search").css("overflow", "hidden"); 579 $("#registration-panel").css("overflow-x", "scroll"); 580 $("#registration-body").css("width", "300%"); 581} 582 583let registrationSearch = new Registration(); 584 585function postSaveRegistrationDeny() { 586 poster.on("Loading"); 587 location.reload(); 588} 589 590function initRegistrationRequestTable(domainRegistrationEnabled) { 591 592 if (domainRegistrationEnabled == 'False') { 593 //remove domain registartion column 594 $('[id$="SystemSelected"]').parent().remove() 595 } 596 initAdditionalInfoPopup(); 597 adjustRegistrationRequestTableColumns(); 598} 599 600function initAdditionalInfoPopup() { 601 //when row has additional data, add icon to display it 602 let hasCustomFieldDataSpans = $("span[name$='.HasCustomFields']"); 603 604 hasCustomFieldDataSpans.each(function () { 605 let textSpan = $(this); 606 let textValue = textSpan.text(); 607 608 //clear text 609 textSpan.text(''); 610 611 //add icon with click event if more data available 612 if (textValue == "True") { 613 textSpan.addClass("glyphicon glyphicon-info-sign additional-info pull-right"); 614 textSpan.attr("title", "View Additional Information"); 615 } 616 }); 617 618 //add click event to icon with registrationID 619 $(".additional-info").click(function () { 620 let regID = $(this).closest("tr").find("input[name$='.RegistrationID']").first().val(); //get the RegistrationID from the row 621 registrationSearch.loadCustomField(regID); 622 }); 623} 624 625function adjustRegistrationRequestTableColumns() { 626 //adjust column widths 627 //selected checbkbox column 628 let selectedTableHead = $("#Requests_Col_Selected").parent(); 629 let selectedTableData = $("input[name$='.Selected']").closest('td'); 630 selectedTableHead.width('3%'); 631 selectedTableData.width('3%'); 632 633 //additional info column 634 let hasCustomFieldsTableHead = $("#Requests_Col_HasCustomFields").parent(); 635 let hasCustomFieldsTableData = $("span[name$='.HasCustomFields']").closest('td'); 636 hasCustomFieldsTableHead.width('3%'); 637 hasCustomFieldsTableData.width('3%'); 638}
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.