/*---------------------------------------------------------------------*/ function floatqq(options){ options=$.extend({},{ hoverable:true, moveable:true, closeable:true, floatable:true, width:120, topbg:'/template/images/qq_top2.gif', middlebg:'/template/images/qq_middle2.gif', bottombg:'/template/images/qq_bottom2.gif', topheight:76, hoverouth:56, bottomheight:16, closecolor:'#ff955d', left:0, top:200, qqtype:16, id:'floatbar', qq:'' },options); new qq(options); var obj=$("#"+options.id); var floattop=options.top; var qqt=$("#"+options.id+"top"); var qqm=$("#"+options.id+"middle"); var qqb=$("#"+options.id+"bottom"); var qqclose=$("#"+options.id+"close"); if(options.hoverable){ qqt.height(options.hoverouth); qqm.hide(); qqb.hide(); obj.hover(function(){ qqt.height(options.topheight);qqm.show();qqb.show(); },function(){ qqt.height(options.hoverouth);qqm.hide();qqb.hide(); }); } if(options.moveable){ obj.css({position:"absolute"}); qqt.css('cursor','hand'); qqt.mousedown(function(){ var leftlen=event.clientx-obj.offset().left; var toplen=event.clienty-obj.offset().top; $(document).bind("mousemove",function(event){ var aa=event.clientx-leftlen; var bb=event.clienty-toplen; obj.css({left:aa,top:bb}); floattop=bb-$(window).scrolltop(); }).bind("mouseup",function(){ $(document).unbind("mousemove").unbind("mouseup"); }); }); } if(options.closeable){ if(qqclose){ qqclose.bind('click mousedown',function(){obj.hide();}); } } if(options.floatable){ obj.css({visibility:"visible",left:((window.screen.width-1024)/2+options.left),top:floattop}); $(window).scroll(function(){ obj.css({top:$(this).scrolltop()+floattop}); }); } } /*****************************qq object==s**************************************/ var qq=function(options){ this.width=options.width; this.topbg=options.topbg; this.middlebg=options.middlebg; this.bottombg=options.bottombg; this.id=options.id; this.qq=options.qq; this.closecolor=options.closecolor; this.qqtype=options.qqtype; this.topheight=options.topheight; this.bottomheight=options.bottomheight; this.getqqstr=function(qqnum,qqtxt,qqtype){ var qqhtml=''; qqhtml=''; qqhtml+=''; qqhtml+=' '; qqhtml+=qqtxt+' '; return qqhtml; } this.initqq=function(){ var qq_str=options.qq.split(','); var qqhtml=new array(); for(var i=0;i关闭
'; html+=' '; html+=' 
'; return html; } this.initqq(); } /*********************************qq object==e***********************************/ /**----------------------------floatqq==e---------------------------------------**/ /**---------------------------floatad==s----------------------------------------**/ /** **version:2.5; **floatad({options}); **case: floatad({ url:"ad.html", left:0, top:200, centercss:"background:#ccc;height:100px;padding:0px;" }); //or floatad({text:"内容 内容"}); ** **/ /*------------------------------------------------------------------------*/ function floatad(options){ options=$.extend({},{ id:"floatad", left:20, top:200, width:200, css:"border:1px solid #666; ", topheight:20, title:"公告:", titlecss:"font-size:14px;font-weight:bold;color:red;", topcss:"background:#666; ", closecolor:"#000", centercss:"background:#ccc;height:100px;padding:5px;", url:" ", pagew:1003, frameh:100, text:"内容", hoverable:true, closeable:true, floatable:true, moveable:true },options); new ad(options); var obj=$("#"+options.id); var floattop=options.top; var adtop=$("#"+options.id+"top"); var adinner=$("#"+options.id+"inner"); var adclose=$("#"+options.id+"close"); if(options.hoverable){ adinner.hide(); obj.hover(function(){adinner.show();},function(){adinner.hide();}); } if(options.closeable){ adclose.bind('click mousedown',function(){obj.hide();}); } if(options.floatable){ obj.css({visibility:"visible",left:(window.screen.width-15-options.pagew)/2+options.left,top:floattop}); $(window).scroll(function(){ obj.css({top:$(this).scrolltop()+floattop}); }); } if(options.moveable){ obj.css({position:"absolute"}); adtop.css('cursor','hand'); adtop.mousedown(function(){ var leftlen=event.clientx-obj.offset().left; var toplen=event.clienty-obj.offset().top; $(document).bind("mousemove",function(event){ var aa=event.clientx-leftlen; var bb=event.clienty-toplen; obj.css({left:aa,top:bb}); floattop=bb-$(window).scrolltop(); }).bind("mouseup",function(){ $(document).unbind("mousemove").unbind("mouseup"); }); }); } } /*****************************ad object==s**************************************/ var ad=function(o){ this.id=o.id; this.width=o.width; this.top=o.top; this.css=o.css; this.title=o.title; this.titlecss=o.titlecss; this.topheight=o.topheight; this.topcss=o.topcss; this.closecolor=o.closecolor; this.centercss=o.centercss; this.url=o.url; this.frameh=o.frameh; this.text=o.text; this.initad=function(){ var html=this.getadhtml(); $("body").append(html); } this.getadhtml=function(){ html='
'+this.title+''; html+=' '; html+='关闭
'; if(this.url!=" "){ html+=''; }else if(this.textid!=""){ htmlinner=$(this.textid).html(); }else{ htmlinner='
'+this.text+'
'; } html+=''; $('body').append(html); this.jobject=$("#"+this.id); this.jclose=$("#"+o.id+"close"); this.jtitle=$("#"+o.id+"title"); var obj=this; this.getcenterp=function(){ this.ll=function(){return (window.screen.width-obj.width)/2;} this.tt=function(){return (window.screen.height-obj.height)/2;} } this.setposition=function(left,top){ obj.jobject.css({left:left+$(document).scrollleft(),top:top+$(document).scrolltop()}); } this.getjobject=function(){ return obj.jobject; } this.bindclose=function(overlay){ obj.jclose.css('cursor','hand'); obj.jclose.bind('click',function(){ obj.jobject.hide(); obj.jobject.remove(); if(overlay){overlay.hide();overlay.remove();} }); } this.bindfloat=function(){ $(window).scroll(function(){ obj.setposition(obj.left,obj.top); }); } this.bindmove=function(){ obj.jtitle.css('cursor','hand'); obj.jtitle.mousedown(function(){ var leftlen=event.clientx-obj.jobject.offset().left; var toplen=event.clienty-obj.jobject.offset().top; $(document).bind("mousemove",function(event){ var aa=event.clientx-leftlen; var bb=event.clienty-toplen; obj.top=bb-$(document).scrolltop(); obj.left=aa-$(document).scrollleft(); obj.jobject.css({left:aa,top:bb}); }).bind("mouseup",function(){ $(document).unbind("mousemove").unbind("mouseup"); }); }); } if(this.left=="auto"){ this.left=new this.getcenterp().ll(); } if(this.top=="auto"){ this.top=new this.getcenterp().tt(); } //初始化位置 this.setposition(this.left,this.top); } /*生成弹出层-------------------e--------------------*/ /*获取页面高度宽度-------------------s--------------------*/ var docinfo=function(dd){ this.ww=function(){var ww=document.compatmode == "css1compat"?document.documentelement.scrollwidth:document.body.scrollwidth;return math.max(ww,$(window).width());} this.hh=function(){var hh=document.compatmode == "css1compat"?document.documentelement.scrollheight:document.body.scrollheight;return math.max(hh,$(window).height());} } /*获取页面高度宽度-------------------e--------------------*/ /*生成遮罩层-------------------s--------------------*/ var overlay=function(id){ var overlay=''; $('body').append(overlay); var obj=this; this.joverlay=$("#"+id+"masks"); this.getjobject=function(){ return obj.joverlay; } this.initoverlay=function(){ obj.joverlay.css({width:new docinfo().ww(),height:new docinfo().hh()}); } this.initoverlay(); } /*生成遮罩层-------------------e--------------------*/ /*处理逻辑 s*/ var gfloatbox=function(obj,o){ //点击创建对象 关闭时移除对象 obj.bind('click',function(){ var floatboxobj=new floatbox(o); //弹出层对象 var overlayobj=new overlay(o.id); //遮罩层对象 var $floatbox=floatboxobj.getjobject(); //弹出层jq对象 var $overlay=overlayobj.getjobject(); //遮罩层jq对象 $overlay.show(); $floatbox.show(); if(o.closeable){floatboxobj.bindclose($overlay);} if(o.floatable){floatboxobj.bindfloat();} if(o.moveable){floatboxobj.bindmove();} }); } /*处理逻辑 e*/ /*main s*/ o=$.extend({},{ id:"floatpo", /*弹出框id */ width:400, /*弹出框宽度 */ height:300, /*弹出框高度 */ left:"auto", /*弹出宽初始左边距 auto时取屏幕中间*/ top:"auto", /*弹出框初始上边距 auto时去屏幕中间*/ url:"", /*包含页面 url 如"aaa.html" */ textid:"", /*包含某id 下的html内容 如"#aaa" */ title: "", /*直接写内容 标题 */ text:"", /*直接写内容 内容 */ titlecss:"", /*标题样式 */ innercss:"", /*内容样式 限直接包含text使用 */ closecss:"", /*关闭按钮样式 */ closeinner:"╳ ", /*关闭按钮内容 */ css:"", /*弹出框 样式 */ closeable:true, /*是否能关闭 */ moveable:true, /*是否能拖动 */ floatable:true /*是否能浮动 */ },o); new gfloatbox($(this),o); /*main e*/ } /**-----------------------------generatefloatbox==e---------------------------------------**/ /**-----------------------------lmarquee==s-----------------------------------------------**/ /** case: $('#id').lmarquee({ loop: 0,//循环滚动次数,0时无限 direction: 'left',//滚动方向,'left','right','up','down' scrollamount:1,//步长 leftbtn:null, rightbtn:null, topbtn:null, bottombtn:null, automove:false, btnl:0.1, //按钮点击,每单次运动的步长 占图片宽度或高度的百分比 btnn:10, //按钮点击,运动的次数 btndelay:10, //按钮点击,每单次运动时长 btndirect:false, //点击按钮后是否根据按钮改变方向 scrolldelay:10//时长 }); **/ jquery.fn.lmarquee = function(options){ var o=this; var opts = $.extend({},{ loop: 0,//循环滚动次数,0时无限 direction: 'left',//滚动方向,'left','right','up','down' scrollamount:1,//步长 leftbtn:null, rightbtn:null, topbtn:null, bottombtn:null, automove:false, btnl:0.1, //按钮点击,每单次运动的步长 占图片宽度或高度的百分比 btnn:10, //按钮点击,运动的次数 btndelay:10, //按钮点击,每单次运动时长 btndirect:false, //点击按钮后是否根据按钮改变方向 scrolldelay:10//时长 }, options||{}); this.moveimg=function(){ o.each(function(){ var marqueeo = $(this);//滚动元素容器 var _scrollobj = marqueeo.get(0);//滚动元素容器dom var scrollw = marqueeo.width();//滚动元素容器的宽度 var scrollh = marqueeo.height();//滚动元素容器的高度 var lelement = marqueeo.children(); //滚动元素 var lkids = lelement.children();//滚动子元素 var scrollsize=0;//滚动元素尺寸 var moveid; var _type = (opts.direction == 'left' || opts.direction == 'right') ? 1:0;//滚动类型,1左右,0上下 //防止滚动子元素比滚动元素宽而取不到实际滚动子元素宽度 marqueeo.css({"position":"relative",overflow:"hidden"}); lelement.css({"position":"relative",margin:"0",padding:"0","list-style":"none"}); lkids.css({margin:"0",padding:"0","position":"relative"}); if(_type){ scrollsize=lkids.length*(lkids.width()); lelement.css({"width" : 2*scrollsize+"px","height" : lkids.height()+"px"}); }else{ scrollsize=lkids.length*(lkids.height()); lelement.css({"height" : 2*scrollsize+"px","width" : lkids.width()+"px"}); } lelement.css(_type?'width':'height',lkids.length*lkids.width()); if (scrollsize<(_type?scrollw:scrollh)) return; //克隆滚动子元素将其插入到滚动元素后,并设定滚动元素宽度 lelement.append(lkids.clone()).css(_type?'width':'height',scrollsize*2); var nummoved = 0; function scrollfunc(amout,dir){ var _dir = (dir == 'left' || dir == 'right') ? 'scrollleft':'scrolltop'; if (opts.loop > 0) { nummoved+=amout; if(nummoved>scrollsize*opts.loop){ _scrollobj[_dir] = 0; return clearinterval(moveid); } } if(dir == 'left' || dir == 'up'){ var newpos = _scrollobj[_dir] + amout; if(newpos>=scrollsize){ newpos -= scrollsize; } _scrollobj[_dir] = newpos; }else{ var newpos = _scrollobj[_dir] - amout; if(newpos<=0){ newpos += scrollsize; } _scrollobj[_dir] = newpos; } } //滚动开始 if(opts.automove){ moveid = setinterval(function(){scrollfunc(opts.scrollamount,opts.direction);}, opts.scrolldelay); hoverfun(marqueeo); if(opts.leftbtn){hoverfun(opts.leftbtn);} if(opts.rightbtn){hoverfun(opts.rightbtn);} if(opts.topbtn){hoverfun(opts.topbtn);} if(opts.bottombtn){hoverfun(opts.bottombtn);} } //鼠标划过停止滚动 function hoverfun(lo){ lo.hover(function(){ if(moveid){clearinterval(moveid);} }, function(){ if(moveid){clearinterval(moveid);} moveid = setinterval(function(){scrollfunc(opts.scrollamount,opts.direction);}, opts.scrolldelay); } ); } btnbind(opts.leftbtn,"left"); btnbind(opts.rightbtn,"right"); btnbind(opts.topbtn,"up"); btnbind(opts.bottombtn,"down"); function btnbind(btn,dir){ if(btn){ var len=_type ? lkids.width() : lkids.height(); //每个单元的宽度或高度 var nn=1/opts.btnl; var zz=opts.btnn/nn; var maxlen=zz*len; var yy=maxlen%opts.btnn; //最后一次运动的量 var ll=math.floor(maxlen/opts.btnn); //前 opts.btnn 次每次运动 的量 btn.bind('click',function(){ var v=1; if(opts.btndirect){opts.direction=dir;} //是否能够改变方向 if(moveid){clearinterval(moveid);} moveid = setinterval(function(){ scrollfunc(ll,dir); v++; if(v>opts.btnn){ //达到次数,结束运动 最后一次运动完剩下的部分 scrollfunc(math.round(yy),dir); if(moveid){clearinterval(moveid);} } }, opts.btndelay); }); } } }); } this.moveimg(); }; /**-----------------------------lmarquee==e---------------------------------------**/