$(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 // 为防止xp系统opacity可能出现的锯齿或边缘模糊, 默认.tabbox效果.show() / .hide() // 拓展.tabbox成opacity, 需在.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 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() { $('.anim_emt').each(function() { var _this = $(this); if (_this.offset().top > $(window).scrolltop() + $(window).height() || _this.offset().top < $(window).scrolltop() - _this.outerheight()) { // _this.removeclass('start'); } else if ($(window).scrolltop() > _this.offset().top - $(window).height() * 0.95) { _this.addclass('start visb'); } }); $(window).scroll(function() { $('.anim_emt').each(function() { var _this = $(this); if (_this.offset().top > $(window).scrolltop() + $(window).height() || _this.offset().top < $(window).scrolltop() - _this.outerheight()) { // _this.removeclass('start'); } else if ($(window).scrolltop() > _this.offset().top - $(window).height() * 0.95) { _this.addclass('start visb'); // $(_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; } // html版式 //
//
//
//
// //
//
//
//
//
function clickvideo(selector) { var video = document.getelementbyid('video'); selector.on('click', function (){ var videosrc = $(this).attr('data-src'); console.log(videosrc); $('#video').attr('src', videosrc); $('.video-fixed').stop().fadein(); video.play(); e.stoppropagation(); e.preventdefault(); }) $('.video-fixed .cha').on('click', function () { $('.video-fixed').stop().fadeout(); video.pause(); }) $(".video-fixed").on("click", function () { $(".video-fixed").fadeout(); }) $(".video-fixed .videoboxs").on("click", function (e) { e.stoppropagation() }) }