;(function($){ $.fn.jccontact = function(options) { var defaults = { speed:600, //璁剧疆鍔ㄧ敾鏃堕棿锛坢m锛? position:'top', //澶栧眰妗嗘灦鍨傜洿浣嶇疆锛屾彁渚?top","center","bottom" posoffsety : 0, //寰皟璁剧疆澶栧眰妗嗘灦鍨傜洿浣嶇疆 btnposition : 'top', //鎸夐挳鍨傜洿浣嶇疆锛屾彁渚?top","center","bottom" btnposoffsety : 90 , //寰皟璁剧疆鎸夐挳鍨傜洿浣嶇疆 float:'left', //妗嗘灦浣嶇疆锛屾彁渚?left","right" event : "mouseover" //璁剧疆灞曞紑妗嗘灦浜嬩欢锛屾彁渚?mouseover","lick" }; var options = $.extend(defaults,options); return this.each(function() { $("body").css("overflow-x","hidden"); var $this = $(this), _self = this, wraptop = 0, btmtop = 0, _width = 0, $window = $(window), winwidth = $window.width(), winheight = $window.height(), $con = $this.children(":eq(0)"), nconwidth = $con.width(), nconheight = $con.height(), $btn = $this.children(":eq(1)"), nbtnwidth = $btn.width(), nbtnheight = $btn.height(), //鏂板缓鍙傛暟绫? fnmode = function(){ this.left = setwrappos; this.right = setwrappos; this.top = setwraptop; this.center = setwraptop; this.bottom = setwraptop; this.btntop = setbtntop; this.btncenter = setbtntop; this.btnbottom = setbtntop; }; fnmode.prototype.mode = function(mode,btnpos,wrappos){ this[mode](mode); this[wrappos](wrappos); this[btnpos](btnpos); }; //鍒濆鍖栦綅缃? var o = new fnmode, speed = math.round(options.speed*0.5); o.mode(options.float,"btn"+options.btnposition,options.position); //婊氬姩浜嬩欢 $(window).scroll(function(){ var nscrolltop = $(this).scrolltop(); setanimate(nscrolltop,setwraptop); }); $btn.bind(options.event,function(e){ var obool = null; if(options.float == "left"){ _width = 0; obool = parseint($this.css("left")) < _width; } else if(options.float == "right"){ _width = winwidth - nconwidth; obool = parseint($this.css("left")) > _width; }; if(obool){ $this.animate({"left": _width},speed); }; }) $this.bind("mouseleave",function(){ if(options.float == "left"){ _width = -nconwidth; } else if(options.float == "right"){ _width = winwidth; }; $this.animate({"left": _width},speed); }); //鍔熻兘鏂规硶 function setbtntop(pos){ var setpos; if(pos == "btntop"){ setpos = 0; } else if(pos == "btncenter") { setpos = (nconheight-nbtnheight)/2; } if(pos == "btnbottom") { setpos = nconheight-nbtnheight; }; btmtop = setpos+options.btnposoffsety; $btn.css("top",btmtop); return false; }; function setwraptop(pos){ var _st,setval; if(pos == "top"){ _st = $(window).scrolltop(); setval = 0; } else if(pos == "center") { _st = $(window).scrolltop(); setval = (winheight-nconheight)/2; } else if(pos == "bottom") { _st = $(window).scrolltop(); setval = winheight-nconheight; }; setwraptop = setval + options.posoffsety; setanimate(_st,setwraptop); return false; }; function setwrappos(spos){ var wrapleft,btnleft; if(spos == "left"){ wrapleft = -nconwidth; btnleft = nconwidth; } else if(spos == "right"){ wrapleft = winwidth; btnleft =-nbtnwidth; }; $btn.css("left",btnleft); $this.css("left",wrapleft).show(); return false; }; function setanimate(st,val){ $this.stop().animate({"top":val+st},options.speed); return false; }; //www.sucaijiayuan.com return false; }); }; })(jquery)