//var tempi=0; function ZoomPic () { this.initialize.apply(this, argument); } ZoomPic.prototype = { 初期化 : function (id) { var _this = this; this.wrap = typeof id === "string" ? document.getElementById(id) : id; this.oUl = this.wrap.getElementsByTagName("ul")[0]; this.aLi = this.wrap.getElementsByTagName("li"); this.spans = this.wrap.getElementsByTagName("label"); this.prev = this.wrap.getElementsByTagName("pre")[0]; this.next = this.wrap.getElementsByTagName("pre")[1]; this.timer = null; this.aSort = []; this.aSpan = []; this.iCenter = 2; this._doPrev = function () {return _this.doPrev.apply(_this)}; this._doNext = function () {return _this.doNext.apply(_this)}; this.options = [ {幅:50, 高さ:212, 上:55, 左:0, zIndex:1}, {幅:90, 高さ:252, 上:35, 左:50, zIndex:2}, {幅:400, 高さ:292, 上:10, 左:140, zIndex:3}, {幅:90, 高さ:252, 上:35, 左:540, zIndex:2}, {幅:50, 高さ:212, 上:55, 左:630, zIndex:1} ]; for (var i = 0; i for (var i = 0; i this.aSort.unshift(this.aSort.pop()); this.setUp(); this.addEvent(this.prev, "クリック", this._doPrev); this.addEvent(this.next, "クリック", this._doNext); this.doImgClick(); this.dospansClick(); this.timer = setInterval(function () { _this.doNext() }, 3000); this.wrap.onmouseover = function () { clearInterval(_this.timer) }; this.wrap.onmouseout = function () { _this.timer = setInterval(function () { _this.doNext() }, 3000); } }, doPrev : function () { this.aSort.unshift(this.aSort.pop());//删除数组最後一项,并そして回数组を返す获取最終次一位 this.setUp() }, doNext : function () { this.aSort.push(this.aSort.shift());//删除数グループの最初の桁を返し、最初の桁を最後に上にプッシュします。 this.setUp() }, doImgClick : function () { var _this = これ; for (var i = 0; i { this.aSort[i].onclick = function () { //alert(this.索引); if (this.index > _this.iCenter) { for (var i = 0; i _this.setUp() } else if(this.index < _this.iCenter) { for (var i = 0; i < _this.iCenter - this.インデックス; i ) _this.aSort.unshift(_this.aSort.pop()); _this.setUp() } } } },dospansClick:function(){ var _this = this; for (var i = 0; i < this.aSpan.length; i ) { this.aSpan[i].onclick = function () { //alert (この.id); //alert(_this.aSort[_this.iCenter].getElementsByTagName('img')[0].name);//获取到現在是第几个在中间 var cruuNum=_this.aSort[ _this.iCenter].getElementsByTagName('img')[0].name; // if (this.id > _this.iCenter) // { // for (var i = 0; i < this.id - _this.iCenter; i ) _this.aSort .push(_this.aSort.shift());//取 // _this.setUp() //alert(this.id '...' cruuNum); if(this.id-cruuNum>0){ for (var i = 0; i _this.setUp() }else{ //if(cruuNum==5){ //if(this.id-cruuNum>0){ for (var i = 0; i < -(this.id-cruuNum); i ) _this.aSort.unshift(_this.aSort.pop());//取 _this.setUp(); //}
//} } // else{ // for (var i = 0; i < -(this.id-cruuNum); i ) _this.aSort.push(_this.aSort.shift());//取 // _this.setUp() // // }
// } // else if(this.id < _this.iCenter) // { // for (var i = 0; i < _this.iCenter) - this.id; i ) _this.aSort.unshift(_this.aSort.pop()); // _this.setUp() // }
// for (var i = 0; i <5; i ){ // _this.aSort.push( _this.aSort.shift());//取第一个 //alert(_this.aSort[_this.iCenter].getElementsByTagName('img')[0].name 'aaa' this.id); // if(_this.aSort[_this.iCenter].getElementsByTagName('img')[0].name==(this.id 1)){ // _this.setUp() // 壊す; // } // }
} } }, setUp : function () { var _this = this; var i = 0; for (i = 0; i for (i = 0; i < this .aSort.length; i ) { this.aSort[i].index = i; //制御浮動层 if (i < 5) {
this.css(this.aSort[i], "display", "block"); this.doMove(this.aSort[i], this.options[i], function () { _this.doMove(_this.aSort[_this.iCenter].getElementsByTagName("img") [0]、{不透明度:100}, function () { _this.doMove(_this.aSort[_this.iCenter].getElementsByTagName("img")[0], {opacity:100}, function () { _this.aSort[_this.iCenter].onmouseover = function ()//ネズミ标放上去 { _this.doMove(this.getElementsByTagName("div")[0], {bottom:0}) }; _this.aSort[_this.iCenter].onmouseout = function () { _this.doMove(this.getElementsByTagName("div")[0], {bottom:-100}) } }) }) }); } else { this.css(this.aSort[i], "display", "none"); this.css(this.aSort[i], "width", 0); this.css(this.aSort[i], "高さ", 0); this.css(this.aSort[i], "top", 37); this.css(this.aSort[i], "left", this.oUl.offsetWidth / 2) } if (i < this.iCenter || i > this.iCenter) // { this.css(this.aSort[i].getElementsByTagName("img")[0], "opacity", 30) this.aSort[i].onmouseover = function ( ) { _this.doMove(this.getElementsByTagName("img")[0], {opacity:100}) }; this.aSort[i].onmouseout = function () { _this.doMove(this.getElementsByTagName("img")[0], {opacity:35}) }; this.aSort[i].onmouseout(); } else { //中间一直是2 //alert(this.aSort[i].text);//取消变亮イベントイベント //alert (this.aSort[i].getElementsByTagName("img")[0].name); //变换颜色 var ttSe=this.aSort[i].getElementsByTagName("img")[0].name; var numbuts= document.getElementsByName('numBut'); //alert(numbuts.length);
for(var t=0;tif(t==0){ if(ttSe==5){ numbuts[t ].className ='numbutLeftCen'; }else numbuts[t].className ='numbutLeft'; }else if(t==ttSe){ numbuts[t].className ='numbutCen'; }else if(t==numbuts.length){ //alert(t); numbuts[0].className ='numbutCen'; }else{ // 全部修正class numbuts[t].className='numbut'; } //var aObj = document.getElementById("a的ID"); //追加イベント //alert(tempi); // if(tempi==0){//alert(tempi); // if (window.addEventListener) {//Mozilla 系 // numbuts[t].addEventListener('click', _this.addClick(t 1), false); // } else if (window.attachEvent) {//IE // numbuts[t].attachEvent('onclick', this.addClick(t 1)); // } // } } // テンポ ; this.aSort[i].onmouseover = this.aSort[i].onmouseout = null } } },addEvent : function (oElement, sEventType, fnHandler) { oElement.addEventListener を返しますか? oElement.addEventListener(sEventType, fnHandler, false) : oElement.attachEvent("on" sEventType, fnHandler) }, css : function (oElement, attr, value) { if (引数) .length == 2) { return oElement.currentStyle ? oElement.currentStyle[attr] : getComputedStyle(oElement, null)[attr] } else if (arguments.length == 3) { switch (attr) { case "width": case "height": case "top": case "left": case "bottom": oElement.style[attr] = value "ピクセル"; 休憩; case "opacity" : oElement.style.filter = "alpha(opacity=" value ")"; oElement.style.opacity = 値 / 100; 休憩; デフォルト: oElement.style[attr] = 値; break } } }, doMove : function (oElement, oAttr, fnCallBack) { var _this = this; clearInterval(oElement.timer); oElement.timer = setInterval(function () { var bStop = true; for (oAttr の var プロパティ) { var iCur = parseFloat(_this.css( oElement, property)); property == "opacity" && (iCur = parseInt(iCur.toFixed(2) * 100)); var iSpeed = (oAttr[property] - iCur); 🎜>iSpeed = iSpeed > 0 ? Math.ceil(iSpeed) : Math.floor(iSpeed);
if (iCur != oAttr[property]) { bStop = false; _this.css(oElement, property, iCur iSpeed) } } if (bStop) { clearInterval(oElement.timer) fnCallBack && fnCallBack. apply(_this, argument) } }, 30) },addClick:function (num){ //alert(num); // if (this.index > _this.iCenter) // { // for (var i = 0; i < this.index - _this.iCenter; i ) _this.aSort .push(_this.aSort.shift()); // _this.setUp() // } } }; window.onload = function () { new ZoomPic("box"); }; 関数 tt(){ //alert(1);