1var isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|MSIE 8|IEMobile|Opera Mini/i.test(navigator.userAgent); 2 3function RefreshjQuery() { 4 LoadOnClick(); 5 SubmitOnClick(); 6 SubmitCategories(); 7 CheckFormValid(); 8 HiddenFieldToggles(); 9 UpdateFieldAndSubmit(); 10 InitRegistrationExportMarkets(); 11 ExportMarketsMax(); 12 FormPagination(); 13 //InitUniform(); 14 //SearchFilters(); 15 16 $.validator.unobtrusive.adapters.addBool("mandatory", "required"); 17 if ($.validator != undefined) { 18 $.validator.setDefaults({ 19 ignore: "" 20 }); 21 } 22} 23 24function ShowNotification(message, isError) { 25 var notificationContainer = $('#notificationSuccess'); 26 if (isError == "1") { 27 notificationContainer = $('#notificationError'); 28 } 29 notificationContainer.find('.content').html(message); // add notification content 30 notificationContainer.fadeIn(); // fade notification in 31 notificationContainer.find('.close').click(function (e) { e.preventDefault(); notificationContainer.fadeOut(); }); // close notification 32 setTimeout(function () { notificationContainer.fadeOut() }, 10000); // set a timeout function so notification fades out after 10 seconds 33} 34 35//make a set of elements all the same height 36$.fn.EqualHeight = function () { 37 var group = $(this); 38 var thisHeight; 39 40 tallest = 0; 41 42 group.each(function () { 43 thisHeight = $(this).outerHeight(); 44 45 if (thisHeight > tallest) { 46 tallest = thisHeight; 47 } 48 }); 49 50 if (tallest > 0) { 51 group.height(tallest); 52 } 53}; 54 55function HiddenFieldToggles() { 56 $(".hidden-field-toggle").each(function () { 57 if ($(this).attr("data-toggleadded") != "true") { 58 if ($(this).is("select")) { 59 $(this).change(function (e) { 60 var container = $(this).parents('.form-group').first(); 61 // hide all hidden fields 62 container.find('.hidden-field').hide(); 63 // find matching hidden field 64 var field = container.find('.hidden-field[data-field-value="' + $(this).val() + '"]'); 65 if (field.length > 0) { 66 field.show(); 67 } 68 }); 69 } else { 70 $(this).click(function (e) { 71 e.preventDefault(); 72 var container = $(this).parents('.form-group').first(); 73 var field = container.find('.hidden-field'); 74 if (field.length > 0) { 75 container.find('.hidden-field').slideToggle(); 76 } 77 }); 78 } 79 80 $(this).attr("data-toggleadded", "true"); 81 } 82 }); 83} 84 85/*---rte---*/ 86function RefreshRTE() { 87 $('textarea.rte').each(function () { 88 var editor_id = $(this).attr('id'); 89 tinymce.EditorManager.execCommand('mceRemoveEditor', true, editor_id); 90 tinymce.EditorManager.execCommand('mceAddEditor', true, editor_id); 91 }); 92} 93 94// Returns text statistics for the specified editor by id 95function getStats(id) { 96 var body = tinymce.get(id).getBody(), text = tinymce.trim(body.innerText || body.textContent); 97 98 return { 99 chars: text.length, 100 words: text.split(/[\w\u2019\'-]+/).length 101 }; 102} 103 104function InitRTE() { 105 tinymce.init({ 106 selector: 'textarea.rte', 107 plugins: [ 108 "paste", 109 "links" 110 ], 111 toolbar: 'undo redo | styleselect | bold italic | alignleft aligncenter alignright al
111ignjustify | link | removeformat ', 112 menubar: false, 113 statusbar: false, 114 height: 200, 115 entity_encoding: 'raw', //all characters will be stored in non-entity form except these XML default entities &,<,>,� 116 invalid_elements: 'script', 117 branding: false, 118 content_css: '/css/admin/tinymce.min.css', 119 browser_spellcheck: true, 120 paste_preprocess: function (pl, o) { 121 // strip all tags except <b><u><i><p><span><a><ul><ol><li> 122 o.content = strip_tags(o.content, '<b><u><i><p><span><a><ul><ol><li>'); 123 //console.log(o.content); 124 }, 125 link_context_toolbar: true, 126 default_link_target: "_blank" 127 }); 128 129 //var test = "<p style=\"font-size:20px;background-color:blue;color:white;padding:20px;\"><span>This <em>is</em> a <strong>test</strong> <a href=\"http://www.google.com\">link</a> <a href=\"mailto:[email protected]\">email</a></span></p>"; 130 //console.log("input: " + test); 131 //var test2 = strip_tags(test, '<b><u><i><p><span><a>'); 132 //console.log("output: " + test2); 133} 134 135function FormComplete() { 136 HideLoad(); 137 RefreshjQuery(); 138 RefreshRTE(); 139 if ($('body').hasClass('no-scroll')) { 140 $('body').removeClass('no-scroll'); 141 } 142 143 $('.list-form').submit(); 144} 145 146function HideLoad() { 147 $(".load-on-click").each(function () { 148 $(this).removeClass("load-on-click-loading"); 149 $(this).html($(this).find(".hiddenLoadContent").html()); 150 }); 151} 152 153function LoadReplace(element) { 154 element.wrapInner("<div class=\"hiddenLoadContent\"></div>"); 155 element.html("<i class=\"fa fa-sync fa-spin\"></i>" + element.html()); 156 157 if (!element.hasClass("load-on-click-loading")) { 158 element.addClass("load-on-click-loading"); 159 } 160} 161 162function WrapColumns(columns, columnsPerRow, centerColumns) { 163 var rowClass = centerColumns == "1" ? "row center-columns" : "row"; 164 if (columns.length > columnsPerRow) { 165 for (var i = 0; i < columns.length; i += columnsPerRow) { 166 columns.slice(i, i + columnsPerRow).wrapAll("<div class='" + rowClass + "'></div>"); 167 } 168 } else { 169 columns.wrapAll("<div class='" + rowClass + "'></div>"); 170 } 171} 172 173function LoadOnClick() { 174 $(".load-on-click").each(function () { 175 if ($(this).attr("data-clickadded") != "true") { 176 $(this).click(function (e) { 177 LoadReplace($(this)); 178 }); 179 $(this).attr("data-clickadded", "true"); 180 } 181 }); 182} 183 184function SubmitOnClick() { 185 $(".submit-on-click").each(function () { 186 if ($(this).attr("data-submitclickadded") != "true") { 187 $(this).click(function (e) { 188 e.preventDefault(); 189 var form = $(this).closest('form'); 190 $('textarea.rte').each(function () { 191 var rteId = $(this).attr('id'); 192 var value = tinymce.get(rteId).getContent(); 193 $('#' + rteId.replace("_1", "")).val(value); 194 }); 195 form.submit(); 196 }); 197 $(this).attr("data-submitclickadded", "true"); 198 } 199 }); 200} 201 202function UpdateFieldAndSubmit() { 203 //update field then submit 204 $(".update-field-submit").each(function () { 205 if ($(this).attr("data-submitclickadded") != "true") { 206 $(this).click(function (e) { 207 e.preventDefault(); 208 209 var fieldToUpdate = $(this).attr("data-fieldid"); 210 var valueToUpdate = $(this).attr("data-value"); 211 212 $('#' + fieldToUpdate).val(valueToUpdate); 213 214 var form = $(this).closest('form'); 215 $('textarea.rte').each(function () { 216 var rteId = $(this).attr('id'); 217 var value = tinymce.get(rteId).getContent(); 218 $('#' + rteId.replace("_1", "")).val(value); 219 }); 220 form.submit(); 221 }); 222 223 $(this).attr("data-submitclickadded", "true"); 224 } 225 }); 226} 227 228function CheckFormValid() { 229 $(function () { 230 $('form').addTriggersToJqueryValidate(); 231 $('form').bind('formValidation', function (event, element, result) { 232 //console.log(result); 233 // if form isn't valid then hide spinner 234 if (result == false) {
235 //console.log('form is invalid'); 236 HideLoad(); 237 } 238 }); 239 }) 240} 241 242// Resource Types 243function SearchFilters() { 244 $(".filter-item").each(function () { 245 if ($(this).attr("data-clickadded") != "true") { 246 $(this).click(function (e) { 247 e.preventDefault(); 248 var target = $($(this).data('target-id')); 249 target.val($(this).data('value')); 250 $(this).closest('form').submit(); 251 }); 252 $(this).attr("data-clickadded", "true"); 253 } 254 }); 255} 256 257// Form Pagination 258function FormPagination() { 259 $("form .pagination a").each(function () { 260 if ($(this).attr("data-clickadded") != "true") { 261 $(this).click(function (e) { 262 e.preventDefault(); 263 var form = $(this).closest('form'); 264 form.find('.page-input').val($(this).data('page')); 265 form.submit(); 266 }); 267 $(this).attr("data-clickadded", "true"); 268 } 269 }); 270 $("form .pagination .pagebutton").each(function () { 271 if ($(this).attr("data-changeadded") != "true") { 272 $(this).click(function (e) { 273 e.preventDefault(); 274 var form = $(this).closest('form'); 275 form.find('.page-input').val($(this).attr('data-page')); 276 form.submit(); 277 }); 278 $(this).attr("data-changeadded", "true"); 279 } 280 }); 281} 282 283//function InitUniform() { 284// $("select, :radio, input:file, :checkbox").uniform(); 285//} 286 287// Strips HTML and PHP tags from a string 288// returns 1: 'Kevin <b>van</b> <i>Zonneveld</i>' 289// example 2: strip_tags('<p>Kevin <img src="someimage.png" onmouseover="someFunction()">van <i>Zonneveld</i></p>', '<p>'); 290// returns 2: '<p>Kevin van Zonneveld</p>' 291// example 3: strip_tags("<a href='http://kevin.vanzonneveld.net'>Kevin van Zonneveld</a>", "<a>"); 292// returns 3: '<a href='http://kevin.vanzonneveld.net'>Kevin van Zonneveld</a>' 293// example 4: strip_tags('1 < 5 5 > 1'); 294// returns 4: '1 < 5 5 > 1' 295function strip_tags(str, allowed_tags, remove_attributes) { 296 var key = '', allowed = false; 297 var matches = []; var allowed_array = []; 298 var allowed_tag = ''; 299 var i = 0; 300 var k = ''; 301 var html = ''; 302 var replacer = function (search, replace, str) { 303 return str.split(search).join(replace); 304 }; 305 // Build allowes tags associative array 306 if (allowed_tags) { 307 allowed_array = allowed_tags.match(/([a-zA-Z0-9]+)/gi); 308 } 309 str += ''; 310 311 // Match tags 312 matches = str.match(/(<\/?[\S][^>]*>)/gi); 313 // Go through all HTML tags 314 for (key in matches) { 315 if (isNaN(key)) { 316 // IE7 Hack 317 continue; 318 } 319 320 // Save HTML tag 321 html = matches[key].toString(); 322 323 // Is tag not in allowed list? Remove from str! 324 allowed = false; 325 326 // Go through all allowed tags 327 for (k in allowed_array) { // Init 328 allowed_tag = allowed_array[k]; 329 i = -1; 330 331 if (i != 0) { i = html.toLowerCase().indexOf('<' + allowed_tag + '>'); } 332 if (i != 0) { i = html.toLowerCase().indexOf('<' + allowed_tag + ' '); } 333 if (i != 0) { i = html.toLowerCase().indexOf('</' + allowed_tag); } 334 335 // Determine 336 if (i == 0) { 337 allowed = true; 338 break; 339 } 340 } 341 if (!allowed) { 342 str = replacer(html, "", str); // Custom replace. No regexing 343 } 344 } 345 346 if (remove_attributes) { 347 // removes all attributes on all tags 348 str = str.replace(/<\s*(\w+).*?>/, '<$1>'); 349 } 350 351 return str; 352} 353 354$(document).ready(function () { 355 RefreshjQuery(); 356 357 InitRTE(); 358 359 // udates list of inputs within a form / modal etc. 360 // example - <a href="#" class="update-field" data-toggle="modal" data-target="#ContactFormModal" data-input-id=".contourField.page input,#3891d593-b295-4d2a-c187-19f59e9b5ae0" data-input-value="@Request.Url,@Model.Content.Name">Enquire</a> 361 $('.update-field').click(function (e) { 362 var inputIds = $(this).data('input-id').split(','); 363 var target = $(this).data('target'); 364 for (var i = 0; i < inputIds.length; i++) { 365 var input = $(target + " " + inputIds[i]); 366 var value = $(this).data('input-value').split(',')[i]; 367 if (input.length > 0) { 368 input.val(value); 369 if (input.parents('.selector').length > 0) { 370 input.parents('.selector').find('span').text(value); 371 } 372 } 373 } 374 }); 375 376 // popup bootstrap window 377 if (window.location.hash != "") { 378 if ($(window.location.hash).length > 0) { 379 if ($(window.location.hash).hasClass('modal')) { 380 $(window.location.hash).modal('show'); 381 } 382 } 383 } 384 385 // Wrap columns 386 $('.wrap-columns').each(function () { 387 var columns = $(this).children('div'); 388 var columnsPerRow = $(this).data('columns-desktop'); 389 var centerColumns = $(this).data('center-columns'); 390 if ($(window).width() < 992) { 391 columnsPerRow = $(this).data('columns-tablet'); 392 } 393 if ($(window).width() < 768) { 394 columnsPerRow = $(this).data('columns-mobile'); 395 } 396 WrapColumns(columns, columnsPerRow, centerColumns); 397 }); 398 399 // Mmenu 400 var logo = $('.mobile-logo'); 401 $("#mainNav").mmenu({ 402 navbars: [{ 403 content: [ 404 logo, 405 "close" 406 ] 407 }], 408 "extensions": [ 409 "border-full", 410 "fixed-elements" 411 ] 412 }, {
413 "clone": true 414 }); 415 416 var mmenuAPI = $("#mainNav").data("mmenu"); 417 418 $(window).on("resize", function () { 419 if (window.matchMedia("(min-width: 1200px)").matches) { 420 if ($("#mainNav").length > 0) { 421 mmenuAPI.close(); 422 } 423 } 424 }); 425 426 // Counter 427 if ($('.stat .stat-content span').length > 0) { 428 $('.stat .stat-content span').counterUp({ 429 delay: 10, 430 time: 1000 431 }); 432 } 433 434 // Magnific 435 $('.magnific').magnificPopup({ 436 type: 'image' 437 }); 438 $('.thumbnail-gallery').each(function () { 439 $(this).find('.magnific-gallery').magnificPopup({ 440 type: 'image', 441 gallery: { 442 enabled: true 443 } 444 }); 445 }); 446 $('.magnific-video').magnificPopup({ 447 type: 'iframe' 448 }); 449 $('.magnific-inline').magnificPopup({ 450 type: 'inline' 451 }); 452 $('.close-mfp').click(function () { 453 $.magnificPopup.close(); 454 }); 455 456 // Tooltips 457 $(function () { 458 $('[data-toggle="tooltip"]').tooltip() 459 }) 460 461 // Map section 462 $('.map-section').each(function () { 463 $(this).MapSection(); 464 }); 465 466 // Steps section 467 $('.steps li').click(function () { 468 $('.steps li').removeClass('active'); 469 $('.step-content').hide(); 470 $('.step-content').removeClass('active'); 471 $(this).addClass('active'); 472 $(this).parents('.steps').find($(this).data('id')).show(); 473 $(this).parents('.steps').find($(this).data('id')).addClass('active'); 474 }); 475 476 // Only allow single modal 477 $('.modal').on('show.bs.modal', function (e) { 478 var openModals = $('.modal.in'); 479 var modalToOpen = $(this); 480 var closeTriggered = false; 481 482 if (openModals.length > 0) { 483 e.preventDefault(); 484 485 // hide all open modals 486 openModals.each(function () { 487 $(this).modal('hide'); 488 //$(this).find('.close').trigger('click'); 489 }); 490 491 // when all hidden open this modal 492 openModals.on('hidden.bs.modal', function () { 493 if (!closeTriggered) { 494 modalToOpen.modal('show'); 495 closeTriggered = true; 496 } 497 }); 498 } 499 }); 500}); 501 502$(window).load(function () { 503 // Hero slider 504 $('.hero-slider .slides, .simple-slider .slides').each(function () { 505 $(this).slick({ 506 infinite: true, 507 dots: false, 508 arrows: true, 509 speed: 500, 510 autoplay: true, 511 autoplaySpeed: 6000, 512 accessibility: false 513 }); 514 }); 515 516 // Stepped circles 517 $('#hero .stepped-circles .row').each(function () { 518 $(this).slick({ 519 infinite: true, 520 dots: false, 521 arrows: false, 522 speed: 500, 523 slidesToShow: 3, 524 autoplay: true, 525 autoplaySpeed: 6000, 526 accessibility: false, 527 responsive: [ 528 { 529 breakpoint: 480, 530 settings: { 531 arrows: true, 532 dots: true, 533 slidesToShow: 1, 534 slidesToScroll: 1 535 } 536 } 537 ] 538 }); 539 }); 540 541 // Testimonial Slider 542 $('.single-testimonial-slider .testimonials').each(function () { 543 $(this).slick({ 544 infinite: true, 545 dots: true, 546 arrows: true, 547 speed: 500, 548 slidesToShow: 1, 549 autoplay: true, 550 autoplaySpeed: 6000, 551 accessibility: false 552 }); 553 }); 554 $('.triple-testimonial-slider .testimonials').each(function () { 555 $(this).slick({ 556 infinite: true, 557 dots: true, 558 arrows: true, 559 speed: 500, 560 slidesToShow: 1, 561 autoplay: true, 562 autoplaySpeed: 6000, 563 accessibility: false, 564 mobileFirst: true, 565 responsive: [ 566 { 567 breakpoint: 768, 568 settings: { 569 slidesToShow: 2, 570 slidesToScroll: 2 571 } 572 }, 573 { 574 breakpoint: 1200, 575 settings: { 576 slidesToShow: 3, 577 slidesToScroll: 3 578 } 579 } 580 ] 581 }); 582 }); 583 584 // Case studies slider 585 $('.section-case-studies .case-study-slider').each(function () { 586 $(this).slick({ 587 infinite: true, 588 dots: true, 589 arrows: true, 590 speed: 500, 591 slidesToShow: 1, 592 autoplay: true, 593 autoplaySpeed: 6000, 594 accessibility: false, 595 mobileFirst: true, 596 responsive: [ 597 { 598 breakpoint: 768, 599 settings: { 600 slidesToShow: 2, 601 slidesToScroll: 2 602 } 603 }, 604 { 605 breakpoint: 1200, 606 settings: { 607 slidesToShow: 3, 608 slidesToScroll: 3 609 } 610 } 611 ] 612 }); 613 });
614 615 // Full Width Gallery slider 616 $('.section-full-width-gallery .slides, .section-full-width-case-study .slides').each(function () { 617 $(this).slick({ 618 infinite: true, 619 dots: false, 620 arrows: false, 621 speed: 500, 622 autoplay: true, 623 autoplaySpeed: 6000, 624 accessibility: false 625 }); 626 }); 627 628 // Logo Slider 629 $('.logo-slider').each(function () { 630 $(this).slick({ 631 infinite: true, 632 dots: false, 633 arrows: false, 634 speed: 500, 635 slidesToShow: 3, 636 slidesToScroll: 3, 637 autoplay: true, 638 autoplaySpeed: 3000, 639 accessibility: false, 640 responsive: [ 641 { 642 breakpoint: 720, 643 settings: { 644 slidesToShow: 3, 645 slidesToScroll: 3 646 } 647 }, 648 { 649 breakpoint: 480, 650 settings: { 651 slidesToShow: 1, 652 slidesToScroll: 1 653 } 654 } 655 ] 656 }); 657 }); 658 659 // Masonry 660 $('.grid').masonry({ 661 itemSelector: '.grid-item' 662 }); 663 664 // Equal Height 665 $('.section.resource-list .grid-item').EqualHeight(); 666}); 667 668//function SubmitCategories() { 669// $("#RegistrationCategories .submit-categories").each(function () { 670// if ($(this).attr("data-submitclickadded") !== "true") { 671// $(this).click(function (e) { 672// e.preventDefault(); 673// var form = $(this).closest('form'); 674 675// UpdateRegistrationCategories(); 676 677// $(form).submit(); 678// }); 679// $(this).attr("data-submitclickadded", "true"); 680// } 681// }); 682//} 683 684function SubmitCategories() { 685 $("#RegistrationCategories input[type=checkbox]").each(function () { 686 $(this).click(function (e) { 687 UpdateRegistrationCategories(); 688 }); 689 }); 690} 691 692function UpdateRegistrationCategories() { 693 var productLifeCycleStagesWrapper = document.getElementById("ProductLifeCycleStagesWrapper"); 694 var productLifeCycleStagesHiddenField = document.getElementById("ProductLifeCycleStages"); 695 var supplyChainCategoriesWrapper = document.getElementById("SupplyChainCategoriesWrapper"); 696 var supplyChainCategoriesHiddenField = document.getElementById("SupplyChainCategories"); 697 var innovationCategoriesWrapper = document.getElementById("InnovationCategoriesWrapper"); 698 var innovationCategoriesHiddenField = document.getElementById("InnovationCategories"); 699 700 // Update Product Life Cycle Stages List 701 UpdateRegistrationCategoriesList(productLifeCycleStagesWrapper, productLifeCycleStagesHiddenField); 702 703 // Update Supply Chain Categories List 704 UpdateRegistrationCategoriesList(supplyChainCategoriesWrapper, supplyChainCategoriesHiddenField); 705 706 // Update Innovation Categories List 707 UpdateRegistrationCategoriesList(innovationCategoriesWrapper, innovationCategoriesHiddenField); 708} 709 710function UpdateRegistrationCategoriesList(wrapper, hiddenField) { 711 if (wrapper !== null && wrapper !== undefined) { 712 var categories = $(wrapper).find("input[type=checkbox]:checked"); 713 714 if (categories !== null && categories !== undefined) { 715 var stringList = []; 716 717 $(categories).each(function () { 718 var udi = $(this).val(); 719 720 stringList.push(udi); 721 }); 722 723 if (hiddenField !== null && hiddenField !== undefined) { 724 if (stringList.length > 0) { 725 $(hiddenField).val(stringList); 726 } 727 else { 728 $(hiddenField).val(""); 729 } 730 } 731 } 732 } 733} 734 735function InitRegistrationExportMarkets() { 736 $('.add-export-market').each(function () { 737 738 var form = $(this).closest('form'); 739 var container = $(this).closest('.form-group'); 740 var dropdown = container.find('select'); 741 var selectionlist = container.find('.selected-export-markets'); 742 var input = form.find('#SelectedTopExportMarkets'); 743 744 if ($(this).attr("data-clickadded") != "true") { 745 746 $(this).click(function (e) { 747 e.preventDefault(); 748 749 var dropdownValue = dropdown.val(); 750 751 if (dropdownValue != null && dropdownValue.length > 0 && dropdownValue != "0") { 752 753 var id = dropdown.val(); 754 var text = dropdown.find("option:selected").text(); 755 756 // add to 'selectionlist' 757 selectionlist.append("<a href=\"#\" class=\"remove-export-market\" data-export-market-id=\"" + id + "\">
757" + text + " <i class=\"fa fa-times\"></i></a>"); 758 759 // remove from dropdown 760 dropdown.find("option[value='" + id + "']").remove(); 761 var defaultOption = dropdown.find('option:first'); 762 dropdown.val(defaultOption.val()); 763 dropdown.closest('.selector').find('span').text(defaultOption.text()); 764 765 /* update input */ 766 767 // get current list as array 768 var currentArray = []; 769 770 if (input.val().length > 0) { 771 currentArray = input.val().split(','); 772 } 773 774 // add this item to array 775 currentArray.push(id); 776 777 // convert array to comma separated list 778 var newList = currentArray.join(","); 779 780 // update input 781 input.val(newList); 782 InitRegistrationExportMarkets(); 783 ExportMarketsMax(); 784 } 785 }); 786 $(this).attr("data-clickadded", "true"); 787 } 788 }); 789 790 /*---addCourseCodes---*/ 791 $(".remove-export-market").click(function (e) { 792 793 e.preventDefault(); 794 795 var form = $(this).closest('form'); 796 var container = $(this).closest('.form-group'); 797 var dropdown = container.find('select'); 798 var input = form.find('#SelectedTopExportMarkets'); 799 800 var id = $(this).data('export-market-id'); 801 var text = $(this).text(); 802 803 // remove from 'selectionlist' 804 $(this).remove(); 805 806 // add to dropdown 807 dropdown.append("<option value='" + id + "'>" + text + "</option>"); 808 809 /* sort dropdown alphabetically */ 810 //SortDropdownAlphabetically(dropdown); 811 812 /* update input */ 813 // get current list as array 814 var currentArray = []; 815 var inputVal = $(input).val(); 816 817 if (inputVal) { 818 currentArray = inputVal.split(','); 819 } 820 821 // remove this item from array 822 var newArray = jQuery.grep(currentArray, function (value) { 823 return value != id; 824 }); 825 826 // convert array to comma separated list 827 var newList = newArray.join(","); 828 829 // update input 830 input.val(newList); 831 ExportMarketsMax(); 832 }); 833} 834 835function RefreshCheckboxes() { 836 $(".udi-list").each(function () { 837 var values = $(this).val(); 838 839 if (values.length > 0) { 840 var checkboxes = $('input[type=checkbox]'); 841 842 if (checkboxes !== null && checkboxes !== undefined) { 843 $(checkboxes).each(function () { 844 if (~values.indexOf($(this).val())) { 845 $(this).prop('checked', 'checked'); 846 } 847 }); 848 } 849 } 850 }); 851} 852 853function ExpandCheckboxAccordionItems() { 854 $('.checkbox-accordion').each(function () { 855 var checkedInputs = $(this).find('input[name="ListItem"]:checked'); 856 857 if (checkedInputs) { 858 $(checkedInputs).each(function () { 859 var parents = $(this).parents('.multi-collapse'); 860 861 if (parents) { 862 $(parents).each(function () { 863 $(this).prev('.checkbox-accordion-item').find('a').removeClass('collapsed'); 864 $(this).addClass('collapse show'); 865 }); 866 } 867 }); 868 } 869 }); 870} 871 872var supplyChainDirectoryDropdown = document.getElementById("SupplyChainDirectoryDropdown"); 873 874if ($(supplyChainDirectoryDropdown).length) { 875 var wrapper = document.getElementById("SupplyChainDirectoryDropdownWrapper"); 876 877 $('#SupplyChainDirectoryDropdownButton').on('click', function (e) { 878 e.stopPropagation(); 879 880 $(wrapper).toggleClass("show"); 881 }); 882 883 $(supplyChainDirectoryDropdown).on('click', function (e) { 884 e.stopPropagation(); 885 }); 886 887 $(document).on('click', function (e) { 888 if ($(wrapper).hasClass("show")) { 889 $(wrapper).toggleClass("show"); 890 } 891 });
892} 893 894 895function SupplyChainDirectoryDropdownFilter() { 896 var input, filter, ul, li, a, i; 897 input = document.getElementById("SupplyChainDirectorySearch"); 898 filter = input.value.toUpperCase(); 899 div = document.getElementById("SupplyChainDirectoryDropdown"); 900 a = div.getElementsByTagName("a"); 901 for (i = 0; i < a.length; i++) { 902 txtValue = a[i].textContent || a[i].innerText; 903 if (txtValue.toUpperCase().indexOf(filter) > -1) { 904 a[i].style.display = ""; 905 } else { 906 a[i].style.display = "none"; 907 } 908 } 909 910 if ($('#SupplyChainDirectoryDropdown a:visible').length == 0) { 911 if ($('#SupplyChainDirectoryDropdown #NoMatch').length == 0) { 912 $(div).append("<p id=\"NoMatch\" class=\"pl-3\">No matches</p>"); 913 } 914 } 915 else { 916 $('#SupplyChainDirectoryDropdown #NoMatch').remove(); 917 } 918} 919 920function ExportMarketsMax() { 921 var selectedInputs = $(".selected-export-markets > a"); 922 var max = 5; 923 924 if (selectedInputs.length >= max) { 925 $(".export-markets-dropdown").attr('disabled', 'disabled'); 926 $(".export-markets-dropdown").addClass('disabled'); 927 } 928 else { 929 $(".export-markets-dropdown").removeAttr('disabled', 'disabled'); 930 $(".export-markets-dropdown").removeClass('disabled'); 931 } 932} 933 934// Form Pagination 935function FormPagination() { 936 $("#companies .pager a").each(function () { 937 if ($(this).attr("data-clickadded") != "true") { 938 $(this).click(function (e) { 939 e.preventDefault(); 940 var form = document.getElementById('CompanySearchForm'); 941 $(form).find('.page-input').val($(this).attr('data-page')); 942 $(form).submit(); 943 }); 944 $(this).attr("data-clickadded", "true"); 945 } 946 }); 947}
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.