PageSourceSearch

https://paviljoendewilgenplas.nl/wp-content/plugins/fooevents_seating/js/seating-frontend.js?ver=1784536838

js paviljoendewilgenplas.nl collected 2026-10-07 00:47:58 UTC 37,462 bytes, 1,157 lines download raw bytes

1(function ($) {
2  jQuery(document).ready(function () {
3    if (jQuery(".fooevents_seating_chart").length) {
4      jQuery(".product").addClass("seating-event");
5    }
6
7    jQuery(".seating-event .qty").hide();
8    jQuery(".theme-Avada .seating-event .quantity").hide();
9    jQuery(".theme-astra .seating-event .quantity").hide();
10
11    /* If this is a product page and a product with variations, only show the Choose Seats button if variations are selected */
12
13    if (typeof variationsToShow !== "undefined") {
14      if (
15        variationsToShow != "none" &&
16        jQuery(".variations_form").length > 0 &&
17        jQuery(".fooevents_seating_chart").length
18      ) {
19        jQuery("a.fooevents_seating_chart").hide();
20        jQuery(".seating-event .qty").show();
21        jQuery(".theme-Avada .seating-event .quantity").show();
22        jQuery(".theme-astra .seating-event .quantity").show();
23        jQuery(".seating-event .single_add_to_cart_button")
24          .prop("disabled", false)
25          .removeClass("disabled");
26      }
27    }
28
29    /* Disable Add to Cart and Select Seats button unless at least one seat is selected */
30    if (
31      jQuery(".seating-event .qty").val() != undefined &&
32      jQuery(".fooevents_seating_chart").length
33    ) {
34      jQuery(".seating-event .single_add_to_cart_button")
35        .prop("disabled", "disabled")
36        .addClass("disabled");
37    }
38
39    /* Build seat dropdowns */
40
41    jQuery(".seating-class-row").each(function () {
42      setOtherDropdowns();
43      var eventID = findIDs(jQuery(this));
44      buildSeats(jQuery(this), eventID[0], eventID[1].substring(20));
45      var currentP = jQuery(this);
46      currentP.find("select").change(function () {
47        if (
48          jQuery(this).attr("data-value") == undefined ||
49          jQuery(this).attr("data-value") != jQuery(this).val()
50        ) {
51          jQuery(this).attr("data-value", jQuery(this).val());
52          setOtherDropdowns();
53          buildSeats(currentP, eventID[0], eventID[1].substring(20));
54        }
55      });
56    });
57
58    jQuery(".seating-class-seat").each(function () {
59      var paragraphContainer = jQuery(this);
60      var eventID = findIDs(jQuery(this));
61      eventID = eventID[0];
62      paragraphContainer.find("select").change(function () {
63        var changedSelect = jQuery(this);
64
65        var alreadySelected = false;
66
67        var selectedSeatVal = jQuery(this).val();
68        if (selectedSeatVal == "") {
69          return;
70        }
71
72        jQuery(".seating-class-seat select")
73          .not(this)
74          .each(function () {
75            var thisEventID = findIDs(
76              jQuery(this).closest(".seating-class-seat")
77            );
78
79            if (
80              jQuery(this).val() == selectedSeatVal &&
81              thisEventID[0] == eventID
82            ) {
83              alreadySelected = true;
84            }
85          });
86
87        if (alreadySelected) {
88          var selectedSeatNumber = changedSelect
89            .find("option")
90            .filter(":selected")
91            .text();
92          var selectedMessage = jQuery(
93            "<p class='woocommerce-error seat_selected_message' style='display:none'>" +
94              fooevents_seating_translations[eventID].chartSeat +
95              selectedSeatNumber +
96              " " +
97              fooevents_seating_translations[eventID].chartAlreadySelected +
98              "</p>"
99          );
100          paragraphContainer.append(selectedMessage);
101
102          changedSelect.val("");
103
104          selectedMessage
105            .slideDown()
106            .delay(3000)
107            .slideUp(function () {
108              jQuery(this).remove();
109            });
110        }
111      });
112    });
113
114    jQuery(".seating-class-seat select").each(function () {
115      var seatSelectID = jQuery(this).attr("id");
116      var eventNr = seatSelectID.substr(
117        22,
118        seatSelectID.lastIndexOf("__") - 22
119      );
120      var attendeeNr = seatSelectID.substr(seatSelectID.lastIndexOf("__") + 2);
121      if (typeof selectedSeat[eventNr] !== "undefined") {
122        jQuery(this).val(selectedSeat[eventNr][attendeeNr]);
123      }
124    });
125  });
126})(jQuery);
127
128/* Finds the ID of the current event */
129
130function findIDs($element) {
131  var theClasses = $element.attr("class").split(" ");
132  var i = 0;
133  var classEventID = 0;
134  var classVariationID = 0;
135
136  while (i < theClasses.length) {
137    if (theClasses[i].indexOf("fooevents_event_") == 0) {
138      classEventID = theClasses[i];
139    }
140    if (theClasses[i].indexOf("fooevents_variation_") == 0) {
141      classVariationID = theClasses[i];
142    }
143    i++;
144  }
145  return [classEventID, classVariationID];
146}
147
148/* Finds the ID of the current event/variation on the event page */
149
150function findIDOnEvent() {
151  if (jQuery(".variation_id").val() != undefined) {
152    var eventID = jQuery(".variation_id").val();
153  } else {
154    var eventID = jQuery(".single_add_to_cart_button").val();
155  }
156  return eventID;
157}
158
159var currentSelectedRowNameFull = "";
160var currentSelectedRowName = "";
161var selectedSeatDropdown = "";
162var currentSelectedSeat = "";
163var numberSeats = 0;
164var variation = 0;
165var currentSelectedAttendeeSeatID = "";
166var optionsToRemove = [];
167var selectedSeatsObject = {};
168var the_variations = null;
169var getAllVariationsResult = {};
170var getSelectedVariationAttributesResult = {};
171var matchedVarIDs = [];
172var qtyOnEvent = jQuery(".qty").val();
173
174if (qtyOnEvent >= 0) {
175  var currentPage = "event";
176} else {
177  var currentPage = "checkout";
178}
179
180/* Builds seats dropdowns according to the number of seats in the "fooevents_seating_data" variable */
181
182function buildSeats($element, eventID, varID) {
183  currentSelectedRowNameFull = $element
184    .find("option")
185    .filter(":selected")
186    .val();
187
188  currentSelectedAttendeeSeatID = $element.attr("id");
189
190  if (currentSelectedRowNameFull != 0) {
191    numberSeats =
192      fooevents_seating_data[eventID][currentSelectedRowNameFull][
193        "number_seats"
194      ];
195  }
196
197  $element.find("option").each(function () {
198    var thisOptionVal = jQuery(this).val();
199
200    if (thisOptionVal != 0) {
201      variations = fooevents_seating_data[eventID][thisOptionVal]["variations"];
202
203      if (
204        (jQuery.isArray(variations) &&
205          jQuery.inArray("default", variations) > -1) ||
206        variations == "default"
207      ) {
208        variations = 0;
209      }
210
211      /* if the current variation has another variation in the array, use that one*/
212
213      if (
214        jQuery.isArray(variations) &&
215        jQuery.inArray(variationsToShow[varID], variations) > -1
216      ) {
217        variations[0] = variationsToShow[varID];
218      }
219
220      if (variationsToShow[varID] == variations) {
221        variations = variationsToShow[varID];
222      }
223
224      if (
225        (jQuery.isArray(variations) &&
226          jQuery.inArray(varID, variations) === -1 &&
227          variations.length !== 0) ||
228        (variations != varID && variations != 0)
229      ) {
230        if (
231          (jQuery.isArray(variations) &&
232            jQuery.inArray(varID, variations) === -1) ||
233          (!jQuery.isArray(variations) && varID !== variations)
234        ) {
235          jQuery("#" + currentSelectedAttendeeSeatID).change();
236          jQuery(
237            "#" +
238              currentSelectedAttendeeSeatID +
239              " option[value='" +
240              thisOptionVal +
241              "']"
242          ).remove();
243          currentSelectedRowNameFull = $element
244            .find("option")
245            .filter(":selected")
246            .val();
247        }
248      }
249    }
250  });
251
252  if (currentSelectedRowNameFull != undefined) {
253    currentSelectedRowName = currentSelectedRowNameFull.substring(
254      0,
255      currentSelectedRowNameFull.indexOf("_row_name")
256    );
257
258    currentSelectedSeatDropdown = $element
259      .next(".seating-class-seat")
260      .find("select");
261    currentSelectedSeatDropdown.html(
262      "<option value=''>" +
263        fooevents_seating_translations[eventID].chartSelectSeat +
264        "</option>"
265    );
266
267    if (currentSelectedRowNameFull != 0) {
268      numberSeats =
269        fooevents_seating_data[eventID][currentSelectedRowNameFull][
270          "number_seats"
271        ];
272
273      var atLeastOneSeat = false;
274
275      for (var i = 1; i <= numberSeats; i++) {
276        var seatValueToAdd = currentSelectedRowName + "_number_seats_" + i;
277        if (
278          jQuery.inArray(
279            seatValueToAdd,
280            fooevents_seats_unavailable[eventID]
281          ) === -1 &&
282          jQuery.inArray(seatValueToAdd, fooevents_seats_blocked[eventID]) ===
283            -1
284        ) {
285          if (
286            typeof selectedSeat != undefined &&
287            selectedSeat == seatValueToAdd
288          ) {
289            currentSelectedSeatDropdown.append(
290              '<option selected value="' +
291                seatValueToAdd +
292                '">' +
293                i +
294                "</option>"
295            );
296          } else {
297            currentSelectedSeatDropdown.append(
298              '<option value="' + seatValueToAdd + '">' + i + "</option>"
299            );
300          }
301
302          atLeastOneSeat = true;
303        }
304      }
305
306      if (!atLeastOneSeat) {
307        currentSelectedSeatDropdown.html(
308          '<option value="">' +
309            fooevents_seating_translations[eventID].chartNoSeatsAvailable +
310            "</option>"
311        );
312        currentSelectedSeatDropdown
313          .closest("select")
314          .prop("disabled", "disabled");
315      } else {
316        currentSelectedSeatDropdown.closest("select").prop("disabled", false);
317      }
318      currentSelectedSeat = $element
319        .next(".seating-class-seat")
320        .find("option")
321        .filter(":selected")
322        .val();
323      currentSelectedSeat = currentSelectedSeat.substring(
324        currentSelectedSeat.indexOf("number_seats_")
325      );
326    }
327  }
328}
329
330/* Builds the seat dropdowns for all other dropdowns that are not currently selected */
331
332function setOtherDropdowns() {
333  var thisSelectedSeat = "";
334  jQuery(".seating-class-row").each(function () {
335    var thisSelectedAttendeeSeatID = jQuery(this).attr("id");
336    if (thisSelectedAttendeeSeatID != currentSelectedAttendeeSeatID) {
337      var thisSelectedRowName = jQuery(this)
338        .find("option")
339        .filter(":selected")
340        .val();
341      if (thisSelectedRowName == currentSelectedRowNameFull) {
342        thisSelectedSeat = jQuery(this)
343          .next(".seating-class-seat")
344          .find("option")
345          .filter(":selected")
346          .val();
347        if (thisSelectedSeat != "") {
348          if (jQuery.inArray(thisSelectedSeat, optionsToRemove) === -1) {
349            optionsToRemove.push(thisSelectedSeat);
350          }
351        }
352      }
353    }
354  });
355}
356
357/* Listen for variation changes on the event screen so that Choose Seats button can display or be hidden - no button if there are no seats set for that variation */
358
359jQuery(".single_variation_wrap").on(
360  "hide_variation",
361  function (event, variation) {
362    if (the_variations != undefined && the_variations != null) {
363      the_variations.abort();
364      the_variations = null;
365    }
366
367    jQuery("a.fooevents_seating_chart").hide();
368    jQuery(".seating-event .qty").show();
369    jQuery(".theme-Avada .seating-event .quantity").show();
370    jQuery(".theme-astra .seating-event .quantity").show();
371    jQuery(".seating-event .single_add_to_cart_button")
372      .prop("disabled", false)
373      .removeClass("disabled");
374  }
375);
376
377function getAllVariations() {
378  matchedVarIDs = [];
379
380  var productID = jQuery("input[name=product_id]").val();
381
382  var dataVariations = {
383    action: "fetch_all_woocommerce_variation_attributes",
384    productID: productID,
385    dataType: "json",
386  };
387
388  if (the_variations != undefined && the_variations != null) {
389    the_variations.abort();
390    the_variations = null;
391  }
392
393  the_variations = jQuery.post(
394    FooEventsSeatingObj.ajaxurl,
395    dataVariations,
396    function (response) {
397      getAllVariationsResult = JSON.parse(response);
398      getSelectedVariationAttributes();
399    }
400  );
401}
402
403function getSelectedVariationAttributes() {
404  var productID = jQuery(".variation_id").val();
405  var dataVariations = {
406    action: "fetch_selected_variation_attributes",
407    productID: productID,
408    dataType: "json",
409  };
410
411  the_variations = jQuery.post(
412    FooEventsSeatingObj.ajaxurl,
413    dataVariations,
414    function (response) {
415      getSelectedVariationAttributesResult = JSON.parse(response);
416      findCorrectVariation();
417    }
418  );
419}
420
421function findCorrectVariation() {
422  var selectedAttr1 = getSelectedVariationAttributesResult[0];
423  var selectedAttr2 = getSelectedVariationAttributesResult[1];
424  var selectedAttr3 = getSelectedVariationAttributesResult[2];
425
426  jQuery.each(getAllVariationsResult, function (unusedKey, valueAll) {
427    var keysAll = Object.keys(valueAll);
428    var thisVarID = valueAll[keysAll[0]];
429    var thisAttr1 = valueAll[keysAll[1]];
430    var thisAttr2 = valueAll[keysAll[2]];
431    var thisAttr3 = valueAll[keysAll[3]];
432
433    // Check to see if the selected variation matches a variation where one attribute is "Any..." or where both attributes are the same
434    if (
435      (thisAttr1 == "" &&
436        thisAttr2 == selectedAttr2 &&
437        thisAttr3 == selectedAttr3) ||
438      (thisAttr1 == "" && thisAttr2 == "" && thisAttr3 == selectedAttr3) ||
439      (thisAttr1 == selectedAttr1 &&
440        thisAttr2 == "" &&
441        thisAttr3 == selectedAttr3) ||
442      (thisAttr1 == selectedAttr1 && thisAttr2 == "" && thisAttr3 == "") ||
443      (thisAttr1 == selectedAttr1 &&
444        thisAttr2 == selectedAttr2 &&
445        thisAttr3 == "") ||
446      (thisAttr1 == "" && thisAttr2 == selectedAttr2 && thisAttr3 == "") ||
447      (thisAttr1 == "" && thisAttr2 == "" && thisAttr3 == "") ||
448      (thisAttr1 == selectedAttr1 &&
449        thisAttr2 == selectedAttr2 &&
450        thisAttr3 == selectedAttr3)
451    ) {
452      matchedVarIDs.push(thisVarID);
453    }
454  });
455
456  if (currentPage == "event") {
457    jQuery("a.fooevents_seating_chart")
458      .show()
459      .removeClass("fooevents_seating_chart_wait");
460    seatsShowVariation();
461  }
462}
463
464function seatsShowVariation() {
465  /* Check to see if there are seats set up for this variation */
466  var eventID = jQuery("input[name=product_id]").val();
467  var chooseSeatsShouldShow = false;
468
469  if (typeof fooevents_seats_options_serialized !== "undefined") {
470    jQuery.each(
471      fooevents_seats_options_serialized[eventID],
472      function (unusedKey, value) {
473        var keys = Object.keys(value);
474
475        if (jQuery.isArray(value[keys[2]])) {
476          jQuery.each(value[keys[2]], function (unusedKey, valueValue) {
477            if (
478              jQuery.inArray(parseInt("" + valueValue), matchedVarIDs) > -1 ||
479              valueValue[keys[2]] == "default" ||
480              valueValue == "default"
481            ) {
482              chooseSeatsShouldShow = true;
483            }
484          });
485        } else {
486          if (
487            jQuery.inArray(parseInt(value[keys[2]]), matchedVarIDs) > -1 ||
488            value[keys[2]] == "default"
489          ) {
490            chooseSeatsShouldShow = true;
491          }
492        }
493      }
494    );
495  }
496
497  if (chooseSeatsShouldShow) {
498    jQuery(".seating-event .single_add_to_cart_button")
499      .prop("disabled", true)
500      .addClass("disabled");
501    jQuery(".fooevents_seating_chart span").html("(0)");
502    jQuery("a.fooevents_seating_chart").show();
503    jQuery(".seating-event .qty").val(1).hide().change();
504    jQuery(".theme-Avada .seating-event .quantity").hide();
505    jQuery(".theme-astra .seating-event .quantity").hide();
506  } else {
507    jQuery("a.fooevents_seating_chart").hide();
508    jQuery(".seating-event .qty").show();
509    jQuery(".theme-Avada .seating-event .quantity").show();
510    jQuery(".theme-astra .seating-event .quantity").show();
511    jQuery(".seating-event .single_add_to_cart_button")
512      .prop("disabled", false)
513      .removeClass("disabled");
514  }
515}
516
517jQuery(".single_variation_wrap").on(
518  "show_variation",
519  function (event, variation) {
520    setTimeout(function () {
521      jQuery(".seating-event .single_add_to_cart_button")
522        .prop("disabled", true)
523        .addClass("disabled");
524      jQuery(".fooevents_seating_chart span").html("(0)");
525      jQuery("a.fooevents_seating_chart")
526        .show()
527        .addClass("fooevents_seating_chart_wait");
528      jQuery(".seating-event .qty").val(1).hide().change();
529      jQuery(".theme-Avada .seating-event .quantity").hide();
530      jQuery(".theme-astra .seating-event .quantity").hide();
531      getAllVariations();
532    }, 100);
533  }
534);
535
536jQuery(".fooevents_seating_chart").on("click", function () {
537  if (jQuery(this).hasClass("fooevents_seating_chart_wait")) {
538    return;
539  }
540
541  var seatingChartButton = jQuery(this);
542  var currentSelect = seatingChartButton.prev().attr("id");
543
544  var currentVariationID = findIDOnEvent();
545
546  if (currentVariationID == undefined) {
547    currentVariationID = seatingChartButton.attr("name").substring(20);
548  }
549
550  var viewportWidth = window.innerWidth - 20;
551  var viewportHeight = window.innerHeight - 20;
552  if (viewportWidth > 1000) viewportWidth = 1000;
553  if (viewportHeight > 500) viewportHeight = 500;
554
555  jQuery("#fooevents_seating_dialog").html("");
556
557  var rowName = "";
558  var rowID = "";
559  var eventID = jQuery(this).attr("id").substring(19);
560  var numberSeats = 0;
561  var seats = "";
562  var unavailableSeats = "";
563  var blockedSeats = "";
564  var currentRow = "";
565  var seatClass = "available";
566  var otherSeatsSelected = [];
567
568  if (currentPage == "checkout") {
569    matchedVarIDs = [];
570  }
571
572  /* Get rows to show on seating chart */
573  var rowsToShowOnChartArray = [];
574  var rowsToShowOnChart = jQuery(this).siblings(".seating-class-row");
575  rowsToShowOnChart.find("select option").each(function () {
576    rowsToShowOnChartArray.push(this.value);
577  });
578
579  if (seatColor == "#") seatColor = "#549E39";
580
581  seatColorStyleAvailable = " style='background-color:" + seatColor + "'";
582
583  if (seatColorSelected == "#") seatColorSelected = "#be3737";
584
585  seatColorStyleSelected =
586    " style='background-color:" + seatColorSelected + "'";
587
588  if (seatColorUnavailableSelected == "#")
589    seatColorUnavailableSelected = "#be7337";
590
591  seatColorStyleUnavailableSelected =
592    " style='background-color:" + seatColorUnavailableSelected + "'";
593
594  var seatColorStyle = seatColorStyleAvailable;
595
596  /* Check the seats selected in the other dropdowns */
597
598  jQuery(".seating-class-seat").each(function () {
599    /* Get currentSelect's event ID */
600    var currentEventID = findIDs(seatingChartButton.prev());
601    currentEventID = currentEventID[0];
602
603    /* Check all other dropdowns regardless of event ID */
604    if (jQuery(this).attr("id") != currentSelect) {
605      var innerEventID = findIDs(jQuery(this));
606      innerEventID = innerEventID[0];
607
608      if (
609        currentEventID == innerEventID &&
610        jQuery(this).find("select").val() != ""
611      ) {
612        otherSeatsSelected.push(jQuery(this).find("select").val());
613      }
614    }
615  });
616
617  if (jQuery(".qty").val() != undefined) {
618    var attendeeLabel =
619      fooevents_seating_translations["fooevents_event_" + eventID]
620        .chartSelectedForAttendee;
621  } else {
622    var attendeeLabel =
623      fooevents_seating_translations["fooevents_event_" + eventID]
624        .chartThisSelected;
625  }
626
627  jQuery("#fooevents_seating_dialog").append(
628    "<div class='fooevents_seating_chart_legend'><div id='fooevents_seating_available'" +
629      seatColorStyleAvailable +
630      "></div> " +
631      fooevents_seating_translations["fooevents_event_" + eventID]
632        .chartAvailable +
633      "<div id='fooevents_seating_unavailable'></div> " +
634      fooevents_seating_translations["fooevents_event_" + eventID].chartBooked +
635      "<div id='fooevents_seating_blocked'></div> " +
636      fooevents_seating_translations["fooevents_event_" + eventID]
637        .chartBlocked +
638      "<div id='fooevents_seating_unavailable_selected'" +
639      seatColorStyleUnavailableSelected +
640      "></div> " +
641      fooevents_seating_translations["fooevents_event_" + eventID]
642        .chartDifferentSelected +
643      "<div id='fooevents_seating_selected'" +
644      seatColorStyleSelected +
645      "></div> " +
646      attendeeLabel +
647      "</div>"
648  );
649  jQuery("#fooevents_seating_dialog").append(
650    "<div class='fooevents_seating_chart_front'>" +
651      fooevents_seating_translations["fooevents_event_" + eventID].chartFront +
652      "</div>"
653  );
654
655  var seatContainer = jQuery("<div class='seat_container' />");
656
657  jQuery.each(
658    fooevents_seats_options_serialized[eventID],
659    function (unusedKey, value) {
660      var keys = Object.keys(value);
661      if (
662        jQuery.inArray(keys[0], rowsToShowOnChartArray) > -1 &&
663        value[keys[2]] != "default"
664      ) {
665        if (value[keys[2]].length > 1) matchedVarIDs.push(value[keys[2]]);
666        else matchedVarIDs.push(parseInt(value[keys[2]]));
667      }
668    }
669  );
670
671  jQuery.each(
672    fooevents_seats_options_serialized[eventID],
673    function (unusedKey, value) {
674      var keys = Object.keys(value);
675      seatType = value[keys[3]];
676      seatTypeClass = value[keys[3]];
677      var otherVarClass = "";
678
679      if (seatType == "table_new_row") {
680        seatTypeClass = "table table_new_row";
681      }
682
683      var shouldAddRow = false;
684
685      if (jQuery.isArray(value[keys[2]])) {
686        jQuery.each(value[keys[2]], function (unusedKey, variationID) {
687          if (
688            jQuery.inArray(parseInt("" + variationID), matchedVarIDs) > -1 ||
689            variationID == "default"
690          ) {
691            shouldAddRow = true;
692          }
693        });
694      } else {
695        if (
696          jQuery.inArray(parseInt(value[keys[2]]), matchedVarIDs) > -1 ||
697          value[keys[2]] == "default"
698        ) {
699          shouldAddRow = true;
700        }
701      }
702
703      if (!shouldAddRow) {
704        otherVarClass = "unavailable_variation";
705      } else {
706        otherVarClass = "";
707      }
708
709      if (shouldAddRow || showOtherVars == "on") {
710        var rowContainer = jQuery(
711          "<div id='fooevents_variation_" +
712            value[keys[2]] +
713            "' class='row_container row_container_event_" +
714            eventID +
715            " " +
716            seatTypeClass +
717            " " +
718            otherVarClass +
719            "' />"
720        );
721
722        rowID = keys[0];
723        rowName = value[keys[0]];
724
725        numberSeats = value[keys[1]];
726        rowContainer.append(
727          "<div class='fooevents_seating_chart_view_row_name " +
728            seatTypeClass +
729            "' id='" +
730            rowID +
731            "'>" +
732            rowName +
733            "</div>"
734        );
735        seats = jQuery("<div>", {
736          class:
737            "fooevents_seating_chart_view_row fooevents_seating_chart_view_row_checkout " +
738            seatTypeClass,
739        });
740        if (
741          typeof fooevents_seats_unavailable_serialized[eventID] != undefined
742        ) {
743          unavailableSeats = JSON.stringify(
744            fooevents_seats_unavailable_serialized[eventID]
745          );
746        } else {
747          unavailableSeats = JSON.stringify(
748            fooevents_seats_unavailable_serialized
749          );
750        }
751
752        if (typeof fooevents_seats_blocked_serialized[eventID] != undefined) {
753          blockedSeats = JSON.stringify(
754            fooevents_seats_blocked_serialized[eventID]
755          );
756        } else {
757          blockedSeats = JSON.stringify(fooevents_seats_blocked_serialized);
758        }
759
760        if (typeof fooevents_seats_aisles_serialized[eventID] != undefined) {
761          aisleSeats = JSON.stringify(
762            fooevents_seats_aisles_serialized[eventID]
763          );
764        } else {
765          aisleSeats = JSON.stringify(fooevents_seats_aisles_serialized);
766        }
767
768        currentRow =
769          rowID.substr(0, rowID.indexOf("_row_name")) + "_number_seats_";
770
771        if (seatType == "table" || seatType == "table_new_row") {
772          numberSeatsTableSize = 8;
773          if (numberSeats > 8) {
774            numberSeatsTableSize = numberSeats;
775          }
776
777          seats.css("width", numberSeatsTableSize * 15 - 31 + "px");
778          seats.css("height", numberSeatsTableSize * 15 - 31 + "px");
779          var theta = [];
780          var frags = 360 / numberSeats;
781          for (var i = 0; i <= numberSeats; i++) {
782            theta.push((frags / 180) * i * Math.PI);
783          }
784        }
785
786        for (var i = 1; i <= numberSeats; i++) {
787          if (
788            (unavailableSeats !== undefined &&
789              unavailableSeats.indexOf(currentRow + i + '"') > -1) ||
790            !shouldAddRow
791          ) {
792            seatClass = "unavailable";
793            seatColorStyle = "";
794          }
795
796          if (
797            blockedSeats !== undefined &&
798            blockedSeats.indexOf(currentRow + i + '"') > -1
799          ) {
800            seatClass = "fe-blocked";
801            seatColorStyle = "";
802          }
803
804          if (
805            otherSeatsSelected !== undefined &&
806            jQuery.inArray(currentRow + i, otherSeatsSelected) > -1
807          ) {
808            seatClass = "unavailable_selected";
809            seatColorStyle = seatColorStyleUnavailableSelected;
810          }
811
812          if (
813            aisleSeats !== undefined &&
814            aisleSeats.indexOf(currentRow + i + '"') > -1
815          ) {
816            seatClass += " aisle";
817          }
818
819          var seat = jQuery(
820            "<span name='" +
821              rowID.replace("_row_name", "") +
822              "_number_seats_" +
823              i +
824              "'" +
825              seatColorStyle +
826              " class='" +
827              seatClass +
828              "'>" +
829              i +
830              "</span>"
831          );
832
833          if (seatType == "table" || seatType == "table_new_row") {
834            var mainHeight = numberSeatsTableSize * 15;
835            var r = mainHeight / 2;
836            seat.position.top = Math.round(r * Math.cos(theta[i])) - 28 + "px";
837            seat.position.left = Math.round(r * Math.sin(theta[i])) + 28 + "px";
838            seat.css("position", "absolute");
839            seat.css(
840              "top",
841              mainHeight / 2 - parseInt(seat.position.left.slice(0, -2)) + "px"
842            );
843            seat.css(
844              "left",
845              mainHeight / 2 + parseInt(seat.position.top.slice(0, -2)) + "px"
846            );
847          }
848
849          jQuery(seats).append(seat);
850          seatClass = "available";
851
852          seatColorStyle = seatColorStyleAvailable;
853        }
854
855        rowContainer.append(seats);
856        seatContainer.append(rowContainer);
857      }
858    }
859  );
860
861  function appendSeats() {
862    jQuery("#fooevents_seating_dialog").append(seatContainer);
863  }
864
865  function setContainerWidthForTables() {
866    var tableRowWidth = 0;
867    var tableRowWidths = [];
868    var maxWidth = 0;
869    /* Set width of seatContainer if tables are used */
870    jQuery(".seat_container div.row_container.table").each(function () {
871      tableRowWidth = tableRowWidth + jQuery(this).width();
872      tableRowWidths.push(tableRowWidth);
873
874      if (jQuery(this).next().hasClass("table_new_row")) {
875        tableRowWidth = 0;
876      }
877      maxWidth = Math.max.apply(Math, tableRowWidths);
878    });
879
880    if (maxWidth > 0) {
881      jQuery(".seat_container").css("width", maxWidth + 17);
882      jQuery(".fooevents_seating_chart_front").css("width", maxWidth);
883    }
884  }
885
886  appendSeats();
887
888  setTimeout(function () {
889    setContainerWidthForTables();
890  }, 100);
891
892  if (selectedSeatsObject[findIDOnEvent()] != undefined) {
893    selectedSeats = selectedSeatsObject[findIDOnEvent()];
894  } else {
895    selectedSeats = [];
896  }
897
898  if (jQuery(".qty").val() != undefined && jQuery(".qty").val() > 0) {
899    jQuery("#fooevents_seating_dialog").append(
900      "<button id='fooevents_seating_select_seats' class='button'>" +
901        fooevents_seating_translations["fooevents_event_" + eventID]
902          .chartSelectSeats +
903        " (" +
904        selectedSeats.length +
905        ")</button>"
906    );
907  } else {
908    jQuery("#fooevents_seating_dialog").append(
909      "<button id='fooevents_seating_select_seats' class='button'>" +
910        fooevents_seating_translations["fooevents_event_" + eventID]
911          .chartSelectSeat +
912        "</button>"
913    );
914  }
915
916  jQuery(".qty").on("change", function () {
917    selectedSeatsObject[findIDOnEvent()] = [];
918  });
919
920  jQuery("#fooevents_seating_select_seats").on("click", function () {
921    jQuery(this).closest(".ui-dialog-content").dialog("close");
922  });
923
924  if (jQuery("#fooevents_seating_dialog").is(":empty")) {
925    jQuery("#fooevents_seating_dialog").append(
926      "<div style='margin-top:20px'>" +
927        fooevents_seating_translations["fooevents_event_" + eventID]
928          .chartNoSeatsToShow +
929        "</div>"
930    );
931  }
932
933  jQuery("#fooevents_seating_dialog").dialog({
934    width: "100%",
935    maxWidth: "768px",
936    height: "auto",
937    maxHeight: "768px",
938    show: {
939      effect: "drop",
940      direction: "up",
941      duration: 1000,
942    },
943
944    open: function () {
945      var thisDialog = jQuery(this);
946      var productID = 0;
947      var qtyOnEvent = 0;
948      var selectedSeats = [];
949      var quantityNr = jQuery(".qty").val();
950      var isSoldIndividually = false;
951
952      /* If qtyOnEvent is 1 or more then this is the product page, otherwise it is the Checkout page. If the qty div is hidden then the product is sold individually. */
953
954      if (jQuery(".qty").val() != undefined) {
955        qtyOnEvent = jQuery(".qty").val();
956
957        if (jQuery(".qty").attr("type") == "hidden") {
958          isSoldIndividually = true;
959        }
960
961        jQuery("#fooevents_seating_unavailable_selected")
962          .get(0)
963          .nextSibling.remove();
964        jQuery("#fooevents_seating_unavailable_selected").remove();
965
966        if (jQuery("input[name=product_id]").val() != undefined) {
967          productID = jQuery(".variation_id").val();
968        } else {
969          productID = jQuery(".single_add_to_cart_button").val();
970        }
971      }
972
973      if (selectedSeatsObject[productID] != undefined) {
974        selectedSeats = selectedSeatsObject[productID];
975      }
976
977      thisDialog
978        .find(
979          'span[name="' + seatingChartButton.prev().find("select").val() + '"]'
980        )
981        .addClass("selected")
982        .css("backgroundColor", seatColorSelected);
983
984      /* See if seats were selected before on this page and select them */
985
986      if (selectedSeats.length > 0) {
987        jQuery("#fooevents_seating_select_seats")
988          .prop("disabled", false)
989          .removeClass("disabled");
990      }
991      if (qtyOnEvent > 0) {
992        for (var i = 0; i < selectedSeats.length; i++) {
993          jQuery("span[name='" + selectedSeats[i] + "']")
994            .css("backgroundColor", seatColorSelected)
995            .addClass("selected");
996        }
997      }
998
999      /* Making seats selectable */
1000      thisDialog.find(".available").on("click", function () {
1001        if (!jQuery(this).hasClass("unavailable")) {
1002          if (!jQuery(this).hasClass("selected")) {
1003            /* If qtyOnEvent is 1 or more then this is the product page, otherwise it is the Checkout page OR the item is sold individually */
1004
1005            if (qtyOnEvent == 0) {
1006              thisDialog
1007                .find(".available")
1008                .removeClass("selected")
1009                .css("backgroundColor", seatColor);
1010              jQuery(this).addClass("selected");
1011              jQuery(this).css("backgroundColor", seatColorSelected);
1012              seatingChartButton
1013                .prev()
1014                .prev()
1015                .find("select")
1016                .val(jQuery(this).parent().prev().attr("id"));
1017              seatingChartButton.prev().prev().find("select").change();
1018              seatingChartButton
1019                .prev()
1020                .find("select")
1021                .val(jQuery(this).attr("name"));
1022            } else {
1023              /* If seats are selected, update the quantity picker */
1024
1025              if (selectedSeats.length >= quantityNr) {
1026                quantityNr++;
1027                jQuery(".qty").val(quantityNr).change();
1028              }
1029
1030              if (!isSoldIndividually) {
1031                selectedSeats.push(jQuery(this).attr("name"));
1032              } else {
1033                selectedSeats = [];
1034                selectedSeats.push(jQuery(this).attr("name"));
1035
1036                jQuery(".fooevents_seating_chart_view_row span").each(
1037                  function () {
1038                    if (!jQuery(this).hasClass("unavailable")) {
1039                      if (jQuery(this).hasClass("selected")) {
1040                        jQuery(this)
1041                          .removeClass("selected")
1042                          .css("backgroundColor", seatColor);
1043                      }
1044
1045                      if (
1046                        blockedSeats.indexOf(jQuery(this).attr("name")) === -1
1047                      ) {
1048                        jQuery(this)
1049                          .removeClass("fe-blocked")
1050                          .css("backgroundColor", seatColor);
1051                      }
1052                    }
1053                  }
1054                );
1055              }
1056
1057              selectedSeatsObject[productID] = selectedSeats;
1058
1059              jQuery(this)
1060                .css("backgroundColor", seatColorSelected)
1061                .addClass("selected");
1062            }
1063          } else {
1064            if (quantityNr > 1) {
1065              quantityNr--;
1066              jQuery(".qty").val(quantityNr).change();
1067            }
1068
1069            if (!isSoldIndividually) {
1070              selectedSeats.splice(
1071                jQuery.inArray(jQuery(this).attr("name"), selectedSeats),
1072                1
1073              );
1074            } else {
1075              selectedSeats = [];
1076            }
1077
1078            jQuery(this)
1079              .css("backgroundColor", seatColorSelected)
1080              .removeClass("selected")
1081              .css("backgroundColor", seatColor);
1082          }
1083
1084          if (jQuery(".qty").val() != undefined && jQuery(".qty").val() > 0) {
1085            jQuery("#fooevents_seating_select_seats").html(
1086              fooevents_seating_translations["fooevents_event_" + eventID]
1087                .chartSelectSeats +
1088                " (" +
1089                selectedSeats.length +
1090                ")"
1091            );
1092            jQuery(".fooevents_seating_chart span").html(
1093              "(" + selectedSeats.length + ")"
1094            );
1095          } else {
1096            jQuery("#fooevents_seating_select_seats").html(
1097              fooevents_seating_translations["fooevents_event_" + eventID]
1098                .chartSelectSeat
1099            );
1100          }
1101        }
1102
1103        /* Disable Add to Cart and Select Seats buttons if 0 seats are selected, otherwise enable */
1104
1105        if (jQuery(".qty").val() != undefined) {
1106          if (selectedSeats.length > 0) {
1107            jQuery(".single_add_to_cart_button")
1108              .prop("disabled", false)
1109              .removeClass("disabled");
1110            jQuery("#fooevents_seating_select_seats")
1111              .prop("disabled", false)
1112              .removeClass("disabled");
1113          } else {
1114            jQuery(".single_add_to_cart_button")
1115              .prop("disabled", "disabled")
1116              .addClass("disabled");
1117            jQuery("#fooevents_seating_select_seats")
1118              .prop("disabled", "disabled")
1119              .addClass("disabled");
1120          }
1121        }
1122      });
1123    },
1124  });
1125});
1126
1127/* Stop add to cart from sending details through, if seats were not selected */
1128
1129(function ($) {
1130  jQuery(document).on("click", ".single_add_to_cart_button", function (e) {
1131    /* Stop add to cart and show seating chart if selectedSeatsObject is empty, fewer seats than the quantity is selected or no seating chart button is visible */
1132
1133    var findIDOnEvent;
1134
1135    if (jQuery(".variation_id").val() != undefined) {
1136      findIDOnEvent = jQuery(".variation_id").val();
1137    } else {
1138      findIDOnEvent = jQuery(".single_add_to_cart_button").val();
1139    }
1140
1141    if (!Object.keys(selectedSeatsObject).includes(findIDOnEvent)) {
1142      findIDOnEvent = Object.keys(selectedSeatsObject)[0];
1143    }
1144
1145    if (
1146      (selectedSeatsObject[findIDOnEvent] == undefined ||
1147        selectedSeatsObject[findIDOnEvent].length == 0) &&
1148      jQuery("a.fooevents_seating_chart").is(":visible")
1149    ) {
1150      e.preventDefault();
1151      jQuery(".fooevents_seating_chart").trigger("click");
1152    } else {
1153      jQuery("#fooevents_seats__trans").val(selectedSeatsObject[findIDOnEvent]);
1154      jQuery(".fooevents_seating_chart span").html("(0)");
1155    }
1156  });
1157})(jQuery);

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.