-
-
Save hrumhrumble/cecf132c55be95c02b4cfbd6be7a2a64 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $(function() { | |
| if ($(".schedule").length > 0) | |
| var e = new Vue({ | |
| el: ".schedule", | |
| data: { | |
| slickInit: !1, | |
| isFiltered: !1, | |
| currentClasses: [], | |
| currentClassId: null, | |
| currentClass: "", | |
| currentTrainer: "", | |
| currentDate: "", | |
| currentClassDropdown: !1, | |
| currentTrainerDropdown: !1, | |
| currentDateDropdown: !1, | |
| weeks: [], | |
| classes: [], | |
| trainers: [], | |
| dates: [], | |
| timer: "" | |
| }, | |
| watch: { | |
| currentClass: function() { | |
| e.filtered() | |
| }, | |
| currentTrainer: function() { | |
| e.filtered() | |
| }, | |
| currentDate: function() { | |
| e.filtered() | |
| } | |
| }, | |
| methods: { | |
| getTrainers: function() { | |
| axios.get("/trainersJson").then(function(a) { | |
| e.trainers = a.data | |
| }) | |
| }, | |
| getClassesTypes: function() { | |
| axios.get("/vueClassTypes").then(function(a) { | |
| e.classes = a.data | |
| }) | |
| }, | |
| getSchedule: function(a) { | |
| var t = this; | |
| axios.get("/vueitems/" + a).then(function(a) { | |
| e.weeks = a.data, | |
| t.getClasses(e.$data), | |
| $(".preloader").fadeOut() | |
| }) | |
| }, | |
| getDatesFunction: function() { | |
| axios.get("/vueDates").then(function(a) { | |
| e.dates = a.data | |
| }) | |
| }, | |
| cancelAutoUpdate: function() { | |
| clearInterval(timer) | |
| }, | |
| changeTab: function() { | |
| _.each(e.weeks, function(e) { | |
| e.show = !e.show | |
| }) | |
| }, | |
| dateSlide: function() { | |
| var a = $("[data-date=" + e.currentDate + "]").parents(".schedule__day").data("slick-index"); | |
| $(".schedule__days").slick("slickGoTo", parseInt(a)) | |
| }, | |
| dropFiltered: function() { | |
| _.each(e.currentClasses, function(e) { | |
| e.filtered = !1 | |
| }) | |
| }, | |
| getClasses: function(e) { | |
| return _.each(e.weeks, function(a) { | |
| _.each(a.days, function(a) { | |
| _.each(a.classes, function(a) { | |
| e.currentClasses.push(a) | |
| }) | |
| }) | |
| }), | |
| e.currentClasses | |
| }, | |
| classDay: function(e, a) { | |
| var t = new Date(a.slug) | |
| , s = new Date | |
| , n = s.getFullYear() + "-" + (s.getMonth() + 1) + "-" + s.getDate(); | |
| return s = new Date(n), | |
| { | |
| "schedule__day-class--disabled": !e.available || t <= s, | |
| "schedule__day-class--filterd": e.filtered | |
| } | |
| }, | |
| initSlider: function() { | |
| if ($(window).width() <= 815 && !$(".schedule").hasClass("schedule--slick-init")) { | |
| $(".schedule__days").not(".slick-initialized").slick({ | |
| centerMode: !0, | |
| centerPadding: "80px", | |
| slidesToShow: 3, | |
| arrows: !1, | |
| responsive: [{ | |
| breakpoint: 600, | |
| settings: { | |
| slidesToShow: 1 | |
| } | |
| }] | |
| }), | |
| $(".schedule").addClass("schedule--slick-init") | |
| } else | |
| $(window).width() > 815 && ($(".schedule__days").hasClass("slick-initialized") && setTimeout(function() { | |
| $(".schedule__days").slick("unslick") | |
| }, 100), | |
| $(".schedule").removeClass("schedule--slick-init")) | |
| }, | |
| nextSlide: function() { | |
| $(".schedule__days").slick("slickNext") | |
| }, | |
| prevSlide: function() { | |
| $(".schedule__days").slick("slickPrev") | |
| }, | |
| destroySlider: function() { | |
| $(".schedule__days").slick("unslick") | |
| }, | |
| helperEvent: function() { | |
| var e = $(".schedule__day-class") | |
| , a = $(".schedule__day-class-hover-helper"); | |
| $(window).width() <= 800 ? (e.off("mouseenter mouseleave"), | |
| a.on("clickout", function() { | |
| $(this).parents(".schedule__day-class").removeClass("schedule__day-class--hovered") | |
| }), | |
| a.off("click").on("click", function() { | |
| $(".schedule__days").slick("slickGoTo", parseInt($(this).parents(".schedule__day").data("slick-index"))), | |
| $(this).parents(".schedule__day-class").hasClass("schedule__day-class--hovered") ? $(this).parents(".schedule__day-class").removeClass("schedule__day-class--hovered") : (e.removeClass("schedule__day-class--hovered"), | |
| $(this).parents(".schedule__day-class").addClass("schedule__day-class--hovered")) | |
| })) : (e.on("mouseenter", function() { | |
| $(this).addClass("schedule__day-class--hovered") | |
| }), | |
| e.on("mouseleave", function() { | |
| $(this).removeClass("schedule__day-class--hovered") | |
| })) | |
| }, | |
| filterOutClick: function() { | |
| $(".schedule__filter").on("clickout", function() { | |
| e.currentClassDropdown = !1, | |
| e.currentTrainerDropdown = !1, | |
| e.currentDateDropdown = !1 | |
| }) | |
| }, | |
| closeDropdownExcept: function(a) { | |
| switch (a) { | |
| case "trainer": | |
| e.currentClassDropdown = !1, | |
| e.currentDateDropdown = !1; | |
| break; | |
| case "klass": | |
| e.currentDateDropdown = !1, | |
| e.currentTrainerDropdown = !1; | |
| break; | |
| case "date": | |
| e.currentClassDropdown = !1, | |
| e.currentTrainerDropdown = !1 | |
| } | |
| }, | |
| tableAutoHeight: function() { | |
| var e = $(".schedule__weeks").height() | |
| , a = $(".schedule__days--active").height(); | |
| if (0 !== e && void 0 !== a) { | |
| var t = $(".schedule__weeks").height() + $(".schedule__days--active").height(); | |
| t < 155 && (t *= 2), | |
| $(".schedule__table").height(t) | |
| } else | |
| $(".schedule__table").height(550) | |
| }, | |
| switchTab: function() { | |
| $(".schedule__week").toggleClass("schedule__week--active"), | |
| $(".schedule__days").toggleClass("schedule__days--active") | |
| } | |
| }, | |
| beforeDestroy: function() { | |
| clearIntervall(this.timer) | |
| }, | |
| created: function() { | |
| var e = this; | |
| e.currentClassId = $("#currentClassId").val(), | |
| e.timer = setInterval(function() { | |
| this.getSchedule(e.currentClassId) | |
| } | |
| .bind(this), 3e5) | |
| }, | |
| mounted: function() { | |
| var e = this; | |
| e.currentClassId = $("#currentClassId").val(), | |
| e.getSchedule(e.currentClassId), | |
| e.getTrainers(), | |
| e.getClassesTypes(), | |
| e.getDatesFunction(), | |
| $(window).on("resize", function() { | |
| e.tableAutoHeight(), | |
| e.initSlider(), | |
| e.helperEvent() | |
| }), | |
| $(".schedule__week").on("click", function() { | |
| $(".schedule__week").toggleClass("schedule__week--active"), | |
| $(".schedule__days").toggleClass("schedule__days--active") | |
| }) | |
| }, | |
| updated: function() { | |
| var e = this; | |
| e.initSlider(), | |
| e.helperEvent(), | |
| e.filterOutClick(), | |
| e.tableAutoHeight() | |
| } | |
| }) | |
| }), |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment