var Tooltip=$class( { el:null, tooltip:null, maxWidth:350, tpl:'<div id="clipboard_title" style="display:none"><div class="bln_info pngbox">\ <div class="tpt">\ <div class="bpt">\ <div class="cont">\ {content}\ </div>\ <div class="bpc"></div>\ </div>\ </div>\ <div class="tcn"></div>\ <div class="bcn"></div>\ </div></div>', constructor:function(el) { if(!el) return; this.el=el; $e.add(el, 'mouseover', this.show, this); $e.add(el, 'mouseout', this.hide, this); this.content=el.title; this.el.title=''; }, remove:function() { this.hide(); $e.del(this.el, 'mouseover', this.show, this); $e.del(this.el, 'mouseout', this.hide, this); this.el=null; }, show:function(el) { var t=this.tooltip=$u.tpl2el(this.tpl,{content:this.content}); document.body.appendChild(t); var width=$el.dimensions(t).width; if(width>this.maxWidth) width=this.maxWidth; var xy=$e.pointerXY($e.e); $config(t.style,{ width:width+'px', left:xy.x-7+'px', top:xy.y+12+'px', display:'block' }); }, hide:function() { $el.remove(this.tooltip); this.tooltip=null; } }); Tooltip.init=function(wrap, css) { if(!css) return; var ar=[], els=(css instanceof Array) ? css : $q.select(wrap, css); for(var i=0, n=els.length; i<n; i++) ar[ar.length]=new Tooltip(els[i]); return ar; }; Tooltip.destroy=function(tooltips) { if(!tooltips || !(tooltips instanceof Array)) return; while(tooltips.length){ tooltips[0].remove(); tooltips.splice(0,1); } }; var Clipboard={ copyMsg:null, defaultCopyMsg:'Copied to clipboard', timestamp:0, msgElement:null, hash:null, init:function() { var a = $q.select(document, ".copy_text"); if (a.length == 0) return; for (var i=0, n = a.length; i < n; i++) { var el = a[i]; $e.add (el, 'focus', this.focus, this); } if (!Flash.init(7)) return; var flashSrc = JSRoot + "flash/__clipboard.swf"; var hash = {}; for (var i=0, n = a.length; i < n; i++) { var el = a[i]; var text2Copy = encodeURIComponent(el.value); var flashId = "clipboardMC" + i; hash[flashId] = el; var flashVars = "clipboard=" + text2Copy + "&id=" + flashId; var flashStr = Flash.draw(flashSrc, "100%", "100%", "transparent", flashVars, true); var flashCont = $u.el('div',{ id:flashId, className:'copy_icon', innerHTML: flashStr }); var inputCont = el.parentNode.parentNode; inputCont.parentNode.insertBefore(flashCont, inputCont); } this.hash = hash; }, focus: function(el) { setTimeout(function(){ el.select(); }, 1); }, getTooltipText: function() { if (this.copyMsg) return this.copyMsg; var clipboard_text = $('clipboard_text'); this.copyMsg=clipboard_text ? clipboard_text.title : this.defaultCopyMsg; return this.copyMsg; }, showMsg: function(flashContId) { var flashCont = $(flashContId); if (!flashCont) return; if(!this.msgElement){ this.msgElement=$u.el('div',{ id:'clipboard_title', innerHTML:'<div class="bln_info pngbox">\ <div class="tpt">\ <div class="bpt">\ <div class="cont">' + this.getTooltipText() + '</div>\ <div class="bpc"></div>\ </div>\ </div>\ <div class="tcn"></div>\ <div class="bcn"></div>\ </div>' }); document.body.appendChild(this.msgElement); } if(this.msgElement.style.display=='block') clearTimeout(this.timestamp); var tl=$el.cumulativeOffset(flashCont); $config(this.msgElement.style,{ display:'block', top:tl.top+12+'px', left:tl.left+16+'px' }); var inpuitEl = this.hash[flashContId]; if (inpuitEl) inpuitEl.select(); this.timestamp=setTimeout('$("clipboard_title").style.display="none"', 1800); } }; Clipboard=new $class(dPage,Clipboard); var dTooltip=$class({ el:null, type:'', target:'', cel:null, x:0, y:0, html:'', images:[], scope:null, _re:null, _wrap:null, _cont:null, _tpl:'<div class="js_tooltip pngbox">\ <div class="tpt">\ <div class="bpt">\ <div class="cont">\ {html}\ </div>\ <div class="bpc"></div>\ </div>\ </div>\ <div class="tcn"></div>\ <div class="bcn"></div>\ </div>', constructor:function(config) { $config(this,config); this.init(); }, init:function() { if(!this.el) throw new Error('No element for dTooltip'); this._re=new RegExp('(^|\\s)'+this.target+'(\\s|$)'); this._wrap=$u.el('div',{ id:'dTooltipWrap', className:'hidden', innerHTML:this._tpl }); this._cont = $q.down(this._wrap, '.cont'); document.body.appendChild(this._wrap); this.attachEventHandlers(); if(this.images.length) $e.add(window,'load',$u.preloadImages.bind(null,this.images)); }, attachEventHandlers :function() { $e.add(this.el,'mouseover',this.test,this); $e.add(this.el,'mouseout',this.test,this); $e.add(this._wrap,'mouseout',this.test,this); }, detachEventHandlers :function() { $e.del(this.el,'mouseover',this.test,this); $e.del(this.el,'mouseout',this.test,this); $e.del(this._wrap,'mouseout',this.test,this); }, destroy:function() { this.detachEventHandlers (); $el.remove(this._wrap); this._wrap=null; this._cont=null; this.el=null; }, test:function(el) { var e=$e.e; if(e.type=='mouseout') el=e.relatedTarget||e.toElement; var p=el, cel=this.cel, w=this._wrap, b=document.body, re=this._re; if(el==cel) return; while(p && p!=cel && p!=w && !re.test(p.className) && p!=b) p=p.parentNode; if(!p || p==b) this.hide(); else if(p!=w && p!=cel) this.show(p); }, show:function(el) { this.cel=el; var config=this.format.call(this.scope || this,$(el)); if(el) el.title=''; this._cont.innerHTML=config.html; this._wrap.style.left=config.left+'px'; this._wrap.style.top=config.top+'px'; this._wrap.className=this.type; }, hide:function() { this._wrap.className='hidden'; this.cel=null; }, format:function(el) { var e=$e.e; var html=el.title; var xy=$e.pointerXY(e); return { left:xy.x, top:xy.y, html:html }; } }); var GiftsViewClass = $class(dPage, { name:'Gifts', gifts:{}, init:function() { this.giftsTooltipInit(); $e.on({'.load_all_gifts':this.load_more}, this); $u.app.on('give_a_gift',this.ovlOpen,this); $u.preloadImages([JSRoot + 'i/loaders-pop.gif']); }, ovlOpen: function() { dOvl.open_ex({rev:this.url,rel:'gift-add'}); }, giftsTooltipInit: function() { if($('gift_add_nosms')) new Tooltip($('gift_add_nosms')); var gifts=$('gifts'); if(gifts) { this.gifts_tooltip=new dTooltip({ _tpl:'<div class="js_tooltip pngbox">\ <div class="tpt">\ <div class="bpt">\ <div class="cont">\ <div class="giftbox-line"></div>\ <span class="bullet"></span>\ <span class="gift_cont">{html}</span>\ </div>\ <div class="bpc"></div>\ </div>\ </div>\ <div class="tcn"></div>\ <div class="bcn"></div>\ </div>', el:gifts, type:'giftbox', target:'gift_tooltip_target', images:[JSRoot+'i/box-gift.png', JSRoot+'i/boxs-apts.png'], format:function(el) { var m=/^gift([\d_]+)$/.exec(el.id); var gift_id = m&&m[1]||''; var gift=this.gifts[gift_id]; var anchor = $('gift_a_' + gift_id); if(!gift || !anchor ) return ''; var hidden = $el.hasClassName (anchor, 'hide_from_other'); this.gifts_tooltip.type = hidden ? 'giftbox hiddengiftbox' : 'giftbox'; var tl=$el.cumulativeOffset(el); var topOfs = hidden ? 0 : -62; return { html:gift.tooltip, left:parseInt(tl.left+el.offsetWidth/2-14), top:tl.top+el.offsetHeight-16 + topOfs }; }, scope:this }); if (this.gifts_tooltip && this.gifts_tooltip._wrap) this.gifts_tooltip._cont = $q.down(this.gifts_tooltip._wrap, '.gift_cont'); } }, load_more:function(el) { this._show_more_el=el; $u.startWaiting(el); var url=el.rev; new $r(url,{ method:'get', params:'', ready: this.loaded, error: this.error },this); }, error:function() { $u.stopWaiting(this._show_more_el); }, loaded:function(res) { var el=this._show_more_el; $u.stopWaiting(el); if(res.errno) return; var p=$q.up(el,'p'); p && p.parentNode.removeChild(p); var gifts=$('gifts'); var img_sample=$q.down(gifts,'img'); for(var i in res.gifts){ var gift=res.gifts[i]; this.gifts[i]=gift; } $('gifts').innerHTML+=res.html; } }); var SLUpdater = function (config) { $config(this, config); this.init(); }; SLUpdater.prototype = { spotlight: null, spotlightVars: null, sls: {}, slp_id: -1, submit_bn:null, params:{}, timeout: 8000, update_ts:0, profileUrl: '', secondUrl: '/sl/list-ws-json/', firstUrl: '/sl/ws/', init: function() { if(!this.spotlightVars) return; this.sls = this.spotlightVars && this.spotlightVars.sls || {}; this.params = this.spotlightVars.params; if (this.spotlightVars.items) this.items = eval('('+this.spotlightVars.items+')'); else this.items = []; this.update_ts = this.params.ts; this.requestParams = { language_id: this.params.lid, spotlight_id: this.params.sid }; this.firstRequest_fn = this.request1.bind(this); this.timerInt = setTimeout(this.firstRequest_fn, this.timeout); }, destroy: function() { clearTimeout(this.timerInt); if (this._t1) { this._t1.abort(); this._t1 = null; } if (this._t2) { this._t2.abort(); this._t2 = null; } this.spotlight = null; }, getProfileUrl: function(r) { var url = window.location.protocol+'\/\/' + (this.params.b?('{login}.' + this.params.s) : (this.params.s + '/{login}')); return url; }, request1: function() { this.getRequest1Transport().request(); }, getRequest1Transport: function(transport) { if (this._t1) return this._t1; this._t1 = new $r(this.firstUrl,{ method: 'get', auto:false, params:this.requestParams, error:this.request1Error, readyEx: this.firstRequestHandler }, this); return this._t1; }, firstRequestHandler : function(transport) { var ts = transport.transport.responseText; if(ts != this.update_ts) { this.update_ts = ts; this.request2(ts); } else { this.runTimeout(); } }, request1Error: function() { this.runTimeout(); }, runTimeout: function() { this.timerInt = setTimeout(this.firstRequest_fn, this.timeout); }, request2: function(ts) { this.getRequest2Transport().request(); }, getRequest2Transport: function(ts) { if (this._t2) return this._t2; this._t2 = new $r (this.secondUrl,{ method: 'get', auto:false, params:this.requestParams, ready: this.secondRequestHandler }, this); return this._t2; }, secondRequestHandler: function(res) { this.items = res; if (this.spotlight) { this.spotlight.updateLayout(this.items); this.timerInt = setTimeout(this.firstRequest_fn, this.timeout); } } }; var SLTooltip = $class(dTooltip,{ tooltipHtmlContent: '', userUrl: '', leftOfs: 0, spotlight: null, visible: false, init:function() { if(!this.el) throw new Error('No element for dTooltip'); this._re=new RegExp('(^|\\s)'+this.target+'(\\s|$)'); this._wrap=$u.el('div',{ id:'dTooltipWrap', className:'hidden', innerHTML:this._tpl }); this._cont = $q.down(this._wrap, '.cont'); $e.add(window,'load',$u.preloadImages.bind(null,[JSRoot + 'i/box-spot.png'])); }, delayedDOMChange: function() { document.body.appendChild(this._wrap); this.attachEventHandlers(); }, format: function(userUrl, html, x) { var tooltipHtmlContent = html.replace('<mask>', userUrl), tl = $el.cumulativeOffset(this.el); return { html: tooltipHtmlContent, left: tl.left + 0 + x +40, top: tl.top + 82+ (this.is_wizard?(document.documentElement.scrollTop || document.body.scrollTop) - (document.documentElement.clientTop || 0):0) }; }, mouseOverHandler: function() { this.mouseOvered = true; }, mouseOutHandler: function() { var e = $e.e, el=e.relatedTarget||e.toElement; if (!el) { this.hide(); return; } var n = el; while (n && n != document.body) { if (n == this.el) { this.mouseOvered = false; return; } if (n == this._wrap) { this.mouseOvered = true; return; } try { n = n.parentNode; } catch (e) { n = null; } } this.hide(); }, show: function(x, tooltip_html, user_url) { var leftOfs = parseInt(x) - 25, config=this.format(user_url, tooltip_html, leftOfs); this._cont.innerHTML=config.html; var sl_add_btn_class = ''; try { if (Spotlight.slLine.focI == 0) sl_add_btn_class = ' sl_add_btn_tooltip'; } catch (e) { } this._wrap.className=this.type + sl_add_btn_class; this.fit(config); this._wrap.style.left=config.left+'px', this._wrap.style.top=config.top+'px', this.mouseOvered = false, this.visible = true; }, fit:function(config) { var tl=$el.cumulativeOffset(this.el), t=tl.left+this.el.offsetWidth-(config.left+this._wrap.offsetWidth); if(t<20) config.left=config.left+t-60; }, hide:function() { this.mouseOvered = false, this._wrap.style.top='-1000px', this.cel=null; if (this.visible) { this.visible = false; this.spotlight.checkFromTooltip(); } }, attachEventHandlers : function() { $e.add(this._wrap,'mouseout',this.mouseOutHandler,this); $e.add(this._wrap,'mouseover',this.mouseOverHandler,this); }, detachEventHandlers :function() { $e.del(this._wrap,'mouseout',this.mouseOutHandler,this); $e.del(this._wrap,'mouseover',this.mouseOverHandler,this); } }); var SLLine=function(config) { $config(this, config); this.init(); }; SLLine.prototype={ spotlight: null, rightBorderDiv:null, cnvs: null, cnvs_wrap: null, items: [], profileURL: "", imgs: [], addBtnImg: null, imgNum: 9, minImgNum: 9, intrv: 3, min: 83, max: 110, originMinSize: 83, originMaxSize: 110, timeOut: 15, timerInt: -1, sp: null, focI: -1, leftOfs: 10, spLeft: 230, spTop: 0, spWidth: 800, spHeight: 120, canvasImgTop: 15, vmlImgTop: 4, imgTop: 30, firstImgLeft: 17, addBtnLeft: 17, applyTimeoutInt:0, applyTimeout: 15, zoomDuration: 250, zoomOutDuration: 250, opacityDuration: 300, updateDuration: 1000, normalSize: 890, zoom: 1, startAlpha: 100, tooltipImgIndex: -1, need2ShowTooltip: -1, need2RemovePreviousItems: false, updateIsAvailable:true, tempUpdateLayoutParams: null, canvasImgBackground: "rgb(228,217,255)", ofsAnimationMode: false, ie6Mode: false, subscribedAnimQueue: [], init: function () { this.resize_binded=this.resize.bind(this), this.timer_binded=this.timer.bind(this), this.showTooltip2_binded=this.showTooltip2.bind(this), this.opacityWaveStep_binded=this.opacityWaveStep.bind(this), this.fullUpdateStart_binded=this.fullUpdateStart.bind(this); $e.on({ '.sl_add_btn, * .sl_add_btn_tooltip, .sl_add_btn_tooltip': this.openWizard }, this); this.rightBorderDiv = $('sl_plug'); this.imgNum = this.items.length < this.minImgNum ? this.items.length : this.minImgNum; this.updateImgLeft(); this.setupZoom(); if(/*@cc_on!@*/false) { this.zoomDuration = 350; this.zoomOutDuration = 400; this.applyTimeout=10, this.timeOut=10, this.imgTop=this.vmlImgTop, this.applyChanges=this.applyChangesVML; $e.add(window, 'resize', this.resizeIE, this); this.initVML(); } else { this.zoomDuration = 250; this.zoomOutDuration = 250; this.applyTimeout=20, this.timeOut=20; this.imgTop=this.canvasImgTop, this.applyChanges=this.applyChangesCanvas; $e.add(window, 'resize', this.resize, this); this.initCanvas(); } this.applyChanges_bind=this.applyChanges.bind(this); }, destroy: function () { this.stopTimer (); this.stopApplyChangesTimer (); clearInterval(this.showTooltipInt); clearInterval(this.resizeIEInt); clearInterval(this.zoomOutInt); clearInterval(this.showTooltipInt); clearInterval(this.fullUpdateStartInt); clearInterval(this.opacityWaveInt); if(/*@cc_on!@*/false) { $e.del(window, 'resize', this.resizeIE, this); $e.del(this.sp, 'mouseover', this.mouseOver, this); $e.del(this.sp, 'mouseout', this.mouseOut, this); } else { $e.del(window, 'resize', this.resize, this); $e.del(this.cnvs_wrap, 'mousemove', this.mouseMove, this); $e.del(this.cnvs_wrap, 'mouseout', this.cnvsMouseOut, this); $e.del(this.cnvs_wrap, 'click', this.canvasClickHandler, this); } var imgs=this.imgs; if (this.addBtnImg) { this.addBtnImg.destroy(); } if (imgs) { for (var i=0, imgNum=this.imgNum; i < imgNum; i++) { var d=imgs[i]; d.destroy(); } } this.addBtnImg=this.subscribedAnimQueue=this.imgs=this.rightBorderDiv=this.VMLPattern=this.cnvs=this.cnvs_wrap=this.sp=this.ctx=null; return true; }, initCanvas: function () { var cnvs_wrap=$("cnvs_wrap"), cnvs=$("cnvs"); this.cnvs_wrap =cnvs_wrap, this.cnvs=cnvs; var tl=$el.cumulativeOffset(cnvs_wrap); this.spLeft=tl.left, this.spTop=tl.top, this.spWidth=parseInt(cnvs_wrap.offsetWidth), this.spHeight=parseInt(cnvs_wrap.offsetHeight), cnvs.width=this.spWidth, cnvs.height=this.spHeight, this.sp=cnvs; var ctx=cnvs.getContext('2d'); this.ctx=ctx; ctx.fillStyle=this.canvasImgBackground, ctx.lineWidth=1, ctx.globalAlpha=this.startAlpha / 100, this.prevCtxAlpha=this.startAlpha / 100; var img=$("img_add_btn"); img.parentNode.style.display='none'; var d=this.newImg(this.addBtnLeft); d.sp=this; d.image=img; this.addBtnImg=d; d.draw(); var ofs=this.firstImgLeft; for (var i=0; i < this.imgNum; i++) { var img=$("img" + i); img.parentNode.style.display='none'; var d=this.newImg(ofs); d.sp=this, d.image=img, d.draw(), this.imgs[this.imgs.length]=d; ofs += this.min + this.intrv; } $e.add(cnvs_wrap, 'mousemove', this.mouseMove, this); $e.add(cnvs_wrap, 'mouseout', this.cnvsMouseOut, this); $e.add(cnvs_wrap, 'click', this.canvasClickHandler, this); }, initVML: function () { var sp=$("sp"), tl=$el.cumulativeOffset(sp); this.sp=sp, this.spLeft=tl.left, this.spTop=tl.top, this.spWidth=parseInt(sp.offsetWidth), this.spHeight=parseInt(sp.offsetHeight), this.ie6Mode=_ua=='ie6'; var img=$("img_add_btn"), vml_img=$("vml_img_add_btn"), anchor=img.parentNode; anchor.title='', img.index=0, vml_img.index=0, anchor.index=0; var d=this.newImg(this.addBtnLeft, anchor, img, vml_img); d.sp=this, this.addBtnImg=d, d.anchor=anchor; d.a.elV = 0; d.a.v = 100; d.drawVMLDirect(); var ofs=this.firstImgLeft; for (var i=0; i < this.imgNum; i++) { var img=$("img" + i), vml_img=$("vml_img" + i), anchor=img.parentNode; img.index=i+1, vml_img.index=i+1, anchor.index=i+1, anchor.title=''; var d=this.newImg(ofs, anchor, img, vml_img); d.sp=this, this.imgs[this.imgs.length]=d, d.anchor=anchor; d.drawVMLDirect(); ofs += this.min + this.intrv; } this.initVMLPattern(); $e.add(sp, 'mouseover', this.mouseOver, this); $e.add(sp, 'mouseout', this.mouseOut, this); }, resizeIEInt: 0, resizeIE: function() { if (this.resizeIEInt) clearInterval(this.resizeIEInt); this.resizeIEInt=setTimeout(this.resize_binded, 20); }, resize: function() { this.setupZoom(); }, updateImgLeft: function(skipImageUpdate) { this.firstImgLeft = this.addBtnLeft + this.min + this.intrv; }, updateRightBorder: function() { var rightBorder = this.firstImgLeft + (this.intrv + this.min) * this.minImgNum; var rightBorderW = this.spWidth - rightBorder + 10; this.rightBorderDiv.style.width = rightBorderW + 'px', this.rightBorderDiv.style.left = rightBorder + 'px'; }, setupZoom: function(skipImageUpdate) { var normalSize=this.normalSize; var slline=$('slline'); var tl=$el.cumulativeOffset(slline); this.spLeft=tl.left; this.spWidth=parseInt(slline.offsetWidth); var currentSize=this.spWidth > normalSize ? normalSize : this.spWidth; this.zoom=Math.round((currentSize * 100 / normalSize)) / 100; var newMinSize=Math.round( this.originMinSize * this.zoom), newMaxSize=Math.round( this.originMaxSize * this.zoom); if (newMinSize != this.min || newMaxSize != this.max) { this.min=newMinSize, this.max=newMaxSize; this.updateImgLeft(); if (skipImageUpdate) return; if (this.imgs && this.imgs.length > 0) { var imgNum=this.imgNum, imgs=this.imgs, ofs=this.firstImgLeft; for (var i=0; i < imgNum; i++) { var d=imgs[i]; d.left.v=ofs; ofs += this.min + this.intrv; } this.setupDestSize(-1000, this.min, 250); } } }, newImg: function(ofs, anchor, img, vml_img) { var d=new sIm ({ w: { elV: this.min,v: this.min,d: this.min,s: this.min,top: this.imgTop,elTop: this.imgTop,dur: this.zoomDuration }, a: {elV: this.startAlpha,d: this.startAlpha,s: this.startAlpha,v: this.startAlpha,dur: this.opacityDuration}, left: {elV: ofs,d: ofs,s: ofs,v: ofs,dur: this.zoomDuration }, anchor: anchor, image: img, vml_image: vml_img }); return d; }, valueByTime: function(t,b,c,d) { var v=Math.round( (c - b) *((t=t/d-1)*t*t+1)+b); if (b > c) { if (v < c ) v=c; } else { if (v > c) v=c; } return v; }, sizeByTime: function(t,b,c,d) { var v=Math.round( (c - b) *((t=t/d-1)*t*t+1)+b); if (b > c) { if (v < c ) v=c; } else { if (v > c) v=c; } if (v < this.min) { v=this.min; } if (v > this.max) { v=this.max; } return v; }, startTimer: function () { clearInterval(this.timerInt); this.timerInt=setInterval(this.timer_binded, this.timeOut); this.startApplyChangesTimer(); }, stopTimer: function () { clearInterval(this.timerInt); this.applyChanges(); this.stopApplyChangesTimer(); }, setupDestLeft: function (dur) { var dur=dur || this.zoomDuration, sum=0, minSum=this.min * this.imgNum, imgs=[this.addBtnImg].concat(this.imgs), imgNum=this.imgNum + 1; for (var i=0; i < imgNum; i++) { var d=imgs[i]; sum += d.w.d; } var firstImgLeft = this.addBtnLeft, curTime=new Date().getTime(), focI=this.focI; if (sum > minSum && focI >= 0 && focI < imgs.length) { var d=imgs[focI], focusedPos= firstImgLeft + focI * (this.min + this.intrv) - Math.round( (d.w.d - this.min)/ 2); d.left.d=focusedPos, d.left.startTime=curTime, d.left.s=d.left.v, d.left.dur=dur; var ofs= focusedPos + d.w.d + this.intrv; for (var i=focI + 1; i < imgNum; i++) { var d=imgs[i]; d.left.d =ofs, d.left.s=d.left.v, d.left.dur=dur, d.left.startTime=curTime; ofs += d.w.d + this.intrv; } var ofs=focusedPos; for (var i=focI - 1; i >= 0 ; i--) { var d=imgs[i]; ofs -= d.w.d + this.intrv; d.left.d =ofs, d.left.startTime=curTime, d.left.dur=dur, d.left.s=d.left.v; } } else { var ofs=0; for (var i=0; i < imgNum; i++) { var d=imgs[i]; d.left.d =ofs + firstImgLeft, d.left.startTime=curTime, d.left.dur=dur, d.left.s=d.left.v; ofs += d.w.d + this.intrv; } } }, opacityWaveDelay: 30, opacityWaveInt: -1, imgWaveIndex: 0, animStep: function () { var need2ProcessMore=false, curTime=new Date().getTime(), imgNum=this.imgNum+1, imgs=[this.addBtnImg].concat(this.imgs), numChanges=0; var wSum=0; for (var i=0; i < imgNum; i++) { var d=imgs[i], changed=false; if (d.a.startTime) { if (d.a.v != d.a.d) { var newAlpha=this.valueByTime(curTime -d.a.startTime,d.a.s, d.a.d, d.a.dur); if (d.a.v != newAlpha) { d.changed=true, d.a.v=newAlpha, changed=true; } if (newAlpha != d.a.d) need2ProcessMore=true; else d.a.startTime=0; } else d.a.startTime=0; } var need2Left = false; if (d.w.startTime) { if (d.w.v != d.w.d) { need2Left = true; var newSize=this.sizeByTime(curTime -d.w.startTime,d.w.s,d.w.d,d.w.dur); var newLeft=this.valueByTime(curTime -d.w.startTime,d.left.s,d.left.d,d.left.dur); if ((Math.abs(d.w.d - d.w.s) != this.max - this.min) || ((Math.abs(newSize - d.w.v) >=2) ) || ((Math.abs(d.left.d - d.left.s)) >= this.min) || (newSize == d.w.d)) { d.w.v=newSize, d.w.top=this.imgTop - Math.round((d.w.v - this.min) / 2), d.changed=true, changed=true; if (d.left.v != d.left.d ) { if (d.left.v != newLeft) { d.changed=true, d.left.v=newLeft, changed=true; } } } } if (d.left.startTime && !need2Left) { if (d.left.v != d.left.d ) { var newLeft=this.valueByTime(curTime -d.w.startTime,d.left.s,d.left.d,d.left.dur); if (d.left.v != newLeft) { d.changed=true, d.left.v=newLeft, changed=true; } if (newLeft != d.left.d) need2ProcessMore=true; else d.left.startTime=0; } } if (d.w.v == d.w.d && d.w.d == this.max && this.tooltipImgIndex != i) { this.need2ShowTooltip=i; } if (d.w.v != d.w.d || d.left.v != d.left.d) need2ProcessMore=true; else d.w.startTime=0; } wSum += d.w.v; if (changed) numChanges++; } this.numChanges=numChanges, this.need2ProcessMore=need2ProcessMore; if (numChanges > 0 && !need2ProcessMore && wSum == imgs.length * this.min) { if (!this.updateIsAvailable && !this.spotlight.slTooltip.visible) { this.processDelayedUpdate(); } } if (!need2ProcessMore && this.ofsAnimationMode) this.stopOfsAnimationEvent(); return need2ProcessMore; }, showTooltip: function() { if (this.need2ShowTooltip == -1) return; this.showTooltipInt=setTimeout(this.showTooltip2_binded, 150); }, showTooltip2: function() { if (!this.imgs || this.need2ShowTooltip == -1 || this.need2ProcessMore || this.need2ShowTooltip != this.focI) return; var simIndex=this.need2ShowTooltip; this.need2ShowTooltip=-1; this.tooltipImgIndex=simIndex; if (simIndex == 0) { var sim=this.addBtnImg; var tooltipStr=this.spotlight.addBtnToolip; var userUrl=''; } else { var sim=this.imgs [simIndex - 1]; var item=this.items[simIndex - 1]; var tooltipStr=item.tooltip; var userUrl=this.profileURL.replace('{login}', item.login); } var leftOfs=sim.left.elV; this.spotlight.tooltip(tooltipStr, leftOfs, userUrl); }, hideTooltip: function() { this.tooltipImgIndex=-1; this.spotlight.tooltip_hide(); }, applyChangesCanvas: function () { this.processSubscribedAnimQueue(); if (this.cnvs.width != this.spWidth) { this.cnvs.width=this.spWidth, this.ctx.fillStyle=this.canvasImgBackground; this.fullCanvasRedraw(); return; } if (this.numChanges == 0) return; if (this.numChanges <= 4) this.fullCanvasRedraw(); else this.fullCanvasRedraw(); this.numChanges=0; if (this.need2ShowTooltip >=0) this.showTooltip(); }, canvasRedrawByImages: function () { var imgs=this.imgs, ctx=this.ctx, changes=this.changes; for (var i=0, n= this.imgNum; i < n; i++) { var d=imgs[i]; if (d.changed) { ctx.clearRect(d.left.elV - 2, d.w.elTop - 2, d.w.elV + 4, d.w.elV + 4); d.w.elV=d.w.v, d.left.elV=d.left.v, d.w.elTop=d.w.top, d.a.elV=d.a.v; if (d.a.elV / 100 != this.prevCtxAlpha) { this.prevCtxAlpha=d.a.elV / 100; ctx.globalAlpha=this.prevCtxAlpha; } d.draw(); } } var d = this.addBtnImg; if (d.changed) { ctx.clearRect(d.left.elV - 2, d.w.elTop - 2, d.w.elV + 4, d.w.elV + 4); d.w.elV=d.w.v, d.left.elV=d.left.v, d.w.elTop=d.w.top, d.a.elV=d.a.v; if (d.a.elV / 100 != this.prevCtxAlpha) { this.prevCtxAlpha=d.a.elV / 100; ctx.globalAlpha=this.prevCtxAlpha; } } d.draw(); }, fullCanvasRedraw: function () { var imgs=this.imgs; var ctx=this.ctx; ctx.clearRect(0, 0, this.spWidth, this.spHeight); for (var i=0, n= this.imgNum; i < n; i++) { var d=imgs[i]; d.w.elV=d.w.v, d.left.elV=d.left.v, d.w.elTop=d.w.top, d.a.elV=d.a.v; d.elFocused= d.focused; if (d.a.elV / 100 != this.prevCtxAlpha) { this.prevCtxAlpha=d.a.elV / 100; ctx.globalAlpha=this.prevCtxAlpha; } d.draw(); } var d = this.addBtnImg; d.w.elV=d.w.v, d.left.elV=d.left.v, d.w.elTop=d.w.top, d.a.elV=d.a.v; d.elFocused= d.focused; if (d.a.elV / 100 != this.prevCtxAlpha) { this.prevCtxAlpha=d.a.elV / 100; ctx.globalAlpha=this.prevCtxAlpha; } this.addBtnImg.draw(); }, applyChangesVML: function () { this.processSubscribedAnimQueue(); var imgs=this.imgs; if (!imgs) return; var d = this.addBtnImg; if (d.changed) d.draw(); for (var i=0, n= this.imgNum; i < n; i++) { var d= imgs[i]; if (d.changed) d.draw(); } this.numChanges=0; if (this.need2ShowTooltip >=0) this.showTooltip(); }, timer: function () { var need2ProcessMore=this.animStep(); if (!need2ProcessMore) this.stopTimer(); }, startApplyChangesTimer: function () { clearInterval(this.applyTimeoutInt); this.applyTimeoutInt= setInterval(this.applyChanges_bind, this.applyTimeout); }, subscribeAnim: function (animDesr) { if (!this.applyTimeoutInt) return false; this.subscribedAnimQueue[this.subscribedAnimQueue.length]=animDesr; return false; }, processSubscribedAnimQueue: function () { var a=this.subscribedAnimQueue; var n=a.length; if (!n) return; for (var i=0;i<n;i++) { var d=a[i]; var d2=null; if (d) { for (var k=n-1;k>=i;k--) { if (d2) { var d3=a[k]; if (d3.func==d.func && d3.scope==d.scope) a[k]=null; } else { d2=a[k]; if (d2.func!=d.func || d2.scope!=d.scope) d2=null; } } } d = d2 || d; d.func.call(d.scope, d.argmts[0]); } this.subscribedAnimQueue=[]; }, stopApplyChangesTimer: function () { clearInterval(this.applyTimeoutInt); this.applyTimeoutInt=0; }, getImageIndex: function (clientX, clientY) { var clientX=clientX - this.spLeft; var clientY=clientY - this.spTop; var descr=this.addBtnImg; if (clientX >= descr.left.elV && clientX < descr.left.elV + descr.w.elV) return 0; for (var i=0, imgs=this.imgs, n=imgs.length; i < n; i++) { var descr= imgs[i]; if (clientX >= descr.left.elV && clientX < descr.left.elV + descr.w.elV) { return i+1; } } return -1; }, openWizard: function () { Spotlight.ovlOpen(); }, spMouseOver: false, imageMouseOverIndex: -1, canvasClickHandler: function () { this.mouseMove(); if (this.focI == 0) { this.openWizard (); } else if (this.focI > 0 && this.focI - 1 < this.items.length) { var item=this.items[this.focI-1]; window.location.href=this.profileURL.replace('{login}', item.login); } }, mouseMove: function () { var event=$e.e, clientX=event.clientX, clientY=event.clientY; if (clientX >= this.spLeft && clientX < this.spLeft + this.spWidth) { this.spMouseOver=true; var imageIndex =this.getImageIndex(clientX, clientY); if (imageIndex == -1 && this.imageMouseOverIndex != -1) { this.imageMouseOverIndex=-1; this.mouseOut({ toElement: this.sp}); this.cnvs_wrap.href="#"; } else if (imageIndex != -1 && imageIndex != this.imageMouseOverIndex) { this.imageMouseOverIndex=imageIndex; this.imageMouseOver({index : imageIndex}); } } else { if (this.spMouseOver) { this.imageMouseOverIndex=-1; this.spMouseOver=false; this.mouseOut({toElement: null}); this.cnvs_wrap.href="#"; } } }, mouseOver: function (event) { var event=$e.e, el=event.target || event.srcElement; if (el == this.sp) return; this.imageMouseOver(el); return true; }, _style_cursor: 'pointer', setupCursorStyle: function (v) { if (this._style_cursor != v) { this._style_cursor=v; this.cnvs_wrap.style.cursor=v; } }, imageMouseOver: function (el) { if (!el || el.index < 0 || el.index >= this.minImgNum+1) return; if (this.cnvs) { this.setupCursorStyle('pointer'); if (el.index >0) { var item=this.items[el.index-1]; this.cnvs_wrap.href=this.profileURL.replace('{login}', item.login); } else this.cnvs_wrap.href='#'; } this.focI=el.index; this.setupDestSize(this.focI, this.max); }, hasAsParent: function (el, parent) { var el=el; while (el && el != document.body) { if (el == parent) return true; try { el=el.parentNode; } catch (e) { return false; } } return false; }, cnvsMouseOut: function (event) { var event=$e.e; var toElement=event.relatedTarget || event.toElement; this.spMouseOver=false, this.imageMouseOverIndex=-1, this.focI=-1; var toTooltip = this.tooltipCheck(event); this.tooltipImgIndex=-1; if (!toTooltip) this.setupDestSize(-1000, this.min, this.zoomOutDuration); }, mouseOut: function (event) { if(/*@cc_on!@*/false) var event=$e.e; else { var event=event || $e.e; } var toElement=event.relatedTarget || event.toElement; if (this.cnvs && (!toElement || !toElement.index)) { this.setupCursorStyle('default'); } if (/*@cc_on!@*/true) { if (toElement == this.cnvs) { return; } } if (this.hasAsParent(toElement, this.sp) || (toElement && toElement.index)) return true; if (/*@cc_on!@*/false) { if (!toElement || (!toElement.index && toElement.index != 0)) { this.spMouseOver=false, this.imageMouseOverIndex=-1, this.focI=-1; var toTooltip = this.tooltipCheck(event); this.tooltipImgIndex=-1; if (!toTooltip) this.setupDestSize(-1000, this.min, this.zoomOutDuration); } } return true; }, tooltipCheck: function (e) { var el=e.relatedTarget || e.toElement; if (!el) { this.hideTooltip(); return false; } var tooltipF = this.hasAsParent(el, this.spotlight.slTooltip._wrap); if (!tooltipF) this.hideTooltip(); return tooltipF; }, zoomOutInt: 0, zoomOut: function (imgIndex, size, dur) { var imgIndex=imgIndex, size=size, dur= dur, scope=this; clearInterval(this.zoomOutInt); this.zoomOutInt=setTimeout(function () { scope.setupDestSize(imgIndex, size, dur); }, 500); }, setupDestSize: function (imgIndex, size, dur) { this.stopTimer(); if (this.zoomOutInt) { clearInterval(this.zoomOutInt); this.zoomOutInt=0; } var dur=dur || this.zoomDuration; var imgs=[this.addBtnImg].concat(this.imgs); if (!imgs) return; if (imgIndex >=0) { this.updateIsAvailable=false; } var curTime=new Date().getTime(), focI=this.focI; for (var i=0, imgNum=this.imgNum+1; i < imgNum; i++) { var d =imgs[i]; d.focused=focI == i, d.w.startTime=curTime, d.w.s=d.w.v, d.w.dur=dur; if (i != imgIndex) { d.w.d=this.min; if (d.w.d < this.min) d.w.d= this.min; } else d.w.d=size; } this.setupDestLeft(dur); this.startTimer(); }, identical: function (a) { for (var i=0, n=a.length; i < n; i++) { var item=a[i]; if (this.getItemIndexByValues(this.items, item) != i) { return false; } } return true; }, updateLayout: function (sljson) { if (!this.updateIsAvailable) { this.tempUpdateLayoutParams=sljson; return; } var newItems=[]; if (sljson instanceof Array) for(var i=0; i < sljson.length; i++){ var item=sljson[i]; newItems[newItems.length]=item; } else for(var itemKey in sljson) { var item=sljson[itemKey]; newItems[newItems.length]=item; } if (this.identical(newItems)) { return; } this.hideTooltip(); clearInterval(this.opacityWaveInt); this.imageMouseOverIndex=-1; if(/*@cc_on!@*/true) this.setupZoom(true); if (!this.items || this.items.length == 0 || newItems.length < this.minImgNum) { this.redrawFullReplace(newItems, 0); } else { this.removePreviousItems (); var ofsIndex=this.getOffsetIndex (newItems); if (ofsIndex >= newItems.length - 1 || ofsIndex == 0) this.redrawFullReplace(newItems, ofsIndex); else this.redrawViaOfsAnimation (newItems, ofsIndex); } }, initVMLPattern: function () { if (this.VMLPattern) return this.VMLPattern; var anchor = this.addBtnImg.anchor; var pattern=anchor.cloneNode(true); var img=pattern.firstChild, vml_img=pattern.lastChild; img.className = "sp_img", vml_img.className = "sp_vml_img", img.src=JSRoot + 'i/blank.gif', vml_img.src=JSRoot + 'i/blank.gif'; this.VMLPattern = pattern; }, getVMLElem: function () { if (!this.VMLPattern) this.initVMLPattern(); var pattern=this.VMLPattern.cloneNode(true); return pattern; }, getImage4Update: function (ofs, imgSrc, profileURL) { if(/*@cc_on!@*/false) { var newEl=this.getVMLElem(); var curFirstElem= this.imgs[0].anchor; this.sp.insertBefore(newEl, curFirstElem); var img=newEl.firstChild, vml_img=newEl.lastChild; newEl.href=profileURL, newEl.style.zIndex = 1000, img.src= imgSrc, newEl.style.left = -1000; if (this.ie6Mode) vml_img.src= imgSrc; var d=this.newImg(ofs, newEl, img, vml_img); d.w.elV=-1, d.sp=this; } else { var d=this.newImg(ofs); var newEl=new Image(); var img=newEl; d.sp=this, d.image=newEl; img.src= imgSrc; } return d; }, startOfsAnimationEvent: function () { this.rightBorderDiv.style.display = 'block'; this.ofsAnimationMode = true; }, stopOfsAnimationEvent: function () { this.rightBorderDiv.style.display = 'none'; this.ofsAnimationMode = false; if (this.need2RemovePreviousItems) { this.removePreviousItems(); if(/*@cc_on!@*/true) this.fullCanvasRedraw(); } }, redrawViaOfsAnimation: function (newItems, ofsIndex) { this.updateRightBorder(); this.startOfsAnimationEvent(); var finalItemsArr=[].concat(this.items); for (var i=ofsIndex - 1; i >= 0; i--) { var item=newItems[i]; finalItemsArr.unshift(item); } this.items=finalItemsArr, this.need2RemovePreviousItems=true, this.imgNum=this.items.length; var ofs=this.firstImgLeft; var startTime=new Date().getTime(); for (var i=ofsIndex - 1; i >= 0 ; i--) { var item=this.items[i]; ofs -= this.min + this.intrv; var profileURL=this.profileURL.replace('{login}', item.login); var d=this.getImage4Update(ofs, item.url, profileURL); if(/*@cc_on!@*/false) { d.image.filters[0].opacity=100; } d.a.elV=0,d.a.d=100,d.a.v=100,d.a.s=100,d.a.startTime=startTime,d.a.dur = 3000; this.imgs.unshift(d); } for (var i=0, n=this.imgs.length; i < n; i++) { var d=this.imgs[i]; d.image.index=i+1; if(/*@cc_on!@*/false) { if (d.vml_image) d.vml_image.index=i+1; d.anchor.index=i+1; } } var startTime=new Date().getTime(); this.zoomOut(-10000, this.min, this.updateDuration); }, redrawFullReplace: function (newItems, ofsIndex) { this.removePreviousItems (); this.items4FullUpdate=newItems, this.d4FullUpdate=[]; var ofs=this.firstImgLeft; var newItemsArrCount = newItems.length > this.minImgNum ? this.minImgNum : newItems.length; for (var i=0; i < newItemsArrCount; i++) { var item=newItems[i]; var profileURL=this.profileURL.replace('{login}', item.login); var d=this.getImage4Update(ofs, item.url, profileURL); d.image.index=i+1; if(/*@cc_on!@*/false) { d.image.filters[0].opacity=0; if (d.vml_image) d.vml_image.index=i+1; d.anchor.index=i+1; } ofs += this.min + this.intrv; d.a.elV=0,d.a.d=100,d.a.v=0,d.a.s=0; this.d4FullUpdate[this.d4FullUpdate.length]=d; } clearInterval(this.opacityWaveInt); this.imgNum = this.imgs.length; this.imgWaveIndex=this.imgNum - 1; this.hideBeforeUpdate=true; this.opacityWaveStep(); this.opacityWaveInt=setInterval(this.opacityWaveStep_binded, this.opacityWaveDelay); }, fullUpdateStart: function () { this.clear(); this.items=this.items4FullUpdate, this.items4FullUpdate=null, this.imgs=this.d4FullUpdate, this.d4FullUpdate=null, this.imgNum=this.items.length > this.minImgNum ? this.minImgNum : this.items.length; for (var i=0; i < this.imgNum; i++) { var item=this.items[i]; var d=this.imgs[i]; if(/*@cc_on!@*/false) { d.drawVMLDirect(); } } this.hideBeforeUpdate=false; clearInterval(this.opacityWaveInt); this.imgWaveIndex=this.imgNum - 1; this.opacityWaveStep(); this.opacityWaveInt=setInterval(this.opacityWaveStep_binded, this.opacityWaveDelay); }, fullUpdateStartInt: 0, opacityWaveStep: function () { var d=this.imgs[this.imgWaveIndex]; if (this.hideBeforeUpdate) { d.a.d=0, d.a.s=100; } else { d.a.d=100, d.a.s=0; } d.a.startTime=new Date().getTime(); if (this.imgWaveIndex > 0) { this.imgWaveIndex--; this.startTimer(); } else { clearInterval(this.opacityWaveInt); if (this.hideBeforeUpdate) { this.fullUpdateStartInt=setTimeout(this.fullUpdateStart_binded, 500); } } }, checkFromTooltip: function() { if (this.tempUpdateLayoutParams) this.processDelayedUpdate(); else this.setupDestSize(-1000, this.min, this.zoomOutDuration); }, processDelayedUpdate: function() { if (this.need2ProcessMore || this.focI >= 0) return; this.updateIsAvailable=true; if (!this.tempUpdateLayoutParams) return; var newItems=this.tempUpdateLayoutParams; this.tempUpdateLayoutParams=null; this.updateLayout(newItems); }, removePreviousItems: function () { var imgs=this.imgs; if (!imgs) return; for (var i=this.minImgNum, n=imgs.length; i < n; i++) { var d=imgs[i]; d.removeFromDOM(); d.destroy(); } this.items.splice (this.minImgNum, this.items.length - this.minImgNum); imgs.splice (this.minImgNum, imgs.length - this.minImgNum); this.imgNum=this.minImgNum; this.need2RemovePreviousItems=false; }, clear: function () { var imgs=this.imgs; for (var i=0, n=imgs.length; i < n; i++) { var d=imgs[i]; d.removeFromDOM(); d.destroy(); } this.imgs=[], this.imgNum=0; }, getItemIndexByValues: function (a, item) { for (var i=0, n=a.length; i < n; i++) { var v=a[i]; if (v.id == item.id) return i; } return -1; }, getOffsetIndex: function (newItemsArr) { var a=[]; var firstInd=-1; var newItemsArrCount = newItemsArr.length > this.minImgNum ? this.minImgNum : newItemsArr.length; for (var i=0, n=newItemsArr.length; i < n; i++) { var item=newItemsArr[i]; item.indexInCurrentItems=this.getItemIndexByValues(this.items, item); if (firstInd == -1 && item.indexInCurrentItems != -1) firstInd=i; } if (firstInd == -1) return this.items.length; for (var i=firstInd + 1, n=newItemsArr.length; i < n; i++) { var item=newItemsArr[i]; var prevItem=newItemsArr[i - 1]; if (prevItem.indexInCurrentItems != item.indexInCurrentItems - 1) return this.items.length; } return firstInd; } }; var sIm=function (config) { $config(this, config); this.init(); }; sIm.prototype={ changed: false, focused: false, elFocused: false, anchor: null, w: { elV: 0,v: 0, d: 0, s: 0, top: 0, elTop: 0, dur: 0, startTime: 0}, a: { elV: 0,d: 0, s: 0, v: 0, dur: 0, startTime: 0}, left: { elV:0,d: 0,s:0,v:0,dur:0,startTime: 0}, image: null, vml_image: null, imageComplete: false, sp: null, ie6Mode:false, init: function () { if(/*@cc_on!@*/false) { this.ie6Mode=_ua=='ie6'; this.draw=this.drawViaVML; if (this.ie6Mode) this.initVMLLoader(); } else { this.draw=this.drawViaCanvas; } }, destroy: function () { if(/*@cc_on!@*/false) { if (this.vml_image) { this.vml_image.onfilterchange = null; this.vml_image = null; } } this.image.onload=null; this.image=null; this.sp=null; this.vml_image=null; this.anchor=null; }, initVMLLoader: function () { var scope = this; this.vml_image.onfilterchange_count = 0; this.vml_image.onfilterchange = function (e) { this.onfilterchange_count++; if (this.onfilterchange_count <2) return; this.onfilterchange = null; setTimeout(function () { try { scope.switch2VML(); } catch (e) { ; } },750); } }, switch2VML: function () { this.vml_image.onfilterchange = null; if (this.imageComplete) return true; this.imageComplete = true; this.drawVMLDirect(); return true; }, initUploadHandler: function (src) { var scope=this; this.image.onload=function() { scope.imageComplete = true; if(/*@cc_on!@*/false) scope.drawVMLDirect(); else scope.drawViaCanvas(); this.onload=null; } }, drawViaCanvas: function () { if (this != this.sp.addBtnImg && this.left.v < this.sp.addBtnLeft) { return; } if (this.image.complete) { try { this.sp.ctx.drawImage(this.image, this.left.elV, this.w.elTop, this.w.elV, this.w.elV); this.imageComplete = true; } catch (e) { this.imageComplete = false; this.drawEmptyRect(); if (!this.image.onload) this.initUploadHandler(); } } else { if (!this.image.onload) this.initUploadHandler(); this.drawEmptyRect(); } this.changed=false; }, drawEmptyRect: function () { this.sp.ctx.fillRect(this.left.elV, this.w.elTop, this.w.elV, this.w.elV); this.changed=false; }, drawViaVML: function () { if (this != this.sp.addBtnImg && this.left.v < this.sp.addBtnLeft) { return; } var img=this.image, vml_image=this.vml_image, anchor=this.anchor; if (this.focused != this.elFocused) { this.elFocused=this.focused; } if (this.w.elV != this.w.v) { var w=this.w.v; img.style.width=w, img.style.height=w, anchor.style.width=w, anchor.style.height=w, anchor.style.top=this.w.top, this.w.elV=this.w.v, this.w.elTop=this.w.top; if (this.ie6Mode && this.imageComplete) { vml_image.style.width=w, vml_image.style.height=w; } } if (this.left.elV != this.left.v) { anchor.style.left=this.left.v, this.left.elV=this.left.v; } if (this.a.elV!= this.a.v) { img.filters[0].opacity=this.a.v; if (this.ie6Mode && this.imageComplete) { vml_image.filters[0].opacity=this.a.v; } this.a.elV=this.a.v; } this.changed=false; }, drawVMLDirect: function () { if (this != this.sp.addBtnImg && this.left.v < this.sp.addBtnLeft) { return; } var img=this.image, vml_image=this.vml_image, anchor=this.anchor; this.elFocused=this.focused; var w=this.w.v; img.style.width=w, img.style.height=w; if (this.ie6Mode && this.imageComplete) { vml_image.style.width=w, vml_image.style.height=w; } anchor.style.width=w, anchor.style.height=w, anchor.style.top=this.w.top, this.w.elV=this.w.v, this.w.elTop=this.w.top, anchor.style.left=this.left.v, this.left.elV=this.left.v; img.filters[0].opacity=this.a.v; if (this.ie6Mode && this.imageComplete) { vml_image.filters[0].opacity=this.a.v; } this.a.elV=this.a.v, this.changed=false; }, removeFromDOM: function () { if(/*@cc_on!@*/false) { this.anchor.parentNode.removeChild(this.anchor); } } }; var SpotlightClass =function(config) { $config(this, config); this.init(); }; SpotlightClass.prototype={ name: 'Spotlight', slLine: null, updater: null, slTooltip: null, init: function() { if(!$('slline') || !vars.Spotlight) return; this.updater = new SLUpdater({ spotlightVars: vars.Spotlight, spotlight: this }); this.slLine = new SLLine({ spotlight: this, items: this.updater.items, profileURL: this.updater.getProfileUrl() }); this.slTooltip = new SLTooltip({ el: this.slLine.sp, spotlight: this, type: 'spotbox', target: 'spotlight-line_ur_2' }); $u.app.on('spotlight', this.ovlOpen, this); $e.add(window,'beforeunload',this.destroy, this); }, ovlOpen: function() { var url = vars.SpotlightWizard && vars.SpotlightWizard.url; dOvl.open_ex({rev:url,rel:'sl_step'}); }, destroy: function() { if (this.slLine) { this.slLine.destroy (); this.slLine = null; } if (this.slTooltip) { this.slTooltip.destroy(); this.slTooltip = null; } if (this.updater) { this.updater.destroy (); this.updater = null; } return true; }, tooltip: function (tooltip_html, x, user_url, from_wizard, id) { this.slTooltip.show(x, tooltip_html, user_url); }, updateLayout: function (json) { this.slLine.updateLayout(json); }, tooltip_hide: function () { if (!this.slTooltip.mouseOvered) { this.slTooltip.hide(); } }, checkFromTooltip: function () { this.slLine.checkFromTooltip(); } }; var SpotlightDOMReadySupply=new $class(dPage, { name: 'SpotlightDOMReadySupply', init: function () { if (window.Spotlight && Spotlight.slTooltip) { Spotlight.slTooltip.delayedDOMChange(); } } }); if(Flash.init(9)){ try{ document.documentElement.className+=' flash_upload '; }catch(e){} } var Statistics=new $class(dPage, { init:function() { $e.on('#stat_more', this.load, this); }, load:function(el) { this.el=el.parentNode; $el.addClassName(this.el, 'el-loading'); new $r(el.href,{ method:'get', params:{ws:1}, ready:this.ready, error:this.error }, this); }, ready:function(res) { if(res.errno){ this.error(); }else{ this.el.parentNode.innerHTML=res.html; this.el=null; } }, error:function() { this.el.parentNode.innerHTML=''; this.el=null; } }); var RedButton= { name:'RedButton', url:'/ws/boring-ws.phtml', activated:false, autoshow:false, pr:false, inset:null, fxAnim: null, forceHide: false, state: 0, animDuration: 750, init:function() { if (!this.pr) return; this.inset=$('js_chatting_button'), this.block=$('js_chatting_block'), this.form=$('red_button_form'); if(!this.inset || !this.block) return; this.block.style.left='-240px'; if(this.autoshow) this.show(this.inset); $e.on('.rb-force-hide',this.force_hide, this); if(!this.activated){ $e.add(this.inset, 'mouseover', this.show, this); }else{ $e.add(this.inset, 'mouseover', this.over, this); $e.add(this.inset, 'click', this.show, this); } $e.add(this.inset, 'mouseout', this.hide, this); $e.add(this.block, 'mouseover', this.over, this); $e.add(this.block, 'mouseout', this.hide, this); $e.add(this.form, 'submit', this.activate, this); }, force_hide:function(el) { this.move(false); this.forceHide = true; new $r(this.url,{ method:'post', params:{ hide:1 } }); }, activate:function(el) { new $r(this.url,{ method:'post', params:{ws:1} }); $el.removeClassName(this.block,'wish_to_chat'); $el.addClassName(this.block,'search_interlocutor'); }, move:function(show) { if (this.forceHide) return; if ((this.state==1 && show) || (this.state==2 && !show)) return; if (this.fxAnim) this.fxAnim.end(); this.state=show?1:2; var from = parseInt(this.block.style.left); var to = show ? 0 : -240; var duration = Math.round(this.animDuration * Math.abs(from - to) / 240); if (!duration) return; this.fxAnim = new $fx.effect({ wait:false, duration: duration, scope:this, items:[ new $fx.style({ rb: this,el:this.block,prop:'left',from: from,to: to, end: function () { this.rb.forceHide = false; this.rb.fxAnim=null; this.rb.state=0; } }) ] }); }, show:function() { this.move(true); }, over:function() { this.show(true); }, hide:function(el) { var e=$e.e; var reltg=$(e.relatedTarget || e.toElement); if(!reltg || (reltg && !$q.up(reltg,'#js_chatting_block'))) { this.move(false); } } }; RedButton=new $class(dPage,RedButton); var MeetMakerPromoLink=new $class(dPage,{ name:'MeetMakerPromoLink', startTS:0, init:function() { if ($('mm_ban_4') || $('mm_ban_1')) this.startTS=setTimeout(function () { $r.script(JSRoot + 'js/meet-maker-promo.js'); }, 1500); }, destroy: function () { clearTimeout(this.startTS); } }); var dConfirm = { el:null, _tpl:'<div class="tpt">\ <div class="tpc"></div>\ <div class="bpt">\ <div class="cont">\ {html}\ </div>\ <div class="bpc"></div>\ </div>\ </div>\ <div class="tcn"></div>\ <div class="bcn"></div>', x:0, y:0, ralign:false, type:'', text:'', onOk:null, onCancel:null, scope:null, defaults:{ x:0, y:0, ralign:false, type:'', text:'', onOk:null, onCancel:null, scope:null }, init:function() { $e.on({ '.dConfirm-ok':this.ok, '.dConfirm-cancel':this.cancel },this); }, create:function() { this.el=$u.el('div',{ className:'hidden pngbox confirm', innerHTML:this._tpl }); this.cont=$q.down(this.el,'.cont'); document.body.appendChild(this.el); }, hide:function() { if(this.el) $el.addClassName(this.el,'hidden'); }, ok:function(el) { this.hide(); if(this.onOk) this.onOk.call(this.scope); }, cancel:function(el) { this.hide(); this.onCancel && this.onCancel.call(this.scope); }, show:function(config) { $config(this,config,this.defaults); if(!this.el) this.create(); if(window.dOvl && dOvl._visible) this.type+=' fixed_confirm'; this.el.className='hidden pngbox confirm '+this.type; if(typeof(this.text)=='string'){ this.cont.innerHTML=this.text; }else if(this.text.nodeType==1){ this.cont.innerHTML=''; this.cont.appendChild(this.text); }else if(text instanceof Array){ this.cont.innerHTML=this.wrap(text); }else{ } if(this.ralign){ this.el.style.left=''; this.el.style.right=$el.dimensions(document).width-this.x+'px'; }else{ this.el.style.left=this.x+'px'; this.el.style.right=''; } this.el.style.top=this.y+'px'; $el.removeClassName(this.el,'hidden'); var bn=$q.down(this.el,'input, button'); bn && bn.focus(); }, wrap:function(texts) { return $u.tpl('<div class="ask" id="confirm_ask">{title}</div>\ {msg}\ <div id="confirm_buttons">\ <input type="button" value="{bn_text}" class="dConfirm-ok" />\ <span class="confirm_or">{or} <a href="#" class="dConfirm-cancel">{cancel}</a></span>\ </div>',{ title:texts[0], bn_text:texts[1], or:texts[2], cancel:texts[3], msg:texts[4] }); } }; dConfirm=new $class(dPage,dConfirm); var GiftsView = new GiftsViewClass(); var ProfileView=new $class(dPage,{ name:'ProfileView', remove_str:['Remove {name} from {folder}?', 'Remove', 'or', 'Cancel'], add_make_meet:false, init:function() { new Tooltip($('write_disabled'), {maxWidth: 350}); $e.on({ '.add_contcat':this.add_contact, '.remove_contcat':this.remove_contact },this); }, add_contact:function(el) { this.send(el.rel||el.href); }, remove_contact:function(el) { if($e.e.shiftKey) this.send(el.rel||el.href); var xy=$e.pointerXY($e.e); dConfirm.show({ x:(xy.x-35), y:(xy.y-115), type:'b_tail', text:dConfirm.wrap(this.remove_str), onOk:this.send.bind(this,el.rel||el.href), scope:this }); }, send:function(url) { new $r(url,{ method:'post', params:{ws:1}, ready:this.data_ready },this); }, data_ready:function(res) { $('in_folder').innerHTML=res.html; if(res.remove_str) this.remove_str=res.remove_str; if(this.add_make_meet) $el.addClassName($('for_make_meet'), 'make_meet'); } });