// JavaScript Document
/**
* 会员免费模板js
*
* date:2015/1/30
*
**/
var detailpage={
productDetail:function(){
detailpage.floatMessageClick();
detailpage.floatSearch();
detailpage.lookContact();
},
floatMessageClick:function(clickLook){
var clickMessage={
clickObj:$('#floatMessageClick'),
messageFlag:false,
messageH:31
};
clickMessage.clickObj.click(function(){
if(clickMessage.messageFlag){
$(this).css('background-position','right -79px').parent().css('height',clickMessage.messageH);
}else{
$(this).css('background-position','right -55px').parent().css('height','auto');
}
clickMessage.messageFlag=!clickMessage.messageFlag;
});
},
lookContact:function(){
var clickLook={
clickShow:$('#clickLookContact'),
clickHide:$('#clickHideContact')
};
clickLook.clickShow.click(function(){
$(this).next('div').show();
});
clickLook.clickHide.click(function(){
$(this).parent('div').hide();
});
},
floatSearch:function(){
$(window).scroll(function(){
if ($(window).scrollTop()>100){
$('#float_contact,#float_message').slideDown();
}
else
{
$('#float_contact,#float_message').slideUp();
}
});
}
};
/**
* 会员模板效果
* ye
* 2015/5/15
*
*/
var msgPop={
initPage : function() {
msgPop.initBtn();
msgPop.initStyle();
msgPop.initData();
},
initBtn : function() {
//留言
$('#msgPopBtn').click(function() {
$.msgBox.window({
title : '留言',
html : '
'+'',
width : 650
});
});
},
initStyle : function() {
},
initData : function() {
},
submitForm : function() {
$.ajax({
type: "POST",
url: "/d17/company/leaveMessage.json",
dataType: "json",
data : {
"companyId" : $("#companyId").val(),
"msgContent" : $("#msgContent").val(),
"msgTel" : $("#msgTel").val(),
"msgName" : $("#msgName").val()
},
success: function(data){
//
if(data.success==null){
alert(data.message);
}else {
alert("留言成功");
}
$.msgBox.close();
}
});
},
//验证消息提示
verificationMessage : function($obj){
$obj.find('input,textarea').focus(function(){
$(this).nextAll('.message').css('display','inline-block').prev('.Validform_checktip').hide();;
}).blur(function(){
$(this).nextAll('.message').hide().prev('.Validform_checktip').css('display','inline-block');
}).keyup(function(){
$(this).nextAll('.message').hide();
});
},
shopVerification : function(){
var $dfrom=$('#msgPopForm');
msgPop.verificationMessage($dfrom);
var form=$dfrom.Validform({
tiptype:3,
showAllError:true,
btnSubmit:"#submitMsgButton",
beforeSubmit:function(curform){
msgPop.submitForm();
return false;
}
});
//验证规则
form.addRule([
{
ele:"#msgContent",
datatype:"*6-200",
nullmsg:"请输入留言内容",
errormsg:"请输入留言内容,6-200字"
},
{
ele:"#msgName",
datatype:/^[\u4E00-\u9FA5\uf900-\ufa2d]{2,6}$/,
nullmsg:"请输入联系人",
errormsg:"请输入中文姓名"
},
{
ele:"#msgTel",
datatype:/^\d{1,4}(-)?\d{4,8}(-)?\d{3,7}$/+" | m",
nullmsg:"请输入联系方式",
errormsg:"请输入联系方式"
}
]);
}
};
var allEffect={
//首页
indexPage:function(){
allEffect.searchDownParam();
allEffect.floatBox();
msgPop.initPage();
//banner
console.log($('#focus .bd').find('li').length)
if($('#focus .bd').find('li').length > 1){
$('#focus').slide({titCell:".hd ul",mainCell:".bd ul",effect:"leftLoop",autoPlay:true,autoPage:true,interTime:3000,delayTime:700});
}else{
$('#focus .hd').hide();
}
if($('#isFree').val() != 1){
$('.tps_bestproduct,.tps_news_center,.tps_friends_link,.tps_company_photo,.tps_btnews').each(function(){
var datastyle = $(this).attr('data-style');
var datavis = $(this).attr('data-vis');
var datanum = $(this).attr('data-num');
if(datastyle != 'default'){
$(this).slide({
//titCell:".hd ul",
mainCell:"ul",
autoPage:true,
effect: datastyle,
autoPlay:true,
vis:datavis,
scroll:datanum
});
}
});
}
},
//公司介绍
companyInfoPage:function(){
allEffect.searchDownParam();
allEffect.floatBox();
msgPop.initPage();
$("#indexPage").removeClass("activity");
$("#introducePage").addClass("activity");
},
//公司相册
companyPhotoPage:function(){
allEffect.searchDownParam();
allEffect.floatBox();
msgPop.initPage();
$("#indexPage").removeClass("activity");
$("#albumPage").addClass("activity");
},
//产品展示
productShowPage:function(){
allEffect.searchDownParam();
allEffect.floatBox();
msgPop.initPage();
$("#indexPage").removeClass("activity");
$("#productPage").addClass("activity");
},
//新闻中心
newsCenterPage:function(){
allEffect.searchDownParam();
allEffect.floatBox();
msgPop.initPage();
$("#indexPage").removeClass("activity");
$("#newsPage").addClass("activity");
},
//荣誉页面
honorPage:function(){
allEffect.honorList();
allEffect.searchDownParam();
allEffect.floatBox();
msgPop.initPage();
$("#indexPage").removeClass("activity");
$("#honourPage").addClass("activity");
},
//联系我们
contactUsPage:function(){
allEffect.searchDownParam();
allEffect.floatBox();
msgPop.initPage();
$("#indexPage").removeClass("activity");
$("#contactUsPage").addClass("activity");
},
//产品详情
productDetailPage:function(){
allEffect.searchDownParam();
allEffect.floatBox();
msgPop.initPage();
allEffect.productScrollImg();
allEffect.productDetailScrollImg();
$("#indexPage").removeClass("activity");
$("#productPage").addClass("activity");
},
floatBox:function(){
$('#floatTel').hover(function(){
$(this).find('span').stop(true,true).animate({left:-176});
},function(){
$(this).find('span').stop(true,false).animate({left:44});
});
},
honorList:function(){
var $honorList=$('#honorList');
var honor_list_mask='.honor_list_mask';
$honorList.find('li').hover(function(){
$(this).find(honor_list_mask).stop(true,true).fadeIn();
},function(){
$(this).find(honor_list_mask).stop(true,false).fadeOut();
});
},
searchDownParam:function(){
var param=$('#search_select');
allEffect.pullDown(param);
param.find('li').click(function(){
var clickText=$(this).text();
var clickVal=$(this).val();
$(this).parent('ul').hide().prev('span').text(clickText);
$('#searchSelVal').val(clickVal);
});
},
pullDown:function(param){
return param.hover(function(){
$(this).children('ul').show();
},function(){
$(this).children('ul').hide();
});
},
categoryAuto:function(){
var $category=$('#category');
$category.find('.allcategory').click(function(){
$category.parent().css('height','auto');
});
},
productDetailScrollImg:function(){
var scrollParam={
pre:$('#productImgPrev'),
next:$('#productImgNext'),
scrollObj:$('#scrollimg'),
scrollLiW:$('#scrollimg li').width()+5,
showNum:1
};
allEffect.scrollImg(scrollParam);
},
productScrollImg:function(){
var scrollParam={
pre:$('#pre'),
next:$('#next'),
scrollObj:$('#scrollimg')
};
scrollParam.scrollObj.find('li').click(function(){
var bigimg=$(this).find('img').attr('bigsrc');
$('#bigimg').attr('src',bigimg);
//alert(bigimg)
});
},
scrollImg:function(scrollParam){
var newParam={
ul:scrollParam.scrollObj.find('ul'),
liNum:scrollParam.scrollObj.find('li').length,
divW:scrollParam.scrollObj.children('.scrollimg_main').width()
};
var ulW=newParam.ul.width(newParam.liNum*scrollParam.scrollLiW);
var param={
ulW:newParam.ul.width(),
ulLeft:newParam.ul.position().left,
sorollW:scrollParam.scrollLiW*scrollParam.showNum,//滚动的宽度
i:0
};
var remainder=newParam.liNum%scrollParam.showNum;
var divisor=(newParam.liNum-remainder)/scrollParam.showNum;
if(param.ulW<=newParam.divW){//alert(ulW)
nodrop(scrollParam.scrollObj.find('span'),true);
}else{
scrollParam.pre.click(function(){
if(param.i>0){
param.i--;showPic(param.i);
nodrop($(this),false);
}else{
nodrop($(this),true);
}
});
scrollParam.next.click(function(){
if(param.i";
};
btn += "";
if(len == 1){
btn = '';
}
this.append(btn).find('span').css("opacity",0.4).mouseenter(function() {
index = $this.children('.btn').children('span').index(this);
showPics(index);
}).eq(0).trigger("mouseenter");
$this.find('li').each(function(){
var imgsrc = $(this).children('img').attr('src');
$(this).children('img').remove();
$(this).css({'background':'url('+imgsrc+') no-repeat center'});
});
size();
$(window).resize(function(){
size();
});
function size(){
sWidth = $this.width();
$this.find('ul').css("width",sWidth * (len)).find('li').css("width",sWidth).find('a').css("width",sWidth);
}
this.hover(function() {
clearInterval(picTimer);
},function() {
picTimer = setInterval(function() {
showPics(index);
index++;
if(index == len) {index = 0;}
},4000);
}).trigger("mouseleave");
function showPics(index) {
var nowLeft = -index*sWidth;
var thisimg = $this.find('img').eq(index);
var colorrel=$this.find('li').eq(index).children('a').attr('rel');
//thisimg.css("margin-top",-(thisimg.height()/2));
$this.parents('.benner').css('background-color',colorrel);
$this.find('ul').stop(true,false).animate({"left":nowLeft},300).nextAll('.btn').find('span').stop(true,false).animate({"opacity":"0.4"},300).eq(index).stop(true,false).animate({"opacity":"1"},300);
};
};
})( jQuery );
var baguetteBox=function(){function t(t,n){L.transforms=f(),L.svg=p(),e(),D=document.querySelectorAll(t),[].forEach.call(D,function(t){var e=t.getElementsByTagName("a");e=[].filter.call(e,function(t){return j.test(t.rel)});var o=S.length;S.push(e),S[o].options=n,[].forEach.call(S[o],function(t,e){h(t,"click",function(t){t.preventDefault?t.preventDefault():t.returnValue=!1,i(o),a(e)})})})}function e(){return(b=v("baguetteBox-overlay"))?(k=v("baguetteBox-slider"),w=v("previous-button"),C=v("next-button"),void(T=v("close-button"))):(b=y("div"),b.id="baguetteBox-overlay",document.getElementsByTagName("body")[0].appendChild(b),k=y("div"),k.id="baguetteBox-slider",b.appendChild(k),w=y("button"),w.id="previous-button",w.innerHTML=L.svg?E:"<",b.appendChild(w),C=y("button"),C.id="next-button",C.innerHTML=L.svg?x:">",b.appendChild(C),T=y("button"),T.id="close-button",T.innerHTML=L.svg?B:"X",b.appendChild(T),w.className=C.className=T.className="baguetteBox-button",void n())}function n(){h(b,"click",function(t){t.target&&"IMG"!==t.target.nodeName&&"FIGCAPTION"!==t.target.nodeName&&s()}),h(w,"click",function(t){t.stopPropagation?t.stopPropagation():t.cancelBubble=!0,c()}),h(C,"click",function(t){t.stopPropagation?t.stopPropagation():t.cancelBubble=!0,u()}),h(T,"click",function(t){t.stopPropagation?t.stopPropagation():t.cancelBubble=!0,s()}),h(b,"touchstart",function(t){N=t.changedTouches[0].pageX}),h(b,"touchmove",function(t){H||(t.preventDefault?t.preventDefault():t.returnValue=!1,touch=t.touches[0]||t.changedTouches[0],touch.pageX-N>40?(H=!0,c()):touch.pageX-N<-40&&(H=!0,u()))}),h(b,"touchend",function(){H=!1}),h(document,"keydown",function(t){switch(t.keyCode){case 37:c();break;case 39:u();break;case 27:s()}})}function i(t){if(A!==t){for(A=t,o(S[t].options);k.firstChild;)k.removeChild(k.firstChild);X.length=0;for(var e,n=0;n',o.onload=function(){var n=document.querySelector("#baguette-img-"+t+" .spinner");i.removeChild(n),!I.async&&e&&e()},o.setAttribute("src",imageSrc),i.appendChild(o),I.captions&&imageCaption&&(a.innerHTML=imageCaption,i.appendChild(a)),I.async&&e&&e()}}function l(t){var e=imageElement.rel;if(t.dataset){var n=[];for(var i in t.dataset)"at-"!==i.substring(0,3)||isNaN(i.substring(3))||(n[i.replace("at-","")]=t.dataset[i]);keys=Object.keys(n).sort(function(t,e){return parseInt(t)=1?(M--,d(),m(M)):I.animation&&(k.className="bounce-from-left",setTimeout(function(){k.className=""},400))}function d(){var t=100*-M+"%";"fadeIn"===I.animation?(k.style.opacity=0,setTimeout(function(){L.transforms?k.style.transform=k.style.webkitTransform="translate3d("+t+",0,0)":k.style.left=t,k.style.opacity=1},400)):L.transforms?k.style.transform=k.style.webkitTransform="translate3d("+t+",0,0)":k.style.left=t}function f(){var t=y("div");return"undefined"!=typeof t.style.perspective||"undefined"!=typeof t.style.webkitPerspective}function p(){var t=y("div");return t.innerHTML="","http://www.w3.org/2000/svg"==(t.firstChild&&t.firstChild.namespaceURI)}function g(t){t-M>=I.preload||r(t+1,function(){g(t+1)})}function m(t){M-t>=I.preload||r(t-1,function(){m(t-1)})}function h(t,e,n){t.addEventListener?t.addEventListener(e,n,!1):t.attachEvent("on"+e,n)}function v(t){return document.getElementById(t)}function y(t){return document.createElement(t)}var b,k,w,C,T,N,E='',x='',B='',I={},P={captions:!0,buttons:"auto",async:!1,preload:2,animation:"slideIn"},L={},M=0,A=-1,H=!1,j=/.+\.(gif|jpe?g|png|webp)/i,D=[],S=[],X=[];return[].forEach||(Array.prototype.forEach=function(t,e){for(var n=0;n'+ (i+1) +'';
}
}else{
$kids.each(function(i){
arrPos.push(scrollSize);
scrollSize += $(this)[_type?'outerWidth':'outerHeight']();
navHtml += ''+ (i+1) +'';
});
}
navHtml += '';
//滚动元素总尺寸小于容器尺寸,不滚动
if (scrollSize<(_type?scrollW:scrollH)) return;
//克隆滚动子元素将其插入到滚动元素后,并设定滚动元素宽度
$element.append($kids.clone()).css(_type?'width':'height',scrollSize*2);
//轮换导航
if (opts.navId) {
$nav = $(opts.navId).append(navHtml).hover( stop, start );
$navBtns = $('li', $nav);
$navBtns.each(function(i){
$(this).bind(opts.eventNav,function(){
if(isMove) return;
if(numView==i) return;
rollFunc(arrPos[i]);
$navBtns.eq(numView).removeClass('navOn');
numView = i;
$(this).addClass('navOn');
});
});
$navBtns.eq(numView).addClass('navOn');
}
//设定初始位置
if (opts.direction == 'right' || opts.direction == 'down') {
_scrollObj[_type?'scrollLeft':'scrollTop'] = scrollSize;
}else{
_scrollObj[_type?'scrollLeft':'scrollTop'] = 0;
}
if(opts.isMarquee){
//滚动开始
//marqueeId = setInterval(scrollFunc, opts.scrollDelay);
marqueeId = setTimeout(scrollFunc, opts.scrollDelay);
//鼠标划过停止滚动
$marquee.hover(
function(){
clearInterval(marqueeId);
},
function(){
//marqueeId = setInterval(scrollFunc, opts.scrollDelay);
clearInterval(marqueeId);
marqueeId = setTimeout(scrollFunc, opts.scrollDelay);
}
);
//控制加速运动
if(opts.controlBtn){
$.each(opts.controlBtn, function(i,val){
$(val).bind(opts.eventA,function(){
opts.direction = i;
opts.oldAmount = opts.scrollAmount;
opts.scrollAmount = opts.newAmount;
}).bind(opts.eventB,function(){
opts.scrollAmount = opts.oldAmount;
});
});
}
}else{
if(opts.isAuto){
//轮换开始
start();
//鼠标划过停止轮换
$marquee.hover( stop, start );
}
//控制前后走
if(opts.btnGo){
$.each(opts.btnGo, function(i,val){
$(val).bind(opts.eventGo,function(){
if(isMove == true) return;
opts.direction = i;
rollFunc();
if (opts.isAuto) {
stop();
start();
}
});
});
}
}
function scrollFunc(){
var _dir = (opts.direction == 'left' || opts.direction == 'right') ? 'scrollLeft':'scrollTop';
if(opts.isMarquee){
if (opts.loop > 0) {
numMoved+=opts.scrollAmount;
if(numMoved>scrollSize*opts.loop){
_scrollObj[_dir] = 0;
return clearInterval(marqueeId);
}
}
var newPos = _scrollObj[_dir]+(opts.direction == 'left' || opts.direction == 'up'?1:-1)*opts.scrollAmount;
}else{
if(opts.duration){
if(t++=scrollSize){
newPos-=scrollSize;
}
}else{
if(newPos<=0){
newPos+=scrollSize;
}
}
_scrollObj[_dir] = newPos;
if(opts.isMarquee){
marqueeId = setTimeout(scrollFunc, opts.scrollDelay);
}else if(t=_len){
numView = 0;
}else if(numView<0){
numView = _len-1;
}
$navBtns.eq(numView).addClass('navOn');
numRoll = numView;
}
var _temp = numRoll<0?scrollSize:0;
t=0;
b=_scrollObj[_dir];
//c=(pPos != undefined)?pPos:_neg*opts.distance;
e=(pPos != undefined)?pPos:_temp+(opts.distance*numRoll)%scrollSize;
if(_neg==1){
if(e>b){
c = e-b;
}else{
c = e+scrollSize -b;
}
}else{
if(e>b){
c =e-scrollSize-b;
}else{
c = e-b;
}
}
d=opts.duration;
//scrollId = setInterval(scrollFunc, opts.scrollDelay);
if(scrollId) clearTimeout(scrollId);
scrollId = setTimeout(scrollFunc, opts.scrollDelay);
}
function start(){
rollId = setInterval(function(){
rollFunc();
}, opts.time*1000);
}
function stop(){
clearInterval(rollId);
}
function easeOutQuad(t,b,c,d){
return -c *(t/=d)*(t-2) + b;
}
function easeOutQuint(t,b,c,d){
return c*((t=t/d-1)*t*t*t*t + 1) + b;
}
});
};
$.fn.kxbdSuperMarquee.defaults = {
isMarquee:false,//是否为Marquee
isEqual:true,//所有滚动的元素长宽是否相等,true,false
loop: 0,//循环滚动次数,0时无限
newAmount:3,//加速滚动的步长
eventA:'mousedown',//鼠标事件,加速
eventB:'mouseup',//鼠标事件,原速
isAuto:true,//是否自动轮换
time:5,//停顿时间,单位为秒
duration:50,//缓动效果,单次移动时间,越小速度越快,为0时无缓动效果
eventGo:'click', //鼠标事件,向前向后走
direction: 'left',//滚动方向,'left','right','up','down'
scrollAmount:1,//步长
scrollDelay:10,//时长
eventNav:'click'//导航事件
};
$.fn.kxbdSuperMarquee.setDefaults = function(settings) {
$.extend( $.fn.kxbdSuperMarquee.defaults, settings );
};
})(jQuery);