PageSourceSearch

https://www.kingmechpump.com/static/template/js/common2.js

js kingmechpump.com collected 2026-10-07 13:08:52 UTC 21,867 bytes, 539 lines download raw bytes

1
2// 初始化wow
3new WOW().init();
4
5$('.head_nav li').each(function () {
6    if ($(this).find('ul').length > 0) {
7        $(this).children('a').append("<b></b>");
8        $(this).addClass('has-child');
9    }
10})
11$('.foot_item_link li').each(function () {
12    if ($(this).find('ul').length > 0) {
13        $(this).children('a').append("<b></b>");
14        $(this).addClass('has-child');
15    }
16})
17// Navigation dropdown menu
18dropMenu('.head_nav li', 'ul', 0, 'menu_show');
19dropMenu('.foot_item_link li', 'ul', 0, 'menu_show');
20
21$(function () {
22    // 监听滚动事件
23    $(window).scroll(function () {
24        if ($(this).scrollTop() > 50) {
25            $('.web_head').addClass('fixed')
26            $('.web_head').css('position', 'fixed')
27        } else {
28            $('.web_head').removeClass('fixed')
29            $('.web_head').css('position', 'relative')
30
31
32        }
33    });
34});
35
36function goTop() {
37    $("html, body").animate({
38        scrollTop: 0
39    }, 600)
40}
41
42
43// get window size
44var winWidth = 0;
45var winHeight = 0;
46
47function getWinSize() {
48    if (window.innerWidth) {
49        winWidth = window.innerWidth;
50    } else if ((document.body) && (document.body.clientWidth)) {
51        winWidth = document.body.clientWidth;
52    }
53    if (window.innerHeight) {
54        winHeight = window.innerHeight;
55    } else if ((document.body) && (document.body.clientHeight)) {
56        winHeight = document.body.clientHeight;
57    }
58    if (document.documentElement && document.documentElement.clientHeight && document.documentElement.clientWidth) {
59        if (window.innerWidth && window.innerHeight) {
60            winWidth = window.innerWidth;
61            winHeight = window.innerHeight;
62        } else {
63            winHeight = document.documentElement.clientHeight;
64            winWidth = document.documentElement.clientWidth;
65        }
66    }
67}
68
69getWinSize();
70
71console.log(winHeight);
72
73
74$(document).ready(function () {
75    $('.change-language .change-language-cont').append("<div class='change-empty'>Untranslated</div>")
76    $('.prisna-wp-translate-seo').append("<div class='lang-more'>More Language</div>")
77    if ($('body .prisna-wp-translate-seo').length > 0 && $('.change-language .prisna-wp-translate-seo').length < 1) {
78        $('.prisna-wp-translate-seo').appendTo('.change-language .change-language-cont')
79        if ($('.change-language .change-language-cont .prisna-wp-translate-seo li').length > 0) {
80            $('.change-language .change-language-cont .change-empty').hide()
81            $('.change-language .change-language-cont .prisna-wp-translate-seo li').each(function (index) {
82                if (index > 35) {
83                    $(this).addClass('lang-item lang-item-hide')
84                    $('.change-language-cont').find('.lang-more').fadeIn()
85                } else {
86                    $('.change-language-cont').find('.lang-more').fadeOut()
87                }
88            })
89            if ($('.change-language-cont .lang-more').length > 0) {
90                $('.change-language-cont .lang-more').click(function () {
91                    if ($(this).parents('.change-language-cont').find('.prisna-wp-translate-seo li.lang-item').hasClass('lang-item-hide')) {
92                        $(this).parents('.change-language-cont').find('.prisna-wp-translate-seo li.lang-item').removeClass('lang-item-hide')
93                        $(this).text('×')
94                    } else {
95                        $(this).parents('.change-language-cont').find('.prisna-wp-translate-seo li.lang-item').addClass('lang-item-hide')
96                        $(this).text('More Language')
97                    }
98                })
99            }
100        } else {
101            $('.change-language .change-language-cont .change-empty').fadeIn()
102        }
103    }
104})
105
106/*search*/
107document.documentElement.className = 'js';;
108(function (window) {
109    if (document.querySelector('.web-search')) {
110        'use strict';
111        var mainContainer = document.querySelector('body'),
112            searchContainer = document.querySelector('.web-search'),
113            openCtrl = document.getElementById('btn-search'),
114            closeCtrl = document.getElementById('btn-search-close'),
115            inputSearch = searchContainer.querySelector('.search-ipt');
116
117        function init() { initEvents() }
118
119        function initEvents() {
120            openCtrl.addEventListener('click', function () { if (!searchContainer.classList.contains("search--open")) {
121                console.log(111111111111111111111111111111);
122                 openSearch();
123                 } else { closeSearch(); } });
124            closeCtrl.addEventListener('click', closeSearch);
125            document.addEventListener('keyup', function (ev) { if (ev.keyCode == 27) { closeSearch() } })
126        }
127
128        function openSearch() {
129            mainContainer.classList.add('main-wrap--move');
130            searchContainer.classList.add('search--open');
131            setTimeout(function () { inputSearch.focus() }, 600)
132            
133            
134        }
135
136        function closeSearch() {
137            mainContainer.classList.remove('main-wrap--move');
138            searchContainer.classList.remove('search--open');
139            inputSearch.blur();
140            inputSearch.value = ''
141        }
142        init()
143    }
144})(window);
145
146
147
148
149
150
151
152function mSizeChange() {
153    getWinSize();
154    // console.log(winWidth);
155
156    if (winWidth <= 950) {
157        if ($('.mobile-head-items').length < 1) {
158            var mobileService = '<div class="mobile-head-items"> <div class="flex">  <div class="mobile-head-item mobile-head-search"> <div class="title"></div> <div class="main-content-wrap middle-content-wrap"> <div class="content-wrap"></div>   </div></div> <div class="mobile-head-item mobile-head-language"> <div class="title"></div>  <div class="main-content-wrap side-content-wrap"><div class="content-wrap"></div>  </div>  </div>  <div class="mobile-head-item mobile-head-nav">  <div class="title"></div>  <div class="main-content-wrap side-content-wrap">  <div class="content-wrap"></div>  </div>  </div>   </div>'
159            $('.header_layout').append(mobileService)
160            if ($('.header_layout .aside').length > 0) {
161                $('.mobile-head-items').append('<div class="mobile-head-item mobile-head-aside"><div class="title"></div><div class="main-content-wrap side-content-wrap"><div class="content-wrap"></div></div></div>')
162            }
163            $('.mobile-head-item').each(function () {
164                $(this).find('.title').click(function () {
165                    if ($(this).parents('.mobile-head-item').find('.main-content-wrap').length > 0) {
166                        var pItem = $(this).parents('.mobile-head-item')
167                        if (!pItem.find('.main-content-wrap').hasClass('show-content-wrap')) {
168                            pItem.find('.main-content-wrap').addClass('show-content-wrap')
169                            pItem.find('.side-content-wrap').stop().animate({ 'left': '0' }, 300)
170                            pItem.find('.middle-content-wrap').addClass('middle-show-content-wrap')
171                            pItem.find('.side-content-wrap').append("<b class='mobile-ico-close'></b>")
172                            pItem.siblings('.mobile-head-item').find('.main-content-wrap').removeClass('show-content-wrap')
173                            pItem.siblings('.mobile-head-item').find('.side-content-wrap').stop().animate({ 'left': '-70%' }, 300)
174                            pItem.siblings('.mobile-head-item').find('.middle-content-wrap').removeClass('middle-show-content-wrap')
175                            pItem.siblings('.mobile-head-item').find('.side-content-wrap .mobile-ico-close').remove()
176                            if ($('.mobile-head-items').find('.mobile-body-mask').length < 1) {
177                                $('.mobile-head-items').append('<div class="mobile-body-mask"></div>')
178                            }
179                        } else {
180                            pItem.find('.main-content-wrap').removeClass('show-content-wrap')
181                            pItem.find('.side-content-wrap').stop().animate({ 'left': '-70%' }, 300)
182                            pItem.find('.middle-content-wrap').removeClass('middle-show-content-wrap')
183                            pItem.find('.side-content-wrap .mobile-ico-close').remove()
184                        }
185                        $('.mobile-body-mask').click(function () {
186                            $('.mobile-body-mask').remove()
187                            $('.mobile-head-item .main-content-wrap').removeClass('show-content-wrap')
188                            $('.mobile-head-item .side-content-wrap').animate({ 'left': '-70%' }, 300)
189                            $('.mobile-head-item .middle-content-wrap').removeClass('middle-show-content-wrap')
190                            $('.mobile-head-item .side-content-wrap .mobile-ico-close').remove()
191                        })
192                        $('.mobile-ico-close').click(function () {
193                            $('.mobile-body-mask').remove()
194                            $('.mobile-head-item .main-content-wrap').removeClass('show-content-wrap')
195                            $('.mobile-head-item .side-content-wrap').stop().animate({ 'left': '-70%' }, 300)
196                            $('.mobile-head-item .middle-content-wrap').removeClass('middle-show-content-wrap')
197                            $('.mobile-head-item .side-content-wrap .mobile-ico-close').remove()
198                        })
199                    }
200                })
201            })
202            $('.change-currency ').clone().appendTo('.mobile-head-item.mobile-head-currency .main-content-wrap .content-wrap')
203            $('.change-language .change-language-cont').clone().appendTo('.mobile-head-item.mobile-head-language .main-content-wrap .content-wrap')
204            $('.nav_wrap .head_nav').clone().appendTo('.mobile-head-item.mobile-head-nav .main-content-wrap .content-wrap')
205            $('.head-search:last').clone().appendTo('.mobile-head-item.mobile-head-search .main-content-wrap .content-wrap')
206            $('.head_sns').clone().appendTo('.mobile-head-item.mobile-head-social .main-content-wrap .content-wrap')
207            $('.aside .aside-wrap').clone().appendTo('.mobile-head-item.mobile-head-aside .main-content-wrap .content-wrap')
208        }
209    }
210    //mobile end
211    else {
212        $(document).ready(function () {
213            $('.mobile-body-mask,.mobile-head-items,.mobile-head-items,.mobile-nav-items,.mobile-cart-items,.mobile-tab-items').remove()
214        });
215    }
216}
217$(function () { mSizeChange(); })
218$(window).resize(function () { mSizeChange() });
219
220
221
222
223function toggleClass(btn, cont, cName, hName, siblingsStatus) {
224    var $btn = $(btn);
225    var $cont = $(cont);
226    if (siblingsStatus == 0) {
227        $btn.parents(cont).siblings(cont).removeClass(cName).addClass(hName);
228    }
229    if ($btn.parents(cont).hasClass(cName)) {
230        $btn.parents(cont).removeClass(cName).addClass(hName);
231    } else {
232        $btn.parents(cont).addClass(cName).removeClass(hName);
233    }
234}
235
236
237
238
239// dropmenu direction
240$(function () {
241    menuDirection('.head_nav>li');
242    $(window).on('resize', function () {
243        menuDirection('.head_nav>li');
244    })
245})
246$(function () {
247
248    $('body').delegate('.head_nav li b', 'click', function () {
249        var navItem = $(this).closest('li');
250        var navMenu = navItem.children('ul');
251        if (navMenu.is(':hidden')) {
252            navMenu.slideDown(150, function () {
253                navItem.addClass('active');
254            });
255        } else {
256            navItem.removeClass('active');
257            navMenu.slideUp(150);
258        }
259        return false;
260    })
261})
262// dropmenu direction
263$(function () {
264    menuDirection('.foot_item_link>li');
265    $(window).on('resize', function () {
266        menuDirection('.foot_item_link>li');
267    })
268})
269$(function () {
270
271    $('body').delegate('.foot_item_link li b', 'click', function () {
272        var navItem = $(this).closest('li');
273        var navMenu = navItem.children('ul');
274        if (navMenu.is(':hidden')) {
275            navMenu.slideDown(150, function () {
276                navItem.addClass('active');
277            });
278        } else {
279            navItem.removeClass('active');
280            navMenu.slideUp(150);
281        }
282        return false;
283    })
284})
285AddCurrent('.feature_product_item', '.feature_products');
286function AddCurrent(CurrentItem, CurrentParent) {
287    $(CurrentItem).each(function () {
288        $(CurrentParent).children(CurrentItem).eq(0).addClass('current');
289        $(this).hover(function () {
290            $(this).addClass('current');
291            $(this).siblings().removeClass('current');
292        })
293    })
294}
295// set head nav Direction
296function menuDirection(ele) {
297    var winW = $(window).innerWidth();
298    $(ele).each(function () {
299        if ($(this).find('ul').length) {
300            var linkEleW = $(this).children('a').width();
301            var offRight = winW - $(this).offset().left;
302            var childLen = $(this).find('ul').length;
303            var childrenWidth = childLen * 250 + 10;
304            if (offRight < childrenWidth) {
305                $(this).addClass('menu_left');
306            } else {
307                $(this).removeClass('menu_left');
308            }
309        }
310    })
311}
312
313// dropMenu
314function dropMenu(menuItem, menuList, menustatus, showClass) {
315    var mouseover_tid = [];
316    var mouseout_tid = [];
317    if (showClass) {
318        showClass = showClass;
319    }
320    else {
321        showClass = 'active';
322    }
323    $(menuItem).each(function (index) {
324        $(this).hover(
325            function () {
326                var _self = this;
327                clearTimeout(mouseout_tid[index]);
328                mouseover_tid[index] = setTimeout(function () {
329                    if (menustatus == '1') {
330                        $(_self).children(menuList).slideDown(150);
331                    }
332                    $(_self).addClass(showClass);
333                }, 150);
334            },
335            function () {
336                var _self = this;
337                clearTimeout(mouseover_tid[index]);
338                mouseout_tid[index] = setTimeout(function () {
339                    if (menustatus == '1') {
340                        $(_self).children(menuList).slideUp(50);
341                    }
342                    $(_self).removeClass(showClass);
343                }, 150);
344            }
345        );
346    })
347}
348// 点击展开子菜单
349$('.mobile-head-nav').on('click', '.has-child > b', function (e) {
350    e.preventDefault();
351    var $parent = $(this).parent('li');
352    if ($parent.hasClass('menu_show')) {
353        $parent.removeClass('menu_show').find('ul').slideUp(200);
354    } else {
355        $parent.addClass('menu_show').find('ul').slideDown(200);
356        // 关闭其他菜单
357        $parent.siblings('.menu_show').removeClass('menu_show').find('ul').slideUp(200);
358    }
359});
360// 点击展开子菜单
361$('.mobile_foot_wrap').on('click', '.has-child > b', function (e) {
362    e.preventDefault();
363    var $parent = $(this).parent('li');
364    if ($parent.hasClass('menu_show')) {
365        $parent.removeClass('menu_show').find('ul').slideUp(200);
366    } else {
367        $parent.addClass('menu_show').find('ul').slideDown(200);
368        // 关闭其他菜单
369        $parent.siblings('.menu_show').removeClass('menu_show').find('ul').slideUp(200);
370    }
371});
372
373
374
375/*-----------------右侧客服代码-----------------*/
376$(document).ready(function () {
377    $(document).scroll(function () {
378        var topHight = $(document).scrollTop();
379        //height = parseInt($(".slider_banner").css("height"));
380        height = 10
381        if (topHight < height) {
382            $("#index_scrollsidebar").css({ "position": '', "bottom": '', "z-index": '', "visibility": "hidden", "right": "-90px", "opacity": "0" });
383        } else {
384            $("#index_scrollsidebar").css({ "position": "fixed", "bottom": "260px", "z-index": "999999", "visibility": "visible", "right": "20px", "opacity": "1" });
385        }
386    });
387});
388
389
390
391/*------------------右下角表单--------------------------*/
392
393var scrollhright = 0, topscroll = 75
394scrollhright = $('#c_chat_form').height() + 26
395$('#c_chat_form').css("bottom", topscroll - scrollhright)
396$('.t_top').click(function () {
397    scrollhright = $('#c_chat_form').height() + 26
398    if ($('#c_chat_form').hasClass('form-active')) {
399        $('#c_chat_form').css("bottom", topscroll - scrollhright)
400        $('#c_chat_form').removeClass('form-active')
401    } else {
402        $('#c_chat_form').css("bottom", 0)
403        $('#c_chat_form').addClass('form-active')
404    }
405})
406$("#submitF").click(function () {
407    $.post(ajaxurl, $(".c_chat_form").serialize(), function (response) {
408        var res = JSON.parse(response);
409        switch (res.code) {
410            case 0:
411                alert('Information record failed');
412                break;
413            case 2:
414                alert('You have not submitted data');
415                break;
416            case 3:
417                alert('Email and phone cannot be empty at the same time.');
418                break;
419            case 4:
420                alert('The message cannot be empty.');
421                break;
422            default:
423                alert('Submitted successfully, customer service will contact you later.');
424                $(".contact-form")[0].reset();
425        }
426    });
427})
428/*side*/
429function sideCate(cateEle, siblingsStatus) {
430    $(cateEle).each(function () {
431        if ($(this).find('ul').length) {
432            $(this).addClass('haschild');
433            $(this).append("<span class='icon-cate icon-cate-down'></span>")
434            $(this).children('.icon-cate').click(function (e) {
435                var mEle = $(this).parent('li');
436                var mList = $(this).parent('li').children('ul');
437                var msiblings = $(this).parent('li').siblings('li');
438                if (siblingsStatus == 0) {
439                    // msiblings.removeClass('active');
440                    // msiblings.children('ul').slideUp(150);
441                    msiblings.children('.icon-cate').removeClass('icon-cate-up').addClass('icon-cate-down');
442                }
443                if (mList.is(':hidden')) {
444                    mEle.addClass('active');
445                    mList.slideDown(150);
446                    // $(this).removeClass('icon-cate-down').addClass('icon-cate-up');
447                } else {
448                    mEle.removeClass('active');
449                    mList.slideUp(150);
450                    $(this).removeClass('icon-cate-down').addClass('icon-cate-up');
451                }
452                e.stopPropagation();
453            })
454        }
455    })
456}
457$(function () {
458    // side cate
459    sideCate('.side-cate li', 0);
460    $('.side-cate,.side-cate ul').each(function () {
461        if (!$(this).find('ul').length) {
462            $(this).addClass('cate-type-list');
463        }
464    })
465    var $currentEle = $('.side-widget .side-cate .nav-current');
466    if ($currentEle.parents('ul').length > 0 && $currentEle.find('ul').length > 0) {
467        $currentEle.parents('ul').show()
468        $currentEle.parents('li').addClass("show_li")
469        $currentEle.parents('li.show_li').children('.icon-cate').removeClass('icon-cate-down').addClass('icon-cate-up')
470        $currentEle.children('ul').show()
471        $('.side-widget .side-cate .nav-current ').children('.icon-cate').removeClass('icon-cate-down').addClass('icon-cate-up');
472    } else if ($currentEle.parents('ul').length > 0 && $currentEle.find('ul').length < 1) {
473        $currentEle.parents('ul').show()
474        $currentEle.parents('li').addClass("show_li")
475        $currentEle.parents('li.show_li').children('.icon-cate').removeClass('icon-cate-down').addClass('icon-cate-up')
476    } else if ($currentEle.parents('ul').length < 1 && $currentEle.find('ul').length > 0) {
477        $currentEle.children('ul').show()
478        $currentEle.children('.icon-cate').removeClass('icon-cate-down').addClass('icon-cate-up');
479    }
480})
481
482
483/*----------------------------------------------------
484                            index
485------------------------------------------------------*/
486
487/*Swiper Banner*/
488if ($('.swiper-wrapper .swiper-slide').length < 2) {
489    $('.swiper-pagination').hide()
490}
491var bannnerPcSwiper = new Swiper('#pc', {
492    loop:true,
493    speed: 1000,
494    autoplay: {
495        delay: 3500,
496        disableOnInteraction: false,
497    },
498    pagination: {
499        el: ".swiper-pagination",
500        clickable: true,
501        renderBullet: function (index, className) {
502            return '<span class="' + className + '">' + 0 + (index + 1) + "</span>";
503        },
504    },
505    navigation: {
506        nextEl: '.swiper-button-next',
507        prevEl: '.swiper-button-prev',
508    },
509})
510var bannerSwiper = new Swiper('#sj', {
511})
512
513var experienceSwiper = new Swiper(".experience-mySwiper", {
514    loop:true,
515    speed: 1000,
516    autoplay: {
517        delay: 3500,
518        disableOnInteraction: false,
519    },
520    pagination: {
521        el: ".swiper-pagination",
522        clickable: true,
523    },
524});
525
526
527var solutionsSwiper = new Swiper(".solutions_mySwiper", {
528    slidesPerView:3,
529    spaceBetween: 30,
530    navigation: {
531        nextEl: ".swiper_box .solutions-button-next",
532        prevEl: ".swiper_box .solutions-button-prev",
533    },
534    breakpoints: {
535        950: {
536            slidesPerView: 1,
537            spaceBetween: 30,
538        }}
539});

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.