1"use strict"; 2 3var onOutsideClickFunctions = {}; 4 5window.blazoredTypeahead = { 6 assemblyname: "Blazored.Typeahead", 7 setFocus: function (element) { 8 if (element && element.focus) element.focus(); 9 }, 10 // No need to remove the event listeners later, the browser will clean this up automagically. 11 addKeyDownEventListener: function (element) { 12 if (element) { 13 element.addEventListener('keydown', function (event) { 14 var key = event.key; 15 16 if (key === "Enter") { 17 event.preventDefault(); 18 } 19 }); 20 } 21 }, 22 onOutsideClickClear: function (element) { 23 24 if (element == null) { 25 return; 26 } 27 28 var bId = ""; 29 for (var clearCount = 0; clearCount < element.attributes.length; clearCount++) { 30 var a = element.attributes[clearCount]; 31 if (a.name.startsWith('_bl_')) { 32 bId = a.name; 33 break; 34 } 35 } 36 37 var func = onOutsideClickFunctions[bId]; 38 if (func == null || func == "undefined") { 39 return; 40 } 41 window.removeEventListener("click", func); 42 onOutsideClickFunctions[bId] = null; 43 }, 44 onOutsideClick: function (searchTextElement, dotnetRef, methodName, clearOnFire) { 45 46 if (searchTextElement == null) { 47 return; 48 } 49 50 var bId = "";//get the blazor internal ID to distinguish different components 51 for (var clearCount = 0; clearCount < searchTextElement.attributes.length; clearCount++) { 52 var a = searchTextElement.attributes[clearCount]; 53 if (a.name.startsWith('_bl_')) { 54 bId = a.name; 55 break; 56 } 57 } 58 59 blazoredTypeahead.onOutsideClickClear(searchTextElement); //clean up just in case 60 61 var func = function(e) { 62 var parent = e.target; 63 while (parent != null) { 64 if (parent.classList != null && parent.classList.contains('blazored-typeahead')) { 65 var hasSearch = parent.contains(searchTextElement); //check if this is the same typeahead parent element 66 if (hasSearch) { 67 return; //we're still in the search so don't fire 68 } 69 } 70 parent = parent.parentNode; 71 } 72 73 dotnetRef.invokeMethodAsync(methodName); 74 if (clearOnFire) { //could also add a check to see if the search element is missing on the DOM to force cleaning up the function? 75 blazoredTypeahead.onOutsideClickClear(searchTextElement); 76 } 77 }; 78 onOutsideClickFunctions[bId] = func; //save a reference to the click function 79 window.addEventListener("click", func); 80 } 81};
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.