Changeset 333:f080de4cad76
- Timestamp:
- 11/08/10 15:28:45 (12 months ago)
- Branch:
- default
- Tags:
- v1.0.5
- Location:
- src/cm
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/cm/media/js/client/c_client-min.js
r332 r333 1 _afterDlg=function(d){var a=d[0];var c=d[1];var b=d[2];a.call(c,b);};_abortNewCommentConfirmed=function(a){if(isICommentFormVisible()){if(gLayout.isInFrame()){gSync.hideICommentForm({fn:function(){_afterDlg(a);}});gSync.resume();}}};_abortNewReplyConfirmed=function(a){if(gNewReplyHost!=null){if(gLayout.isInFrame()){cancelNewReplyForm();_afterDlg(a);}}};_abortNewEditConfirmed=function(a){if(gEditICommentHost!=null){if(gLayout.isInFrame()){cancelEditForm();_afterDlg(a);}}};checkForOpenedDialog=function(e,b,d,c){var a=[];if(e!=null){a=CY.Array.map(gDb.getThreads([gDb.getComment(e.commentId)]),function(f){return f.id;});}if(isICommentFormVisible()||(gNewReplyHost!=null&&(e==null||CY.Array.indexOf(a,gNewReplyHost.commentId)!=-1))||(gEditICommentHost!=null&&(e==null||CY.Array.indexOf(a,gEditICommentHost.commentId)!=-1))){if(gLayout.isInFrame()){if(isICommentFormVisible()){parent.f_yesNoDialog(gettext("New comment will be canceled, continue?"),gettext("Warning"),null,null,null,_abortNewCommentConfirmed,this,[b,d,c]);}else{if(gNewReplyHost!=null){parent.f_yesNoDialog(gettext("Started reply will be canceled, continue?"),gettext("Warning"),null,null,null,_abortNewReplyConfirmed,this,[b,d,c]);}else{if(gEditICommentHost!=null){parent.f_yesNoDialog(gettext("Started comment edition will be canceled, continue?"),gettext("Warning"),null,null,null,_abortNewEditConfirmed,this,[b,d,c]);}}}}}else{b.call(d,[]);}};IComment=function(){this.commentId=null;var l=gLayout.getTopICommentsWidth();var a=gConf.iCommentLeftPadding;var r=gettext("change comment state to pending");var n=gettext("change comment state to approved");var e=gettext("change comment state to unapproved");var q=gettext("cancel changing the state of this comment");var c=gettext("pending");var d=gettext("approved");var m=gettext("unapproved");var b=gettext("cancel");var p=gettext("show replies");var s=gettext("change to:");var i=ngettext("reply","replies",1);var g=gettext("edit comment");var j=gettext("delete comment");var o=gettext("edit");var f=gettext("delete");var k=gettext("close");var h=gettext("show scope");var t=gettext("Comment is detached: it was created on a previous version and text it applied to has been modified or removed.");this.overlay=new CY.Overlay({zIndex:3,shim:false,visible:false,width:l,xy:[a,0],headerContent:'<div class="icomment-header"><div class="c-iactions"><a class="c-moderate c-action" title="">vis</a> <a class="c-edit c-action" title="'+g+'" alt="'+g+'">'+o+'</a> <a class="c-delete c-action" title="'+j+'" alt="'+j+'">'+f+'</a> </div><div class="c-state-actions displaynone">'+s+' <a class="c-state-pending c-action" title="'+r+'" alt="'+r+'">'+c+'</a> <a class="c-state-approved c-action" title="'+n+'" alt="'+n+'">'+d+'</a> <a class="c-state-unapproved c-action" title="'+e+'" alt="'+e+'">'+m+'</a> <a class="c-state-cancel c-action" title="'+q+'" alt="'+q+'">'+b+'</a> </div><div class="c-no-scope-msg">'+t+'</div><a class="c-show-scope c-action" title="'+h+'" alt="'+h+'"><em>-</em></a><a class="c-close c-action" title="'+k+'" alt="'+k+'"><em>X</em></a></div>',bodyContent:'<div class="icomment-body"><span class="c-content"></span><span class="c-ireplyactions"><a class="c-readreplies c-action" title="'+p+'" alt="'+p+'">'+p+'</a> <a class="c-reply c-action" title="'+i+'" alt="'+i+'">'+i+"</a> </span></div>"});this.overlay.get("contentBox").addClass("c-comment");this.overlay.render("#leftcolumn");this.animation=new CY.Anim({node:this.overlay.get("boundingBox"),duration:gPrefs.get("general","animduration"),easing:CY.Easing.easeOut});this.overlay.get("contentBox").query(".c-close").on("click",this.onCloseCommentClick,this);this.overlay.get("contentBox").query(".c-moderate").on("click",this.onModerateCommentClick,this);this.overlay.get("contentBox").query(".c-state-pending").on("click",this.onPendingCommentClick,this);this.overlay.get("contentBox").query(".c-state-approved").on("click",this.onApprovedCommentClick,this);this.overlay.get("contentBox").query(".c-state-unapproved").on("click",this.onUnapprovedCommentClick,this);this.overlay.get("contentBox").query(".c-state-cancel").on("click",this.onCancelStateChangeClick,this);this.overlay.get("contentBox").query(".c-edit").on("click",this.onEditCommentClick,this);this.overlay.get("contentBox").query(".c-delete").on("click",this.onDeleteCommentClick,this);this.overlay.get("contentBox").query(".c-reply").on("click",this.onReplyCommentClick,this);this.overlay.get("contentBox").query(".c-readreplies").on("click",this.onReadRepliesCommentClick,this);this.overlay.get("contentBox").query(".icomment-header").on("mouseenter",this.onMouseEnterHeader,this);this.overlay.get("contentBox").query(".icomment-header").on("mouseleave",this.onMouseLeaveHeader,this);this.overlay.get("contentBox").on("click",this.onCommentClick,this);};IComment.prototype={onCloseCommentClick:function(a){a.halt();if(readyForAction()&&this.isVisible()){gSync.closeComment(this);}},onModerateCommentClick:function(a){a.halt();if(readyForAction()&&this.isVisible()){this.overlay.get("contentBox").query(".c-iactions").addClass("displaynone");this.overlay.get("contentBox").query(".c-state-actions").removeClass("displaynone");}},onPendingCommentClick:function(a){a.halt();if(readyForAction()&&this.isVisible()){gSync.moderateComment(this,"pending");}},onApprovedCommentClick:function(a){a.halt();if(readyForAction()&&this.isVisible()){gSync.moderateComment(this,"approved");}},onUnapprovedCommentClick:function(a){a.halt();if(readyForAction()&&this.isVisible()){gSync.moderateComment(this,"unapproved");}},onCancelStateChangeClick:function(a){a.halt();if(readyForAction()&&this.isVisible()){this.overlay.get("contentBox").query(".c-iactions").removeClass("displaynone");this.overlay.get("contentBox").query(".c-state-actions").addClass("displaynone");}},onDeleteCommentClick:function(a){a.halt();if(readyForAction()&&this.isVisible()){gSync.removeComment(this);}},onEditCommentClick:function(a){a.halt();if(readyForAction()&&this.isVisible()){gSync.showEditForm(this);}},onReplyCommentClick:function(a){a.halt();if(readyForAction()&&this.isVisible()){gSync.showReplyForm(this);}},onReadRepliesCommentClick:function(a){a.halt();if(readyForAction()&&this.isVisible()){gSync.openComment(this);}},onCommentClick:function(d){if(readyForAction()&&this.isVisible()){if(d.target.get("target")=="_blank"){var b=d.target;var g=sv_site_url+sv_text_view_show_comment_url;if(b.get("href").indexOf(g)==0){var a=(new RegExp("comment_id_key=([^&]*)","g"))c(b.get("href"));if(a!=null){var c=a[1];var f=gDb.getCommentByIdKey(c);if(f!=null){d.halt();if(!b.hasClass("c-permalink")){checkForOpenedDialog(null,function(){gSync.showSingleComment(f);});}}}}}else{if(gShowingAllComments){if(!this._isHostingAForm()){var f=gDb.getComment(this.commentId);checkForOpenedDialog(null,function(){if(f!=null){gSync.showSingleComment(f);}});}}else{gSync.activate(this);}}}},onMouseEnterHeader:function(){if(readyForAction()&&this.isVisible()&&(sv_prefix=="")){this.overlay.get("contentBox").query(".c-permalink").removeClass("displaynone");}},onMouseLeaveHeader:function(){if(readyForAction()&&this.isVisible()&&(sv_prefix=="")){this.overlay.get("contentBox").query(".c-permalink").addClass("displaynone");}},setWidth:function(a){this.overlay.get("boundingBox").setStyle("width",a+"px");},activate:function(){this.overlay.get("boundingBox").addClass("c-focus-comment");},deactivate:function(){this.overlay.get("boundingBox").removeClass("c-focus-comment");},hide:function(){if(gIComments.isTopActive(this.commentId)){if(!gIComments.activateVisibleNext()){gIComments.deactivate();}}if(this.isVisible()){this.overlay.hide();this.overlay.blur();}},hideContent:function(){this.overlay.get("contentBox").query(".icomment-header").addClass("displaynone");this.overlay.get("contentBox").query(".icomment-body").addClass("displaynone");},showContent:function(){this.overlay.get("contentBox").query(".icomment-header").removeClass("displaynone");this.overlay.get("contentBox").query(".icomment-body").removeClass("displaynone");},isVisible:function(){return this.overlay.get("visible");},show:function(){this.hideReadRepliesLnk();return this.overlay.show();},showReadRepliesLnk:function(){this.overlay.get("contentBox").query(".c-readreplies").removeClass("displaynone");},hideReadRepliesLnk:function(){this.overlay.get("contentBox").query(".c-readreplies").addClass("displaynone");},changeModeration:function(b){var a=this.overlay.get("contentBox").query(".c-moderate");a.set("innerHTML",gettext(b.state));a.removeClass("c-state-approved");a.removeClass("c-state-pending");a.removeClass("c-state-unapproved");a.addClass("c-state-"+b.state);this.overlay.get("contentBox").query(".c-iactions").removeClass("displaynone");this.overlay.get("contentBox").query(".c-state-actions").addClass("displaynone");},isfetched:function(){return(this.commentId!=null);},unfetch:function(){this.commentId=null;},fetch:function(h){this.commentId=h.id;var b=this.overlay.get("boundingBox");if(h.start_wrapper!=-1){b.addClass("c-has-scope");b.removeClass("c-has-no-scope");}else{b.addClass("c-has-no-scope");b.removeClass("c-has-scope");}if(h.reply_to_id!=null){b.addClass("c-is-reply");}else{b.removeClass("c-is-reply");}var f=interpolate(gettext("last modified on %(date)s"),{date:h.modified_user_str},true);var k=(h.modified==h.created)?"":'<a title="'+f+'"> * </a>';var i=gettext("Permalink to this comment");var n="";if(sv_prefix==""){n='<a class="c-permalink displaynone c-action" target="_blank" title="'+i+'" href="/" >¶ </a>';}var j=interpolate(gettext("by %(name)s, created on %(date)s"),{name:h.name,date:h.created_user_str},true);var c='<span class="c-header"><div class="c-header-title">'+h.title+n+'</div><div class="c-infos">'+j+"</div></span>";var d=CY.Node.create(c);var o=b.query(".c-header");if(o==null){b.query(".icomment-header").insertBefore(d,b.one(".c-iactions"));}else{o.get("parentNode").replaceChild(d,o);}var g=CY.Node.create('<div class="c-tags"><span class="c-tags-infos">tags:</span>'+h.tags+"</div>");var m=b.query(".c-tags");if(m==null){b.query(".icomment-header").appendChild(g);}else{m.get("parentNode").replaceChild(g,m);}if(h.tags==""){g.addClass("displaynone");}var e=CY.Node.create('<span class="c-content">'+h.content_html+"</span>");var a=b.query(".c-content");if(a==null){b.query(".icomment-body").appendChild(e);}else{a.get("parentNode").replaceChild(e,a);}if(sv_prefix==""){b.query(".c-permalink").set("href",sv_site_url+h.permalink);}this.changeModeration(h);var l=b.queryAll(".c-content a");if(l!=null){l.setAttribute("target","_blank");}l=b.queryAll(".c-header-title a");if(l!=null){l.setAttribute("target","_blank");}this.permAdapt(h);},permAdapt:function(e){var b=this.overlay.get("contentBox").query(".c-delete");if(b){if(!e.can_delete){b.addClass("displaynone");}else{b.removeClass("displaynone");}}var a=this.overlay.get("contentBox").query(".c-edit");if(a){if(!e.can_edit){a.addClass("displaynone");}else{a.removeClass("displaynone");}}var d=this.overlay.get("contentBox").query(".c-reply");if(d){if(!hasPerm("can_create_comment")){d.addClass("displaynone");}else{d.removeClass("displaynone");}}var c=this.overlay.get("contentBox").query(".c-moderate");if(c){if(!e.can_moderate){c.addClass("displaynone");}else{c.removeClass("displaynone");}}},setThreadPad:function(a){this.overlay.get("contentBox").query(".yui-widget-hd").setStyle("paddingLeft",a+"px");this.overlay.get("contentBox").query(".yui-widget-bd").setStyle("paddingLeft",a+"px");},setPosition:function(b){var a=this.overlay.get("boundingBox");a.setStyle("opacity",1);a.setXY(b);},getPosition:function(b){var a=this.overlay.get("boundingBox");return a.getXY();},onAnimationEnd:function(){if(!CY.Lang.isUndefined(this["animation-handle"])&&!CY.Lang.isNull(this["animation-handle"])){this["animation-handle"].detach();this["animation-handle"]=null;}gIComments.signalAnimationEnd();if(gIComments.animationsEnded()){gIComments.whenAnimationsEnd();}},onAnimationEndFocus:function(){if(!CY.Lang.isUndefined(this["animation-handle"])&&!CY.Lang.isNull(this["animation-handle"])){this["animation-handle"].detach();this["animation-handle"]=null;}gIComments.signalAnimationEnd();if(gIComments.animationsEnded()){gIComments.whenAnimationsEndFocus();}},setAnimationToPosition:function(c,a){var b=this.overlay.get("boundingBox");if(gPrefs.get("general","animduration")<0.011){b.setXY(c);}this.animation.set("to",{xy:c});this.animation.set("duration",gPrefs.get("general","animduration"));if(a){this["animation-handle"]=this.animation.on("end",this.onAnimationEndFocus,this);}else{this["animation-handle"]=this.animation.on("end",this.onAnimationEnd,this);}return this.animation;},getHeight:function(){return this.overlay.get("boundingBox").get("offsetHeight");},scrollIntoView:function(){if(!this.overlay.get("contentBox").inViewportRegion()){this.overlay.get("contentBox").scrollIntoView(true);}},_isHostingAForm:function(){return(this.isVisible()&&((gNewReplyHost!=null&&gNewReplyHost==this)||(gEditICommentHost!=null&&gEditICommentHost==this)));}};hasPerm=function(a){return(-1!=CY.Array.indexOf(sv_user_permissions,a));};_afterDlg=function(g){var f=g[0];var h=g[1];var e=g[2];f.call(h,e);};_abortNewCommentConfirmed=function(b){if(isICommentFormVisible()){if(gLayout.isInFrame()){gSync.hideICommentForm({fn:function(){_afterDlg(b);}});gSync.resume();}}};_abortNewReplyConfirmed=function(b){if(gNewReplyHost!=null){if(gLayout.isInFrame()){cancelNewReplyForm();_afterDlg(b);}}};_abortNewEditConfirmed=function(b){if(gEditICommentHost!=null){if(gLayout.isInFrame()){cancelEditForm();_afterDlg(b);}}};checkForOpenedDialog=function(h,f,i,j){var g=[];if(h!=null){g=CY.Array.map(gDb.getThreads([gDb.getComment(h.commentId)]),function(a){return a.id;});}if(isICommentFormVisible()||(gNewReplyHost!=null&&(h==null||CY.Array.indexOf(g,gNewReplyHost.commentId)!=-1))||(gEditICommentHost!=null&&(h==null||CY.Array.indexOf(g,gEditICommentHost.commentId)!=-1))){if(gLayout.isInFrame()){if(isICommentFormVisible()){parent.f_yesNoDialog(gettext("New comment will be canceled, continue?"),gettext("Warning"),null,null,null,_abortNewCommentConfirmed,this,[f,i,j]);}else{if(gNewReplyHost!=null){parent.f_yesNoDialog(gettext("Started reply will be canceled, continue?"),gettext("Warning"),null,null,null,_abortNewReplyConfirmed,this,[f,i,j]);}else{if(gEditICommentHost!=null){parent.f_yesNoDialog(gettext("Started comment edition will be canceled, continue?"),gettext("Warning"),null,null,null,_abortNewEditConfirmed,this,[f,i,j]);}}}}}else{f.call(i,[]);}};IComment=function(){this.commentId=null;var C=gLayout.getTopICommentsWidth();var N=gConf.iCommentLeftPadding;var w=gettext("change comment state to pending");var A=gettext("change comment state to approved");var J=gettext("change comment state to unapproved");var x=gettext("cancel changing the state of this comment");var L=gettext("pending");var K=gettext("approved");var B=gettext("unapproved");var M=gettext("cancel");var y=gettext("show replies");var v=gettext("change to:");var F=ngettext("reply","replies",1);var H=gettext("edit comment");var E=gettext("delete comment");var z=gettext("edit");var I=gettext("delete");var D=gettext("close");var G=gettext("show scope");var u=gettext("Comment is detached: it was created on a previous version and text it applied to has been modified or removed.");this.overlay=new CY.Overlay({zIndex:3,shim:false,visible:false,width:C,xy:[N,0],headerContent:'<div class="icomment-header"><div class="c-iactions"><a class="c-moderate c-action" title="">vis</a> <a class="c-edit c-action" title="'+H+'" alt="'+H+'">'+z+'</a> <a class="c-delete c-action" title="'+E+'" alt="'+E+'">'+I+'</a> </div><div class="c-state-actions displaynone">'+v+' <a class="c-state-pending c-action" title="'+w+'" alt="'+w+'">'+L+'</a> <a class="c-state-approved c-action" title="'+A+'" alt="'+A+'">'+K+'</a> <a class="c-state-unapproved c-action" title="'+J+'" alt="'+J+'">'+B+'</a> <a class="c-state-cancel c-action" title="'+x+'" alt="'+x+'">'+M+'</a> </div><div class="c-no-scope-msg">'+u+'</div><a class="c-show-scope c-action" title="'+G+'" alt="'+G+'"><em>-</em></a><a class="c-close c-action" title="'+D+'" alt="'+D+'"><em>X</em></a></div>',bodyContent:'<div class="icomment-body"><span class="c-content"></span><span class="c-ireplyactions"><a class="c-readreplies c-action" title="'+y+'" alt="'+y+'">'+y+'</a> <a class="c-reply c-action" title="'+F+'" alt="'+F+'">'+F+"</a> </span></div>"});this.overlay.get("contentBox").addClass("c-comment");this.overlay.render("#leftcolumn");this.animation=new CY.Anim({node:this.overlay.get("boundingBox"),duration:gPrefs.get("general","animduration"),easing:CY.Easing.easeOut});this.overlay.get("contentBox").query(".c-close").on("click",this.onCloseCommentClick,this);this.overlay.get("contentBox").query(".c-moderate").on("click",this.onModerateCommentClick,this);this.overlay.get("contentBox").query(".c-state-pending").on("click",this.onPendingCommentClick,this);this.overlay.get("contentBox").query(".c-state-approved").on("click",this.onApprovedCommentClick,this);this.overlay.get("contentBox").query(".c-state-unapproved").on("click",this.onUnapprovedCommentClick,this);this.overlay.get("contentBox").query(".c-state-cancel").on("click",this.onCancelStateChangeClick,this);this.overlay.get("contentBox").query(".c-edit").on("click",this.onEditCommentClick,this);this.overlay.get("contentBox").query(".c-delete").on("click",this.onDeleteCommentClick,this);this.overlay.get("contentBox").query(".c-reply").on("click",this.onReplyCommentClick,this);this.overlay.get("contentBox").query(".c-readreplies").on("click",this.onReadRepliesCommentClick,this);this.overlay.get("contentBox").query(".icomment-header").on("mouseenter",this.onMouseEnterHeader,this);this.overlay.get("contentBox").query(".icomment-header").on("mouseleave",this.onMouseLeaveHeader,this);this.overlay.get("contentBox").on("click",this.onCommentClick,this);};IComment.prototype={onCloseCommentClick:function(b){b.halt();if(readyForAction()&&this.isVisible()){gSync.closeComment(this);}},onModerateCommentClick:function(b){b.halt();if(readyForAction()&&this.isVisible()){this.overlay.get("contentBox").query(".c-iactions").addClass("displaynone");this.overlay.get("contentBox").query(".c-state-actions").removeClass("displaynone");}},onPendingCommentClick:function(b){b.halt();if(readyForAction()&&this.isVisible()){gSync.moderateComment(this,"pending");}},onApprovedCommentClick:function(b){b.halt();if(readyForAction()&&this.isVisible()){gSync.moderateComment(this,"approved");}},onUnapprovedCommentClick:function(b){b.halt();if(readyForAction()&&this.isVisible()){gSync.moderateComment(this,"unapproved");}},onCancelStateChangeClick:function(b){b.halt();if(readyForAction()&&this.isVisible()){this.overlay.get("contentBox").query(".c-iactions").removeClass("displaynone");this.overlay.get("contentBox").query(".c-state-actions").addClass("displaynone");}},onDeleteCommentClick:function(b){b.halt();if(readyForAction()&&this.isVisible()){gSync.removeComment(this);}},onEditCommentClick:function(b){b.halt();if(readyForAction()&&this.isVisible()){gSync.showEditForm(this);}},onReplyCommentClick:function(b){b.halt();if(readyForAction()&&this.isVisible()){gSync.showReplyForm(this);}},onReadRepliesCommentClick:function(b){b.halt();if(readyForAction()&&this.isVisible()){gSync.openComment(this);}},onCommentClick:function(k){if(readyForAction()&&this.isVisible()){if(k.target.get("target")=="_blank"){var e=k.target;var i=sv_site_url+sv_text_view_show_comment_url;if(e.get("href").indexOf(i)==0){var h=(new RegExp("comment_id_key=([^&]*)","g"))c(e.get("href"));if(h!=null){var l=h[1];var j=gDb.getCommentByIdKey(l);if(j!=null){k.halt();if(!e.hasClass("c-permalink")){checkForOpenedDialog(null,function(){gSync.showSingleComment(j);});}}}}}else{if(gShowingAllComments){if(!this._isHostingAForm()){var j=gDb.getComment(this.commentId);checkForOpenedDialog(null,function(){if(j!=null){gSync.showSingleComment(j);}});}}else{gSync.activate(this);}}}},onMouseEnterHeader:function(){if(readyForAction()&&this.isVisible()&&(sv_prefix=="")){this.overlay.get("contentBox").query(".c-permalink").removeClass("displaynone");}},onMouseLeaveHeader:function(){if(readyForAction()&&this.isVisible()&&(sv_prefix=="")){this.overlay.get("contentBox").query(".c-permalink").addClass("displaynone");}},setWidth:function(b){this.overlay.get("boundingBox").setStyle("width",b+"px");},activate:function(){this.overlay.get("boundingBox").addClass("c-focus-comment");},deactivate:function(){this.overlay.get("boundingBox").removeClass("c-focus-comment");},hide:function(){if(gIComments.isTopActive(this.commentId)){if(!gIComments.activateVisibleNext()){gIComments.deactivate();}}if(this.isVisible()){this.overlay.hide();this.overlay.blur();}},hideContent:function(){this.overlay.get("contentBox").query(".icomment-header").addClass("displaynone");this.overlay.get("contentBox").query(".icomment-body").addClass("displaynone");},showContent:function(){this.overlay.get("contentBox").query(".icomment-header").removeClass("displaynone");this.overlay.get("contentBox").query(".icomment-body").removeClass("displaynone");},isVisible:function(){return this.overlay.get("visible");},show:function(){this.hideReadRepliesLnk();return this.overlay.show();},showReadRepliesLnk:function(){this.overlay.get("contentBox").query(".c-readreplies").removeClass("displaynone");},hideReadRepliesLnk:function(){this.overlay.get("contentBox").query(".c-readreplies").addClass("displaynone");},changeModeration:function(c){var d=this.overlay.get("contentBox").query(".c-moderate");d.set("innerHTML",gettext(c.state));d.removeClass("c-state-approved");d.removeClass("c-state-pending");d.removeClass("c-state-unapproved");d.addClass("c-state-"+c.state);this.overlay.get("contentBox").query(".c-iactions").removeClass("displaynone");this.overlay.get("contentBox").query(".c-state-actions").addClass("displaynone");},isfetched:function(){return(this.commentId!=null);},unfetch:function(){this.commentId=null;},fetch:function(w){this.commentId=w.id;var C=this.overlay.get("boundingBox");if(w.start_wrapper!=-1){C.addClass("c-has-scope");C.removeClass("c-has-no-scope");}else{C.addClass("c-has-no-scope");C.removeClass("c-has-scope");}if(w.reply_to_id!=null){C.addClass("c-is-reply");}else{C.removeClass("c-is-reply");}var y=interpolate(gettext("last modified on %(date)s"),{date:w.modified_user_str},true);var t=(w.modified==w.created)?"":'<a title="'+y+'"> * </a>';var v=gettext("Permalink to this comment");var q="";if(sv_prefix==""){q='<a class="c-permalink displaynone c-action" target="_blank" title="'+v+'" href="/" >¶ </a>';}var u=interpolate(gettext("by %(name)s, created on %(date)s"),{name:w.name,date:w.created_user_str},true);var B='<span class="c-header"><div class="c-header-title">'+w.title+q+'</div><div class="c-infos">'+u+"</div></span>";var A=CY.Node.create(B);var p=C.query(".c-header");if(p==null){C.query(".icomment-header").insertBefore(A,C.one(".c-iactions"));}else{p.get("parentNode").replaceChild(A,p);}var x=CY.Node.create('<div class="c-tags"><span class="c-tags-infos">tags:</span>'+w.tags+"</div>");var r=C.query(".c-tags");if(r==null){C.query(".icomment-header").appendChild(x);}else{r.get("parentNode").replaceChild(x,r);}if(w.tags==""){x.addClass("displaynone");}var z=CY.Node.create('<span class="c-content">'+w.content_html+"</span>");var D=C.query(".c-content");if(D==null){C.query(".icomment-body").appendChild(z);}else{D.get("parentNode").replaceChild(z,D);}if(sv_prefix==""){C.query(".c-permalink").set("href",sv_site_url+w.permalink);}this.changeModeration(w);var s=C.queryAll(".c-content a");if(s!=null){s.setAttribute("target","_blank");}s=C.queryAll(".c-header-title a");if(s!=null){s.setAttribute("target","_blank");}this.permAdapt(w);},permAdapt:function(h){var f=this.overlay.get("contentBox").query(".c-delete");if(f){if(!h.can_delete){f.addClass("displaynone");}else{f.removeClass("displaynone");}}var g=this.overlay.get("contentBox").query(".c-edit");if(g){if(!h.can_edit){g.addClass("displaynone");}else{g.removeClass("displaynone");}}var i=this.overlay.get("contentBox").query(".c-reply");if(i){if(!hasPerm("can_create_comment")){i.addClass("displaynone");}else{i.removeClass("displaynone");}}var j=this.overlay.get("contentBox").query(".c-moderate");if(j){if(!h.can_moderate){j.addClass("displaynone");}else{j.removeClass("displaynone");}}},setThreadPad:function(b){this.overlay.get("contentBox").query(".yui-widget-hd").setStyle("paddingLeft",b+"px");this.overlay.get("contentBox").query(".yui-widget-bd").setStyle("paddingLeft",b+"px");},setPosition:function(c){var d=this.overlay.get("boundingBox");d.setStyle("opacity",1);d.setXY(c);},getPosition:function(c){var d=this.overlay.get("boundingBox");return d.getXY();},onAnimationEnd:function(){if(!CY.Lang.isUndefined(this["animation-handle"])&&!CY.Lang.isNull(this["animation-handle"])){this["animation-handle"].detach();this["animation-handle"]=null;}gIComments.signalAnimationEnd();if(gIComments.animationsEnded()){gIComments.whenAnimationsEnd();}},onAnimationEndFocus:function(){if(!CY.Lang.isUndefined(this["animation-handle"])&&!CY.Lang.isNull(this["animation-handle"])){this["animation-handle"].detach();this["animation-handle"]=null;}gIComments.signalAnimationEnd();if(gIComments.animationsEnded()){gIComments.whenAnimationsEndFocus();}},setAnimationToPosition:function(f,e){var d=this.overlay.get("boundingBox");if(gPrefs.get("general","animduration")<0.011){d.setXY(f);}this.animation.set("to",{xy:f});this.animation.set("duration",gPrefs.get("general","animduration"));if(e){this["animation-handle"]=this.animation.on("end",this.onAnimationEndFocus,this);}else{this["animation-handle"]=this.animation.on("end",this.onAnimationEnd,this);}return this.animation;},getHeight:function(){return this.overlay.get("boundingBox").get("offsetHeight");},scrollIntoView:function(){if(!this.overlay.get("contentBox").inViewportRegion()){this.overlay.get("contentBox").scrollIntoView(true);}},_isHostingAForm:function(){return(this.isVisible()&&((gNewReplyHost!=null&&gNewReplyHost==this)||(gEditICommentHost!=null&&gEditICommentHost==this)));}};hasPerm=function(b){return(-1!=CY.Array.indexOf(sv_user_permissions,b));};paintCommentScope=function(b){if(b.reply_to_id==null&&b.start_wrapper!=-1){var a={start:{elt:document.getElementById("sv_"+b.start_wrapper),offset:b.start_offset},end:{elt:document.getElementById("sv_"+b.end_wrapper),offset:b.end_offset}};if(document.getElementById("sv_"+b.start_wrapper)==null){warn_server({from:"paintCommentScope",start_wrapper:b.start_wrapper});}else{if(document.getElementById("sv_"+b.end_wrapper)==null){warn_server({from:"paintCommentScope",end_wrapper:b.end_wrapper});}else{a.start=_convertSelectionFromCSToCC(a.start);a.end=_convertSelectionFromCSToCC(a.end);renderComment(a,b.id);}}}};getCommentIdsFromClasses=function(b){var a=[];var e=b.className.split(" ");for(var d=0,c=e.length;d<c;d++){if(e[d].indexOf("c-id-")==0){a.push(parseInt(e[d].substring("c-id-".length)));}}return a;};renderComment=function(d,c){var a=d.start["offset"];var b=d.end["offset"];var f=d.start["elt"];var e=d.end["elt"];if((f!=null)&&(e!=null)&&_getTextNodeContent(f)!=""&&_getTextNodeContent(e)!=""){markWholeNodesAsComments(f,e,c);markEndsAsComments(f,a,e,b,c);}};markWholeNodesAsComments=function(d,c,b){var a=_findCommonAncestor(d,c);_dynSpanToAnc(d,a,b,false);_dynSpanToAnc(c,a,b,true);_dynSpanInBetween(a,d,c,b);};_setTextNodeContent=function(a,b){CY.DOM.setText(a,b);};_getTextNodeContent=function(a){return CY.DOM.getText(a);};markEndsAsComments=function(d,i,l,j,h){var n=_getTextNodeContent(d).substring(0,i);var o=_getTextNodeContent(d).substring(i);var p=_getTextNodeContent(l).substring(0,j);var g=_getTextNodeContent(l).substring(j);var b=(d===l);if(o!=""){if(CY.DOM.hasClass(d,"c-c")){var f=null,k=null,c=null,a=null;var m=(b)?_getTextNodeContent(d).substring(i,j):o;if(b&&(g!="")){c=d;f=c;}if(m!=""){if(f==null){k=d;}else{k=_yuiCloneNode(d);f.parentNode.insertBefore(k,f);}f=k;}if(n!=""){if(f==null){a=d;}else{a=_yuiCloneNode(d);f.parentNode.insertBefore(a,f);}f=a;}if(c!=null){_setTextNodeContent(c,g);}if(k!=null){_setTextNodeContent(k,m);_addIdClass(k,h);}if(a!=null){_setTextNodeContent(a,n);}}}if((!b)&&(p!="")){if(CY.DOM.hasClass(l,"c-c")){var f=null,e=null,c=null;if(g!=""){c=l;f=l;}if(p!=""){if(f==null){e=l;}else{e=_yuiCloneNode(l);f.parentNode.insertBefore(e,f);}f=e;}if(c!=null){_setTextNodeContent(c,g);}if(e!=null){_addIdClass(e,h);_setTextNodeContent(e,p);}}}};_yuiCloneNode=function(b){var a=CY.Node.getDOMNode(CY.get("#"+b.id).cloneNode(true));a.id=CY.guid();return a;};_dynSpanToAnc=function(a,e,d,f){var g=a;while((g!=null)&&(g!==e)&&(g.parentNode!==e)){var b=null;if(f){b=g.previousSibling;}else{b=g.nextSibling;}if(b==null){g=g.parentNode;}else{g=b;_recAddComment(g,d);}}};_dynSpanInBetween=function(g,h,f,d){var b=h;var e=null;while(b){if(b.parentNode===g){e=b;break;}b=b.parentNode;}if(e!=null){b=f;var c=null;while(b){if(b.parentNode===g){c=b;break;}b=b.parentNode;}if(c!=null){b=e.nextSibling;while((b!=null)&&(b!==c)){_recAddComment(b,d);b=b.nextSibling;}}}};_bruteContains=function(a,b){while(b){if(a===b){return true;}b=b.parentNode;}return false;},_addIdClass=function(a,b){CY.DOM.addClass(a,"c-id-"+b);_updateCommentCounter(a);};_removeIdClass=function(a,b){CY.DOM.removeClass(a,"c-id-"+b);_updateCommentCounter(a);};_removeIdClasses=function(a){var b=_cgetRegExp("(?:^|\\s+)c-id-(?:\\d+)","g");a.className=a.className.replace(b," ");_updateCommentCounter(a);};_recAddComment=function(a,b){if(CY.DOM.hasClass(a,"c-c")){_addIdClass(a,b);}else{var d=a.firstChild;while(d!=null){_recAddComment(d,b);d=d.nextSibling;}}};_findCommonAncestor=function(c,a){if(_bruteContains(c,a)){return c;}else{var b=a;while((b!=null)&&!_bruteContains(b,c)){b=b.parentNode;}return b;}};_cregexCache={};_cgetRegExp=function(b,a){a=a||"";if(!_cregexCache[b+a]){_cregexCache[b+a]=new RegExp(b,a);}return _cregexCache[b+a];};_updateCommentCounter=function(b){var c=_cgetRegExp("(?:^|\\s+)c-id-(?:\\d+)","g");var d=b.className.match(c);var a=(d==null)?0:d.length;c=_cgetRegExp("(?:^|\\s+)c-count-(?:\\d+)","g");b.className=b.className.replace(c," ");CY.DOM.addClass(b,"c-count-"+a+" ");};_convertSelectionFromCCToCS=function(b){var d=b.offset;var a=b.elt.parentNode;var c=b.elt.previousSibling;while(c!=null){d+=_getTextNodeContent(c).length;c=c.previousSibling;}return{elt:a,offset:d};};_convertSelectionFromCSToCC=function(d){var a={elt:null,offset:-1};var f=null;var e=d.elt.firstChild;var c=0;while(e!=null){var b=c;c+=_getTextNodeContent(e).length;if(c>=d.offset){a.elt=e;a.offset=d.offset-b;break;}e=e.nextSibling;}return a;};unpaintCommentScope=function(k){var j=k.id;var r="c-id-"+j;var m=[];var t=CY.all("."+r);if(t!=null){for(var h=0,d=t.size();h<d;h++){var q=t.item(h);if(q.hasClass("c-c")){var l=CY.Node.getDOMNode(q);_removeIdClass(l,j);var f=getCommentIdsFromClasses(l);quicksort(f);var a=q.get("previousSibling");if(a!=null){var b=CY.Node.getDOMNode(a);var s=getCommentIdsFromClasses(b);quicksort(s);if(areSortedArraysEqual(f,s)){_setTextNodeContent(l,_getTextNodeContent(b)+_getTextNodeContent(l));m.push(b);}}var e=q.get("nextSibling");if(e!=null){var o=CY.Node.getDOMNode(e);var g=getCommentIdsFromClasses(o);quicksort(g);if(areSortedArraysEqual(f,g)){l.firstChild.data=l.firstChild.data+o.firstChild.data;m.push(o);}}}else{alert("HAS NO c-c ? : "+commentNode.get("id")+" , innerHTML :"+commentNode.get("innerHTML"));return;}}}for(var h=0,d=m.length;h<d;h++){m[h].parentNode.removeChild(m[h]);}};unpaintAllComments=function(){var k=CY.all(".c-s");var f=[];for(var e=0,a=k.size();e<a;e++){var h=k.item(e);var d=h.get("firstChild");var j=CY.Node.getDOMNode(h.get("firstChild"));_removeIdClasses(j);var b=d.get("nextSibling");while(b!=null){var g=CY.Node.getDOMNode(b);j.firstChild.data=j.firstChild.data+g.firstChild.data;f.push(g);b=b.get("nextSibling");}}for(var e=0,a=f.length;e<a;e++){f[e].parentNode.removeChild(f[e]);}};showScope=function(b){var a=CY.all(".c-id-"+b);if(a!=null){a.addClass("c-scope");}};hideScopeAnyway=function(){var a=CY.all(".c-scope");if(a!=null){a.removeClass("c-scope");}};getWrapperAncestor=function(a){var b=a;while(b!=null){if(CY.DOM.hasClass(b,"c-s")){return b;}b=b.parentNode;}return null;};hasWrapperAncestor=function(a){return(getWrapperAncestor(a)!=null);};getSelectionInfo=function(){var J=null,m=null,D=0,c=0,h="";if(window.getSelection){var r=window.getSelection();if(r.rangeCount>0){var l=r.getRangeAt(0);h=l.toString();if(h!=""){var E=document.createRange();E.setStart(r.anchorNode,r.anchorOffset);E.collapse(true);var B=document.createRange();B.setEnd(r.focusNode,r.focusOffset);B.collapse(false);var I=(B.compareBoundaryPoints(2,E)==1);J=(I)?r.anchorNode.parentNode:r.focusNode.parentNode;innerStartNode=(I)?r.anchorNode:r.focusNode;m=(I)?r.focusNode.parentNode:r.anchorNode.parentNode;innerEndNode=(I)?r.focusNode:r.anchorNode;D=(I)?r.anchorOffset:r.focusOffset;c=(I)?r.focusOffset:r.anchorOffset;if(!hasWrapperAncestor(m)&&hasWrapperAncestor(J)){var z=document.createRange();z.setStart(innerStartNode,D);var b=getWrapperAncestor(J);var q=b;z.setEndAfter(q);var f=parseInt(b.id.substring("sv_".length));while(z.toString().length<l.toString().length){f++;var t=CY.get("#sv_"+f);if(t){q=CY.Node.getDOMNode(t);z.setEndAfter(q);}else{break;}}m=q.lastChild;c=CY.DOM.getText(m).length;}else{if(!hasWrapperAncestor(J)&&hasWrapperAncestor(m)){var z=document.createRange();z.setEnd(innerEndNode,c);var g=getWrapperAncestor(m);var p=g;z.setStartBefore(p);var f=parseInt(g.id.substring("sv_".length));while(z.toString().length<l.toString().length){f--;var t=CY.get("#sv_"+f);if(t){p=CY.Node.getDOMNode(t);z.setStartBefore(p);}else{break;}}J=p.firstChild;D=0;}else{if(!hasWrapperAncestor(J)&&!hasWrapperAncestor(m)){var o=h.length;var n=[];for(var f=0;;f++){var G=CY.get("#sv_"+f);if(G==null){break;}else{var x=G.get("text");if(h.indexOf(x)==0){n.push(f);}}}var y=[];for(var f=0;;f++){var G=CY.get("#sv_"+f);if(G==null){break;}else{var x=G.get("text");if(h.indexOf(x)==(o-x.length)){y.push(f);}}}var w=false;for(var C=0;C<n.length;C++){for(var A=0;A<y.length;A++){var v=document.createRange();var k=CY.Node.getDOMNode(CY.get("#sv_"+n[C]));var F=CY.Node.getDOMNode(CY.get("#sv_"+y[A]));v.setStartBefore(k);v.setEndAfter(CY.Node.getDOMNode(F));if((-1<v.compareBoundaryPoints(0,l))&&(1>v.compareBoundaryPoints(2,l))){J=k.firstChild;D=0;m=F.lastChild;c=CY.DOM.getText(F).length;w=true;break;}}if(w){break;}}}}}E.detach();B.detach();}else{return null;}}else{return null;}}else{if(document.selection){var d=document.selection.createRange();if(d.text.length==0){return null;}var a=d.parentElement();var H=d.duplicate();var u=d.duplicate();H.collapse(true);u.collapse(false);J=H.parentElement();while(H.moveStart("character",-1)!=0){if(H.parentElement()!=J){break;}D++;}m=u.parentElement();while(u.moveEnd("character",-1)!=0){if(u.parentElement()!=m){break;}c++;}h=d.text;}}if(!hasWrapperAncestor(J)||!hasWrapperAncestor(m)){return null;}return{text:h,start:{elt:J,offset:D},end:{elt:m,offset:c}};};Preferences=function(){this.prefs={};};Preferences.prototype={init:function(){this._read();},_read:function(){for(var b in gConf.defaultPrefs){this.prefs[b]={};for(var a in gConf.defaultPrefs[b]){var c=null;if(b=="user"&&(a=="name"||a=="email")){c=CY.Cookie.get("user_"+a);}else{c=CY.Cookie.getSub(b,a);}this.prefs[b][a]=(c==null)?gConf.defaultPrefs[b][a]:c;}}},persist:function(b,a,d){var c={path:"/",expires:(new Date()).setFullYear(2100,0,1)};if(b=="user"&&(a=="name"||a=="email")){CY.Cookie.set("user_"+a,d,c);}else{CY.Cookie.setSub(b,a,d,c);}this.prefs[b][a]=d;},get:function(b,a){return this.prefs[b][a];},readDefault:function(b,a){return gConf.defaultPrefs[b][a];},reset:function(a){for(var b=0;b<a.length;b++){var d=a[b];for(var c in gConf.defaultPrefs[d]){this.persist(d,c,gConf.defaultPrefs[d][c]);}}}};gNoSelectionYet=gettext("No selection yet");gFormHtml={formStart:'<form id="###" onsubmit="return false;">',nameInput:gettext("Username:")+'<center><input id="###" name="name" class="n_name user_input" style="padding:1px;" type="text"></input></center>',emailInput:gettext("E-mail address:")+'<center><input id="###" name="email" class="n_email user_input" style="padding:1px;" type="text"></input></center>',titleInput:gettext("Title:")+'<center><input id="###" name="title" class="n_title comment_input" style="padding:1px;" type="text"></input></center>',contentInput:gettext("Content:")+'<center><textarea id="###" name="content" class="n_content comment_input" rows="10" style="padding:1px;"></textarea></center>',tagsInput:gettext("Tag:")+'<center><input id="###" name="tags" class="n_tags comment_input" style="padding:1px;" type="text"></input></center>',hidden:'<input id="###" class="comment_input" name="???" type="hidden" value=""></input>',formEnd:"</form>",changeScope:'<div id="###">'+gettext("Modify comment's scope:")+'<input type="checkbox" name="change_scope"></input></div>',headerTitle:'<center><div id="###" class="c-header-title"></div></center>',currentSel:'<div id="###">'+gettext("Comment will apply to this selection:")+'<br/><div class="current_sel"><div id="???" class="current_sel_ins">'+gNoSelectionYet+"</div></div>#hiddeninput#</div>",btns:'<center><input id="###" type="button" value="'+gettext("Save")+'" /><input id="???" type="button" value="'+gettext("Cancel")+'" /></center>',closeIcon:'<a id="###" class="c-close" title="'+gettext("close")+'"><em> </em></a>'};getHtml=function(f){ret={};ret.headerContent="";if("closeBtnId" in f){ret.headerContent+=gFormHtml.closeIcon.replace("###",f.closeBtnId);}ret.headerContent+=gFormHtml.headerTitle.replace("###",f.formTitleId);var b="";if("changeScopeInputId" in f){b=gFormHtml.changeScope.replace("###",f.changeScopeInputId);}var e="<center>"+gFormHtml.hidden.replace("###",f.selectionPlaceId).replace("???","selection_place")+"</center>";var a=gFormHtml.currentSel.replace("###",f.currentSelId).replace("???",f.currentSelIdI).replace("#hiddeninput#",e);var d=gFormHtml.btns.replace("###",f.addBtnId).replace("???",f.cancelBtnId);var c=gFormHtml.formStart.replace("###",f.formId)+b+a;if("nameInputId" in f){c=c+gFormHtml.nameInput.replace("###",f.nameInputId);}if("emailInputId" in f){c=c+gFormHtml.emailInput.replace("###",f.emailInputId);}c=c+gFormHtml.titleInput.replace("###",f.titleInputId)+gFormHtml.contentInput.replace("###",f.contentInputId)+gFormHtml.tagsInput.replace("###",f.tagsInputId);c=c+gFormHtml.hidden.replace("###",f.formatInputId).replace("???","format");c=c+gFormHtml.hidden.replace("###",f.startWrapperInputId).replace("???","start_wrapper");c=c+gFormHtml.hidden.replace("###",f.endWrapperInputId).replace("???","end_wrapper");c=c+gFormHtml.hidden.replace("###",f.startOffsetInputId).replace("???","start_offset");c=c+gFormHtml.hidden.replace("###",f.endOffsetInputId).replace("???","end_offset");c=c+gFormHtml.hidden.replace("###",f.keyId).replace("???","comment_key");c=c+gFormHtml.hidden.replace("###",f.editCommentId).replace("???","edit_comment_id");c=c+d+gFormHtml.formEnd;ret.bodyContent=c;return ret;};changeFormFieldsWidth=function(d,c){var a=(c-20)+"px";var b=CY.all("#"+d+" input[type='text']");if(b!=null){b.setStyle("width",a);}b=CY.all("#"+d+" textarea");if(b!=null){b.setStyle("width",a);}};addFormErrMsg=function(j,g,d){var f=document.getElementById(j);var b,h,c,a;for(b=0,a=f.elements.length;b<a;++b){h=f.elements[b];if(h.name==g){c=document.createElement("DIV");CY.DOM.addClass(c,"c-error");c.id=h.id+"-err";c.appendChild(document.createTextNode(d));if(h.parentNode.nextSibling){h.parentNode.parentNode.insertBefore(c,h.parentNode.nextSibling);}else{h.parentNode.parentNode.appendChild(c);}}}};removeFormErrMsg=function(b){var a=CY.all("#"+b+" .c-error");if(a!=null){a.each(function(c){c.get("parentNode").removeChild(c);});}};Layout=function(){};Layout.prototype={init:function(){},isInFrame:function(){return(!CY.Lang.isUndefined(parent)&&parent.location!=location&&CY.Lang.isFunction(parent.f_getFrameFilterData));},isInComentSite:function(){var b=false;try{if(!CY.Lang.isUndefined(sv_site_url)&&!CY.Lang.isUndefined(parent)&&!CY.Lang.isUndefined(parent.parent)){var a=new String(parent.parent.location);b=(a.indexOf(sv_site_url)==0);}}catch(c){b=false;}return b;},sliderValToPx:function(d){var a=CY.DOM.winWidth();if(this.isInFrame()){a=parent.$(parent).width();}var b=d/100;b=Math.min(b,gConf.sliderFixedMin);b=Math.max(b,gConf.sliderFixedMax);var c=b*a;return Math.floor(c);},getTopICommentsWidth:function(){return this.getTopICommentsWidthFromWidth(this.sliderValToPx(gPrefs.get("layout","comments_col_width")));},getTopICommentsWidthFromWidth:function(b){var a=b-(2*gConf.iCommentThreadPadding);return a-7;},setLeftColumnWidth:function(a){CY.get("#contentcolumn").setStyle("marginLeft",a+"px");CY.get("#leftcolumn").setStyle("width",a+"px");},parentInterfaceUnfreeze:function(){if(this.isInFrame()){parent.f_interfaceUnfreeze();}}};_changeIds=function(a,b){if(a.id){a.id=a.id+b;}var d=a.firstChild;while(d!=null){_changeIds(d,b);d=d.nextSibling;}};suffix=0;domDuplicate=function(a){var b=a.cloneNode(true);suffix++;_changeIds(b,"-"+suffix);return b;};getDuplicated=function(a){return document.getElementById(a.id+"-"+suffix);};logSel=function(a){log("text :"+a.text+", start id : "+a.start["elt"].id+" , start offset : "+a.start["offset"]+" , end id : "+a.end["elt"].id+"end offset : "+a.end["offset"]);};log=function(b){var a=document.getElementById("log");a.innerHTML=a.innerHTML+"<li>"+b+"</li>";};urlEncode=function(h){if(!h){return"";}var c=[];for(var f in h){var e=h[f],b=encodeURIComponent(f);var g=typeof e;if(g=="undefined"){c.push(b,"=&");}else{if(g!="function"&&g!="object"){c.push(b,"=",encodeURIComponent(e),"&");}else{if(CY.Lang.isArray(e)){if(e.length){for(var d=0,a=e.length;d<a;d++){c.push(b,"=",encodeURIComponent(e[d]===undefined?"":e[d]),"&");}}else{c.push(b,"=&");}}}}}c.pop();return c.join("");};urlDecode=function(f,h){if(!f||!f.length){return{};}var d={};var b=f.split("&");var c,a,j;for(var e=0,g=b.length;e<g;e++){c=b[e].split("=");a=decodeURIComponent(c[0]);j=decodeURIComponent(c[1]);if(h!==true){if(typeof d[a]=="undefined"){d[a]=j;}else{if(typeof d[a]=="string"){d[a]=[d[a]];d[a].push(j);}else{d[a].push(j);}}}else{d[a]=j;}}return d;};areSortedArraysEqual=function(b,a){if(b.length!=a.length){return false;}for(var d=0,c=b.length;d<c;d++){if(b[d]!=a[d]){return false;}}return true;};quicksort=function(a){_quicksort(a,0,a.length-1);};_quicksort=function(e,g,d){var a,c,f,b;if(d-g==1){if(e[g]>e[d]){b=e[g];e[g]=e[d];e[d]=b;}return;}a=e[parseInt((g+d)/2)];e[parseInt((g+d)/2)]=e[g];e[g]=a;c=g+1;f=d;do{while(c<=f&&e[c]<=a){c++;}while(e[f]>a){f--;}if(c<f){b=e[c];e[c]=e[f];e[f]=b;}}while(c<f);e[g]=e[f];e[f]=a;if(g<f-1){_quicksort(e,g,f-1);}if(f+1<d){_quicksort(e,f+1,d);}};gShowingAllComments=false;Sync=function(){this._q=null;this._iPreventClick=false;};Sync.prototype={init:function(a){this._q=new CY.AsyncQueue();},setPreventClickOn:function(){CY.log("setPreventClickOn !");if(gLayout.isInFrame()){parent.f_interfaceFreeze();}this._iPreventClick=true;},setPreventClickOff:function(){CY.log("setPreventClickOff !");if(gLayout.isInFrame()){parent.f_interfaceUnfreeze();}this._iPreventClick=false;},removeCommentRet:function(b){var d=b.successfull;var a=(d)?b.failure["iComment"]:b.success["iComment"];if(d){var c=b.returned["filterData"];if(gLayout.isInFrame()){parent.f_updateFilterData(c);}var f=gIComments.getTopPosition()[1];var e=gDb.getComment(a.commentId);this._q.add(function(){unpaintCommentScope(e);gIComments.close(e.id);gIComments.remove(e.id);if(e.reply_to_id!=null){gIComments.refresh(e.reply_to_id);}gDb.del(e);if(gLayout.isInFrame()){if(gDb.comments.length==0&&gDb.allComments.length!=0){parent.f_enqueueMsg(gettext("no filtered comments left"));parent.resetFilter();}else{var g=gDb.computeFilterResults();updateFilterResultsCount(g.nbDiscussions,g.nbComments,g.nbReplies);}}});this._animateTo(f);}this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this.resume();},moderateCommentRet:function(c){var e=c.successfull;var a=(e)?c.failure["iComment"]:c.success["iComment"];if(e){var b=c.returned;var f=b.comment;gDb.upd(f);var d=gLayout.isInFrame()&&!parent.f_isFrameFilterFieldsInit();if(d){parent.resetFilter();this._showSingleComment(f);}else{a.changeModeration(f);}}this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this.resume();},saveCommentRet:function(h){var i=h.successfull;if(i){var l=h.success["formId"];var g=h.returned;removeFormErrMsg(l);if("errors" in g){var k=g.errors;for(var d in k){addFormErrMsg(l,d,k[d]);}this._animateToTop();}else{var b=function(){return(gNewReply!=null)&&(l==gNewReply.ids["formId"]);};var c=function(){return(gICommentForm!=null)&&(l==gICommentForm.formId);};var e=function(){return(gEdit!=null)&&(l==gEdit.ids["formId"]);};if(c()){this.hideICommentForm(cleanICommentForm());}else{if(e()){this._hideEditForm();}else{if(b()){this._hideNewReplyForm();}}}if("ask_for_notification" in g){if(g.ask_for_notification){parent.f_yesNoDialog(gettext("Do you want to be notified of all replies in all discussions you participated in?"),gettext("Reply notification"),function(){var m={method:"POST",data:urlEncode({fun:"ownNotify",key:sv_key,version_key:sv_version_key,email:g.email,active:false})};CY.io(sv_client_url,m);},this,null,function(){var m={method:"POST",data:urlEncode({fun:"ownNotify",key:sv_key,version_key:sv_version_key,email:g.email,active:true})};CY.io(sv_client_url,m);},this,null);}}if("comment" in g){var f=g.comment;gDb.upd(f);var a=gLayout.isInFrame()&&!parent.f_isFrameFilterFieldsInit();if(a){parent.resetFilter();}else{if(f.reply_to_id==null){unpaintCommentScope(f);paintCommentScope(f);}}var j=g.filterData;if(gLayout.isInFrame()){parent.f_updateFilterData(j);updateResetFilterResultsCount();}if(b()){if(!a){this._insertReply(f);}}else{this._showSingleComment(f);}}else{this._animateToTop();}}}else{this._q.add({id:"expl",fn:function(){CY.log("in example .........");}});this._q.promote("expl");}this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this.resume();},example:function(){CY.log("in example .........");},moderateComment:function(a,b){var c=gDb.getComment(a.commentId);this._q.add({fn:CY.bind(this.setPreventClickOn,this)},{autoContinue:false,fn:CY.bind(doExchange,null,"editComment",{comment_key:c.key,state:b},null,this.moderateCommentRet,this,{iComment:a},gettext("could not save comment"))}).run();},_saveComment:function(b,a){this._q.add({fn:CY.bind(this.setPreventClickOn,this)},{autoContinue:false,fn:CY.bind(doExchange,null,b,{},a,this.saveCommentRet,this,{formId:a},gettext("could not save comment"))}).run();},editComment:function(){this._saveComment("editComment",gEdit.ids["formId"]);},saveComment:function(a){this._saveComment("addComment",a);},removeComment:function(a){checkForOpenedDialog(a,function(){if(gLayout.isInFrame()){parent.f_yesNoDialog(gettext("Are you sure you want to delete this comment?"),gettext("Warning"),function(){this.animateToTop();},this,null,function(){var b=gDb.getComment(a.commentId);this._q.add({fn:CY.bind(this.setPreventClickOn,this)},{autoContinue:false,fn:CY.bind(doExchange,null,"removeComment",{comment_key:b.key},null,this.removeCommentRet,this,{iComment:a},gettext("could not remove comment"))}).run();},this,null);}},this,null);},resume:function(b,a){this._q.run();},resetAutoContinue:function(a){this._q.getCallback(a).autoContinue=true;},hideICommentForm:function(a){this._q.add({autoContinue:false,fn:CY.bind(gICommentForm.animationHide.run,gICommentForm.animationHide)});if(a){this._q.add(a);}},showCommentForm:function(a){checkForOpenedDialog(null,function(){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this._q.add({fn:function(){if(a==null){var b=getSelectionInfo();updateICommentFormSelection(b);}showICommentForm(a);}});this._q.add({autoContinue:false,fn:CY.bind(gICommentForm.animationShow.run,gICommentForm.animationShow)},{fn:CY.bind(this.setPreventClickOff,this)}).run();},this,null);},showEditForm:function(a){checkForOpenedDialog(null,function(){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this._q.add({fn:function(){showEditForm(a);}});this._animateToTop();this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},this,null);},showReplyForm:function(a){checkForOpenedDialog(null,function(){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this._q.add({fn:function(){instanciateNewReplyForm(a);}});this._animateToTop();this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},this,null);},cancelICommentForm:function(){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this.hideICommentForm();this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},cancelEdit:function(){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this._q.add({fn:function(){cancelEditForm();}});this._animateToTop();this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},cancelReply:function(){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this._q.add({fn:function(){cancelNewReplyForm();}});this._animateToTop();this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},changeScopeFormClick:function(){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this._q.add({fn:function(){changeScopeFormClick();}});this._animateToTop();this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},_hideNewReplyForm:function(){this._q.add({fn:function(){cleanNewReplyForm();cancelNewReplyForm();}});},_hideEditForm:function(){this._q.add({fn:function(){cancelEditForm();}});},_insertReply:function(a){this._q.add({fn:function(){var g=gDb.getComment(a.reply_to_id);var e=gDb.getThreads([g]);var c=e[e.length-2];var d=gIComments.insertAfter(c,a);var h=gIComments.getPosition(a.reply_to_id);d.setPosition(h);var b=gDb.getPath(a);var f=b[b.length-1];if(gIComments.isTopActive(f.id)){d.activate();}d.show();}});this._animateToTop();},_showSingleComment:function(d){if(d!=null){var c=gDb.getPath(d);var b=c[c.length-1];var a=0;if(d.start_wrapper!=-1){a=CY.get(".c-id-"+b.id).getY();}else{a=CY.get("document").get("scrollTop");}this._showComments([b.id],a,false);if(b.replies.length>0){this._animateTo(a);}}},_showFocusSingleComment:function(c,b){if(c!=null){var a=0;if(c.start_wrapper!=-1){a=CY.get(".c-id-"+c.id).getY();}else{a=CY.get("document").get("scrollTop");}this._showComments([c.id],a,false);if(c.replies.length>0){this._animateToAndFocus(a,b.id);}}},showSingleComment:function(a){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this._showSingleComment(a);this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},showFocusSingleComment:function(b,a){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this._showFocusSingleComment(b,a);this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},browse:function(a,b){var c=gIComments.browse(a,b);if(c!=null){this.showSingleComment(c);}},_showComments:function(c,b,a){this._q.add({fn:function(){gShowingAllComments=a;gIComments.hide();var d=CY.Array.map(c,function(g){return gDb.getComment(g);});var f=gDb.getThreads(d);gIComments.fetch(f);if(c.length>0){if(a){CY.get("document").set("scrollTop",0);}else{gIComments.activate(c[0]);var e=CY.get(".c-id-"+c[0]);if(e&&!e.inViewportRegion()){e.scrollIntoView(true);}}}gIComments.setPosition([gConf.iCommentLeftPadding,b]);gIComments.show();}});},_animateTo:function(a){this._q.add({fn:function(){gIComments.setAnimationToPositions(a);}},{id:"animationRun",autoContinue:false,fn:CY.bind(gIComments.runAnimations,gIComments)});},_animateToAndFocus:function(a,b){this._q.add({fn:function(){gIComments.setAnimationToPositionsAndFocus(a,b);}},{id:"animationRun",autoContinue:false,fn:CY.bind(gIComments.runAnimations,gIComments)});},_animateToTop:function(){var a=gIComments.getTopPosition();if(a!=null){this._animateTo(a[1]);}},animateToTop:function(){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this._animateToTop();this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},showAllComments:function(){checkForOpenedDialog(null,function(){gShowingAllComments=true;var a=CY.Array.map(gDb.comments,function(b){return b.id;});this.showComments(a,[0,0],true);},this,null);},showScopeRemovedComments:function(){checkForOpenedDialog(null,function(){gShowingAllComments=true;var b=CY.Array.filter(gDb.comments,function(c){return(c.start_wrapper==-1);});var a=CY.Array.map(b,function(d){return d.id;});this.showComments(a,[0,0],true);},this,null);},showComments:function(c,b,a){checkForOpenedDialog(null,function(){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this._showComments(c,b[1],a);this._animateTo(b[1]);this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},this,null);},openComment:function(a){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});var b=gIComments.getTopPosition()[1];this._q.add({fn:function(){gIComments.open(a.commentId);gIComments.refresh(a.commentId);}});this._animateTo(b);this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},closeComment:function(a){checkForOpenedDialog(a,function(){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});var b=gIComments.getTopPosition()[1];this._q.add({fn:function(){var c=gDb.getComment(a.commentId);gIComments.close(a.commentId);if(c.reply_to_id!=null){gIComments.refresh(c.reply_to_id);}}});this._animateTo(b);this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},this,null);},activate:function(a){gIComments.activate(a.commentId);}};readyForAction=function(){return !gSync._iPreventClick;};gEditICommentHost=null;gEdit=null;dbgc=null;showEditForm=function(a){if(gEdit==null){gEdit={ids:{formId:CY.guid(),formTitleId:CY.guid(),nameInputId:CY.guid(),emailInputId:CY.guid(),titleInputId:CY.guid(),contentInputId:CY.guid(),tagsInputId:CY.guid(),formatInputId:CY.guid(),startWrapperInputId:CY.guid(),endWrapperInputId:CY.guid(),startOffsetInputId:CY.guid(),endOffsetInputId:CY.guid(),changeScopeInputId:CY.guid(),changeScopeInputWrapper:CY.guid(),selectionPlaceId:CY.guid(),keyId:CY.guid(),editCommentId:CY.guid(),currentSelId:CY.guid(),currentSelIdI:CY.guid(),addBtnId:CY.guid(),cancelBtnId:CY.guid()},handlers:{}};}gEditICommentHost=a;gEditICommentHost.hideContent();var c=getHtml(gEdit.ids);var b='<div class="icomment-edit-header">'+c.headerContent+"</div>";var e='<div class="icomment-edit-body">'+c.bodyContent+"</div>";gEditICommentHost.overlay.setStdModContent(CY.WidgetStdMod.HEADER,CY.Node.create(b),CY.WidgetStdMod.AFTER);gEditICommentHost.overlay.setStdModContent(CY.WidgetStdMod.BODY,CY.Node.create(e),CY.WidgetStdMod.AFTER);CY.get("#"+gEdit.ids["formTitleId"]).set("innerHTML",gettext("Edit comment"));var f=gDb.getComment(gEditICommentHost.commentId);CY.get("#"+gEdit.ids["editCommentId"]).set("value",f.id);CY.get("#"+gEdit.ids["keyId"]).set("value",f.key);CY.get("#"+gEdit.ids["changeScopeInputId"]+" input").set("checked",false);if(f.reply_to_id!=null){CY.get("#"+gEdit.ids["changeScopeInputId"]).addClass("displaynone");}changeScopeFormClick();CY.get("#"+gEdit.ids["nameInputId"]).set("value",f.name);CY.get("#"+gEdit.ids["emailInputId"]).set("value",f.email);if(f.logged_author){CY.get("#"+gEdit.ids["nameInputId"]).setAttribute("disabled",true);CY.get("#"+gEdit.ids["emailInputId"]).setAttribute("disabled",true);}CY.get("#"+gEdit.ids["titleInputId"]).set("value",f.title);CY.get("#"+gEdit.ids["contentInputId"]).set("value",f.content);CY.get("#"+gEdit.ids["tagsInputId"]).set("value",f.tags);CY.get("#"+gEdit.ids["formatInputId"]).set("value",gConf.defaultCommentFormat);var d=gLayout.getTopICommentsWidth();changeFormFieldsWidth(gEdit.ids["formId"],d);gEdit.handlers["addBtnId"]=CY.on("click",onEditSaveClick,"#"+gEdit.ids["addBtnId"]);gEdit.handlers["cancelBtnId"]=CY.on("click",onEditCancelClick,"#"+gEdit.ids["cancelBtnId"]);gEdit.handlers["changeScope"]=CY.on("click",onChangeScopeClick,"#"+gEdit.ids["changeScopeInputId"]);};onEditSaveClick=function(a){if(readyForAction()){gSync.editComment();}};onEditCancelClick=function(a){if(readyForAction()){gSync.cancelEdit();}};onChangeScopeClick=function(){if(readyForAction()){gSync.changeScopeFormClick();}else{var a=CY.get("#"+gEdit.ids["changeScopeInputId"]+" input");var b=a.get("checked");a.set("checked",!b);}};changeScopeFormClick=function(){var a=CY.get("#"+gEdit.ids["currentSelId"]);if(CY.get("#"+gEdit.ids["changeScopeInputId"]+" input").get("checked")){a.removeClass("displaynone");}else{a.addClass("displaynone");}};cancelEditForm=function(){if(gEditICommentHost!=null){for(var b in gEdit.handlers){if(gEdit.handlers[b]!=null){gEdit.handlers[b].detach();gEdit.handlers[b]=null;}}var a=gEditICommentHost.overlay.get("contentBox").query(".icomment-edit-body");a.get("parentNode").removeChild(a);a=gEditICommentHost.overlay.get("contentBox").query(".icomment-edit-header");a.get("parentNode").removeChild(a);gEditICommentHost.showContent();gEditICommentHost=null;}};gICommentForm=null;instanciateICommentForm=function(){gICommentForm={position:[CY.WidgetPositionExt.LC,CY.WidgetPositionExt.LC],formId:CY.guid(),formTitleId:CY.guid(),titleInputId:CY.guid(),contentInputId:CY.guid(),tagsInputId:CY.guid(),formatInputId:CY.guid(),startWrapperInputId:CY.guid(),endWrapperInputId:CY.guid(),startOffsetInputId:CY.guid(),endOffsetInputId:CY.guid(),selectionPlaceId:CY.guid(),keyId:CY.guid(),currentSelId:CY.guid(),currentSelIdI:CY.guid(),addBtnId:CY.guid(),cancelBtnId:CY.guid(),closeBtnId:CY.guid()};if(!sv_loggedIn){gICommentForm.nameInputId=CY.guid();gICommentForm.emailInputId=CY.guid();}var c=getHtml(gICommentForm);var e=gLayout.getTopICommentsWidth();var b=new CY.Overlay({zIndex:3,shim:false,visible:false,headerContent:c.headerContent,bodyContent:c.bodyContent,xy:[10,10],width:e});b.get("contentBox").addClass("c-newcomment");b.render("#leftcolumn");if(!sv_loggedIn){CY.get("#"+gICommentForm.nameInputId).set("value",gPrefs.get("user","name"));CY.get("#"+gICommentForm.emailInputId).set("value",gPrefs.get("user","email"));}CY.get("#"+gICommentForm.formTitleId).set("innerHTML",gettext("New comment"));CY.get("#"+gICommentForm.formatInputId).set("value",gConf.defaultCommentFormat);CY.on("click",onSubmitICommentFormClick,"#"+gICommentForm.addBtnId);CY.on("click",onCancelICommentFormClick,"#"+gICommentForm.cancelBtnId);CY.on("click",onCancelICommentFormClick,"#"+gICommentForm.closeBtnId);gICommentForm.overlay=b;var d=null;d=new CY.Anim({node:b.get("boundingBox"),duration:0.3,easing:CY.Easing.easeOut});gICommentForm.animationHide=d;d.set("to",{opacity:0});gICommentForm["animationHide-handle"]=d.on("end",onICommentFormHideAnimEnd,gICommentForm);var a=null;a=new CY.Anim({node:b.get("boundingBox"),duration:0.3,easing:CY.Easing.easeOut});gICommentForm.animationShow=a;a.set("to",{opacity:1});gICommentForm["animationShow-handle"]=a.on("end",onICommentFormShowAnimEnd,gICommentForm);changeFormFieldsWidth(gICommentForm.formId,e);};cleanICommentForm=function(){CY.get("#"+gICommentForm.currentSelIdI).set("innerHTML",gNoSelectionYet);var a=gICommentForm.overlay.getStdModNode(CY.WidgetStdMod.BODY);a.queryAll(".comment_input").set("value","");CY.get("#"+gICommentForm.formatInputId).set("value",gConf.defaultCommentFormat);if(!sv_loggedIn){a.queryAll(".user_input").set("value","");}};onICommentFormHideAnimEnd=function(){this.overlay.hide();gSync.resume();};onICommentFormShowAnimEnd=function(){gSync.resume();};onSubmitICommentFormClick=function(){if(!sv_loggedIn){var b=CY.get("#"+gICommentForm.nameInputId).get("value");gPrefs.persist("user","name",b);var a=CY.get("#"+gICommentForm.emailInputId).get("value");gPrefs.persist("user","email",a);}gSync.saveComment(gICommentForm.formId);};onCancelICommentFormClick=function(){gSync.cancelICommentForm();};_updateICommentFormSelection=function(c,e,b,a){var d=CY.Node.get("#"+c.currentSelIdI);if(d!=null){d.set("innerHTML",e);}d=CY.get("#"+c.startWrapperInputId);if(d!=null){d.set("value",b.elt.id.substring("sv_".length));}d=CY.get("#"+c.startOffsetInputId);if(d!=null){d.set("value",b.offset);}d=CY.get("#"+c.endWrapperInputId);if(d!=null){d.set("value",a.elt.id.substring("sv_".length));}d=CY.get("#"+c.endOffsetInputId);if(d!=null){d.set("value",a.offset);}};updateICommentFormSelection=function(h){var i=(h==null)?"":h.text;if(i!=""){var f=i;var b=100;if(i.length>b){var a=i.substring(0,(i.substring(0,b/2)).lastIndexOf(" "));var d=i.substring(i.length-b/2);var c=d.substring(d.indexOf(" "));f=a+" ... "+c;}var e=_convertSelectionFromCCToCS(h.start);var g=_convertSelectionFromCCToCS(h.end);_updateICommentFormSelection(gICommentForm,f,e,g);if(gEdit!=null){_updateICommentFormSelection(gEdit.ids,f,e,g);}positionICommentForm();}};showICommentForm=function(){removeFormErrMsg(gICommentForm.formId);if(!sv_loggedIn){if(CY.get("#"+gICommentForm.nameInputId).get("value")==""){CY.get("#"+gICommentForm.nameInputId).set("value",gPrefs.get("user","name"));}if(CY.get("#"+gICommentForm.emailInputId).get("value")==""){CY.get("#"+gICommentForm.emailInputId).set("value",gPrefs.get("user","email"));}}gIComments.hide();positionICommentForm();gICommentForm.overlay.show();CY.get("#"+gICommentForm.titleInputId).focus();};isICommentFormVisible=function(){if(gICommentForm!=null){return gICommentForm.overlay.get("visible");}return false;};positionICommentForm=function(){if(gICommentForm!=null){var b=gICommentForm.overlay;var a=b.get("boundingBox");var c=a.get("offsetHeight");var e=a.get("winHeight");var d=gICommentForm.position;if(c>e){d=[CY.WidgetPositionExt.BL,CY.WidgetPositionExt.BL];}b.set("align",{points:d});a.setX(a.getX()+gConf.iCommentLeftPadding);}};Db=function(){this.comments=null;this.allComments=null;this.commentsByDbId={};this.allCommentsByDbId={};this.ordered_comment_ids={};};Db.prototype={init:function(){this.allComments=CY.JSON.parse(sv_comments);if(sv_read_only){this.initToReadOnly();}this._computeAllCommentsByDbId();this._reorder();},_del:function(a,e,g){var f=e[g];for(var c=0;c<f.replies.length;c++){var d=f.replies[c].id;this._del(f.replies,e,d);c--;}for(var c=0,b=a.length;c<b;c++){if(a[c].id==g){a.splice(c,1);delete e[g];break;}}},del:function(b){var a=(b.reply_to_id==null)?this.comments:this.commentsByDbId[b.reply_to_id].replies;this._del(a,this.commentsByDbId,b.id);a=(b.reply_to_id==null)?this.allComments:this.allCommentsByDbId[b.reply_to_id].replies;this._del(a,this.allCommentsByDbId,b.id);this._reorder();},_reorder:function(){var n=[];for(var k=0,c=this.allComments.length;k<c;k++){var l=this.allComments[k];var r=false;for(var g=0,q=n.length;g<q;g++){var b=n[g];var f=this.allCommentsByDbId[b];if((l.start_wrapper<f.start_wrapper)||((l.start_wrapper==f.start_wrapper)&&(l.start_offset<f.start_offset))||((l.start_wrapper==f.start_wrapper)&&(l.start_offset==f.start_offset)&&(l.end_wrapper<f.end_wrapper))||((l.start_wrapper==f.start_wrapper)&&(l.start_offset==f.start_offset)&&(l.end_wrapper==f.end_wrapper)&&(l.end_offset<f.end_offset))){n.splice(g,0,l.id);r=true;break;}}if(!r){n.push(l.id);}}this.ordered_comment_ids.scope=n;n=[];var m={};for(var k=0,c=this.allComments.length;k<c;k++){var l=this.allComments[k];var o=l.modified;m[l.id]=o;for(var g=0,q=l.replies.length;g<q;g++){var e=l.replies[g];var d=e.modified;if(d>m[l.id]){m[l.id]=d;}}}for(var b in m){var h=this.allCommentsByDbId[b].id;var r=false;for(var k=0,c=n.length;k<c;k++){var p=n[k];if(m[b]<m[p]){n.splice(k,0,h);r=true;break;}}if(!r){n.push(h);}}this.ordered_comment_ids.modif_thread=n;},_upd:function(a,f,g){var e=false;for(var d=0,b=a.length;d<b;d++){if(a[d].id==g.id){a.splice(d,1,g);e=true;break;}}if(!e){a.push(g);}f[g.id]=g;},upd:function(c){var a=(c.reply_to_id==null)?this.allComments:this.allCommentsByDbId[c.reply_to_id].replies;this._upd(a,this.allCommentsByDbId,c);var b=CY.clone(c);a=(c.reply_to_id==null)?this.comments:this.commentsByDbId[c.reply_to_id].replies;this._upd(a,this.commentsByDbId,b);this._reorder();},initComments:function(a){this.comments=[];for(var d=0,c=this.allComments.length;d<c;d++){var b=CY.Array.indexOf(a,this.allComments[d].id);if(b!=-1){var e=CY.clone(this.allComments[d]);this.comments.push(e);}}this._computeCommentsByDbId();},_computeCommentsByDbId:function(){this.commentsByDbId={};var b=this.getThreads(this.comments);for(var a=0;a<b.length;a++){this.commentsByDbId[b[a].id]=b[a];}},_computeAllCommentsByDbId:function(){this.allCommentsByDbId={};var b=this.getThreads(this.allComments);for(var a=0;a<b.length;a++){this.allCommentsByDbId[b[a].id]=b[a];}},getThreads:function(c){var a=[];for(var b=0;b<c.length;b++){a.push(c[b]);if(c[b].replies.length>0){a=a.concat(this.getThreads(c[b].replies));}}return a;},_getPath:function(b,e){var a=[e];var d=e;while(d.reply_to_id!=null){d=b[d.reply_to_id];a.push(d);}return a;},getPath:function(a){return this._getPath(this.commentsByDbId,a);},getComment:function(a){return this.commentsByDbId[a];},getCommentByIdKey:function(a){for(var c in this.commentsByDbId){var b=this.commentsByDbId[c];if(b.id_key==a){return b;}}return null;},isChild:function(d,b){var c=this.commentsByDbId[d];var a=(d==b);while((!a)&&(c.reply_to_id!=null)){c=this.commentsByDbId[c.reply_to_id];a=(c.id==b);}return a;},initToReadOnly:function(f,c){for(var b=0,a=this.allComments.length;b<a;b++){var e=this.allComments[b];for(var d in e){if(0==d.indexOf("can_")&&typeof e[d]==="boolean"){e[d]=false;}}}},browsingIndex:function(b){var c={};for(var a in this.ordered_comment_ids){var d=CY.Array.filter(this.ordered_comment_ids[a],function(e){return(e in this.commentsByDbId);},this);c[a]=CY.Array.indexOf(d,b);}return c;},browse:function(b,f,c){var a=this.ordered_comment_ids[b];if(a.length>0){var g=-1;if((f=="prev")||(f=="next")){for(var e=0;e<a.length;e++){var h=a[e];if(h==c){g=(f=="prev")?e-1:e+1;g=(a.length+g)%a.length;break;}}if(g==-1){CY.error("internal error in db browse (was called with a dbId that isn't among the filtered ones)");return null;}}if(f=="last"){g=a.length-1;}if(f=="first"){g=0;}for(var e=g,d=0;(e>=0)&&(e<a.length);d++){var h=a[e];if(h in this.commentsByDbId){return this.commentsByDbId[h];}if((f=="prev")||(f=="last")){e=e-1;}else{e=e+1;}e=(a.length+e)%a.length;if(d>a.length){break;}}CY.error("internal error in db browse (could not find any filtered comment)");}return null;},computeFilterResults:function(n){var a={};if(n){for(key in n){if(key.indexOf("filter_")==0){a[key.substr("filter_".length)]=n[key];}}}else{if(gLayout.isInFrame()){a=parent.f_getFrameFilterData();}}var v=[];var w=[];var b="";if("name" in a){b=a.name;}this.filterByName(b,v,w);var p=[];var c=[];var C="";if("date" in a){C=a.date;}this.filterByDate(C,p,c);var g=[];var f=[];var t="";if("text" in a){t=a.text;}this.filterByText(t,g,f);var x=[];var m=[];var A="";if("tag" in a){A=a.tag;}this.filterByTag(A,x,m);var u=[];var e=[];var k="";if("state" in a){k=a.state;}this.filterByState(k,u,e);var d=[];var z=[];for(var y=0,j=v.length;y<j;y++){var s=v[y];if((CY.Array.indexOf(p,s)!=-1)&&(CY.Array.indexOf(g,s)!=-1)&&(CY.Array.indexOf(x,s)!=-1)&&(CY.Array.indexOf(u,s)!=-1)){d.push(s);}}for(var y=0,j=w.length;y<j;y++){var s=w[y];if((CY.Array.indexOf(c,s)!=-1)&&(CY.Array.indexOf(f,s)!=-1)&&(CY.Array.indexOf(m,s)!=-1)&&(CY.Array.indexOf(e,s)!=-1)){z.push(s);}}var q=z.length,l=d.length;var r=l;for(var y=0,j=z.length;y<j;y++){var s=z[y];var o=this.allCommentsByDbId[s];var B=this._getPath(this.allCommentsByDbId,o);var h=B[B.length-1];var s=h.id;if(CY.Array.indexOf(d,s)==-1){d.push(s);r++;}}return{commentIds:d,nbDiscussions:r,nbComments:l,nbReplies:q};},filterByText:function(c,f,b){var a=new RegExp(c,"gi");for(var e in this.allCommentsByDbId){var d=this.allCommentsByDbId[e];if(c==""||ac(d.title)!=null||ac(d.content)!=null){if(d.reply_to_id==null){f.push(d.id);}else{b.push(d.id);}}}},filterByName:function(a,c,b){for(var e in this.allCommentsByDbId){var d=this.allCommentsByDbId[e];if(a==""||d.name==a){if(d.reply_to_id==null){c.push(d.id);}else{b.push(d.id);}}}},filterByTag:function(i,e,b){var h=new RegExp("^"+i+"$","g");var g=new RegExp("^"+i+", ","g");var d=new RegExp(", "+i+", ","g");var c=new RegExp(", "+i+"$","g");for(var a in this.allCommentsByDbId){var f=this.allCommentsByDbId[a];if(i==""||hc(f.tags)||gc(f.tags)!=null||dc(f.tags)!=null||cc(f.tags)!=null){if(f.reply_to_id==null){e.push(f.id);}else{b.push(f.id);}}}},filterByState:function(c,a,b){for(var e in this.allCommentsByDbId){var d=this.allCommentsByDbId[e];if(c==""||d.state==c){if(d.reply_to_id==null){a.push(d.id);}else{b.push(d.id);}}}},filterByDate:function(b,d,a){var c=(b=="")?0:parseInt(b);for(var f in this.allCommentsByDbId){var e=this.allCommentsByDbId[f];if(e.modified>c){if(e.reply_to_id==null){d.push(e.id);}else{a.push(e.id);}}}},getCommentsAndRepliesCounts:function(d){var b=0;var f=0;var a=(d)?this.allComments:this.comments;var e=this.getThreads(a);for(var c=0;c<e.length;c++){if(e[c].reply_to_id==null){b++;}else{f++;}}return[b,f];},getCommentsNb:function(b){var a=(b)?this.allComments:this.comments;return this.getThreads(a).length;},getFilteredCommentIdsAsString:function(){var a="";for(var b in this.commentsByDbId){a=a+b+",";}return a;}};var gtest={renaud:"RENAUD",random:Math.random(),bernard:"BERNARD",myFunc:function(){doExchange("theServerFun",{},null,this.myRetFunc,this,["foo","bar"]);},myRetFunc:function(a){CY.log("this.renaud : "+this.renaud);CY.log("this.random : "+this.random);CY.log("arg.returned : "+a.returned);CY.log(a.returned);CY.log("arg.success : "+a.success);CY.log(a.success);}};doExchange=function(h,e,g,f,d,c,b){e.fun=h;e.key=sv_key;e.version_key=sv_version_key;var a={method:"POST",data:urlEncode(e),on:{success:function(l,k,j){var i={};if(k.responseText){i=CY.JSON.parse(k.responseText);}if(gLayout.isInFrame()&&("msg" in i)){parent.f_enqueueMsg(i.msg);}j.returned=i;j.successfull=true;f.call(d,j);},failure:function(k,j,i){if(gLayout.isInFrame()){parent.f_enqueueErrorMsg(gettext("error:")+b);}i.successfull=false;f.call(d,i);}},arguments:{success:c,failure:c}};if(g!=null){a.form={id:g};}CY.io(sv_client_url,a);};warn_server=function(c){c.fun="warn";c.key=sv_key;c.version_key=sv_version_key;var b=CY.UA;var a={method:"POST",data:urlEncode(CY.merge(c,b))};CY.io("/client/",a);};IComments=function(){this._c=[];this._a=[];this._nbEndedAnim=0;this._topActiveCommentDbId=null;};IComments.prototype={init:function(a){for(var b=0;b<gConf.iCommentsInitAlloc;b++){this._c.push(new IComment());}},getIComment:function(a){return CY.Array.find(this._c,function(b){return(b.isfetched()&&b.commentId==a);});},insertAfter:function(a,d){var c=CY.Array.map(this._c,function(e){return e.commentId;});var b=CY.Array.indexOf(c,a.id);if(b!=-1){this._c.splice(b+1,0,new IComment());this._c[b+1].fetch(d);return this._c[b+1];}return null;},_remove:function(c){var d=CY.Array.map(c,function(e){return e.commentId;});for(var b=0;b<this._c.length;b++){var a=this._c[b];if(a.isfetched()&&CY.Array.indexOf(d,a.commentId)!=-1){a.unfetch();this._c.push(this._c.splice(b,1)[0]);b--;}}},_getChildren:function(a){return CY.Array.filter(this._c,function(b){return(b.isfetched()&&gDb.isChild(b.commentId,a));});},_getInvisibleChildren:function(a){return CY.Array.filter(this._getChildren(a),function(b){return(!b.isVisible());});},refresh:function(c){var b=this.getIComment(c);var a=this._getInvisibleChildren(c);if(a.length>0){b.showReadRepliesLnk();}else{b.hideReadRepliesLnk();}},remove:function(a){this._remove(this._getChildren(a));},close:function(a){CY.Array.each(this._getChildren(a),function(b){b.hide();});},open:function(a){CY.Array.each(this._getChildren(a),function(b){b.show();});},fetch:function(b){for(var a=0;a<b.length;a++){if(a==this._c.length){this._c.push(new IComment());}this._c[a].fetch(b[a]);}for(var a=b.length;a<this._c.length;a++){this._c[a].unfetch();}},setPosition:function(a){CY.each(this._c,function(b){b.setPosition(a);});},show:function(){CY.each(this._c,function(a){if(a.isfetched()){a.show();}});},hide:function(){this.deactivate();CY.each(this._c,function(a){if(a.commentId!=null){a.hide();}});},setWidth:function(c){var e=null;for(var b=0;b<this._c.length;b++){var a=this._c[b];a.setWidth(c);if(a.commentId!=null&&a.isVisible()){var d=a.getPosition();if(e==null){e=d[1];}d[1]=e;a.setPosition(d);e+=a.getHeight();}}},getTopPosition:function(){for(var b=0;b<this._c.length;b++){var a=this._c[b];if(a.commentId!=null&&a.isVisible()){return a.getPosition();}}return null;},getPosition:function(c){for(var b=0;b<this._c.length;b++){var a=this._c[b];if(a.commentId==c&&a.isVisible()){return a.getPosition();}}return null;},setAnimationToPositions:function(h){this._initAnimations();var c=(gPrefs.get("comments","threadpad")=="1")?gConf.iCommentThreadPadding:0;var f=h;for(var d=0;d<this._c.length;d++){var b=this._c[d];if(b.isfetched&&b.isVisible()){var a=gDb.getPath(gDb.getComment(b.commentId));var g=((a.length-1)*c)+gConf.iCommentLeftPadding;if(f==null){var e=b.getPosition();f=e[1];}this._a.push(b.setAnimationToPosition([g,f]));f+=b.getHeight();}}},setAnimationToPositionsAndFocus:function(f,e){this._initAnimations();var a=(gPrefs.get("comments","threadpad")=="1")?gConf.iCommentThreadPadding:0;var g=f;for(var c=0;c<this._c.length;c++){var b=this._c[c];if(b.isfetched&&b.isVisible()){var d=gDb.getPath(gDb.getComment(b.commentId));var j=((d.length-1)*a)+gConf.iCommentLeftPadding;if(g==null){var h=b.getPosition();g=h[1];}if(b.commentId>=e){this._a.push(b.setAnimationToPosition([j,g],e));}else{this._a.push(b.setAnimationToPosition([j,g]));}g+=b.getHeight();}}},_initAnimations:function(){this._a=[];this._nbEndedAnim=0;},runAnimations:function(){if(this._a.length==0){gSync.resetAutoContinue("animationRun");}else{CY.each(this._a,function(a){a.run();});}},whenAnimationsEnd:function(){gSync.resume();},whenAnimationsEndFocus:function(){gGETValues=CY.JSON.parse(sv_get_params);if("comment_id_key" in gGETValues){var b=gGETValues.comment_id_key;var a=gDb.getCommentByIdKey(b);if(a!=null){gIComments.getIComment(a.id).overlay.focus();}}gSync.resume();},animationsEnded:function(){return((this._a.length==0)||(this._a.length==this._nbEndedAnim));},signalAnimationEnd:function(){this._nbEndedAnim++;},isTopActive:function(a){return((a!=null)&&(this._topActiveCommentDbId==a));},isAnyActive:function(){return(this._topActiveCommentDbId!=null);},activate:function(f){if(this._topActiveCommentDbId!=null){this.deactivate();}var e=gDb.getComment(f);var b=gDb.getPath(e);var a=b[b.length-1];var c=this._getChildren(a.id);CY.Array.each(c,function(g){g.activate();});this._topActiveCommentDbId=a.id;if(gLayout.isInFrame()){var d=gDb.browsingIndex(this._topActiveCommentDbId);parent.$("#browse_by option").each(function(){var g=1+d[this.value];parent.$("#c_browse_indx_"+this.value).html(""+g);});}showScope(a.id);},deactivate:function(){if(this._topActiveCommentDbId!=null){parent.$("#browse_by option").each(function(){parent.$("#c_browse_indx_"+this.value).html("-");});hideScopeAnyway();var a=this._getChildren(this._topActiveCommentDbId);CY.Array.each(a,function(b){b.deactivate();});this._topActiveCommentDbId=null;}},activateVisibleNext:function(){if(this._topActiveCommentDbId!=null){for(var d=0;d<2;d++){var f=(d==0)?0:this._c.length-1;var a=false;for(var e=f;(e>=0)&&e<=(this._c.length-1);){var c=this._c[e];if(c.commentId!=null&&c.isVisible()){a=a||(gDb.isChild(c.commentId,this._topActiveCommentDbId));if(a&&(!gDb.isChild(c.commentId,this._topActiveCommentDbId))){this.activate(c.commentId);return true;}}e=(d==0)?e+1:e-1;}}}return false;},browse:function(b,c){var a=c;if((c=="prev")&&!this.isAnyActive()){a="last";}if((c=="next")&&!this.isAnyActive()){a="first";}return gDb.browse(b,a,this._topActiveCommentDbId);}};gNewReplyHost=null;gNewReply=null;instanciateNewReplyForm=function(i){if(gNewReply==null){gNewReply={val:{name:gPrefs.get("user","name"),email:gPrefs.get("user","email"),title:"",content:"",tags:""},ids:{name:gPrefs.get("user","name"),email:gPrefs.get("user","email"),title:"",content:"",tags:"",formId:CY.guid(),nameInputId:CY.guid(),emailInputId:CY.guid(),titleInputId:CY.guid(),contentInputId:CY.guid(),keyInputId:CY.guid(),formatInputId:CY.guid(),tagsInputId:CY.guid(),parentCommentId:CY.guid(),addBtnId:CY.guid(),cancelBtnId:CY.guid()},handlers:{}};}gNewReplyHost=i;var b='<hr/><center><div class="c-header-title">'+gettext("New reply")+"</div></center>";var e=gFormHtml.formStart.replace("###",gNewReply.ids["formId"]);if(!sv_loggedIn){e=e+gFormHtml.nameInput.replace("###",gNewReply.ids["nameInputId"])+gFormHtml.emailInput.replace("###",gNewReply.ids["emailInputId"]);}e=e+gFormHtml.titleInput.replace("###",gNewReply.ids["titleInputId"])+gFormHtml.contentInput.replace("###",gNewReply.ids["contentInputId"])+gFormHtml.tagsInput.replace("###",gNewReply.ids["tagsInputId"]);e=e+gFormHtml.hidden.replace("###",gNewReply.ids["keyInputId"]).replace("???","comment_key");e=e+gFormHtml.hidden.replace("###",gNewReply.ids["formatInputId"]).replace("???","format");e=e+gFormHtml.hidden.replace("###",gNewReply.ids["parentCommentId"]).replace("???","reply_to_id");var h=gFormHtml.btns.replace("###",gNewReply.ids["addBtnId"]).replace("???",gNewReply.ids["cancelBtnId"]);gNewReplyHost.overlay.setStdModContent(CY.WidgetStdMod.FOOTER,b+e+h);var c=gNewReplyHost.overlay.getStdModNode(CY.WidgetStdMod.FOOTER);var f=gDb.getComment(i.commentId);var a="Re: ";var g=(gNewReply.val["title"]==""||gNewReply.val["title"].substring(0,a.length)==a)?a+f.title:gNewReply.val["title"];if(!sv_loggedIn){c.query(".n_name").set("value",gNewReply.val["name"]);c.query(".n_email").set("value",gNewReply.val["email"]);}c.query(".n_title").set("value",g);c.query(".n_content").set("value",gNewReply.val["content"]);c.query(".n_tags").set("value",gNewReply.val["tags"]);c.query("#"+gNewReply.ids["parentCommentId"]).set("value",i.commentId);c.query("#"+gNewReply.ids["formatInputId"]).set("value",gConf.defaultCommentFormat);gNewReplyHost.overlay.get("contentBox").query(".c-reply").addClass("displaynone");gNewReply.handlers["addBtnId"]=CY.on("click",onAddNewReplyClick,"#"+gNewReply.ids["addBtnId"]);gNewReply.handlers["cancelBtnId"]=CY.on("click",onCancelNewReplyClick,"#"+gNewReply.ids["cancelBtnId"]);var d=gLayout.getTopICommentsWidth();changeFormFieldsWidth(gNewReply.ids["formId"],d);};cleanNewReplyForm=function(){if(gNewReplyHost!=null){var a=gNewReplyHost.overlay.getStdModNode(CY.WidgetStdMod.FOOTER);a.queryAll(".comment_input").set("value","");}};cancelNewReplyForm=function(){if(gNewReplyHost!=null){for(var b in gNewReply.handlers){if(gNewReply.handlers[b]!=null){gNewReply.handlers[b].detach();gNewReply.handlers[b]=null;}}gNewReplyHost.overlay.get("contentBox").query(".c-reply").removeClass("displaynone");var a=gNewReplyHost.overlay.getStdModNode(CY.WidgetStdMod.FOOTER);if(!sv_loggedIn){gNewReply.val["name"]=a.query(".n_name").get("value");gNewReply.val["email"]=a.query(".n_email").get("value");}gNewReply.val["title"]=a.query(".n_title").get("value");gNewReply.val["content"]=a.query(".n_content").get("value");gNewReply.val["tags"]=a.query(".n_tags").get("value");a.set("innerHTML","");gNewReplyHost=null;}};onAddNewReplyClick=function(){if(!sv_loggedIn){var b=CY.get("#"+gNewReply.ids["nameInputId"]).get("value");gPrefs.persist("user","name",b);var a=CY.get("#"+gNewReply.ids["emailInputId"]).get("value");gPrefs.persist("user","email",a);}gSync.saveComment(gNewReply.ids["formId"]);};onCancelNewReplyClick=function(){gSync.cancelReply();};c_persistPreference=function(b,a,c){gPrefs.persist(b,a,c);};c_readDefaultPreference=function(b,a){return gConf.defaultPrefs[b][a];};c_readPreference=function(b,a){return gPrefs.get(b,a);};c_resetPreferences=function(a){gPrefs.reset(a);};c_applyTextStyle=function(a){CY.use(a);};sliderValToPx=function(d){var a=CY.DOM.winWidth();if(gLayout.isInFrame()){a=parent.$(parent).width();}var b=d/100;b=Math.min(b,gConf.sliderFixedMin);b=Math.max(b,gConf.sliderFixedMax);var c=b*a;return Math.floor(c);};c_setCommentsColWidth=function(c){var a=sliderValToPx(c);gLayout.setLeftColumnWidth(a);var b=gLayout.getTopICommentsWidthFromWidth(a);gIComments.setWidth(b);gICommentForm.overlay.get("boundingBox").setStyle("width",b+"px");changeFormFieldsWidth(gICommentForm.formId,b);if(gNewReply){changeFormFieldsWidth(gNewReply.ids["formId"],b);}if(gEdit){changeFormFieldsWidth(gEdit.ids["formId"],b);}};CY=null;gPrefs=null;gLayout=null;gDb=null;gIComments=null;gSync=null;gGETValues=null;gConf={iCommentLeftPadding:4,iCommentThreadPadding:12,defaultCommentFormat:"markdown",sliderFixedMin:0.9,sliderFixedMax:0.1,iCommentsInitAlloc:2,defaultPrefs:{text:{style:"text-modern-style"},user:{name:"",email:""},general:{animduration:"0.4"},comments:{threadpad:"1"},layout:{comments_col_width:"25"}}};gTextStyles={"text-modern-style":gettext("modern"),"text-classic-style":gettext("classic"),"text-code-style":gettext("code")};YUI({base:sv_media_url+"/js/lib/yui/"+c_yui_base+"/build/",timeout:10000}).use("text-modern-style","cookie","json","overlay","io-form","async-queue","event-mouseenter","anim","collection",function(a){CY=a;gPrefs=new Preferences();gPrefs.init();gLayout=new Layout();gLayout.init();if(sv_withComments){gDb=new Db();gDb.init();gIComments=new IComments();gIComments.init();}gSync=new Sync();gSync.init();CY.on("domready",onDomReady,this);});_reinit=function(a){gIComments.hide();gDb.initComments(a.commentIds);unpaintAllComments();renderCommentScopes();updateFilterResultsCount(a.nbDiscussions,a.nbComments,a.nbReplies);};reinit=function(b){var a=gDb.computeFilterResults(b);_reinit(a);};hideAll=function(){_reinit({commentIds:[],nbDiscussions:0,nbComments:0,nbReplies:0});};updateFilterResultsCount=function(f,a,b){var e=gDb.getCommentsAndRepliesCounts(true);var g=e[0],d=e[1];var c=(a!=0||b!=0)&&(g!=a||d!=b);if(gLayout.isInFrame()){parent.f_updateFilterCountDetailed(c);parent.f_updateFilterCountResult(f,a,b,g,d);}};updateResetFilterResultsCount=function(){var c=gDb.getCommentsAndRepliesCounts(false);var a=c[0],b=c[1];var d=a;updateFilterResultsCount(d,a,b);};renderCommentScopes=function(){for(var a=0;a<gDb.comments.length;a++){var b=gDb.comments[a];paintCommentScope(b);}};onTextMouseUp=function(f){if(readyForAction()){var c=getSelectionInfo();if(c!=null){updateICommentFormSelection(c);if(gEditICommentHost!=null){var g=CY.get("#"+gEdit.ids["changeScopeInputId"]+" input").get("checked");if(g){gEditICommentHost.scrollIntoView();}}}else{var d=f.target;if(d.hasClass("c-c")){var b=CY.Node.getDOMNode(d);var a=getCommentIdsFromClasses(b);if(a.length>0){checkForOpenedDialog(null,function(){gSync.showComments(a,[f.pageX,f.pageY],false);});}}}}};gLastScrollTime=null;checkForAlignement=function(){var a=(new Date()).getTime();if((gLastScrollTime!=null)&&(a-gLastScrollTime)>200){positionICommentForm();gLastScrollTime=null;}};onFrameScroll=function(){gLastScrollTime=(new Date()).getTime();};browse=function(a,b){gSync.browse(a,b);};initialConnect=function(){CY.on("mouseup",onTextMouseUp,"#textcontainer");gTimer=CY.Lang.later(200,this,checkForAlignement,[],true);CY.on("scroll",onFrameScroll,window,this,true);CY.on("resize",onFrameScroll,window,this,true);};preventLinksInText=function(){var a=function(g){var c=g.target;var d=null;while(c!=null&&d==null){c=c.get("parentNode");d=c.get("href");}if(c!=null&&d!=null){var b=window.location.href;var f=b.indexOf("#");if(f!=-1){b=b.substring(0,f);}if(d.indexOf(b)==-1){window.open(c.get("href"));g.preventDefault();}}};CY.all("#textcontainer a").on("click",a);};onDomReady=function(b){preventLinksInText();var a=new CY.AsyncQueue();a.add({fn:function(){if(gLayout.isInComentSite()){parent.toInitialSize();}if(sv_withComments){instanciateICommentForm();}},timeout:5},{fn:function(){gGETValues=CY.JSON.parse(sv_get_params);CY.get("#maincontainer").setStyle("display","block");CY.get("#textcontainer").setStyle("display","block");var e=(sv_withComments)?gPrefs.get("layout","comments_col_width"):0;var d=sliderValToPx(e);gLayout.setLeftColumnWidth(d);if(gLayout.isInFrame()){parent.f_initFrame();parent.f_layoutFrames();if(sv_withComments){parent.f_fillTopToolbar();if(hasPerm("can_create_comment")){parent.$("#add_comment_btn").removeClass("initially_hidden");}parent.f_fillFilterTab();parent.f_fillPreferencesTab();var c=CY.JSON.parse(sv_filter_data);parent.f_updateFilterData(c);parent.f_setFilterValue(gGETValues);}parent.f_fillTextPreferencesTab();}if(gLayout.isInComentSite()){parent.$("#c_fullscreen_btn").show();}else{parent.$("#c_fullscreen_btn").hide();}},timeout:5},{fn:function(){if(sv_withComments){reinit(gGETValues);initialConnect();}},timeout:5},{fn:function(){if(gLayout.isInFrame()){parent.f_interfaceUnfreeze();parent.f_removeLoadingMsg();}if("comment_id_key" in gGETValues){var e=gGETValues.comment_id_key;var g=gDb.getCommentByIdKey(e);if(g!=null){var f=gDb.getPath(g);var c=f[f.length-1];var d=gDb.getCommentByIdKey(e);gSync.showFocusSingleComment(c,d);}}if("comments_auto_display" in gGETValues){gSync.showAllComments();}}});a.run();};1 _afterDlg=function(d){var a=d[0];var c=d[1];var b=d[2];a.call(c,b);};_abortNewCommentConfirmed=function(a){if(isICommentFormVisible()){if(gLayout.isInFrame()){gSync.hideICommentForm({fn:function(){_afterDlg(a);}});gSync.resume();}}};_abortNewReplyConfirmed=function(a){if(gNewReplyHost!=null){if(gLayout.isInFrame()){cancelNewReplyForm();_afterDlg(a);}}};_abortNewEditConfirmed=function(a){if(gEditICommentHost!=null){if(gLayout.isInFrame()){cancelEditForm();_afterDlg(a);}}};checkForOpenedDialog=function(e,b,d,c){var a=[];if(e!=null){a=CY.Array.map(gDb.getThreads([gDb.getComment(e.commentId)]),function(f){return f.id;});}if(isICommentFormVisible()||(gNewReplyHost!=null&&(e==null||CY.Array.indexOf(a,gNewReplyHost.commentId)!=-1))||(gEditICommentHost!=null&&(e==null||CY.Array.indexOf(a,gEditICommentHost.commentId)!=-1))){if(gLayout.isInFrame()){if(isICommentFormVisible()){parent.f_yesNoDialog(gettext("New comment will be canceled, continue?"),gettext("Warning"),null,null,null,_abortNewCommentConfirmed,this,[b,d,c]);}else{if(gNewReplyHost!=null){parent.f_yesNoDialog(gettext("Started reply will be canceled, continue?"),gettext("Warning"),null,null,null,_abortNewReplyConfirmed,this,[b,d,c]);}else{if(gEditICommentHost!=null){parent.f_yesNoDialog(gettext("Started comment edition will be canceled, continue?"),gettext("Warning"),null,null,null,_abortNewEditConfirmed,this,[b,d,c]);}}}}}else{b.call(d,[]);}};IComment=function(){this.commentId=null;var l=gLayout.getTopICommentsWidth();var a=gConf.iCommentLeftPadding;var r=gettext("change comment state to pending");var n=gettext("change comment state to approved");var e=gettext("change comment state to unapproved");var q=gettext("cancel changing the state of this comment");var c=gettext("pending");var d=gettext("approved");var m=gettext("unapproved");var b=gettext("cancel");var p=gettext("show replies");var s=gettext("change to:");var i=ngettext("reply","replies",1);var g=gettext("edit comment");var j=gettext("delete comment");var o=gettext("edit");var f=gettext("delete");var k=gettext("close");var h=gettext("show scope");var t=gettext("Comment is detached: it was created on a previous version and text it applied to has been modified or removed.");this.overlay=new CY.Overlay({zIndex:3,shim:false,visible:false,width:l,xy:[a,0],headerContent:'<div class="icomment-header"><div class="c-iactions"><a class="c-moderate c-action" title="">vis</a> <a class="c-edit c-action" title="'+g+'" alt="'+g+'">'+o+'</a> <a class="c-delete c-action" title="'+j+'" alt="'+j+'">'+f+'</a> </div><div class="c-state-actions displaynone">'+s+' <a class="c-state-pending c-action" title="'+r+'" alt="'+r+'">'+c+'</a> <a class="c-state-approved c-action" title="'+n+'" alt="'+n+'">'+d+'</a> <a class="c-state-unapproved c-action" title="'+e+'" alt="'+e+'">'+m+'</a> <a class="c-state-cancel c-action" title="'+q+'" alt="'+q+'">'+b+'</a> </div><div class="c-no-scope-msg">'+t+'</div><a class="c-show-scope c-action" title="'+h+'" alt="'+h+'"><em>-</em></a><a class="c-close c-action" title="'+k+'" alt="'+k+'"><em>X</em></a></div>',bodyContent:'<div class="icomment-body"><span class="c-content"></span><span class="c-ireplyactions"><a class="c-readreplies c-action" title="'+p+'" alt="'+p+'">'+p+'</a> <a class="c-reply c-action" title="'+i+'" alt="'+i+'">'+i+"</a> </span></div>"});this.overlay.get("contentBox").addClass("c-comment");this.overlay.render("#leftcolumn");this.animation=new CY.Anim({node:this.overlay.get("boundingBox"),duration:gPrefs.get("general","animduration"),easing:CY.Easing.easeOut});this.overlay.get("contentBox").query(".c-close").on("click",this.onCloseCommentClick,this);this.overlay.get("contentBox").query(".c-moderate").on("click",this.onModerateCommentClick,this);this.overlay.get("contentBox").query(".c-state-pending").on("click",this.onPendingCommentClick,this);this.overlay.get("contentBox").query(".c-state-approved").on("click",this.onApprovedCommentClick,this);this.overlay.get("contentBox").query(".c-state-unapproved").on("click",this.onUnapprovedCommentClick,this);this.overlay.get("contentBox").query(".c-state-cancel").on("click",this.onCancelStateChangeClick,this);this.overlay.get("contentBox").query(".c-edit").on("click",this.onEditCommentClick,this);this.overlay.get("contentBox").query(".c-delete").on("click",this.onDeleteCommentClick,this);this.overlay.get("contentBox").query(".c-reply").on("click",this.onReplyCommentClick,this);this.overlay.get("contentBox").query(".c-readreplies").on("click",this.onReadRepliesCommentClick,this);this.overlay.get("contentBox").query(".icomment-header").on("mouseenter",this.onMouseEnterHeader,this);this.overlay.get("contentBox").query(".icomment-header").on("mouseleave",this.onMouseLeaveHeader,this);this.overlay.get("contentBox").on("click",this.onCommentClick,this);};IComment.prototype={onCloseCommentClick:function(a){a.halt();if(readyForAction()&&this.isVisible()){gSync.closeComment(this);}},onModerateCommentClick:function(a){a.halt();if(readyForAction()&&this.isVisible()){this.overlay.get("contentBox").query(".c-iactions").addClass("displaynone");this.overlay.get("contentBox").query(".c-state-actions").removeClass("displaynone");}},onPendingCommentClick:function(a){a.halt();if(readyForAction()&&this.isVisible()){gSync.moderateComment(this,"pending");}},onApprovedCommentClick:function(a){a.halt();if(readyForAction()&&this.isVisible()){gSync.moderateComment(this,"approved");}},onUnapprovedCommentClick:function(a){a.halt();if(readyForAction()&&this.isVisible()){gSync.moderateComment(this,"unapproved");}},onCancelStateChangeClick:function(a){a.halt();if(readyForAction()&&this.isVisible()){this.overlay.get("contentBox").query(".c-iactions").removeClass("displaynone");this.overlay.get("contentBox").query(".c-state-actions").addClass("displaynone");}},onDeleteCommentClick:function(a){a.halt();if(readyForAction()&&this.isVisible()){gSync.removeComment(this);}},onEditCommentClick:function(a){a.halt();if(readyForAction()&&this.isVisible()){gSync.showEditForm(this);}},onReplyCommentClick:function(a){a.halt();if(readyForAction()&&this.isVisible()){gSync.showReplyForm(this);}},onReadRepliesCommentClick:function(a){a.halt();if(readyForAction()&&this.isVisible()){gSync.openComment(this);}},onCommentClick:function(d){if(readyForAction()&&this.isVisible()){if(d.target.get("target")=="_blank"){var b=d.target;var g=sv_site_url+sv_text_view_show_comment_url;if(b.get("href").indexOf(g)==0){var a=(new RegExp("comment_id_key=([^&]*)","g"))c(b.get("href"));if(a!=null){var c=a[1];var f=gDb.getCommentByIdKey(c);if(f!=null){d.halt();if(!b.hasClass("c-permalink")){checkForOpenedDialog(null,function(){gSync.showSingleComment(f);});}}}}}else{if(gShowingAllComments){if(!this._isHostingAForm()){var f=gDb.getComment(this.commentId);checkForOpenedDialog(null,function(){if(f!=null){gSync.showSingleComment(f);}});}}else{gSync.activate(this);}}}},onMouseEnterHeader:function(){if(readyForAction()&&this.isVisible()&&(sv_prefix=="")){this.overlay.get("contentBox").query(".c-permalink").removeClass("displaynone");}},onMouseLeaveHeader:function(){if(readyForAction()&&this.isVisible()&&(sv_prefix=="")){this.overlay.get("contentBox").query(".c-permalink").addClass("displaynone");}},setWidth:function(a){this.overlay.get("boundingBox").setStyle("width",a+"px");},activate:function(){this.overlay.get("boundingBox").addClass("c-focus-comment");},deactivate:function(){this.overlay.get("boundingBox").removeClass("c-focus-comment");},hide:function(){if(gIComments.isTopActive(this.commentId)){if(!gIComments.activateVisibleNext()){gIComments.deactivate();}}if(this.isVisible()){this.overlay.hide();this.overlay.blur();}},hideContent:function(){this.overlay.get("contentBox").query(".icomment-header").addClass("displaynone");this.overlay.get("contentBox").query(".icomment-body").addClass("displaynone");},showContent:function(){this.overlay.get("contentBox").query(".icomment-header").removeClass("displaynone");this.overlay.get("contentBox").query(".icomment-body").removeClass("displaynone");},isVisible:function(){return this.overlay.get("visible");},show:function(){this.hideReadRepliesLnk();return this.overlay.show();},showReadRepliesLnk:function(){this.overlay.get("contentBox").query(".c-readreplies").removeClass("displaynone");},hideReadRepliesLnk:function(){this.overlay.get("contentBox").query(".c-readreplies").addClass("displaynone");},changeModeration:function(b){var a=this.overlay.get("contentBox").query(".c-moderate");a.set("innerHTML",gettext(b.state));a.removeClass("c-state-approved");a.removeClass("c-state-pending");a.removeClass("c-state-unapproved");a.addClass("c-state-"+b.state);this.overlay.get("contentBox").query(".c-iactions").removeClass("displaynone");this.overlay.get("contentBox").query(".c-state-actions").addClass("displaynone");},isfetched:function(){return(this.commentId!=null);},unfetch:function(){this.commentId=null;},fetch:function(h){this.commentId=h.id;var b=this.overlay.get("boundingBox");if(h.start_wrapper!=-1){b.addClass("c-has-scope");b.removeClass("c-has-no-scope");}else{b.addClass("c-has-no-scope");b.removeClass("c-has-scope");}if(h.reply_to_id!=null){b.addClass("c-is-reply");}else{b.removeClass("c-is-reply");}var f=interpolate(gettext("last modified on %(date)s"),{date:h.modified_user_str},true);var k=(h.modified==h.created)?"":'<a title="'+f+'"> * </a>';var i=gettext("Permalink to this comment");var n="";if(sv_prefix==""){n='<a class="c-permalink displaynone c-action" target="_blank" title="'+i+'" href="/" >¶ </a>';}var j=interpolate(gettext("by %(name)s, created on %(date)s"),{name:h.name,date:h.created_user_str},true);var c='<span class="c-header"><div class="c-header-title">'+h.title+n+'</div><div class="c-infos">'+j+"</div></span>";var d=CY.Node.create(c);var o=b.query(".c-header");if(o==null){b.query(".icomment-header").insertBefore(d,b.one(".c-iactions"));}else{o.get("parentNode").replaceChild(d,o);}var g=CY.Node.create('<div class="c-tags"><span class="c-tags-infos">tags:</span>'+h.tags+"</div>");var m=b.query(".c-tags");if(m==null){b.query(".icomment-header").appendChild(g);}else{m.get("parentNode").replaceChild(g,m);}if(h.tags==""){g.addClass("displaynone");}var e=CY.Node.create('<span class="c-content">'+h.content_html+"</span>");var a=b.query(".c-content");if(a==null){b.query(".icomment-body").appendChild(e);}else{a.get("parentNode").replaceChild(e,a);}if(sv_prefix==""){b.query(".c-permalink").set("href",sv_site_url+h.permalink);}this.changeModeration(h);var l=b.queryAll(".c-content a");if(l!=null){l.setAttribute("target","_blank");}l=b.queryAll(".c-header-title a");if(l!=null){l.setAttribute("target","_blank");}this.permAdapt(h);},permAdapt:function(e){var b=this.overlay.get("contentBox").query(".c-delete");if(b){if(!e.can_delete){b.addClass("displaynone");}else{b.removeClass("displaynone");}}var a=this.overlay.get("contentBox").query(".c-edit");if(a){if(!e.can_edit){a.addClass("displaynone");}else{a.removeClass("displaynone");}}var d=this.overlay.get("contentBox").query(".c-reply");if(d){if(!hasPerm("can_create_comment")){d.addClass("displaynone");}else{d.removeClass("displaynone");}}var c=this.overlay.get("contentBox").query(".c-moderate");if(c){if(!e.can_moderate){c.addClass("displaynone");}else{c.removeClass("displaynone");}}},setThreadPad:function(a){this.overlay.get("contentBox").query(".yui-widget-hd").setStyle("paddingLeft",a+"px");this.overlay.get("contentBox").query(".yui-widget-bd").setStyle("paddingLeft",a+"px");},setPosition:function(b){var a=this.overlay.get("boundingBox");a.setStyle("opacity",1);a.setXY(b);},getPosition:function(b){var a=this.overlay.get("boundingBox");return a.getXY();},onAnimationEnd:function(){if(!CY.Lang.isUndefined(this["animation-handle"])&&!CY.Lang.isNull(this["animation-handle"])){this["animation-handle"].detach();this["animation-handle"]=null;}gIComments.signalAnimationEnd();if(gIComments.animationsEnded()){gIComments.whenAnimationsEnd();}},onAnimationEndFocus:function(){if(!CY.Lang.isUndefined(this["animation-handle"])&&!CY.Lang.isNull(this["animation-handle"])){this["animation-handle"].detach();this["animation-handle"]=null;}gIComments.signalAnimationEnd();if(gIComments.animationsEnded()){gIComments.whenAnimationsEndFocus();}},setAnimationToPosition:function(c,a){var b=this.overlay.get("boundingBox");if(gPrefs.get("general","animduration")<0.011){b.setXY(c);}this.animation.set("to",{xy:c});this.animation.set("duration",gPrefs.get("general","animduration"));if(a){this["animation-handle"]=this.animation.on("end",this.onAnimationEndFocus,this);}else{this["animation-handle"]=this.animation.on("end",this.onAnimationEnd,this);}return this.animation;},getHeight:function(){return this.overlay.get("boundingBox").get("offsetHeight");},scrollIntoView:function(){if(!this.overlay.get("contentBox").inViewportRegion()){this.overlay.get("contentBox").scrollIntoView(true);}},_isHostingAForm:function(){return(this.isVisible()&&((gNewReplyHost!=null&&gNewReplyHost==this)||(gEditICommentHost!=null&&gEditICommentHost==this)));}};hasPerm=function(a){return(-1!=CY.Array.indexOf(sv_user_permissions,a));};_afterDlg=function(g){var f=g[0];var h=g[1];var e=g[2];f.call(h,e);};_abortNewCommentConfirmed=function(b){if(isICommentFormVisible()){if(gLayout.isInFrame()){gSync.hideICommentForm({fn:function(){_afterDlg(b);}});gSync.resume();}}};_abortNewReplyConfirmed=function(b){if(gNewReplyHost!=null){if(gLayout.isInFrame()){cancelNewReplyForm();_afterDlg(b);}}};_abortNewEditConfirmed=function(b){if(gEditICommentHost!=null){if(gLayout.isInFrame()){cancelEditForm();_afterDlg(b);}}};checkForOpenedDialog=function(h,f,i,j){var g=[];if(h!=null){g=CY.Array.map(gDb.getThreads([gDb.getComment(h.commentId)]),function(a){return a.id;});}if(isICommentFormVisible()||(gNewReplyHost!=null&&(h==null||CY.Array.indexOf(g,gNewReplyHost.commentId)!=-1))||(gEditICommentHost!=null&&(h==null||CY.Array.indexOf(g,gEditICommentHost.commentId)!=-1))){if(gLayout.isInFrame()){if(isICommentFormVisible()){parent.f_yesNoDialog(gettext("New comment will be canceled, continue?"),gettext("Warning"),null,null,null,_abortNewCommentConfirmed,this,[f,i,j]);}else{if(gNewReplyHost!=null){parent.f_yesNoDialog(gettext("Started reply will be canceled, continue?"),gettext("Warning"),null,null,null,_abortNewReplyConfirmed,this,[f,i,j]);}else{if(gEditICommentHost!=null){parent.f_yesNoDialog(gettext("Started comment edition will be canceled, continue?"),gettext("Warning"),null,null,null,_abortNewEditConfirmed,this,[f,i,j]);}}}}}else{f.call(i,[]);}};IComment=function(){this.commentId=null;var C=gLayout.getTopICommentsWidth();var N=gConf.iCommentLeftPadding;var w=gettext("change comment state to pending");var A=gettext("change comment state to approved");var J=gettext("change comment state to unapproved");var x=gettext("cancel changing the state of this comment");var L=gettext("pending");var K=gettext("approved");var B=gettext("unapproved");var M=gettext("cancel");var y=gettext("show replies");var v=gettext("change to:");var F=ngettext("reply","replies",1);var H=gettext("edit comment");var E=gettext("delete comment");var z=gettext("edit");var I=gettext("delete");var D=gettext("close");var G=gettext("show scope");var u=gettext("Comment is detached: it was created on a previous version and text it applied to has been modified or removed.");this.overlay=new CY.Overlay({zIndex:3,shim:false,visible:false,width:C,xy:[N,0],headerContent:'<div class="icomment-header"><div class="c-iactions"><a class="c-moderate c-action" title="">vis</a> <a class="c-edit c-action" title="'+H+'" alt="'+H+'">'+z+'</a> <a class="c-delete c-action" title="'+E+'" alt="'+E+'">'+I+'</a> </div><div class="c-state-actions displaynone">'+v+' <a class="c-state-pending c-action" title="'+w+'" alt="'+w+'">'+L+'</a> <a class="c-state-approved c-action" title="'+A+'" alt="'+A+'">'+K+'</a> <a class="c-state-unapproved c-action" title="'+J+'" alt="'+J+'">'+B+'</a> <a class="c-state-cancel c-action" title="'+x+'" alt="'+x+'">'+M+'</a> </div><div class="c-no-scope-msg">'+u+'</div><a class="c-show-scope c-action" title="'+G+'" alt="'+G+'"><em>-</em></a><a class="c-close c-action" title="'+D+'" alt="'+D+'"><em>X</em></a></div>',bodyContent:'<div class="icomment-body"><span class="c-content"></span><span class="c-ireplyactions"><a class="c-readreplies c-action" title="'+y+'" alt="'+y+'">'+y+'</a> <a class="c-reply c-action" title="'+F+'" alt="'+F+'">'+F+"</a> </span></div>"});this.overlay.get("contentBox").addClass("c-comment");this.overlay.render("#leftcolumn");this.animation=new CY.Anim({node:this.overlay.get("boundingBox"),duration:gPrefs.get("general","animduration"),easing:CY.Easing.easeOut});this.overlay.get("contentBox").query(".c-close").on("click",this.onCloseCommentClick,this);this.overlay.get("contentBox").query(".c-moderate").on("click",this.onModerateCommentClick,this);this.overlay.get("contentBox").query(".c-state-pending").on("click",this.onPendingCommentClick,this);this.overlay.get("contentBox").query(".c-state-approved").on("click",this.onApprovedCommentClick,this);this.overlay.get("contentBox").query(".c-state-unapproved").on("click",this.onUnapprovedCommentClick,this);this.overlay.get("contentBox").query(".c-state-cancel").on("click",this.onCancelStateChangeClick,this);this.overlay.get("contentBox").query(".c-edit").on("click",this.onEditCommentClick,this);this.overlay.get("contentBox").query(".c-delete").on("click",this.onDeleteCommentClick,this);this.overlay.get("contentBox").query(".c-reply").on("click",this.onReplyCommentClick,this);this.overlay.get("contentBox").query(".c-readreplies").on("click",this.onReadRepliesCommentClick,this);this.overlay.get("contentBox").query(".icomment-header").on("mouseenter",this.onMouseEnterHeader,this);this.overlay.get("contentBox").query(".icomment-header").on("mouseleave",this.onMouseLeaveHeader,this);this.overlay.get("contentBox").on("click",this.onCommentClick,this);};IComment.prototype={onCloseCommentClick:function(b){b.halt();if(readyForAction()&&this.isVisible()){gSync.closeComment(this);}},onModerateCommentClick:function(b){b.halt();if(readyForAction()&&this.isVisible()){this.overlay.get("contentBox").query(".c-iactions").addClass("displaynone");this.overlay.get("contentBox").query(".c-state-actions").removeClass("displaynone");}},onPendingCommentClick:function(b){b.halt();if(readyForAction()&&this.isVisible()){gSync.moderateComment(this,"pending");}},onApprovedCommentClick:function(b){b.halt();if(readyForAction()&&this.isVisible()){gSync.moderateComment(this,"approved");}},onUnapprovedCommentClick:function(b){b.halt();if(readyForAction()&&this.isVisible()){gSync.moderateComment(this,"unapproved");}},onCancelStateChangeClick:function(b){b.halt();if(readyForAction()&&this.isVisible()){this.overlay.get("contentBox").query(".c-iactions").removeClass("displaynone");this.overlay.get("contentBox").query(".c-state-actions").addClass("displaynone");}},onDeleteCommentClick:function(b){b.halt();if(readyForAction()&&this.isVisible()){gSync.removeComment(this);}},onEditCommentClick:function(b){b.halt();if(readyForAction()&&this.isVisible()){gSync.showEditForm(this);}},onReplyCommentClick:function(b){b.halt();if(readyForAction()&&this.isVisible()){gSync.showReplyForm(this);}},onReadRepliesCommentClick:function(b){b.halt();if(readyForAction()&&this.isVisible()){gSync.openComment(this);}},onCommentClick:function(k){if(readyForAction()&&this.isVisible()){if(k.target.get("target")=="_blank"){var e=k.target;var i=sv_site_url+sv_text_view_show_comment_url;if(e.get("href").indexOf(i)==0){var h=(new RegExp("comment_id_key=([^&]*)","g"))c(e.get("href"));if(h!=null){var l=h[1];var j=gDb.getCommentByIdKey(l);if(j!=null){k.halt();if(!e.hasClass("c-permalink")){checkForOpenedDialog(null,function(){gSync.showSingleComment(j);});}}}}}else{if(gShowingAllComments){if(!this._isHostingAForm()){var j=gDb.getComment(this.commentId);checkForOpenedDialog(null,function(){if(j!=null){gSync.showSingleComment(j);}});}}else{gSync.activate(this);}}}},onMouseEnterHeader:function(){if(readyForAction()&&this.isVisible()&&(sv_prefix=="")){this.overlay.get("contentBox").query(".c-permalink").removeClass("displaynone");}},onMouseLeaveHeader:function(){if(readyForAction()&&this.isVisible()&&(sv_prefix=="")){this.overlay.get("contentBox").query(".c-permalink").addClass("displaynone");}},setWidth:function(b){this.overlay.get("boundingBox").setStyle("width",b+"px");},activate:function(){this.overlay.get("boundingBox").addClass("c-focus-comment");},deactivate:function(){this.overlay.get("boundingBox").removeClass("c-focus-comment");},hide:function(){if(gIComments.isTopActive(this.commentId)){if(!gIComments.activateVisibleNext()){gIComments.deactivate();}}if(this.isVisible()){this.overlay.hide();this.overlay.blur();}},hideContent:function(){this.overlay.get("contentBox").query(".icomment-header").addClass("displaynone");this.overlay.get("contentBox").query(".icomment-body").addClass("displaynone");},showContent:function(){this.overlay.get("contentBox").query(".icomment-header").removeClass("displaynone");this.overlay.get("contentBox").query(".icomment-body").removeClass("displaynone");},isVisible:function(){return this.overlay.get("visible");},show:function(){this.hideReadRepliesLnk();return this.overlay.show();},showReadRepliesLnk:function(){this.overlay.get("contentBox").query(".c-readreplies").removeClass("displaynone");},hideReadRepliesLnk:function(){this.overlay.get("contentBox").query(".c-readreplies").addClass("displaynone");},changeModeration:function(c){var d=this.overlay.get("contentBox").query(".c-moderate");d.set("innerHTML",gettext(c.state));d.removeClass("c-state-approved");d.removeClass("c-state-pending");d.removeClass("c-state-unapproved");d.addClass("c-state-"+c.state);this.overlay.get("contentBox").query(".c-iactions").removeClass("displaynone");this.overlay.get("contentBox").query(".c-state-actions").addClass("displaynone");},isfetched:function(){return(this.commentId!=null);},unfetch:function(){this.commentId=null;},fetch:function(w){this.commentId=w.id;var C=this.overlay.get("boundingBox");if(w.start_wrapper!=-1){C.addClass("c-has-scope");C.removeClass("c-has-no-scope");}else{C.addClass("c-has-no-scope");C.removeClass("c-has-scope");}if(w.reply_to_id!=null){C.addClass("c-is-reply");}else{C.removeClass("c-is-reply");}var y=interpolate(gettext("last modified on %(date)s"),{date:w.modified_user_str},true);var t=(w.modified==w.created)?"":'<a title="'+y+'"> * </a>';var v=gettext("Permalink to this comment");var q="";if(sv_prefix==""){q='<a class="c-permalink displaynone c-action" target="_blank" title="'+v+'" href="/" >¶ </a>';}var u=interpolate(gettext("by %(name)s, created on %(date)s"),{name:w.name,date:w.created_user_str},true);var B='<span class="c-header"><div class="c-header-title">'+w.title+q+'</div><div class="c-infos">'+u+"</div></span>";var A=CY.Node.create(B);var p=C.query(".c-header");if(p==null){C.query(".icomment-header").insertBefore(A,C.one(".c-iactions"));}else{p.get("parentNode").replaceChild(A,p);}var x=CY.Node.create('<div class="c-tags"><span class="c-tags-infos">tags:</span>'+w.tags+"</div>");var r=C.query(".c-tags");if(r==null){C.query(".icomment-header").appendChild(x);}else{r.get("parentNode").replaceChild(x,r);}if(w.tags==""){x.addClass("displaynone");}var z=CY.Node.create('<span class="c-content">'+w.content_html+"</span>");var D=C.query(".c-content");if(D==null){C.query(".icomment-body").appendChild(z);}else{D.get("parentNode").replaceChild(z,D);}if(sv_prefix==""){C.query(".c-permalink").set("href",sv_site_url+w.permalink);}this.changeModeration(w);var s=C.queryAll(".c-content a");if(s!=null){s.setAttribute("target","_blank");}s=C.queryAll(".c-header-title a");if(s!=null){s.setAttribute("target","_blank");}this.permAdapt(w);},permAdapt:function(h){var f=this.overlay.get("contentBox").query(".c-delete");if(f){if(!h.can_delete){f.addClass("displaynone");}else{f.removeClass("displaynone");}}var g=this.overlay.get("contentBox").query(".c-edit");if(g){if(!h.can_edit){g.addClass("displaynone");}else{g.removeClass("displaynone");}}var i=this.overlay.get("contentBox").query(".c-reply");if(i){if(!hasPerm("can_create_comment")){i.addClass("displaynone");}else{i.removeClass("displaynone");}}var j=this.overlay.get("contentBox").query(".c-moderate");if(j){if(!h.can_moderate){j.addClass("displaynone");}else{j.removeClass("displaynone");}}},setThreadPad:function(b){this.overlay.get("contentBox").query(".yui-widget-hd").setStyle("paddingLeft",b+"px");this.overlay.get("contentBox").query(".yui-widget-bd").setStyle("paddingLeft",b+"px");},setPosition:function(c){var d=this.overlay.get("boundingBox");d.setStyle("opacity",1);d.setXY(c);},getPosition:function(c){var d=this.overlay.get("boundingBox");return d.getXY();},onAnimationEnd:function(){if(!CY.Lang.isUndefined(this["animation-handle"])&&!CY.Lang.isNull(this["animation-handle"])){this["animation-handle"].detach();this["animation-handle"]=null;}gIComments.signalAnimationEnd();if(gIComments.animationsEnded()){gIComments.whenAnimationsEnd();}},onAnimationEndFocus:function(){if(!CY.Lang.isUndefined(this["animation-handle"])&&!CY.Lang.isNull(this["animation-handle"])){this["animation-handle"].detach();this["animation-handle"]=null;}gIComments.signalAnimationEnd();if(gIComments.animationsEnded()){gIComments.whenAnimationsEndFocus();}},setAnimationToPosition:function(f,e){var d=this.overlay.get("boundingBox");if(gPrefs.get("general","animduration")<0.011){d.setXY(f);}this.animation.set("to",{xy:f});this.animation.set("duration",gPrefs.get("general","animduration"));if(e){this["animation-handle"]=this.animation.on("end",this.onAnimationEndFocus,this);}else{this["animation-handle"]=this.animation.on("end",this.onAnimationEnd,this);}return this.animation;},getHeight:function(){return this.overlay.get("boundingBox").get("offsetHeight");},scrollIntoView:function(){if(!this.overlay.get("contentBox").inViewportRegion()){this.overlay.get("contentBox").scrollIntoView(true);}},_isHostingAForm:function(){return(this.isVisible()&&((gNewReplyHost!=null&&gNewReplyHost==this)||(gEditICommentHost!=null&&gEditICommentHost==this)));}};hasPerm=function(b){return(-1!=CY.Array.indexOf(sv_user_permissions,b));};paintCommentScope=function(b){if(b.reply_to_id==null&&b.start_wrapper!=-1){var a={start:{elt:document.getElementById("sv_"+b.start_wrapper),offset:b.start_offset},end:{elt:document.getElementById("sv_"+b.end_wrapper),offset:b.end_offset}};if(document.getElementById("sv_"+b.start_wrapper)==null){warn_server({from:"paintCommentScope",start_wrapper:b.start_wrapper});}else{if(document.getElementById("sv_"+b.end_wrapper)==null){warn_server({from:"paintCommentScope",end_wrapper:b.end_wrapper});}else{a.start=_convertSelectionFromCSToCC(a.start);a.end=_convertSelectionFromCSToCC(a.end);renderComment(a,b.id);}}}};getCommentIdsFromClasses=function(b){var a=[];var e=b.className.split(" ");for(var d=0,c=e.length;d<c;d++){if(e[d].indexOf("c-id-")==0){a.push(parseInt(e[d].substring("c-id-".length)));}}return a;};renderComment=function(d,c){var a=d.start["offset"];var b=d.end["offset"];var f=d.start["elt"];var e=d.end["elt"];if((f!=null)&&(e!=null)&&_getTextNodeContent(f)!=""&&_getTextNodeContent(e)!=""){markWholeNodesAsComments(f,e,c);markEndsAsComments(f,a,e,b,c);}};markWholeNodesAsComments=function(d,c,b){var a=_findCommonAncestor(d,c);_dynSpanToAnc(d,a,b,false);_dynSpanToAnc(c,a,b,true);_dynSpanInBetween(a,d,c,b);};_setTextNodeContent=function(a,b){CY.DOM.setText(a,b);};_getTextNodeContent=function(a){return CY.DOM.getText(a);};markEndsAsComments=function(d,i,l,j,h){var n=_getTextNodeContent(d).substring(0,i);var o=_getTextNodeContent(d).substring(i);var p=_getTextNodeContent(l).substring(0,j);var g=_getTextNodeContent(l).substring(j);var b=(d===l);if(o!=""){if(CY.DOM.hasClass(d,"c-c")){var f=null,k=null,c=null,a=null;var m=(b)?_getTextNodeContent(d).substring(i,j):o;if(b&&(g!="")){c=d;f=c;}if(m!=""){if(f==null){k=d;}else{k=_yuiCloneNode(d);f.parentNode.insertBefore(k,f);}f=k;}if(n!=""){if(f==null){a=d;}else{a=_yuiCloneNode(d);f.parentNode.insertBefore(a,f);}f=a;}if(c!=null){_setTextNodeContent(c,g);}if(k!=null){_setTextNodeContent(k,m);_addIdClass(k,h);}if(a!=null){_setTextNodeContent(a,n);}}}if((!b)&&(p!="")){if(CY.DOM.hasClass(l,"c-c")){var f=null,e=null,c=null;if(g!=""){c=l;f=l;}if(p!=""){if(f==null){e=l;}else{e=_yuiCloneNode(l);f.parentNode.insertBefore(e,f);}f=e;}if(c!=null){_setTextNodeContent(c,g);}if(e!=null){_addIdClass(e,h);_setTextNodeContent(e,p);}}}};_yuiCloneNode=function(b){var a=CY.Node.getDOMNode(CY.get("#"+b.id).cloneNode(true));a.id=CY.guid();return a;};_dynSpanToAnc=function(a,e,d,f){var g=a;while((g!=null)&&(g!==e)&&(g.parentNode!==e)){var b=null;if(f){b=g.previousSibling;}else{b=g.nextSibling;}if(b==null){g=g.parentNode;}else{g=b;_recAddComment(g,d);}}};_dynSpanInBetween=function(g,h,f,d){var b=h;var e=null;while(b){if(b.parentNode===g){e=b;break;}b=b.parentNode;}if(e!=null){b=f;var c=null;while(b){if(b.parentNode===g){c=b;break;}b=b.parentNode;}if(c!=null){b=e.nextSibling;while((b!=null)&&(b!==c)){_recAddComment(b,d);b=b.nextSibling;}}}};_bruteContains=function(a,b){while(b){if(a===b){return true;}b=b.parentNode;}return false;},_addIdClass=function(a,b){CY.DOM.addClass(a,"c-id-"+b);_updateCommentCounter(a);};_removeIdClass=function(a,b){CY.DOM.removeClass(a,"c-id-"+b);_updateCommentCounter(a);};_removeIdClasses=function(a){var b=_cgetRegExp("(?:^|\\s+)c-id-(?:\\d+)","g");a.className=a.className.replace(b," ");_updateCommentCounter(a);};_recAddComment=function(a,b){if(CY.DOM.hasClass(a,"c-c")){_addIdClass(a,b);}else{var d=a.firstChild;while(d!=null){_recAddComment(d,b);d=d.nextSibling;}}};_findCommonAncestor=function(c,a){if(_bruteContains(c,a)){return c;}else{var b=a;while((b!=null)&&!_bruteContains(b,c)){b=b.parentNode;}return b;}};_cregexCache={};_cgetRegExp=function(b,a){a=a||"";if(!_cregexCache[b+a]){_cregexCache[b+a]=new RegExp(b,a);}return _cregexCache[b+a];};_updateCommentCounter=function(b){var c=_cgetRegExp("(?:^|\\s+)c-id-(?:\\d+)","g");var d=b.className.match(c);var a=(d==null)?0:d.length;c=_cgetRegExp("(?:^|\\s+)c-count-(?:\\d+)","g");b.className=b.className.replace(c," ");CY.DOM.addClass(b,"c-count-"+a+" ");};_convertSelectionFromCCToCS=function(b){var d=b.offset;var a=b.elt.parentNode;var c=b.elt.previousSibling;while(c!=null){d+=_getTextNodeContent(c).length;c=c.previousSibling;}return{elt:a,offset:d};};_convertSelectionFromCSToCC=function(d){var a={elt:null,offset:-1};var f=null;var e=d.elt.firstChild;var c=0;while(e!=null){var b=c;c+=_getTextNodeContent(e).length;if(c>=d.offset){a.elt=e;a.offset=d.offset-b;break;}e=e.nextSibling;}return a;};unpaintCommentScope=function(k){var j=k.id;var r="c-id-"+j;var m=[];var t=CY.all("."+r);if(t!=null){for(var h=0,d=t.size();h<d;h++){var q=t.item(h);if(q.hasClass("c-c")){var l=CY.Node.getDOMNode(q);_removeIdClass(l,j);var f=getCommentIdsFromClasses(l);quicksort(f);var a=q.get("previousSibling");if(a!=null){var b=CY.Node.getDOMNode(a);var s=getCommentIdsFromClasses(b);quicksort(s);if(areSortedArraysEqual(f,s)){_setTextNodeContent(l,_getTextNodeContent(b)+_getTextNodeContent(l));m.push(b);}}var e=q.get("nextSibling");if(e!=null){var o=CY.Node.getDOMNode(e);var g=getCommentIdsFromClasses(o);quicksort(g);if(areSortedArraysEqual(f,g)){l.firstChild.data=l.firstChild.data+o.firstChild.data;m.push(o);}}}else{alert("HAS NO c-c ? : "+commentNode.get("id")+" , innerHTML :"+commentNode.get("innerHTML"));return;}}}for(var h=0,d=m.length;h<d;h++){m[h].parentNode.removeChild(m[h]);}};unpaintAllComments=function(){var k=CY.all(".c-s");var f=[];for(var e=0,a=k.size();e<a;e++){var h=k.item(e);var d=h.get("firstChild");var j=CY.Node.getDOMNode(h.get("firstChild"));_removeIdClasses(j);var b=d.get("nextSibling");while(b!=null){var g=CY.Node.getDOMNode(b);j.firstChild.data=j.firstChild.data+g.firstChild.data;f.push(g);b=b.get("nextSibling");}}for(var e=0,a=f.length;e<a;e++){f[e].parentNode.removeChild(f[e]);}};showScope=function(b){var a=CY.all(".c-id-"+b);if(a!=null){a.addClass("c-scope");}};hideScopeAnyway=function(){var a=CY.all(".c-scope");if(a!=null){a.removeClass("c-scope");}};getWrapperAncestor=function(a){var b=a;while(b!=null){if(CY.DOM.hasClass(b,"c-s")){return b;}b=b.parentNode;}return null;};hasWrapperAncestor=function(a){return(getWrapperAncestor(a)!=null);};getSelectionInfo=function(){var J=null,m=null,D=0,c=0,h="";if(window.getSelection){var r=window.getSelection();if(r.rangeCount>0){var l=r.getRangeAt(0);h=l.toString();if(h!=""){var E=document.createRange();E.setStart(r.anchorNode,r.anchorOffset);E.collapse(true);var B=document.createRange();B.setEnd(r.focusNode,r.focusOffset);B.collapse(false);var I=(B.compareBoundaryPoints(2,E)==1);J=(I)?r.anchorNode.parentNode:r.focusNode.parentNode;innerStartNode=(I)?r.anchorNode:r.focusNode;m=(I)?r.focusNode.parentNode:r.anchorNode.parentNode;innerEndNode=(I)?r.focusNode:r.anchorNode;D=(I)?r.anchorOffset:r.focusOffset;c=(I)?r.focusOffset:r.anchorOffset;if(!hasWrapperAncestor(m)&&hasWrapperAncestor(J)){var z=document.createRange();z.setStart(innerStartNode,D);var b=getWrapperAncestor(J);var q=b;z.setEndAfter(q);var f=parseInt(b.id.substring("sv_".length));while(z.toString().length<l.toString().length){f++;var t=CY.get("#sv_"+f);if(t){q=CY.Node.getDOMNode(t);z.setEndAfter(q);}else{break;}}m=q.lastChild;c=CY.DOM.getText(m).length;}else{if(!hasWrapperAncestor(J)&&hasWrapperAncestor(m)){var z=document.createRange();z.setEnd(innerEndNode,c);var g=getWrapperAncestor(m);var p=g;z.setStartBefore(p);var f=parseInt(g.id.substring("sv_".length));while(z.toString().length<l.toString().length){f--;var t=CY.get("#sv_"+f);if(t){p=CY.Node.getDOMNode(t);z.setStartBefore(p);}else{break;}}J=p.firstChild;D=0;}else{if(!hasWrapperAncestor(J)&&!hasWrapperAncestor(m)){var o=h.length;var n=[];for(var f=0;;f++){var G=CY.get("#sv_"+f);if(G==null){break;}else{var x=G.get("text");if(h.indexOf(x)==0){n.push(f);}}}var y=[];for(var f=0;;f++){var G=CY.get("#sv_"+f);if(G==null){break;}else{var x=G.get("text");if(h.indexOf(x)==(o-x.length)){y.push(f);}}}var w=false;for(var C=0;C<n.length;C++){for(var A=0;A<y.length;A++){var v=document.createRange();var k=CY.Node.getDOMNode(CY.get("#sv_"+n[C]));var F=CY.Node.getDOMNode(CY.get("#sv_"+y[A]));v.setStartBefore(k);v.setEndAfter(CY.Node.getDOMNode(F));if((-1<v.compareBoundaryPoints(0,l))&&(1>v.compareBoundaryPoints(2,l))){J=k.firstChild;D=0;m=F.lastChild;c=CY.DOM.getText(F).length;w=true;break;}}if(w){break;}}}}}E.detach();B.detach();}else{return null;}}else{return null;}}else{if(document.selection){var d=document.selection.createRange();if(d.text.length==0){return null;}var a=d.parentElement();var H=d.duplicate();var u=d.duplicate();H.collapse(true);u.collapse(false);J=H.parentElement();while(H.moveStart("character",-1)!=0){if(H.parentElement()!=J){break;}D++;}m=u.parentElement();while(u.moveEnd("character",-1)!=0){if(u.parentElement()!=m){break;}c++;}h=d.text;}}if(!hasWrapperAncestor(J)||!hasWrapperAncestor(m)){return null;}return{text:h,start:{elt:J,offset:D},end:{elt:m,offset:c}};};Preferences=function(){this.prefs={};};Preferences.prototype={init:function(){this._read();},_read:function(){for(var b in gConf.defaultPrefs){this.prefs[b]={};for(var a in gConf.defaultPrefs[b]){var c=null;if(b=="user"&&(a=="name"||a=="email")){c=CY.Cookie.get("user_"+a);}else{c=CY.Cookie.getSub(b,a);}this.prefs[b][a]=(c==null)?gConf.defaultPrefs[b][a]:c;}}},persist:function(b,a,d){var c={path:"/",expires:(new Date()).setFullYear(2100,0,1)};if(b=="user"&&(a=="name"||a=="email")){CY.Cookie.set("user_"+a,d,c);}else{CY.Cookie.setSub(b,a,d,c);}this.prefs[b][a]=d;},get:function(b,a){return this.prefs[b][a];},readDefault:function(b,a){return gConf.defaultPrefs[b][a];},reset:function(a){for(var b=0;b<a.length;b++){var d=a[b];for(var c in gConf.defaultPrefs[d]){this.persist(d,c,gConf.defaultPrefs[d][c]);}}}};gNoSelectionYet=gettext("No selection yet");gFormHtml={formStart:'<form id="###" onsubmit="return false;">',nameInput:gettext("Username:")+'<center><input id="###" name="name" class="n_name user_input" style="padding:1px;" type="text"></input></center>',emailInput:gettext("E-mail address:")+'<center><input id="###" name="email" class="n_email user_input" style="padding:1px;" type="text"></input></center>',titleInput:gettext("Title:")+'<center><input id="###" name="title" class="n_title comment_input" style="padding:1px;" type="text"></input></center>',contentInput:gettext("Content:")+'<center><textarea id="###" name="content" class="n_content comment_input" rows="10" style="padding:1px;"></textarea></center>',tagsInput:gettext("Tag:")+'<center><input id="###" name="tags" class="n_tags comment_input" style="padding:1px;" type="text"></input></center>',hidden:'<input id="###" class="comment_input" name="???" type="hidden" value=""></input>',formEnd:"</form>",changeScope:'<div id="###">'+gettext("Modify comment's scope:")+'<input type="checkbox" name="change_scope"></input></div>',headerTitle:'<center><div id="###" class="c-header-title"></div></center>',currentSel:'<div id="###">'+gettext("Comment will apply to this selection:")+'<br/><div class="current_sel"><div id="???" class="current_sel_ins">'+gNoSelectionYet+"</div></div>#hiddeninput#</div>",btns:'<center><input id="###" type="button" value="'+gettext("Save")+'" /><input id="???" type="button" value="'+gettext("Cancel")+'" /></center>',closeIcon:'<a id="###" class="c-close" title="'+gettext("close")+'"><em> </em></a>'};getHtml=function(f){ret={};ret.headerContent="";if("closeBtnId" in f){ret.headerContent+=gFormHtml.closeIcon.replace("###",f.closeBtnId);}ret.headerContent+=gFormHtml.headerTitle.replace("###",f.formTitleId);var b="";if("changeScopeInputId" in f){b=gFormHtml.changeScope.replace("###",f.changeScopeInputId);}var e="<center>"+gFormHtml.hidden.replace("###",f.selectionPlaceId).replace("???","selection_place")+"</center>";var a=gFormHtml.currentSel.replace("###",f.currentSelId).replace("???",f.currentSelIdI).replace("#hiddeninput#",e);var d=gFormHtml.btns.replace("###",f.addBtnId).replace("???",f.cancelBtnId);var c=gFormHtml.formStart.replace("###",f.formId)+b+a;if("nameInputId" in f){c=c+gFormHtml.nameInput.replace("###",f.nameInputId);}if("emailInputId" in f){c=c+gFormHtml.emailInput.replace("###",f.emailInputId);}c=c+gFormHtml.titleInput.replace("###",f.titleInputId)+gFormHtml.contentInput.replace("###",f.contentInputId)+gFormHtml.tagsInput.replace("###",f.tagsInputId);c=c+gFormHtml.hidden.replace("###",f.formatInputId).replace("???","format");c=c+gFormHtml.hidden.replace("###",f.startWrapperInputId).replace("???","start_wrapper");c=c+gFormHtml.hidden.replace("###",f.endWrapperInputId).replace("???","end_wrapper");c=c+gFormHtml.hidden.replace("###",f.startOffsetInputId).replace("???","start_offset");c=c+gFormHtml.hidden.replace("###",f.endOffsetInputId).replace("???","end_offset");c=c+gFormHtml.hidden.replace("###",f.keyId).replace("???","comment_key");c=c+gFormHtml.hidden.replace("###",f.editCommentId).replace("???","edit_comment_id");c=c+d+gFormHtml.formEnd;ret.bodyContent=c;return ret;};changeFormFieldsWidth=function(d,c){var a=(c-20)+"px";var b=CY.all("#"+d+" input[type='text']");if(b!=null){b.setStyle("width",a);}b=CY.all("#"+d+" textarea");if(b!=null){b.setStyle("width",a);}};addFormErrMsg=function(j,g,d){var f=document.getElementById(j);var b,h,c,a;for(b=0,a=f.elements.length;b<a;++b){h=f.elements[b];if(h.name==g){c=document.createElement("DIV");CY.DOM.addClass(c,"c-error");c.id=h.id+"-err";c.appendChild(document.createTextNode(d));if(h.parentNode.nextSibling){h.parentNode.parentNode.insertBefore(c,h.parentNode.nextSibling);}else{h.parentNode.parentNode.appendChild(c);}}}};removeFormErrMsg=function(b){var a=CY.all("#"+b+" .c-error");if(a!=null){a.each(function(c){c.get("parentNode").removeChild(c);});}};Layout=function(){};Layout.prototype={init:function(){},isInFrame:function(){return(!CY.Lang.isUndefined(parent)&&parent.location!=location&&CY.Lang.isFunction(parent.f_getFrameFilterData));},isInComentSite:function(){var b=false;try{if(!CY.Lang.isUndefined(sv_site_url)&&!CY.Lang.isUndefined(parent)&&!CY.Lang.isUndefined(parent.parent)){var a=new String(parent.parent.location);b=(a.indexOf(sv_site_url)==0);}}catch(c){b=false;}return b;},sliderValToPx:function(d){var a=CY.DOM.winWidth();if(this.isInFrame()){a=parent.$(parent).width();}var b=d/100;b=Math.min(b,gConf.sliderFixedMin);b=Math.max(b,gConf.sliderFixedMax);var c=b*a;return Math.floor(c);},getTopICommentsWidth:function(){return this.getTopICommentsWidthFromWidth(this.sliderValToPx(gPrefs.get("layout","comments_col_width")));},getTopICommentsWidthFromWidth:function(b){var a=b-(2*gConf.iCommentThreadPadding);return a-7;},setLeftColumnWidth:function(a){CY.get("#contentcolumn").setStyle("marginLeft",a+"px");CY.get("#leftcolumn").setStyle("width",a+"px");},parentInterfaceUnfreeze:function(){if(this.isInFrame()){parent.f_interfaceUnfreeze();}}};_changeIds=function(a,b){if(a.id){a.id=a.id+b;}var d=a.firstChild;while(d!=null){_changeIds(d,b);d=d.nextSibling;}};suffix=0;domDuplicate=function(a){var b=a.cloneNode(true);suffix++;_changeIds(b,"-"+suffix);return b;};getDuplicated=function(a){return document.getElementById(a.id+"-"+suffix);};logSel=function(a){log("text :"+a.text+", start id : "+a.start["elt"].id+" , start offset : "+a.start["offset"]+" , end id : "+a.end["elt"].id+"end offset : "+a.end["offset"]);};log=function(b){var a=document.getElementById("log");a.innerHTML=a.innerHTML+"<li>"+b+"</li>";};urlEncode=function(h){if(!h){return"";}var c=[];for(var f in h){var e=h[f],b=encodeURIComponent(f);var g=typeof e;if(g=="undefined"){c.push(b,"=&");}else{if(g!="function"&&g!="object"){c.push(b,"=",encodeURIComponent(e),"&");}else{if(CY.Lang.isArray(e)){if(e.length){for(var d=0,a=e.length;d<a;d++){c.push(b,"=",encodeURIComponent(e[d]===undefined?"":e[d]),"&");}}else{c.push(b,"=&");}}}}}c.pop();return c.join("");};urlDecode=function(f,h){if(!f||!f.length){return{};}var d={};var b=f.split("&");var c,a,j;for(var e=0,g=b.length;e<g;e++){c=b[e].split("=");a=decodeURIComponent(c[0]);j=decodeURIComponent(c[1]);if(h!==true){if(typeof d[a]=="undefined"){d[a]=j;}else{if(typeof d[a]=="string"){d[a]=[d[a]];d[a].push(j);}else{d[a].push(j);}}}else{d[a]=j;}}return d;};areSortedArraysEqual=function(b,a){if(b.length!=a.length){return false;}for(var d=0,c=b.length;d<c;d++){if(b[d]!=a[d]){return false;}}return true;};quicksort=function(a){_quicksort(a,0,a.length-1);};_quicksort=function(e,g,d){var a,c,f,b;if(d-g==1){if(e[g]>e[d]){b=e[g];e[g]=e[d];e[d]=b;}return;}a=e[parseInt((g+d)/2)];e[parseInt((g+d)/2)]=e[g];e[g]=a;c=g+1;f=d;do{while(c<=f&&e[c]<=a){c++;}while(e[f]>a){f--;}if(c<f){b=e[c];e[c]=e[f];e[f]=b;}}while(c<f);e[g]=e[f];e[f]=a;if(g<f-1){_quicksort(e,g,f-1);}if(f+1<d){_quicksort(e,f+1,d);}};gShowingAllComments=false;Sync=function(){this._q=null;this._iPreventClick=false;};Sync.prototype={init:function(a){this._q=new CY.AsyncQueue();},setPreventClickOn:function(){CY.log("setPreventClickOn !");if(gLayout.isInFrame()){parent.f_interfaceFreeze();}this._iPreventClick=true;},setPreventClickOff:function(){CY.log("setPreventClickOff !");if(gLayout.isInFrame()){parent.f_interfaceUnfreeze();}this._iPreventClick=false;},removeCommentRet:function(b){var d=b.successfull;var a=(d)?b.failure["iComment"]:b.success["iComment"];if(d){var c=b.returned["filterData"];if(gLayout.isInFrame()){parent.f_updateFilterData(c);}var f=gIComments.getTopPosition()[1];var e=gDb.getComment(a.commentId);this._q.add(function(){unpaintCommentScope(e);gIComments.close(e.id);gIComments.remove(e.id);if(e.reply_to_id!=null){gIComments.refresh(e.reply_to_id);}gDb.del(e);if(gLayout.isInFrame()){if(gDb.comments.length==0&&gDb.allComments.length!=0){parent.f_enqueueMsg(gettext("no filtered comments left"));parent.resetFilter();}else{var g=gDb.computeFilterResults();updateFilterResultsCount(g.nbDiscussions,g.nbComments,g.nbReplies);}}});this._animateTo(f);}this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this.resume();},moderateCommentRet:function(c){var e=c.successfull;var a=(e)?c.failure["iComment"]:c.success["iComment"];if(e){var b=c.returned;var f=b.comment;gDb.upd(f);var d=gLayout.isInFrame()&&!parent.f_isFrameFilterFieldsInit();if(d){parent.resetFilter();this._showSingleComment(f);}else{a.changeModeration(f);}}this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this.resume();},saveCommentRet:function(h){var i=h.successfull;if(i){var l=h.success["formId"];var g=h.returned;removeFormErrMsg(l);if("errors" in g){var k=g.errors;for(var d in k){addFormErrMsg(l,d,k[d]);}this._animateToTop();}else{var b=function(){return(gNewReply!=null)&&(l==gNewReply.ids["formId"]);};var c=function(){return(gICommentForm!=null)&&(l==gICommentForm.formId);};var e=function(){return(gEdit!=null)&&(l==gEdit.ids["formId"]);};if(c()){this.hideICommentForm(cleanICommentForm());}else{if(e()){this._hideEditForm();}else{if(b()){this._hideNewReplyForm();}}}if("ask_for_notification" in g){if(g.ask_for_notification){parent.f_yesNoDialog(gettext("Do you want to be notified of all replies in all discussions you participated in?"),gettext("Reply notification"),function(){var m={method:"POST",data:urlEncode({fun:"ownNotify",key:sv_key,version_key:sv_version_key,email:g.email,active:false})};CY.io(sv_client_url,m);},this,null,function(){var m={method:"POST",data:urlEncode({fun:"ownNotify",key:sv_key,version_key:sv_version_key,email:g.email,active:true})};CY.io(sv_client_url,m);},this,null);}}if("comment" in g){var f=g.comment;gDb.upd(f);var a=gLayout.isInFrame()&&!parent.f_isFrameFilterFieldsInit();if(a){parent.resetFilter();}else{if(f.reply_to_id==null){unpaintCommentScope(f);paintCommentScope(f);}}var j=g.filterData;if(gLayout.isInFrame()){parent.f_updateFilterData(j);updateResetFilterResultsCount();}if(b()){if(!a){this._insertReply(f);}}else{this._showSingleComment(f);}}else{this._animateToTop();}}}else{this._q.add({id:"expl",fn:function(){CY.log("in example .........");}});this._q.promote("expl");}this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this.resume();},example:function(){CY.log("in example .........");},moderateComment:function(a,b){var c=gDb.getComment(a.commentId);this._q.add({fn:CY.bind(this.setPreventClickOn,this)},{autoContinue:false,fn:CY.bind(doExchange,null,"editComment",{comment_key:c.key,state:b},null,this.moderateCommentRet,this,{iComment:a},gettext("could not save comment"))}).run();},_saveComment:function(b,a){this._q.add({fn:CY.bind(this.setPreventClickOn,this)},{autoContinue:false,fn:CY.bind(doExchange,null,b,{},a,this.saveCommentRet,this,{formId:a},gettext("could not save comment"))}).run();},editComment:function(){this._saveComment("editComment",gEdit.ids["formId"]);},saveComment:function(a){this._saveComment("addComment",a);},removeComment:function(a){checkForOpenedDialog(a,function(){if(gLayout.isInFrame()){parent.f_yesNoDialog(gettext("Are you sure you want to delete this comment?"),gettext("Warning"),function(){this.animateToTop();},this,null,function(){var b=gDb.getComment(a.commentId);this._q.add({fn:CY.bind(this.setPreventClickOn,this)},{autoContinue:false,fn:CY.bind(doExchange,null,"removeComment",{comment_key:b.key},null,this.removeCommentRet,this,{iComment:a},gettext("could not remove comment"))}).run();},this,null);}},this,null);},resume:function(b,a){this._q.run();},resetAutoContinue:function(a){this._q.getCallback(a).autoContinue=true;},hideICommentForm:function(a){this._q.add({autoContinue:false,fn:CY.bind(gICommentForm.animationHide.run,gICommentForm.animationHide)});if(a){this._q.add(a);}},showCommentForm:function(a){checkForOpenedDialog(null,function(){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this._q.add({fn:function(){if(a==null){var b=getSelectionInfo();updateICommentFormSelection(b);}showICommentForm(a);}});this._q.add({autoContinue:false,fn:CY.bind(gICommentForm.animationShow.run,gICommentForm.animationShow)},{fn:CY.bind(this.setPreventClickOff,this)}).run();},this,null);},showEditForm:function(a){checkForOpenedDialog(null,function(){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this._q.add({fn:function(){showEditForm(a);}});this._animateToTop();this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},this,null);},showReplyForm:function(a){checkForOpenedDialog(null,function(){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this._q.add({fn:function(){instanciateNewReplyForm(a);}});this._animateToTop();this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},this,null);},cancelICommentForm:function(){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this.hideICommentForm();this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},cancelEdit:function(){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this._q.add({fn:function(){cancelEditForm();}});this._animateToTop();this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},cancelReply:function(){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this._q.add({fn:function(){cancelNewReplyForm();}});this._animateToTop();this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},changeScopeFormClick:function(){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this._q.add({fn:function(){changeScopeFormClick();}});this._animateToTop();this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},_hideNewReplyForm:function(){this._q.add({fn:function(){cleanNewReplyForm();cancelNewReplyForm();}});},_hideEditForm:function(){this._q.add({fn:function(){cancelEditForm();}});},_insertReply:function(a){this._q.add({fn:function(){var g=gDb.getComment(a.reply_to_id);var e=gDb.getThreads([g]);var c=e[e.length-2];var d=gIComments.insertAfter(c,a);var h=gIComments.getPosition(a.reply_to_id);d.setPosition(h);var b=gDb.getPath(a);var f=b[b.length-1];if(gIComments.isTopActive(f.id)){d.activate();}d.show();}});this._animateToTop();},_showSingleComment:function(d){if(d!=null){var c=gDb.getPath(d);var b=c[c.length-1];var a=0;if(d.start_wrapper!=-1){a=CY.get(".c-id-"+b.id).getY();}else{a=CY.get("document").get("scrollTop");}this._showComments([b.id],a,false);if(b.replies.length>0){this._animateTo(a);}}},_showFocusSingleComment:function(c,b){if(c!=null){var a=0;if(c.start_wrapper!=-1){a=CY.get(".c-id-"+c.id).getY();}else{a=CY.get("document").get("scrollTop");}this._showComments([c.id],a,false);if(c.replies.length>0){this._animateToAndFocus(a,b.id);}}},showSingleComment:function(a){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this._showSingleComment(a);this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},showFocusSingleComment:function(b,a){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this._showFocusSingleComment(b,a);this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},browse:function(a,b){var c=gIComments.browse(a,b);if(c!=null){this.showSingleComment(c);}},_showComments:function(c,b,a){this._q.add({fn:function(){gShowingAllComments=a;gIComments.hide();var d=CY.Array.map(c,function(g){return gDb.getComment(g);});var f=gDb.getThreads(d);gIComments.fetch(f);if(c.length>0){if(a){CY.get("document").set("scrollTop",0);}else{gIComments.activate(c[0]);var e=CY.get(".c-id-"+c[0]);if(e&&!e.inViewportRegion()){e.scrollIntoView(true);}}}gIComments.setPosition([gConf.iCommentLeftPadding,b]);gIComments.show();}});},_animateTo:function(a){this._q.add({fn:function(){gIComments.setAnimationToPositions(a);}},{id:"animationRun",autoContinue:false,fn:CY.bind(gIComments.runAnimations,gIComments)});},_animateToAndFocus:function(a,b){this._q.add({fn:function(){gIComments.setAnimationToPositionsAndFocus(a,b);}},{id:"animationRun",autoContinue:false,fn:CY.bind(gIComments.runAnimations,gIComments)});},_animateToTop:function(){var a=gIComments.getTopPosition();if(a!=null){this._animateTo(a[1]);}},animateToTop:function(){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this._animateToTop();this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},showAllComments:function(){checkForOpenedDialog(null,function(){gShowingAllComments=true;var a=CY.Array.map(gDb.comments,function(b){return b.id;});this.showComments(a,[0,0],true);},this,null);},showScopeRemovedComments:function(){checkForOpenedDialog(null,function(){gShowingAllComments=true;var b=CY.Array.filter(gDb.comments,function(c){return(c.start_wrapper==-1);});var a=CY.Array.map(b,function(d){return d.id;});this.showComments(a,[0,0],true);},this,null);},showComments:function(c,b,a){checkForOpenedDialog(null,function(){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this._showComments(c,b[1],a);this._animateTo(b[1]);this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},this,null);},openComment:function(a){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});var b=gIComments.getTopPosition()[1];this._q.add({fn:function(){gIComments.open(a.commentId);gIComments.refresh(a.commentId);}});this._animateTo(b);this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},closeComment:function(a){checkForOpenedDialog(a,function(){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});var b=gIComments.getTopPosition()[1];this._q.add({fn:function(){var c=gDb.getComment(a.commentId);gIComments.close(a.commentId);if(c.reply_to_id!=null){gIComments.refresh(c.reply_to_id);}}});this._animateTo(b);this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},this,null);},activate:function(a){gIComments.activate(a.commentId);}};readyForAction=function(){return !gSync._iPreventClick;};gEditICommentHost=null;gEdit=null;dbgc=null;showEditForm=function(a){if(gEdit==null){gEdit={ids:{formId:CY.guid(),formTitleId:CY.guid(),nameInputId:CY.guid(),emailInputId:CY.guid(),titleInputId:CY.guid(),contentInputId:CY.guid(),tagsInputId:CY.guid(),formatInputId:CY.guid(),startWrapperInputId:CY.guid(),endWrapperInputId:CY.guid(),startOffsetInputId:CY.guid(),endOffsetInputId:CY.guid(),changeScopeInputId:CY.guid(),changeScopeInputWrapper:CY.guid(),selectionPlaceId:CY.guid(),keyId:CY.guid(),editCommentId:CY.guid(),currentSelId:CY.guid(),currentSelIdI:CY.guid(),addBtnId:CY.guid(),cancelBtnId:CY.guid()},handlers:{}};}gEditICommentHost=a;gEditICommentHost.hideContent();var c=getHtml(gEdit.ids);var b='<div class="icomment-edit-header">'+c.headerContent+"</div>";var e='<div class="icomment-edit-body">'+c.bodyContent+"</div>";gEditICommentHost.overlay.setStdModContent(CY.WidgetStdMod.HEADER,CY.Node.create(b),CY.WidgetStdMod.AFTER);gEditICommentHost.overlay.setStdModContent(CY.WidgetStdMod.BODY,CY.Node.create(e),CY.WidgetStdMod.AFTER);CY.get("#"+gEdit.ids["formTitleId"]).set("innerHTML",gettext("Edit comment"));var f=gDb.getComment(gEditICommentHost.commentId);CY.get("#"+gEdit.ids["editCommentId"]).set("value",f.id);CY.get("#"+gEdit.ids["keyId"]).set("value",f.key);CY.get("#"+gEdit.ids["changeScopeInputId"]+" input").set("checked",false);if(f.reply_to_id!=null){CY.get("#"+gEdit.ids["changeScopeInputId"]).addClass("displaynone");}changeScopeFormClick();CY.get("#"+gEdit.ids["nameInputId"]).set("value",f.name);CY.get("#"+gEdit.ids["emailInputId"]).set("value",f.email);if(f.logged_author){CY.get("#"+gEdit.ids["nameInputId"]).setAttribute("disabled",true);CY.get("#"+gEdit.ids["emailInputId"]).setAttribute("disabled",true);}CY.get("#"+gEdit.ids["titleInputId"]).set("value",f.title);CY.get("#"+gEdit.ids["contentInputId"]).set("value",f.content);CY.get("#"+gEdit.ids["tagsInputId"]).set("value",f.tags);CY.get("#"+gEdit.ids["formatInputId"]).set("value",gConf.defaultCommentFormat);var d=gLayout.getTopICommentsWidth();changeFormFieldsWidth(gEdit.ids["formId"],d);gEdit.handlers["addBtnId"]=CY.on("click",onEditSaveClick,"#"+gEdit.ids["addBtnId"]);gEdit.handlers["cancelBtnId"]=CY.on("click",onEditCancelClick,"#"+gEdit.ids["cancelBtnId"]);gEdit.handlers["changeScope"]=CY.on("click",onChangeScopeClick,"#"+gEdit.ids["changeScopeInputId"]);};onEditSaveClick=function(a){if(readyForAction()){gSync.editComment();}};onEditCancelClick=function(a){if(readyForAction()){gSync.cancelEdit();}};onChangeScopeClick=function(){if(readyForAction()){gSync.changeScopeFormClick();}else{var a=CY.get("#"+gEdit.ids["changeScopeInputId"]+" input");var b=a.get("checked");a.set("checked",!b);}};changeScopeFormClick=function(){var a=CY.get("#"+gEdit.ids["currentSelId"]);if(CY.get("#"+gEdit.ids["changeScopeInputId"]+" input").get("checked")){a.removeClass("displaynone");}else{a.addClass("displaynone");}};cancelEditForm=function(){if(gEditICommentHost!=null){for(var b in gEdit.handlers){if(gEdit.handlers[b]!=null){gEdit.handlers[b].detach();gEdit.handlers[b]=null;}}var a=gEditICommentHost.overlay.get("contentBox").query(".icomment-edit-body");a.get("parentNode").removeChild(a);a=gEditICommentHost.overlay.get("contentBox").query(".icomment-edit-header");a.get("parentNode").removeChild(a);gEditICommentHost.showContent();gEditICommentHost=null;}};gICommentForm=null;instanciateICommentForm=function(){gICommentForm={position:[CY.WidgetPositionExt.LC,CY.WidgetPositionExt.LC],formId:CY.guid(),formTitleId:CY.guid(),titleInputId:CY.guid(),contentInputId:CY.guid(),tagsInputId:CY.guid(),formatInputId:CY.guid(),startWrapperInputId:CY.guid(),endWrapperInputId:CY.guid(),startOffsetInputId:CY.guid(),endOffsetInputId:CY.guid(),selectionPlaceId:CY.guid(),keyId:CY.guid(),currentSelId:CY.guid(),currentSelIdI:CY.guid(),addBtnId:CY.guid(),cancelBtnId:CY.guid(),closeBtnId:CY.guid()};if(!sv_loggedIn){gICommentForm.nameInputId=CY.guid();gICommentForm.emailInputId=CY.guid();}var c=getHtml(gICommentForm);var e=gLayout.getTopICommentsWidth();var b=new CY.Overlay({zIndex:3,shim:false,visible:false,headerContent:c.headerContent,bodyContent:c.bodyContent,xy:[10,10],width:e});b.get("contentBox").addClass("c-newcomment");b.render("#leftcolumn");if(!sv_loggedIn){CY.get("#"+gICommentForm.nameInputId).set("value",gPrefs.get("user","name"));CY.get("#"+gICommentForm.emailInputId).set("value",gPrefs.get("user","email"));}CY.get("#"+gICommentForm.formTitleId).set("innerHTML",gettext("New comment"));CY.get("#"+gICommentForm.formatInputId).set("value",gConf.defaultCommentFormat);CY.on("click",onSubmitICommentFormClick,"#"+gICommentForm.addBtnId);CY.on("click",onCancelICommentFormClick,"#"+gICommentForm.cancelBtnId);CY.on("click",onCancelICommentFormClick,"#"+gICommentForm.closeBtnId);gICommentForm.overlay=b;var d=null;d=new CY.Anim({node:b.get("boundingBox"),duration:0.3,easing:CY.Easing.easeOut});gICommentForm.animationHide=d;d.set("to",{opacity:0});gICommentForm["animationHide-handle"]=d.on("end",onICommentFormHideAnimEnd,gICommentForm);var a=null;a=new CY.Anim({node:b.get("boundingBox"),duration:0.3,easing:CY.Easing.easeOut});gICommentForm.animationShow=a;a.set("to",{opacity:1});gICommentForm["animationShow-handle"]=a.on("end",onICommentFormShowAnimEnd,gICommentForm);changeFormFieldsWidth(gICommentForm.formId,e);};cleanICommentForm=function(){CY.get("#"+gICommentForm.currentSelIdI).set("innerHTML",gNoSelectionYet);var a=gICommentForm.overlay.getStdModNode(CY.WidgetStdMod.BODY);a.queryAll(".comment_input").set("value","");CY.get("#"+gICommentForm.formatInputId).set("value",gConf.defaultCommentFormat);if(!sv_loggedIn){a.queryAll(".user_input").set("value","");}};onICommentFormHideAnimEnd=function(){this.overlay.hide();gSync.resume();};onICommentFormShowAnimEnd=function(){gSync.resume();};onSubmitICommentFormClick=function(){if(!sv_loggedIn){var b=CY.get("#"+gICommentForm.nameInputId).get("value");gPrefs.persist("user","name",b);var a=CY.get("#"+gICommentForm.emailInputId).get("value");gPrefs.persist("user","email",a);}gSync.saveComment(gICommentForm.formId);};onCancelICommentFormClick=function(){gSync.cancelICommentForm();};_updateICommentFormSelection=function(c,e,b,a){var d=CY.Node.get("#"+c.currentSelIdI);if(d!=null){d.set("innerHTML",e);}d=CY.get("#"+c.startWrapperInputId);if(d!=null){d.set("value",b.elt.id.substring("sv_".length));}d=CY.get("#"+c.startOffsetInputId);if(d!=null){d.set("value",b.offset);}d=CY.get("#"+c.endWrapperInputId);if(d!=null){d.set("value",a.elt.id.substring("sv_".length));}d=CY.get("#"+c.endOffsetInputId);if(d!=null){d.set("value",a.offset);}};updateICommentFormSelection=function(h){var i=(h==null)?"":h.text;if(i!=""){var f=i;var b=100;if(i.length>b){var a=i.substring(0,(i.substring(0,b/2)).lastIndexOf(" "));var d=i.substring(i.length-b/2);var c=d.substring(d.indexOf(" "));f=a+" ... "+c;}var e=_convertSelectionFromCCToCS(h.start);var g=_convertSelectionFromCCToCS(h.end);_updateICommentFormSelection(gICommentForm,f,e,g);if(gEdit!=null){_updateICommentFormSelection(gEdit.ids,f,e,g);}positionICommentForm();}};showICommentForm=function(){removeFormErrMsg(gICommentForm.formId);if(!sv_loggedIn){if(CY.get("#"+gICommentForm.nameInputId).get("value")==""){CY.get("#"+gICommentForm.nameInputId).set("value",gPrefs.get("user","name"));}if(CY.get("#"+gICommentForm.emailInputId).get("value")==""){CY.get("#"+gICommentForm.emailInputId).set("value",gPrefs.get("user","email"));}}gIComments.hide();positionICommentForm();gICommentForm.overlay.show();CY.get("#"+gICommentForm.titleInputId).focus();};isICommentFormVisible=function(){if(gICommentForm!=null){return gICommentForm.overlay.get("visible");}return false;};positionICommentForm=function(){if(gICommentForm!=null){var b=gICommentForm.overlay;var a=b.get("boundingBox");var c=a.get("offsetHeight");var e=a.get("winHeight");var d=gICommentForm.position;if(c>e){d=[CY.WidgetPositionExt.BL,CY.WidgetPositionExt.BL];}b.set("align",{points:d});a.setX(a.getX()+gConf.iCommentLeftPadding);}};Db=function(){this.comments=null;this.allComments=null;this.commentsByDbId={};this.allCommentsByDbId={};this.ordered_comment_ids={};};Db.prototype={init:function(){this.allComments=CY.JSON.parse(sv_comments);if(sv_read_only){this.initToReadOnly();}this._computeAllCommentsByDbId();this._reorder();},_del:function(a,e,g){var f=e[g];for(var c=0;c<f.replies.length;c++){var d=f.replies[c].id;this._del(f.replies,e,d);c--;}for(var c=0,b=a.length;c<b;c++){if(a[c].id==g){a.splice(c,1);delete e[g];break;}}},del:function(b){var a=(b.reply_to_id==null)?this.comments:this.commentsByDbId[b.reply_to_id].replies;this._del(a,this.commentsByDbId,b.id);a=(b.reply_to_id==null)?this.allComments:this.allCommentsByDbId[b.reply_to_id].replies;this._del(a,this.allCommentsByDbId,b.id);this._reorder();},_reorder:function(){var l=[];for(var g=0,c=this.allComments.length;g<c;g++){var h=this.allComments[g];var p=false;for(var e=0,o=l.length;e<o;e++){var b=l[e];var d=this.allCommentsByDbId[b];if((h.start_wrapper<d.start_wrapper)||((h.start_wrapper==d.start_wrapper)&&(h.start_offset<d.start_offset))||((h.start_wrapper==d.start_wrapper)&&(h.start_offset==d.start_offset)&&(h.end_wrapper<d.end_wrapper))||((h.start_wrapper==d.start_wrapper)&&(h.start_offset==d.start_offset)&&(h.end_wrapper==d.end_wrapper)&&(h.end_offset<d.end_offset))){l.splice(e,0,h.id);p=true;break;}}if(!p){l.push(h.id);}}this.ordered_comment_ids.scope=l;l=[];var k={};for(var g=0,c=this.allComments.length;g<c;g++){var h=this.allComments[g];var m=h.modified;k[h.id]=this._latest_mod(h);}for(var b in k){var f=this.allCommentsByDbId[b].id;var p=false;for(var g=0,c=l.length;g<c;g++){var n=l[g];if(k[b]<k[n]){l.splice(g,0,f);p=true;break;}}if(!p){l.push(f);}}this.ordered_comment_ids.modif_thread=l;},_latest_mod:function(e){var c=e.modified;for(var b=0;b<e.replies.length;b++){var d=e.replies[b];var a=this._latest_mod(d);if(a>c){c=a;}}return c;},_upd:function(a,f,g){var e=false;for(var d=0,b=a.length;d<b;d++){if(a[d].id==g.id){a.splice(d,1,g);e=true;break;}}if(!e){a.push(g);}f[g.id]=g;},upd:function(c){var a=(c.reply_to_id==null)?this.allComments:this.allCommentsByDbId[c.reply_to_id].replies;this._upd(a,this.allCommentsByDbId,c);var b=CY.clone(c);a=(c.reply_to_id==null)?this.comments:this.commentsByDbId[c.reply_to_id].replies;this._upd(a,this.commentsByDbId,b);this._reorder();},initComments:function(a){this.comments=[];for(var d=0,c=this.allComments.length;d<c;d++){var b=CY.Array.indexOf(a,this.allComments[d].id);if(b!=-1){var e=CY.clone(this.allComments[d]);this.comments.push(e);}}this._computeCommentsByDbId();},_computeCommentsByDbId:function(){this.commentsByDbId={};var b=this.getThreads(this.comments);for(var a=0;a<b.length;a++){this.commentsByDbId[b[a].id]=b[a];}},_computeAllCommentsByDbId:function(){this.allCommentsByDbId={};var b=this.getThreads(this.allComments);for(var a=0;a<b.length;a++){this.allCommentsByDbId[b[a].id]=b[a];}},getThreads:function(c){var a=[];for(var b=0;b<c.length;b++){a.push(c[b]);if(c[b].replies.length>0){a=a.concat(this.getThreads(c[b].replies));}}return a;},_getPath:function(b,e){var a=[e];var d=e;while(d.reply_to_id!=null){d=b[d.reply_to_id];a.push(d);}return a;},getPath:function(a){return this._getPath(this.commentsByDbId,a);},getComment:function(a){return this.commentsByDbId[a];},getCommentByIdKey:function(a){for(var c in this.commentsByDbId){var b=this.commentsByDbId[c];if(b.id_key==a){return b;}}return null;},isChild:function(d,b){var c=this.commentsByDbId[d];var a=(d==b);while((!a)&&(c.reply_to_id!=null)){c=this.commentsByDbId[c.reply_to_id];a=(c.id==b);}return a;},initToReadOnly:function(f,c){for(var b=0,a=this.allComments.length;b<a;b++){var e=this.allComments[b];for(var d in e){if(0==d.indexOf("can_")&&typeof e[d]==="boolean"){e[d]=false;}}}},browsingIndex:function(b){var c={};for(var a in this.ordered_comment_ids){var d=CY.Array.filter(this.ordered_comment_ids[a],function(e){return(e in this.commentsByDbId);},this);c[a]=CY.Array.indexOf(d,b);}return c;},browse:function(b,f,c){var a=this.ordered_comment_ids[b];if(a.length>0){var g=-1;if((f=="prev")||(f=="next")){for(var e=0;e<a.length;e++){var h=a[e];if(h==c){g=(f=="prev")?e-1:e+1;g=(a.length+g)%a.length;break;}}if(g==-1){CY.error("internal error in db browse (was called with a dbId that isn't among the filtered ones)");return null;}}if(f=="last"){g=a.length-1;}if(f=="first"){g=0;}for(var e=g,d=0;(e>=0)&&(e<a.length);d++){var h=a[e];if(h in this.commentsByDbId){return this.commentsByDbId[h];}if((f=="prev")||(f=="last")){e=e-1;}else{e=e+1;}e=(a.length+e)%a.length;if(d>a.length){break;}}CY.error("internal error in db browse (could not find any filtered comment)");}return null;},computeFilterResults:function(n){var a={};if(n){for(key in n){if(key.indexOf("filter_")==0){a[key.substr("filter_".length)]=n[key];}}}else{if(gLayout.isInFrame()){a=parent.f_getFrameFilterData();}}var v=[];var w=[];var b="";if("name" in a){b=a.name;}this.filterByName(b,v,w);var p=[];var c=[];var C="";if("date" in a){C=a.date;}this.filterByDate(C,p,c);var g=[];var f=[];var t="";if("text" in a){t=a.text;}this.filterByText(t,g,f);var x=[];var m=[];var A="";if("tag" in a){A=a.tag;}this.filterByTag(A,x,m);var u=[];var e=[];var k="";if("state" in a){k=a.state;}this.filterByState(k,u,e);var d=[];var z=[];for(var y=0,j=v.length;y<j;y++){var s=v[y];if((CY.Array.indexOf(p,s)!=-1)&&(CY.Array.indexOf(g,s)!=-1)&&(CY.Array.indexOf(x,s)!=-1)&&(CY.Array.indexOf(u,s)!=-1)){d.push(s);}}for(var y=0,j=w.length;y<j;y++){var s=w[y];if((CY.Array.indexOf(c,s)!=-1)&&(CY.Array.indexOf(f,s)!=-1)&&(CY.Array.indexOf(m,s)!=-1)&&(CY.Array.indexOf(e,s)!=-1)){z.push(s);}}var q=z.length,l=d.length;var r=l;for(var y=0,j=z.length;y<j;y++){var s=z[y];var o=this.allCommentsByDbId[s];var B=this._getPath(this.allCommentsByDbId,o);var h=B[B.length-1];var s=h.id;if(CY.Array.indexOf(d,s)==-1){d.push(s);r++;}}return{commentIds:d,nbDiscussions:r,nbComments:l,nbReplies:q};},filterByText:function(c,f,b){var a=new RegExp(c,"gi");for(var e in this.allCommentsByDbId){var d=this.allCommentsByDbId[e];if(c==""||ac(d.title)!=null||ac(d.content)!=null){if(d.reply_to_id==null){f.push(d.id);}else{b.push(d.id);}}}},filterByName:function(a,c,b){for(var e in this.allCommentsByDbId){var d=this.allCommentsByDbId[e];if(a==""||d.name==a){if(d.reply_to_id==null){c.push(d.id);}else{b.push(d.id);}}}},filterByTag:function(i,e,b){var h=new RegExp("^"+i+"$","g");var g=new RegExp("^"+i+", ","g");var d=new RegExp(", "+i+", ","g");var c=new RegExp(", "+i+"$","g");for(var a in this.allCommentsByDbId){var f=this.allCommentsByDbId[a];if(i==""||hc(f.tags)||gc(f.tags)!=null||dc(f.tags)!=null||cc(f.tags)!=null){if(f.reply_to_id==null){e.push(f.id);}else{b.push(f.id);}}}},filterByState:function(c,a,b){for(var e in this.allCommentsByDbId){var d=this.allCommentsByDbId[e];if(c==""||d.state==c){if(d.reply_to_id==null){a.push(d.id);}else{b.push(d.id);}}}},filterByDate:function(b,d,a){var c=(b=="")?0:parseInt(b);for(var f in this.allCommentsByDbId){var e=this.allCommentsByDbId[f];if(e.modified>c){if(e.reply_to_id==null){d.push(e.id);}else{a.push(e.id);}}}},getCommentsAndRepliesCounts:function(d){var b=0;var f=0;var a=(d)?this.allComments:this.comments;var e=this.getThreads(a);for(var c=0;c<e.length;c++){if(e[c].reply_to_id==null){b++;}else{f++;}}return[b,f];},getCommentsNb:function(b){var a=(b)?this.allComments:this.comments;return this.getThreads(a).length;},getFilteredCommentIdsAsString:function(){var a="";for(var b in this.commentsByDbId){a=a+b+",";}return a;}};var gtest={renaud:"RENAUD",random:Math.random(),bernard:"BERNARD",myFunc:function(){doExchange("theServerFun",{},null,this.myRetFunc,this,["foo","bar"]);},myRetFunc:function(a){CY.log("this.renaud : "+this.renaud);CY.log("this.random : "+this.random);CY.log("arg.returned : "+a.returned);CY.log(a.returned);CY.log("arg.success : "+a.success);CY.log(a.success);}};doExchange=function(h,e,g,f,d,c,b){e.fun=h;e.key=sv_key;e.version_key=sv_version_key;var a={method:"POST",data:urlEncode(e),on:{success:function(l,k,j){var i={};if(k.responseText){i=CY.JSON.parse(k.responseText);}if(gLayout.isInFrame()&&("msg" in i)){parent.f_enqueueMsg(i.msg);}j.returned=i;j.successfull=true;f.call(d,j);},failure:function(k,j,i){if(gLayout.isInFrame()){parent.f_enqueueErrorMsg(gettext("error:")+b);}i.successfull=false;f.call(d,i);}},arguments:{success:c,failure:c}};if(g!=null){a.form={id:g};}CY.io(sv_client_url,a);};warn_server=function(c){c.fun="warn";c.key=sv_key;c.version_key=sv_version_key;var b=CY.UA;var a={method:"POST",data:urlEncode(CY.merge(c,b))};CY.io("/client/",a);};IComments=function(){this._c=[];this._a=[];this._nbEndedAnim=0;this._topActiveCommentDbId=null;};IComments.prototype={init:function(a){for(var b=0;b<gConf.iCommentsInitAlloc;b++){this._c.push(new IComment());}},getIComment:function(a){return CY.Array.find(this._c,function(b){return(b.isfetched()&&b.commentId==a);});},insertAfter:function(a,d){var c=CY.Array.map(this._c,function(e){return e.commentId;});var b=CY.Array.indexOf(c,a.id);if(b!=-1){this._c.splice(b+1,0,new IComment());this._c[b+1].fetch(d);return this._c[b+1];}return null;},_remove:function(c){var d=CY.Array.map(c,function(e){return e.commentId;});for(var b=0;b<this._c.length;b++){var a=this._c[b];if(a.isfetched()&&CY.Array.indexOf(d,a.commentId)!=-1){a.unfetch();this._c.push(this._c.splice(b,1)[0]);b--;}}},_getChildren:function(a){return CY.Array.filter(this._c,function(b){return(b.isfetched()&&gDb.isChild(b.commentId,a));});},_getInvisibleChildren:function(a){return CY.Array.filter(this._getChildren(a),function(b){return(!b.isVisible());});},refresh:function(c){var b=this.getIComment(c);var a=this._getInvisibleChildren(c);if(a.length>0){b.showReadRepliesLnk();}else{b.hideReadRepliesLnk();}},remove:function(a){this._remove(this._getChildren(a));},close:function(a){CY.Array.each(this._getChildren(a),function(b){b.hide();});},open:function(a){CY.Array.each(this._getChildren(a),function(b){b.show();});},fetch:function(b){for(var a=0;a<b.length;a++){if(a==this._c.length){this._c.push(new IComment());}this._c[a].fetch(b[a]);}for(var a=b.length;a<this._c.length;a++){this._c[a].unfetch();}},setPosition:function(a){CY.each(this._c,function(b){b.setPosition(a);});},show:function(){CY.each(this._c,function(a){if(a.isfetched()){a.show();}});},hide:function(){this.deactivate();CY.each(this._c,function(a){if(a.commentId!=null){a.hide();}});},setWidth:function(c){var e=null;for(var b=0;b<this._c.length;b++){var a=this._c[b];a.setWidth(c);if(a.commentId!=null&&a.isVisible()){var d=a.getPosition();if(e==null){e=d[1];}d[1]=e;a.setPosition(d);e+=a.getHeight();}}},getTopPosition:function(){for(var b=0;b<this._c.length;b++){var a=this._c[b];if(a.commentId!=null&&a.isVisible()){return a.getPosition();}}return null;},getPosition:function(c){for(var b=0;b<this._c.length;b++){var a=this._c[b];if(a.commentId==c&&a.isVisible()){return a.getPosition();}}return null;},setAnimationToPositions:function(h){this._initAnimations();var c=(gPrefs.get("comments","threadpad")=="1")?gConf.iCommentThreadPadding:0;var f=h;for(var d=0;d<this._c.length;d++){var b=this._c[d];if(b.isfetched&&b.isVisible()){var a=gDb.getPath(gDb.getComment(b.commentId));var g=((a.length-1)*c)+gConf.iCommentLeftPadding;if(f==null){var e=b.getPosition();f=e[1];}this._a.push(b.setAnimationToPosition([g,f]));f+=b.getHeight();}}},setAnimationToPositionsAndFocus:function(f,e){this._initAnimations();var a=(gPrefs.get("comments","threadpad")=="1")?gConf.iCommentThreadPadding:0;var g=f;for(var c=0;c<this._c.length;c++){var b=this._c[c];if(b.isfetched&&b.isVisible()){var d=gDb.getPath(gDb.getComment(b.commentId));var j=((d.length-1)*a)+gConf.iCommentLeftPadding;if(g==null){var h=b.getPosition();g=h[1];}if(b.commentId>=e){this._a.push(b.setAnimationToPosition([j,g],e));}else{this._a.push(b.setAnimationToPosition([j,g]));}g+=b.getHeight();}}},_initAnimations:function(){this._a=[];this._nbEndedAnim=0;},runAnimations:function(){if(this._a.length==0){gSync.resetAutoContinue("animationRun");}else{CY.each(this._a,function(a){a.run();});}},whenAnimationsEnd:function(){gSync.resume();},whenAnimationsEndFocus:function(){gGETValues=CY.JSON.parse(sv_get_params);if("comment_id_key" in gGETValues){var b=gGETValues.comment_id_key;var a=gDb.getCommentByIdKey(b);if(a!=null){gIComments.getIComment(a.id).overlay.focus();}}gSync.resume();},animationsEnded:function(){return((this._a.length==0)||(this._a.length==this._nbEndedAnim));},signalAnimationEnd:function(){this._nbEndedAnim++;},isTopActive:function(a){return((a!=null)&&(this._topActiveCommentDbId==a));},isAnyActive:function(){return(this._topActiveCommentDbId!=null);},activate:function(f){if(this._topActiveCommentDbId!=null){this.deactivate();}var e=gDb.getComment(f);var b=gDb.getPath(e);var a=b[b.length-1];var c=this._getChildren(a.id);CY.Array.each(c,function(g){g.activate();});this._topActiveCommentDbId=a.id;if(gLayout.isInFrame()){var d=gDb.browsingIndex(this._topActiveCommentDbId);parent.$("#browse_by option").each(function(){var g=1+d[this.value];parent.$("#c_browse_indx_"+this.value).html(""+g);});}showScope(a.id);},deactivate:function(){if(this._topActiveCommentDbId!=null){parent.$("#browse_by option").each(function(){parent.$("#c_browse_indx_"+this.value).html("-");});hideScopeAnyway();var a=this._getChildren(this._topActiveCommentDbId);CY.Array.each(a,function(b){b.deactivate();});this._topActiveCommentDbId=null;}},activateVisibleNext:function(){if(this._topActiveCommentDbId!=null){for(var d=0;d<2;d++){var f=(d==0)?0:this._c.length-1;var a=false;for(var e=f;(e>=0)&&e<=(this._c.length-1);){var c=this._c[e];if(c.commentId!=null&&c.isVisible()){a=a||(gDb.isChild(c.commentId,this._topActiveCommentDbId));if(a&&(!gDb.isChild(c.commentId,this._topActiveCommentDbId))){this.activate(c.commentId);return true;}}e=(d==0)?e+1:e-1;}}}return false;},browse:function(b,c){var a=c;if((c=="prev")&&!this.isAnyActive()){a="last";}if((c=="next")&&!this.isAnyActive()){a="first";}return gDb.browse(b,a,this._topActiveCommentDbId);}};gNewReplyHost=null;gNewReply=null;instanciateNewReplyForm=function(i){if(gNewReply==null){gNewReply={val:{name:gPrefs.get("user","name"),email:gPrefs.get("user","email"),title:"",content:"",tags:""},ids:{name:gPrefs.get("user","name"),email:gPrefs.get("user","email"),title:"",content:"",tags:"",formId:CY.guid(),nameInputId:CY.guid(),emailInputId:CY.guid(),titleInputId:CY.guid(),contentInputId:CY.guid(),keyInputId:CY.guid(),formatInputId:CY.guid(),tagsInputId:CY.guid(),parentCommentId:CY.guid(),addBtnId:CY.guid(),cancelBtnId:CY.guid()},handlers:{}};}gNewReplyHost=i;var b='<hr/><center><div class="c-header-title">'+gettext("New reply")+"</div></center>";var e=gFormHtml.formStart.replace("###",gNewReply.ids["formId"]);if(!sv_loggedIn){e=e+gFormHtml.nameInput.replace("###",gNewReply.ids["nameInputId"])+gFormHtml.emailInput.replace("###",gNewReply.ids["emailInputId"]);}e=e+gFormHtml.titleInput.replace("###",gNewReply.ids["titleInputId"])+gFormHtml.contentInput.replace("###",gNewReply.ids["contentInputId"])+gFormHtml.tagsInput.replace("###",gNewReply.ids["tagsInputId"]);e=e+gFormHtml.hidden.replace("###",gNewReply.ids["keyInputId"]).replace("???","comment_key");e=e+gFormHtml.hidden.replace("###",gNewReply.ids["formatInputId"]).replace("???","format");e=e+gFormHtml.hidden.replace("###",gNewReply.ids["parentCommentId"]).replace("???","reply_to_id");var h=gFormHtml.btns.replace("###",gNewReply.ids["addBtnId"]).replace("???",gNewReply.ids["cancelBtnId"]);gNewReplyHost.overlay.setStdModContent(CY.WidgetStdMod.FOOTER,b+e+h);var c=gNewReplyHost.overlay.getStdModNode(CY.WidgetStdMod.FOOTER);var f=gDb.getComment(i.commentId);var a="Re: ";var g=(gNewReply.val["title"]==""||gNewReply.val["title"].substring(0,a.length)==a)?a+f.title:gNewReply.val["title"];if(!sv_loggedIn){c.query(".n_name").set("value",gNewReply.val["name"]);c.query(".n_email").set("value",gNewReply.val["email"]);}c.query(".n_title").set("value",g);c.query(".n_content").set("value",gNewReply.val["content"]);c.query(".n_tags").set("value",gNewReply.val["tags"]);c.query("#"+gNewReply.ids["parentCommentId"]).set("value",i.commentId);c.query("#"+gNewReply.ids["formatInputId"]).set("value",gConf.defaultCommentFormat);gNewReplyHost.overlay.get("contentBox").query(".c-reply").addClass("displaynone");gNewReply.handlers["addBtnId"]=CY.on("click",onAddNewReplyClick,"#"+gNewReply.ids["addBtnId"]);gNewReply.handlers["cancelBtnId"]=CY.on("click",onCancelNewReplyClick,"#"+gNewReply.ids["cancelBtnId"]);var d=gLayout.getTopICommentsWidth();changeFormFieldsWidth(gNewReply.ids["formId"],d);};cleanNewReplyForm=function(){if(gNewReplyHost!=null){var a=gNewReplyHost.overlay.getStdModNode(CY.WidgetStdMod.FOOTER);a.queryAll(".comment_input").set("value","");}};cancelNewReplyForm=function(){if(gNewReplyHost!=null){for(var b in gNewReply.handlers){if(gNewReply.handlers[b]!=null){gNewReply.handlers[b].detach();gNewReply.handlers[b]=null;}}gNewReplyHost.overlay.get("contentBox").query(".c-reply").removeClass("displaynone");var a=gNewReplyHost.overlay.getStdModNode(CY.WidgetStdMod.FOOTER);if(!sv_loggedIn){gNewReply.val["name"]=a.query(".n_name").get("value");gNewReply.val["email"]=a.query(".n_email").get("value");}gNewReply.val["title"]=a.query(".n_title").get("value");gNewReply.val["content"]=a.query(".n_content").get("value");gNewReply.val["tags"]=a.query(".n_tags").get("value");a.set("innerHTML","");gNewReplyHost=null;}};onAddNewReplyClick=function(){if(!sv_loggedIn){var b=CY.get("#"+gNewReply.ids["nameInputId"]).get("value");gPrefs.persist("user","name",b);var a=CY.get("#"+gNewReply.ids["emailInputId"]).get("value");gPrefs.persist("user","email",a);}gSync.saveComment(gNewReply.ids["formId"]);};onCancelNewReplyClick=function(){gSync.cancelReply();};c_persistPreference=function(b,a,c){gPrefs.persist(b,a,c);};c_readDefaultPreference=function(b,a){return gConf.defaultPrefs[b][a];};c_readPreference=function(b,a){return gPrefs.get(b,a);};c_resetPreferences=function(a){gPrefs.reset(a);};c_applyTextStyle=function(a){CY.use(a);};sliderValToPx=function(d){var a=CY.DOM.winWidth();if(gLayout.isInFrame()){a=parent.$(parent).width();}var b=d/100;b=Math.min(b,gConf.sliderFixedMin);b=Math.max(b,gConf.sliderFixedMax);var c=b*a;return Math.floor(c);};c_setCommentsColWidth=function(c){var a=sliderValToPx(c);gLayout.setLeftColumnWidth(a);var b=gLayout.getTopICommentsWidthFromWidth(a);gIComments.setWidth(b);gICommentForm.overlay.get("boundingBox").setStyle("width",b+"px");changeFormFieldsWidth(gICommentForm.formId,b);if(gNewReply){changeFormFieldsWidth(gNewReply.ids["formId"],b);}if(gEdit){changeFormFieldsWidth(gEdit.ids["formId"],b);}};CY=null;gPrefs=null;gLayout=null;gDb=null;gIComments=null;gSync=null;gGETValues=null;gConf={iCommentLeftPadding:4,iCommentThreadPadding:12,defaultCommentFormat:"markdown",sliderFixedMin:0.9,sliderFixedMax:0.1,iCommentsInitAlloc:2,defaultPrefs:{text:{style:"text-modern-style"},user:{name:"",email:""},general:{animduration:"0.4"},comments:{threadpad:"1"},layout:{comments_col_width:"25"}}};gTextStyles={"text-modern-style":gettext("modern"),"text-classic-style":gettext("classic"),"text-code-style":gettext("code")};YUI({base:sv_media_url+"/js/lib/yui/"+c_yui_base+"/build/",timeout:10000}).use("text-modern-style","cookie","json","overlay","io-form","async-queue","event-mouseenter","anim","collection",function(a){CY=a;gPrefs=new Preferences();gPrefs.init();gLayout=new Layout();gLayout.init();if(sv_withComments){gDb=new Db();gDb.init();gIComments=new IComments();gIComments.init();}gSync=new Sync();gSync.init();CY.on("domready",onDomReady,this);});_reinit=function(a){gIComments.hide();gDb.initComments(a.commentIds);unpaintAllComments();renderCommentScopes();updateFilterResultsCount(a.nbDiscussions,a.nbComments,a.nbReplies);};reinit=function(b){var a=gDb.computeFilterResults(b);_reinit(a);};hideAll=function(){_reinit({commentIds:[],nbDiscussions:0,nbComments:0,nbReplies:0});};updateFilterResultsCount=function(f,a,b){var e=gDb.getCommentsAndRepliesCounts(true);var g=e[0],d=e[1];var c=(a!=0||b!=0)&&(g!=a||d!=b);if(gLayout.isInFrame()){parent.f_updateFilterCountDetailed(c);parent.f_updateFilterCountResult(f,a,b,g,d);}};updateResetFilterResultsCount=function(){var c=gDb.getCommentsAndRepliesCounts(false);var a=c[0],b=c[1];var d=a;updateFilterResultsCount(d,a,b);};renderCommentScopes=function(){for(var a=0;a<gDb.comments.length;a++){var b=gDb.comments[a];paintCommentScope(b);}};onTextMouseUp=function(f){if(readyForAction()){var c=getSelectionInfo();if(c!=null){updateICommentFormSelection(c);if(gEditICommentHost!=null){var g=CY.get("#"+gEdit.ids["changeScopeInputId"]+" input").get("checked");if(g){gEditICommentHost.scrollIntoView();}}}else{var d=f.target;if(d.hasClass("c-c")){var b=CY.Node.getDOMNode(d);var a=getCommentIdsFromClasses(b);if(a.length>0){checkForOpenedDialog(null,function(){gSync.showComments(a,[f.pageX,f.pageY],false);});}}}}};gLastScrollTime=null;checkForAlignement=function(){var a=(new Date()).getTime();if((gLastScrollTime!=null)&&(a-gLastScrollTime)>200){positionICommentForm();gLastScrollTime=null;}};onFrameScroll=function(){gLastScrollTime=(new Date()).getTime();};browse=function(a,b){gSync.browse(a,b);};initialConnect=function(){CY.on("mouseup",onTextMouseUp,"#textcontainer");gTimer=CY.Lang.later(200,this,checkForAlignement,[],true);CY.on("scroll",onFrameScroll,window,this,true);CY.on("resize",onFrameScroll,window,this,true);};preventLinksInText=function(){var a=function(g){var c=g.target;var d=null;while(c!=null&&d==null){c=c.get("parentNode");d=c.get("href");}if(c!=null&&d!=null){var b=window.location.href;var f=b.indexOf("#");if(f!=-1){b=b.substring(0,f);}if(d.indexOf(b)==-1){window.open(c.get("href"));g.preventDefault();}}};CY.all("#textcontainer a").on("click",a);};onDomReady=function(b){preventLinksInText();var a=new CY.AsyncQueue();a.add({fn:function(){if(gLayout.isInComentSite()){parent.toInitialSize();}if(sv_withComments){instanciateICommentForm();}},timeout:5},{fn:function(){gGETValues=CY.JSON.parse(sv_get_params);CY.get("#maincontainer").setStyle("display","block");CY.get("#textcontainer").setStyle("display","block");var e=(sv_withComments)?gPrefs.get("layout","comments_col_width"):0;var d=sliderValToPx(e);gLayout.setLeftColumnWidth(d);if(gLayout.isInFrame()){parent.f_initFrame();parent.f_layoutFrames();if(sv_withComments){parent.f_fillTopToolbar();if(hasPerm("can_create_comment")){parent.$("#add_comment_btn").removeClass("initially_hidden");}parent.f_fillFilterTab();parent.f_fillPreferencesTab();var c=CY.JSON.parse(sv_filter_data);parent.f_updateFilterData(c);parent.f_setFilterValue(gGETValues);}parent.f_fillTextPreferencesTab();}if(gLayout.isInComentSite()){parent.$("#c_fullscreen_btn").show();}else{parent.$("#c_fullscreen_btn").hide();}},timeout:5},{fn:function(){if(sv_withComments){reinit(gGETValues);initialConnect();}},timeout:5},{fn:function(){if(gLayout.isInFrame()){parent.f_interfaceUnfreeze();parent.f_removeLoadingMsg();}if("comment_id_key" in gGETValues){var e=gGETValues.comment_id_key;var g=gDb.getCommentByIdKey(e);if(g!=null){var f=gDb.getPath(g);var c=f[f.length-1];var d=gDb.getCommentByIdKey(e);gSync.showFocusSingleComment(c,d);}}if("comments_auto_display" in gGETValues){gSync.showAllComments();}}});a.run();}; -
src/cm/media/js/client/c_db.js
r144 r333 105 105 var commentModif = comment.modified ; 106 106 107 mod[comment.id] = commentModif ; 108 109 for (var j = 0, jlen = comment.replies.length ; j < jlen ; j++) { 110 111 var reply = comment.replies[j] ; 112 var replyModif = reply.modified ; 113 114 if (replyModif > mod[comment.id]) 115 mod[comment.id] = replyModif ; 116 } 107 mod[comment.id] = this._latest_mod(comment); 117 108 } 118 109 … … 137 128 this.ordered_comment_ids['modif_thread'] = a ; 138 129 }, 130 131 // Finds recursively the last modification date of a thread. 132 _latest_mod : function(comment) { 133 var latest_mod = comment.modified; 134 for (var i=0; i<comment.replies.length; i++) { 135 var reply = comment.replies[i] ; 136 var reply_mod = this._latest_mod(reply); 137 if (reply_mod > latest_mod) 138 latest_mod = reply_mod; 139 } 140 return latest_mod; 141 }, 139 142 140 143 // EDIT OR ADD CASE : when just added id is max and so both (comments and replies) initial id asc order remains -
src/cm/templates/site/text_view_comments.html
r332 r333 108 108 <script type="text/javascript" src="{{ CM_MEDIA_PREFIX }}js/site/c_text_view_comments.js"></script> 109 109 {% else %} 110 <script type="text/javascript" src="{{ CM_MEDIA_PREFIX }}js/client/c_client-min.js?128922 3828"></script>110 <script type="text/javascript" src="{{ CM_MEDIA_PREFIX }}js/client/c_client-min.js?1289226453"></script> 111 111 {% endif %} 112 112 -
src/cm/templates/site/text_view_frame.html
r332 r333 37 37 <script type="text/javascript" src="{{ CM_MEDIA_PREFIX }}js/site/f_text_view_frame.js"></script> 38 38 {% else %} 39 <script type="text/javascript" src="{{ CM_MEDIA_PREFIX }}js/client/f_client-min.js?128922 3828"></script>39 <script type="text/javascript" src="{{ CM_MEDIA_PREFIX }}js/client/f_client-min.js?1289226453"></script> 40 40 {% endif %} 41 41 <style type="text/css">
Note: See TracChangeset
for help on using the changeset viewer.