1 2if (window.jQuery) { 3 (function ($) { 4 $(document).ready(function () { 5 var activeStep = $(".progress .list-group-item.active"); 6 if (activeStep.length) { 7 //Placing div outside of ol parent because div is not allowed as direct children inside ol/ul 8 $(activeStep).parents().eq(1).append('<div id=' + activeStep.text() + ' class="sr-only" aria-live="assertive">' + activeStep.text() + '</div>'); 9 $("fieldset").first().attr("aria-labelledby", activeStep.text()); 10 setTimeout(function () { 11 $("fieldset .control").first()[0].firstChild.focus(); 12 }); 13 } 14 15 // Linkify readonly url and email input types. 16 $(".entity-form input[type='url'][readonly], .entity-form input[type='url'][disabled]").each(function () { 17 var url = null; 18 var text = ''; 19 if ($(this).hasClass("tickersymbol")) { 20 url = "http://go.microsoft.com/fwlink?linkid=8506&Symbol=" + encodeURIComponent($(this).val().toString().toUpperCase()); 21 text = $(this).val(); 22 } else { 23 url = $(this).val(); 24 text = url; 25 } 26 if (text == null || text == '' || url == null || url == '') { 27 return; 28 } 29 var $parent = $(this).parent(); 30 var $container = $("<div></div>").addClass("control"); 31 var $link = $("<a></a>").addClass("text-primary").css("cursor", "pointer").attr("href", url).attr("target", "_blank").attr("readonly", "readonly").text(text); 32 $(this).hide(); 33 $container.append($link).appendTo($parent); 34 }); 35 $(".entity-form input[type='email'][readonly], .entity-form input[type='email'][disabled]").each(function () { 36 var email = $(this).val(); 37 if (email == null || email == '') { 38 return; 39 } 40 var $parent = $(this).parent(); 41 var $container = $("<div></div>").addClass("control"); 42 var $link = $("<a></a>").addClass("text-primary").css("cursor", "pointer").attr("href", "mailto:" + email).attr("readonly", "readonly").text(email); 43 $(this).hide(); 44 $container.append($link).appendTo($parent); 45 }); 46 47 // Add "required" attribute anywhere it couldn't be done on the server 48 $(".entity-form span[data-required]").each(function () { 49 $(this).find("input,select,textarea").prop("required", $(this).data("required")); 50 }); 51 52 $(".entity-form").on("keypress.entityform", "*", function (e) { 53 var keyCode = e.keyCode ? e.keyCode : e.which; 54 if (keyCode == '13') { 55 //stop form from submitting in address composite control on press of enter key 56 let addresscomposite = $('textarea[id^=address]'); 57 if (addresscomposite != undefined && addresscomposite.length != 0) { 58 let addresscompositepopover = addresscomposite.closest('.control').find('.popover-content'); 59 if (addresscompositepopover != undefined && addresscompositepopover.has($(document.activeElement)).length != 0) { 60 e.preventDefault(); 61 } 62 } 63 e.stopPropagation(); 64 } 65 }); 66 67 $("form").find("input[type=submit],button").on("keypress.entityform", function (e) { 68 var keyCode = e.keyCode ? e.keyCode : e.which; 69 if (keyCode == '13') { 70 e.preventDefault(); 71 e.stopPropagation(); 72 $(this).trigger("click"); 73 } 74 }); 75 }); 76 }(window.jQuery)); 77} 78//changed to fix accessibilty bug 4471976 79$(window).load(function () { 80 setfocusOnSuccessMessage(); 81}); 82function setfocusOnSuccessMessage() { 83 if ($('#MessageLabel').is(':visible')) { 84 $('div.status > span.label-default').text($('#casetypecode option[selected="selected"]').text()); 85 // Use aria-live to announce success message without moving focus 86 $('#MessageLabel').attr({'aria-live': 'polite', 'aria-atomic': 'true'}); 87 if ($('#MessageLabel').parent("div").hasClass("success")) 88 { 89 if (window.history.replaceState) { 90 window.history.replaceState(null, $("title").text(), window.location.href); 91 } 92 } 93 // Do not programmatically focus the message; aria-live will announce it 94 } 95 else { 96 if ($('#PreviousButton').is(':visible')) { 97 $('form:not(.filter,.form-search) input,select,textarea,button').filter(function () { 98 if ($(this).is(':visible:enabled:not([readonly])')) 99 return this; 100 }).first().trigger('focus'); 101 } 102 } 103} 104// Simple helper to return the "exMaxLen" attribute for 105// the specified field. Using "getAttribute" won't work 106// with Firefox. 107function GetMaxLength(targetField) { 108 return targetField.exMaxLen; 109} 110 111// 112// Limit the text input in the specified field. 113// 114function LimitInput(targetField, sourceEvent) { 115 var isPermittedKeystroke; 116 var enteredKeystroke; 117 var maximumFieldLength; 118 var currentFieldLength; 119 var inputAllowed = true; 120 var selectionLength = parseInt(GetSelectionLength(targetField)); 121 122 if (GetMaxLength(targetField) != null) { 123 // Get the current and maximum field length 124 currentFieldLength = parseInt(targetField.value.length); 125 maximumFieldLength = parseInt(GetMaxLength(targetField)); 126 127 // Allow non-printing, arrow and delete keys 128 enteredKeystroke = window.event ? sourceEvent.keyCode : sourceEvent.which; 129 isPermittedKeystroke = ((enteredKeystroke < 32) 130 || (enteredKeystroke >= 33 && enteredKeystroke <= 40) 131 || (enteredKeystroke == 46)); 132 133 // Decide whether the keystroke is allowed to proceed 134 if (!isPermittedKeystroke) { 135 if ((currentFieldLength - selectionLength) >= maximumFieldLength) { 136 inputAllowed = false; 137 } 138 } 139 140 // Force a trim of the textarea contents if necessary 141 if (currentFieldLength > maximumFieldLength) { 142 targetField.value = targetField.value.substring(0, maximumFieldLength); 143 } 144 } 145 146 sourceEvent.returnValue = inputAllowed; 147 return (inputAllowed); 148} 149 150// 151// Limit the text input in the specified field. 152// 153function LimitPaste(targetField, sourceEvent) { 154 var clipboardText; 155 var resultantLength; 156 var maximumFieldLength; 157 var currentFieldLength; 158 var pasteAllowed = true; 159 var selectionLength = GetSelectionLength(targetField); 160 161 if (GetMaxLength(targetField) != null) { 162 // Get the current and maximum field length 163 currentFieldLength = parseInt(targetField.value.length); 164 maximumFieldLength = parseInt(GetMaxLength(targetField)); 165 166 clipboardText = (window.clipboardData || sourceEvent.clipboardData).getData("Text"); 167 resultantLength = currentFieldLength + clipboardText.length - selectionLength; 168 if (resultantLength > maximumFieldLength) { 169 pasteAllowed = false; 170 } 171 } 172 173 sourceEvent.returnValue = pasteAllowed; 174 return (pasteAllowed); 175} 176 177function LengthError(targetField, sourceEvent) { 178 var maxLength = parseInt($(targetField).attr("maxlength")); 179 var errorMessageID = 'length_error_message'; 180 if ($('#' + errorMessageID).length) { 181 $('#' + errorMessageID).remove(); 182 } 183 184 if ($(targetField).val().length == maxLength) { 185 $(targetField).after('<p class="alert sr-only" role="alert" id="' + errorMessageID + '">' + window.ResourceManager['Length_ErrorText'] + '</p>'); 186 return false; 187 } 188 return true; 189} 190 191// 192// Returns the number of selected characters in 193// the specified element 194// 195function GetSelectionLength(targetField) { 196 if (targetField.selectionStart == undefined) { 197 return document.selection.createRange().text.length; 198 } 199 else { 200 return (targetField.selectionEnd - targetField.selectionStart); 201 } 202} 203 204// Rounds the value of the specified element to the precision provided 205function setPrecision(id, precision) { 206 if (!id) { 207 return; 208 } 209 precision = precision || 0; 210 var y = document.getElementById(id).value; 211 if (y == "" || isNaN(y)) { 212 return; 213 } 214 document.getElementById(id).value = (parseFloat(y)).toFixed(precision); 215} 216 217// Opens ticker symbol with web url in a new window 218function launchTickerSymbolUrl(symbol) { 219 if (symbol == '') { 220 return false; 221 } 222 var url = "http://go.microsoft.com/fwlink?linkid=8506" + "&Symbol=" + encodeURIComponent(symbol.toString().toUpperCase()); 223 window.open(url, '_blank'); 224 return false; 225} 226 227// Sets the input elements string to uppercase 228function uppercaseTickerSymbol(element) { 229 if (element.value == '') { 230 return; 231 } 232 element.value = element.value.toUpperCase(); 233} 234 235// Opens a url in a new window 236function launchUrl(url) { 237 if (url == '') { 238 return false; 239 } 240 var scheme = getUrlScheme(url); 241 var validUrl; 242 switch (scheme.toLowerCase()) { 243 case "http": case "https": case "ftp": case "ftps": case "onenote": case "tel": 244 validUrl = true; 245 break; 246 default: 247 validUrl = false; 248 break; 249 } 250 if (validUrl) { 251 window.open(url, '_blank'); 252 return false; 253 } 254 return false; 255} 256
257// Launch email 258function launchEmail(email) { 259 if (email == '') { 260 return false; 261 } 262 window.location.href = "mailto:" + email; 263 return false; 264} 265 266// Returns the scheme of a url such as http, https, ftp etc. 267function getUrlScheme(value) { 268 var index = value.indexOf("://"); 269 if (index === -1) { 270 return ""; 271 } 272 else { 273 return value.substr(0, index); 274 } 275} 276 277// Ensures the input url has a valid scheme 278function validateUrlInput(element, maxLength) { 279 var url = element.value; 280 element.value = validateUrlProtocol(url, maxLength); 281} 282 283// If the url scheme is not valid it prepends a valid scheme to the url. 284function validateUrlProtocol(url, maxLength) { 285 if (url == '') { 286 return url; 287 } 288 maxLength = maxLength || 100; 289 var scheme = getUrlScheme(url); 290 switch (scheme.toLowerCase()) { 291 case "http": case "https": case "ftp": case "ftps": case "onenote": case "tel": return url; 292 case "": return prefixHttp(url, maxLength); 293 default: 294 alert('Invalid Protocol. Only HTTP, HTTPS, FTP, FTPS, ONENOTE and TEL protocols are allowed in this field.'); 295 return url; 296 } 297} 298 299// Checks if required field is empty 300function validateRequiredField(id) { 301 var control = document.getElementById(id); 302 if (control != undefined && (control.value == "" || control.value == null || control.value == undefined)) { 303 control.setAttribute("aria-invalid", "true"); 304 } 305 else { 306 control.setAttribute("aria-invalid", "false"); 307 } 308 // To check for radio button 309 $("#" + id).find("input:radio").each(function (i) { 310 if ($(this).is(":checked")) { 311 control.setAttribute("aria-invalid", "false"); 312 } 313 }); 314 315 // To check for checkbox 316 $("#" + id).find("input:checkbox").each(function (i) { 317 if ($(this).is(":checked")) { 318 control.setAttribute("aria-invalid", "false"); 319 } 320 }); 321} 322 323// Returns a url with a valid scheme 324function prefixHttp(url, maxlength) { 325 url = url.trim(); 326 if ("http://" != url.substr(0, "http://".length).toLowerCase() && "https://" != url.substr(0, "https://".length).toLowerCase()) url = "https://" + url.substring(0, maxlength - "https://".length); 327 return url; 328} 329 330// Scroll to element and focus on element. 331function scrollToAndFocus(scollToId, focusOnId) { 332 if (focusOnId == null || focusOnId.length <= 0) { 333 return; 334 } 335 if (scollToId == null || scollToId.length <= 0) { 336 scrollToPosition(focusOnId); 337 } else { 338 scrollToPosition(scollToId); 339 } 340 setFocus(focusOnId); 341} 342 343// Set focus on the element with the specified id. 344function setFocus(id) { 345 if (id == null) { 346 return; 347 } 348 var element = document.getElementById(id); 349 if (element != null) { 350 element.focus(); 351 } 352} 353 354// Scroll to the position of the element with the specified id. 355function scrollToPosition(id) { 356 if (id == null) { 357 return; 358 } 359 var element = document.getElementById(id); 360 var posX = element.offsetLeft; 361 var posY = element.offsetTop; 362 var parentElement = element.offsetParent; 363 while (parentElement != null) { 364 posX += parentElement.offsetLeft; 365 posY += parentElement.offsetTop; 366 parentElement = parentElement.offsetParent; 367 } 368 window.scrollTo(posX, posY); 369} 370 371function disableButtons() { 372 var inputs = document.getElementsByTagName("input"); 373 for (var i = 0, j = inputs.length; i < j; i++) { 374 if (inputs[i].type === 'submit' || inputs[i].type === 'button') { 375 inputs[i].disabled = true; 376 } 377 } 378} 379 380// Remove whitespace from the ends of a string 381String.prototype.trim = function () { 382 return this.replace(/^\s+|\s+$/g, ""); 383}; 384 385document.getElementsByClassName = function (cl) { 386 var retnode = []; 387 var myclass = new RegExp('\\b' + cl + '\\b'); 388 var elem = this.getElementsByTagName('*'); 389 for (var i = 0, j = elem.length; i < j; i++) { 390 var classes = elem[i].className; 391 if (myclass.test(classes)) retnode.push(elem[i]); 392 } 393 return retnode; 394}; 395 396// Updates the total of a constant sum composite control 397function updateConstantSum(name) { 398 var elements = document.getElementsByClassName(name); 399 var total = 0; 400 for (var i = 0, j = elements.length; i < j; i++) { 401 var value = elements[i].value; 402 if (!isNaN(value) && value.length > 0) { 403 total += parseInt(value); 404 } 405 if (i == (j - 1)) { 406 var totalField = document.getElementById("ConstantSumTotalValue" + name); 407 if (totalField != null) { 408 totalField.value = total; 409 } 410 } 411 } 412}; 413 414// for image control 415 416function createInputElement(label, size, message, messageForAttachmentLimit) { 417 var inputElement = document.createElement("input"); 418 inputElement.setAttribute("type", "file"); 419 inputElement.setAttribute("accept", "image/*"); 420 inputElement.setAttribute("aria-label", label); 421 inputElement.setAttribute("id", label); 422 inputElement.setAttribute("onchange", "imageLoad(this,'" + messageForAttachmentLimit + "', '" + size + "', '" + message + "')"); 423 return inputElement; 424 425} 426 427function imageSuccessMessage(message) { 428 var para = document.createElement("p"); 429 para.setAttribute("role", "alert"); 430 para.setAttribute("style", "font-size: 0; margin: 0 0 !important"); 431 para.setAttribute("tabindex","0"); 432 para.setAttribute("aria-label", message); 433 return para; 434} 435 436function deleteImage(element, label) { 437 var parent = element.parentNode; 438 var grandParent = parent.parentNode; 439 var grandGrandParent = grandParent.parentNode; 440 element.setAttribute("style", "display:none"); 441 var divForImage = grandParent.firstChild; 442 divForImage.setAttribute("style", "display:none"); 443 divForImage.firstChild.setAttribute("href", ""); 444 divForImage.firstChild.firstChild.setAttribute("src", ""); 445 var hidden = document.getElementById(label + "hidden"); 446 hidden.setAttribute("value", ""); 447 var hiddenForImageSize = document.getElementById(label + "hidden_image_size"); 448 var hiddenForImageChange = document.getElementById(label + "hidden_image_change"); 449 hiddenForImageChange.value = "true"; 450 if (hiddenForImageSize.value != null && hiddenForImageSize.value != "") { 451 window.sizeOfFiles -= parseInt(hiddenForImageSize.value); 452 } 453 var elementForZeroFile = document.createElement("input"); 454 elementForZeroFile.setAttribute("type", "file"); 455 456 // for show message after delete image. 457 var imageSuccessMessageParaForDelete = imageSuccessMessage(window.ResourceManager['Image_Deleted_Successfully']);
458 grandGrandParent.appendChild(imageSuccessMessageParaForDelete); 459 460 461 var inputElement = grandGrandParent.firstChild.firstChild; 462 inputElement.files = elementForZeroFile.files; 463 inputElement.nextSibling.removeAttribute("style"); 464}; 465function renderInlineImage(element, id, imageData, size, message, messageForAttachmentLimit) { 466 467 var parent = element.parentNode; 468 var divForImageDelete = parent.nextSibling; 469 var divForImage = divForImageDelete.firstChild; 470 divForImage.setAttribute("class", "image-inline"); 471 divForImage.removeAttribute("style"); 472 var imageElement = divForImage.firstChild.firstChild; 473 imageElement.setAttribute("src", imageData); 474 var divForDelete = divForImage.nextSibling; 475 476 var buttonForDelete = divForDelete.firstChild; 477 buttonForDelete.removeAttribute("style"); 478 479 // for show success message after upload image. 480 var imageSuccessMessageParaForUpload = imageSuccessMessage(window.ResourceManager['Image_Uploaded_Successfully']); 481 divForImage.appendChild(imageSuccessMessageParaForUpload); 482 483 var uploadingDiv = divForImageDelete.nextSibling; 484 var grandparent = parent.parentNode; 485 grandparent.removeChild(uploadingDiv); 486 var hidden = document.getElementById(id + "hidden"); 487 var imageValue = imageData.substr(imageData.indexOf(',') + 1); 488 hidden.setAttribute("value", imageValue); 489}; 490function renderErrorMessage(element, id, size, showMessage, message, messageForAttachmentLimit) { 491 var elementForZeroFile = document.createElement("input"); 492 elementForZeroFile.setAttribute("type", "file"); 493 element.files = elementForZeroFile.files; 494 var parent = element.parentNode; 495 var grandparent = parent.parentNode; 496 var divForImageDelete = parent.nextSibling; 497 var divForInputFile = element.nextSibling; 498 divForInputFile.removeAttribute("style"); 499 500 var hidden = document.getElementById(id + "hidden"); 501 hidden.setAttribute("value", ""); 502 503 var divForErrorMessage = document.createElement("div"); 504 divForErrorMessage.setAttribute("class", "error_message"); 505 var elementForError = document.createElement("p"); 506 elementForError.setAttribute("class", "validator-text"); 507 elementForError.innerText = showMessage; 508 divForErrorMessage.appendChild(elementForError); 509 510 var uploadingDiv = divForImageDelete.nextSibling; 511 grandparent.removeChild(uploadingDiv); 512 grandparent.insertBefore(divForErrorMessage, hidden); 513}; 514 515function renderUploadingMessage(element) { 516 var parent = element.parentNode; 517 var grandParent = parent.parentNode; 518 var id = element.getAttribute("id"); 519 var hidden = document.getElementById(id + "hidden"); 520 var uploadingDiv = document.createElement("div"); 521 uploadingDiv.innerText = "Uploading..."; 522 523 grandParent.insertBefore(uploadingDiv, hidden); 524 var elementForDivInput = element.nextSibling; 525 elementForDivInput.setAttribute("style", "display:none"); 526}; 527 528function chooseImage(element, id) { 529 var elementForInputImage = document.getElementById(id); 530 elementForInputImage.click(); 531} 532function imageLoad(element, maxSizeInMB, size) { 533 var id = element.getAttribute("id"); 534 var hidden = document.getElementById(id + "hidden"); 535 var hiddenForImageSize = document.getElementById(id + "hidden_image_size"); 536 var hiddenForImageChange = document.getElementById(id + "hidden_image_change"); 537 var errorElement = element.parentElement.parentElement.getElementsByClassName("error_message"); 538 var messageForAttachmentLimit = window.ResourceManager['Max_Attachment_Limit_Exceeded']; 539 var message = window.ResourceManager['MaxSize_Image_Exceeded']; 540 message = message.replace("{0}", maxSizeInMB); 541 542 if (errorElement.length > 0) { 543 errorElement[0].parentNode.removeChild(errorElement[0]); 544 } 545 renderUploadingMessage(element); 546 var file = element.files; 547 var imageValue = ""; 548 if (file) { 549 var fileReader = new FileReader(); 550 551 if (fileReader && file && file.length) { 552 if (file[0].size > parseInt(size)) { 553 renderErrorMessage(element, id, size, message, message, messageForAttachmentLimit); 554 } 555 else if (window.sizeOfFiles + file[0].size > window.maxAllowedRequestSize) { 556 renderErrorMessage(element, id, size, messageForAttachmentLimit, message, messageForAttachmentLimit); 557 } 558 else {
559 fileReader.readAsDataURL(file[0]); 560 561 fileReader.onload = function () { 562 hiddenForImageChange.value = "true"; 563 hiddenForImageSize.value = file[0].size; 564 window.sizeOfFiles += file[0].size; 565 var imageData = fileReader.result; 566 imageValue = imageData.substr(imageData.indexOf(',') + 1); 567 hidden.setAttribute("value", imageValue); 568 renderInlineImage(element, id, imageData, size, message, messageForAttachmentLimit); 569 }; 570 } 571 } 572 } 573}; 574 575// for file control 576 577function renderSizeLimitVoilatedMessage(element, id, message) { 578 var parent = element.parentNode; 579 var grandParent = parent.parentNode; 580 var hiddenForFileName = document.getElementById(id + "hidden_filename"); 581 var divForErrorMessage = document.createElement("div"); 582 divForErrorMessage.setAttribute("class", "error_message"); 583 var elementForError = document.createElement("p"); 584 elementForError.setAttribute("role", "alert"); 585 elementForError.setAttribute("class", "validator-text"); 586 elementForError.innerText = message; 587 element.value = null; 588 divForErrorMessage.appendChild(elementForError); 589 grandParent.parentNode.parentNode.insertBefore(divForErrorMessage, hiddenForFileName); 590}; 591 592function fileLoad(element, id, size, maxSizeInMB) { 593 var hiddenForFileName = document.getElementById(id + "hidden_filename"); 594 var hiddenForFileType = document.getElementById(id + "hidden_filetype"); 595 var hiddenForFileChanged = document.getElementById(id + "hidden_file_change"); 596 var elementForInputButton = document.getElementById(id); 597 var elementForFileSize = document.getElementById(id + "hidden_file_size"); 598 var elementForFileName = document.getElementById(id + "_file_name"); 599 var elementForDelete = document.getElementById(id + "_delete_button"); 600 var messageForFileAttachmentLimit = window.ResourceManager['Max_Attachment_Limit_Exceeded']; 601 var messageForNoFile = window.ResourceManager['Text_For_No_File']; 602 var messageForChooseFile = window.ResourceManager['Text_For_Choose_File']; 603 var messageForChangeFile = window.ResourceManager['Text_For_Change_File']; 604 var messageForUpperLimit = window.ResourceManager['MaxSize_File_Error'].replace("{0}", maxSizeInMB); 605 var messageForLowerLimit = window.ResourceManager['MinSize_File_Error']; 606 var errorElement = element.parentElement.parentElement.parentElement.parentElement.getElementsByClassName("error_message"); 607 if (errorElement.length > 0) { 608 errorElement[0].parentNode.removeChild(errorElement[0]); 609 } 610 var file = element.files; 611 if (file) { 612 var fileReader = new FileReader(); 613 614 if (fileReader && file && file.length) { 615 var earlierFileSize = 0; 616 if (elementForFileSize.value != null && elementForFileSize.value != "") { 617 earlierFileSize = parseInt(elementForFileSize.value); 618 } 619 620 if (file[0].size == 0) { 621 renderSizeLimitVoilatedMessage(element, id, messageForLowerLimit); 622 deleteFile(elementForDelete, id, messageForNoFile, messageForChooseFile); 623 } 624 else if (file[0].size > parseInt(size)) { 625 renderSizeLimitVoilatedMessage(element, id, messageForUpperLimit); 626 deleteFile(elementForDelete, id, messageForNoFile, messageForChooseFile); 627 } 628 else if ((window.sizeOfFiles + file[0].size - earlierFileSize) > window.maxAllowedRequestSize) { 629 renderSizeLimitVoilatedMessage(element, id, messageForFileAttachmentLimit); 630 deleteFile(elementForDelete, id, messageForNoFile, messageForChooseFile); 631 } 632 else { 633 window.sizeOfFiles -= earlierFileSize; 634 window.sizeOfFiles += file[0].size; 635 elementForFileSize.value = file[0].size; 636 elementForInputButton.innerText = messageForChangeFile; 637 elementForInputButton.ariaLabel = messageForChangeFile; 638 elementForFileName.innerText = file[0].name; 639 hiddenForFileName.setAttribute("value", file[0].name); 640 hiddenForFileType.setAttribute("value", file[0].type); 641 hiddenForFileChanged.setAttribute("value", "upload"); 642 elementForFileName.parentElement.setAttribute("style", "display:none"); 643 elementForFileName.parentNode.parentNode.lastChild.innerText = file[0].name; 644 elementForFileName.parentNode.parentNode.lastChild.removeAttribute("style"); 645 elementForDelete.removeAttribute("style"); 646 } 647 } 648 } 649}; 650 651function chooseFile(element, id) { 652 var elementForInputFile = document.getElementById(id + "_input_file"); 653 elementForInputFile.click(); 654} 655 656$(document).ready(function () { 657 var elementForFileControl = document.getElementsByClassName("break-file-name"); 658 for (var i = 0, j = elementForFileControl.length; i < j; i++) { 659 var fileName = elementForFileControl[i].firstChild.firstChild.innerText; 660 var elementForHiddenFileName = elementForFileControl[i].parentNode.parentNode.nextSibling; 661 elementForHiddenFileName.value = fileName; 662 var elementForHiddenFileSize = elementForFileControl[i].parentNode.parentNode.parentNode.lastChild; 663 elementForHiddenFileSize.setAttribute("value", ""); 664 } 665 var elementForImageControl = document.getElementsByClassName("image-inline"); 666 for (var i = 0, j = elementForImageControl.length; i < j; i++) { 667 if (elementForImageControl[i].firstChild.href == null || elementForImageControl[i].firstChild.href == "") { 668 elementForImageControl[i].parentNode.nextSibling.setAttribute("value", ""); 669 } 670 elementForImageControl[i].parentNode.nextSibling.nextSibling.setAttribute("value", ""); 671 } 672 673 window.sizeOfFiles = 0; 674 window.maxAllowedRequestSize = 122880000; 675 var elements = document.getElementsByClassName("file-control-container"); 676 for (var i = 0, j = elements.length; i < j; i++) { 677 if (elements[i].clientWidth < 250 && elements[i].clientWidth >= 120) { 678 elements[i].removeAttribute("class"); 679 elements[i].firstChild.nextSibling.setAttribute("class", "container-filelink-delete gap-between-vertical-element"); 680 } 681 else if (elements[i].clientWidth < 120) { 682 elements[i].removeAttribute("class"); 683 elements[i].firstChild.nextSibling.removeAttribute("class"); 684 elements[i].firstChild.nextSibling.firstChild.setAttribute("class", "break-file-name gap-between-vertical-element"); 685 elements[i].firstChild.nextSibling.lastChild.setAttribute("class", "gap-between-vertical-element"); 686 687 } 688 } 689 var elementForImageControl = document.getElementsByClassName("break-image-name"); 690 for (var i = 0, j = elementForImageControl.length; i < j; i++) { 691 if (elementForImageControl[i].parentElement.parentElement.clientWidth >= 250) { 692 693 elementForImageControl[i].parentElement.setAttribute("class", "div-for-image-input"); 694 elementForImageControl[i].parentNode.firstChild.setAttribute("class", "btn btn-default btn-for-image-input btn-for-inputofimage"); 695 elementForImageControl[i].setAttribute("class","break-image-name") 696 } 697 } 698 699}); 700 701function deleteFile(element, id) { 702 var messageForNoFile = window.ResourceManager['Text_For_No_File']; 703 var messageForChooseFile = window.ResourceManager['Text_For_Choose_File']; 704 element.setAttribute("style", "display:none"); 705 var elementForChooseFile = document.getElementById(id); 706 elementForChooseFile.innerText = messageForChooseFile; 707 var spanElementForFile = document.getElementById(id + "_file_name"); 708 var anchorForFile = spanElementForFile.parentElement; 709 anchorForFile.setAttribute("style", "display:none"); 710 var hiddenForFileChanged = document.getElementById(id + "hidden_file_change"); 711 hiddenForFileChanged.setAttribute("value", "delete"); 712 var elementForNoFile = spanElementForFile.parentNode.parentNode.lastChild; 713 elementForNoFile.removeAttribute("style"); 714 elementForNoFile.innerText = messageForNoFile; 715 var elementForZeroFile = document.createElement("input"); 716 elementForZeroFile.setAttribute("type", "file"); 717 var elementForFileInput = document.getElementById(id + "_input_file"); 718 elementForFileInput.setAttribute("value", ""); 719 elementForFileInput.files = elementForZeroFile.files; 720 var hiddenForFileName = document.getElementById(id + "hidden_filename"); 721 hiddenForFileName.setAttribute("value", ""); 722 var hiddenForFileType = document.getElementById(id + "hidden_filetype"); 723 hiddenForFileType.setAttribute("value", ""); 724 var elementForFileSize = document.getElementById(id + "hidden_file_size"); 725 if (elementForFileSize.value != null && elementForFileSize.value != "") { 726 window.sizeOfFiles -= parseInt(elementForFileSize.value); 727 elementForFileSize.setAttribute("value", ""); 728 } 729 //for success message after delete file. 730 var para = document.createElement("span"); 731 para.setAttribute("role", "alert"); 732 para.setAttribute("style", "font-size: 0"); 733 para.setAttribute("aria-label", window.ResourceManager['File_Deleted_Successfully']);
734 elementForChooseFile.appendChild(para); 735 736 // for set focus on choose file button after delete file. 737 $(".btn-for-file-input").attr("tabindex", 0); 738 setFocus(elementForChooseFile.id); 739}; 740 741// Adds class name "dirty" 742function setIsDirty(id) { 743 if (!id) { 744 return; 745 } 746 var className = "dirty"; 747 var element = document.getElementById(id); 748 if (element == null) { 749 return; 750 } 751 if (!element.className.match(new RegExp('(\\s|^)' + className + '(\\s|$)'))) { 752 element.className += " " + className; 753 } 754 if ($("#" + id).attr("aria-invalid") != undefined) { 755 validateRequiredField(id); 756 } 757}; 758 759// Returns true if is dirty (i.e. an input has a class name 'dirty'. Otherwise returns false. 760function isDirty() { 761 var elements = document.getElementsByClassName("dirty"); 762 if (elements.length > 0) { 763 return true; 764 } else { 765 return false; 766 } 767}; 768 769function clearIsDirty() { 770 var elements = document.getElementsByClassName("dirty"); 771 for (var i = 0, j = elements.length; i < j; i++) { 772 var className = "dirty"; 773 var reg = new RegExp('(\\s|^)' + className + '(\\s|$)'); 774 elements[i].className = elements[i].className.replace(reg, ''); 775 } 776} 777 778window.onbeforeunload = confirmExit; 779 780function confirmExit() { 781 var confirm = false; 782 var confirmOnExit = document.getElementById("confirmOnExit"); 783 if (confirmOnExit != null) { 784 if (confirmOnExit.value != null) { 785 if (confirmOnExit.value == 'true') { 786 confirm = true; 787 } 788 } 789 } 790 if (confirm) { 791 // check to see if any changes to the data entry fields have been made 792 if (isDirty()) { 793 var message = window.ResourceManager['Click_Stay_To_Save_Your_Changes']; 794 var element = document.getElementById("confirmOnExitMessage"); 795 if (element != null) { 796 if (element.value != null && element.value != '') { 797 message = element.value; 798 } 799 } 800 return message; 801 } 802 // no changes - return nothing 803 } 804}; 805 806 807if (window.jQuery) { 808 (function ($) { 809 if (typeof (Page_ClientValidate) != 'undefined') { 810 var originalValidationFunction = Page_ClientValidate; 811 if (originalValidationFunction && typeof (originalValidationFunction) == "function") { 812 Page_ClientValidate = function () { 813 originalValidationFunction.apply(this, arguments); 814 if (typeof (Page_IsValid) != 'undefined' && !Page_IsValid) { 815 var validationSummary = $(".validation-summary"); 816 if (validationSummary != null && validationSummary != undefined) { 817 var validationheader = $(".validation-header"); 818 // Use aria-live so screen readers announce the validation summary on load 819 validationSummary.attr({'aria-live': 'assertive', 'aria-atomic': 'true'}); 820 // Prevent duplicate announcements from header 821 validationheader.attr("role", 'presentation'); 822 validationSummary.find("ul").attr("role", "list"); 823 validationSummary.find("ul li").attr("role", "listitem"); 824 // To add aria-invalid attribute for form input required fields on submit/update 825 validationSummary.find("ul li a").each( 826 function () { 827 var id = $(this).attr("referenceControlId"); 828 if (id && ($("#" + id).is("input") || $("#" + id).is("textarea") || $("#" + id).is("select"))) { 829 validateRequiredField(id); 830 } 831 });
832 return false; 833 } 834 } 835 return true; 836 }; 837 } 838 } 839 }(window.jQuery)); 840} 841 842$(window).bind("load", function () { 843 if (portal) { 844 portal.setValidationSummaryFocus(); 845 } 846});
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.