PageSourceSearch

https://motiversity.com/wp-content/themes/motivation2stady/scripts/develop/index.js

js motiversity.com collected 2026-10-02 06:52:35 UTC 12,622 bytes, 471 lines download raw bytes

1const openMenu  = () =>{
2    $('.header__burger').toggleClass("header__burger-open");
3    $('.header__menu').toggleClass('header__menu-show')
4    $('section').toggleClass('hideSection')
5};
6
7
8const Drop = () =>{
9    function handleOpenClose(e){
10        $(this).next('.header__button-drop').slideToggle();
11    }
12    $(document).on('click', '.header__button', handleOpenClose)
13
14    $(document).click(function(e) {
15        let target = e.target;
16        if (!$(target).is('.header__button') && !$(target).parents().is('.header__button'))
17        { $('.header__button-drop').slideUp(); }
18    });
19};
20
21const filterActive=()=>{
22    $('.speeches__filter a').click(function(){
23        $('.speeches__filter a').removeClass("speeches__filter-active");
24        $(this).addClass("speeches__filter-active");
25    });
26}
27
28const changeBlock=()=>{
29    if(!$('.creative img').length){
30        $('.project__container').css("padding-bottom", "5rem");
31    }
32}
33
34const playVideo = () => {
35    $('.video__poster').click(function(){
36        let video = '<iframe allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" frameBorder="0" src="'+ $(this).attr('data-video') +'" title="'+ $(this).attr('data-title') +'"></iframe>';
37        $(this).next(".video__info").hide()
38        $(this).replaceWith(video);
39
40    });
41}
42
43
44const validateForm = (modal,form) => {
45    $.validator.addMethod("goodEmail", function(value, element) {
46        return this.optional(element) || /^([a-z0-9_-]+\.)*[a-z0-9_-]+@[a-z0-9_-]+(\.[a-z0-9_-]+)*\.[a-z]{2,6}$/i.test(value);
47    }, "Enter valid email");
48
49    $.validator.addMethod("goodName",function(value,element) {
50        return this.optional(element) || /^[a-zA-Z0-9._-]{2,30}$/i.test(value);
51    },"Enter a valid name");
52
53    form.validate({
54        rules: {
55            name: {
56                required: true,
57                goodName: true,
58                minlength: 2
59            },
60            email: {
61                required:true,
62                goodEmail: true,
63                email: true
64            },
65        },
66        messages: {
67            name: {
68                required: "This field is required",
69                minlength: "Name can't be shorter than 2 characters"
70            },
71            email: {
72                required: "This field is required",
73                email: "Please input the correct Email"
74            }
75        },
76        submitHandler: function () {
77            modal.fancybox();
78            modal.trigger('click');
79            form[0].reset();
80        }
81    });
82}
83
84
85
86const accordion  = () =>{
87    function handleOpenCloseAcc(e){
88        if(!$(this).next().hasClass('show')){
89            return $(this).next().addClass("show");
90        }
91
92        if($(this).next().hasClass('show')) {
93            $(this).next().removeClass("show");
94            return $('.header__drop-right').removeClass("show");
95        }
96    }
97    $(document).on('click', '.drop__toggle', handleOpenCloseAcc)
98}
99
100
101
102// let speechesIndex = 20;
103// const speechesShow=()=> {
104//     let i=0;
105//     $('.speeches__item').css('display','none')
106//     $('.speeches__item').each(function(){
107//         if(i<20){
108//             $(this).css('display','block')
109//         }
110//         i++;
111//
112//         // console.log ($(this));
113//     });
114//
115//     $('.load').click(function (){
116//         i=0;
117//         speechesIndex+=20;
118//         $('.speeches__item').each(function(){
119//             console.log(i, speechesIndex)
120//             if(i<speechesIndex){
121//                 $(this).css('display','block')
122//             }
123//             i++;
124//         });
125//
126//     })
127// }
128
129
130
131
132
133const ajaxGetPosts =(obj)=>{
134    $.ajax({
135        type: 'POST',
136        url: '/wp-admin/admin-ajax.php',
137        dataType: 'html',
138        data: obj,
139        success: function (res) {
140            let loadMoreBtn;
141
142            $('.load').remove();
143            $('.speeches__list').append(res);
144            loadMoreBtn = $('.speeches__list').find('.load').clone(true);
145            $('.speeches__list').find('.load').remove();
146            loadMoreBtn.appendTo('.speeches__container');
147        }
148    });
149}
150
151const booknow = () => {
152    
153
154    $("body").on('click','.closeit',function(){
155        $('.addclass').addClass('dnone')
156    });
157    $(".booknowformsubmit").submit(function (event) {
158        event.preventDefault();
159
160        const name = $('.name').val();
161        const email = $('.email').val();
162        const description = $('.description').val();
163        const formData = new FormData(this)
164        //const obj = { name: name, email: email,  description: description, action: 'booknow' }
165        $.ajax({
166            type: "POST",
167            url: '/wp-admin/admin-ajax.php',
168            data: formData,
169            contentType: false,
170            cache: false,
171            processData: false,
172            beforeSend: function () {
173                $('.spinner').addClass('displayblock')
174                $('.spinner').removeClass('displaynone')
175            },
176            success: function (data) {
177                $('.spinner').addClass('displaynone')
178                $('.spinner').removeClass('displayblock')
179                $('.booknowformsubmit')[0].reset();
180                $('.addclass').removeClass('dnone')
181                $('html,body').animate({
182                    scrollTop: $('.addclass').offset().top
183                },'slow');
184                 
185               
186            },
187        })
188
189        
190    });
191}
192
193
194const loadMore = () =>{
195    const urlParams = new URLSearchParams(window.location.search);
196    const sort = urlParams.get('sort_by');
197    const search = urlParams.get('s');
198
199    // const obj = {sort_by:sort, s:search, page:1, action:'loadmore'}
200    // ajaxGetPosts(obj);
201    let currentPage = 1;
202    $(document).on('click', '.load', function () {
203        currentPage++;
204        const obj = {sort_by:sort, s:search, page:currentPage, action:'loadmore'}
205        ajaxGetPosts(obj);
206    })
207}
208     // Do currentPage + 1, because we want to load the next page
209
210
211// });
212
213function removeImg( wrap){
214    wrap.each(function(){
215        if($(this).find('img').attr('src')===''){
216            $(this).hide();
217        }
218        $(this).closest('.similar__item').css('justify-content','flex-end')
219    })
220}
221
222// function removeImgSimilar( wrap){
223//     wrap.each(function(){
224//         if($(this).find('img').attr('src')===''){
225//             $(this).hide();
226//         }
227//         $(this).closest('.similar__item').css('justify-content','flex-end')
228//     })
229// }
230
231
232const sliderPosts = () => {
233    if (window.innerWidth <= 666) {
234        $(".posts__list").addClass('posts__slider');
235        console.log('dsfdsfsd')
236    }
237    $(".posts__slider").slick({
238        arrows: true,
239        slidesToShow: 1,
240        prevArrow: '<button class="slick-previous"></button>',
241        nextArrow: '<button class="slick-nextt"></button>',
242    });
243}
244
245const sliderYoutube = () => {
246    console.log($('.youtube__item').length)
247    if ($('.youtube__item').length>3){
248        $('.youtube__list').slick({
249            arrows : true,
250            slidesToShow: 3,
251            slidesToScroll: 1,
252            infinite: false,
253            autoplay:true,
254            autoplaySpeed:3000,
255
256            prevArrow: '<button class="slick-previous"></button>',
257            nextArrow: '<button class="slick-nextt"></button>',
258            responsive: [
259                {
260                    breakpoint: 666,
261                    settings: {
262                        slidesToShow: 1,
263                    }
264                },
265            ]
266        });
267    }
268    // if (window.innerWidth <= 666) {
269    //     $('.youtube__list').slick({
270    //         arrows : true,
271    //         slidesToShow: 1,
272    //         slidesToScroll: 1,
273    //         autoplay:true,
274    //         autoplaySpeed:3000,
275    //         infinite: false,
276    //         prevArrow: '<button class="slick-previous"></button>',
277    //         nextArrow: '<button class="slick-nextt"></button>',
278    //     });
279    // }
280}
281
282
283function sliderListen() {
284
285    $('.listen .listen__list').slick({
286        arrows : true,
287        slidesToShow: 6,
288        slidesToScroll: 1,
289        infinite: false,
290
291        prevArrow: '<button class="slick-previous"></button>',
292        nextArrow: '<button class="slick-nextt"></button>',
293        responsive: [
294            {
295                breakpoint: 666,
296                settings: {
297                    slidesToShow: 2,
298
299                }
300            },
301            {
302                breakpoint: 425,
303                settings: {
304                    slidesToShow: 1,
305
306                }
307            },
308        ]
309    });
310}
311
312
313    $('.youtube-link .listen__list').slick({
314        arrows : true,
315        slidesToShow: 3,
316        slidesToScroll: 1,
317        infinite: true,
318        autoplay:true,
319        autoplaySpeed:3000,
320
321        prevArrow: '<button class="slick-previous"></button>',
322        nextArrow: '<button class="slick-nextt"></button>',
323        responsive: [
324            {
325                breakpoint: 666,
326                settings: {
327                    slidesToShow: 2,
328
329                }
330            },
331            {
332                breakpoint: 425,
333                settings: {
334                    slidesToShow: 1,
335
336                }
337            },
338        ]
339    });
340
341
342
343const sliderShop = () => {
344    console.log($('.shop__item').length)
345    if ($('.shop__item').length>4) {
346        $('.shop__list').slick({
347            arrows: true,
348            slidesToShow: 4,
349            slidesToScroll: 1,
350            infinite: true,
351            autoplay:true,
352            autoplaySpeed:3000,
353            prevArrow: '<button class="slick-previous"></button>',
354            nextArrow: '<button class="slick-nextt"></button>',
355            responsive: [
356                {
357                    breakpoint: 666,
358                    settings: {
359                        slidesToShow: 1,
360                    }
361                },
362                {
363                    breakpoint: 425,
364                    settings: {
365                        slidesToShow: 1,
366                        slidesToScroll: 1,
367                    }
368                },
369            ]
370
371
372        });
373    }
374    // if (window.innerWidth <= 666) {
375    //     console.log('shopppppppp-list')
376    //     $('.shop__list').slick({
377    //         arrows : true,
378    //         slidesToShow: 2,
379    //         slidesToScroll: 1,
380    //         infinite: false,
381    //         prevArrow: '<button class="slick-previous"></button>',
382    //         nextArrow: '<button class="slick-nextt"></button>',
383    //         responsive: [
384    //             {
385    //                 breakpoint: 425,
386    //                 settings: {
387    //                     slidesToShow: 1,
388    //
389    //                 }
390    //             },
391    //         ]
392    //     });
393    // }
394}
395
396
397const sliderBrands = () => {
398    console.log('brands ',$('.brands__item').length)
399
400    if (window.innerWidth <= 666) {
401        $('.brands__list').slick({
402            arrows : true,
403            slidesToShow: 2,
404            slidesToScroll: 1,
405            infinite: false,
406            prevArrow: '<button class="slick-previous"></button>',
407            nextArrow: '<button class="slick-nextt"></button>',
408            responsive: [
409                {
410                    breakpoint: 480,
411                    settings: {
412                        slidesToShow: 1,
413                        arrows: true,
414                    }
415                },
416            ]
417        });
418    }
419    if ($('.brands__item').length > 7 && window.innerWidth > 666 ) {
420        $('.brands__list').slick({
421            arrows: false,
422            slidesToShow: 7,
423            slidesToScroll: 3,
424            autoplay:true,
425            autoplaySpeed:3000,
426            infinite: true,
427            prevArrow: '<button class="slick-previous"></button>',
428            nextArrow: '<button class="slick-nextt"></button>',
429
430        });
431
432
433    }
434
435}
436// if (window.innerWidth <= 666) {
437//     $(".listen__list").addClass('listen__slider');
438//     console.log('sssssssssssssssssssssss')
439// }
440
441$(document).ready(function(){
442    accordion();
443    filterActive();
444    Drop();
445    playVideo();
446    changeBlock();
447    sliderYoutube();
448    // sliderYoutubeLink();
449    sliderBrands();
450    sliderPosts();
451    sliderShop();
452    loadMore()
453    booknow()
454    removeImg($('.quotes__img'));
455    removeImg($('.similar__img'));
456    // speechesShow();
457    $('.header__burger').on('click', openMenu);
458});
459
460$(window).load(function(){
461
462    let formSubs = $('.sign__form'),
463        modalSubs = $('.sign__modal')
464    validateForm(modalSubs,formSubs);
465    sliderListen();
466
467});
468
469$(window).resize(function(){
470
471});

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.