1_modal = { 2 initalizeModal: function () { 3 // Detects all the relevent modal elements 4 var modal = $("#modal"); 5 var modalLoadingState = modal.find(".modal-loading-state"); 6 var modalBody = modal.find(".modal-body"); 7 var currentCulture = document.documentElement.getAttribute("lang") || "en-GB"; 8 9 // Detects all the modal links on the page 10 var modalLinks = $('[data-toggle="modal"]'); 11 12 // Clicked modal link behaviour 13 modalLinks.click(function (e) { 14 // Disables the default modal click behaviour 15 e.stopPropagation(); 16 17 // Disables the default link behaviour 18 e.preventDefault(); 19 20 var thisModalLink = $(this); 21 22 // Get the ID of the current node 23 const nodeId = thisModalLink.data("node-id"); 24 25 var thisModalLinkStyle = thisModalLink.attr("data-modal"); 26 27 // Create a null varabiel which will be populated within the If / else statement below 28 var thisModalLinkContent = null; 29 30 // Detects the content applied to the modal trigger 31 var thisModalContent = thisModalLink.data("modal-content"); 32 33 // Checks a style has been detected 34 if (thisModalLinkStyle != undefined) { 35 // Adds the style to the modal content 36 modal.addClass(thisModalLinkStyle); 37 } 38 39 if (thisModalLinkStyle == "media") { 40 try { 41 // Make request to ModalSurfaceController.cs 42 $.get( 43 "/umbraco/surface/modalsurface/getnodedata", 44 { nodeId: nodeId }, 45 (data) => { 46 modalBody.html(data); 47 48 // Displays the modal 49 modal.modal("show"); 50 } 51 ); 52 } catch (error) { 53 throw error; 54 } 55 } else if (thisModalLinkStyle === "team") { 56 $.get( 57 "/Umbraco/Surface/ModalSurface/TeamBio", 58 { 59 Id: thisModalLink.attr("data-node-id"), 60 culture: currentCulture // ð send the culture param 61 }, 62 function (data) { 63 // Injects the detected HTML into the modal 64 modalBody.html(data); 65 // Hides the loading state 66 modalLoadingState.addClass("hidden"); 67 } 68 ).fail(function (xhr, textStatus, errorThrown) { 69 // Error callback 70 console.error("AJAX request failed: " + textStatus, errorThrown); 71 }); 72 } 73 else if (thisModalLinkStyle === "brand") { 74 $.get( 75 "/Umbraco/Surface/ModalSurface/GetData?Id=" + 76 thisModalLink.attr("data-node-id"), 77 function (data) { 78 // Injects the detected HTML into the modal 79 modalBody.html(data); 80 // Hides the loading state 81 modalLoadingState.addClass("hidden"); 82 } 83 ); 84 // if a page banner modal 85 } else if (thisModalLinkStyle === "video") { 86 try{ 87 // Detects the href on the clicked modal link 88 var thisModalLinkContent = thisModalLink.attr("href"); 89 90 // Loads the content from the detected href 91 modalBody.load(thisModalLinkContent, function () { 92 // Injects the detected HTML into the modal 93 if(thisModalLinkContent != null) { 94 modalBody.html("<iframe class='videoModal' width='560' height='315' frameborder='0' allowfullscreen src='" + thisModalLinkContent + "?modestbranding=1&autoplay=1&showinfo=0&rel=0'></iframe>"); 95 } else { 96 modalBody.html("<div class='st-4 sb-4 ps-4 pe-4'><p>Sorry there is an issue with viewing the video.<br> Please try again later.</p></div>"); 97 } 98 // Hides the loading state 99 modalLoadingState.addClass("hidden"); 100 }); 101 } catch(error) { 102 throw error; 103 } 104 // if a modal has come from a button in content from the main body 105 } else if (thisModalLinkStyle === "button") { 106 try { 107 $.get( 108 "/Umbraco/Surface/ModalSurface/GetModalData?LinkUrl=" + 109 thisModalLink.attr("href"), 110 function (data) { 111 // Injects the HTML recieved from the template into the modal 112 modalBody.html(data); 113 //checks if the modal contains an iframe with a class of just-see-content 114 if (document.querySelector('.just-see-content')) { 115 // Call the initializeModal function to strip out header, footer, etc 116 _modalGetPageContent.initializeModal(); 117 } 118 // Hides the loading state 119 modalLoadingState.addClass("hidden"); 120 } 121 ); 122 } catch(error) { 123 throw error; 124 } 125 126 } else { 127 try { 128 // Detects the href on the clicked modal link 129 var thisModalLinkContent = thisModalLink.attr("href"); 130 131 // Checks if the href already has an query string parameters 132 thisModalLinkContent += thisModalLinkContent.indexOf("?") > 0 ? thisModalLinkContent += "&modal=1" : thisModalLinkContent += "?modal=1"; 133 134 // Checks if the content has beed defined on the modal trigger 135 if (thisModalContent !== undefined) { 136 // Adds the modal content parameter and value to the href 137 thisModalLinkContent += "&modal-content=" + thisModalContent; 138 } 139 140 // Loads the content from the detected href 141 modalBody.load(thisModalLinkContent, function (response, status, xhr) { 142 // Injects the detected HTML into the modal 143 modalBody.html(thisModalLinkContent != null ? "<div>" + thisModalLinkContent + "</div>" : "<div class='st-4 sb-4 ps-4 pe-4'><p>Sorry there is an issue.<br> Please try again later.</p></div>" ); 144 // Hides the loading state 145 modalLoadingState.addClass("hidden"); 146 }); 147 } catch(error) { 148 throw error; 149 } 150 151 } 152 153 // Displays the modal 154 modal.modal("show"); 155 }); 156 157 // Close modal behaviour 158 modal.on("hidden.bs.modal", function () { 159 // Empties the modal of all previously injetced HTML 160 modalBody.empty(); 161 162 // Remove bespoke classes if applied 163 modal.removeClass("video-embed"); 164 modal.removeClass("team"); 165 166 // Reenables the loading state 167 modalLoadingState.removeClass("hidden"); 168 }); 169 }, 170 }; 171
172 // Initializers 173 $(document).ready(function () { 174 _modal.initalizeModal(); 175 }); 176
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.