PageSourceSearch

https://www.vspoptics.com/.resources/base-site21/webresources/js/d…ased-modal~2026-06-10-14-54-06-629~cache.js

js vspoptics.com collected 2026-10-10 00:57:10 UTC 17,063 bytes, 364 lines download raw bytes

1
2function sameHeightColumns(element) {
3    var elementHeight = element.eq(0).innerHeight();
4    //log("at load = " + elementHeight);
5    $.each(element, function(index, value) {
6        // log(index + ": " + $(this).innerHeight());
7        // log("element html = " + $(this).html() );
8        $(this).innerHeight() > elementHeight ? elementHeight = $(this).innerHeight() : '';
9    });
10    //log("elementHeight = " +elementHeight);
11    element.innerHeight(elementHeight);
12    /*** set elementHeight back to 0 for calls within the same page ***/
13    elementHeight = 0;
14};
15
16function buildLink( linkType, linkPathIdentifier )
17{
18    var linkArray = [];
19
20    console.log("linkType: " + linkType);
21    console.log("linkPathIdentifier: " + linkPathIdentifier);
22
23    if ( linkType == "RSlinkPage" || linkType == "imageRSlinkPage" )
24    {
25        linkArray = linkPathIdentifier.split("/");
26        console.log("linkArray for page link:");
27        console.log(linkArray);
28        var linkArrayJoined = linkArray.slice(3).join('/');
29        console.log(linkArrayJoined);
30        return linkArrayJoined + ".html";
31
32    }
33    else if ( linkType == "RSlinkAsset" || linkType =="imageRSlinkAsset")
34    {
35
36        console.log("UUID for Asset link:");
37        console.log(linkPathIdentifier);
38        return "/dam/" + linkPathIdentifier;
39    }
40    else if ( linkType == "imageRSlinkExternal" )
41    {
42
43        console.log("UUID for Asset link:");
44        console.log(linkPathIdentifier);
45        return linkPathIdentifier;
46    }
47}
48
49function getModal( modalAppRecord )
50{
51    var modalResults = "";
52    var modalSettings = {
53      "async": true,
54      "crossDomain": true,
55      "url": modalHostResource + "/.rest/delivery/modals" + modalAppRecord + "?orderBy=name asc",
56      "method": "GET",
57      "dataType": "json",
58      "statusCode": {
59          404: function (data, textStatus, jqXHR) { // success
60              console.log("NO CONTENT APP RECORD");
61              console.log(textStatus);
62              console.dir(jqXHR);
63              $('.reveal').removeAttr( "data-reveal" );
64              $('.modalContainer').html('<div class="modalError">No content app record was found. If a modal is needed, please configure a modal and assign it to this page.</div>');
65          }
66      }
67    }
68
69    var modalJSON = $.ajax(modalSettings);
70    var modalParsedRecord = [];
71    var startDate="";
72    var endDate="";
73    var pageURLPath="";
74    var currentDate = new Date();
75
76    modalJSON.done(function(data) {
77        modalJSONResults = data;
78
79        console.log("MODAL CALL RESULTS:");
80        console.dir(modalJSONResults);
81
82        if (Object.hasOwn(modalJSONResults, 'results') == true)
83        {
84            console.log("JSON LENGTH in IF:");
85            console.log(modalJSONResults.results.length);
86
87            /*** loop thru all modals found for this site ***/
88            for (let i = 0; i < modalJSONResults.results.length; i++) {
89              modalJSONResults.results[i].startDate ? startDate=modalJSONResults.results[i].startDate : '';
90              modalJSONResults.results[i].endDate ? endDate=modalJSONResults.results[i].endDate : '';
91              var pageURLPath = '';
92              var childPageCheck = "false";
93              var pageURLNodes = modalJSONResults.results[i]["pageURL"]["@nodes"];
94
95              console.log("modal node:");
96              console.dir(modalJSONResults.results[i]);
97
98                /*** must loop thru the pageURl node to cover all page assignments ***/
99                if (typeof pageURLNodes !== 'undefined' && pageURLNodes.length > 0)
100                {
101                    for (let j = 0; j < pageURLNodes.length; j++) {
102
103                      var pageURLNodeName = modalJSONResults.results[i]["pageURL"]["@nodes"][j];
104
105                      console.log("pageURLNodeName check:");
106                      console.log( pageURLNodeName );
107
108                      console.log("includeOnChildPages check:");
109                      console.log( modalJSONResults.results[i]["pageURL"][pageURLNodeName].includeOnChildPages );
110
111                      console.log("pageURL array - " + j + ":");
112                      console.log( modalJSONResults.results[i]["pageURL"][pageURLNodeName].urlPath );
113
114                      console.log("currentPageID: " + currentPageID);
115
116                      console.log("Current Date = " + currentDate);
117
118                      console.log("Start Date:");
119                      console.dir( startDate );
120
121                      console.log("End Date:");
122                      console.dir( endDate );
123                      
124                      var startDate2 = new Date( startDate );
125                      console.log("startDate2:");
126                      console.log(startDate2);
127
128                      var endDate2 = new Date( endDate );
129                      console.log("endDate2:");
130                      console.log(endDate2);
131
132                          /*** retained assigned page UUID value ***/
133                          pageURLPath=modalJSONResults.results[i]["pageURL"][pageURLNodeName].urlPath;
134                          childPageCheck = modalJSONResults.results[i]["pageURL"][pageURLNodeName].includeOnChildPages;
135
136                            console.log("Dates:");
137                            console.log( startDate2 );
138                            console.log( endDate2 );
139                            console.log( currentDate );
140
141                          /*** check current page UUID and start date is after end date ***/
142                          if ( ( pageURLPath != '' && currentPageID == pageURLPath && startDate2 > endDate2 ) )
143                          {
144                              modalParsedRecord.push(modalJSONResults.results[i]);
145                          }
146                          /*** check current page UUID and current date is in date range ***/
147                          else if ( ( pageURLPath != '' && currentPageID == pageURLPath && currentDate >= startDate2 && currentDate <= endDate2 ) )
148                          {
149                              modalParsedRecord.push(modalJSONResults.results[i]);
150                          }
151                          /*** check current page UUID and no date range so ALWAYS load this modal on assigned page ***/
152                          else if ( ( pageURLPath != '' && currentPageID == pageURLPath && startDate == '' && endDate == '' ) )
153                          {
154                              modalParsedRecord.push(modalJSONResults.results[i]);
155                          }
156                          /*** check for child page display ***/
157                          else if ( childPageCheck == true )
158                          {
159                              /*** compare assigned page UUID to parent UUID and check if start date comes after end date ***/
160                              if ( ( pageURLPath != '' && parentPageID == pageURLPath && startDate2 > endDate2 ) )
161                              {
162                                  modalParsedRecord.push(modalJSONResults.results[i]);
163                              }
164                              /*** check ancestor array for matching uuid value - if true include modal in modalParsedRecord - check if start date is after end date ***/
165                              else if ( pageURLPath != '' && ancestorPageID.includes(pageURLPath) && startDate2 > endDate2 )
166                              {
167                                  modalParsedRecord.push(modalJSONResults.results[i]);
168                              }
169                              /*** compare assigned page UUID to parent UUID if child checkbox is true ***/
170                              else if ( pageURLPath != '' && parentPageID == pageURLPath && currentDate >= startDate2 && currentDate <= endDate2 )
171                              {
172                                  modalParsedRecord.push(modalJSONResults.results[i]);
173                              }
174                              /*** check ancestor array for matching uuid value - if true include modal in modalParsedRecord ***/
175                              else if ( pageURLPath != '' && ancestorPageID.includes(pageURLPath) && currentDate >= startDate2 && currentDate <= endDate2 )
176                              {
177                                  modalParsedRecord.push(modalJSONResults.results[i]);
178                              }
179                              /*** check ancestor array for matching uuid value - if no start or end date always include ***/
180                              else if ( pageURLPath != '' && ancestorPageID.includes(pageURLPath) && startDate == '' && endDate == '' )
181                              {
182                                  modalParsedRecord.push(modalJSONResults.results[i]);
183                              }
184                              else {
185                                console.log("NO CHILD MODALS IN DATE RANGE");
186                              }
187                          }
188                          else {
189                            console.log("NO MODAL IN DATE RANGE");
190                          }
191                          console.log("Current Modal Array");
192                          console.dir( modalParsedRecord );
193                    }
194                    startDate = '';
195                    endDate = '';
196                }
197
198            }
199
200            console.log("Parsed Modal Record NEW:");
201            console.dir( modalParsedRecord );
202
203            console.log("Parsed Modal Record Length:");
204            console.dir( modalParsedRecord.length );
205
206            if ( modalParsedRecord.length == 1 && ( modalParsedRecord[0].startDate > modalParsedRecord[0].endDate ) )
207            {
208                $('.reveal').removeAttr( "data-reveal" );
209                $('.modalContainer').html("<div class='modalError'>
209A Modal was found for this page, but the Start Date occurs after the End Date. Please check the content app to fix the date chronology.</div>");
210            }
211            else if ( modalParsedRecord.length == 1)
212            {
213                // console.log("Modal Template:");
214                // console.log( modalParsedRecord[0].modalTemplate );
215
216                if ( modalParsedRecord[0].modalTemplate == "basicModal")
217                {
218                    modalTemplateSource = $("#basic-modal-template").html();
219                }
220                else if ( modalParsedRecord[0].modalTemplate == "mediaModal" && modalParsedRecord[0].modalAsset == "modalAssetImage")
221                {
222                    modalTemplateSource = $("#image-template").html();
223                }
224                else if ( modalParsedRecord[0].modalTemplate == "mediaModal" && modalParsedRecord[0].modalAsset == "modalAssetVideo" && modalParsedRecord[0].selectVideoSource == "youtube")
225                {
226                    modalTemplateSource = $("#youtube-video-template").html();
227                }
228                else if ( modalParsedRecord[0].modalTemplate == "mediaModal" && modalParsedRecord[0].modalAsset == "modalAssetVideo" && modalParsedRecord[0].selectVideoSource == "vimeo")
229                {
230                    modalTemplateSource = $("#vimeo-video-template").html();
231                }
232                else if ( modalParsedRecord[0].modalTemplate == "mediaModal" && modalParsedRecord[0].modalAsset == "modalAssetVideo" && modalParsedRecord[0].selectVideoSource == "linkExternal")
233                {
234                    modalTemplateSource = $("#external-video-template").html();
235                }
236                else if ( modalParsedRecord[0].modalTemplate == "columnModal" )
237                {
238                    modalTemplateSource = $("#blockgrid-modal-template").html();
239                }
240
241                // console.log("modalTemplateSource:");
242                // console.log( modalTemplateSource );
243
244                if ( modalParsedRecord[0].modalTemplate &&  modalTemplateSource != "")
245                {
246                    $('.modalTitle').html( modalParsedRecord[0].modalTitle );
247                    $('.reveal').attr( 'id', modalParsedRecord[0].modalId );
248                    $('.reveal').addClass( modalParsedRecord[0].modalSize );
249
250                    if( modalParsedRecord[0].modalTemplate == "columnModal" )
251                    {
252                        delete modalParsedRecord[0]['columnContent']['@id'];
253                        delete modalParsedRecord[0]['columnContent']['@name'];
254                        delete modalParsedRecord[0]['columnContent']['@nodeType'];
255                        delete modalParsedRecord[0]['columnContent']['@nodes'];
256                        delete modalParsedRecord[0]['columnContent']['@path'];
257
258                        console.log("Parsed Modal Record remove id:");
259                        console.dir( modalParsedRecord );
260                    }
261                    // else
262                    // {
263                    //     var modalTemplate = Handlebars.compile(modalTemplateSource);
264                    //     var modalContentResult = modalTemplate(modalParsedRecord[0].columnContent);
265                    // }
266
267                    var modalTemplate = Handlebars.compile(modalTemplateSource);
268                    var modalContentResult = modalTemplate(modalParsedRecord[0]);
269                    $('.modalContainer').html(modalContentResult);
270
271                    var videoSrc = $('.videoComponent iframe').attr('src');
272                    $('.videoComponent iframe').attr('src', videoSrc);
273
274                    $('.dynamicControlModal').on('closed.zf.reveal', function() {
275                        /*** silence modal after close by reseting the iframe src ***/
276                        var videoSrc = $('.videoComponent iframe').attr('src');
277                        $('.videoComponent iframe').attr('src', videoSrc);
278
279                        if ( $('#noShow').is(":checked") )
280                        {
281                            sessionStorage.setItem("noShowModal", "true");
282                        }
283                        else
284                        {
285                            sessionStorage.removeItem("noShowModal");
286                        }
287                    });
288
289                    console.log("here in modal compile - " + modalID)
290
291                    /*** do not display modal if anchor is present in URL ***/
292                    if (!window.location.hash) {
293                        $('.reveal').foundation('open');
294                    }
295
296                }
297                else {
298                    $('.modalContainer').html("Please configure modal assets.");
299                }
300
301            }
302            else if ( modalParsedRecord.length == 0)
303            {
304                $('.reveal').removeAttr( "data-reveal" );
305                $('.modalContainer').html("<div class='modalError'>No modal entry was found for this page and today's date. If using Dynamic Modals, please check content app page and date settings.</div>");
306            }
307            else
308            {
309                $('.reveal').removeAttr( "data-reveal" );
310                $('.modalContainer').html('<div class="modalError">More than one modal is configured for this page - ONLY one dynamic modal can be configured for the same page and date. Please use the list below to re-configure your modal setup in the Modals content app.</div>');
311                $('.modalContainer').append('<br /><ul class="modalError"></ul>');
312
313                for (let a = 0; a < modalParsedRecord.length; a++)
314                {
315                    $('.modalContainer ul').append("<li>" + modalParsedRecord[a].modalTitle + " - " + modalParsedRecord[a]['@path'] + "</li>")
316                }
317            }
318        }
319        else
320        {
321          console.log("NO CONTENT APP RECORD");
322          $('.reveal').removeAttr( "data-reveal" );
323          $('.modalContainer').html('<div class="modalError">No content app record was found. Please configure a modal and assign it to this page.</div>');
324        }
325
326    });
327
328};
329
330$(function()
331{
332    /*** check to see modal check should be run ***/
333    if ( sessionStorage.getItem("noShowModal") == null || sessionStorage.getItem("noShowModal") == false )
334    {
335        /*** don't run unless modalSource folder assigned ***/
336        if (typeof modalSource != "undefined")
337        {
338            getModal( modalSource );
339        }
340    }
341
342    $('.dynamicControlModal').on('open.zf.reveal', function()
343    {
344        if( $(".reveal.modal .modalContainer .row").hasClass('modal-block-grid')  )
345        {
346            var columnTitles = $(".reveal.modal .modalContainer .paragraphTitle");
347            var columnParagraph = $(".reveal.modal .modalContainer .row .paragraphCopy");
348            var columnLinkContainer = $(".reveal.modal .modalContainer .row .linkContainer");
349
350            console.log("Here in column check");
351            console.log(columnTitles.length);
352
353            console.log( columnTitles.eq(0).html() );
354            console.log( columnTitles.eq(0).height() );
355
356
357            sameHeightColumns(columnTitles);
358            sameHeightColumns(columnParagraph);
359            sameHeightColumns(columnLinkContainer);
360        }
361
362    });
363
364});

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.