PageSourceSearch

https://www.yonex.cn/public/home/js/lib.js

js yonex.cn collected 2026-10-04 18:44:36 UTC 12,837 bytes, 332 lines download raw bytes

1// 前端模板
2! function(a) {
3    "use strict";
4    var b = function(a, c) {
5        var d = /[^\w\-\.:]/.test(a) ? new Function(b.arg + ",tmpl", "var _e=tmpl.encode" + b.helper + ",_s='" + a.replace(b.regexp, b.func) + "';return _s;") : b.cache[a] = b.cache[a] || b(b.load(a));
6        return c ? d(c, b) : function(a) {
7            return d(a, b)
8        }
9    };
10    b.cache = {}, b.load = function(a) {
11        return document.getElementById(a).innerHTML
12    }, b.regexp = /([\s'\\])(?!(?:[^{]|\{(?!%))*%\})|(?:\{%(=|#)([\s\S]+?)%\})|(\{%)|(%\})/g, b.func = function(a, b, c, d, e, f) {
13        return b ? {
14            "\n": "\\n",
15            "\r": "\\r",
16            "	": "\\t",
17            " ": " "
18        } [b] || "\\" + b : c ? "=" === c ? "'+_e(" + d + ")+'" : "'+(" + d + "==null?'':" + d + ")+'" : e ? "';" : f ? "_s+='" : void 0
19    }, b.encReg = /[<>&"'\x00]/g, b.encMap = {
20        "<": "&lt;",
21        ">": "&gt;",
22        "&": "&amp;",
23        '"': "&quot;",
24        "'": "&#39;"
25    }, b.encode = function(a) {
26        return (null == a ? "" : "" + a).replace(b.encReg, function(a) {
27            return b.encMap[a] || ""
28        })
29    }, b.arg = "o", b.helper = ",print=function(s,e){_s+=e?(s==null?'':s):_e(s);},include=function(s,d){_s+=tmpl(s,d);}", "function" == typeof define && define.amd ? define(function() {
30        return b
31    }) : a.tmpl = b
32}(this);
33// 迷你发布订阅系统
34(function($) {
35    var o = $({});
36    $.subscribe = function() {
37        o.on.apply(o, arguments);
38    };
39    $.unsubscribe = function() {
40        o.off.apply(o, arguments);
41    };
42    $.publish = function() {
43        o.trigger.apply(o, arguments);
44    };
45}($));
46
47$(function() {
48    'use strict';
49    var win = window;
50    win.GLOBAL = win.GLOBAL || {};
51    win.hr = win.hr || {};
52
53    win.hr.version = '1.6.12';
54    win.hr.page = win.hr.page || {};
55    win.hr.component = win.hr.component || {};
56
57    /**
58     * @description 注册组件
59     * @param {String} name 组件名字
60     * @param {Object} obj 组件 Javascript 逻辑,JSON 格式
61     * @return {Object} 返回 window.hr.component 对象
62     * @example
63     * hr.regComponent('组件名', {
64     *     init: function () { // 此 init 方法为必需,组件注册后会执行的方法
65     *         this.someAction();
66     *     },
67     *     someAction: function () {
68     *         // 组件 Javascript 逻辑,可以根据需要写多个 Function
69     *     }
70     * });
71     * 组件注册后如果要再次调用,可以用 hr.component.组件名 获取组件对象
72     */
73    win.hr.regComponent = function(name, obj) {
74        if (typeof name == 'string' && name !== '') {
75            win.hr.util._createNamespace(name.split('.'), obj, win.hr.component);
76        }
77    };
78
79    /**
80     * @description 注册页面
81     * @param {String} name 页面名字
82     * @param {Object} obj 页面 Javascript 逻辑,JSON 格式
83     * @return {Object} 返回 window.hr.page 对象
84     * @example
85     * hr.regPage('页面名', {
86     *     init: function () { // 此 init 方法为必需,组件页面后会执行的方法
87     *         this.someAction();
88     *     },
89     *     someAction: function () {
90     *         // 页面 Javascript 逻辑,可以根据需要写多个 Function
91     *     }
92     * });
93     * 页面注册后如果要再次调用,可以用 hr.page.页面名 获取页面对象
94     */
95    win.hr.regPage = function(name, obj) {
96        if (typeof name == 'string' && name !== '') {
97            win.hr.util._createNamespace(name.split('.'), obj, win.hr.page);
98        }
99    };
100
101    win.hr.util = {
102        /**
103         * @description 渲染模板
104         * @param {JSON} opt 包含以下内容
105         * @param {String} opt.tmpl 模板区域的 ID 名
106         * @param {Object} opt.data 要渲染的 JSON 数据
107         * @param {Object} opt.to 要追加进的 jQuery DOM 对象
108         * @param {Object} opt.insertTo 要插入到其之前或之后的 jQuery DOM 对象
109         * @param {String}
109 opt.method 渲染的方式,包括 replace、append 和 prepend,当同时有 insertTo 时,是以 insertTo 为基准
110         * @param {Function} opt.callbackFn 回调函数
111         */
112        renderTmpl: function(opt) {
113            var strTargetTmpl = opt.tmpl || '';
114            var jsonData = opt.data || {};
115            var $target = opt.to;
116            var method = opt.method || 'append';
117            var $insertTo = opt.insertTo || null;
118            if ($target) {
119                var tmpled = tmpl(strTargetTmpl, jsonData);
120                switch (method) {
121                    case 'replace':
122                        $target.html(tmpled);
123                        break;
124                    case 'append':
125                        if ($insertTo) {
126                            $(tmpled).insertAfter($insertTo);
127                        } else {
128                            $target.append(tmpled);
129                        }
130                        break;
131                    case 'prepend':
132                        if ($insertTo) {
133                            $(tmpled).insertBefore($insertTo);
134                        } else {
135                            $target.prepend(tmpled);
136                        }
137                        break;
138                    default:
139                        break;
140                }
141            }
142            $.isFunction(opt.callbackFn) && opt.callbackFn();
143        },
144        /**
145         * @description 从 URL 中获取指定参数值
146         * @param {String} str 要从 URL 中获取的参数值
147         */
148        getUrlParam: function(str) {
149            var s = location.search;
150            var tmp = [];
151            var value = '';
152            if (s) {
153                tmp = s.substr(1).split('&');
154            }
155            for (var i = 0; i < tmp.length; i++) {
156                if (tmp[i].substring(0, tmp[i].indexOf('=')) === str) {
157                    value = tmp[i].substr(tmp[i].indexOf('=') + 1);
158                    break;
159                }
160            }
161            return value;
162        },
163        /**
164         * @description 使用 rem 单位时自动计算 html 初始字体尺寸。比如设计稿是 750px 的,那么对应的 1rem 就等于 100px;如果设计稿是非标准尺寸,比如 844px,那么可以传入参数 baseWidth 844,这样可以保证 1rem 等于 100px,便于计算。
165         * @param {Number} baseWidth 基准尺寸
166         */
167        resizePage: function(baseWidth) {
168            var baseW = baseWidth || 750;
169            var docEl = document.documentElement,
170                resizeEvt = 'orientationchange' in win ? 'orientationchange' : 'resize',
171                recalc = function() {
172                    var clientWidth = docEl.clientWidth;
173                    if (!clientWidth) {
174                        return;
175                    }
176                    if (clientWidth > baseW) {
177                        clientWidth = baseW;
178                    }
179                    docEl.style.fontSize = 100 * (clientWidth / baseW) + 'px';
180                };
181            if (!document.addEventListener) {
182                return;
183            }
184            win.addEventListener(resizeEvt, recalc, false);
185            recalc();
186        },
187        /**
188         * @description 内部方法,创建一个命名空间
189         */
190        _createNamespace: function(parts, obj, parent) {
191            var obj = obj || {
192                init: function() {}
193            };
194            var i = 0;
195            if (parts[0] === 'hr') {
196                parts = parts.slice(1);
197            }
198            for (i = 0; i < parts.length; i++) {
199                if (typeof parent[parts[i]] == 'undefined') {
200                    parent[parts[i]] = obj;
201                    // 组件或页面注册后执行
202                    obj.init();
203                }
204                parent = parent[parts[i]];
205            }
206        },
207
208        moNav: function() {
209            $('body').on('click', '.mo-open', function() {
210                $('.mo-menu').addClass('open')
211            }).on('click', '.js-close', function() {
212                $('.mo-menu').removeClass('open')
213            }).on('click', '.mo-nav .v1', function() {
214                // $(this).toggleClass('active').siblings('.con').stop().slideToggle().parent('li').siblings('li').find('.v1').removeClass('active').siblings('.con').stop().slideUp()
215                $(this).find('.con').stop().slideToggle().parent('li').siblings('li').find('.con').stop().slideUp();
216            });
217        },
218        weixinPop: function() {
219            $('body').on('click', '.js-weixin', function() {
220                $('.pop-mask, .pop-eq').stop().fadeIn();
221            }).on('click', '.weixin-btn', function() {
222                $('.pop-mask, .pop-eq').stop().fadeOut();
223            })
224        },
225        popWait: function() {
226            $('body').on('click', '.js_wait', function() {
227                $('.pop-wait').fadeIn();
228                var t = setTimeout(function() {
229                    $('.pop-wait').fadeOut();
230                }, 2000)
231            })
232        },
233        videoPlay: function() {
234            $('body').on('click', '.js_play', function() {
235                $(this).hide();
236                $('#video1').attr('controls', true);
237                $('#video1')[0].play();
238            })
239        },
240        brJs: function() {
241            var _width = $(window).width();
242            if (_width < 768) {
243                $('.z-tab322 li:eq(4)').after('<br>')
244            }
245        },
246        navHover: function() {
247            $('.nav').hover(function() {
248                $('.page-shadow').stop().fadeIn(200);
249            }, function() {
250                $('.page-shadow').stop().fadeOut(200);
251                $('.menu-modal-right').css('display', 'none');
252            });
253
254            $('.nav > li').hover(
255                function() {
256                    $(this).addClass('hover');
257                    $(this).children('.nav_child').stop().fadeIn();
258                },
259                function() {
260                    $(this).removeClass('hover');
261                    $(this).children('.nav_child').stop().fadeOut();
262                    var $right = $(this).parent().parent().parent().parent().find('.nav-child-right');
263                    $right.fadeOut(200);
264                }
265            );
266            $('.left-nav>li>a').hover(
267                function() {
268                    if (window.screen.width > 1280) {
269                        var $right = $(this).parent().parent().parent().parent().find('.nav-child-right');
270                        $right.fadeIn(200);
271                        var menu_data = $(this).attr('data-type');
272                        getDis($right, menu_data);
273                    }
274                },
275                function() {
276                    var $right = $(this).parent().parent().parent().parent().find('.nav-child-right');
277
278                }
279            );
280
281            function getDis(obj, index) {
282                var $obj_child = obj.find('.menu-modal-right');
283                $obj_child.each(function() {
284                    var $this = $(this);
285                    if ($(this).attr('data-type') == index) {
286                        $obj_child.not($(this)).fadeOut(200);
287                        $this.fadeIn(200);
288                    }
289                });
290            }
291        },
292        telHover: function(){
293            $('.fd-follow .tel').hover(function(){
294                $('.phone-num').stop().fadeToggle();
295            })
296        },
297        goTop: function() {
298            // 返回顶部
299            var $goTop = $('.goTop');
300            $goTop.on('click', function() {
301                $('body,html').animate({
302                    scrollTop: 0
303                }, 500);
304                // $('.goTop').css({
305                // 	background: 'rgba(0,0,0,0.6)'
306                // });
307                return false;
308            })
309        },
310        swiperWelcome: function() {
311            var welcomeSwiper = new Swiper ('.swiper-welcome1', {
312                direction: 'vertical',
313                loop: true,
314                autoplay: { delay: 3000, stopOnLastSlide: false, disableOnInteraction: true, }
315            })     
316        }
317
318    };
319
320    win.hr.init = function() {
321        hr.util.moNav();
322        hr.util.weixinPop();
323        hr.util.popWait();
324        hr.util.videoPlay();
325        hr.util.brJs();
326        hr.util.telHover();
327        hr.util.goTop();
328        hr.util.swiperWelcome();
329    };
330
331    win.hr.init();
332});

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.