B.Comments=new $class(B.Page, { name: 'Comments', init:function() { if(!$('comments')) return; $e.on({ '.reply_anchor':this.reply, '.add_comment_anchor':this.add_comment }, this); if($('add_comment_form')){ $el.del($('add_comment_form'), 'editing'); }else{ if($('reply_form')){ $('reply_form').style.display = 'block'; } } }, reply:function(el) { if($el.has(el.parentNode, 'editing')){ $el.del(el.parentNode, 'editing'); $('reply_form').style.display = 'none'; }else{ if($el.has($('add_comment'), 'editing')) $el.del($('add_comment'), 'editing'); $el.del($('reply_form').parentNode, 'editing'); $el.add(el.parentNode, 'editing'); el.parentNode.appendChild($('reply_form')); $('reply_form').style.display = 'block'; } }, add_comment:function(el) { if($el.has($('add_comment'), 'editing')) { $el.del($('add_comment'), 'editing'); $('reply_form').style.display = 'none'; if($('no_comments_text')) $('no_comments_text').style.display = 'block'; }else{ if($el.has($('reply_form').parentNode, 'editing')) $el.del($('reply_form').parentNode, 'editing'); $el.add($('add_comment'), 'editing'); $('add_comment_form').appendChild($('reply_form')); if($('no_comments_text')) $('no_comments_text').style.display = 'none'; $('reply_form').style.display = 'block'; } } }); $u.Slider=$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, dir:'x', constructor:function(config, scope) { this.z=[]; $config(this,config); this.scope=scope||this; if(!this.el || !this.fe){ return; } if(this.dir=='y'){ this.prop='top', this.propget='offsetHeight', this.propset='top', this.getpos=this.getposy; }else{ this.prop='left', this.propget='offsetWidth', this.propset='marginLeft', this.getpos=this.getposx; if($el.dir()=='rtl'){ this.v2px=this.v2px_rtl; this.px2v=this.px2v_rtl; } } this.z0e && $e.add(this.z0e,'click',this.zoom_prev,this); this.z1e && $e.add(this.z1e,'click',this.zoom_next,this); $e.add(this.el,'mousedown',this.start,this); this.init(); }, init:function() { this.ww=this.el[this.propget]-this.fe[this.propget]+1; if(this.p!=-1){ var ex=this.v2px(this.p); this.fe.style[this.propset]=ex+'px'; this.pm=this.p; } }, getposx:function(e){ return e.pageX || (e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft)) }, getposy:function(e){ return e.pageY || (e.clientY + (document.documentElement.scrollTop || document.body.scrollTop)) }, v2px:function(v){ return this.ww*(v-this.z0)/(this.z1-this.z0); }, v2px_rtl:function(v){ return this.ww-this.ww*(v-this.z0)/(this.z1-this.z0); }, px2v:function(px){ return parseInt((this.z0+(this.z1-this.z0)*px/this.ww)*1000)/1000; }, px2v_rtl:function(px){ return parseInt((this.z0+(this.z1-this.z0)*(this.ww-px)/this.ww)*1000)/1000; }, 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[this.prop]; this.ww=this.el[this.propget]-this.fe[this.propget]+1; this.drag(el); }, drag:function(el) { var e=$e.e, p, ww=this.ww, ex=this.getpos(e) - this.wx; ex=ex<0?0:(ex>ww?ww:ex); p=this.px2v(ex); if(p==this.pm) return; this.fe.style[this.propset]=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.v2px(p); this.fe.style[this.propset]=ex+'px'; this.onUpdate.call(this.scope,this.pm=p); this.onUpdateEnd.call(this.scope,this.pm); } }); B.EntryView=$class(B.Page, { 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=$el.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($el.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 $u.Slider({ 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($u.flash.init(9) && ($u.flash.version[0]>9 || ($u.flash.version[0]==9 && $u.flash.version[2]>=115))){ $('slideshow_flash').innerHTML=$u.flash.draw(JSRoot+'flash/slideshow.swf', "144", "16", "#fff", $('slideshow_params').value, true, "fSlideshow"); $el.add($('slideshow'),'on'); }else{ $el.add($('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.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=$el.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.del(els[i],'hovered'); els=[]; for(var i=0, n=ids.length; i<n; i++) (el=$('i'+ids[i])) && (els[els.length]=el) && $el.add(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.del(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); $u.Confirm.show({ x:(xy.x-24), y:(xy.y-115), type:'confirm_claim', text: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; } }); B.Entry=new B.EntryView();
