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 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); 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 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 Comments=new $class(dPage, { name: 'Comments', deleteText:{ comment:"Delete only this comment", thread:"Delete whole thread" }, init:function() { if(!$('comments')) return; $e.on({ '.sub_to_com, * .sub_to_com':this.toggle_subscribe, '.reply_anchor':this.reply, '.add_comment_anchor':this.add_comment, '.delete_comment': this.delete_comment }, this); if($('add_comment_form')){ $el.removeClassName($('add_comment_form'), 'editing'); }else{ if($('reply_form')){ $('reply_form').style.display = 'block'; } } if($('f_comment')) $u.textarea_count('f_comment', 5000); if($('comment_timer')) this.comment_timer(); }, toggle_subscribe:function(el) { $el.toggleClassName(el, 'enabled'); new $r(el.href,{ method:'get', params:{ws:1} }); }, comment_timer: function() { var ct=$('comment_timer'); var t=parseInt(ct.value)-1; if(t>0){ ct.value=t; $('post_comment').disabled=true; $('post_comment_error_wait').style.display='inline'; var el = $q.down($('post_comment_error_wait'), 'b'); el.innerHTML = t; var comments = this; window.setTimeout(function () { comments.comment_timer() } , 1000); }else{ $('post_comment').disabled=false; $('post_comment_error_wait').style.display='none'; } }, reply:function(el) { if($el.hasClassName(el.parentNode, 'editing')){ $el.removeClassName(el.parentNode, 'editing'); $('reply_form').style.display = 'none'; }else{ if($el.hasClassName($('add_comment'), 'editing')) $el.removeClassName($('add_comment'), 'editing'); $el.removeClassName($('reply_form').parentNode, 'editing'); $el.addClassName(el.parentNode, 'editing'); el.parentNode.appendChild($('reply_form')); $('reply_form').style.display = 'block'; if($('f_comment'))$('f_comment').focus(); } if($('thread_id')) { var t=el.rel.split('|'); $('thread_id').value=t[0]; $('photo_id').value=t[1]; } if($('current_page'))$('page_num').value=$('current_page').value; }, add_comment:function(el) { if($el.hasClassName($('add_comment'), 'editing')) { $el.removeClassName($('add_comment'), 'editing'); $('reply_form').style.display = 'none'; if($('no_comments_text')) $('no_comments_text').style.display = 'block'; }else{ if($el.hasClassName($('reply_form').parentNode, 'editing')) $el.removeClassName($('reply_form').parentNode, 'editing'); $el.addClassName($('add_comment'), 'editing'); $('add_comment_form').appendChild($('reply_form')); if($('no_comments_text')) $('no_comments_text').style.display = 'none'; $('reply_form').style.display = 'block'; if($('f_comment')) $('f_comment').focus(); } if($('page_num')) $('page_num').value=''; if($('thread_id') && top==self){ $('thread_id').value=0; } }, delete_comment:function(el) { var texts=vars.comments_str.slice(); var opt=''; if(el.rev == '1') opt='<div id="confirm_text"><label><input type="radio" id="confirm_opt1" name="confirm_opt" checked="checked" value="1"> '+ this.deleteText.comment + '</label><br /><label><input type="radio" id="confirm_opt2" name="confirm_opt" value="2"> '+ this.deleteText.thread + '</label></div>'; texts[4]=opt; var tl = $el.cumulativeOffset(el); var url1= el.rel; var url2 = opt ? $u.add_href(el.rel, 'all=1') : ''; dConfirm.show({ x: tl.left -10, y: tl.top-90-35 *(el.rev=='1'), type:'b_tail', text:dConfirm.wrap(texts), onOk:function () { dConfirm.hide(); document.location =(url2 ?($('confirm_opt1').checked?url1:url2):url1); } }); } }); var dSlider=$class({ el:null, fe:null, p:-1, pm:-1, z0:0, z1:1, z0e:null, z1e: null, z:null, onStart:function(p){}, onUpdate:function(p){}, onUpdateEnd:function(p){}, scope:null, constructor:function(config, scope) { this.z=[]; $config(this,config); this.scope=scope||this; if(!this.el || !this.fe){ return; } this.ww=this.el.offsetWidth-this.fe.offsetWidth+1; if(this.p!=-1){ var ex=this.v2px(this.p); this.fe.style.left=ex+'px'; this.pm=this.p; } $e.add(this.z0e,'click',this.zoom_prev,this); $e.add(this.z1e,'click',this.zoom_next,this); $e.add(this.el,'mousedown',this.start,this); }, v2px:function(v) { return this.ww*(v-this.z0)/(this.z1-this.z0); }, fit:function(ex) { var ww=this.ww; ex=ex<0?0:(ex>ww?ww:ex); var p=parseInt((this.z0+(this.z1-this.z0)*ex/ww)*1000)/1000; return p; }, start:function(el) { this.onStart.call(this.scope,this.pm); $e.add(document,'mousemove',this.drag,this); $e.add(document,'mouseup',this.stop,this); var wtl=$el.cumulativeOffset(this.el); this.wx=wtl.left; this.ww=this.el.offsetWidth-this.fe.offsetWidth+1; this.drag(el); }, drag:function(el) { var e=$e.e, ww=this.ww, ex= (e.pageX || (e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft))) - this.wx; ex=ex<0?0:(ex>ww?ww:ex); var p=parseInt((this.z0+(this.z1-this.z0)*ex/ww)*1000)/1000; if(p==this.pm) return; this.fe.style.left=ex+'px'; this.onUpdate.call(this.scope,this.pm=p); }, stop:function() { $e.del(document,'mouseup',this.stop,this); $e.del(document,'mousemove',this.drag,this); this.onUpdateEnd.call(this.scope,this.pm); this.interactive=false; }, zoom_next:function() { var z=this.z, p=this.pm; for(var i=0, n=z.length; i<n; i++) if(z[i]>p){ p=z[i]; break; } this.zoom(p); }, zoom_prev:function() { var z=this.z, p=this.pm; for(var i=z.length-1; i>=0; i--) if(z[i]<p){ p=z[i]; break; } this.zoom(p); }, zoom:function(p) { if(p==this.pm) return; var ex=this.ww*(p-this.z0)/(this.z1-this.z0); this.fe.style.left=ex+'px'; this.onUpdate.call(this.scope,this.pm=p); this.onUpdateEnd.call(this.scope,this.pm); } }); var EntryView=$class(dPage, { name:'Entry', ez:1, photo_count:0, cc_photos:null, fom:false, have_others:false, s_confirm_abuse:null, wrap:null, wrap2:null, ds:null, z_items:null, ozh:96, z0:0.5, z1:3.125, z:[0.5, 1, 2, 3.125], zoom_path:[48, 96, 192, 300, 300], init:function() { this.prev_z=this.zoom_path[this.ez<0.6?0:Math.ceil(this.ez)]; this.wrap=$('b_photos'); if(!this.wrap){ return; } this.z_items=$q.select(this.wrap, 'img'); if(this.fom && this.have_others){ this.wrap2=$('b_photos_other'); if(this.wrap2){ this.z_items=this.z_items.concat($q.select(this.wrap2, 'img')); if(!this.photo_count) $('slider_other').appendChild($('slider')); } } var def_w=this.ozh; for(var i=0, ez=this.ez, els=this.z_items, n=els.length; i<n; i++){ var el=els[i]; el._w=parseInt(el.width/ez)||def_w; el._id=el.parentNode.id; } this.ds=new dSlider({ el:$('scale'), fe:$('slide_me'), p:this.ez, z0:this.z0, z1:this.z1, z:this.z, z0e:$('zoom_out'), z1e:$('zoom_in'), onUpdate:this.zoom, onUpdateEnd:this.zoom_end, zoomNext:this.zoom_next, zoomPrev:this.zoom_prev }, this); if($('slideshow')){ if(Flash.init(9) && (Flash.version[0]>9 || (Flash.version[0]==9 && Flash.version[2]>=115))){ $('slideshow_flash').innerHTML=Flash.draw(JSRoot+'flash/slideshow.swf', "144", "16", "#fff", $('slideshow_params').value, true, "fSlideshow"); $el.addClassName($('slideshow'),'on'); }else{ $el.addClassName($('slideshow'),'bad-flash-ver'); } } var people=$('people_tagged'); if(people){ $e.add(people, 'mouseover', this.tag_over, this); $e.add(people, 'mouseout', this.tag_out, this); } $e.on({ '#tagsmore':this.load_tags, '#confirm_abuse':this.confirm_abuse }, this); }, zoom:function(p,items) { var w,h=p*this.ozh; for(var i=0, els=items||this.z_items, n=els.length; i<n; i++){ els[i].height=Math.ceil(h); els[i].width=p*els[i]._w; } }, zoom_end:function(p,items) { this.ez=p; var d=new Date(); d.setFullYear(5+d.getFullYear()); $u.set_cookie('ez',parseInt(p*100)/100,d,'/','.'+/[^.]+\.[^.]+$/.exec(location.host)); var z=(p<0.6?0:Math.ceil(p)); if(this.zoom_path[z]==this.prev_z) return; this.prev_z=this.zoom_path[z]; var i,m,id,src,cc, ccs=this.cc_photos, cc_i=({'2':0,'3':1,'4':1})[''+z], re=/_(\d+)(\.\w+(\?|$))/, re_cc=/(\?|&)cc=([^&]+)(&|$)/, new_size='_'+this.zoom_path[z]+'$2'; for(var j=0, els=items||this.z_items, n=els.length; j<n; j++){ i=els[j]; src=i.src.replace(re, new_size); if(src==i.src) continue; src=src.replace(re_cc,'$1').replace(/&$/,''); if(ccs && cc_i!=undefined) src+=(ccs[id=i._id] && ccs[id][cc_i] && ('&cc='+ccs[id][cc_i]) || ''); i.src=src; } }, zoom_end_one:function(i) { var p=this.ez, z=(p<0.6?0:Math.ceil(p)), w,h=p*this.ozh, m,id,src,cc, ccs=this.cc_photos, cc_i=({'2':0,'3':1,'4':1})[''+z], re=/_(\d+)(\.\w+(\?|$))/, re_cc=/(\?|&)cc=([^&]+)(&|$)/, new_size='_'+this.zoom_path[z]+'$2'; i.height=Math.ceil(h); i.width=p*i._w; src=i.src.replace(re, new_size); if(src==i.src) return; src=src.replace(re_cc,'$1').replace(/&$/,''); if(ccs && cc_i!=undefined) src+=(ccs[id=i._id] && ccs[id][cc_i] && ('&cc='+ccs[id][cc_i]) || ''); i.src=src; }, last_hovered:[], tag_over:function(el) { if(el.nodeName!='LI') el=$q.up(el,'li'); if(!el) return; var els=this.last_hovered, ids=el.id.split('_'); ids.shift(); for(var i=0, n=els.length; i<n; i++) $el.removeClassName(els[i],'hovered'); els=[]; for(var i=0, n=ids.length; i<n; i++) (el=$('i'+ids[i])) && (els[els.length]=el) && $el.addClassName(el,'hovered'); this.last_hovered=els; }, tag_out:function(el) { var els=this.last_hovered; for(var i=0, n=els.length; i<n; i++) $el.removeClassName(els[i],'hovered'); this.last_hovered=[]; }, load_tags:function(el) { this.load_tags_el=el.parentNode.parentNode; new $r(el.rev,{ ready:this.load_tags_done },this); }, load_tags_done:function(res) { $('people_tagged').innerHTML+=res.html; if(res.more) this.load_tags_el.parentNode.replaceChild($u.tpl2el(res.more),this.load_tags_el); else this.load_tags_el.parentNode.removeChild(this.load_tags_el); }, confirm_abuse:function(el) { if(!this.s_confirm_abuse) return true; var xy=$e.pointerXY($e.e); dConfirm.show({ x:(xy.x-24), y:(xy.y-115), type:'confirm_claim', text:dConfirm.wrap(this.s_confirm_abuse), onOk:this.abuse_redirect.bind(this,$u.add_href(el.href, 'confirm=1')), scope:this }); }, abuse_redirect:function(url) { window.location=url; } }); var Entry=new EntryView();