// 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);