/** * author: 张中乐 * email: sjz20072-304@163.com * update: 2014.5.13 */ ;(function($){ //个人插件 start $.fn.extend({ /** * 功能介绍:标签切换tab * 参数介绍: * myevent:'click', 默认为单击click事件,可修改 * contentid:'', 默认为空,可切换内容父级标签id,选填项 * contentcss:'' 默认为空,可切换内容标签样式,必填项 * titleoff:'', 默认为空,提示标题常状态样式,选填项 * titleon:'', 默认为空,提示标题当前选中状态样式,选填项 * btn:'li' 默认为li标签做为点击按钮,可修改 *--------------------------------------- * update: 2014.4.30 */ 'tab':function(options){ var p_self=$(this); var last=null; options=$.extend({ myevent:'click', contentid:'', contentcss:'', titleoff:'', titleon:'', animtecss:'fadeinright', active:false, btn:'li' },options); p_self.children(options.btn).on(options.myevent,function(){ if(last==$(this).index()) return false; if(options.active){ p_self.children(options.btn).removeclass(options.titleon) $(this).addclass(options.titleon); }else{ p_self.children(options.btn).attr('class',options.titleoff) $(this).attr('class',options.titleon); } if(options.contentid){ $(options.contentid+' '+options.contentcss).eq($(this).index()).show().siblings().hide(); }else{ $(options.contentcss).hide(); $(options.contentcss).eq($(this).index()).show(); if(options.animtecss){ $(options.contentcss).removeclass(options.animtecss); $(options.contentcss).eq($(this).index()).addclass(options.animtecss); } } last=$(this).index(); }); return this; }, /** * 功能介绍:imitate select 模拟下拉框 * 参数介绍: * sub_ul:'ul', 默认下拉框父标签为‘ul’,可修改为其他标签 * sub_li:'li', 默认下拉框子标签为‘li’,可修改为其他标签 * myevent:'click', 默认事件为‘click’,可修改 * selected:1, 默认选中下拉菜单第一项,可修改为1,2,3... ;若为last,选中最后一项 * speed:100, * clickishide 默认为true,点击后下拉框是否消失 *--------------------------------------- * update: 2014.4.30 */ 'imiselect':function(options){ var clickone_tid = []; var p_self=$(this); var ele={} options=$.extend({ sub_ul:'ul', sub_li:'li', myevent:'click', selected:1, speed:100, clickishide:true, parent_css:'.zselect', box:'.zse_ul' },options); //显示和隐藏下拉框 p_self.on(options.myevent,function(){ $(options.box).slideup(); $(this).addclass("zfl_white"); $(options.parent_css).css('zindex','1'); $(this).css('zindex','22'); cleartimeout(clickone_tid[0]); self_=this; clickone_tid[0]=settimeout(function(){ $(self_).find(options.sub_ul+':eq(0)').slidetoggle(options.speed?'fast':options.speed); },200); }); //默认选中第n项 ele.ul=p_self.find(options.sub_ul+':eq(0)'); ele.li=p_self.find(options.sub_ul+':eq(0)').find(options.sub_li); if(options.selected){ if(options.selected'+parseint(i+1)+''); }else{ $(notconf.point).append('<'+notconf.tmp+' class="'+options.pointoff+'">'); } }; $(notconf.point).find(notconf.tmp).each(function(index){ $(this).on('click',function(){ if(notconf.count!=index){ move_right(index); } $(this).attr('class',options.pointon).siblings().attr('class',options.pointoff); notconf.count=index; }); }); //添加当前按钮样式 function cur_btn(){ $(notconf.point).find(notconf.tmp).eq(notconf.count).attr('class',options.pointon).siblings().attr('class',options.pointoff); } if(options.ispoint){ notconf.point.show(); } //根据窗口改变重新初始化 function setwindow(){ notconf.width=$(window).width(); //notconf.height=$(window).height(); if(notconf.width<=options.minw){ notconf.width=options.minw; } if(!options.isfull){ notconf.width=options.minw; } //options.bg.height(notconf.height+'px'); notconf.content.width(notconf.width); notconf.mid.html(notconf.middle.html()); notconf.middle.width(notconf.content.length*notconf.width); notconf.mid.width(notconf.content.length*notconf.width); if(notconf.flag){ //保留注释,待更新在浏览器大小改变时,不改变当前图片 //notconf.mid.css('left',-notconf.width*notconf.count+'px'); //notconf.middle.css('left',notconf.width*(notconf.content.length-notconf.count)+'px'); setone(); notconf.lastw=notconf.width; //notconf.lasth=notconf.height; notconf.flag=0; } } setwindow(); //校对轨道 function check(f){ //f值为1:校对向左滑动轨道,f值为0或空:校对向右滑动轨道 if(f){ var site=(notconf.mid.position().left<=0?notconf.mid.position().left*-1:notconf.mid.position().left*1)/notconf.width; notconf.middle.css('left',(notconf.content.length-site)*notconf.width+'px'); }else{ var site=(notconf.mid.position().left<=0?notconf.mid.position().left*-1:notconf.mid.position().left*1)/notconf.width; notconf.middle.css('left',(notconf.content.length+site)*notconf.width*-1+'px'); } } //初始化被克隆和克隆内容的位置,以满足左右按钮条件使点击左右滑动 function setone(){ notconf.middle.css('left',notconf.content.length*notconf.width*-1+'px'); notconf.mid.css('left',0+'px'); notconf.count=0; cur_btn(); } setone(); //左滑动 function move_left(){ if(notconf.isbottom){ notconf.isbottom=0; check(1); } if(notconf.middle.position().left<=(-(notconf.content.length)*notconf.width)){ notconf.middle.css('left',notconf.content.length*notconf.width+'px'); } notconf.middle.not(':animated').animate({left:"-="+notconf.width},600,function(){notconf.isanimate=true;}); if(notconf.mid.position().left<=(-(notconf.content.length)*notconf.width)){ notconf.mid.css('left',notconf.content.length*notconf.width+'px'); } notconf.mid.not(':animated').animate({left:"-="+notconf.width},600,function(){notconf.isanimate=true;}); //记录当前图片 if(notconf.isanimate){ notconf.isanimate=false; if(notconf.count