/* 幻灯片插件 jQuery Orbit Plugin 1.2.3 */ (function($) { $.fn.orbit = function(options) { //Defaults to extend options var defaults = { animation: 'fade', //幻灯片切换方式,可选 fade, horizontal-slide, vertical-slide, horizontal-push animationSpeed: 1000, //幻灯片切换动画时间,单位为毫秒 timer: true, //是否显示计时器 advanceSpeed: 4000, //幻灯片切换间隔,单位为毫秒 pauseOnHover: true, //鼠标悬停在上面是否暂停 startClockOnMouseOut: true, //点击导航后是否暂停计时器,直到鼠标移开 startClockOnMouseOutAfter: 0, //鼠标移开后多久开始计时,单位为毫秒 directionalNav: true, //是否显示左右方向导航 captions: false, //是否显示标题 captionAnimation: 'fade', //标题显示动画方式,可选 fade(淡入淡出)、slideOpen、none,需要 captions 为 true captionAnimationSpeed: 600, //标题动画时间,单位为毫秒 bullets: true, //是否显示项目导航 bulletThumbs: false, //是否显示缩略图,需要 bullets 为 true bulletThumbLocation: '', //缩略图的文件地址 afterSlideChange: function(){} //幻灯片切换后的回调函数 }; //Extend those options var options = $.extend(defaults, options); return this.each(function() { // ============== // ! SETUP // ============== //Global Variables var activeSlide = 0, numberSlides = 0, orbitWidth, orbitHeight, locked; //Initialize var orbit = $(this).addClass('orbit'), orbitWrapper = orbit.wrap('
').parent(); var orbitid = orbit.attr('id'); orbitWrapper.addClass(orbitid); orbit.add(orbitWidth).width('1px').height('1px'); //Collect all slides and set slider size of largest image var slides = orbit.children('li'); slides.each(function() { var _slide = $(this), _slideWidth = _slide.width(), _slideHeight = _slide.height(); if(_slideWidth > orbit.width()) { orbit.add(orbitWrapper).width(_slideWidth); orbitWidth = orbit.width(); } if(_slideHeight > orbit.height()) { orbit.add(orbitWrapper).height(_slideHeight); orbitHeight = orbit.height(); } numberSlides++; }); //Animation locking functions function unlock() { locked = false; } function lock() { locked = true; } //If there is only a single slide remove nav, timer and bullets if(slides.length == 1) { options.directionalNav = false; options.timer = false; options.bullets = false; } //Set initial front photo z-index and fades it in slides.eq(activeSlide) .css({"z-index" : 3}) .fadeIn(function() { //brings in all other slides IF css declares a display: none slides.css({"display":"block"}) }); // ============== // ! TIMER // ============== //Timer Execution function startClock() { if(!options.timer || options.timer == 'false') { return false; //if timer is hidden, don't need to do crazy calculations } else if(timer.is(':hidden')) { clock = setInterval(function(e){ shift("next"); }, options.advanceSpeed); //if timer is visible and working, let's do some math } else { timerRunning = true; pause.removeClass('active') clock = setInterval(function(e){ var degreeCSS = "rotate("+degrees+"deg)" degrees += 2 rotator.css({ "-webkit-transform": degreeCSS, "-moz-transform": degreeCSS, "-o-transform": degreeCSS }); if(degrees > 180) { rotator.addClass('move'); mask.addClass('move'); } if(degrees > 360) { rotator.removeClass('move'); mask.removeClass('move'); degrees = 0; shift("next"); } }, options.advanceSpeed/180); } } function stopClock() { if(!options.timer || options.timer == 'false') { return false; } else { timerRunning = false; clearInterval(clock); pause.addClass('active'); } } //Timer Setup if(options.timer) { var timerHTML = '
' orbitWrapper.append(timerHTML); var timer = orbitWrapper.children('div.timer'), timerRunning; if(timer.length != 0) { var rotator = $('div.timer span.rotator'), mask = $('div.timer span.mask'), pause = $('div.timer span.pause'), degrees = 0, clock; startClock(); timer.click(function() { if(!timerRunning) { startClock(); } else { stopClock(); } }); if(options.startClockOnMouseOut){ var outTimer; orbitWrapper.mouseleave(function() { outTimer = setTimeout(function() { if(!timerRunning){ startClock(); } }, options.startClockOnMouseOutAfter) }) orbitWrapper.mouseenter(function() { clearTimeout(outTimer); }) } } } //Pause Timer on hover if(options.pauseOnHover) { orbitWrapper.mouseenter(function() { stopClock(); }); } // ============== // ! CAPTIONS // ============== //Caption Setup if(options.captions) { var captionHTML = '
'; orbitWrapper.append(captionHTML); var caption = orbitWrapper.children('.orbit-caption'); setCaption(); } //Caption Execution function setCaption() { if(!options.captions || options.captions =="false") { return false; } else { var _captionLocation = slides.eq(activeSlide).data('caption'); //get ID from rel tag on image _captionHTML = $(_captionLocation).html(); //get HTML from the matching HTML entity //Set HTML for the caption if it exists if(_captionHTML) { caption .attr('id',_captionLocation) // Add ID caption .html(_captionHTML); // Change HTML in Caption //Animations for Caption entrances if(options.captionAnimation == 'none') { caption.show(); } if(options.captionAnimation == 'fade') { caption.fadeIn(options.captionAnimationSpeed); } if(options.captionAnimation == 'slideOpen') { caption.slideDown(options.captionAnimationSpeed); } } else { //Animations for Caption exits if(options.captionAnimation == 'none') { caption.hide(); } if(options.captionAnimation == 'fade') { caption.fadeOut(options.captionAnimationSpeed); } if(options.captionAnimation == 'slideOpen') { caption.slideUp(options.captionAnimationSpeed); } } } } // ================== // ! DIRECTIONAL NAV // ================== //DirectionalNav { rightButton --> shift("next"), leftButton --> shift("prev"); if(options.directionalNav) { if(options.directionalNav == "false") { return false; } var directionalNavHTML = '
RightLeft
'; orbitWrapper.append(directionalNavHTML); var leftBtn = orbitWrapper.children('div.slider-nav').children('span.left'), rightBtn = orbitWrapper.children('div.slider-nav').children('span.right'); leftBtn.click(function() { stopClock(); shift("prev"); }); rightBtn.click(function() { stopClock(); shift("next") }); } // ================== // ! BULLET NAV // ================== //Bullet Nav Setup if(options.bullets) { var bulletHTML = ''; orbitWrapper.append(bulletHTML); var bullets = orbitWrapper.children('ul.orbit-bullets'); for(i=0; i'+(i+1)+''); if(options.bulletThumbs) { var thumbName = slides.eq(i).data('thumb'); if(thumbName) { var liMarkup = $('
  • '+i+'
  • ') liMarkup.css({"background" : "url("+options.bulletThumbLocation+thumbName+") no-repeat"}); } } orbitWrapper.children('ul.orbit-bullets').append(liMarkup); liMarkup.data('index',i); liMarkup.click(function() { stopClock(); shift($(this).data('index')); }); } setActiveBullet(); } //Bullet Nav Execution function setActiveBullet() { if(!options.bullets) { return false; } else { bullets.children('li').removeClass('active').eq(activeSlide).addClass('active'); } } // ==================== // ! SHIFT ANIMATIONS // ==================== //Animating the shift! function shift(direction) { //remember previous activeSlide var prevActiveSlide = activeSlide, slideDirection = direction; //exit function if bullet clicked is same as the current image if(prevActiveSlide == slideDirection) { return false; } //reset Z & Unlock function resetAndUnlock() { slides .eq(prevActiveSlide) .css({"z-index" : 1}); unlock(); options.afterSlideChange.call(this); } if(slides.length == "1") { return false; } if(!locked) { lock(); //deduce the proper activeImage if(direction == "next") { activeSlide++ if(activeSlide == numberSlides) { activeSlide = 0; } } else if(direction == "prev") { activeSlide-- if(activeSlide < 0) { activeSlide = numberSlides-1; } } else { activeSlide = direction; if (prevActiveSlide < activeSlide) { slideDirection = "next"; } else if (prevActiveSlide > activeSlide) { slideDirection = "prev" } } //set to correct bullet setActiveBullet(); //set previous slide z-index to one below what new activeSlide will be slides .eq(prevActiveSlide) .css({"z-index" : 2}); //fade if(options.animation == "fade") { slides .eq(activeSlide) .css({"opacity" : 0, "z-index" : 3}) .animate({"opacity" : 1}, options.animationSpeed, resetAndUnlock); } //horizontal-slide if(options.animation == "horizontal-slide") { if(slideDirection == "next") { slides .eq(activeSlide) .css({"left": orbitWidth, "z-index" : 3}) .animate({"left" : 0}, options.animationSpeed, resetAndUnlock); } if(slideDirection == "prev") { slides .eq(activeSlide) .css({"left": -orbitWidth, "z-index" : 3}) .animate({"left" : 0}, options.animationSpeed, resetAndUnlock); } } //vertical-slide if(options.animation == "vertical-slide") { if(slideDirection == "prev") { slides .eq(activeSlide) .css({"top": orbitHeight, "z-index" : 3}) .animate({"top" : 0}, options.animationSpeed, resetAndUnlock); } if(slideDirection == "next") { slides .eq(activeSlide) .css({"top": -orbitHeight, "z-index" : 3}) .animate({"top" : 0}, options.animationSpeed, resetAndUnlock); } } //push-over if(options.animation == "horizontal-push") { if(slideDirection == "next") { slides .eq(activeSlide) .css({"left": orbitWidth, "z-index" : 3}) .animate({"left" : 0}, options.animationSpeed, resetAndUnlock); slides .eq(prevActiveSlide) .animate({"left" : -orbitWidth}, options.animationSpeed); } if(slideDirection == "prev") { slides .eq(activeSlide) .css({"left": -orbitWidth, "z-index" : 3}) .animate({"left" : 0}, options.animationSpeed, resetAndUnlock); slides .eq(prevActiveSlide) .animate({"left" : orbitWidth}, options.animationSpeed); } } setCaption(); } //lock }//orbit function });//each call }//orbit plugin call })(jQuery); /*彦磊图片(文字)平滑连续滚动插件1.0*/ (function($) { $.fn.extend({ "totalWidth": function() { var tmpWidth = 0; $(this).each(function() { tmpWidth += $(this).outerWidth(true); }); return tmpWidth; }, "totalHeight": function() { var tmpHeight = 0; $(this).each(function() { tmpHeight += $(this).outerHeight(true); }); return tmpHeight; } }); $.fn.YlMarquee = function(o) { o = $.extend({ speed: 60, step: 3, vertical: false, width: 0, height: 0, visible: 0, textMode: false }, o || {}); var wrap = $(this), ul = $("ul", wrap), li = $("li", ul), v = o.visible, step = o.step, liNum = li.size(), visibleLi = li.slice(0, v); var whiteSpace, floatStyle, displayStyle, liSize, ie7HackCss, marginStyle, paddingStyle, wrapSize, visibleLiSize, i, scrollSize, cssPro; if (o.vertical) { whiteSpace = "normal"; floatStyle = "none"; displayStyle = "block"; wrapSize = o.height; } else { whiteSpace = "nowrap"; floatStyle = "left"; displayStyle = "inline"; wrapSize = o.width; ie7HackCss = o.textMode ? "*float:none;" : ""; } wrap.css({ position: "relative", overflow: "hidden" }); ul.css({ position: "relative", "white-space": whiteSpace, overflow: "hidden", "list-style-type": "none", margin: "0", padding: "0" }); li.css({ "white-space": whiteSpace, "display": displayStyle, overflow: "hidden" }); li.attr("style", li.attr("style") + ";" + "float:" + floatStyle + ";" + ie7HackCss); liSize = o.vertical ? li.totalHeight() : li.totalWidth(); o.vertical ? ul.height(liSize) : ul.width(liSize); visibleLiSize = o.vertical ? visibleLi.totalHeight() : visibleLi.totalWidth(); if (wrapSize == 0) { wrapSize = visibleLiSize; } o.vertical ? wrap.height(wrapSize) : wrap.width(wrapSize); if (wrapSize < liSize) { ul.append(li.clone()); var newLi = $("li", ul), newLiSize = o.vertical ? newLi.totalHeight() : newLi.totalWidth(); newLi.attr("style", newLi.attr("style") + ";" + "float:" + floatStyle + ";"); o.vertical ? ul.height(newLiSize) : ul.width(newLiSize); scrollSize = o.vertical ? newLi.slice(0, liNum).totalHeight() : newLi.slice(0, liNum).totalWidth(); var MyMar = setInterval(marquee, o.speed); ul.hover(function() { clearInterval(MyMar); }, function() { MyMar = setInterval(marquee, o.speed); }); } function marquee() { if (o.vertical) { if (wrap.scrollTop() >= scrollSize) { wrap.scrollTop(wrap.scrollTop() - scrollSize + step); } else { i = wrap.scrollTop(); i += step; wrap.scrollTop(i) } } else { if (wrap.scrollLeft() >= scrollSize) { wrap.scrollLeft(wrap.scrollLeft() - scrollSize + step); } else { i = wrap.scrollLeft(); i += step; wrap.scrollLeft(i); } } }; }; })(jQuery); /*淡入淡出可自动切换的幻灯插件*/ $.fn.iFadeSlide = function(iSet){ /* * iSet可选参数说明: * iSet.field==>幻灯区域内的图片集 * iSet.ico==>按钮钩子 * iSet.high==>按钮高亮样式 * iSet.interval==>图片切换时间 * iSet.leaveTime==>不触发鼠标划入事件的最大时间值 * iSet.fadeInTime==>淡入时间 * iSet.fadeOutTime==>淡出时间 * 调用方式$(document).iFadeSlide({field:'...',ico:'...',...}) */ iSet = $.extend({high:'high',interval:5000,leaveTime:150,fadeOutTime:400,fadeInTime:400},iSet); var imgField = $(iSet.field || '.slide>a'); var icoField = $(iSet.ico || '.nb'); var curIndex = 0; var slideInterval = iSet.interval || 5000; var hoverTime = iSet.leaveTime || 150; var fadeOutTime = iSet.fadeOutTime || 400; var fadeInTime = iSet.fadeInTime || 400; var icos=null, fastHoverFun = null, autoSlideFun = null, hasIcoHighCls = null, changeFun = null,max=null;; var icoHtml = ''; icoField.append(icoHtml); //淡入淡出函数 changeFun = function(n){ imgField.filter(':visible').fadeOut(fadeOutTime, function(){ imgField.eq(n).fadeIn(fadeInTime) icos.eq(n).addClass(iSet.high).siblings().removeClass(iSet.high); }); } icos = icoField.find('ul>li'); //为第一个按键初始化高亮 icos.first().addClass(iSet.high); //按钮鼠标划入划出事件 icos.hover(function(){ clearInterval(autoSlideFun); curIndex = icos.index(this); hasIcoHighName = $(this).hasClass(iSet.high); //setTimeout避免用户快速(无意识性划过)划过时触发事件 fastHoverFun = setTimeout(function(){ //鼠标划入当前图片按钮时不闪烁 if (!hasIcoHighName) { changeFun(curIndex); } }, hoverTime); }, function(){ clearTimeout(fastHoverFun); //自动切换 autoSlideFun = setInterval(function(){ curIndex++; changeFun(curIndex); if (curIndex ==max ) { changeFun(0); curIndex = 0; } }, slideInterval) }).eq(0).trigger('mouseleave'); //当鼠标划入图片区域时停止切换 imgField.hover(function(){ curIndex = imgField.index(this); clearInterval(autoSlideFun); }, function(){ icos.eq(curIndex).trigger('mouseleave'); }); } $(function(){ $(document).iFadeSlide({ field: $('#slide a'), ico:$('.nb'), high: 'hnb', interval: 5000 }); }); /* 间歇停顿滚动 http://www.rjboy.cn By sean during 2010.07 - 2010.12; Demo: $(".productshow").Xslider({//.productshow是要移动对象的外框,页面上所有绑定了类.productshow的对象都会有切换效果; unitdisplayed:3,//可视的单位个数 必需项; numtoMove:1,//要移动的单位个数 必需项; viewedSize:120,//可视宽度或高度 不传入则查找要移动对象外层的宽或高度; scrollobj:".vscrollobj",//要移动的对象 不传入则查找productshow下的ul; unitlen:20,//移动的单位宽或高度 不传入则查找li的尺寸; scrollobjSize:$(".vscrollobj").height(),//移动最长宽或高(要移动对象的宽度或高度) 不传入则由li个数乘以unitlen计算; dir:"V",//水平移动还是垂直移动 默认H为水平移动,传入V则表示垂直移动(注意是大写字母); loop:"cycle",//循环滚动 不传入则不循环滚动; speed:500, //滚动速度 默认为500; autoscroll:2000//自动移动间隔时间(毫秒) 不传入则不会自动移动; }); */ (function($){ $.extend($.easing,{ easeInSine: function (x, t, b, c, d) { return -c * Math.cos(t/d * (Math.PI/2)) + c + b; } }); $.fn.Xslider=function(settings){ settings=$.extend({},$.fn.Xslider.sn.defaults,settings); this.each(function(){ var scrollobj=settings.scrollobj ? $(this).find(settings.scrollobj) : $(this).find("div.box"), viewedSize=settings.viewedSize || (settings.dir=="H" ? scrollobj.parent().width() : scrollobj.parent().height()),//length of the wrapper visible; scrollunits=scrollobj.find("ul"),//units to move; unitlen=settings.unitlen || (settings.dir=="H" ? scrollunits.eq(0).outerWidth() : scrollunits.eq(0).outerHeight()), unitdisplayed=settings.unitdisplayed,//units num displayed; numtoMove=settings.numtoMove > unitdisplayed ? unitdisplayed : settings.numtoMove, scrollobjSize=settings.scrollobjSize || scrollunits.length*unitlen,//length of the scrollobj; offset=0,//max width to move; offsetnow=0,//scrollobj now offset; movelength=unitlen*numtoMove, pos=settings.dir=="H" ? "left" : "top", moving=false,//moving now?; btnright=$(this).find("a.aright"), btnleft=$(this).find("a.aleft"); btnright.unbind("click"); btnleft.unbind("click"); settings.dir=="H" ? scrollobj.css("left","0px") : scrollobj.css("top","0px"); if(scrollobjSize>viewedSize){ if(settings.loop=="cycle"){ btnleft.removeClass("agrayleft"); if(scrollunits.length<2*numtoMove+unitdisplayed-numtoMove){ scrollobj.find("ul").clone().appendTo(scrollobj); } }else{ btnleft.addClass("agrayleft"); offset=scrollobjSize-viewedSize; } btnright.removeClass("agrayright"); }else{ btnleft.addClass("agrayleft"); btnright.addClass("agrayright"); } btnleft.click(function(){ if($(this).is("[class*='agrayleft']")){return false;} if(!moving){ moving=true; if(settings.loop=="cycle"){ scrollobj.find("ul:gt("+(scrollunits.length-numtoMove-1)+")").prependTo(scrollobj); scrollobj.css(pos,"-"+movelength+"px"); $.fn.Xslider.sn.animate(scrollobj,0,settings.dir,settings.speed,function(){moving=false;}); }else{ offsetnow-=movelength; if(offsetnow>unitlen*unitdisplayed-viewedSize){ $.fn.Xslider.sn.animate(scrollobj,-offsetnow,settings.dir,settings.speed,function(){moving=false;}); }else{ $.fn.Xslider.sn.animate(scrollobj,0,settings.dir,settings.speed,function(){moving=false;}); offsetnow=0; $(this).addClass("agrayleft"); } btnright.removeClass("agrayright"); } } return false; }); btnright.click(function(){ if($(this).is("[class*='agrayright']")){return false;} if(!moving){ moving=true; if(settings.loop=="cycle"){ var callback=function(){ scrollobj.find("ul:lt("+numtoMove+")").appendTo(scrollobj); scrollobj.css(pos,"0px"); moving=false; } $.fn.Xslider.sn.animate(scrollobj,-movelength,settings.dir,settings.speed,callback); }else{ offsetnow+=movelength; if(offsetnowparentHeight && objWidth>parentWidth){//当图片宽高都大于父容器宽高 if(objHeight>objWidth) {//如果图片高大于宽,以宽为基础高作适应 $this.width(parentWidth); var objHeight2=parentWidth*ratio;//重新获取宽高 $this.height(objHeight2); $(this).css("margin-top",(parentHeight-objHeight2)/2); } else {//如果图片宽大于高,以高为基础宽作适应 $this.height(parentHeight); var objWidth2=parentHeight/ratio; $this.width(objWidth2); $(this).css("margin-left",(parentWidth-objWidth2)/2); } } else{//当图片宽高小于父容器宽高 if(objWidth>parentWidth){//当图片宽大于容器宽,小于时利用css text-align属性居中 $(this).css("margin-left",(parentWidth-objWidth)/2); } $(this).css("margin-top",(parentHeight-objHeight)/2); } }) } /*调用 $(window).load(function() { imgfit($(".imgfit")); }); */ /*tabs选项卡*/ function wtabs(trigger,content,cur,events){ var events2; //事件参数 if (events) { events2 = events; } else { events2 = "mouseover"; }; var cur2; //默认选中序号参数 if (cur) { cur2 = cur; } else { cur2 = 0; }; trigger.removeClass("selected"); trigger.eq(cur2).addClass("selected"); //触发元素设置选中样式 content.hide(); content.eq(cur2).show(); //内容选中显示 trigger.on("mouseover",function(){ trigger.removeClass("selected"); $(this).addClass("selected"); content.hide(); var n=$(this).index(); content.eq(n).show(); }); } /*调用 $(document).ready(function(){ // wtabs($(".tabs_t a"),$(".tabs_c>div"),0,"click"); wtabs($(".tabs_t a"),$(".tabs_c>div")); }); */ function qtabs(obj,cur,events){ $("[id^='qtabs_']").each(function(){ var trigger = $(this).children(); var cid = $(this).attr("id").substring(6); var content = $("#"+cid).children(); trigger.removeClass("selected"); trigger.eq(0).addClass("selected"); //触发元素设置选中样式 content.hide(); content.eq(0).show(); //内容选中显示 trigger.on("mouseover",function(){ trigger.removeClass("selected"); $(this).addClass("selected"); content.hide(); var n=$(this).index(); content.eq(n).show(); }); }) } /*调用 $(document).ready(function(){ qtabs(); }); 应用示例
    触发元素集合
    内容元素集合
    */ /*跟随页面浮动层(固定) 可以让指定的层浮动到网页上的任何位置,当滚动条滚动时它会保持在当前位置不变,不会产生闪动 */ jQuery.fn.floatdiv=function(location,closer){ //判断浏览器版本 var isIE6=false; var Sys = {}; var ua = navigator.userAgent.toLowerCase(); var s; (s = ua.match(/msie ([\d.]+)/)) ? Sys.ie = s[1] : 0; if(Sys.ie && Sys.ie=="6.0"){ isIE6=true; } var windowWidth,windowHeight;//窗口的高和宽 //取得窗口的高和宽 if (self.innerHeight) { windowWidth=self.innerWidth; windowHeight=self.innerHeight; }else if (document.documentElement&&document.documentElement.clientHeight) { windowWidth=document.documentElement.clientWidth; windowHeight=document.documentElement.clientHeight; } else if (document.body) { windowWidth=document.body.clientWidth; windowHeight=document.body.clientHeight; } return this.each(function(){ var loc;//层的绝对定位位置 var wrap=$("
    "); //构建一个容器 if(closer){ //关闭动作 var closedom = $("×"); closedom.appendTo(wrap); closedom.click( function () { wrap.hide(); return false; }); }; var top=-1; if(location==undefined || location.constructor == String){ switch(location){ case("rightbottom")://右下角 loc={right:"0px",bottom:"0px"}; break; case("leftbottom")://左下角 loc={left:"0px",bottom:"0px"}; break; case("lefttop")://左上角 loc={left:"0px",top:"0px"}; top=0; break; case("righttop")://右上角 loc={right:"0px",top:"0px"}; top=0; break; case("middletop")://居中置顶 loc={left:windowWidth/2-$(this).width()/2+"px",top:"0px"}; top=0; break; case("middlebottom")://居中置底 loc={left:windowWidth/2-$(this).width()/2+"px",bottom:"0px"}; break; case("leftmiddle")://左边居中 loc={left:"0px",top:windowHeight/2-$(this).height()/2+"px"}; top=windowHeight/2-$(this).height()/2; break; case("rightmiddle")://右边居中 loc={right:"0px",top:windowHeight/2-$(this).height()/2+"px"}; top=windowHeight/2-$(this).height()/2; break; case("middle")://居中 var l=0;//居左 var t=0;//居上 l=windowWidth/2-$(this).width()/2; t=windowHeight/2-$(this).height()/2; top=t; loc={left:l+"px",top:t+"px"}; break; default://默认为右下角 location="rightbottom"; loc={right:"0px",bottom:"0px"}; break; } }else{ loc=location; //alert(loc.bottom); var str=loc.top; //09-11-5修改:加上top为空值时的判断 if (typeof(str)!= 'undefined'){ str=str.replace("px",""); top=str; } } /*fied ie6 css hack*/ if(isIE6){ if (top>=0) { wrap=$("
    "); }else{ wrap=$("
    "); } } $("#wbody").append(wrap); wrap.css(loc).css({position:"fixed","z-index":"9000"}); if (isIE6) { wrap.css("position","absolute"); //没有加这个的话,ie6使用表达式时就会发现跳动现象 //至于为什么要加这个,还有为什么要加nothing.txt这个,偶也不知道,希望知道的同学可以告诉我 $("body").css("background-attachment","fixed").css("background-image","url(n1othing.txt)"); } //将要固定的层添加到固定层里 $(this).appendTo(wrap); }); }; /*调用: 1 无参数调用:默认浮动在右下角 $("#id").floatdiv(); 2 内置固定位置浮动 //右下角 $("#id").floatdiv("rightbottom"); rightbottom(右下角)、leftbottom(左下角)、righttop(右上角)、lefttop(左上角)、middletop(居中置顶)、middlebottom(居中置底)、leftmiddle(左侧居中)、rightmiddle(右侧居中)、middle(正中) 3 自定义位置浮动 $("#id").floatdiv({left:"10px",top:"10px"}); $(document).ready(function(){ $("#float").floatdiv({right:"10px",top:"100px"}); $("#float2").floatdiv({left:"10px",top:"100px"}); }); */ /*跟随页面浮动层(缓动)*/ jQuery.fn.scrollFollow=function(style1,style2,closer){ return this.each(function(){ var dom = $(this); var wrap=$("
    "); //构建一个内容器 wrap.css(style2); //赋予样式给容器 dom.css({ position: "absolute", height: "100%", top: "0px", "z-index": "9000"}); dom.css(style1); //赋予样式给容器 dom.wrapInner(wrap); //插入对象到容器 if(closer){ //关闭动作 var closedom = $("×"); closedom.appendTo(dom); closedom.click( function () { dom.hide(); return false; }); }; $(window).scroll(function () { //鼠标滚动时计算改变top值 var offsetTop = $(window).scrollTop() + "px"; dom.animate({ top: offsetTop }, { duration: 600, queue: false }); }); }); } /*调用 $(document).ready(function(){ $("#float100").scrollFollow({right:"20px",bottom:"20px"}); }); */ /*满屏弹性漂浮层*/ jQuery.fn.floatAd=function(location,closer){ return this.each(function(){ var wrap=$("
    "); //构建一个容器 wrap.css({width:$(this).width(),height:$(this).height()}); //赋予对象的宽、高给容器 wrap.css(location); //赋予定位属性给容器 if(closer){ //关闭动作 var closedom = $("×"); closedom.appendTo(wrap); closedom.click( function () { wrap.hide(); return false; }); }; $(this).appendTo(wrap); //插入对象到容器 $("#wbody").append(wrap); //插入容器到页面最后 var x = wrap.offset().left; y = wrap.offset().top var xin = true; yin = true var step = 1 var float = function(){ var L = T = 0; var OW = wrap.width();//当前广告的宽 var OH = wrap.height();//高 var DW = $(window).width(); //浏览器窗口的宽 var DH = $(window).height(); x = x + step *( xin ? 1 : -1 ); if (x < L) { xin = true; x = L } if (x > DW-OW-1){//-1为了ie xin = false; x = DW-OW-1 } y = y + step * ( yin ? 1 : -1 ); if (y > DH-OH-1) { yin = false; y = DH-OH-1 ; } if (y < T) { yin = true; y = T } var left = x; var top = y; wrap.css({'top':top,'left':left}); } var itl = setInterval(float,10); wrap.mouseover(function(){clearInterval(itl)}); wrap.mouseout(function(){itl=setInterval(float,10)} ) }); } /*调用 $(function(){ $("#float200").floatAd({top:"20px",left:"20px"}); }) */ /** * 列表翻页插件jQuery jPages v0.7 * http://luis-almeida.github.com/jPages */ ;(function($, window, document, undefined) { var name = "jPages", instance = null, defaults = { containerID: "", //列表元素 first: false, //"首页" previous: "上一页", next: "下一页", last: false, //"尾页" links: "numeric", //链接类型:数字或 blank || title startPage: 1, //默认显示第1页 perPage: 20, //每页显示条数 midRange: 5, startRange: 1, endRange: 1, keyBrowse: false, scrollBrowse: false, pause: 0, clickStop: false, delay: 50, //延迟载入速度 direction: "forward", // backwards || auto || random || animation: "", // http://daneden.me/animate/ - any entrance animations fallback: 400, //淡入效果速度 minHeight: true, callback: undefined // function( pages, items ) { } }; function Plugin(element, options) { this.options = $.extend({}, defaults, options); this._container = $("#" + this.options.containerID); if (!this._container.length) return; this.jQwindow = $(window); this.jQdocument = $(document); this._holder = $(element); this._nav = {}; this._first = $(this.options.first); this._previous = $(this.options.previous); this._next = $(this.options.next); this._last = $(this.options.last); /* only visible items! */ //this._items = this._container.children(":visible"); this._items = this._container.children(); this._itemsShowing = $([]); this._itemsHiding = $([]); this._numPages = Math.ceil(this._items.length / this.options.perPage); this._currentPageNum = this.options.startPage; this._clicked = false; this._cssAnimSupport = this.getCSSAnimationSupport(); this.init(); } Plugin.prototype = { constructor : Plugin, getCSSAnimationSupport : function() { var animation = false, animationstring = 'animation', keyframeprefix = '', domPrefixes = 'Webkit Moz O ms Khtml'.split(' '), pfx = '', elm = this._container.get(0); if (elm.style.animationName) animation = true; if (animation === false) { for (var i = 0; i < domPrefixes.length; i++) { if (elm.style[domPrefixes[i] + 'AnimationName'] !== undefined) { pfx = domPrefixes[i]; animationstring = pfx + 'Animation'; keyframeprefix = '-' + pfx.toLowerCase() + '-'; animation = true; break; } } } return animation; }, init : function() { this.setStyles(); this.setNav(); this.paginate(this._currentPageNum); this.setMinHeight(); }, setStyles : function() { var requiredStyles = ""; $(requiredStyles).appendTo("head"); if (this._cssAnimSupport && this.options.animation.length) this._items.addClass("animated jp-hidden"); else this._items.hide(); }, setNav : function() { var navhtml = this.writeNav(); this._holder.each(this.bind(function(index, element) { var holder = $(element); holder.html(navhtml); this.cacheNavElements(holder, index); this.bindNavHandlers(index); this.disableNavSelection(element); }, this)); if (this.options.keyBrowse) this.bindNavKeyBrowse(); if (this.options.scrollBrowse) this.bindNavScrollBrowse(); }, writeNav : function() { var i = 1, navhtml; navhtml = this.writeBtn("first") + this.writeBtn("previous"); for (; i <= this._numPages; i++) { if (i === 1 && this.options.startRange === 0) navhtml += "..."; if (i > this.options.startRange && i <= this._numPages - this.options.endRange) navhtml += ""; switch (this.options.links) { case "numeric": navhtml += i; break; case "blank": break; case "title": var title = this._items.eq(i - 1).attr("data-title"); navhtml += title !== undefined ? title : ""; break; } navhtml += ""; if (i === this.options.startRange || i === this._numPages - this.options.endRange) navhtml += "..."; } navhtml += this.writeBtn("next") + this.writeBtn("last") + "
    "; return navhtml; }, writeBtn : function(which) { return this.options[which] !== false && !$(this["_" + which]).length ? "" + this.options[which] + "" : ""; }, cacheNavElements : function(holder, index) { this._nav[index] = {}; this._nav[index].holder = holder; this._nav[index].first = this._first.length ? this._first : this._nav[index].holder.find("a.jp-first"); this._nav[index].previous = this._previous.length ? this._previous : this._nav[index].holder.find("a.jp-previous"); this._nav[index].next = this._next.length ? this._next : this._nav[index].holder.find("a.jp-next"); this._nav[index].last = this._last.length ? this._last : this._nav[index].holder.find("a.jp-last"); this._nav[index].fstBreak = this._nav[index].holder.find("span:first"); this._nav[index].lstBreak = this._nav[index].holder.find("span:last"); this._nav[index].pages = this._nav[index].holder.find("a").not(".jp-first, .jp-previous, .jp-next, .jp-last"); this._nav[index].permPages = this._nav[index].pages.slice(0, this.options.startRange) .add(this._nav[index].pages.slice(this._numPages - this.options.endRange, this._numPages)); this._nav[index].pagesShowing = $([]); this._nav[index].currentPage = $([]); }, bindNavHandlers : function(index) { var nav = this._nav[index]; // default nav nav.holder.bind("click.jPages", this.bind(function(evt) { var newPage = this.getNewPage(nav, $(evt.target)); if (this.validNewPage(newPage)) { this._clicked = true; this.paginate(newPage); } evt.preventDefault(); }, this)); // custom first if (this._first.length) { this._first.bind("click.jPages", this.bind(function() { if (this.validNewPage(1)) { this._clicked = true; this.paginate(1); } }, this)); } // custom previous if (this._previous.length) { this._previous.bind("click.jPages", this.bind(function() { var newPage = this._currentPageNum - 1; if (this.validNewPage(newPage)) { this._clicked = true; this.paginate(newPage); } }, this)); } // custom next if (this._next.length) { this._next.bind("click.jPages", this.bind(function() { var newPage = this._currentPageNum + 1; if (this.validNewPage(newPage)) { this._clicked = true; this.paginate(newPage); } }, this)); } // custom last if (this._last.length) { this._last.bind("click.jPages", this.bind(function() { if (this.validNewPage(this._numPages)) { this._clicked = true; this.paginate(this._numPages); } }, this)); } }, disableNavSelection : function(element) { if (typeof element.onselectstart != "undefined") element.onselectstart = function() { return false; }; else if (typeof element.style.MozUserSelect != "undefined") element.style.MozUserSelect = "none"; else element.onmousedown = function() { return false; }; }, bindNavKeyBrowse : function() { this.jQdocument.bind("keydown.jPages", this.bind(function(evt) { var target = evt.target.nodeName.toLowerCase(); if (this.elemScrolledIntoView() && target !== "input" && target != "textarea") { var newPage = this._currentPageNum; if (evt.which == 37) newPage = this._currentPageNum - 1; if (evt.which == 39) newPage = this._currentPageNum + 1; if (this.validNewPage(newPage)) { this._clicked = true; this.paginate(newPage); } } }, this)); }, elemScrolledIntoView : function() { var docViewTop, docViewBottom, elemTop, elemBottom; docViewTop = this.jQwindow.scrollTop(); docViewBottom = docViewTop + this.jQwindow.height(); elemTop = this._container.offset().top; elemBottom = elemTop + this._container.height(); return ((elemBottom >= docViewTop) && (elemTop <= docViewBottom)); // comment above and uncomment below if you want keyBrowse to happen // only when container is completely visible in the page /*return ((elemBottom >= docViewTop) && (elemTop <= docViewBottom) && (elemBottom <= docViewBottom) && (elemTop >= docViewTop) );*/ }, bindNavScrollBrowse : function() { this._container.bind("mousewheel.jPages DOMMouseScroll.jPages", this.bind(function(evt) { var newPage = (evt.originalEvent.wheelDelta || -evt.originalEvent.detail) > 0 ? (this._currentPageNum - 1) : (this._currentPageNum + 1); if (this.validNewPage(newPage)) { this._clicked = true; this.paginate(newPage); } evt.preventDefault(); return false; }, this)); }, getNewPage : function(nav, target) { if (target.is(nav.currentPage)) return this._currentPageNum; if (target.is(nav.pages)) return nav.pages.index(target) + 1; if (target.is(nav.first)) return 1; if (target.is(nav.last)) return this._numPages; if (target.is(nav.previous)) return nav.pages.index(nav.currentPage); if (target.is(nav.next)) return nav.pages.index(nav.currentPage) + 2; }, validNewPage : function(newPage) { return newPage !== this._currentPageNum && newPage > 0 && newPage <= this._numPages; }, paginate : function(page) { var itemRange, pageInterval; itemRange = this.updateItems(page); pageInterval = this.updatePages(page); this._currentPageNum = page; if ($.isFunction(this.options.callback)) this.callback(page, itemRange, pageInterval); this.updatePause(); }, updateItems : function(page) { var range = this.getItemRange(page); this._itemsHiding = this._itemsShowing; this._itemsShowing = this._items.slice(range.start, range.end); if (this._cssAnimSupport && this.options.animation.length) this.cssAnimations(page); else this.jQAnimations(page); return range; }, getItemRange : function(page) { var range = {}; range.start = (page - 1) * this.options.perPage; range.end = range.start + this.options.perPage; if (range.end > this._items.length) range.end = this._items.length; return range; }, cssAnimations : function(page) { clearInterval(this._delay); this._itemsHiding .removeClass(this.options.animation + " jp-invisible") .addClass("jp-hidden"); this._itemsShowing .removeClass("jp-hidden") .addClass("jp-invisible"); this._itemsOriented = this.getDirectedItems(page); this._index = 0; this._delay = setInterval(this.bind(function() { if (this._index === this._itemsOriented.length) clearInterval(this._delay); else { this._itemsOriented .eq(this._index) .removeClass("jp-invisible") .addClass(this.options.animation); } this._index = this._index + 1; }, this), this.options.delay); }, jQAnimations : function(page) { clearInterval(this._delay); this._itemsHiding.addClass("jp-hidden"); this._itemsShowing.fadeTo(0, 0).removeClass("jp-hidden"); this._itemsOriented = this.getDirectedItems(page); this._index = 0; this._delay = setInterval(this.bind(function() { if (this._index === this._itemsOriented.length) clearInterval(this._delay); else { this._itemsOriented .eq(this._index) .fadeTo(this.options.fallback, 1); } this._index = this._index + 1; }, this), this.options.delay); }, getDirectedItems : function(page) { var itemsToShow; switch (this.options.direction) { case "backwards": itemsToShow = $(this._itemsShowing.get().reverse()); break; case "random": itemsToShow = $(this._itemsShowing.get().sort(function() { return (Math.round(Math.random()) - 0.5); })); break; case "auto": itemsToShow = page >= this._currentPageNum ? this._itemsShowing : $(this._itemsShowing.get().reverse()); break; default: itemsToShow = this._itemsShowing; } return itemsToShow; }, updatePages : function(page) { var interval, index, nav; interval = this.getInterval(page); for (index in this._nav) { if (this._nav.hasOwnProperty(index)) { nav = this._nav[index]; this.updateBtns(nav, page); this.updateCurrentPage(nav, page); this.updatePagesShowing(nav, interval); this.updateBreaks(nav, interval); } } return interval; }, getInterval : function(page) { var neHalf, upperLimit, start, end; neHalf = Math.ceil(this.options.midRange / 2); upperLimit = this._numPages - this.options.midRange; start = page > neHalf ? Math.max(Math.min(page - neHalf, upperLimit), 0) : 0; end = page > neHalf ? Math.min(page + neHalf - (this.options.midRange % 2 > 0 ? 1 : 0), this._numPages) : Math.min(this.options.midRange, this._numPages); return {start: start,end: end}; }, updateBtns : function(nav, page) { if (page === 1) { nav.first.addClass("jp-disabled"); nav.previous.addClass("jp-disabled"); } if (page === this._numPages) { nav.next.addClass("jp-disabled"); nav.last.addClass("jp-disabled"); } if (this._currentPageNum === 1 && page > 1) { nav.first.removeClass("jp-disabled"); nav.previous.removeClass("jp-disabled"); } if (this._currentPageNum === this._numPages && page < this._numPages) { nav.next.removeClass("jp-disabled"); nav.last.removeClass("jp-disabled"); } }, updateCurrentPage : function(nav, page) { nav.currentPage.removeClass("jp-current"); nav.currentPage = nav.pages.eq(page - 1).addClass("jp-current"); }, updatePagesShowing : function(nav, interval) { var newRange = nav.pages.slice(interval.start, interval.end).not(nav.permPages); nav.pagesShowing.not(newRange).addClass("jp-hidden"); newRange.not(nav.pagesShowing).removeClass("jp-hidden"); nav.pagesShowing = newRange; }, updateBreaks : function(nav, interval) { if ( interval.start > this.options.startRange || (this.options.startRange === 0 && interval.start > 0) ) nav.fstBreak.removeClass("jp-hidden"); else nav.fstBreak.addClass("jp-hidden"); if (interval.end < this._numPages - this.options.endRange) nav.lstBreak.removeClass("jp-hidden"); else nav.lstBreak.addClass("jp-hidden"); }, callback : function(page, itemRange, pageInterval) { var pages = { current: page, interval: pageInterval, count: this._numPages }, items = { showing: this._itemsShowing, oncoming: this._items.slice(itemRange.start + this.options.perPage, itemRange.end + this.options.perPage), range: itemRange, count: this._items.length }; pages.interval.start = pages.interval.start + 1; items.range.start = items.range.start + 1; this.options.callback(pages, items); }, updatePause : function() { if (this.options.pause && this._numPages > 1) { clearTimeout(this._pause); if (this.options.clickStop && this._clicked) return; else { this._pause = setTimeout(this.bind(function() { this.paginate(this._currentPageNum !== this._numPages ? this._currentPageNum + 1 : 1); }, this), this.options.pause); } } }, setMinHeight : function() { if (this.options.minHeight && !this._container.is("table, tbody")) { setTimeout(this.bind(function() { this._container.css({ "min-height": this._container.css("height") }); }, this), 1000); } }, bind : function(fn, me) { return function() { return fn.apply(me, arguments); }; }, destroy : function() { this.jQdocument.unbind("keydown.jPages"); this._container.unbind("mousewheel.jPages DOMMouseScroll.jPages"); if (this.options.minHeight) this._container.css("min-height", ""); if (this._cssAnimSupport && this.options.animation.length) this._items.removeClass("animated jp-hidden jp-invisible " + this.options.animation); else this._items.removeClass("jp-hidden").fadeTo(0, 1); this._holder.unbind("click.jPages").empty(); } }; $.fn[name] = function(arg) { var type = $.type(arg); if (type === "object") { if (this.length && !$.data(this, name)) { instance = new Plugin(this, arg); this.each(function() { $.data(this, name, instance); }); } return this; } if (type === "string" && arg === "destroy") { instance.destroy(); this.each(function() { $.removeData(this, name); }); return this; } if (type === 'number' && arg % 1 === 0) { if (instance.validNewPage(arg)) instance.paginate(arg); return this; } return this; }; })(jQuery, window, document); /* 调用 $(function() { $("div.yema").jPages({ containerID: "fanye" }); if ($("#fanye").find("li").size() < 20) { $("div.yema").hide(); } }); */ /*! * jquery-powerFloat.js * jQuery 万能下拉浮动层插件 * http://www.zhangxinxu.com/wordpress/?p=1328 */ (function($) { $.fn.powerFloat = function(options) { return $(this).each(function() { var s = $.extend({}, defaults, options || {}); var init = function(pms, trigger) { if (o.target && o.target.css("display") !== "none") { o.targetHide(); } o.s = pms; o.trigger = trigger; }, hoverTimer; switch (s.eventType) { case "hover": { $(this).hover(function() { if (o.timerHold) { o.flagDisplay = true; } var numShowDelay = parseInt(s.showDelay, 10); init(s, $(this)); //鼠标hover延时 if (numShowDelay) { if (hoverTimer) { clearTimeout(hoverTimer); } hoverTimer = setTimeout(function() { o.targetGet.call(o); }, numShowDelay); } else { o.targetGet(); } }, function() { if (hoverTimer) { clearTimeout(hoverTimer); } if (o.timerHold) { clearTimeout(o.timerHold); } o.flagDisplay = false; o.targetHold(); }); if (s.hoverFollow) { //鼠标跟随 $(this).mousemove(function(e) { o.cacheData.left = e.pageX; o.cacheData.top = e.pageY; o.targetGet.call(o); return false; }); } break; } case "click": { $(this).click(function(e) { if (o.display && o.trigger && e.target === o.trigger.get(0)) { o.flagDisplay = false; o.displayDetect(); } else { init(s, $(this)); o.targetGet(); if (!$(document).data("mouseupBind")) { $(document).bind("mouseup", function(e) { var flag = false; if (o.trigger) { var idTarget = o.target.attr("id"); if (!idTarget) { idTarget = "R_" + Math.random(); o.target.attr("id", idTarget); } $(e.target).parents().each(function() { if ($(this).attr("id") === idTarget) { flag = true; } }); if (s.eventType === "click" && o.display && e.target != o.trigger.get(0) && !flag) { o.flagDisplay = false; o.displayDetect(); } } return false; }).data("mouseupBind", true); } } }); break; } case "focus": { $(this).focus(function() { var self = $(this); setTimeout(function() { init(s, self); o.targetGet(); }, 200); }).blur(function() { o.flagDisplay = false; setTimeout(function() { o.displayDetect(); }, 190); }); break; } default: { init(s, $(this)); o.targetGet(); // 放置页面点击后显示的浮动内容隐掉 $(document).unbind("mouseup").data("mouseupBind", false); } } }); }; var o = { targetGet: function() { //一切显示的触发来源 if (!this.trigger) { return this; } var attr = this.trigger.attr(this.s.targetAttr), target = typeof this.s.target == "function"? this.s.target.call(this.trigger): this.s.target; switch (this.s.targetMode) { case "common": { if (target) { var type = typeof(target); if (type === "object") { if (target.size()) { o.target = target.eq(0); } } else if (type === "string") { if ($(target).size()) { o.target = $(target).eq(0); } } } else { if (attr && $("#" + attr).size()) { o.target = $("#" + attr); } } if (o.target) { o.targetShow(); } else { return this; } break; } case "ajax": { //ajax元素,如图片,页面地址 var url = target || attr; this.targetProtect = false; if (!url) { return; } if (!o.cacheData[url]) { o.loading(); } //优先认定为图片加载 var tempImage = new Image(); tempImage.onload = function() { var w = tempImage.width, h = tempImage.height; var winw = $(window).width(), winh = $(window).height(); var imgScale = w / h, winScale = winw / winh; if (imgScale > winScale) { //图片的宽高比大于显示屏幕 if (w > winw / 2) { w = winw / 2; h = w / imgScale; } } else { //图片高度较高 if (h > winh / 2) { h = winh / 2; w = h * imgScale; } } var imgHtml = ''; o.cacheData[url] = true; o.target = $(imgHtml); o.targetShow(); }; tempImage.onerror = function() { //如果图片加载失败,两种可能,一是100%图片,则提示;否则作为页面加载 if (/(\.jpg|\.png|\.gif|\.bmp|\.jpeg)$/i.test(url)) { o.target = $('
    图片加载失败。
    '); o.targetShow(); } else { $.ajax({ url: url, success: function(data) { if (typeof(data) === "string") { o.cacheData[url] = true; o.target = $('
    ' + data + '
    '); o.targetShow(); } }, error: function() { o.target = $('
    数据没有加载成功。
    '); o.targetShow(); } }); } }; tempImage.src = url; break; } case "list": { //下拉列表 var targetHtml = ''; o.target = $(targetHtml); this.targetProtect = false; o.targetShow(); break; } case "remind": { //内容均是字符串 var strRemind = target || attr; this.targetProtect = false; if (typeof(strRemind) === "string") { o.target = $('' + strRemind + ''); o.targetShow(); } break; } default: { var objOther = target || attr, type = typeof(objOther); if (objOther) { if (type === "string") { //选择器 if (/^.[^:#\[\.,]*$/.test(objOther)) { if ($(objOther).size()) { o.target = $(objOther).eq(0); this.targetProtect = true; } else if ($("#" + objOther).size()) { o.target = $("#" + objOther).eq(0); this.targetProtect = true; } else { o.target = $('
    ' + objOther + '
    '); this.targetProtect = false; } } else { o.target = $('
    ' + objOther + '
    '); this.targetProtect = false; } o.targetShow(); } else if (type === "object") { if (!$.isArray(objOther) && objOther.size()) { o.target = objOther.eq(0); this.targetProtect = true; o.targetShow(); } } } } } return this; }, container: function() { //容器(如果有)重装target var cont = this.s.container, mode = this.s.targetMode || "mode"; if (mode === "ajax" || mode === "remind") { //显示三角 this.s.sharpAngle = true; } else { this.s.sharpAngle = false; } //是否反向 if (this.s.reverseSharp) { this.s.sharpAngle = !this.s.sharpAngle; } if (mode !== "common") { //common模式无新容器装载 if (cont === null) { cont = "plugin"; } if ( cont === "plugin" ) { if (!$("#floatBox_" + mode).size()) { $('
    ').appendTo($("body")).hide(); } cont = $("#floatBox_" + mode); } if (cont && typeof(cont) !== "string" && cont.size()) { if (this.targetProtect) { o.target.show().css("position", "static"); } o.target = cont.empty().append(o.target); } } return this; }, setWidth: function() { var w = this.s.width; if (w === "auto") { if (this.target.get(0).style.width) { this.target.css("width", "auto"); } } else if (w === "inherit") { this.target.width(this.trigger.width()); } else { this.target.css("width", w); } return this; }, position: function() { if (!this.trigger || !this.target) { return this; } var pos, tri_h = 0, tri_w = 0, cor_w = 0, cor_h = 0, tri_l, tri_t, tar_l, tar_t, cor_l, cor_t, tar_h = this.target.data("height"), tar_w = this.target.data("width"), st = $(window).scrollTop(), off_x = parseInt(this.s.offsets.x, 10) || 0, off_y = parseInt(this.s.offsets.y, 10) || 0, mousePos = this.cacheData; //缓存目标对象高度,宽度,提高鼠标跟随时显示性能,元素隐藏时缓存清除 if (!tar_h) { tar_h = this.target.outerHeight(); if (this.s.hoverFollow) { this.target.data("height", tar_h); } } if (!tar_w) { tar_w = this.target.outerWidth(); if (this.s.hoverFollow) { this.target.data("width", tar_w); } } pos = this.trigger.offset(); tri_h = this.trigger.outerHeight(); tri_w = this.trigger.outerWidth(); tri_l = pos.left; tri_t = pos.top; var funMouseL = function() { if (tri_l < 0) { tri_l = 0; } else if (tri_l + tri_h > $(window).width()) { tri_l = $(window).width() - tri_w; } }, funMouseT = function() { if (tri_t < 0) { tri_t = 0; } else if (tri_t + tri_h > $(document).height()) { tri_t = $(document).height() - tri_h; } }; //如果是鼠标跟随 if (this.s.hoverFollow && mousePos.left && mousePos.top) { if (this.s.hoverFollow === "x") { //水平方向移动,说明纵坐标固定 tri_l = mousePos.left funMouseL(); } else if (this.s.hoverFollow === "y") { //垂直方向移动,说明横坐标固定,纵坐标跟随鼠标移动 tri_t = mousePos.top; funMouseT(); } else { tri_l = mousePos.left; tri_t = mousePos.top; funMouseL(); funMouseT(); } } var arrLegalPos = ["4-1", "1-4", "5-7", "2-3", "2-1", "6-8", "3-4", "4-3", "8-6", "1-2", "7-5", "3-2"], align = this.s.position, alignMatch = false, strDirect; $.each(arrLegalPos, function(i, n) { if (n === align) { alignMatch = true; return; } }); if (!alignMatch) { align = "4-1"; } var funDirect = function(a) { var dir = "bottom"; //确定方向 switch (a) { case "1-4": case "5-7": case "2-3": { dir = "top"; break; } case "2-1": case "6-8": case "3-4": { dir = "right"; break; } case "1-2": case "8-6": case "4-3": { dir = "left"; break; } case "4-1": case "7-5": case "3-2": { dir = "bottom"; break; } } return dir; }; //居中判断 var funCenterJudge = function(a) { if (a === "5-7" || a === "6-8" || a === "8-6" || a === "7-5") { return true; } return false; }; var funJudge = function(dir) { var totalHeight = 0, totalWidth = 0, flagCorner = (o.s.sharpAngle && o.corner) ? true: false; if (dir === "right") { totalWidth = tri_l + tri_w + tar_w + off_x; if (flagCorner) { totalWidth += o.corner.width(); } if (totalWidth > $(window).width()) { return false; } } else if (dir === "bottom") { totalHeight = tri_t + tri_h + tar_h + off_y; if (flagCorner) { totalHeight += o.corner.height(); } if (totalHeight > st + $(window).height()) { return false; } } else if (dir === "top") { totalHeight = tar_h + off_y; if (flagCorner) { totalHeight += o.corner.height(); } if (totalHeight > tri_t - st) { return false; } } else if (dir === "left") { totalWidth = tar_w + off_x; if (flagCorner) { totalWidth += o.corner.width(); } if (totalWidth > tri_l) { return false; } } return true; }; //此时的方向 strDirect = funDirect(align); if (this.s.sharpAngle) { //创建尖角 this.createSharp(strDirect); } //边缘过界判断 if (this.s.edgeAdjust) { //根据位置是否溢出显示界面重新判定定位 if (funJudge(strDirect)) { //该方向不溢出 (function() { if (funCenterJudge(align)) { return; } var obj = { top: { right: "2-3", left: "1-4" }, right: { top: "2-1", bottom: "3-4" }, bottom: { right: "3-2", left: "4-1" }, left: { top: "1-2", bottom: "4-3" } }; var o = obj[strDirect], name; if (o) { for (name in o) { if (!funJudge(name)) { align = o[name]; } } } })(); } else { //该方向溢出 (function() { if (funCenterJudge(align)) { var center = { "5-7": "7-5", "7-5": "5-7", "6-8": "8-6", "8-6": "6-8" }; align = center[align]; } else { var obj = { top: { left: "3-2", right: "4-1" }, right: { bottom: "1-2", top: "4-3" }, bottom: { left: "2-3", right: "1-4" }, left: { bottom: "2-1", top: "3-4" } }; var o = obj[strDirect], arr = []; for (name in o) { arr.push(name); } if (funJudge(arr[0]) || !funJudge(arr[1])) { align = o[arr[0]]; } else { align = o[arr[1]]; } } })(); } } //已确定的尖角 var strNewDirect = funDirect(align), strFirst = align.split("-")[0]; if (this.s.sharpAngle) { //创建尖角 this.createSharp(strNewDirect); cor_w = this.corner.width(), cor_h = this.corner.height(); } //确定left, top值 if (this.s.hoverFollow) { //如果鼠标跟随 if (this.s.hoverFollow === "x") { //仅水平方向跟随 tar_l = tri_l + off_x; if (strFirst === "1" || strFirst === "8" || strFirst === "4" ) { //最左 tar_l = tri_l - (tar_w - tri_w) / 2 + off_x; } else { //右侧 tar_l = tri_l - (tar_w - tri_w) + off_x; } //这是垂直位置,固定不动 if (strFirst === "1" || strFirst === "5" || strFirst === "2" ) { tar_t = tri_t - off_y - tar_h - cor_h; //尖角 cor_t = tri_t - cor_h - off_y - 1; } else { //下方 tar_t = tri_t + tri_h + off_y + cor_h; cor_t = tri_t + tri_h + off_y + 1; } cor_l = pos.left - (cor_w - tri_w) / 2; } else if (this.s.hoverFollow === "y") { //仅垂直方向跟随 if (strFirst === "1" || strFirst === "5" || strFirst === "2" ) { //顶部 tar_t = tri_t - (tar_h - tri_h) / 2 + off_y; } else { //底部 tar_t = tri_t - (tar_h - tri_h) + off_y; } if (strFirst === "1" || strFirst === "8" || strFirst === "4" ) { //左侧 tar_l = tri_l - tar_w - off_x - cor_w; cor_l = tri_l - cor_w - off_x - 1; } else { //右侧 tar_l = tri_l + tri_w - off_x + cor_w; cor_l = tri_l + tri_w + off_x + 1; } cor_t = pos.top - (cor_h - tri_h) / 2; } else { tar_l = tri_l + off_x; tar_t = tri_t + off_y; } } else { switch (strNewDirect) { case "top": { tar_t = tri_t - off_y - tar_h - cor_h; if (strFirst == "1") { tar_l = tri_l - off_x; } else if (strFirst === "5") { tar_l = tri_l - (tar_w - tri_w) / 2 - off_x; } else { tar_l = tri_l - (tar_w - tri_w) - off_x; } cor_t = tri_t - cor_h - off_y - 1; cor_l = tri_l - (cor_w - tri_w) / 2; break; } case "right": { tar_l = tri_l + tri_w + off_x + cor_w; if (strFirst == "2") { tar_t = tri_t + off_y; } else if (strFirst === "6") { tar_t = tri_t - (tar_h - tri_h) / 2 + off_y; } else { tar_t = tri_t - (tar_h - tri_h) + off_y; } cor_l = tri_l + tri_w + off_x + 1; cor_t = tri_t - (cor_h - tri_h) / 2; break; } case "bottom": { tar_t = tri_t + tri_h + off_y + cor_h; if (strFirst == "4") { tar_l = tri_l + off_x; } else if (strFirst === "7") { tar_l = tri_l - (tar_w - tri_w) / 2 + off_x; } else { tar_l = tri_l - (tar_w - tri_w) + off_x; } cor_t = tri_t + tri_h + off_y + 1; cor_l = tri_l - (cor_w - tri_w) / 2; break; } case "left": { tar_l = tri_l - tar_w - off_x - cor_w; if (strFirst == "2") { tar_t = tri_t - off_y; } else if (strFirst === "6") { tar_t = tri_t - (tar_w - tri_w) / 2 - off_y; } else { tar_t = tri_t - (tar_h - tri_h) - off_y; } cor_l = tar_l + cor_w; cor_t = tri_t - (tar_w - cor_w) / 2; break; } } } //尖角的显示 if (cor_h && cor_w && this.corner) { this.corner.css({ left: cor_l, top: cor_t, zIndex: this.s.zIndex + 1 }); } //浮动框显示 this.target.css({ position: "absolute", left: tar_l, top: tar_t, zIndex: this.s.zIndex }); return this; }, createSharp: function(dir) { var bgColor, bdColor, color1 = "", color2 = ""; var objReverse = { left: "right", right: "left", bottom: "top", top: "bottom" }, dirReverse = objReverse[dir] || "top"; if (this.target) { bgColor = this.target.css("background-color"); if (parseInt(this.target.css("border-" + dirReverse + "-width")) > 0) { bdColor = this.target.css("border-" + dirReverse + "-color"); } if (bdColor && bdColor !== "transparent") { color1 = 'style="color:' + bdColor + ';"'; } else { color1 = 'style="display:none;"'; } if (bgColor && bgColor !== "transparent") { color2 = 'style="color:' + bgColor + ';"'; }else { color2 = 'style="display:none;"'; } } var html = '
    ' + '' + '' + '
    '; if (!$("#floatCorner_" + dir).size()) { $("body").append($(html)); } this.corner = $("#floatCorner_" + dir); return this; }, targetHold: function() { if (this.s.hoverHold) { var delay = parseInt(this.s.hideDelay, 10) || 200; if (this.target) { this.target.hover(function() { o.flagDisplay = true; }, function() { if (o.timerHold) { clearTimeout(o.timerHold); } o.flagDisplay = false; o.targetHold(); }); } o.timerHold = setTimeout(function() { o.displayDetect.call(o); }, delay); } else { this.displayDetect(); } return this; }, loading: function() { this.target = $('
    '); this.targetShow(); this.target.removeData("width").removeData("height"); return this; }, displayDetect: function() { //显示与否检测与触发 if (!this.flagDisplay && this.display) { this.targetHide(); this.timerHold = null; } return this; }, targetShow: function() { o.cornerClear(); this.display = true; this.container().setWidth().position(); this.target.show(); if ($.isFunction(this.s.showCall)) { this.s.showCall.call(this.trigger, this.target); } return this; }, targetHide: function() { this.display = false; this.targetClear(); this.cornerClear(); if ($.isFunction(this.s.hideCall)) { this.s.hideCall.call(this.trigger); } this.target = null; this.trigger = null; this.s = {}; this.targetProtect = false; return this; }, targetClear: function() { if (this.target) { if (this.target.data("width")) { this.target.removeData("width").removeData("height"); } if (this.targetProtect) { //保护孩子 this.target.children().hide().appendTo($("body")); } this.target.unbind().hide(); } }, cornerClear: function() { if (this.corner) { //使用remove避免潜在的尖角颜色冲突问题 this.corner.remove(); } }, target: null, trigger: null, s: {}, cacheData: {}, targetProtect: false }; $.powerFloat = {}; $.powerFloat.hide = function() { o.targetHide(); }; var defaults = { width: "auto", //可选参数:inherit,数值(px) offsets: { x: 0, y: 0 }, zIndex: 999, eventType: "hover", //事件类型,其他可选参数有:click, focus showDelay: 0, //鼠标hover显示延迟 hideDelay: 0, //鼠标移出隐藏延时 hoverHold: true, hoverFollow: false, //true或是关键字x, y targetMode: "common", //浮动层的类型,其他可选参数有:ajax, list, remind target: null, //target对象获取来源,优先获取,如果为null,则从targetAttr中获取。 targetAttr: "rel", //target对象获取来源,当targetMode为list时无效 container: null, //转载target的容器,可以使用"plugin"关键字,则表示使用插件自带容器类型 reverseSharp: false, //是否反向小三角的显示,默认ajax, remind是显示三角的,其他如list和自定义形式是不显示的 position: "4-1", //trigger-target edgeAdjust: true, //边缘位置自动调整 showCall: $.noop, hideCall: $.noop }; })(jQuery); /*打印插件jqprint 0.3*/ (function($) { var opt; $.fn.jqprint = function (options) { opt = $.extend({}, $.fn.jqprint.defaults, options); var $element = (this instanceof jQuery) ? this : $(this); if (opt.operaSupport && $.support.opera) { var tab = window.open("","jqPrint-preview"); tab.document.open(); var doc = tab.document; } else { var $iframe = $("