PageSourceSearch

https://dromnyc.com/wp-content/plugins/fooevents_seating/engines/v1/js/seating-frontend.js?ver=1790245154

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