$(function(){ if(!placeholderSupport()){ // 鍒ゆ柇娴忚鍣ㄦ槸鍚︽敮鎸 placeholder $('[placeholder]').focus(function() { var input = $(this); if (input.val() == input.attr('placeholder')) { input.val(''); input.removeClass('placeholder'); } }).blur(function() { var input = $(this); if (input.val() == '' || input.val() == input.attr('placeholder')) { input.addClass('placeholder'); input.val(input.attr('placeholder')); } }).blur(); }; }) // 榛樿obj涓烘墽琛屽厓绱 function Hover(obj, classname) { obj.hover(function(){ $(this).addClass(classname) }, function(){ $(this).removeClass(classname) }) } //杩斿洖椤堕儴鏂规硶 function backTop(obj) { obj.on('click',function(){ $('html,body').animate({ scrollTop: 0 },600, 'easeInOutQuad'); }); } // TAB // 榛樿鐒︾偣鏍峰紡 .cur // 涓洪槻姝p绯荤粺opacity鍙兘鍑虹幇鐨勯敮榻挎垨杈圭紭妯$硦锛 榛樿.tabbox鏁堟灉.show() / .hide() // 鎷撳睍.tabbox鎴恛pacity锛 闇€鍦?tabbox涓婂姞涓 data-effect="true" function Tab(tabBtn, tabBox) { var tabbl = true; tabBtn.eq(0).addClass("cur") tabBox.eq(0).show() tabBtn.click(function(){ var n = $(this).index(); $(this).addClass("cur").siblings().removeClass("cur") if(tabBox.attr("data-effect") == "true"){ if(!tabbl){ return } tabbl = false; tabBox.eq(n).stop().fadeIn(800).siblings().stop().fadeOut(800, function(){ tabbl = true; }) }else{ tabBox.eq(n).show().siblings().hide() } }) } // 瑙嗛鍏ㄥ睆 / 瑙嗛鍏呮弧鏁翠釜鐖剁骇 (video鑾峰彇瀹介珮鏈夐棶棰? function videoFull(obj, width, height){ var $video = obj function resizeBg() { $video.attr("width", "").attr("height", "").attr("style", "") var boxR = $('.top-video').outerWidth() / $('.top-video').outerHeight(), objR = width / height; if( objR < boxR ) { $video.attr("width", "100%") var videoHeight = $video.width() / objR var top = - (videoHeight - $('.top-video').outerHeight()) / 2 > 0 ? 0 : - (videoHeight - $('.top-video').outerHeight()) / 2 $video.css("margin-top", top); }else{ $video.attr("height", "100%") var videoWidth = $video.height() * objR var left = - (videoWidth - $('.top-video').outerWidth()) / 2 > 0 ? 0 : - (videoWidth - $('.top-video').outerWidth()) / 2 $video.css("margin-left", left); } } $(window).resize(resizeBg).trigger("resize"); } function placeholderSupport() { return 'placeholder' in document.createElement('input'); } $(function(){ if(!placeholderSupport()){ // 鍒ゆ柇娴忚鍣ㄦ槸鍚︽敮鎸 placeholder $('[placeholder]').focus(function() { var input = $(this); if (input.val() == input.attr('placeholder')) { input.val(''); input.removeClass('placeholder'); } }).blur(function() { var input = $(this); if (input.val() == '' || input.val() == input.attr('placeholder')) { input.addClass('placeholder'); input.val(input.attr('placeholder')); } }).blur(); }; }) function visual_button_scroll_down(obj){ obj.on('click',function(){ var target = $(this).attr('data-id'); var target_top = $(target).offset().top; $('html,body').animate({ scrollTop : target_top },600, 'easeInOutQuad'); return false; }); } function scrollAni() { $('.secwen').each(function() { var _this = $(this); if (_this.offset().top > $(window).scrollTop() + $(window).height() || _this.offset().top < $(window).scrollTop() - _this.outerHeight()) { // _this.removeClass('animate'); } else if ($(window).scrollTop() > _this.offset().top - $(window).height() * 0.95) { _this.addClass('animate'); } }); $(window).scroll(function() { $('.secwen').each(function() { var _this = $(this); if (_this.offset().top > $(window).scrollTop() + $(window).height() || _this.offset().top < $(window).scrollTop() - _this.outerHeight()) { // _this.removeClass('animate'); } else if ($(window).scrollTop() > _this.offset().top - $(window).height() * 0.95) { _this.addClass('animate'); // $(_this) // startScramble('.i-img-list.animate .home-dec'); } }); }); } function startScramble(name) { $(name).each(function (i, item) { var newText = $(item).data('text') || $(item).text(); var delay = Number($(item).data('delay')) || 0; setTimeout(function () { $(item).attr('data-text', newText); setScramble(item, [newText]); }, delay); }); } function setScramble(text, phrase) { var count = 0; var scramble = new TextScramble(text); scramble.setText(phrase[count]); var doScramble = function doScramble() { scramble.setText(phrase[count]).then(function () { setTimeout(doScramble, 800); }); count = (count + 1) % phrase.length; } //doScramble(); } function btnhover(obj){ var ink, d, x, y; var ulbox = obj; ulbox.find("a").bind("click touchstart", function(e) { $(".ink").remove(); if ($(this).children(".ink").length === 0) { $(this).prepend("") } ink = $(this).find(".ink"); ink.removeClass("animate-ink"); if (!ink.height() && !ink.width()) { d = Math.max($(this).outerWidth(), $(this).outerHeight()); ink.css({ height: d, width: d }) } x = e.pageX - $(this).offset().left - ink.width() / 2; y = e.pageY - $(this).offset().top - ink.height() / 2; ink.css({ top: y + 'px', left: x + 'px' }).addClass("animate-ink") }) } // 鍥剧墖鍔犺浇 璋冪敤鏂规硶 // _PreLoadImg([ // 鍥剧墖璺緞(鏁扮粍褰㈠紡) // ],function(){ // }) function _PreLoadImg(b,e){var c=0,a={},d=0;for(src in b){d++}for(src in b){a[src]=new Image();a[src].onload=function(){if(++c>=d){e(a)}};a[src].src=b[src]}}; /*寮€濮嬪姞杞介〉闈富浣撳浘鐗?/ // var _imgArr=[];// 閫夋嫨鍣 璺緞 鏄惁鑳屾櫙 // $("[data-bg-src]").each(function(){ // var arr=[$(this),$(this).attr('data-bg-src'),true]; // _imgArr.push(arr); // }); // $("[data-src]").each(function(){ // var arr=[$(this),$(this).attr('data-src'),false]; // _imgArr.push(arr); // }); // console.log(_imgArr); function _PreLoadImg2(b, e, isnum) { var c = 0, a = {}, d = 0; for (src in b) { d++ } for (i in b) { var j=i; var image = new Image(); image.src = b[i][1]; image.onload = function() { if (++c >= d) { e(a); } if(isnum){ // $('#qLoverlay .loadingcar2').css({ // 'opacity': c / d // }); $('.progressbar .num').text(parseInt(c / d) * 100); } }; if(b[i][2]){ b[i][0].css({ 'background-image': 'url('+b[i][1]+')' }); }else{ b[i][0].attr('src',b[i][1]); } } }; /* var _id = getUrlParam("id"); if (_id == 6) { alert(0); } */ function getUrlParam(name){ var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)"); var r = window.location.search.substr(1).match(reg); if (r!=null) return unescape(r[2]); return null; } function set_font() { var html = document.getElementsByTagName('html')[0]; var designFontSize = 100, designWidth = 1920; function setFontSize() { var winWidth = document.documentElement.getBoundingClientRect().width; if(winWidth>=770){ designWidth = 1920*2.5; }else{ designWidth = 750; } var fontSize = winWidth / designWidth * designFontSize; html.style.fontSize = fontSize + 'px'; } setFontSize(); window.addEventListener('resize', function () { setFontSize(); }); return this; } set_font()