/* * date - 数据,name - .classname 或者 #id,width - 宽度,height - 高度 * slide: banner效果,需要传递相应的.classname或者#id,不然默认插入网页底部; * couplet: 对联广告,最好不指定name值,默认插入body; * floatp: 浮动广告,乱飘的那个,最好不指定name值,默认插入body,开完cpu飞起来,慎开; * mount: 泰山压顶,不指定name值,默认插到网页顶部; * bottomcenter: 网页底部居中广告; * bottomright : 网页底部居右广告; * randompic: 随机单张,需给定name值,不然默认插到网页底部; * piclist: 图片罗列,所有传过来的数据全部罗列出来; */ function bindclose(closebtn,closebox){ $(closebtn).click(function(){ $(closebox).remove(); }); } function errorsalert(width,height){ if(width == "" || height==""){ alert("广告未填写高度或宽度,请重新填写!"); } } function nonelink(link){ if(link == ""){ links = "javascript:;"; target = "_self"; }else{ links = link; target = "_blank"; } } function atm(){ var links="", target=""; } atm.prototype = { slide:function(data,name,width,height){ // 幻灯片 errorsalert(width,height); name == "" ? name = "body" : name; var kli = ""; !function(a){a.fn.slide=function(b){return a.fn.slide.defaults={type:"slide",effect:"fade",autoplay:!1,delaytime:500,intertime:2500,triggertime:150,defaultindex:0,titcell:".hd li",maincell:".bd",targetcell:null,trigger:"mouseover",scroll:1,vis:1,titonclassname:"on",autopage:!1,prevcell:".atm_prev",nextcell:".atm_next",pagestatecell:".pagestate",opp:!1,pnloop:!0,easing:"swing",startfun:null,endfun:null,switchload:null,playstatecell:".playstate",mouseoverstop:!0,defaultplay:!0,returndefault:!1},this.each(function(){var c=a.extend({},a.fn.slide.defaults,b),d=a(this),e=c.effect,f=a(c.prevcell,d),g=a(c.nextcell,d),h=a(c.pagestatecell,d),i=a(c.playstatecell,d),j=a(c.titcell,d),k=j.size(),l=a(c.maincell,d),m=l.children().size(),n=c.switchload,o=a(c.targetcell,d),p=parseint(c.defaultindex),q=parseint(c.delaytime),r=parseint(c.intertime);parseint(c.triggertime);var q,t=parseint(c.scroll),u=parseint(c.vis),v="false"==c.autoplay||0==c.autoplay?!1:!0,w="false"==c.opp||0==c.opp?!1:!0,x="false"==c.autopage||0==c.autopage?!1:!0,y="false"==c.pnloop||0==c.pnloop?!1:!0,z="false"==c.mouseoverstop||0==c.mouseoverstop?!1:!0,a="false"==c.defaultplay||0==c.defaultplay?!1:!0,b="false"==c.returndefault||0==c.returndefault?!1:!0,c=0,d=0,e=0,f=0,g=c.easing,h=null,i=null,j=null,k=c.titonclassname,l=j.index(d.find("."+k)),m=p=-1==l?p:l,n=p,o=p,p=m>=u?0!=m%t?m%t:t:0,r="leftmarquee"==e||"topmarquee"==e?!0:!1,s=function(){a.isfunction(c.startfun)&&c.startfun(p,k,d,a(c.titcell,d),l,o,f,g)},t=function(){a.isfunction(c.endfun)&&c.endfun(p,k,d,a(c.titcell,d),l,o,f,g)},u=function(){j.removeclass(k),a&&j.eq(n).addclass(k)};if("menu"==c.type)return a&&j.removeclass(k).eq(p).addclass(k),j.hover(function(){q=a(this).find(c.targetcell);var b=j.index(a(this));i=settimeout(function(){switch(p=b,j.removeclass(k).eq(p).addclass(k),s(),e){case"fade":q.stop(!0,!0).animate({opacity:"show"},q,g,t);break;case"slidedown":q.stop(!0,!0).animate({height:"show"},q,g,t)}},c.triggertime)},function(){switch(cleartimeout(i),e){case"fade":q.animate({opacity:"hide"},q,g);break;case"slidedown":q.animate({height:"hide"},q,g)}}),b&&d.hover(function(){cleartimeout(j)},function(){j=settimeout(u,q)}),void 0;if(0==k&&(k=m),r&&(k=2),x){if(m>=u)if("leftloop"==e||"toploop"==e)k=0!=m%t?(0^m/t)+1:m/t;else{var v=m-u;k=1+parseint(0!=v%t?v/t+1:v/t),0>=k&&(k=1)}else k=1;j.html("");var w="";if(1==c.autopage||"true"==c.autopage)for(var x=0;k>x;x++)w+="
  • "+(x+1)+"
  • ";else for(var x=0;k>x;x++)w+=c.autopage.replace("$",x+1);j.html(w);var j=j.children()}if(m>=u){l.children().each(function(){a(this).width()>e&&(e=a(this).width(),d=a(this).outerwidth(!0)),a(this).height()>f&&(f=a(this).height(),c=a(this).outerheight(!0))});var y=l.children(),z=function(){for(var a=0;u>a;a++)y.eq(a).clone().addclass("clone").appendto(l);for(var a=0;p>a;a++)y.eq(m-a-1).clone().addclass("clone").prependto(l)};switch(e){case"fold":l.css({position:"relative",width:d,height:c}).children().css({position:"absolute",width:e,left:0,top:0,display:"none"});break;case"top":l.wrap('
    ').css({top:-(p*t)*c,position:"relative",padding:"0",margin:"0"}).children().css({height:f});break;case"left":l.wrap('
    ').css({width:m*d,left:-(p*t)*d,position:"relative",overflow:"hidden",padding:"0",margin:"0"}).children().css({"float":"left",width:e});break;case"leftloop":case"leftmarquee":z(),l.wrap('
    ').css({width:(m+u+p)*d,position:"relative",overflow:"hidden",padding:"0",margin:"0",left:-(p+p*t)*d}).children().css({"float":"left",width:e});break;case"toploop":case"topmarquee":z(),l.wrap('
    ').css({height:(m+u+p)*c,position:"relative",padding:"0",margin:"0",top:-(p+p*t)*c}).children().css({height:f})}}var $=function(a){var b=a*t;return a==k?b=m:-1==a&&0!=m%t&&(b=-m%t),b},_=function(b){var c=function(c){for(var d=c;u+c>d;d++)b.eq(d).find("img["+n+"]").each(function(){var b=a(this);if(b.attr("src",b.attr(n)).removeattr(n),l.find(".clone")[0])for(var c=l.children(),d=0;d=1?p=1:0>=p&&(p=0):(o=p,p>=k?p=0:0>p&&(p=k-1)),s(),null!=n&&_(l.children()),o[0]&&(q=o.eq(p),null!=n&&_(o),"slidedown"==e?(o.not(q).stop(!0,!0).slideup(q),q.slidedown(q,g,function(){l[0]||t()})):(o.not(q).stop(!0,!0).hide(),q.animate({opacity:"show"},q,function(){l[0]||t()}))),m>=u)switch(e){case"fade":l.children().stop(!0,!0).eq(p).animate({opacity:"show"},q,g,function(){t()}).siblings().hide();break;case"fold":l.children().stop(!0,!0).eq(p).animate({opacity:"show"},q,g,function(){t()}).siblings().animate({opacity:"hide"},q,g);break;case"top":l.stop(!0,!1).animate({top:-p*t*c},q,g,function(){t()});break;case"left":l.stop(!0,!1).animate({left:-p*t*d},q,g,function(){t()});break;case"leftloop":var b=o;l.stop(!0,!0).animate({left:-($(o)+p)*d},q,g,function(){-1>=b?l.css("left",-(p+(k-1)*t)*d):b>=k&&l.css("left",-p*d),t()});break;case"toploop":var b=o;l.stop(!0,!0).animate({top:-($(o)+p)*c},q,g,function(){-1>=b?l.css("top",-(p+(k-1)*t)*c):b>=k&&l.css("top",-p*c),t()});break;case"leftmarquee":var c=l.css("left").replace("px","");0==p?l.animate({left:++c},0,function(){l.css("left").replace("px","")>=0&&l.css("left",-m*d)}):l.animate({left:--c},0,function(){l.css("left").replace("px","")<=-(m+p)*d&&l.css("left",-p*d)});break;case"topmarquee":var d=l.css("top").replace("px","");0==p?l.animate({top:++d},0,function(){l.css("top").replace("px","")>=0&&l.css("top",-m*c)}):l.animate({top:--d},0,function(){l.css("top").replace("px","")<=-(m+p)*c&&l.css("top",-p*c)})}j.removeclass(k).eq(p).addclass(k),m=p,y||(g.removeclass("nextstop"),f.removeclass("prevstop"),0==p&&f.addclass("prevstop"),p==k-1&&g.addclass("nextstop")),h.html(""+(p+1)+"/"+k)}};a&&ab(!0),b&&d.hover(function(){cleartimeout(j)},function(){j=settimeout(function(){p=n,a?ab():"slidedown"==e?q.slideup(q,u):q.animate({opacity:"hide"},q,u),m=p},300)});var bb=function(a){h=setinterval(function(){w?p--:p++,ab()},a?a:r)},cb=function(a){h=setinterval(ab,a?a:r)},db=function(){z||(clearinterval(h),bb())},eb=function(){(y||p!=k-1)&&(p++,ab(),r||db())},fb=function(){(y||0!=p)&&(p--,ab(),r||db())},gb=function(){clearinterval(h),r?cb():bb(),i.removeclass("pausestate")},hb=function(){clearinterval(h),i.addclass("pausestate")};if(v?r?(w?p--:p++,cb(),z&&l.hover(hb,gb)):(bb(),z&&d.hover(hb,gb)):(r&&(w?p--:p++),i.addclass("pausestate")),i.click(function(){i.hasclass("pausestate")?gb():hb()}),"mouseover"==c.trigger?j.hover(function(){var a=j.index(this);i=settimeout(function(){p=a,ab(),db()},c.triggertime)},function(){cleartimeout(i)}):j.click(function(){p=j.index(this),ab(),db()}),r){if(g.mousedown(eb),f.mousedown(fb),y){var ib,jb=function(){ib=settimeout(function(){clearinterval(h),cb(0^r/10)},150)},kb=function(){cleartimeout(ib),clearinterval(h),cb()};g.mousedown(jb),g.mouseup(kb),f.mousedown(jb),f.mouseup(kb)}"mouseover"==c.trigger&&(g.hover(eb,function(){}),f.hover(fb,function(){}))}else g.click(eb),f.click(fb)})}}(jquery),jquery.easing.jswing=jquery.easing.swing,jquery.extend(jquery.easing,{def:"easeoutquad",swing:function(a,b,c,d,e){return jquery.easing[jquery.easing.def](a,b,c,d,e)},easeinquad:function(a,b,c,d,e){return d*(b/=e)*b+c},easeoutquad:function(a,b,c,d,e){return-d*(b/=e)*(b-2)+c},easeinoutquad:function(a,b,c,d,e){return(b/=e/2)<1?d/2*b*b+c:-d/2*(--b*(b-2)-1)+c},easeincubic:function(a,b,c,d,e){return d*(b/=e)*b*b+c},easeoutcubic:function(a,b,c,d,e){return d*((b=b/e-1)*b*b+1)+c},easeinoutcubic:function(a,b,c,d,e){return(b/=e/2)<1?d/2*b*b*b+c:d/2*((b-=2)*b*b+2)+c},easeinquart:function(a,b,c,d,e){return d*(b/=e)*b*b*b+c},easeoutquart:function(a,b,c,d,e){return-d*((b=b/e-1)*b*b*b-1)+c},easeinoutquart:function(a,b,c,d,e){return(b/=e/2)<1?d/2*b*b*b*b+c:-d/2*((b-=2)*b*b*b-2)+c},easeinquint:function(a,b,c,d,e){return d*(b/=e)*b*b*b*b+c},easeoutquint:function(a,b,c,d,e){return d*((b=b/e-1)*b*b*b*b+1)+c},easeinoutquint:function(a,b,c,d,e){return(b/=e/2)<1?d/2*b*b*b*b*b+c:d/2*((b-=2)*b*b*b*b+2)+c},easeinsine:function(a,b,c,d,e){return-d*math.cos(b/e*(math.pi/2))+d+c},easeoutsine:function(a,b,c,d,e){return d*math.sin(b/e*(math.pi/2))+c},easeinoutsine:function(a,b,c,d,e){return-d/2*(math.cos(math.pi*b/e)-1)+c},easeinexpo:function(a,b,c,d,e){return 0==b?c:d*math.pow(2,10*(b/e-1))+c},easeoutexpo:function(a,b,c,d,e){return b==e?c+d:d*(-math.pow(2,-10*b/e)+1)+c},easeinoutexpo:function(a,b,c,d,e){return 0==b?c:b==e?c+d:(b/=e/2)<1?d/2*math.pow(2,10*(b-1))+c:d/2*(-math.pow(2,-10*--b)+2)+c},easeincirc:function(a,b,c,d,e){return-d*(math.sqrt(1-(b/=e)*b)-1)+c},easeoutcirc:function(a,b,c,d,e){return d*math.sqrt(1-(b=b/e-1)*b)+c},easeinoutcirc:function(a,b,c,d,e){return(b/=e/2)<1?-d/2*(math.sqrt(1-b*b)-1)+c:d/2*(math.sqrt(1-(b-=2)*b)+1)+c},easeinelastic:function(a,b,c,d,e){var f=1.70158,g=0,h=d;if(0==b)return c;if(1==(b/=e))return c+d;if(g||(g=.3*e),hb?-.5*h*math.pow(2,10*(b-=1))*math.sin((b*e-f)*2*math.pi/g)+c:.5*h*math.pow(2,-10*(b-=1))*math.sin((b*e-f)*2*math.pi/g)+d+c},easeinback:function(a,b,c,d,e,f){return void 0==f&&(f=1.70158),d*(b/=e)*b*((f+1)*b-f)+c},easeoutback:function(a,b,c,d,e,f){return void 0==f&&(f=1.70158),d*((b=b/e-1)*b*((f+1)*b+f)+1)+c},easeinoutback:function(a,b,c,d,e,f){return void 0==f&&(f=1.70158),(b/=e/2)<1?d/2*b*b*(((f*=1.525)+1)*b-f)+c:d/2*((b-=2)*b*(((f*=1.525)+1)*b+f)+2)+c},easeinbounce:function(a,b,c,d,e){return d-jquery.easing.easeoutbounce(a,e-b,0,d,e)+c},easeoutbounce:function(a,b,c,d,e){return(b/=e)<1/2.75?d*7.5625*b*b+c:2/2.75>b?d*(7.5625*(b-=1.5/2.75)*b+.75)+c:2.5/2.75>b?d*(7.5625*(b-=2.25/2.75)*b+.9375)+c:d*(7.5625*(b-=2.625/2.75)*b+.984375)+c},easeinoutbounce:function(a,b,c,d,e){return e/2>b?.5*jquery.easing.easeinbounce(a,2*b,0,d,e)+c:.5*jquery.easing.easeoutbounce(a,2*b-e,0,d,e)+.5*d+c}}); for(var i=0; i"+ data[i].title +""; } var atmslide = "
      "+ kli +"
    "; $(name).append(atmslide); var atm_banner = $(".atm_banner"); atm_banner.css("height",height); $(".atm_banner_box").css({"width":width,"margin-left":-width/2+"px"}); atm_banner.slide({maincell:".atm_banner_pic" , effect:"fold", autoplay:true, delaytime:700 , autopage:true }); }, couplet:function(data,name,width,height){ // 对联广告 errorsalert(width,height); name == "" ? name = "body" : name; nonelink(data[0].href); var atmcouplet = "关闭关闭"+ data[0].title +""+ data[1].title +""; $(name).append(atmcouplet); bindclose(".atm_couplet_left_close,.atm_couplet_right_close",".atm_couplet_left_close,.atm_couplet_right_close,.atm_couplet_left,.atm_couplet_right"); }, floatp:function(data,name,width,height){ // 浮动广告 errorsalert(width,height); nonelink(data[0].href); name == "" ? name = "body" : name; (function ( $, window, document, undefined ) { var pluginname = 'floatpic'; var defaults = { step: 1, delay: 50, islinkclosed: false, onclose: function(elem){} }; var ads = { linkurl: '#', 'z-index': '100', 'closed-icon': '', imgheight: '', imgwidth: '', title: data[0].title, img: '#', linkwindow: target, headfilter: 0.2 }; function plugin(element, options) { this.element = element; this.options = $.extend( {}, defaults, options, { width: $(window).width(), height: $(window).height(), xpos: this.getrandomnum(0, $(window).width() - $(element).innerwidth()), ypos: this.getrandomnum(0, 300), yon: this.getrandomnum(0, 1), xon: this.getrandomnum(0, 1), ypath: this.getrandomnum(0, 1), xpath: this.getrandomnum(0, 1), hoffset: $(element).innerheight(), woffset: $(element).innerwidth(), fn: function(){}, interval: 0 } ); this._defaults = defaults; this._name = pluginname; this.init(); } plugin.prototype = { init: function () { var elem = $(this.element); var defaults = this.options; var p = this; var xflag = 0; var yflag = 0; elem.css({"left": defaults.xpos + p.scrollx(), "top": defaults.ypos + p.scrolly()}); defaults.fn = function(){ defaults.width = $(window).width(); defaults.height = $(window).height(); if(xflag == p.scrollx() && yflag == p.scrolly()){ elem.css({"left": defaults.xpos + p.scrollx(), "top": defaults.ypos + p.scrolly()}); if (defaults.yon) defaults.ypos = defaults.ypos + defaults.step; else defaults.ypos = defaults.ypos - defaults.step; if (defaults.ypos <= 0) { defaults.yon = 1; defaults.ypos = 0; } if (defaults.ypos >= (defaults.height - defaults.hoffset)) { defaults.yon = 0; defaults.ypos = (defaults.height - defaults.hoffset); } if (defaults.xon) defaults.xpos = defaults.xpos + defaults.step; else defaults.xpos = defaults.xpos - defaults.step; if (defaults.xpos <= 0) { defaults.xon = 1; defaults.xpos = 0; } if (defaults.xpos >= (defaults.width - defaults.woffset)) { defaults.xon = 0; defaults.xpos = (defaults.width - defaults.woffset); } } yflag = $(window).scrolltop(); xflag = $(window).scrollleft(); }; this.run(elem, defaults); }, run: function(elem, defaults){ this.start(elem, defaults); this.adevent(elem,defaults); }, start: function(elem, defaults){ elem.find('div.floatpicclose').hide(); defaults.interval = window.setinterval(defaults.fn, defaults.delay); window.settimeout(function(){elem.show();}, defaults.delay); }, getrandomnum: function (min, max){ var range = max - min; var rand = math.random(); return(min + math.round(rand * range)); }, getpath: function(on){ return on ? 0 : 1; }, clear: function(elem, defaults){ elem.find('div.floatpicclose').show(); window.clearinterval(defaults.interval); }, close: function(elem, defaults, isclose){ //elem.unbind('hover'); elem.unbind("mouseenter mouseleave"); elem.hide(); if(isclose) defaults.onclose.call(elem); }, adevent: function(elem, defaults){ var obj = { elem: this, fn_close: function() { this.elem.close(elem, defaults, true); }, fn_clear: function() { if(this.elem.options.islinkclosed) this.elem.close(elem, defaults, false); } }; elem.find('div.floatpicclose').bind('click', jquery.proxy(obj, "fn_close")); elem.find('a').bind('click', jquery.proxy(obj, "fn_clear")); var stop = { elem: this, over: function(){ this.elem.clear(elem, defaults); }, out: function(){ this.elem.start(elem, defaults); } }; elem.bind("mouseenter", jquery.proxy(stop, "over")); elem.bind("mouseleave", jquery.proxy(stop, "out")); }, scrollx: function(){ var de = document.documentelement; return self.pagexoffset || (de && de.scrollleft) || document.body.scrollleft; }, scrolly: function(){ var de = document.documentelement; return self.pageyoffset || (de && de.scrolltop) || document.body.scrolltop; } }; $.fn.floatpic = function(options) { return this.children("div").each(function (i, elem) { if (!$.data(this, 'plugin_' + pluginname)) { $.data(this, 'plugin_' + pluginname, new plugin(this, options)); } }); }; $.floatpic = function(options){ if(options){ if(options.ad){ var addiv = $('#' + pluginname); if(addiv.length <= 0) addiv = $('
    ', { 'id': pluginname, 'class': pluginname }).appendto('body'); for(var i in options.ad){ var ad = options.ad[i]; ad = $.extend({}, ads, ad); var div = $('
    ', { 'class': 'floatimg' }); div.css("z-index", ad['z-index']); var closediv = $('
    ', { 'class': 'floatpicclose' }); closediv.appendto(div); var content = $('
    '); $('', { href: ad.linkurl, target: ad.linkwindow, title: ad.title }).append( $('', { 'src': ad.img, 'style': (ad.imgheight ? 'height:' + ad.imgheight + 'px;' : '') + (ad.imgwidth ? 'width:' + ad.imgwidth + 'px;' : '') }) ).appendto(content); content.appendto(div); div.appendto(addiv); } delete options.ad; $('#' + pluginname).floatpic(options); } } else $.error('浮动模块出错!'); }; })(jquery, window, document); $.floatpic({ delay: 10, //islinkclosed: true, ad: [{ 'img': data[0].url, 'imgheight': width, 'imgwidth': height, 'linkurl': links, 'z-index': 100 }] }); $(".floatpicclose").text("x"); }, mount:function(data,name,width,height){ // 泰山压顶 errorsalert(width,height); name == "" ? name = "body" : name; nonelink(data[0].href); var atmmount = ""; $(name).prepend(atmmount); $(".mount").css("height",height); $(".mount a").css("margin-left",-width/2); $(".mount").slidedown(1200,function(){ settimeout(function(){ $(".mount").slideup(1000); },5000); }); bindclose(".mount_close",".mount"); }, bottomcenter:function(data,name,width,height){ // 底部浮动居中广告 errorsalert(width,height); name == "" ? name = "body" : name; nonelink(data[0].href); var atmbottomcenter = "
    x"+ data[0].title+"
    "; $(name).prepend(atmbottomcenter); $(".atm_bottom_pic").css("height",height); $(".atm_bottom_pic a").css("margin-left",-width/2); bindclose(".atm_bottom_pic_close",".atm_bottom_pic_bg"); }, bottomright:function(data,name,width,height){ // 底部浮动居右广告 errorsalert(width,height); name == "" ? name = "body" : name; nonelink(data[0].href); var atmbottomright = "
    x"+ data[0].title+"
    "; $(name).prepend(atmbottomright); bindclose(".atm_bottom_pic_close",".atm_bottom_right"); }, randompic:function(data,name,width,height){ // 随机单张广告 errorsalert(width,height); name == "" ? name = "body" : name; var atmrandom, i = parseint(data.length*math.random()); nonelink(data[i].href); atmrandom = ""+ data[i].title +""; $(name).append(atmrandom); }, piclist:function(data,name,width,height){ // 图片罗列广告 errorsalert(width,height); name == "" ? name = "body" : name; var i=0, piclist=""; for(i;i"+ data[i].title +""; } $(name).append(piclist); } }