1(function(window) { 2 var ys = {}; 3 var ys = window.ys || {}; 4 var lenis_use = false; 5 // æ»å¨æ¡éè䏿¾ç¤º 6 var scrollbar = { 7 $html: $("html"), 8 $body: $("body"), 9 originalBodyPad: null, 10 scrollbarWidth: 0, 11 hide: function() { 12 this.$body = $("body"); 13 this.checkScrollbar(); 14 this.setScrollbar(); 15 this.$html.css("overflow", "hidden"); 16 // if (this.isMobileSafari()) { 17 // this.$html.css({ 18 // width: "100%", 19 // position: "fixed" 20 // }); 21 // } 22 }, 23 show: function() { 24 this.$body = $("body"); 25 this.$html.removeAttr("style"); 26 this.resetScrollbar(); 27 }, 28 checkScrollbar: function() { 29 var fullWindowWidth = window.innerWidth 30 if (!fullWindowWidth) { // workaround for missing window.innerWidth in IE8 31 var documentElementRect = document.documentElement.getBoundingClientRect(); 32 fullWindowWidth = documentElementRect.right - Math.abs(documentElementRect.left); 33 } 34 this.bodyIsOverflowing = document.body.clientWidth < fullWindowWidth; 35 this.scrollbarWidth = this.measureScrollbar(); 36 }, 37 setScrollbar: function() { 38 var bodyPad = parseInt((this.$body.css('padding-right') || 0), 10) 39 this.originalBodyPad = document.body.style.paddingRight || '' 40 if (this.bodyIsOverflowing) this.$body.css('padding-right', bodyPad + this 41 .scrollbarWidth) 42 }, 43 measureScrollbar: function() { 44 var scrollDiv = document.createElement('div'); 45 scrollDiv.style.position = "absolute"; 46 scrollDiv.style.top = "-9999px"; 47 scrollDiv.style.width = "50px"; 48 scrollDiv.style.height = "50px"; 49 scrollDiv.style.overflow = "scroll"; 50 51 this.$body.append(scrollDiv); 52 var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth; 53 this.$body[0].removeChild(scrollDiv); 54 return scrollbarWidth; 55 }, 56 resetScrollbar: function() { 57 this.$body.css('padding-right', 0); 58 }, 59 isMobileSafari: function() { 60 var ua = navigator.userAgent.toLowerCase(); 61 var isChrome = ua.indexOf("chrome") != -1; 62 var isSafari = ua.indexOf("safari") != -1; 63 var isMobile = ua.indexOf("safari") != -1; 64 65 if (!isChrome && isSafari && isMobile) { 66 return 1; 67 } else { 68 return 0; 69 } 70 } 71 }; 72 ys.scrollbar = scrollbar; 73 $.extend(ys, { 74 // 页é¢å¹³æ»æ»å¨ 75 yxlenis: function(val, isUse) { 76 lenis_use = isUse || false; 77 if (lenis_use && window.Lenis) { 78 if (window.lenis) return; 79 window.lenis = new Lenis({ 80 duration: val || 1.2 81 }); 82 function raf(time) { 83 if (window.lenis) { // å¢å æ£æ¥ï¼é²æ¢éæ¯åæ¥é 84 window.lenis.raf(time); 85 requestAnimationFrame(raf); 86 } 87 } 88 requestAnimationFrame(raf); 89 } 90 }, 91 /** 92 * @description åå°é¡¶é¨ 93 * @param {Number} duration - æ¶é´(ms) 94 * @param {Number} pos - æ¶é´(px) 95 */ 96 goTop: function(duration,pos,callback) { 97 duration = duration || 500; 98 pos = pos || 0; 99 if (lenis_use && window.lenis && typeof window.lenis.scrollTo === 'function') { 100 window.lenis.scrollTo(pos, { 101 duration: duration / 1000, 102 onComplete: callback 103 }); 104 } else { 105 $("html,body").stop().animate({ 106 scrollTop: pos 107 }, duration, function() { 108 callback && callback(); 109 }); 110 } 111 }, 112 /**
113 * @description ågoTop类似ï¼åºå®ä½¿ç¨lenisæ»å¨ 114 * @param {Number} duration - æ¶é´(ms) 115 * @param {Number} pos - æ¶é´(px) 116 */ 117 lenisTo: function(duration,pos,callback) { 118 if (!lenis_use || !window.lenis) { 119 console.warn('lenisTo: Lenis æªåå§åï¼è¯·ç¡®ä¿å·²è°ç¨ yxlenis(val, true)'); 120 return; 121 } 122 duration = (duration || 500) / 1000; 123 pos = pos || 0; 124 window.lenis.scrollTo(pos, { 125 offset: 0, 126 immediate: false, 127 duration: duration, 128 easing: t => t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2, 129 onComplete: callback 130 }); 131 }, 132 lenisStop:function(){ 133 if (lenis_use && window.lenis){ 134 window.lenis.stop(); 135 } 136 }, 137 lenisStart:function(){ 138 if (lenis_use && window.lenis){ 139 window.lenis.start(); 140 } 141 }, 142 /** 143 * @description æ»å¨æ¡åå§å 144 * @param {String} selector - csséæ©å¨ 145 * @param {Boolean} inside - æ»å¨æ¡å ç¨å å®¹åº 146 * @param {String} inside - æ»å¨æ¡æ¹å 147 */ 148 mCustomScrollbarInit:function(selector, inside, axis) { 149 var $obj = $(selector); 150 if ($obj.length === 0) { 151 console.warn('mCustomScrollbarInit: æªæ¾å°å ç´ ', selector); 152 return this; 153 } 154 var scrollbarAxis = axis ? axis : "y"; 155 var scrollbarPosition = inside ? "inside" : "outside"; 156 $obj.mCustomScrollbar({ 157 axis: scrollbarAxis, 158 scrollInertia: 500, 159 theme: 'dark', 160 scrollbarPosition: scrollbarPosition, 161 }); 162 $obj.on('click.mCSB', '.mCSB_scrollTools', function(e) { 163 e.stopPropagation(); 164 }); 165 return this; 166 }, 167 /** 168 * @description 彿»å¨æ¡ç¦»å¼æé¡¶é¨ç»éæ©å ç´ å ä¸ä¸ªç±»åisfixed 169 * è·ç¦»é¡¶é¨è¶ è¿posæ¶å ç±»åisfixedï¼å¦åç§»é¤ç±»å 170 * pcç«¯é¼ æ ç§»å ¥æ¶å ç±»åishoverï¼å¦åç§»é¤ç±»å 171 * @param {String} selector - csséæ©å¨ 172 * @param {Number} pos - æ»å¨ä½ç¦»å¼ä½ç½®(px) 173 */ 174 isFixed:function(selector, pos) { 175 var $obj = $(selector); 176 if ($obj.length === 0) { 177 console.warn('isFixed: æªæ¾å°å ç´ ', selector); 178 return; 179 } 180 pos = pos || 0; 181 var resizeTimer; 182 function judgeTop() { 183 var scrollTop = window.pageYOffset || $(window).scrollTop(); 184 $obj.toggleClass("isfixed", scrollTop > pos); 185 } 186 function bindHover() { 187 var isTouch = 'ontouchstart' in window; 188 if (window.innerWidth > 1199 && !isTouch) { 189 $obj.off('mouseenter.isFixed mouseleave.isFixed') 190 .on('mouseenter.isFixed', function() { 191 $(this).addClass('ishover'); 192 }) 193 .on('mouseleave.isFixed', function() { 194 $(this).removeClass('ishover'); 195 }); 196 } else { 197 $obj.off('mouseenter.isFixed mouseleave.isFixed').removeClass('ishover'); 198 } 199 } 200 $(function() { 201 judgeTop(); 202 bindHover(); 203 $(window).on("scroll.isFixed", judgeTop).on("resize.isFixed", function() { 204 clearTimeout(resizeTimer); 205 resizeTimer = setTimeout(function() { 206 judgeTop(); 207 bindHover(); 208 }, 100); 209 }); 210 }); 211 }, 212 /** 213 * @description æ°åæ»å¨ 214 * @param {String} selector - csséæ©å¨ 215 * @param {Boolean} addZero - æ¯å¦è¡¥0 216 * @param {Number} speed - æ»å¨é度(ms) 217 */ 218 numRoll: function(selector, addZero, speed) { 219 var $ele = $(selector); 220 if ($ele.length === 0) return; 221 speed = speed || 1000; 222 function toThousands(num) { 223 var parts = num.toString().split('.'); 224 parts[0] = parts[0].replace(/(\d)(?=(?:\d{3})+$)/g, '$1,'); 225 return parts.join('.'); 226 } 227 if (!$.fn.appear || !$.fn.countTo) return; 228 $ele.each(function() { 229 var $this = $(this); 230 if (!$this.data('numRoll-init')) { 231 var content = $this.data("to"); 232 if (content) $this.attr('data-save', content); 233 $this.data('numRoll-init', true); 234 } 235 }); 236 $ele.appear(function() { 237 var $this = $(this); 238 var realContent = $this.text().trim(); 239 // 忢å䏿¬¡å¨ç» 240 $this.stop(true, true).removeAttr('style'); 241 $this.width($this.width()); 242 243 var fromNum = parseFloat($this.data("from")) || 0; 244 var content = $this.data("to") || realContent; 245 var savedData = $this.data("save"); 246 247 var targetNum = parseFloat(content.toString().replace(/,/g, "").replace(/[^\d.]/g, '')); 248 var decimalPlaces = (targetNum.toString().split('.')[1] || '').length; 249 var targetIntLength = parseInt(targetNum).toString().length; 250 var hasComma = content.toString().indexOf(',') !== -1; 251 252 var formatter = function(value, options) { 253 var myValue = value.toFixed(decimalPlaces); 254 var parts = myValue.split('.'); 255 if (addZero) { 256 var intPart = parts[0]; 257 while (intPart.length < targetIntLength) { 258 intPart = "0" + intPart; 259 } 260 parts[0] = intPart; 261 myValue = parts.join('.'); 262 } 263 if (hasComma || parseInt(parts[0]) >= 1000) { 264 myValue = toThousands(myValue); 265 } 266 return myValue; 267 }; 268 if (!isNaN(targetNum)) { 269 $this.countTo({ 270 from: fromNum, 271 to: targetNum, 272 speed: speed, 273 refreshInterval: 60, 274 decimals: decimalPlaces, 275 formatter: formatter, 276 onComplete: function() { 277 $this.removeAttr("style").text(savedData || realContent); 278 } 279 }); 280 } 281 }, { one: false }); 282 }, 283 /**
284 * @description bannerè½®æè§é¢åå§å 285 * @param {String} selector - csséæ©å¨ 286 */ 287 banVideo: function(selector) { 288 var $obj = $(selector); 289 var autoplay = true; 290 var timers = []; // åå¨å®æ¶å¨ç¨äºæ¸ ç 291 var isInitialized = false; 292 // æ¸ ç彿° 293 function clearTimers() { 294 timers.forEach(clearTimeout); 295 timers = []; 296 } 297 function stopAllVideos() { 298 $obj.find("video").each(function() { 299 var video = $(this).get(0); 300 video.pause(); 301 video.currentTime = 0; 302 video.onended = null; 303 }); 304 } 305 function bindVideoEnd($video) { 306 if ($video.length === 0) return; 307 var video = $video.get(0); 308 video.onended = function() { 309 if (autoplay && $obj.get(0).slick) { // æ£æ¥ slick æ¯å¦åå¨ 310 $obj.slick('slickNext'); 311 $obj.slick('slickPlay'); 312 } 313 }; 314 } 315 function handleSlideChange(slick, index) { 316 clearTimers(); 317 stopAllVideos(); 318 var $nowSlide = $(slick.$slides[index]); 319 var $video = $nowSlide.find("video"); 320 if ($video.length > 0) { 321 $obj.slick('slickPause'); 322 // å»¶è¿ææ¾ç¡®ä¿ DOM 就绪 323 var timer = setTimeout(function() { 324 if ($video.length > 0 && $video.is(':visible')) { 325 $video.get(0).play().catch(function(e) { 326 console.warn('Video play failed:', e); 327 // ææ¾å¤±è´¥æ¶æ¢å¤è½®æ 328 if (autoplay) $obj.slick('slickPlay'); 329 }); 330 } 331 }, 50); 332 timers.push(timer); 333 bindVideoEnd($video); 334 } else if (autoplay) { 335 $obj.slick('slickPlay'); 336 } 337 } 338 if (window.innerWidth > 1199 && $obj.find("video").length > 0) { 339 if (isInitialized) return; // 鲿¢éå¤åå§å 340 isInitialized = true; 341 // è§£ç»æ§äºä»¶ï¼ä¿é©èµ·è§ï¼ 342 $obj.off('.banVideo'); 343 clearTimers(); 344 // åå§å第ä¸å¼ 345 var $firstSlide = $obj.find(".slick-slide[data-slick-index=0]"); 346 var $firstVideo = $firstSlide.find("video"); 347 if ($firstVideo.length > 0) { 348 $obj.slick('slickPause'); 349 if ($obj.get(0).slick.slideCount < 2) { 350 $firstVideo.attr("loop", "loop"); 351 } 352 if ($firstVideo.get(0).paused) { 353 var timer = setTimeout(function() { 354 $firstVideo.get(0).play().catch(function(e) { 355 console.warn('First video autoplay failed:', e); 356 }); 357 }, 100); 358 timers.push(timer); 359 } 360 bindVideoEnd($firstVideo); 361 } 362 // ç»å®åæ¢äºä»¶ 363 $obj.on('afterChange.banVideo', function(event, slick, index) { 364 handleSlideChange(slick, index); 365 }); 366 } else { 367 // ç§»å¨ç«¯ 368 $obj.slick('slickPlay'); 369 // å½»åºåæ¢è§é¢ï¼ä¸ç§»é¤ DOMï¼ä»¥ä¾¿çªå£åå¤§æ¶æ¢å¤ï¼ 370 $obj.find("video").each(function() { 371 var $v = $(this); 372 var video = $v.get(0); 373 video.pause(); 374 video.src = ''; // 忢ç¼å² 375 video.load(); // éç½® 376 $v.hide(); 377 }); 378 } 379 var banvideo = { 380 play: function() { 381 autoplay = true; 382 $obj.slick('slickPlay'); 383 }, 384 pause: function() { 385 autoplay = false; 386 $obj.slick('slickPause'); 387 }, 388 destroy: function() { 389 $obj.off('.banVideo'); // ç§»é¤ææ .banVideo å½å空é´äºä»¶ 390 clearTimers(); 391 stopAllVideos(); 392 isInitialized = false; 393 }, 394 refresh: function() { 395 this.destroy(); 396 } 397 }
398 return banvideo; 399 }, 400 // æåææslickè½®æ 401 stopSlick: function() { 402 $(".slick-slider").each(function() { 403 var $slider = $(this); 404 // æ£æ¥æ¯å¦å·²åå§å 405 if ($slider.hasClass('slick-initialized')) { 406 $slider.slick('slickPause'); 407 } 408 }); 409 }, 410 /** 411 * @description å¼¹çªèå± 412 * @param {String} btn å¼¹çªè§¦åæé®ï¼éæ©å¨ï¼ 413 * @param {String} modal 对åºå¼¹çªï¼éæ©å¨ï¼ 414 * @param {String} scrollEle æ»å¨æ¡å ç´ ï¼éæ©å¨ï¼ 415 * @param {Function} data æ°æ®å¯¹åº 416 */ 417 modal: function(btn, modal, scrollEle, data) { 418 var $modal = $(modal); 419 var eventNs = '.modal_' + modal.replace(/[#.\s\[\]]/g, '_'); // å¯ä¸å½åç©ºé´ 420 // æ¸ çæ§äºä»¶ï¼é²æ¢éå¤ç»å®ï¼ 421 $("body").off(eventNs); 422 $(document).off(eventNs); 423 // æ°æ®å¡«å 彿°ï¼ç§»åºéå ï¼ 424 function fillData($btn, data) { 425 $.each(data, function(index, item) { 426 var selector = item[0], target = item[1], type = item[2], attr = item[3]; 427 var $from = $btn.find(selector).length ? $btn.find(selector) : $btn; 428 var $to = $modal.find(target); 429 switch(type) { 430 case 'img': 431 $to.attr('src', $from.attr('src')); 432 break; 433 case 'attr': 434 $to.text($from.attr(attr)); 435 break; 436 case 'html': 437 $to.html($from.html()); 438 break; 439 case 'text': 440 default: 441 $to.text($from.text().trim()); 442 } 443 }); 444 } 445 // æ¾ç¤º 446 $("body").on("click" + eventNs, btn, function(e) { 447 e.preventDefault(); 448 var $btn = $(this); 449 // å¡«å æ°æ® 450 if (data) fillData($btn, data); 451 // æ¾ç¤ºå¼¹çª 452 $modal.stop().fadeIn(function() { 453 // ç¦ç¹ç®¡çï¼ç§»å°å¼¹çªå 第ä¸ä¸ªå¯èç¦å ç´ 454 $modal.attr('tabindex', '-1').focus(); 455 // æèç¦å ³éæé®ï¼$modal.find('.ys-modal-close').focus(); 456 }); 457 // ç¦ç¨èæ¯æ»å¨ 458 if (typeof scrollbar !== 'undefined') scrollbar.hide(); 459 if (window.lenis && lenis_use) window.lenis.stop(); 460 // 黿¢èæ¯æ»å¨ï¼iOSï¼ 461 $('body').addClass('modal-open'); 462 }); 463 // å ³é彿°ï¼å¤ç¨ï¼ 464 function closeModal() { 465 $modal.stop().fadeOut(function() { 466 // æ¢å¤æ»å¨ 467 if (typeof scrollbar !== 'undefined') scrollbar.show(); 468 if (window.lenis && lenis_use) window.lenis.start(); 469 $('body').removeClass('modal-open'); 470 // æ¸ ç©ºæ°æ® 471 if (data) { 472 $.each(data, function(i, item) { 473 $modal.find(item[1]).empty(); 474 }); 475 } 476 // éç½®æ»å¨ä½ç½® 477 if ($modal.hasClass('ys-modal-update')) { 478 var scrollEl = $modal.find('.ys-modal-content')[0] || $modal[0]; 479 scrollEl.scrollTop = 0; // ç®åéç½® 480 } 481 }); 482 // è¿åç¦ç¹å°è§¦åæé®ï¼éè¦åå¨ï¼ 483 if ($modal.data('triggerBtn')) { 484 $modal.data('triggerBtn').focus(); 485 } 486 } 487 // å ³éæé® 488 $("body").on("click" + eventNs, ".ys-modal-close", closeModal);
489 // é®ç½©å ³é 490 $("body").on("click" + eventNs, ".ys-modal-mask", function(e) { 491 if (e.target === this) closeModal(); // ç¡®ä¿æ¯ç¹å»é®ç½©æ¬èº« 492 }); 493 // ESC é®å ³é 494 $(document).on("keydown" + eventNs, function(e) { 495 if (e.key === 'Escape' && $modal.is(':visible')) { 496 closeModal(); 497 } 498 }); 499 // åå§åæ»å¨æ¡ï¼ä» 䏿¬¡ï¼ 500 var actualScrollEle = scrollEle || ".ys-modal-content"; 501 if (!$modal.hasClass('ys-modal-update') && actualScrollEle !== "noscroll") { 502 var $scroller = $modal.find(actualScrollEle); 503 if ($scroller.length && !$scroller.hasClass('mCustomScrollbar')) { 504 $scroller.mCustomScrollbar({ 505 axis: "y", 506 scrollInertia: 500, 507 theme: 'dark', 508 mouseWheel: { preventDefault: true } // 鲿¢å泡 509 }); 510 } 511 } else if (actualScrollEle === "noscroll") { 512 $modal.find(".ys-modal-content").addClass("noscroll"); 513 } 514 // è¿åæ§å¶å¯¹è±¡ï¼å¯éï¼ 515 return { 516 open: function($triggerBtn) { 517 $modal.data('triggerBtn', $triggerBtn); 518 $modal.stop().fadeIn(); 519 }, 520 close: closeModal, 521 destroy: function() { 522 $("body").off(eventNs); 523 $(document).off(eventNs); 524 if ($modal.find('.mCustomScrollbar').length) { 525 $modal.find('.mCustomScrollbar').mCustomScrollbar('destroy'); 526 } 527 } 528 }; 529 }, 530 /** 531 * @description è§é¢å¼¹çª 532 * @param {selector} selector - csséæ©å¨ 533 * @param {Boolean} autoplay - æ¯å¦å¼¹çªèªå¨ææ¾video 534 * @param {selector} btn - å ¶ä»ç¹å»ç±»å 535 */ 536 videomodal: function(selector, autoplay) { 537 // é»è®¤ autoplay 为 trueï¼ä½å 许æ¾å¼ä¼ å ¥ false 538 autoplay = (autoplay !== false); 539 var $videomodal; 540 var eventNs = '.videomodal_' + selector.replace(/[#.\s\[\]]/g, '_'); 541 // æ¸ çæ§äºä»¶ï¼é²æ¢éå¤è°ç¨ï¼ 542 $("body").off("click" + eventNs); 543 $(document).off("keydown" + eventNs); 544 // æå ¥æè·åè§é¢æ¨¡çï¼å便¨¡å¼ï¼ 545 if ($(".ys-videom").length > 0) { 546 $videomodal = $(".ys-videom"); 547 } else { 548 var videomodalHtml = 549 '<div class="ys-videom" role="dialog" aria-modal="true" tabindex="-1">' + 550 '<div class="ys-modal-mask"></div>' + 551 '<div class="ys-videom-container">' + 552 '<button class="ys-videom-close" aria-label="å ³éè§é¢">' + 553 '<i class="iconfont icon-close"></i>' + 554 '</button>' + 555 '<div class="ys-videom-content">' + 556 '<div class="ys-videom-iframebox"></div>' + 557 '</div>' + 558 '</div>' + 559 '</div>'; 560 $videomodal = $(videomodalHtml); 561 $("body").append($videomodal); 562 } 563 // å é¨äºä»¶åªç»å®ä¸æ¬¡ 564 if (!$videomodal.data('events-bound')) { 565 $videomodal.on("click.videomodal", ".ys-videom-close, .ys-modal-mask", function(e) { 566 if ($(e.target).is('.ys-videom-close, .ys-modal-mask, .icon-close')) { 567 Vmodal.close(); 568 } 569 }); 570 $videomodal.data('events-bound', true); 571 } 572 var Vmodal = { 573 $self: $videomodal, 574 $triggerBtn: null, // åå¨è§¦åæé® 575 close: function() { 576 // æ¢å¤æ»å¨ 577 if (typeof scrollbar !== 'undefined') scrollbar.show(); 578 if (window.lenis && typeof lenis_use !== 'undefined' && lenis_use) { 579 window.lenis.start(); 580 }
581 // æ¸ çè§é¢ï¼å æååç§»é¤ï¼ 582 var $video = $videomodal.find(".ys-videom-video"); 583 if ($video.length) { 584 var video = $video.get(0); 585 video.pause(); 586 video.src = ''; 587 video.load(); 588 $video.remove(); 589 } 590 // æ¸ ç iframe 591 $videomodal.find(".ys-videom-iframebox").hide().empty(); 592 // éèå¼¹çª 593 $videomodal.hide().removeAttr('aria-hidden'); 594 // è¿åç¦ç¹ 595 if (this.$triggerBtn) { 596 this.$triggerBtn.focus(); 597 } 598 // è§£ç» ESC 599 $(document).off("keydown" + eventNs); 600 }, 601 show: function($trigger) { 602 this.$triggerBtn = $trigger; // ä¿å触åæé® 603 scrollbar.hide(); 604 if (window.lenis && typeof lenis_use !== 'undefined' && lenis_use) { 605 window.lenis.stop(); 606 } 607 $videomodal.show().attr('aria-hidden', 'false'); 608 // ç¦ç¹è½¬ç§»å°å ³éæé®æå¼¹çª 609 setTimeout(function() { 610 $videomodal.find('.ys-videom-close').focus(); 611 }, 100); 612 // ç»å® ESC å ³é 613 var self = this; 614 $(document).on("keydown" + eventNs, function(e) { 615 if (e.key === 'Escape') { 616 self.close(); 617 } 618 }); 619 } 620 }; 621 // 触åæé®ç¹å» 622 $("body").on("click" + eventNs, selector, function(e) { 623 e.preventDefault(); 624 var $btn = $(this); 625 var videoType = $btn.attr("data-type"); 626 var videoSrc = $btn.attr("data-src"); 627 if (!videoSrc) return; 628 if (videoType === "video") { 629 // æ¸ çæ§è§é¢ 630 $videomodal.find(".ys-videom-video").remove(); 631 var videoPoster = $btn.data("poster") || ''; 632 var isMobile = window.innerWidth < 767; 633 var isExternal = /^https?:\/\//.test(videoSrc); 634 // å建è§é¢å ç´ ï¼å®å ¨æ¹å¼ï¼ 635 var $video = $('<video>') 636 .addClass('ys-videom-video') 637 .css('display', 'block') 638 .attr({ 639 playsinline: true, 640 controls: true, 641 poster: videoPoster 642 }); 643 // ç§»å¨ç«¯å¤é¨è§é¢ç¹æ®å¤çï¼èªå¨ææ¾çç¥ï¼ 644 if (isMobile && isExternal && autoplay) { 645 $video.attr('muted', true); 646 } 647 // å®å ¨è®¾ç½® src 648 $('<source>').attr('src', videoSrc).appendTo($video); 649 $videomodal.find(".ys-videom-content").append($video); 650 Vmodal.show($btn); 651 // èªå¨ææ¾ 652 if (autoplay) { 653 var playPromise = $video.get(0).play(); 654 if (playPromise !== undefined) { 655 playPromise.catch(function(err) { 656 console.warn('Autoplay prevented:', err); 657 // æ¾ç¤ºææ¾æé®æç¤ºç¨æ·æå¨ææ¾ 658 }); 659 } 660 } 661 } else if (videoType === "iframe") { 662 // éªè¯ URL å®å ¨ 663 // if (!/^https?:\/\/(www\.)?(youtube\.com|youtu\.be|vimeo\.com|bilibili\.com|player\.bilibili\.com)/.test(videoSrc)) { 664 // console.error('Unsafe iframe URL:', videoSrc); 665 // return; 666 // } 667 // å¤çèªå¨ææ¾åæ° 668 var finalSrc = ""; 669 var rawInput = videoSrc.trim(); 670 if (rawInput.toLowerCase().indexOf('<iframe') > -1) { 671 var match = rawInput.match(/src=["']?([^"'\s>]+)["']?/i); 672 if (match && match[1]) { 673 finalSrc = match[1]; 674 } else { 675 finalSrc = rawInput; 676 } 677 } else { 678 finalSrc = rawInput; 679 } 680 var separator = finalSrc.indexOf('?') > -1 ? '&' : '?'; 681 var autoplayParam = autoplay ? separator + 'autoplay=1' : ''; 682 683 var absoluteUrl = finalSrc + autoplayParam; 684 685 var $iframe = $('<iframe>').attr({ 686 src: absoluteUrl, 687 frameborder: 0, 688 allowfullscreen: true, 689 allow: 'accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture' 690 }); 691 692 // å¡«å å°å®¹å¨å¹¶æ¾ç¤º
693 $videomodal.find(".ys-videom-iframebox").show().empty().append($iframe); 694 Vmodal.show($btn); 695 } else { 696 return; 697 } 698 }); 699 return Vmodal; // è¿åæ§å¶å¯¹è±¡ä¾å¤é¨ä½¿ç¨ 700 }, 701 /** 702 * @description è§£å³bshareä¹±ç 703 * @param {String} title - åäº«çæ é¢æå 704 * @param {String} summary - å享çå 容æå 705 */ 706 shareInit: function(title, summary) { 707 var _this = this; 708 var pageTitle = title || $("h1").text().trim(); 709 var pageSummary = summary || $("p").eq(0).text().replace(/\s+/g, " "); 710 711 var encodedTitle = encodeURIComponent(pageTitle); 712 var encodedSummary = encodeURIComponent(pageSummary); 713 var currentUrl = encodeURIComponent(window.location.href); 714 var rawUrl = window.location.href; 715 716 var eventNs = '.shareinit'; 717 718 // ========== 微信åäº«ä¿æä¸åï¼å¼¹çªäºç»´ç ï¼========== 719 if (!$(".ys-share-wechat").data('share-bound')) { 720 $(".ys-share-wechat").data('share-bound', true).on("click" + eventNs, function(e) { 721 e.preventDefault(); 722 var $wechatpop; 723 // æå ¥æè·åå¼¹çª 724 if ($(".ys-wechat").length > 0) { 725 $wechatpop = $(".ys-wechat"); 726 } else { 727 var wechatHtml = 728 '<div class="ys-wechat" role="dialog" aria-modal="true">' + 729 '<div class="ys-modal-mask"></div>' + 730 '<div class="ys-wechat-cont">' + 731 '<div id="qrcode">' + 732 '<div class="ys-wechat-cont-parga"><p></p></div>' + 733 '<div class="ys-wechat-cont-btn" aria-label="å ³é">' + 734 '<i class="iconfont icon-close"></i>' + 735 '</div>' + 736 '</div>' + 737 '</div>' + 738 '</div>'; 739 $wechatpop = $(wechatHtml); 740 $("body").append($wechatpop); 741 // äºä»¶åªç»å®ä¸æ¬¡ 742 $wechatpop.on("click" + eventNs, ".ys-wechat-cont-btn, .ys-modal-mask", function() { 743 $wechatpop.stop().fadeOut(function() { 744 if (typeof scrollbar !== 'undefined') scrollbar.show(); 745 if (window.lenis && typeof lenis_use !== 'undefined' && lenis_use) { 746 window.lenis.start(); 747 } 748 }); 749 }); 750 // ESC å ³é 751 $(document).on("keydown" + eventNs, function(e) { 752 if (e.key === 'Escape' && $wechatpop.is(':visible')) { 753 $wechatpop.find('.ys-wechat-cont-btn').trigger('click'); 754 } 755 }); 756 } 757 // æ¸ ç©ºæ§äºç»´ç ï¼æ¯æ canvas å imgï¼ 758 $wechatpop.find("#qrcode canvas").remove(); 759 $wechatpop.find("#qrcode img").remove(); 760 // çææ°äºç»´ç 761 if ($.fn.qrcode) { 762 $('#qrcode').qrcode({ 763 text: rawUrl, 764 width: 200, 765 height: 200 766 }); 767 } else { 768 console.error('qrcode plugin not loaded'); 769 // åéï¼æ¾ç¤º URL ææ¬ 770 $('#qrcode').html('<p style="word-break:break-all;">' + rawUrl + '</p>'); 771 } 772 // æ¾ç¤ºå¼¹çª 773 $wechatpop.stop().fadeIn(function() { 774 $(this).find('.ys-wechat-cont-btn').focus(); // ç¦ç¹ç®¡ç 775 }); 776 if (typeof scrollbar !== 'undefined') scrollbar.hide(); 777 if (window.lenis && typeof lenis_use !== 'undefined' && lenis_use) { 778 window.lenis.stop(); 779 } 780 }); 781 } 782 783 // ========== 社交平å°åäº«ï¼æ°æ ç¾é¡µæå¼ï¼========== 784 var sharePlatforms = [ 785 { selector: '.ys-share-sinaminiblog', url: 'https://service.weibo.com/share/share.php?url={url}&title={title}%20-{summary}' }, 786 { selector: '.ys-share-twitter', url: 'https://twitter.com/intent/tweet?text={title}%20{url}' }, 787 { selector: '.ys-share-facebook', url: 'https://www.facebook.com/sharer/sharer.php?u={url}' }, 788 { selector: '.ys-share-linkedin', url: 'https://www.linkedin.com/sharing/share-offsite/?url={url}' }, 789 { selector: '.ys-share-qq', url: 'https://connect.qq.com/widget/shareqq/index.html?url={url}&title={title}&summary={summary}' } 790 ]; 791
792 sharePlatforms.forEach(function(platform) { 793 var $btn = $(platform.selector); 794 if ($btn.length && !$btn.data('share-bound')) { 795 $btn.data('share-bound', true) 796 .css("cursor", "pointer") 797 .on("click" + eventNs, function(e) { 798 e.preventDefault(); 799 e.stopPropagation(); // å ³é®ï¼é»æ¢å泡å°ç¶çº§ a æ ç¾ 800 801 var shareUrl = platform.url 802 .replace('{url}', currentUrl) 803 .replace('{title}', encodedTitle) 804 .replace('{summary}', encodedSummary); 805 806 // æ ¸å¿ä¿®æ¹ï¼ä¸ä¼ ä»»ä½å°ºå¯¸åæ°ï¼æµè§å¨ä¼ç´æ¥å¼æ°æ ç¾é¡µ 807 // ä½¿ç¨ "_blank" é å "noopener,noreferrer" ç¡®ä¿æ§è½åå®å ¨ 808 window.open(shareUrl, "_blank", "noopener,noreferrer"); 809 }); 810 } 811 }); 812 }, 813 /** 814 * @description éè¿jsè°ç¨animate.cssçå¨ç» 815 * @param {String} ele - å¨ç»çå ç´ 816 * @param {String} animate - å¨ç»çåå 817 * @param {Function} callback - å¨ç»æ§è¡å®çåè°å½æ° 818 */ 819 animateCss: function(ele, animate, callback) { 820 var $ele = $(ele); 821 var duration = $ele.css('animation-duration'); 822 duration = (duration === '0s' || !duration) ? 1000 : parseFloat(duration) * 1000; 823 // å ç§»é¤åæ·»å ï¼ç¡®ä¿å¨ç»è½éå¤è§¦å 824 $ele.removeClass('animated ' + animate); 825 void $ele[0].offsetWidth; // 强å¶éç» 826 $ele.addClass('animated ' + animate); 827 if (callback === 'show') $ele.stop().show(); 828 setTimeout(function() { 829 $ele.removeClass('animated ' + animate); 830 if (callback === 'hide') { 831 $ele.stop().hide(); 832 } else if (typeof callback === 'function') { 833 callback(); 834 } 835 }, duration); 836 }, 837 //æ£æ¥é¡µé¢æ¯å¦ç¼©æ¾ 838 checkViewport: function() { 839 var zoom = 1; 840 var isZoomed = false; 841 // æ´åç¡®çæ£æµï¼æ¯è¾è§è§è§å£ä¸å¸å±è§å£ 842 if (window.visualViewport && window.visualViewport.scale) { 843 zoom = window.visualViewport.scale; 844 isZoomed = (zoom !== 1); 845 } 846 // å¤ç¨æ¹æ¡ 847 if (window.outerWidth && window.innerWidth) { 848 zoom = Math.round((window.outerWidth / window.innerWidth) * 100) / 100; 849 // 容差ï¼å 许 0.95-1.05 850 isZoomed = (zoom < 0.95 || zoom > 1.05); 851 } 852 // IE 853 if (window.screen && window.screen.deviceXDPI) { 854 zoom = window.screen.deviceXDPI / window.screen.logicalXDPI; 855 isZoomed = (zoom !== 1); 856 } 857 if (isZoomed) { 858 alert('å½å页é¢ç¼©æ¾æ¯ä¾ä¸º ' + Math.round(zoom * 100) + '%ï¼è¯·è®¾ç½®æ 100%'); 859 } 860 }, 861 // éæ°å è½½main.cssåmidea.css 862 reloadCss: function(options) { 863 const defaults = { 864 targetFiles: ['main.css', 'media.css'], // ç®æ æä»¶ 865 attribute: 'href', // 龿¥å±æ§ 866 excludeExternal: true, // æé¤å¤é¨é¾æ¥ 867 forceReload: false // æælinké½å æ¶é´æ³ 868 }; 869 const settings = $.extend({}, defaults, options); 870 $("link[rel='stylesheet']").each(function() { 871 const $link = $(this); 872 let href = $link.attr(settings.attribute); 873 // è·³è¿æ æé¾æ¥ 874 if (!href || href === 'undefined') return; 875 // æé¤å¤é¨é¾æ¥ 876 if (settings.excludeExternal && (href.indexOf('//') === 0 || href.indexOf('http') === 0)) { 877 // æ£æ¥æ¯å¦åæº 878 if (href.indexOf(location.host) === -1) return; 879 } 880 // æ£æ¥æ¯å¦å¹é ç®æ æä»¶ 881 const shouldReload = settings.targetFiles.some(function(file) { 882 return href.indexOf(file) !== -1; 883 }); 884 if (shouldReload || settings.forceReload) { 885 // ç§»é¤æ§çæ¶é´æ³ï¼é¿å éå¤è¿½å 886 href = href.replace(/\?.*$/, '').replace(/&.*$/, ''); 887 // æ·»å æ°æ¶é´æ³ 888 const timestamp = new Date().getTime(); 889 const separator = href.indexOf('?') !== -1 ? '&' : '?'; 890 $link.attr(settings.attribute, href + separator + 't=' + timestamp); 891 } 892 }); 893 }, 894 /**
895 * @description éç¹å®ä½ 896 * @param {String} tp - è·¯ç±æ¼æ¥ 897 * @param {Number} navHeight - pc导èªé«åº¦ 898 * @param {Number} time - æ»å¨çæ¶é´ 899 */ 900 yxtop:function(param) { 901 var head1 = parseFloat($('html').css('--headh')) || 0; 902 var dataDef = { 903 navHeight: head1, 904 time: 500, 905 tp: "", 906 delay: 0, 907 mobileBreakpoint: 1200, // æç¹å¯é ç½® 908 mobileNavHeight: 56, // ç§»å¨ç«¯å¯¼èªé«åº¦ 909 offset: 0, // é¢å¤åç§»é 910 force: false // æ¯å¦å¼ºå¶æ»å¨ï¼å³ä½¿æ tp åæ°ï¼ 911 }; 912 var data = $.extend({}, dataDef, param); 913 function doScroll(targetTp, pushState) { 914 var navHeight = data.navHeight; 915 if (window.innerWidth < data.mobileBreakpoint) { 916 navHeight = data.mobileNavHeight; 917 } 918 var target = $('[data-section="' + targetTp + '"]'); 919 if (target.length === 0) { 920 console.warn('yxtop: æªæ¾å°ç®æ å ç´ [data-section="' + targetTp + '"]'); 921 return false; 922 } 923 var scrollTop = target.offset().top - navHeight - data.offset; 924 scrollTop = Math.max(0, scrollTop); 925 $("html, body").stop().animate({ 926 scrollTop: scrollTop 927 }, data.time); 928 // æ´æ° URLï¼å¯é 929 if (pushState !== false) { 930 history.pushState(null, null, '#section=' + targetTp); 931 } 932 return true; 933 } 934 function init(config) { 935 var tp = config.tp; 936 var hash = window.location.hash; 937 if (hash) { 938 // æ¯æ #section=xxx æ #xxx æ #sectionxxx ä¸ç§æ ¼å¼ 939 if (hash.indexOf('tp=') !== -1) { 940 tp = hash.replace(/^#tp=/, '').replace(/^#/, ''); 941 }else if(hash.indexOf('tp') !== -1){ 942 tp = hash.replace(/^#tp/, '').replace(/^#/, ''); 943 }else if (hash.indexOf('section=') !== -1) { 944 tp = hash.replace(/^#section=/, '').replace(/^#/, ''); 945 }else if(hash.indexOf('section') !== -1){ 946 tp = hash.replace(/^#section/, '').replace(/^#/, ''); 947 } else { 948 tp = hash.replace(/^#/, ''); 949 } 950 } 951 if (!tp && !config.force) return; // æ ç®æ ä¸ä¸å¼ºå¶ï¼ç´æ¥éåº 952 doScroll(tp, false); 953 } 954 function bindClick() { 955 $(document).off('click.yxtop').on('click.yxtop', 'a[href^="#"]', function(e) { 956 var href = $(this).attr('href'); 957 if (!href || href === '#') return; 958 var targetTp; 959 // æ¯æ #section=xxx æ #xxx æ #sectionxxx ä¸ç§æ ¼å¼ 960 if (href.indexOf('tp=') !== -1) { 961 targetTp = href.replace(/^#tp=/, '').replace(/^#/, ''); 962 }else if(href.indexOf('tp') !== -1){ 963 targetTp = href.replace(/^#tp/, '').replace(/^#/, ''); 964 }else if (href.indexOf('section=') !== -1) { 965 targetTp = href.replace(/^#section=/, '').replace(/^#/, ''); 966 }else if(href.indexOf('section') !== -1){ 967 targetTp = href.replace(/^#section/, '').replace(/^#/, ''); 968 } else { 969 targetTp = href.replace(/^#/, ''); 970 } 971 // 黿¢é»è®¤éç¹è¡ä¸ºï¼å¼ºå¶æ»å¨ 972 e.preventDefault(); 973 doScroll(targetTp, true); 974 }); 975 } 976 bindClick(); 977 $(window).on("load.yxtop hashchange.yxtop", function() { 978 init(data); 979 }); 980 if(data.delay>0){ 981 setTimeout(function(){ 982 init(data); 983 }, data.delay); 984 } 985 return { 986 scrollTo: function(tp, customOffset) { 987 // æ¯æç¼ç¨å¼è°ç¨ 988 var originalOffset = data.offset; 989 if (customOffset !== undefined) { 990 data.offset = customOffset; 991 } 992 doScroll(tp, true); 993 data.offset = originalOffset; // æ¢å¤ 994 }, 995 refresh: function() { 996 init(data); 997 }, 998 clear: function() { 999 history.pushState("", document.title, window.location.pathname + window.location.search); 1000 } 1001 }; 1002 }, 1003 /**
1004 * @description ä¾§è¾¹åºå® 1005 * @param {String} nav - ä¾§è¾¹å¯¼èªæå¤é¢ççå 1006 * @param {String} area - ä¾§è¾¹å¯¼èªæ¾ç¤ºçåºå 1007 */ 1008 asideNav: function(nav, area, options) { 1009 var $nav = $(nav); 1010 var $area = $(area); 1011 var settings = $.extend({ 1012 fixedClass: 'ys-fixed', // å¨åºåå åºå® 1013 bottomClass: 'ys-notfixed', // æ»åºåºååºé¨ 1014 topOffset: 0, // é¡¶é¨è§¦ååç§» 1015 bottomOffset: 0, // åºé¨è§¦ååç§»,乿¯è·ç¦»é¡¶é¨è·ç¦» 1016 throttle: null, // null = ä½¿ç¨ RAF, æ°å = æ¶é´èæµ(ms) 1017 useRAF: true // ä¼å ä½¿ç¨ requestAnimationFrame 1018 }, options); 1019 var timerId = null; 1020 var resizeTimer = null; 1021 function updateState() { 1022 var scrollTop = $(window).scrollTop(); 1023 var areaOffsetTop = $area.offset().top; 1024 var areaTop = areaOffsetTop - settings.topOffset; 1025 var areaBottom = areaOffsetTop + $area.height() - settings.bottomOffset; 1026 var navHeight = $nav.outerHeight(); 1027 // ä¸ç§ç¶æ 1028 var isAbove = scrollTop < areaTop; // æªè¿å ¥åºå 1029 var isInside = scrollTop >= areaTop && 1030 (scrollTop + navHeight) <= areaBottom; // å¨åºåå 1031 var isBelow = (scrollTop + navHeight) > areaBottom; // è¶ åºåºååºé¨ 1032 // åºç¨ç¶æ 1033 $nav.toggleClass(settings.fixedClass, isInside); 1034 $nav.toggleClass(settings.bottomClass, isBelow); 1035 // è°è¯æ¥å¿ 1036 // console.log('scroll:', scrollTop, 'area:', areaTop, '-', areaBottom, 1037 // 'ç¶æ:', isAbove ? 'ä¸' : isInside ? 'ä¸' : 'ä¸'); 1038 } 1039 function init() { 1040 // éç½®ç¶æ 1041 $nav.removeClass(settings.fixedClass + ' ' + settings.bottomClass); 1042 updateState(); 1043 } 1044 // èæµæ»å¨ 1045 function onScroll() { 1046 if (timerId) return; 1047 1048 if (settings.useRAF && window.requestAnimationFrame) { 1049 timerId = requestAnimationFrame(function() { 1050 updateState(); 1051 timerId = null; 1052 }); 1053 } else { 1054 timerId = setTimeout(function() { 1055 updateState(); 1056 timerId = null; 1057 }, settings.throttle || 16); 1058 } 1059 } 1060 // 鲿 resize 1061 function onResize() { 1062 clearTimeout(resizeTimer); 1063 resizeTimer = setTimeout(init, 100); 1064 } 1065 // ç»å®äºä»¶ï¼å½å空é´ï¼ 1066 $(window) 1067 .on('scroll.asideNav', onScroll) 1068 .on('resize.asideNav', onResize) 1069 .on('load.asideNav', init); 1070 // åå§å 1071 init(); 1072 // è¿åæ§å¶ 1073 return { 1074 refresh: init, 1075 destroy: function() { 1076 $(window).off('.asideNav'); 1077 $nav.removeClass(settings.fixedClass + ' ' + settings.bottomClass); 1078 } 1079 }; 1080 }, 1081 /** 1082 * @description 夿æ¯å¦ä¸ºIEæµè§å¨ 1083 */ 1084 isIE:function() { 1085 if (!!window.ActiveXObject || "ActiveXObject" in window || !!document.documentMode) { 1086 console.warn('该æµè§å¨ä¸ºIEæµè§å¨'); 1087 return true; 1088 } else { 1089 return false; 1090 } 1091 }, 1092 // a龿¥æ¼æ¥å符串 1093 concatHref:function(str, selector) { 1094 var $ele = selector ? $(selector) : $("a"); 1095 $ele.each(function() { 1096 var $this = $(this); 1097 var oldHref = $this.attr("href"); 1098 if (!oldHref || oldHref === '#') return; 1099 if (oldHref.indexOf('javascript') === 0) return; 1100 if (oldHref.indexOf('http') === 0 && oldHref.indexOf(location.host) === -1) return; 1101 var hasQuery = oldHref.indexOf("?") !== -1; 1102 var hasHash = oldHref.indexOf("#") !== -1; 1103 // 鲿¢é夿·»å ç¸ååæ° 1104 var paramKey = str.split('=')[0]; 1105 if (oldHref.indexOf(paramKey + '=') !== -1) return; 1106 var newHref; 1107 if (hasHash && !hasQuery) { 1108 newHref = oldHref.replace('#', '?' + str + '#'); 1109 } else if (hasQuery) { 1110 var separator = oldHref.indexOf("?") === oldHref.length - 1 ? '' : '&'; 1111 newHref = oldHref + separator + str; 1112 } else { 1113 newHref = oldHref + "?" + str; 1114 } 1115 $this.attr("href", newHref); 1116 }); 1117 }, 1118 // ç§»å¨ç«¯å±å¹é«åº¦ 1119 screenh:function(){ 1120 function setFullHeight() { 1121 var screenHeight = window.innerHeight; 1122 $('.ys-page-wrap').css('--height-ph',screenHeight+'px'); 1123 } 1124 setFullHeight(); 1125 window.addEventListener('resize', setFullHeight); 1126 }, 1127 /**
1128 * @description 䏿鿩 1129 * @param {String} selector - csséæ©å¨ 1130 * @param {String} value - è·åid/value 1131 */ 1132 select: function(selector, valueKey, callback) { 1133 var $obj = $(selector); 1134 var eventNs = ".ysSelect"; 1135 $obj.find(".ys-select-li").each(function(index) { 1136 var $li = $(this); 1137 if ($li.attr("data-id") === undefined) { 1138 $li.attr("data-id", index); 1139 } 1140 if (!$li.attr("data-value")) { 1141 $li.attr("data-value", $li.text().trim()); 1142 } 1143 }); 1144 $obj.find(".ys-select-hd").off(eventNs).on("click" + eventNs, function(e) { 1145 e.stopPropagation(); 1146 var $thisHd = $(this); 1147 var $parent = $thisHd.closest(".ys-select"); 1148 var $thisBd = $thisHd.siblings(".ys-select-bd"); 1149 var isOpening = !$thisHd.hasClass("on"); 1150 // å ³éå ¶ä»ææçä¸ææ¡ 1151 $(".ys-select-hd").not($thisHd).removeClass("on"); 1152 $(".ys-select-bd").not($thisBd).stop().slideUp(200, function() { 1153 $(this).closest(".ys-select").removeClass("zindex"); 1154 }); 1155 if (isOpening) { 1156 // å±å¼é»è¾ 1157 $thisHd.addClass("on"); 1158 $parent.addClass("zindex"); // å±å¼åç«å³å¢å å±çº§ 1159 $thisBd.stop().slideDown(300, function() { 1160 $(this).addClass("showscroll"); 1161 // ä» å¨æ¾ç¤ºåæ´æ°æ»å¨æ¡ï¼æé«æ§è½ 1162 var $scrollContent = $(this).find(".ys-select-inof"); 1163 if ($scrollContent.data("mCS")) { 1164 $scrollContent.mCustomScrollbar("update"); 1165 } 1166 }); 1167 } else { 1168 // æ¶èµ·é»è¾ 1169 $thisHd.removeClass("on"); 1170 $thisBd.stop().slideUp(200, function() { 1171 $(this).removeClass("showscroll"); 1172 $parent.removeClass("zindex"); 1173 }); 1174 } 1175 }); 1176 $obj.off(eventNs, ".ys-select-li").on("click" + eventNs, ".ys-select-li", function(e) { 1177 e.stopPropagation(); 1178 var $li = $(this); 1179 var $parentBd = $li.closest(".ys-select-bd"); 1180 var $parentHd = $parentBd.siblings(".ys-select-hd"); 1181 var selectShow = $li.text().trim(); 1182 var data = $li.data(); 1183 // 卿è·åå¼ï¼ä¼å 使ç¨ä¼ å ¥ç valueKey 1184 var realVal = valueKey ? $li.data(valueKey) : $li.data("value"); 1185 // å¡«å å¼å¹¶è§¦ååç change äºä»¶ 1186 $parentHd.find(".ys-select-show").val(selectShow); 1187 $parentHd.find(".ys-select-real") 1188 .attr("data-id", data.id) 1189 .val(realVal) 1190 .trigger("change"); 1191 $li.addClass("on").siblings().removeClass("on"); 1192 // èªå¨æ¶èµ· 1193 $parentHd.click(); 1194 if (typeof callback === 'function') { 1195 callback(data); 1196 } 1197 }); 1198 // ç¹ç©ºç½æ¶èµ·ä¸æ 1199 $(document).off(eventNs).on("click" + eventNs, function(e) { 1200 var $target = $(e.target); 1201 var isSelectComponent = $target.closest(".ys-select-hd, .ys-select-bd, .mCSB_scrollTools").length > 0; 1202 if (!isSelectComponent) { 1203 $(".ys-select-hd.on").each(function() { 1204 var $thisHd = $(this); 1205 var $thisBd = $thisHd.siblings(".ys-select-bd"); 1206 $thisHd.removeClass("on"); 1207 $thisBd.stop().slideUp(200, function() { 1208 $(this).removeClass("showscroll"); 1209 $(this).closest(".ys-select").removeClass("zindex"); 1210 }); 1211 }); 1212 } 1213 }); 1214 $obj.on("mousedown" + eventNs, ".mCSB_scrollTools", function(e) { 1215 e.stopPropagation(); 1216 }); 1217 var $scrollArea = $obj.find(".ys-select-inof"); 1218 if ($scrollArea.length && $.fn.mCustomScrollbar) { 1219 $scrollArea.mCustomScrollbar({ 1220 axis: "y", 1221 scrollInertia: 300, // ç¼©çæ¯æ§æ¶é´ï¼æä½æ´è·æ 1222 theme: 'dark', 1223 scrollbarPosition: "outside", 1224 // autoHideScrollbar: true, 1225 mouseWheel: { preventDefault: true } // 鲿¢æ»å¨ç©¿é 1226 }); 1227 } 1228 }, 1229 // pcé»è®¤å¯¼èªä¸æ 1230 navSlide: function() {
1231 var $navItems = $('.head-nav-item-title'); 1232 var $pageWrap = $('.ys-page-wrap'); 1233 var eventNs = '.navSlide'; 1234 var slideSpeed = 300; // ç»ä¸æ§å¶é度 1235 $navItems.off(eventNs).hover(function() { 1236 var $this = $(this); 1237 var $dropdown = $this.siblings('.head-nav-item-down'); 1238 var $parentItem = $this.closest('.head-nav-item'); 1239 $dropdown.stop(true, true).slideDown(slideSpeed); 1240 $parentItem.addClass("yxnav-active1").siblings().removeClass("yxnav-active1"); 1241 $this.closest('.head-nav-item-nub').addClass('on'); 1242 $pageWrap.addClass('open-nav'); 1243 }); 1244 $navItems.closest('.head-nav-item-nub').off(eventNs).hover(function() {}, function() { 1245 var $this = $(this); 1246 var $dropdown = $this.find('.head-nav-item-down'); 1247 var $parentItem = $this.closest('.head-nav-item'); 1248 $dropdown.stop(true, true).slideUp(slideSpeed); 1249 $this.removeClass('on'); 1250 $parentItem.removeClass("yxnav-active1"); 1251 $pageWrap.removeClass('open-nav'); 1252 $('.head-nav-item.act').addClass("yxnav-active1"); 1253 }); 1254 }, 1255 /** 1256 * @description pcé¤ä¸çº§å¤ 1257 * @ele1 hoverç±»å 1258 * @ele2 å éä¸ç±»åçç±»å 1259 * @class1 éä¸ç±»å 1260 */ 1261 navSlide2: function(trigger, targetWrap, activeClass) { 1262 var $triggers = $(trigger); 1263 var eventNs = '.navSlide2'; 1264 $triggers.off(eventNs).hover(function() { 1265 var $this = $(this); 1266 var $target; 1267 if (trigger === targetWrap) { 1268 $target = $this; 1269 } else { 1270 $target = $this.closest(targetWrap); 1271 } 1272 $target.addClass(activeClass).siblings().removeClass(activeClass); 1273 1274 }, function() { 1275 var $this = $(this); 1276 var $target; 1277 if (trigger === targetWrap) { 1278 $target = $this; 1279 } else { 1280 $target = $this.closest(targetWrap); 1281 } 1282 $target.removeClass(activeClass); 1283 $(targetWrap).filter(".act").addClass(activeClass); 1284 }); 1285 }, 1286 /** 1287 * @description ç§»å¨ç«¯å¯¼èªåå§å 1288 * @param {Number} style - 1289 */ 1290 phNavInit: function(style) { 1291 var _this = this; 1292 var eventNs = '.phNav'; 1293 var setPageState = function(isOpen) { 1294 if (isOpen) { 1295 if (_this.scrollbar) _this.scrollbar.hide(); 1296 if (_this.lenisStop) _this.lenisStop(); 1297 $('.ys-page-wrap').addClass('open-nav'); 1298 } else { 1299 if (_this.scrollbar) _this.scrollbar.show(); 1300 if (_this.lenisStart) _this.lenisStart(); 1301 $('.ys-page-wrap').removeClass('open-nav'); 1302 } 1303 }; 1304 // å¯¼èªæ¯å¦åç½ 1305 var toggleWhiteNav = function(isOpen) { 1306 if (isOpen) { 1307 $('.ys-hd-ph').addClass('has-btn'); 1308 } else { 1309 $('.ys-hd-ph').removeClass('has-btn'); 1310 } 1311 }; 1312 var initActiveExpand = function() { 1313 $('body').find('.ys-phnav-haschild .yxnav-active2, .ys-phnav-haschild .yxnav-active3').each(function() { 1314 var $ul = $(this).parent('ul'); 1315 $ul.css('display', 'block'); 1316 $ul.siblings('.ys-phnav-lisbox').find('.ys-phnav-icon').addClass('on'); 1317 }); 1318 }; 1319 // å±å¼æå 1320 var bindAccordion = function() { 1321 $(".ys-phnav-lisbox").off(eventNs).on("click" + eventNs, function() { 1322 var $subNav = $(this).siblings("ul"); 1323 if ($subNav.length > 0) { 1324 $(this).find(".ys-phnav-icon").toggleClass("on"); 1325 $subNav.stop().slideToggle(); 1326 $(this).parent().siblings().find("ul").stop().slideUp(); 1327 $(this).parent().siblings().find(".ys-phnav-icon").removeClass("on"); 1328 } 1329 }); 1330 $(".ys-phnav-lisbox a").on("click", function(e) { e.stopPropagation(); }); 1331 }; 1332 switch (style) { 1333 case 1: 1334 phNavInit1(); 1335 break; 1336 case 2: 1337 phNavInit2(); 1338 break; 1339 case 3: 1340 phNavInit3(); 1341 break; 1342 case 4: 1343 phNavInit4(); 1344 break; 1345 default: 1346 phNavInit1(); 1347 } 1348 function phNavInit1() { 1349 initActiveExpand(); 1350 $(".ys-phnav-menubtn").off(eventNs).on("click" + eventNs, function() { 1351 var isOpening = !$(this).hasClass("on"); 1352 $(this).toggleClass("on"); 1353 toggleWhiteNav(isOpening); 1354 setPageState(isOpening); 1355 $(".ys-phnav-menu").stop().slideToggle(300); 1356 }); 1357 bindAccordion(); 1358 initCustomScroll('.ys-phmenu-scroll'); 1359 } 1360 function phNavInit2() { 1361 initActiveExpand(); 1362 $(".ys-phnavss-btn").off(eventNs).on("click" + eventNs, function(e) { 1363 e.stopPropagation(); 1364 var isOpening = !$(".ys-phnavss-xl").is(':visible'); 1365 $(".ys-phnav-menubtn, .ys-phnav-menu, .ys-phnav2-lang-modal").removeClass("on"); 1366 toggleWhiteNav(isOpening); 1367 setPageState(isOpening); 1368 $(this).toggleClass("on"); 1369 $(".ys-phnavss-xl").stop().slideToggle(300); 1370 }); 1371 $(".ys-main, .ys-footer").on("click" + eventNs, function() { 1372 if($(".ys-phnavss-xl").is(':visible')) { 1373 $(".ys-phnavss-xl").stop().slideUp(200); 1374 $(".ys-phnavss-btn").removeClass('on'); 1375 toggleWhiteNav(false); 1376 setPageState(false); 1377 } 1378 }); 1379 $(".ys-phnav-menubtn").off(eventNs).on("click" + eventNs, function(e) { 1380 e.stopPropagation(); 1381 $(".ys-phnavss-xl").hide(); // ç«å³éèæç´¢ 1382 $(".ys-phnavss-btn").removeClass('on'); 1383 var isOpening = !$(this).hasClass("on"); 1384 if (!isOpening) $(".ys-phnav2-lang-modal").removeClass("on"); 1385 $(this).toggleClass("on"); 1386 $(".ys-phnav-menu").toggleClass("on"); 1387 toggleWhiteNav(isOpening); 1388 setPageState(isOpening); 1389 }); 1390 bindAccordion(); 1391 $(".ys-phnav2-lang-btn").on("click", function() { $(".ys-phnav2-lang-modal").addClass("on"); }); 1392 $(".ys-phnav2-lang-back").on("click", function() { $(".ys-phnav2-lang-modal").removeClass("on"); }); 1393 initCustomScroll('.ys-phmenu-scroll'); 1394 } 1395 function phNavInit3() { 1396 if (_this.modal) { 1397 _this.modal(".ys-phnavss-btn", ".ys-phnavss-modal"); 1398 } 1399 $(".ys-phnav-menubtn").off(eventNs).on("click" + eventNs, function() { 1400 setPageState(true); 1401 $(this).addClass("on"); 1402 $(".ys-phnav-menu").addClass("on"); 1403 }); 1404 $(".ys-phmenu-close").off(eventNs).on("click" + eventNs, function() { 1405 setPageState(false); 1406 $(".ys-phnav-menubtn, .ys-phnav-menu, .ys-phsubnav-modal").removeClass("on"); 1407 $(".ys-phnav3-lang-hd").removeClass("on"); 1408 $(".ys-phnav3-lang-bd").stop().slideUp(0); 1409 }); 1410 $(".ys-phnav-lisbox").off(eventNs).on("click" + eventNs, function() { 1411 var $subNav = $(this).siblings(".ys-phsubnav-modal"); 1412 if ($subNav.length > 0) { $subNav.addClass("on"); } 1413 }); 1414 $(".ys-phsubnav-close").off(eventNs).on("click" + eventNs, function() { 1415 $(this).closest(".ys-phsubnav-modal").removeClass("on"); 1416 }); 1417 $(".ys-phnav3-lang-hd").off(eventNs).on("click" + eventNs, function() { 1418 $(this).toggleClass("on"); 1419 $(".ys-phnav3-lang-bd").stop().slideToggle(); 1420 }); 1421 $(".ys-phnav-lisbox a, .ys-phnav3-lang-hd a").on("click", function(e) { 1422 e.stopPropagation(); 1423 }); 1424 initCustomScroll('.ys-phmenu-scroll'); 1425 initCustomScroll('.ys-phsubnav-scroll'); 1426 } 1427 function phNavInit4() { 1428 initActiveExpand(); 1429 if (_this.modal) { 1430 _this.modal(".ys-phnavss-btn", ".ys-phnavss-modal"); 1431 } 1432 $(".ys-phnav-menubtn").off(eventNs).on("click" + eventNs, function() { 1433 var isOpening = !$(this).hasClass("on"); 1434 $(this).toggleClass("on"); 1435 toggleWhiteNav(isOpening); 1436 setPageState(isOpening); 1437 $(".ys-phnav-menu").stop().slideToggle(300, function() { 1438 if ($.fn.mCustomScrollbar) $('.ys-phmenu-scroll').mCustomScrollbar("update"); 1439 }); 1440 }); 1441 bindAccordion(); 1442 initCustomScroll('.ys-phmenu-scroll'); 1443 } 1444 function initCustomScroll(selector) { 1445 var $el = $(selector); 1446 if ($el.length && $.fn.mCustomScrollbar) { 1447 $el.mCustomScrollbar({ 1448 axis: "y", 1449 scrollInertia: 500, 1450 theme: 'dark', 1451 scrollbarPosition: "outside" 1452 }); 1453 } 1454 } 1455 }, 1456 /**
1457 * @description å 页éç¹å®ä½ 1458 * @param {String} btn éç¹ç¹å»æé®ï¼éæ©å¨,é»è®¤.anchor-btnï¼ 1459 * @param {String} selector å¯¹åºæ¿åï¼éæ©å¨ï¼é»è®¤.mod-pointï¼ 1460 * @param {number} pos è·ç¦»é¡¶é¨è·ç¦»ï¼pxï¼é»è®¤å¯¼èªé«åº¦ï¼ 1461 * @param {number} pos2 æ»å¨è·ç¦»é¡¶é¨è·ç¦»pos2ï¼pxï¼é»è®¤å±å¹é«åº¦çä¸åï¼ 1462 */ 1463 insideAnchor: function(btn, selector, pos, pos2) { 1464 var _this = this; 1465 var btn = btn ? btn : ".anchor-btn"; 1466 var selector = selector ? selector : ".mod-point"; 1467 var getHeaderHeight = function() { 1468 if (window.innerWidth < 1200) return 56; 1469 return $('.ys-hd-pc').height() || 0; 1470 }; 1471 var pos = pos ? pos : getHeaderHeight(); 1472 var pos2 = pos2 ? pos2 : $(window).height() / 2; 1473 achange(); 1474 asideNav(); 1475 $(window).on("scroll", asideNav); 1476 $(window).on("load", asideNav); 1477 $(window).on("resize", asideNav); 1478 function achange() { 1479 $(btn).on("click", function() { 1480 var pag = $(this).attr('data-num'); 1481 $(selector).removeClass('act-nr'); 1482 var $target = $(selector + '[data-num="' + pag + '"]').addClass('act-nr'); 1483 setTimeout(function() { 1484 if ($target.length > 0) { 1485 var targetTop = $target.offset().top - pos; 1486 _this.goTop(500, targetTop); 1487 } 1488 }, 100); 1489 }); 1490 } 1491 function asideNav() { 1492 var maxNum = $(btn + ':last-child').attr('data-num'); 1493 var scrollTop = $(window).scrollTop(); 1494 for (var i = 0; i <= maxNum; i++) { 1495 var $item = $(selector + '[data-num="' + i + '"]'); 1496 if ($item.length > 0) { 1497 var pos1 = $item.offset().top - pos2; 1498 if (scrollTop > pos1) { 1499 // æ»å¨æ¶ç²¾åèå¨ 1500 $(selector).removeClass('act-nr'); 1501 $item.addClass('act-nr'); 1502 $(btn + '[data-num="' + i + '"]').addClass('act').siblings().removeClass('act'); 1503 } 1504 } 1505 } 1506 } 1507 }, 1508 /** 1509 * @description ä¾§è¾¹éç¹éè 1510 * @param {String} selector ä¾§è¾¹éç¹çåï¼éæ©å¨ï¼é»è®¤.mod-anchorï¼ 1511 * @param {String} selector1 æ»å°æ¤æ¿åä¾§è¾¹éèï¼éæ©å¨ï¼é»è®¤.anchor-hideï¼ 1512 * @param {Number} topx éç¹å¼å§åºç°ä½ç½®ï¼é»è®¤bannerä¸ï¼ 1513 * @param {Number} botx éç¹ç»æåºç°ä½ç½®ï¼é»è®¤footerï¼ 1514 */ 1515 anchorHide: function(selector, selector1, topx_custom, botx_custom) { 1516 var _this = this; 1517 var $selector = $(selector || ".mod-anchor"); 1518 var $selector1 = $(selector1 || ".anchor-hide"); 1519 // å°åéåå ¥å±é¨å¯¹è±¡ï¼é¿å resize æ¶ä¸¢å¤± 1520 var vals = { 1521 sideh: 0, 1522 placeh: 0, 1523 topx: 0, 1524 botx: 0 1525 }; 1526 function initValue() { 1527 vals.sideh = $selector.outerHeight() / 2; 1528 vals.placeh = $(window).height() / 2 - vals.sideh; 1529 var banh = $('.ys-nybanner').length > 0 ? $('.ys-nybanner').outerHeight() : 0; 1530 var mainTop = $('.ys-main').length > 0 ? $('.ys-main').offset().top : 0; 1531 var footerTop = $('.ys-footer').length > 0 ? $('.ys-footer').offset().top : $(document).height(); 1532 // ä¼å 使ç¨ä¼ å ¥çåæ°ï¼å¦åå¨æè®¡ç® 1533 vals.topx = topx_custom ? topx_custom : (mainTop + banh - vals.placeh); 1534 vals.botx = botx_custom ? botx_custom : (footerTop - $(window).height() + vals.placeh); 1535 } 1536 // 头é¨åºé¨æ¾éé»è¾ 1537 function tfHide() { 1538 var sTop = $(window).scrollTop(); 1539 if (sTop > vals.topx && sTop < vals.botx) { 1540 $selector.addClass('on1'); 1541 } else { 1542 $selector.removeClass('on1'); 1543 } 1544 } 1545 // ä¾§è¾¹éç¹éå°ç¹å®åºåï¼selector1ï¼æ¶çé¿è®©é»è¾ 1546 function scrollAn() { 1547 var sTop = $(window).scrollTop(); 1548 var shouldHide = false; // å¢å æ å¿ä½ï¼è§£å³å¾ªç¯è¦çé®é¢ 1549 $selector1.each(function() { 1550 var $item = $(this); 1551 var itemH = $item.outerHeight(); 1552 // 计ç®å½ååºå触åéèç临çç¹ 1553 var t1 = $item.offset().top - $(window).height() / 2 - vals.sideh; 1554 var b1 = $item.offset().top + itemH - ($(window).height() / 2 - vals.sideh); 1555 if (sTop > t1 && sTop < b1) { 1556 shouldHide = true; 1557 return false; // æ¾å°ä¸ä¸ªå¹é ç就跳åºå¾ªç¯ï¼æé«æ§è½ 1558 } 1559 }); 1560 if (shouldHide) { 1561 $selector.addClass('act'); 1562 } else { 1563 $selector.removeClass('act'); 1564 } 1565 } 1566 $(window).on("load.anchorHide resize.anchorHide", function() { 1567 initValue(); 1568 tfHide(); 1569 scrollAn(); 1570 }); 1571 $(window).on("scroll.anchorHide", function() { 1572 tfHide(); 1573 scrollAn(); 1574 }); 1575 setTimeout(function() { 1576 initValue(); 1577 tfHide(); 1578 scrollAn(); 1579 }, 500); 1580 }, 1581 // å¾çæ¾å¤§ 1582 viewer:function(selector,Boolean){ 1583 var _this = this; 1584 var selector = selector ? selector : ".viewerimg"; 1585 var viewerBool = Boolean ? Boolean : true; 1586 $(selector).viewer({ 1587 navbar: Boolean, 1588 title: Boolean, 1589 toolbar: Boolean, 1590 tooltip: Boolean, 1591 url: 'data-original', 1592 show: function() { 1593 // éå®é¡µé¢æ»å¨ 1594 if (ys.scrollbar) ys.scrollbar.hide(); 1595 if (ys.lenisStop) ys.lenisStop(); 1596 $("body").addClass("mod-viewer"); 1597 }, 1598 // 彿¥çå¨éèï¼å¨ç»å¼å§åï¼ 1599 hide: function() { 1600 // æ¢å¤é¡µé¢æ»å¨ 1601 if (ys.scrollbar) ys.scrollbar.show(); 1602 if (ys.lenisStart) ys.lenisStart(); 1603 $("body").removeClass("mod-viewer"); 1604 } 1605 }); 1606 }, 1607 /**
1608 * @description 走马ç¯ä¸ªæ° 1609 * @param {Number} selector - è·åselector1éselectorçæ»ä¸ªæ° 1610 * @param {Number} selector1 - selector1ç--totalæ¾ç¤ºè·åçä¸ªæ° 1611 * @param {Number} speed - 走马ç¯é度 1612 * nohover - 䏿¬åæå 1613 */ 1614 goon: function(selector, selector1, speed) { 1615 $(selector1).each(function() { 1616 var $parent = $(this); 1617 if ($parent.data('gsap_horse')) { 1618 $parent.data('gsap_horse').kill(); 1619 } 1620 var $original = $parent.find('.ys-horse-inof1'); 1621 var html1 = $original.prop('outerHTML'); 1622 if ($parent.find('.ys-horse-inof2').length < 1) { 1623 $parent.append(html1); 1624 $parent.find('.ys-horse-inof').eq(1).addClass('ys-horse-inof2').removeClass('ys-horse-inof1'); 1625 } 1626 if ($parent.find('.ys-horse-inof3').length < 1) { 1627 $parent.append(html1); 1628 $parent.find('.ys-horse-inof').eq(2).addClass('ys-horse-inof3').removeClass('ys-horse-inof1'); 1629 } 1630 var shu1 = $parent.find(selector).length; 1631 $parent.css('--total', shu1); 1632 var effectiveSpeed = speed || 3; 1633 var duration1 = effectiveSpeed * shu1; 1634 var $e1 = $parent.find('.ys-horse-inof1'); 1635 var $e2 = $parent.find('.ys-horse-inof2'); 1636 var $e3 = $parent.find('.ys-horse-inof3'); 1637 var horse = gsap.timeline({ repeat: -1 }); 1638 $parent.data('gsap_horse', horse); // åå¨å¨ç»å¯¹è±¡ä»¥ä¾¿åç»æ¸ ç 1639 if ($parent.hasClass('act')) { 1640 horse.set($e1, { x: "0%" }).set($e2, { x: "100%" }).set($e3, { x: "-100%" }); 1641 horse.to([$e1, $e2, $e3], { x: "+=100%", duration: duration1, ease: "none" }); 1642 } else if ($parent.hasClass('up')) { 1643 horse.to($e1, { y: "-100%", duration: duration1, ease: "none" }, 0) 1644 .to($e2, { y: "0%", duration: duration1, ease: "none" }, 0) 1645 .to($e3, { y: "100%", duration: duration1, ease: "none" }, 0); 1646 } else if ($parent.hasClass('down')) { 1647 horse.to($e1, { y: "100%", duration: duration1, ease: "none" }, 0) 1648 .to($e2, { y: "200%", duration: duration1, ease: "none" }, 0) 1649 .to($e3, { y: "0%", duration: duration1, ease: "none" }, 0); 1650 } else { 1651 horse.to($e1, { x: "-100%", duration: duration1, ease: "none" }, 0) 1652 .to($e2, { x: "0%", duration: duration1, ease: "none" }, 0) 1653 .to($e3, { x: "100%", duration: duration1, ease: "none" }, 0); 1654 } 1655 $parent.off('mouseenter mouseleave click'); 1656 if (!$parent.hasClass('nohover')) { 1657 if (window.innerWidth > 1199) { 1658 $parent.hover(function() { horse.pause(); }, function() { horse.resume(); }); 1659 } else { 1660 $parent.on('click', function() { 1661 if ($parent.hasClass('act-on')) { 1662 horse.resume(); 1663 $parent.removeClass('act-on'); 1664 } else { 1665 horse.pause(); 1666 $parent.addClass('act-on'); 1667 } 1668 }); 1669 } 1670 } 1671 }); 1672 }, 1673 // slickè½®æè¿åº¦æ¡ 1674 dots1: function() { 1675 var _this = this; 1676 $('.ys-dots1').appear(function() { 1677 $(this).addClass('dots-go'); 1678 }); 1679 $('.ys-dots1 .slick-slide video').each(function() { 1680 var $video = $(this); 1681 var $container = $video.parents('.ys-dots1'); 1682 var index = $video.parents('.slick-slide').attr('data-slick-index'); 1683 var setDuration = function(duration) { 1684 if (duration) { 1685 $container.find('.slick-dots li').eq(index).css('--pro', duration + 's'); 1686 } 1687 }; 1688 if (this.readyState >= 1) { 1689 setDuration(this.duration); 1690 } else { 1691 $video.one('loadedmetadata', function() { 1692 setDuration(this.duration); 1693 }); 1694 } 1695 }); 1696 }, 1697 // ç¦æ¢å³é® 1698 rightclick:function() { 1699 document.addEventListener('contextmenu', function(e) { 1700 e.preventDefault(); 1701 }); 1702 }, 1703 // ä¿æ¤é¡µé¢å¾çæå 容 1704 websafe:function(){ 1705 // ç¦ç¨å³é®èå 1706 document.addEventListener('contextmenu', function(e) { 1707 e.preventDefault(); 1708 }); 1709 // ç¦ç¨ F12 å 常ç¨çå¼åè å·¥å ·å¿«æ·é® (å¯éï¼å¢å ç ´è§£ææ¬) 1710 document.addEventListener('keydown', function(e) { 1711 if ( 1712 e.key === 'F12' || 1713 (e.ctrlKey && e.shiftKey && (e.key === 'I' || e.key === 'J' || e.key === 'C')) || 1714 (e.ctrlKey && e.key === 'U') 1715 ) { 1716 e.preventDefault(); 1717 } 1718 }); 1719 // 鲿¢ææ½ä¸è½½ 1720 $('img').on('dragstart', function(e) { 1721 e.preventDefault(); 1722 }); 1723 }, 1724 // åºé¨å享äºç»´ç
1725 footershare: function(li, btn1, code1) { 1726 var $li = $(li || ".footer-share li"); 1727 var $btn1 = $(btn1 || ".footer-share-btn"); 1728 var $code1 = $(code1 || ".footer-share-code"); 1729 //å è§£ç»ï¼é²æ¢ resize æå¤æ¬¡åå§å导è´äºä»¶å å 1730 $li.off('mouseenter mouseleave'); 1731 $btn1.off('click'); 1732 $(document).off('click.share'); // 使ç¨å½å空é´è§£ç» 1733 $code1.off('click'); 1734 if (window.innerWidth > 1199) { 1735 $li.hover(function() { 1736 $(this).find($code1).stop().slideDown(300); 1737 }, function() { 1738 $(this).find($code1).stop().slideUp(200); 1739 }); 1740 } else { 1741 $btn1.on('click', function(e) { 1742 e.stopPropagation(); 1743 var $currentCode = $(this).parents('li').find($code1); 1744 $currentCode.stop().slideToggle(300); 1745 $(this).parents('li').siblings().find($code1).stop().slideUp(200); 1746 }); 1747 // 使ç¨å½å空é´ç»å®ï¼æ¹ä¾¿ç®¡çï¼ç¹å»é¡µé¢ä»»æä½ç½®å ³é 1748 $(document).on('click.share', function() { 1749 $code1.stop().slideUp(200); 1750 }); 1751 // 黿¢äºç»´ç åºåèªèº«çç¹å»å泡ï¼é²æ¢ç¹äºç»´ç æ¶ä¹è§¦åå ³éï¼ 1752 $code1.on('click', function(e) { 1753 e.stopPropagation(); 1754 }); 1755 } 1756 }, 1757 // åºé¨å¯å¯¼èªç§»å¨ç«¯ 1758 // Boolean为true,ç¹å»ä¸çº§å¯¼èªä¸è·³è½¬ï¼é»è®¤false,ç¹å»ä¸çº§å¯¼èªè·³è½¬ 1759 footernav: function(Boolean) { 1760 Boolean = Boolean || false; 1761 var $navItem = $('.footer-nav>li'); 1762 $navItem.each(function() { 1763 if ($(this).find('ul').length < 1) { 1764 $(this).addClass('no-nav'); 1765 } 1766 }); 1767 $navItem.off('click').on('click', function(e) { 1768 if ($(this).find('ul').length > 0 && Boolean) { 1769 e.preventDefault(); // æ ¹æ®éæ±å³å®æ¯å¦é»æ¢ a æ ç¾è·³è½¬ 1770 } 1771 $(this).toggleClass('act').siblings().removeClass('act'); 1772 $(this).find('ul').stop().slideToggle(300); 1773 $(this).siblings().find('ul').stop().slideUp(250); 1774 }); 1775 }, 1776 // è¯è¨ä¸æ 1777 lang: function(hover1, down1) { 1778 var $hover = $(hover1 || ".head-lang"); 1779 var $down = $(down1 || ".head-lang-down"); 1780 // å è§£ç»ï¼é²æ¢éå¤åå§å 1781 $hover.off('mouseenter mouseleave click'); 1782 if (window.innerWidth > 1199) { 1783 $hover.hover(function() { 1784 $(this).addClass('act'); 1785 $(this).find($down).stop().slideDown(200); 1786 }, function() { 1787 var $this = $(this); 1788 $this.find($down).stop().slideUp(200, function() { 1789 $this.removeClass('act'); 1790 }); 1791 }); 1792 } else { 1793 $hover.on('click', function(e) { 1794 e.stopPropagation(); 1795 $(this).toggleClass('act'); 1796 $(this).find($down).stop().slideToggle(300); 1797 }); 1798 $(document).on('click.lang', function() { 1799 $down.slideUp(200); 1800 $hover.removeClass('act'); 1801 }); 1802 } 1803 }, 1804 // æç´¢ 1805 pcSearch: function(style) { 1806 var _this = this; 1807 var $header = $('.ys-hd-pc'); 1808 // æ¸ ç彿°ï¼é²æ¢æ ·å¼åæ¢æ¶æ§äºä»¶å¹²æ° 1809 function clearEvents() { 1810 $(".head-search-btn").off("click"); 1811 $header.off("mouseenter mouseleave"); 1812 $(document).off("click.pcSearch"); 1813 } 1814 // éç¨ç䏿æç´¢é»è¾ (éé style 2, 3 ç) 1815 function commonSlideSearch(btnSelector, winSelector) { 1816 clearEvents(); 1817 var $btn = $(btnSelector); 1818 var $win = $(winSelector); 1819 $btn.on("click", function(e) { 1820 e.stopPropagation(); 1821 $win.stop().slideToggle(); 1822 $(this).toggleClass('act'); 1823 $header.toggleClass('has-search'); 1824 }); 1825 // 黿¢çªå£å é¨ç¹å»å泡 1826 $win.on("click", function(e) { 1827 e.stopPropagation(); 1828 }); 1829 // ç¹å»ç©ºç½å¤å ³é 1830 $(document).on("click.pcSearch", function() { 1831 $win.stop().slideUp(); 1832 $btn.removeClass('act'); 1833 $header.removeClass('has-search'); 1834 }); 1835 } 1836 switch (style) { 1837 case 1: 1838 this.modal(".ys-search1 .head-search-btn", ".ys-search1 .ys-phnavss-modal"); 1839 break; 1840 case 2: 1841 commonSlideSearch(".ys-search2 .head-search-btn", ".ys-search2-win"); 1842 break; 1843 case 3: 1844 commonSlideSearch(".ys-search3 .head-search-btn", ".yx-search3xlbox"); 1845 // hoverç§»åºå¯¼èªæ¶èµ· 1846 $header.hover(function() {}, function() { 1847 $(".yx-search3xlbox").stop().slideUp(); 1848 $(".ys-search3 .head-search-btn").removeClass('act'); 1849 $header.removeClass('has-search'); 1850 }); 1851 break; 1852 case 4: 1853 // é¢çä½ç½® 1854 break; 1855 case 5: 1856 this.modal(".ys-search5 .head-search-btn", ".ys-search5 .ys-phnavss-modal"); 1857 break; 1858 default: 1859 commonSlideSearch(".ys-search3 .head-search-btn", ".yx-search3xlbox"); 1860 // hoverç§»åºå¯¼èªæ¶èµ· 1861 $header.hover(function() {}, function() { 1862 $(".yx-search3xlbox").stop().slideUp(); 1863 $(".ys-search3 .head-search-btn").removeClass('act'); 1864 $header.removeClass('has-search'); 1865 }); 1866 } 1867 }, 1868 // éé¡¹å¡ 1869 // 妿项ç®ä¸ç¨äºè½®æå¾ææå è½½ï¼å¯ä»¥å¨æ¤å¤è§¦å resize 1870 tab: function(ele1, ele2, ele3,callback) { 1871 var _ele1 = ele1 || '.ys-tab'; 1872 var _ele2 = ele2 || '.ys-tab-btn-item'; 1873 var _ele3 = ele3 || '.ys-tab-core-item'; 1874 $(_ele1).each(function() { 1875 var $parent = $(this); 1876 // åªæ¥æ¾å½å Tab 容å¨ä¸çç´æ¥æé®ï¼é²æ¢å¹²æ°åµå¥ç Tab 1877 var $btns = $parent.find(_ele2); 1878 var $contents = $parent.find(_ele3); 1879 $btns.off('click').on('click', function() { 1880 // ä½¿ç¨ index($btns) ç¡®ä¿åºå·åªå¨æé®ç»å 计ç®ï¼ä¸åå ¶ä»å å¼å ç´ å¹²æ° 1881 var index = $btns.index(this); 1882 // æé®ç¶æåæ¢ 1883 $(this).addClass("on").siblings(_ele2).removeClass("on"); 1884 // å 容ååæ¢ï¼ 1885 // 1. åªæä½å½å容å¨ä¸çå 容 1886 // 2. ä½¿ç¨ fadeTo é å hide å¯ä»¥è®©å¨ç»å¨æäºå¡é¡¿ç¯å¢ä¸æ´å¹³æ» 1887 $contents.eq(index).stop().fadeIn(300) 1888 .siblings(_ele3).stop().hide(); 1889 if (typeof callback === 'function') { 1890 callback(index); 1891 } 1892 }); 1893 }); 1894 }, 1895 // è½½å ¥ 1896 fadeup1: function(ele1, class1, pos) { 1897 var _ele = ele1 || '.ys-upfade1'; 1898 var _class = class1 || 'ys-fade-true'; 1899 var _pos = pos || 0; // å¦ææ²¡ä¼ ï¼é»è®¤åç§»0 1900 $( _ele ).each(function () { 1901 let ele = $(this); 1902 ScrollTrigger.create({ 1903 trigger: ele, 1904 endTrigger: $('.ys-main').length ? '.ys-main' : ele, 1905 start: "top bottom-=" + _pos, 1906 end: "bottom top", 1907 toggleActions: "play none none none", 1908 onEnter: function(){ 1909 ele.addClass(_class); 1910 } , 1911 onLeaveBack: function(){ 1912 ele.removeClass(_class); 1913 } , 1914 }); 1915 }); 1916 }, 1917 // å¢å pcé»è®¤å¾ªç¯ææ¾è§é¢ï¼ç§»å¨ç«¯éè 1918 playVideopc: function(ele1) { 1919 var $targets = $(ele1); 1920 if (window.innerWidth > 1199) { 1921 $targets.each(function() { 1922 var $el = $(this);
1923 var _v = $el.is('video') ? this : $el.find('video').get(0); 1924 if (!_v) return; 1925 _v.muted = true; 1926 _v.loop = true; 1927 _v.setAttribute('playsinline', ''); 1928 var initTrigger = function() { 1929 ScrollTrigger.create({ 1930 trigger: _v, 1931 invalidateOnRefresh: true, 1932 start: "top bottom", 1933 end: "bottom top", 1934 onEnter: () => _v.play(), 1935 onLeaveBack: () => _v.pause() 1936 }); 1937 ScrollTrigger.refresh(); 1938 }; 1939 if (_v.readyState >= 1) { 1940 initTrigger(); 1941 } else { 1942 _v.addEventListener('loadedmetadata', initTrigger); 1943 } 1944 }); 1945 }else{ 1946 $targets.each(function() { 1947 var $el = $(this); 1948 var $video = $el.is('video') ? $el : $el.find('video'); 1949 if ($video.length > 0) { 1950 // å½»åºéæ¯è§é¢é²æ¢åå°è¿è¡ 1951 $video.each(function() { 1952 this.pause(); 1953 this.src = ""; 1954 this.load(); 1955 $(this).remove(); 1956 }); 1957 } 1958 }); 1959 } 1960 }, 1961 // open ç¹å» ele1 å ç±»åactï¼ 1962 // close ç¹å» ele1 å»ç±»å act 1963 filter:function(open,close,ele1,act){ 1964 var _this = this; 1965 var $body = $('body'); 1966 $body.on('click', open, function() { 1967 var $target = $(this).parents(ele1); 1968 $target.addClass(act); 1969 if (ys.scrollbar) ys.scrollbar.hide(); 1970 if (typeof ys.lenisStop === 'function') ys.lenisStop(); 1971 }); 1972 $body.on('click', close, function() { 1973 var $target = $(this).parents(ele1); 1974 $target.removeClass(act); 1975 if (ys.scrollbar) ys.scrollbar.show(); 1976 if (typeof ys.lenisStart === 'function') ys.lenisStart(); 1977 }); 1978 }, 1979 // 表åç±» 1980 // æç¤ºè¯ 1981 form_init: function() { 1982 $('.ys-fii-tips').each(function() { 1983 var $this = $(this); 1984 var $item = $this.closest('.ys-form-inof-item'); 1985 var $group = $this.closest('.ys-form-inof'); 1986 var groupTips = $group.data('tips') || ""; 1987 var itemTip = $item.data('tips') || ""; 1988 var itemTips1 = $item.data('tips1') || ""; 1989 if (itemTip) { 1990 $this.find('i').text(itemTip); 1991 $this.find('span').text(groupTips); 1992 } else { 1993 $this.find('span').text(itemTips1 || groupTips); 1994 } 1995 }); 1996 }, 1997 // area为cn为å½å ï¼gl为海å¤,hmtä¸ºå«æ¸¯æ¾³å°çå½å ï¼é»è®¤å½å 1998 tips: function(area, callback) { 1999 area = area || 'cn'; 2000 var telReg = /^(\+86\s?)?1[3-9]\d{9}$/; 2001 var emailReg = /^[\w\-\.]+@[\w\-\.]+(\.\w+)+$/; 2002 // ææºå½å±å°åæ¢ 2003 $('.ys-fpc-top').off('click').click(function() { 2004 $(this).siblings('.ys-fpc-down').stop().slideToggle(); 2005 $(this).closest('.ys-form-phone').toggleClass('phone-select'); 2006 }); 2007 $('.ys-form-phone-city').on('click', '.ys-select-item', function() { 2008 var $parent = $(this).closest('.ys-form-phone'); 2009 var selectShow = $(this).text().trim(); 2010 $parent.find(".ys-fpc-top span").text(selectShow); 2011 $parent.removeClass('phone-select ys-form-empty').find('input').val(''); 2012 $parent.find('.ys-fpc-down').stop().slideUp(); 2013 if (selectShow == '港澳å°') { 2014 $parent.addClass('hk-ma-tai'); 2015 } else { 2016 $parent.removeClass('hk-ma-tai'); 2017 } 2018 }); 2019 // æ ¸å¿æ ¡éªé»è¾ 2020 var checkRequired = function($item) { 2021 var $input = $item.find('input, textarea'); 2022 var val = $input.val() ? $input.val().trim() : ""; 2023 if($item.hasClass('ys-form-phone') && $item.find('.iti').length > 0){ 2024 var $input1 = $item.find('input.iti__tel-input'); 2025 var val1 = $input1.val() ? $input1.val().trim() : ""; 2026 } 2027 // 䏿/æç´¢/å¾éæ¡é»è¾ 2028 if ($item.find('.ys-fii-select-search, .ys-fii-select, [class^="ys-fii-checkbox"]').length > 0) { 2029 if ($item.find('.ys-select-show').val().trim()) $item.removeClass('ys-form-empty'); 2030 else $item.addClass('ys-form-empty'); 2031 } 2032 // å¹³éºæé®é»è¾ 2033 else if ($item.hasClass('ys-form-tiled')) { 2034 if ($item.find('.ys-form-oi-nub.on').length > 0) $item.removeClass('ys-form-empty'); 2035 else $item.addClass('ys-form-empty'); 2036 } 2037 // éç§åè®®é»è¾ 2038 else if ($item.hasClass('ys-form-inof-agree')) { 2039 if ($item.hasClass('on')) $item.removeClass('ys-form-empty'); 2040 else $item.addClass('ys-form-empty'); 2041 } 2042 // ææºå·/é®ç®±æ£åé»è¾ 2043 else { 2044 if ($item.hasClass('ys-form-phone')) { 2045 if($item.find('.iti').length > 0){ 2046 var isIntl1 = $('.iti__cn').length ; 2047 if(val1 === ''){
2048 $item.addClass('ys-form-empty').removeClass('ys-form-empty1'); 2049 } else { 2050 if (isIntl1<2 ? val1.length < 6 : !telReg.test(val1)) { 2051 $item.addClass('ys-form-empty ys-form-empty1'); 2052 } else { 2053 $item.removeClass('ys-form-empty ys-form-empty1'); 2054 } 2055 } 2056 }else{ 2057 var isIntl = (area == 'gl' || (area == 'hmt' && $item.hasClass('hk-ma-tai'))); 2058 if (isIntl ? val.length < 6 : !telReg.test(val)) { 2059 $item.addClass('ys-form-empty ys-form-empty1'); 2060 } else { 2061 $item.removeClass('ys-form-empty ys-form-empty1'); 2062 } 2063 } 2064 } else if (val === '') { 2065 $item.addClass('ys-form-empty').removeClass('ys-form-empty1'); 2066 } else if ($item.hasClass('ys-form-email') && !emailReg.test(val)) { 2067 $item.addClass('ys-form-empty ys-form-empty1'); 2068 } else { 2069 $item.removeClass('ys-form-empty ys-form-empty1'); 2070 } 2071 } 2072 }; 2073 // äºä»¶ç»å® 2074 $('.ys-form-inof').each(function() { 2075 var $form = $(this); 2076 var debounceTimer; // 鲿 2077 // éç§å¾éç¹å» 2078 $form.find('.ys-fia-text-btn').click(function() { 2079 var $agree = $(this).closest('.ys-form-inof-agree'); 2080 $agree.toggleClass('on'); 2081 checkRequired($agree); 2082 }); 2083 // å¹³éºæé®ç¹å» 2084 $form.find(".ys-form-oi-nub").click(function() { 2085 var $tiled = $(this).closest('.ys-form-tiled'); 2086 if ($tiled.hasClass('ys-form-tiled2')) $(this).toggleClass('on'); 2087 else $(this).addClass("on").siblings().removeClass("on"); 2088 checkRequired($tiled.closest('.ys-form-required')); 2089 }); 2090 // è¾å ¥æ¡å®æ¶çå¬ 2091 $form.find('.ys-form-required input, .ys-form-required textarea').on('input propertychange', function() { 2092 var $el = $(this); 2093 clearTimeout(debounceTimer); 2094 debounceTimer = setTimeout(function() { 2095 checkRequired($el.closest('.ys-form-required')); 2096 }, 300); 2097 }); 2098 // 失å»ç¦ç¹ 2099 $form.find('.ys-form-required input, .ys-form-required textarea').on('blur', function() { 2100 checkRequired($(this).closest('.ys-form-required')); 2101 }); 2102 // 䏿èåéæ©çå¬ 2103 $form.on('click', '.ys-form-required .ys-select-bd .ys-select-li', function() { 2104 $(this).closest('.ys-form-required').removeClass('ys-form-empty'); 2105 }); 2106 // æäº¤æé®é»è¾ 2107 $form.find('.ys-fii-submit').off('click').click(function() { 2108 var $currentForm = $(this).closest('.ys-form-inof'); 2109 // æäº¤æ¶å¯¹ææééèçå¿ å¡«é¡¹æ§è¡ä¸æ¬¡å ¨éæ£æ¥ 2110 $currentForm.find('.ys-form-required:not(.ys-form-hide)').each(function() { 2111 checkRequired($(this)); 2112 }); 2113 // æç»å¤æ ok ç¶æå¹¶æ§è¡åè° 2114 var ok = true; 2115 if ($currentForm.find('.ys-form-empty').length > 0) { 2116 ok = false; 2117 var $firstError = $currentForm.find('.ys-form-empty').first(); 2118 if (typeof ys.focus === 'function') ys.focus($firstError); 2119 } 2120 if (ok) callback && callback($currentForm.data()); 2121 }); 2122 }); 2123 }, 2124 // èç¦ 2125 focus: function(ele) { 2126 var $ele = $(ele); 2127 if (!$ele.hasClass('ys-form-empty')) return false; 2128 var top_pos = $ele.offset().top - $(window).height() / 3; 2129 if ($ele.closest('.ys-modal').length === 0) { 2130 $("html, body").stop().animate({ 2131 scrollTop: top_pos 2132 }, 300); 2133 } 2134 var isSpecial = $ele.find('.ys-fii-select-search, .ys-fii-select').length > 0 || 2135 $ele.hasClass('ys-form-inof-agree'); 2136 if (!isSpecial) { 2137 $ele.find('.ys-fii-input input').focus(); 2138 } 2139 return true; 2140 }, 2141 /**
2142 * @description 带æç´¢åé䏿鿩 2143 * @param {String} selector - csséæ©å¨ 2144 * @param {String} value - ä¼ å¼ 2145 */ 2146 select_search: function(selector, value, callback) { 2147 var $obj = $(selector); 2148 // åå§åæ°æ® 2149 $obj.find(".ys-select-li").each(function(index) { 2150 var $this = $(this); 2151 if ($this.attr("data-id") === undefined) $this.attr("data-id", index); 2152 $this.attr("data-value", $this.text().trim()); 2153 }); 2154 // å 鍿 ¡éª 2155 var checkSelectEmpty = function($targetSelect) { 2156 var $required = $targetSelect.closest('.ys-form-required'); 2157 if ($required.length > 0) { 2158 var val = $targetSelect.find(".ys-select-show").val(); 2159 $required.toggleClass('ys-form-empty', (!val || val.trim() === "")); 2160 } 2161 }; 2162 var jumpToSelectedSync = function($container, $bd) { 2163 var $select = $bd.closest(".ys-select"); 2164 var currentText = $select.find(".ys-select-show").val() ? $select.find(".ys-select-show").val().trim() : ""; 2165 // ç«å³åæ¥ç±»åç¶æ 2166 $bd.find(".ys-select-li").removeClass("on"); 2167 var $targetLi = null; 2168 if (currentText !== "") { 2169 $bd.find(".ys-select-li").each(function() { 2170 if ($(this).text().trim() === currentText) { 2171 $targetLi = $(this).addClass("on"); 2172 return false; 2173 } 2174 }); 2175 } 2176 // å¼ºå¶æä»¶å¨éèç¶æä¸å®æè®¡ç® 2177 $container.mCustomScrollbar("update"); 2178 // æ§è¡å®ä½ï¼scrollInertia 设为 0 2179 if ($targetLi) { 2180 $container.mCustomScrollbar("scrollTo", $targetLi, { 2181 scrollInertia: 0, 2182 timeout: 0, 2183 callbacks: false // ç¦ç¨åè°ä»¥æåæ§è½ 2184 }); 2185 } else { 2186 $container.mCustomScrollbar("scrollTo", "top", { scrollInertia: 0, timeout: 0 }); 2187 } 2188 }; 2189 // 头é¨ç¹å»é»è¾ 2190 $obj.find(".ys-select-hd").off('click').click(function(e) { 2191 e.stopPropagation(); 2192 var $thisHd = $(this); 2193 var $thisSelect = $thisHd.closest(".ys-select"); 2194 var $thisBd = $thisHd.siblings(".ys-select-bd"); 2195 var $scrollContainer = $thisBd.find(".ys-fiiss-core").length > 0 ? 2196 $thisBd.find(".ys-fiiss-core") : 2197 $thisBd.find(".ys-select-inof"); 2198 // äºæ¥å ³éé»è¾... 2199 $(".ys-select-hd").not(this).each(function() { 2200 var $other = $(this).closest(".ys-select"); 2201 if ($other.hasClass("zindex")) { 2202 $(this).removeClass("on"); 2203 $other.find('.ys-fiiss-input-close').trigger('click'); 2204 $other.find(".ys-select-bd").stop().hide(); 2205 $other.find(".ys-checkbox-bd").stop().hide(); 2206 $other.removeClass("zindex"); 2207 checkSelectEmpty($other); 2208 } 2209 }); 2210 if ($thisSelect.hasClass("zindex")) { 2211 // æ¶èµ· 2212 $thisHd.removeClass("on"); 2213 $thisSelect.find('.ys-fiiss-input-close').trigger('click'); 2214 $thisBd.stop().slideUp(function() { 2215 $thisSelect.removeClass("zindex"); 2216 checkSelectEmpty($thisSelect); 2217 }); 2218 } else { 2219 // å¨å±å¼åï¼å 让容å¨å¤äºä¸å¯è§ä½å æ®ç©ºé´çç¶æï¼æè ç´æ¥å¼ºå¶ update å®ä½ 2220 $thisBd.show().css("visibility", "hidden"); 2221 jumpToSelectedSync($scrollContainer, $thisBd); 2222 $thisBd.hide().css("visibility", "visible"); // ç¬é´è¿åç¶æ 2223 // æ§è¡å±å¼ 2224 $thisHd.addClass("on"); 2225 $thisSelect.addClass("zindex"); 2226 // ä½¿ç¨ show() æå¿«é slideDownï¼ç¡®ä¿ä½ç½®å·²ç»å®æ» 2227 $thisBd.stop().slideDown(200, function() { 2228 $(this).addClass("showscroll"); 2229 }); 2230 } 2231 }); 2232 // å表项ç¹å»é»è¾ (ä¿æä¸å) 2233 $obj.find(".ys-select-bd").off('click', '.ys-select-li').on("click", ".ys-select-li", function(e) { 2234 var $li = $(this); 2235 var $select = $li.closest(".ys-select"); 2236 var $hd = $select.find(".ys-select-hd"); 2237 $hd.find(".ys-select-show").val($li.text().trim()); 2238 $hd.find(".ys-select-real").val(value ? $li.data(value) : $li.data("value")).trigger("change"); 2239 $li.addClass("on").siblings().removeClass("on"); 2240 $hd.trigger('click'); // è§¦åæ¶èµ· 2241 if (callback) callback($li.data()); 2242 }); 2243 // åå§å mCustomScrollbar 2244 var scrollConfig = { 2245 axis: "y", 2246 scrollInertia: 500, 2247 theme: 'dark', 2248 scrollbarPosition: "outside", 2249 advanced: { autoScrollOnFocus: false } 2250 }; 2251 if ($obj.find(".ys-fiiss-core").length > 0) { 2252 $obj.find(".ys-fiiss-core").mCustomScrollbar(scrollConfig); 2253 } else { 2254 $obj.find(".ys-select-bd .ys-select-inof").mCustomScrollbar(scrollConfig); 2255 } 2256 // ç¹å»ç©ºç½æ¶èµ·é»è¾ 2257 $(document).off('click.select_close').on('click.select_close', function(e) { 2258 if (!$(e.target).closest('.ys-select').length) { 2259 $(".ys-select.zindex").each(function() { 2260 var $active = $(this); 2261 $active.find('.ys-fiiss-input-close').trigger('click'); 2262 $active.find(".ys-select-hd").removeClass("on"); 2263 $active.find(".ys-select-bd").stop().slideUp(200, function() { 2264 $active.removeClass("zindex"); 2265 checkSelectEmpty($active); 2266 }); 2267 }); 2268 } 2269 }); 2270 }, 2271 /**
2272 * @description 带æç´¢å¤é䏿鿩1 2273 * @param {String} selector - csséæ©å¨ 2274 * @param {String} text1: æ¨éä¸äº 2275 * @param {String} text2: 个é项 2276 */ 2277 checkbox1: function(selector, text1, text2, callback) { 2278 var texta = text1 ? text1 : 'æ¨éä¸äº'; 2279 var textb = text2 ? text2 : '个é项'; 2280 var $obj = $(selector); 2281 // åå§åæ°æ®ï¼åé ID å Value 2282 $obj.find(".ys-select-li").each(function(index) { 2283 var $this = $(this); 2284 if ($this.attr("data-id") == undefined) { 2285 $this.attr("data-id", index); 2286 } 2287 $this.attr("data-value", $this.find('.ys-checkbox1-font').text().trim()); 2288 }); 2289 // å 鍿 ¡éª 2290 var checkSelectEmpty = function($targetSelect) { 2291 var $required = $targetSelect.closest('.ys-form-required'); 2292 if ($required.length > 0) { 2293 var val = $targetSelect.find(".ys-select-show").val(); 2294 $required.toggleClass('ys-form-empty', (!val || val.trim() === "")); 2295 } 2296 }; 2297 // å é¨ç§æï¼ç¬é´å®ä½å°ç¬¬ä¸ä¸ªéä¸é¡¹ --- 2298 var jumpToSelectedSync = function($container, $bd) { 2299 // æ¥æ¾ç¬¬ä¸ä¸ªéä¸ç项 2300 var $firstSelected = $bd.find(".ys-select-li.on").first(); 2301 // å¼ºå¶æä»¶æ´æ° 2302 $container.mCustomScrollbar("update"); 2303 if ($firstSelected.length > 0) { 2304 $container.mCustomScrollbar("scrollTo", $firstSelected, { 2305 scrollInertia: 0, 2306 timeout: 0, 2307 callbacks: false 2308 }); 2309 } else { 2310 $container.mCustomScrollbar("scrollTo", "top", { 2311 scrollInertia: 0, 2312 timeout: 0, 2313 callbacks: false 2314 }); 2315 } 2316 }; 2317 // 头é¨ç¹å»ï¼å±å¼/æ¶èµ·ï¼ 2318 $obj.find(".ys-select-hd").off('click').click(function(e) { 2319 e.stopPropagation(); 2320 var $thisHd = $(this); 2321 var $thisSelect = $thisHd.closest(".ys-select"); 2322 var $thisBd = $thisHd.siblings(".ys-checkbox-bd"); 2323 var $scrollInof = $thisBd.find(".ys-select-inof"); 2324 // äºæ¥é»è¾ï¼å ³éå ¶ä»ä¸ææ¡ 2325 $(".ys-select-hd").not(this).each(function() { 2326 var $otherHd = $(this); 2327 var $otherSelect = $otherHd.closest(".ys-select"); 2328 if ($otherSelect.hasClass("zindex")) { 2329 $otherHd.removeClass("on"); 2330 // ç´æ¥ hideï¼é¿å å¤éå¨ç»å²çª 2331 $otherSelect.find(".ys-checkbox-bd, .ys-select-bd").stop().hide(); 2332 $otherSelect.removeClass("zindex"); 2333 checkSelectEmpty($otherSelect); 2334 } 2335 }); 2336 if ($thisSelect.hasClass("zindex")) { 2337 // æ¶åé»è¾ 2338 $thisHd.removeClass("on"); 2339 $thisBd.removeClass("showscroll").stop().slideUp(function() { 2340 $thisSelect.removeClass("zindex"); 2341 $scrollInof.mCustomScrollbar("disable"); 2342 checkSelectEmpty($thisSelect); 2343 }); 2344 } else { 2345 // A. 颿¸²æå®ä½ 2346 $thisBd.show().css("visibility", "hidden"); 2347 jumpToSelectedSync($scrollInof, $thisBd); 2348 $thisBd.hide().css("visibility", "visible"); 2349 // B. å¨ç»å±å¼ 2350 $thisHd.addClass("on"); 2351 setTimeout(function() { 2352 $thisSelect.addClass("zindex"); 2353 }, 200); 2354 $thisBd.stop().slideDown(200, function() { 2355 $(this).addClass("showscroll"); 2356 $scrollInof.mCustomScrollbar("update"); 2357 }); 2358 } 2359 }); 2360 // é项ç¹å»ï¼å¤éé»è¾ï¼ 2361 $obj.find(".ys-checkbox-bd").off('click', '.ys-select-li').on("click", ".ys-select-li", function(e) { 2362 e.stopPropagation(); 2363 var $li = $(this); 2364 var $bd = $li.closest('.ys-checkbox-bd'); 2365 var $hd = $bd.siblings(".ys-select-hd"); 2366 $li.toggleClass("on"); // 忢éä¸ç¶æ 2367 var $onLis = $bd.find('.ys-select-li.on'); 2368 var length1 = $onLis.length; 2369 // å¿ å¡«æ ¡éªæ¾ç¤ºéè 2370 var $required = $li.parents('.ys-form-required'); 2371 if (length1 > 0) { 2372 $required.removeClass('ys-form-empty'); 2373 } else { 2374 $required.addClass('ys-form-empty'); 2375 } 2376 // å¤çæ¾ç¤ºæåå ID éå 2377 var displayValue = ''; 2378 var idArr = []; 2379 var dataResult = []; 2380 if (length1 === 1) { 2381 var $singleOn = $onLis.eq(0); 2382 displayValue = $singleOn.find('.ys-checkbox1-font').text().trim();
2383 idArr.push($singleOn.data('id')); 2384 dataResult = $singleOn.data(); 2385 } else if (length1 > 1) { 2386 displayValue = texta + length1 + textb; 2387 $onLis.each(function() { 2388 idArr.push($(this).data('id')); 2389 dataResult.push($(this).data()); 2390 }); 2391 } 2392 // æ´æ°å¤´é¨æ¾ç¤ºåéèå 2393 $hd.find(".ys-select-show").val(displayValue); 2394 $hd.find(".ys-select-real").attr("data-id", idArr.join(',')).val(idArr.join(',')).trigger("change"); 2395 if (callback) { 2396 callback(dataResult); 2397 } 2398 }); 2399 // ç¹å»é¡µé¢ç©ºç½å ³é 2400 $(document).off('click.checkbox_close').on('click.checkbox_close', function(e) { 2401 if (!$(e.target).closest('.ys-select').length) { 2402 $(".ys-select.zindex").each(function() { 2403 var $active = $(this); 2404 $active.find(".ys-select-hd").removeClass("on"); 2405 $active.find(".ys-checkbox-bd").removeClass("showscroll").stop().slideUp(function() { 2406 $active.removeClass("zindex"); 2407 checkSelectEmpty($active); 2408 }); 2409 }); 2410 } 2411 }); 2412 // åå§åæ»å¨æ¡ 2413 var scrollConfig = { 2414 axis: "y", 2415 scrollInertia: 500, // å ¨å±è®¾ä¸º 0ï¼å½»åºæ¶é¤åé¡¿æ 2416 theme: 'dark', 2417 scrollbarPosition: "outside", 2418 advanced: { autoScrollOnFocus: false } 2419 }; 2420 $obj.find(".ys-checkbox-bd .ys-select-inof").mCustomScrollbar(scrollConfig); 2421 // é»è®¤ç¦ç¨ï¼çå±å¼æ¶å update 2422 $obj.find(".ys-checkbox-bd .ys-select-inof").mCustomScrollbar("disable"); 2423 // 黿¢æ»å¨æ¡ç¹å»å泡 2424 $('body').on('click', '.mCSB_scrollTools', function (e) { 2425 e.stopPropagation(); 2426 }); 2427 }, 2428 /** 2429 * @description 带æç´¢å¤é䏿鿩2 2430 * @param {String} selector - csséæ©å¨ 2431 * @param {String} value - ä¼ å¼ 2432 */ 2433 checkbox2: function(selector, callback) { 2434 var $obj = $(selector); 2435 // åå§åæ°æ® 2436 $obj.find(".ys-select-li").each(function(index) { 2437 var $this = $(this); 2438 if ($this.attr("data-id") == undefined) { 2439 $this.attr("data-id", index); 2440 } 2441 $this.attr("data-value", $this.find('.ys-checkbox1-font').text().trim()); 2442 }); 2443 // å 鍿 ¡éª 2444 var checkSelectEmpty = function($targetSelect) { 2445 var $required = $targetSelect.closest('.ys-form-required'); 2446 if ($required.length > 0) { 2447 var val = $targetSelect.find(".ys-select-show").val(); 2448 $required.toggleClass('ys-form-empty', (!val || val.trim() === "")); 2449 } 2450 }; 2451 // å é¨ç§æï¼ç¬é´å®ä½å°ç¬¬ä¸ä¸ªéä¸é¡¹ --- 2452 var jumpToSelectedSync = function($container, $bd) { 2453 var $firstSelected = $bd.find(".ys-select-li.on").first(); 2454 $container.mCustomScrollbar("update"); 2455 if ($firstSelected.length > 0) { 2456 $container.mCustomScrollbar("scrollTo", $firstSelected, { 2457 scrollInertia: 0, 2458 timeout: 0, 2459 callbacks: false 2460 }); 2461 } else { 2462 $container.mCustomScrollbar("scrollTo", "top", { 2463 scrollInertia: 0, 2464 timeout: 0, 2465 callbacks: false 2466 }); 2467 } 2468 }; 2469 // 头é¨ç¹å»é»è¾ 2470 $obj.find(".ys-select-hd").off('click').click(function(e) { 2471 e.stopPropagation(); 2472 var $thisHd = $(this); 2473 var $thisSelect = $thisHd.closest(".ys-select"); 2474 var $thisBd = $thisHd.siblings(".ys-checkbox-bd"); 2475 var $scrollInof = $thisBd.find(".ys-select-inof"); 2476 // äºæ¥å ³éå ¶ä» 2477 $(".ys-select-hd").not(this).each(function() { 2478 var $otherHd = $(this); 2479 var $otherSelect = $otherHd.closest(".ys-select"); 2480 if ($otherSelect.hasClass("zindex")) { 2481 $otherHd.removeClass("on"); 2482 $otherSelect.find(".ys-checkbox-bd, .ys-select-bd").stop().hide(); 2483 $otherSelect.removeClass("zindex"); 2484 checkSelectEmpty($otherSelect); 2485 } 2486 }); 2487 if ($thisSelect.hasClass("zindex")) { 2488 // æ¶å 2489 $thisHd.removeClass("on"); 2490 $thisBd.removeClass("showscroll").stop().slideUp(function() { 2491 $thisSelect.removeClass("zindex"); 2492 $scrollInof.mCustomScrollbar("disable"); 2493 checkSelectEmpty($thisSelect); 2494 }); 2495 } else { 2496 // å±å¼å颿¸²æå®ä½ 2497 $thisBd.show().css("visibility", "hidden"); 2498 jumpToSelectedSync($scrollInof, $thisBd); 2499 $thisBd.hide().css("visibility", "visible"); 2500 // æ§è¡å±å¼ 2501 $thisHd.addClass("on"); 2502 setTimeout(function() { $thisSelect.addClass("zindex"); }, 200); 2503 $thisBd.stop().slideDown(200, function() { 2504 $(this).addClass("showscroll"); 2505 $scrollInof.mCustomScrollbar("update"); 2506 checkSelectEmpty($thisSelect); 2507 }); 2508 } 2509 }); 2510 // å表项ç¹å»é»è¾ 2511 $obj.find(".ys-checkbox-bd").off('click', '.ys-select-li').on("click", ".ys-select-li", function(e) { 2512 e.stopPropagation(); 2513 var $li = $(this); 2514 var $bd = $li.closest('.ys-checkbox-bd'); 2515 var $hd = $bd.siblings(".ys-select-hd"); 2516 $li.toggleClass("on"); 2517 var $onLis = $bd.find('.ys-select-li.on'); 2518 var length1 = $onLis.length; 2519 // å¿ å¡«æ ¡éª 2520 var $required = $li.parents('.ys-form-required'); 2521 $required.toggleClass('ys-form-empty', length1 === 0); 2522 var displayValues = []; 2523 var idArr = []; 2524 var dataResult = []; 2525 // éåææéä¸ç liï¼æåæåå ID 2526 $onLis.each(function(i) { 2527 var $current = $(this); 2528 displayValues.push($current.find('.ys-checkbox1-font').text().trim());
2529 idArr.push($current.data('id')); 2530 dataResult.push($current.data()); 2531 }); 2532 // å°ç»æç¨éå·æ¼æ¥å±ç¤º 2533 $hd.find(".ys-select-show").val(displayValues.join(',')); 2534 // 注æï¼data.id å¨å¤éæ¶åºä¼ åéæé¦é¡¹ï¼è¿ééµå¾ªä½ å代ç é»è¾ä¼ id å符串 2535 $hd.find(".ys-select-real").attr("data-id", idArr.join(',')).val(idArr.join(',')).trigger("change"); 2536 if (callback) callback(dataResult); 2537 }); 2538 // ç¹å»é¡µé¢å ³é 2539 $(document).off('click.checkbox2_close').on('click.checkbox2_close', function(e) { 2540 if (!$(e.target).closest('.ys-select').length) { 2541 $(".ys-select.zindex").each(function() { 2542 var $active = $(this); 2543 $active.find(".ys-select-hd").removeClass("on"); 2544 $active.find(".ys-checkbox-bd").removeClass("showscroll").stop().slideUp(function() { 2545 $active.removeClass("zindex"); 2546 checkSelectEmpty($active); 2547 }); 2548 }); 2549 } 2550 }); 2551 // æ»å¨æ¡é ç½® 2552 var scrollConfig = { 2553 axis: "y", 2554 scrollInertia: 500, 2555 theme: 'dark', 2556 scrollbarPosition: "outside", 2557 advanced: { autoScrollOnFocus: false } 2558 }; 2559 $obj.find(".ys-checkbox-bd .ys-select-inof").mCustomScrollbar(scrollConfig); 2560 $obj.find(".ys-checkbox-bd .ys-select-inof").mCustomScrollbar("disable"); 2561 // 黿¢æ»å¨æ¡ç¹å»å泡 2562 $obj.find('.mCSB_scrollTools').off('click').on('click', function (e) { 2563 e.stopPropagation(); 2564 }); 2565 }, 2566 /** 2567 * @description 表å䏿æç´¢åµå ¥ 2568 * @param {String} nodata - æ²¡ææ°æ®æ¶æ¿æ¢æå 2569 */ 2570 select_input: function(nodata) { 2571 $(document).off('input.ys_input', '.ys-fiiss-input input').on('input.ys_input', '.ys-fiiss-input input', function() { 2572 var $inputWrap = $(this).parents('.ys-fiiss-input'); 2573 if ($(this).val() === '') { 2574 $inputWrap.removeClass('act'); 2575 } else { 2576 $inputWrap.addClass('act'); 2577 } 2578 }); 2579 $(document).off('click.ys_clear', '.ys-fiiss-input-close').on('click.ys_clear', '.ys-fiiss-input-close', function(e) { 2580 e.stopPropagation(); 2581 var $inputWrap = $(this).parents('.ys-fiiss-input'); 2582 var $input = $inputWrap.find('input'); 2583 $input.val('').trigger('input'); // 触å input äºä»¶ä»¥æ¢å¤å表 2584 $inputWrap.removeClass('act'); 2585 }); 2586 $('.ys-fiiss-input').each(function() { 2587 var $inputWrap = $(this); 2588 if ($inputWrap.parents('.ys-form-inof-item').hasClass('ys-form-next')) return; 2589 var $core = $inputWrap.siblings('.ys-fiiss-core'); 2590 var $contentArea = $core.find(".mCSB_container").length > 0 ? $core.find(".mCSB_container") : $core; 2591 // æ ¸å¿ï¼å¨åå§åæ¶ä¿ååå§ HTMLãæ³¨æï¼åªå¨ç¬¬ä¸æ¬¡åå§åæ¶ä¿åï¼é²æ¢éå¤ä¿åæç´¢åçç»æ 2592 if (!$inputWrap.data('original-html')) { 2593 $inputWrap.data('original-html', $contentArea.html()); 2594 } 2595 var originalHtml = $inputWrap.data('original-html'); 2596 var timer = null; 2597 $inputWrap.find("input").off("input.filter").on("input.filter", function () { 2598 var _this = this; 2599 var val = $(_this).val().toLowerCase(); 2600 var $selectBd = $inputWrap.closest('.ys-select-bd'); 2601 var valueon = $selectBd.find('.ys-select-li.on').data('value'); 2602 if (timer) clearTimeout(timer); 2603 timer = setTimeout(function () { 2604 if (val === '') { 2605 $contentArea.html(originalHtml); 2606 } else {
2607 var $tempDiv = $('<div>').append(originalHtml); 2608 var resultArr = []; 2609 $tempDiv.find('.ys-select-li').each(function() { 2610 var itemText = $(this).data('value') ? String($(this).data('value')) : $(this).text().trim(); 2611 if (itemText.toLowerCase().indexOf(val) !== -1) { 2612 var newText = itemText.replace(new RegExp('(' + val + ')', 'gi'), '<span style="color:red;">$1</span>'); 2613 $(this).html(newText); 2614 resultArr.push($(this)[0].outerHTML); 2615 } 2616 }); 2617 if (resultArr.length === 0) { 2618 $contentArea.html('<li class="ys-select-li ys-select-emptyli">' + nodata + '</li>'); 2619 } else { 2620 $contentArea.html(resultArr.join('')); 2621 } 2622 } 2623 // éæ°æ è®°éä¸é¡¹ 2624 if (valueon) { 2625 $contentArea.find('.ys-select-li[data-value="' + valueon + '"]').addClass('on'); 2626 } 2627 $core.mCustomScrollbar("update"); 2628 $core.mCustomScrollbar("scrollTo", "top", { scrollInertia: 0 }); 2629 }, 200); 2630 }); 2631 }); 2632 }, 2633 // 表å䏿æç´¢ 2634 select_input_dan: function(ele, nodata) { 2635 var $ele = $(ele); 2636 var $selectBd = $ele.closest('.ys-select-bd'); 2637 var $core = $ele.siblings('.ys-fiiss-core'); 2638 var $container = $core.find(".mCSB_container").length > 0 ? $core.find(".mCSB_container") : $core; 2639 // ç¼ååå§ HTMLï¼åªå¨ç¬¬ä¸æ¬¡è°ç¨æ¶ç¼åï¼ 2640 if (!$ele.data('original-html')) { 2641 $ele.data('original-html', $container.html()); 2642 } 2643 var originalHtml = $ele.data('original-html'); 2644 // è¾å ¥æ¡é»è¾ï¼æ§å¶æ¸ 空æé® + è¿æ»¤ 2645 var timer = null; 2646 $ele.find("input").off("input").on("input", function() { 2647 var _this = this; 2648 var val = $(_this).val().trim().toLowerCase(); 2649 // æ§å¶æ¸ 空æé®æ¾ç¤º 2650 $ele.toggleClass('act', val !== ''); 2651 if (timer) clearTimeout(timer); 2652 timer = setTimeout(function() { 2653 if (val === '') { 2654 $container.html(originalHtml); 2655 } else { 2656 var $tempDiv = $('<div>').append(originalHtml); 2657 var resultHtml = ''; 2658 $tempDiv.find('.ys-select-li').each(function() { 2659 var $li = $(this); 2660 var text = $li.data('value') ? String($li.data('value')) : $li.text().trim(); 2661 if (text.toLowerCase().indexOf(val) !== -1) { 2662 // é«äº®å¹é æå 2663 var highlighted = text.replace(new RegExp('(' + val + ')', 'gi'), '<span style="color:red;">$1</span>'); 2664 $li.html(highlighted); 2665 resultHtml += $li[0].outerHTML; 2666 } 2667 }); 2668 $container.html(resultHtml || '<li class="ys-select-li ys-select-emptyli">' + nodata + '</li>'); 2669 } 2670 // ä¿æä¹åéä¸çé«äº® 2671 var currentVal = $selectBd.siblings('.ys-select-hd').find('.ys-select-show').val(); 2672 $container.find('.ys-select-li').each(function() { 2673 if ($(this).data('value') == currentVal) $(this).addClass('on'); 2674 }); 2675 // å·æ°æ»å¨æ¡ 2676 $core.mCustomScrollbar("update"); 2677 $core.mCustomScrollbar("scrollTo", "top", { scrollInertia: 0 }); 2678 }, 200); 2679 }); 2680 // æ¸ ç©ºæé®ç¹å» 2681 $ele.find('.ys-fiiss-input-close').off('click').on('click', function(e) { 2682 e.stopPropagation(); 2683 $ele.find('input').val('').trigger('input'); 2684 }); 2685 }, 2686 });
2687 // slickæ»å¨å°èªå¨è½®æ 2688 function slickAuto(accy) { 2689 var offset = accy || 0; 2690 return this.each(function() { // ä¿æé¾å¼è°ç¨ 2691 var $this = $(this); 2692 $this.appear(function() { 2693 if ($this.hasClass('slick-initialized')) { 2694 $this.slick("slickPlay"); // 注æï¼è¾æ°çæ¬ slick å»ºè®®ç¨ slickPlay 2695 } 2696 }, { accY: offset }); 2697 }); 2698 } 2699 $.fn.slickAuto = slickAuto; 2700 // loadå è½½å¨ç» 2701 var loading = { 2702 show:function(fonts){ 2703 var fonts = fonts ? fonts : 'å è½½ä¸'; 2704 var loadingELe = ''; 2705 loadingELe+='<div id="modal-loading">'; 2706 loadingELe+=' <div class="modal-loading-container">'; 2707 loadingELe+=' <svg class="loading-svg" viewBox="0 0 40 40" version="1.1" fill="none" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">'; 2708 loadingELe+=' <circle class="loading-svg-circle loading-svg-circle1" cx="50%" cy="50%" r="12" stroke-width="3" stroke="#1833BA" />'; 2709 loadingELe+=' <circle class="loading-svg-circle loading-svg-circle2" cx="50%" cy="50%" r="16" stroke-width="3" stroke="#1833BA" />'; 2710 loadingELe+=' </svg>'; 2711 loadingELe+=' <div class="loading-svg-text">'+fonts+'</div>'; 2712 loadingELe+=' </div>'; 2713 loadingELe+='</div>';
2714 if($("#modal-loading").length<1){ 2715 $("body").append(loadingELe); 2716 } 2717 $("#modal-loading").removeAttr("style").css("display", "flex"); 2718 }, 2719 hide:function(){ 2720 $("#modal-loading").stop().fadeOut(); 2721 } 2722 }; 2723 ys.loading = loading; 2724 // iPad导èªå ¼å®¹ 2725 document.addEventListener('DOMContentLoaded', (event) => { 2726 // æ£æµæ¯å¦æ¯iPad 2727 const isIPad = navigator.userAgent.match(/iPad/i) != null; 2728 if (isIPad) { 2729 // 为ææé¾æ¥æ·»å ç¹å»äºä»¶çå¬å¨ 2730 document.querySelectorAll('.head-nav-item-title').forEach((link) => { 2731 link.addEventListener('click', (event) => { 2732 // 黿¢é¾æ¥è·³è½¬ 2733 event.preventDefault(); 2734 // å¯ä»¥å¨è¿éæ·»å å ¶ä»é»è¾ï¼æ¯å¦æ¾ç¤ºè¦åä¿¡æ¯ç 2735 // alert('龿¥è·³è½¬è¢«ç¦æ¢ï¼'); 2736 }); 2737 }); 2738 } 2739 }); 2740 if(window.innerWidth<1200){ 2741 // QQæµè§å¨å¾é触åå ¼å®¹æ§é®é¢,viewer-showå ç»å¾çæ¾å¤§æä»¶ä¸è¦æ¾å¤§çå¾ç 2742 $('img:not([data-original]),video').click(function (e) { 2743 e.preventDefault(); 2744 }); 2745 $('img,video').each(function () { 2746 if ($(this).parents('a').length > 0) { 2747 if ($(this).parents('a').attr('target') == '_blank') { 2748 $(this).parents('a').click(function(){ 2749 window.open(this.href,'_blank'); 2750 }); 2751 }else if($(this).parents('a').attr('href') != "javascript:void(0);" && $(this).parents('a').attr('href')!='javascript:void(0)' && $(this).parents('a').attr('href')!='' && $(this).parents('a').attr('href')!='javascript:;' && $(this).parents('a').attr('href')!=undefined){ 2752 $(this).parents('a').click(function(){ 2753 window.location = this.href; 2754 }); 2755 } 2756 } 2757 }) 2758 } 2759 // img尺寸æç¤ºä»£ç 2760 $(function(){ 2761 if (typeof(closeWeb)=='undefined') { 2762 showImgSize(); 2763 window.onload = showImgSize; 2764 function showImgSize() { 2765 $("img").each(function () { 2766 var w = this.naturalWidth; 2767 var h = this.naturalHeight; 2768 if(w<400 || h<400){ 2769 w = w*2; 2770 h = h*2; 2771 } 2772 $(this).attr('data-size', w + "*" + h); 2773 }); 2774 } 2775 } 2776 }) 2777 window.ys = ys; 2778}(window)); 2779 2780 2781var anmtArr = []; 2782 2783function banVideow(selector) { 2784 var $obj = $(selector); 2785 var autoplay = true; 2786 if ($(window).width() > 1200 && $obj.find("video").length > 0) { 2787 init(); 2788 2789 function init() { 2790 firstVideo(); 2791 videoEnd(); 2792 afterChange(); 2793 videoCircleInit(); 2794 }; 2795 // æ¿¡îå妤ç²ç¼é¡å¨ç¨é§îä»¦è¹æÐ¦é¸æ°¾éå©ä½ºæ´é¡æ¶±æ¥ 2796 function firstVideo() { 2797 var $firSlide = $obj.find(".slick-slide[data-slick-index=0]"); 2798 var $video = $firSlide.find("video"); 2799 // autoplayé¼å¥äºæ¿®â å¹é¡ç¸æ¹ 2800 if ($video.length > 0) { 2801 $obj.slick('slickPause'); 2802 // 婵â³å¹é夿½ªé¡è¥å°¡é¸æ¬äºå©ä½¹ç¨é§îç¨é¡å¬å黿»å±é¸é弨é� 2803 if ($obj.get(0).slick.slideCount < 2) { 2804 $video.attr("loop", "loop"); 2805 }; 2806 if ($video.get(0).paused) { 2807 setTimeout(function () { 2808 $video.get(0).play(); 2809 }, 100); 2810 } 2811 } else { 2812 $obj.slick('slickPlay'); 2813 anmtArr[0].play(); 2814 } 2815 }; 2816 // é¸ææ´¦å®æ¥å´æ£°ä½ºç卿¯åçµî¾å§µå¦²æå´¥éè¥ç®éæ¬æ£é¡£ï¿½ 2817 function afterChange() { 2818 $obj.on('afterChange', function (event, slick, index) { 2819 // 鿬æ£é¡£å 弳鿰«ç²»æ¥ ç¶æ³å¨²æ å´éµî å卿¯åé¢î¤æ· 2820 $obj.find("video").each(function () { 2821 var video = $(this).get(0); 2822 video.pause(); 2823 video.currentTime = 0; 2824 }); 2825 // éºå î³é¡«å¬«ï¼é´æ¿çéºå叿µ ç³æ½ªé¡è¥å°¡ 2826 var $nowSlide = $(slick.$slides[index]); 2827 var $video = $nowSlide.find("video"); 2828 if ($video.length > 0) { 2829 $obj.slick('slickPause'); 2830 $video.get(0).play(); 2831 } else { 2832 if (autoplay) { 2833 $obj.slick('slickPlay'); 2834 } 2835 anmtArr[index].play(); 2836 }; 2837 }); 2838 }; 2839 // 鿬æ£é¡£å 崷顿¥ç®éâç¨ç¹æ½å´ 褰æå¸³ 2840 function videoCircleInit() { 2841 $obj.find("video").each(function () { 2842 var video = $(this).get(0); 2843 video.ontimeupdate = function (e) { 2844 var index = parseInt($(this).parents(".slick-slide").attr( 2845 "data-slick-index")); 2846 var duration = this.duration; 2847 var currentTime = this.currentTime; 2848 var progress = parseInt((currentTime / duration) * 100) / 100; 2849 if (progress < 1) { 2850 if (anmtArr[index]) { 2851 anmtArr[index].seek(anmtArr[index].duration * progress); 2852 } 2853 } else { 2854 if (anmtArr[index]) { 2855 anmtArr[index].seek(anmtArr[index].duration * 0.999999); 2856 } 2857 $obj.slick("next"); 2858 } 2859 }; 2860 }); 2861 }; 2862 // 鿬æ£é¡£å å¹é¡çµæé¸ææ´¦å®æ¥å´æ£°ä½ºç卿¯åçµîæ· 2863 function videoEnd() { 2864 $obj.find("video").each(function () { 2865 var video = $(this).get(0); 2866 video.onended = function () { 2867 if (autoplay) { 2868 $obj.slick("next"); 2869 $obj.slick('slickPlay'); 2870 } 2871 }; 2872 }); 2873 }; 2874 2875 } else { 2876 $obj.slick('play'); 2877 anmtArr[0].play(); 2878 $obj.on('afterChange', function (event, slick, index) { 2879 anmtArr[index].play(); 2880 }); 2881 }; 2882 $obj.on('beforeChange', function (event, slick, index) { 2883 // 鿬æ£é¡£å 弳鿰«ç²»æ¥ ç¶æ³å¨²æ å´éµî å卿¯åé¢î¤æ· 2884 $obj.find("video").each(function () { 2885 var video = $(this).get(0); 2886 video.pause(); 2887 video.currentTime = 0; 2888 }); 2889 // 鏿»åéé¹å¼³éæ°«ç²»æ¥ ç¶æ³å¨²æ å´éµî å卿¯åé¢î¤æ· 2890 anmtArr[index].pause(); 2891 anmtArr[index].seek(0); 2892 });
2893 var banvideo = { 2894 play: function () { 2895 $obj.slick('slickPlay'); 2896 autoplay = true; 2897 }, 2898 pause: function () { 2899 autoplay = false; 2900 $obj.slick('slickPause'); 2901 } 2902 }; 2903 return banvideo; 2904}; 2905ys.banVideow = banVideow;
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.