var chart; $(document).ready(function() { try { moci.init({ slick: $("[data-slick]"), selectpicker: $(".selectpicker"), innerscroll: $(".inner-scroll") }); }catch(e) { console.log(e); }; }); var self; var moci = { init: function(options) { this.settings = options; self = this; lazyload.load(".video-listing", 'src/data/video-listing.html'); lazyload.load(".photo-listing", 'src/data/photo-listing.html'); lazyload.load(".e-services__items", 'src/data/e-services-items.html'); this.loader(); this.video_modal(); this.utilities(); // this.changeTheme(); // this.changefontSize(); this.configureModal(); // this.datepickers(); this.selectpicker(); // this.mainBanner(); // this.mediaSlider(); this.customNavSlider(); }, customNavSlider: function() { $('.custom-slider').each(function() { var $slider = $(this); var $sliderContainer = $slider.closest('.slider-container'); if ($slider.length && $sliderContainer.length) { var slidesCount; var currentSlide; var sliderCounter = $sliderContainer.find(".slider-counter .total"); var activeSlideNum = $sliderContainer.find(".slider-counter .current"); var progress = $sliderContainer.find(".progress"); var updateSliderCounter = function(slick, currentIndex) { currentSlide = slick.slickCurrentSlide() + 1; slidesCount = slick.slideCount; sliderCounter.text("0" + slidesCount); activeSlideNum.text("0" + currentSlide); }; $slider.on('init', function(event, slick) { updateSliderCounter(slick); }); $slider.on('afterChange', function(event, slick, currentSlide) { updateSliderCounter(slick, currentSlide); }); $slider.on("beforeChange", function (event, slick, currentSlide, nextSlide) { var oo = 100 / slick.slideCount; progress .css("background-size", (nextSlide + 1) * oo + "% 100%") .attr("aria-valuenow", nextSlide * oo); }); } }); }, loader: function() { setTimeout(function() { $('body').addClass('loaded'); }, 3500); }, video_modal: function() { $(document).on("click", ".video-gallery .video-item", function() { $("#video-modal .modal-body").empty(); var video_path = $(this).attr("data-video-path"); $("#video-modal .modal-header h4").text($(this).attr("data-video-title")); if ($(this).attr("data-type") == "iframe") { $("#video-modal .modal-body").append(''); } else { $("#video-modal .modal-body").append(''); $("#video-modal .modal-body video").trigger('play'); } $("#video-modal").modal("show"); }); $("#video-modal").on('hidden.bs.modal', function() { var modal_body = document.getElementById('video-modal').getElementsByClassName('modal-body')[0] for (let child of modal_body.children) { modal_body.removeChild(child); } }); }, // selectpicker selectpicker: function() { $.fn.selectpicker.Constructor.BootstrapVersion = '4'; if (/Android|webOS|iPhone|BlackBerry/i.test(navigator.userAgent)) { $.fn.selectpicker.Constructor.DEFAULTS.mobile = true; } moci.settings.selectpicker.selectpicker({ container: 'body', size: 8, liveSearchPlaceholder: 'Search' }); }, utilities: function() { AOS.init({ delay: 100, // values from 0 to 3000, with step 50ms duration: 900, // values from 0 to 3000, with step 50ms }); $(".toggler-filter.on-991 .nav-link").on("click", function(e) { if ($(window).width() <= 991) { $(this).closest('.toggler-filter.on-991').find(".nav-tabs").slideToggle("slow"); var title = $(this).text(); $(".toggler-filter-btn").text(title); } }); $(document).click(function(e) { e.stopPropagation(); var container = $(".toggler-filter.on-991"); if ($(window).width() <= 991) { if (!$(".toggler-filter.on-991 .nav-tabs").is(":hidden")) { } } }); $('.main-banner__slider').on('beforeChange', function(event, slick, currentSlide, nextSlide){ // Pause the video in the current slide var currentVideo = $(slick.$slides[currentSlide]).find('video'); if (currentVideo.length) { currentVideo.get(0).pause(); } }); $('.main-banner__slider').on('afterChange', function(event, slick, currentSlide){ // Play the video in the new slide var newVideo = $(slick.$slides[currentSlide]).find('video'); if (newVideo.length) { newVideo.get(0).play(); } }); $('.media-sec a[data-toggle="tab"]').on('shown.bs.tab', function(e) { $(".media-sec .slick-slider").slick('setPosition', 0); }); $('.e-services__filters form').on('focus blur keyup', '.form-control:not([required])', function(e) { e.preventDefault(); if ($(this).val().length) { $('.e-services__filters .input-wrapper').addClass('valid-text'); } else { $('.e-services__filters .input-wrapper').removeClass('valid-text'); } }); /* clear text */ $('.e-services__filters form').on('click', '.clear', function(e) { e.preventDefault(); $(this).prev('input').val(''); $('.input-wrapper').removeClass('valid-text'); return false; }); $(".rating-fixed").starRating({ totalStars: 5, emptyColor: "#BEBEBE", hoverColor: "#2283C4", activeColor: "#2283C4", initialRating: 5, strokeWidth: 0, useGradient: false, // disableAfterRate: false, minRating: 1, readOnly: true, starSize: 25, }); //slick slider moci.settings.slick.slick(); // mCustomScrollbar moci.settings.innerscroll.mCustomScrollbar(); // $(".footer-heading").on("click", function(e) { // e.preventDefault(); // if ($(window).width() <= 768) { // $(this).parent().toggleClass("active"); // $(this).parent().find("ul").slideToggle(); // } // }); $(".footer-menu .toggle-filter-btn").on("click", function(e) { e.preventDefault(); if ($(window).width() <= 768) { $(this).parent().toggleClass("active"); $(this).parent().find("ul").slideToggle(); } }); let cur_path = window.location.toString(); if (cur_path.includes("/ar/")) { $('.data-table').DataTable({ language: { search: "بحث :", lengthMenu: "عرض _MENU_ سجلات", info: "عرض _START_-_END_ من _TOTAL_ سجلات", paginate: { previous: "السابق", next: "التالي", }, } }); } else { $('.data-table').DataTable(); } if ($(window).width() >= 991) { $('header nav li.has-submenu').hover(function() { // Add the class .open and show the menu $(this).addClass('active'); }, function() { // Sets the timer variable to run the timeout delay timer = setTimeout(function() { // remove the class .open and hide the submenu $('header nav li.has-submenu').removeClass("active"); }, 300); }); } }, // modal configureModal: function() { $("body").on("click", "*[data-toggle='custom-modal']", function(e) { e.preventDefault(); $(".custom-modal").removeClass("large"); var url = $(this).attr("data-path"); var size = $(this).attr("data-size"); var class_name = $(this).attr("data-class"); $(".custom-modal").removeClass("large"); $(".custom-modal").removeClass("medium"); $(".custom-modal").removeClass("small"); $.get(url, function(data) { $(".custom-modal").modal("show"); $(".custom-modal .modal-body").html(data); if (size) { $(".custom-modal").addClass(size); } if (class_name) { $(".custom-modal").addClass(class_name); } setTimeout(function() { $(".custom-modal .modal-body").addClass("show"); }, 200); $("body").addClass("remove-scroll"); }); }); $(".modal").on("hidden.bs.modal", function() { $(".custom-modal .modal-body").removeClass("show"); $(".custom-modal .modal-body").empty(); $(".custom-modal").removeClass("account-modal"); $("body").removeClass("remove-scroll"); $(".custom-modal").removeClass("large"); $(".custom-modal").removeClass("medium"); $(".custom-modal").removeClass("small"); }); }, }; var lazyload = { load: function(wrapper, dataURL) { $(".marker-end") .on('lazyshow', function() { if ($("#loadmorecount").val() < 3) { $.ajax({ url: dataURL, dataType: "html", success: function(responseText) { setTimeout(function() { if (responseText != "") { $(wrapper).append($.parseHTML(responseText)); $(window).lazyLoadXT(); $('.marker-end').lazyLoadXT({ visibleOnly: false, checkDuplicates: false }); } else { $('.marker-end').hide(); } }, 700); }, complete: function() { $("#loadmorecount").val(parseInt($("#loadmorecount").val()) + 1); } }) } else { $('.marker-end').hide(); } }) .lazyLoadXT({ visibleOnly: false }); } };