Changeset 4:8e6d7ff63451

Show
Ignore:
Timestamp:
11/23/09 17:06:53 (5 days ago)
Author:
reno
Branch:
default
Message:

client min

Location:
src/cm
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • src/cm/media/js/client/c_client-min.js

    r0 r4  
    1 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();};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}};};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 c-iclose" title="'+gettext("close")+'"><em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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);});}};gNewReplyHost=null;gNewReply=null;instanciateNewReplyForm=function(j){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=j;var q='<hr/><center><div class="c-header-title">'+gettext("New reply")+"</div></center>";var n=gFormHtml.formStart.replace("###",gNewReply.ids.formId);if(!sv_loggedIn){n=n+gFormHtml.nameInput.replace("###",gNewReply.ids.nameInputId)+gFormHtml.emailInput.replace("###",gNewReply.ids.emailInputId);}n=n+gFormHtml.titleInput.replace("###",gNewReply.ids.titleInputId)+gFormHtml.contentInput.replace("###",gNewReply.ids.contentInputId)+gFormHtml.tagsInput.replace("###",gNewReply.ids.tagsInputId);n=n+gFormHtml.hidden.replace("###",gNewReply.ids.keyInputId).replace("???","comment_key");n=n+gFormHtml.hidden.replace("###",gNewReply.ids.formatInputId).replace("???","format");n=n+gFormHtml.hidden.replace("###",gNewReply.ids.parentCommentId).replace("???","reply_to_id");var k=gFormHtml.btns.replace("###",gNewReply.ids.addBtnId).replace("???",gNewReply.ids.cancelBtnId);gNewReplyHost.overlay.setStdModContent(CY.WidgetStdMod.FOOTER,q+n+k);var p=gNewReplyHost.overlay.getStdModNode(CY.WidgetStdMod.FOOTER);var m=gDb.getComment(j.commentId);var r="Re: ";var l=(gNewReply.val.title==""||gNewReply.val.title.substring(0,r.length)==r)?r+m.title:gNewReply.val.title;if(!sv_loggedIn){p.query(".n_name").set("value",gNewReply.val.name);p.query(".n_email").set("value",gNewReply.val.email);}p.query(".n_title").set("value",l);p.query(".n_content").set("value",gNewReply.val.content);p.query(".n_tags").set("value",gNewReply.val.tags);p.query("#"+gNewReply.ids.parentCommentId).set("value",j.commentId);p.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 o=gLayout.getTopICommentsWidth();changeFormFieldsWidth(gNewReply.ids.formId,o);};cleanNewReplyForm=function(){if(gNewReplyHost!=null){var b=gNewReplyHost.overlay.getStdModNode(CY.WidgetStdMod.FOOTER);b.queryAll(".comment_input").set("value","");}};cancelNewReplyForm=function(){if(gNewReplyHost!=null){for(var c in gNewReply.handlers){if(gNewReply.handlers[c]!=null){gNewReply.handlers[c].detach();gNewReply.handlers[c]=null;}}gNewReplyHost.overlay.get("contentBox").query(".c-reply").removeClass("displaynone");var d=gNewReplyHost.overlay.getStdModNode(CY.WidgetStdMod.FOOTER);if(!sv_loggedIn){gNewReply.val.name=d.query(".n_name").get("value");gNewReply.val.email=d.query(".n_email").get("value");}gNewReply.val.title=d.query(".n_title").get("value");gNewReply.val.content=d.query(".n_content").get("value");gNewReply.val.tags=d.query(".n_tags").get("value");d.set("innerHTML","");gNewReplyHost=null;}};onAddNewReplyClick=function(){if(!sv_loggedIn){var c=CY.get("#"+gNewReply.ids.nameInputId).get("value");gPrefs.persist("user","name",c);var d=CY.get("#"+gNewReply.ids.emailInputId).get("value");gPrefs.persist("user","email",d);}gSync.saveComment(gNewReply.ids.formId);};onCancelNewReplyClick=function(){gSync.cancelReply();};getWrapperAncestor=function(d){var c=d;while(c!=null){if(CY.DOM.hasClass(c,"c-s")){return c;}c=c.parentNode;}return null;};hasWrapperAncestor=function(b){return(getWrapperAncestor(b)!=null);};getSelectionInfo=function(){var j=null,ac=null,T=0,aj=0,af="";if(window.getSelection){var V=window.getSelection();if(V.rangeCount>0){var ad=V.getRangeAt(0);af=ad.toString();if(af!=""){var R=document.createRange();R.setStart(V.anchorNode,V.anchorOffset);R.collapse(true);var W=document.createRange();W.setEnd(V.focusNode,V.focusOffset);W.collapse(false);var K=(W.compareBoundaryPoints(2,R)==1);j=(K)?V.anchorNode.parentNode:V.focusNode.parentNode;innerStartNode=(K)?V.anchorNode:V.focusNode;ac=(K)?V.focusNode.parentNode:V.anchorNode.parentNode;innerEndNode=(K)?V.focusNode:V.anchorNode;T=(K)?V.anchorOffset:V.focusOffset;aj=(K)?V.focusOffset:V.anchorOffset;if(!hasWrapperAncestor(ac)&&hasWrapperAncestor(j)){var e=document.createRange();e.setStart(innerStartNode,T);var ak=getWrapperAncestor(j);var X=ak;e.setEndAfter(X);var ah=parseInt(ak.id.substring("sv_".length));while(e.toString().length<ad.toString().length){ah++;var S=CY.get("#sv_"+ah);if(S){X=CY.Node.getDOMNode(S);e.setEndAfter(X);}else{break;}}ac=X.lastChild;aj=CY.DOM.getText(ac).length;}else{if(!hasWrapperAncestor(j)&&hasWrapperAncestor(ac)){var e=document.createRange();e.setEnd(innerEndNode,aj);var ag=getWrapperAncestor(ac);var Z=ag;e.setStartBefore(Z);var ah=parseInt(ag.id.substring("sv_".length));while(e.toString().length<ad.toString().length){ah--;var S=CY.get("#sv_"+ah);if(S){Z=CY.Node.getDOMNode(S);e.setStartBefore(Z);}else{break;}}j=Z.firstChild;T=0;}else{if(!hasWrapperAncestor(j)&&!hasWrapperAncestor(ac)){var aa=af.length;var ab=[];for(var ah=0;;ah++){var O=CY.get("#sv_"+ah);if(O==null){break;}else{var s=O.get("text");if(af.indexOf(s)==0){ab.push(ah);}}}var i=[];for(var ah=0;;ah++){var O=CY.get("#sv_"+ah);if(O==null){break;}else{var s=O.get("text");if(af.indexOf(s)==(aa-s.length)){i.push(ah);}}}var M=false;for(var U=0;U<ab.length;U++){for(var Y=0;Y<i.length;Y++){var N=document.createRange();var ae=CY.Node.getDOMNode(CY.get("#sv_"+ab[U]));var Q=CY.Node.getDOMNode(CY.get("#sv_"+i[Y]));N.setStartBefore(ae);N.setEndAfter(CY.Node.getDOMNode(Q));if((-1<N.compareBoundaryPoints(0,ad))&&(1>N.compareBoundaryPoints(2,ad))){j=ae.firstChild;T=0;ac=Q.lastChild;aj=CY.DOM.getText(Q).length;M=true;break;}}if(M){break;}}}}}R.detach();W.detach();}else{return null;}}else{return null;}}else{if(document.selection){var ai=document.selection.createRange();if(ai.text.length==0){return null;}var al=ai.parentElement();var L=ai.duplicate();var P=ai.duplicate();L.collapse(true);P.collapse(false);j=L.parentElement();while(L.moveStart("character",-1)!=0){if(L.parentElement()!=j){break;}T++;}ac=P.parentElement();while(P.moveEnd("character",-1)!=0){if(P.parentElement()!=ac){break;}aj++;}af=ai.text;}}if(!hasWrapperAncestor(j)||!hasWrapperAncestor(ac)){return null;}return{text:af,start:{elt:j,offset:T},end:{elt:ac,offset:aj}};};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 c-iclose" title="'+gettext("close")+'"><em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</em></a>'};getHtml=function(i){ret={};ret.headerContent="";if("closeBtnId" in i){ret.headerContent+=gFormHtml.closeIcon.replace("###",i.closeBtnId);}ret.headerContent+=gFormHtml.headerTitle.replace("###",i.formTitleId);var g="";if("changeScopeInputId" in i){g=gFormHtml.changeScope.replace("###",i.changeScopeInputId);}var j="<center>"+gFormHtml.hidden.replace("###",i.selectionPlaceId).replace("???","selection_place")+"</center>";var h=gFormHtml.currentSel.replace("###",i.currentSelId).replace("???",i.currentSelIdI).replace("#hiddeninput#",j);var k=gFormHtml.btns.replace("###",i.addBtnId).replace("???",i.cancelBtnId);var l=gFormHtml.formStart.replace("###",i.formId)+g+h;if("nameInputId" in i){l=l+gFormHtml.nameInput.replace("###",i.nameInputId);}if("emailInputId" in i){l=l+gFormHtml.emailInput.replace("###",i.emailInputId);}l=l+gFormHtml.titleInput.replace("###",i.titleInputId)+gFormHtml.contentInput.replace("###",i.contentInputId)+gFormHtml.tagsInput.replace("###",i.tagsInputId);l=l+gFormHtml.hidden.replace("###",i.formatInputId).replace("???","format");l=l+gFormHtml.hidden.replace("###",i.startWrapperInputId).replace("???","start_wrapper");l=l+gFormHtml.hidden.replace("###",i.endWrapperInputId).replace("???","end_wrapper");l=l+gFormHtml.hidden.replace("###",i.startOffsetInputId).replace("???","start_offset");l=l+gFormHtml.hidden.replace("###",i.endOffsetInputId).replace("???","end_offset");l=l+gFormHtml.hidden.replace("###",i.keyId).replace("???","comment_key");l=l+gFormHtml.hidden.replace("###",i.editCommentId).replace("???","edit_comment_id");l=l+k+gFormHtml.formEnd;ret.bodyContent=l;return ret;};changeFormFieldsWidth=function(g,h){var f=(h-20)+"px";var e=CY.all("#"+g+" input[type='text']");if(e!=null){e.setStyle("width",f);}e=CY.all("#"+g+" textarea");if(e!=null){e.setStyle("width",f);}};addFormErrMsg=function(k,m,o){var n=document.getElementById(k);var e,l,p,i;for(e=0,i=n.elements.length;e<i;++e){l=n.elements[e];if(l.name==m){p=document.createElement("DIV");CY.DOM.addClass(p,"c-error");p.id=l.id+"-err";p.appendChild(document.createTextNode(o));if(l.parentNode.nextSibling){l.parentNode.parentNode.insertBefore(p,l.parentNode.nextSibling);}else{l.parentNode.parentNode.appendChild(p);}}}};removeFormErrMsg=function(c){var d=CY.all("#"+c+" .c-error");if(d!=null){d.each(function(a){a.get("parentNode").removeChild(a);});}};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);}};_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);}};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);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];},getCommentByKey:function(a){for(var c in this.commentsByDbId){var b=this.commentsByDbId[c];if(b.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;},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;}CY.log(a);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;}};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")?15: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();}}},_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();},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);}};gEditICommentHost=null;gEdit=null;dbgc=null;showEditForm=function(b){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=b;gEditICommentHost.hideContent();var h=b.overlay.get("contentBox").query(".yui-widget-hd");var a=b.overlay.get("contentBox").query(".yui-widget-bd");var d=getHtml(gEdit.ids);var c='<div class="icomment-edit-header">'+d.headerContent+"</div>";var f='<div class="icomment-edit-body">'+d.bodyContent+"</div>";h.append(c);a.append(f);CY.get("#"+gEdit.ids["formTitleId"]).set("innerHTML",gettext("Edit comment"));var g=gDb.getComment(gEditICommentHost.commentId);CY.get("#"+gEdit.ids["editCommentId"]).set("value",g.id);CY.get("#"+gEdit.ids["keyId"]).set("value",g.key);CY.get("#"+gEdit.ids["changeScopeInputId"]+" input").set("checked",false);if(g.reply_to_id!=null){CY.get("#"+gEdit.ids["changeScopeInputId"]).addClass("displaynone");}changeScopeFormClick();CY.get("#"+gEdit.ids["nameInputId"]).set("value",g.name);CY.get("#"+gEdit.ids["emailInputId"]).set("value",g.email);if(g.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",g.title);CY.get("#"+gEdit.ids["contentInputId"]).set("value",g.content);CY.get("#"+gEdit.ids["tagsInputId"]).set("value",g.tags);CY.get("#"+gEdit.ids["formatInputId"]).set("value",gConf.defaultCommentFormat);var e=gLayout.getTopICommentsWidth();changeFormFieldsWidth(gEdit.ids["formId"],e);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();}};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;}};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]);}}}};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;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;var b=CY.UA;var a={method:"POST",data:urlEncode(CY.merge(c,b))};CY.io("/client/",a);};Layout=function(){};Layout.prototype={init:function(){},isInFrame:function(){return(!CY.Lang.isUndefined(parent)&&parent.location!=location&&CY.Lang.isFunction(parent.f_getFrameFilterData));},isInComentSite:function(){return(!CY.Lang.isUndefined(top)&&top.location!=location&&CY.Lang.isFunction(top.v_toggleFrameSize));},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(a){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();}}};IComment=function(){this.commentId=null;var k=gLayout.getTopICommentsWidth();var a=gConf.iCommentLeftPadding;var q=gettext("change comment state to pending");var m=gettext("change comment state to approved");var e=gettext("change comment state to unapproved");var p=gettext("cancel changing the state of this comment");var c=gettext("pending");var d=gettext("approved");var l=gettext("unapproved");var b=gettext("cancel");var o=gettext("show replies");var r=gettext("change to:");var h=gettext("reply");var g=gettext("edit comment");var i=gettext("delete comment");var n=gettext("edit");var f=gettext("delete");var j=gettext("close");this.overlay=new CY.Overlay({zIndex:3,shim:false,visible:false,width:k,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+'">'+n+'</a> <a class="c-delete c-action" title="'+i+'" alt="'+i+'">'+f+'</a> </div><div class="c-state-actions displaynone">'+r+'&nbsp;<a class="c-state-pending c-action" title="'+q+'" alt="'+q+'">'+c+'</a> <a class="c-state-approved c-action" title="'+m+'" alt="'+m+'">'+d+'</a> <a class="c-state-unapproved c-action" title="'+e+'" alt="'+e+'">'+l+'</a> <a class="c-state-cancel c-action" title="'+p+'" alt="'+p+'">'+b+'</a> </div><a class="c-close c-iclose c-action" title="'+j+'" alt="'+j+'"><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="'+o+'" alt="'+o+'">'+o+'</a>&nbsp;<a class="c-reply c-action" title="'+h+'" alt="'+h+'">'+h+"</a>&nbsp;</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 c=d.target;var g=sv_site_url+sv_text_view_show_comment_url;if(c.get("href").indexOf(g)==0){var b=(new RegExp("comment_key=([^&]*)","g"))c(c.get("href"));if(b!=null){var a=b[1];var f=gDb.getCommentByKey(a);if(f!=null){d.halt();if(!c.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()){this.overlay.get("contentBox").query(".c-permalink").removeClass("displaynone");}},onMouseLeaveHeader:function(){if(readyForAction()&&this.isVisible()){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");this.overlay.get("contentBox").query(".c-close").addClass("c-iclose-focus");this.overlay.get("contentBox").query(".c-close").removeClass("c-iclose");},deactivate:function(){this.overlay.get("boundingBox").removeClass("c-focus-comment");this.overlay.get("contentBox").query(".c-close").addClass("c-iclose");this.overlay.get("contentBox").query(".c-close").removeClass("c-iclose-focus");},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(i){this.commentId=i.id;var b=this.overlay.get("boundingBox");var g=interpolate(gettext("last modified on %(date)s"),{date:i.modified_user_str},true);var l=(i.modified==i.created)?"":'<a title="'+g+'"> * </a>';var j=gettext("Permalink to this comment");var o='<a class="c-permalink displaynone c-action" target="_blank" title="'+j+'" href="/" >¶&nbsp;</a>';var k=interpolate(gettext("by %(name)s, created on %(date)s"),{name:i.name,date:i.created_user_str},true);var d='<span class="c-header"><div class="c-header-title">'+i.title+o+'</div><div class="c-infos">'+k+"</div></span>";var e=CY.Node.create(d);var p=b.query(".c-header");if(p==null){b.query(".icomment-header").insertBefore(e,b.one(".c-iactions"));}else{p.get("parentNode").replaceChild(e,p);}var h=CY.Node.create('<div class="c-tags"><span class="c-tags-infos">tags:</span>'+i.tags+"</div>");var n=b.query(".c-tags");if(n==null){b.query(".icomment-header").appendChild(h);}else{n.get("parentNode").replaceChild(h,n);}if(i.tags==""){h.addClass("displaynone");}var f=CY.Node.create('<span class="c-content">'+i.content_html+"</span>");var a=b.query(".c-content");if(a==null){b.query(".icomment-body").appendChild(f);}else{a.get("parentNode").replaceChild(f,a);}b.query(".c-permalink").set("href",sv_site_url+i.permalink);this.changeModeration(i);var c=this.overlay.get("contentBox").query(".c-moderate");c.set("title","click to change comment ID visibility".replace(/ID/,this.commentId).replace(/  /," "));var m=b.queryAll(".c-content a");if(m!=null){m.setAttribute("target","_blank");}m=b.queryAll(".c-header-title a");if(m!=null){m.setAttribute("target","_blank");}this.permAdapt(i);},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();}},setAnimationToPosition:function(b){var a=this.overlay.get("boundingBox");if(gPrefs.get("general","animduration")<0.011){a.setXY(b);}this.animation.set("to",{xy:b});this.animation.set("duration",gPrefs.get("general","animduration"));this["animation-handle"]=this.animation.on("end",this.onAnimationEnd,this);return this.animation;},setWidth:function(b){var a=this.overlay.get("boundingBox");a.setStyle("width",b+"px");},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)));}};_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,[]);}};hasPerm=function(a){return(-1!=CY.Array.indexOf(sv_user_permissions,a));};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("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=CY.get(".c-id-"+b.id).getY();this._showComments([b.id],a,false);this._animateTo(a);}},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();},browse:function(a,b){var c=gIComments.browse(a,b);if(c!=null){this.showSingleComment(c);}},_showComments:function(c,a,b){this._q.add({fn:function(){gShowingAllComments=b;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(!b){gIComments.activate(c[0]);var e=CY.get(".c-id-"+c[0]);if(!e.inViewportRegion()){e.scrollIntoView(true);}}else{CY.get("document").set("scrollTop",0);}}gIComments.setPosition([gConf.iCommentLeftPadding,a]);gIComments.show();}});},_animateTo:function(a){this._q.add({fn:function(){gIComments.setAnimationToPositions(a);}},{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);},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;};paintCommentScope=function(b){if(b.reply_to_id==null){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");}};CY=null;gPrefs=null;gLayout=null;gDb=null;gIComments=null;gSync=null;gGETValues=null;gConf={iCommentLeftPadding:4,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(c){c.preventDefault();var b=c.target;while(b!=null&&b.get("href")==null){b=b.get("parentNode");}if(b!=null&&b.get("href")!=null){window.open(b.get("href"));}};CY.all("#textcontainer a").on("click",a);};onDomReady=function(b){preventLinksInText();var a=new CY.AsyncQueue();a.add({fn:function(){if(gLayout.isInComentSite()){top.v_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.isInComentSite()){parent.$("#c_fullscreen_btn").show();}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();}},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_key" in gGETValues){var c=gGETValues.comment_key;var f=gDb.getCommentByKey(c);if(f!=null){var e=gDb.getPath(f);var d=e[e.length-1];gSync.showSingleComment(d);}}else{gSync.showAllComments();}}});a.run();};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);}}; 
     1gNewReplyHost=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();};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}};};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 c-iclose" title="'+gettext("close")+'"><em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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);});}};gNewReplyHost=null;gNewReply=null;instanciateNewReplyForm=function(j){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=j;var q='<hr/><center><div class="c-header-title">'+gettext("New reply")+"</div></center>";var n=gFormHtml.formStart.replace("###",gNewReply.ids.formId);if(!sv_loggedIn){n=n+gFormHtml.nameInput.replace("###",gNewReply.ids.nameInputId)+gFormHtml.emailInput.replace("###",gNewReply.ids.emailInputId);}n=n+gFormHtml.titleInput.replace("###",gNewReply.ids.titleInputId)+gFormHtml.contentInput.replace("###",gNewReply.ids.contentInputId)+gFormHtml.tagsInput.replace("###",gNewReply.ids.tagsInputId);n=n+gFormHtml.hidden.replace("###",gNewReply.ids.keyInputId).replace("???","comment_key");n=n+gFormHtml.hidden.replace("###",gNewReply.ids.formatInputId).replace("???","format");n=n+gFormHtml.hidden.replace("###",gNewReply.ids.parentCommentId).replace("???","reply_to_id");var k=gFormHtml.btns.replace("###",gNewReply.ids.addBtnId).replace("???",gNewReply.ids.cancelBtnId);gNewReplyHost.overlay.setStdModContent(CY.WidgetStdMod.FOOTER,q+n+k);var p=gNewReplyHost.overlay.getStdModNode(CY.WidgetStdMod.FOOTER);var m=gDb.getComment(j.commentId);var r="Re: ";var l=(gNewReply.val.title==""||gNewReply.val.title.substring(0,r.length)==r)?r+m.title:gNewReply.val.title;if(!sv_loggedIn){p.query(".n_name").set("value",gNewReply.val.name);p.query(".n_email").set("value",gNewReply.val.email);}p.query(".n_title").set("value",l);p.query(".n_content").set("value",gNewReply.val.content);p.query(".n_tags").set("value",gNewReply.val.tags);p.query("#"+gNewReply.ids.parentCommentId).set("value",j.commentId);p.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 o=gLayout.getTopICommentsWidth();changeFormFieldsWidth(gNewReply.ids.formId,o);};cleanNewReplyForm=function(){if(gNewReplyHost!=null){var b=gNewReplyHost.overlay.getStdModNode(CY.WidgetStdMod.FOOTER);b.queryAll(".comment_input").set("value","");}};cancelNewReplyForm=function(){if(gNewReplyHost!=null){for(var c in gNewReply.handlers){if(gNewReply.handlers[c]!=null){gNewReply.handlers[c].detach();gNewReply.handlers[c]=null;}}gNewReplyHost.overlay.get("contentBox").query(".c-reply").removeClass("displaynone");var d=gNewReplyHost.overlay.getStdModNode(CY.WidgetStdMod.FOOTER);if(!sv_loggedIn){gNewReply.val.name=d.query(".n_name").get("value");gNewReply.val.email=d.query(".n_email").get("value");}gNewReply.val.title=d.query(".n_title").get("value");gNewReply.val.content=d.query(".n_content").get("value");gNewReply.val.tags=d.query(".n_tags").get("value");d.set("innerHTML","");gNewReplyHost=null;}};onAddNewReplyClick=function(){if(!sv_loggedIn){var c=CY.get("#"+gNewReply.ids.nameInputId).get("value");gPrefs.persist("user","name",c);var d=CY.get("#"+gNewReply.ids.emailInputId).get("value");gPrefs.persist("user","email",d);}gSync.saveComment(gNewReply.ids.formId);};onCancelNewReplyClick=function(){gSync.cancelReply();};getWrapperAncestor=function(d){var c=d;while(c!=null){if(CY.DOM.hasClass(c,"c-s")){return c;}c=c.parentNode;}return null;};hasWrapperAncestor=function(b){return(getWrapperAncestor(b)!=null);};getSelectionInfo=function(){var j=null,ac=null,T=0,aj=0,af="";if(window.getSelection){var V=window.getSelection();if(V.rangeCount>0){var ad=V.getRangeAt(0);af=ad.toString();if(af!=""){var R=document.createRange();R.setStart(V.anchorNode,V.anchorOffset);R.collapse(true);var W=document.createRange();W.setEnd(V.focusNode,V.focusOffset);W.collapse(false);var K=(W.compareBoundaryPoints(2,R)==1);j=(K)?V.anchorNode.parentNode:V.focusNode.parentNode;innerStartNode=(K)?V.anchorNode:V.focusNode;ac=(K)?V.focusNode.parentNode:V.anchorNode.parentNode;innerEndNode=(K)?V.focusNode:V.anchorNode;T=(K)?V.anchorOffset:V.focusOffset;aj=(K)?V.focusOffset:V.anchorOffset;if(!hasWrapperAncestor(ac)&&hasWrapperAncestor(j)){var e=document.createRange();e.setStart(innerStartNode,T);var ak=getWrapperAncestor(j);var X=ak;e.setEndAfter(X);var ah=parseInt(ak.id.substring("sv_".length));while(e.toString().length<ad.toString().length){ah++;var S=CY.get("#sv_"+ah);if(S){X=CY.Node.getDOMNode(S);e.setEndAfter(X);}else{break;}}ac=X.lastChild;aj=CY.DOM.getText(ac).length;}else{if(!hasWrapperAncestor(j)&&hasWrapperAncestor(ac)){var e=document.createRange();e.setEnd(innerEndNode,aj);var ag=getWrapperAncestor(ac);var Z=ag;e.setStartBefore(Z);var ah=parseInt(ag.id.substring("sv_".length));while(e.toString().length<ad.toString().length){ah--;var S=CY.get("#sv_"+ah);if(S){Z=CY.Node.getDOMNode(S);e.setStartBefore(Z);}else{break;}}j=Z.firstChild;T=0;}else{if(!hasWrapperAncestor(j)&&!hasWrapperAncestor(ac)){var aa=af.length;var ab=[];for(var ah=0;;ah++){var O=CY.get("#sv_"+ah);if(O==null){break;}else{var s=O.get("text");if(af.indexOf(s)==0){ab.push(ah);}}}var i=[];for(var ah=0;;ah++){var O=CY.get("#sv_"+ah);if(O==null){break;}else{var s=O.get("text");if(af.indexOf(s)==(aa-s.length)){i.push(ah);}}}var M=false;for(var U=0;U<ab.length;U++){for(var Y=0;Y<i.length;Y++){var N=document.createRange();var ae=CY.Node.getDOMNode(CY.get("#sv_"+ab[U]));var Q=CY.Node.getDOMNode(CY.get("#sv_"+i[Y]));N.setStartBefore(ae);N.setEndAfter(CY.Node.getDOMNode(Q));if((-1<N.compareBoundaryPoints(0,ad))&&(1>N.compareBoundaryPoints(2,ad))){j=ae.firstChild;T=0;ac=Q.lastChild;aj=CY.DOM.getText(Q).length;M=true;break;}}if(M){break;}}}}}R.detach();W.detach();}else{return null;}}else{return null;}}else{if(document.selection){var ai=document.selection.createRange();if(ai.text.length==0){return null;}var al=ai.parentElement();var L=ai.duplicate();var P=ai.duplicate();L.collapse(true);P.collapse(false);j=L.parentElement();while(L.moveStart("character",-1)!=0){if(L.parentElement()!=j){break;}T++;}ac=P.parentElement();while(P.moveEnd("character",-1)!=0){if(P.parentElement()!=ac){break;}aj++;}af=ai.text;}}if(!hasWrapperAncestor(j)||!hasWrapperAncestor(ac)){return null;}return{text:af,start:{elt:j,offset:T},end:{elt:ac,offset:aj}};};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 c-iclose" title="'+gettext("close")+'"><em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</em></a>'};getHtml=function(i){ret={};ret.headerContent="";if("closeBtnId" in i){ret.headerContent+=gFormHtml.closeIcon.replace("###",i.closeBtnId);}ret.headerContent+=gFormHtml.headerTitle.replace("###",i.formTitleId);var g="";if("changeScopeInputId" in i){g=gFormHtml.changeScope.replace("###",i.changeScopeInputId);}var j="<center>"+gFormHtml.hidden.replace("###",i.selectionPlaceId).replace("???","selection_place")+"</center>";var h=gFormHtml.currentSel.replace("###",i.currentSelId).replace("???",i.currentSelIdI).replace("#hiddeninput#",j);var k=gFormHtml.btns.replace("###",i.addBtnId).replace("???",i.cancelBtnId);var l=gFormHtml.formStart.replace("###",i.formId)+g+h;if("nameInputId" in i){l=l+gFormHtml.nameInput.replace("###",i.nameInputId);}if("emailInputId" in i){l=l+gFormHtml.emailInput.replace("###",i.emailInputId);}l=l+gFormHtml.titleInput.replace("###",i.titleInputId)+gFormHtml.contentInput.replace("###",i.contentInputId)+gFormHtml.tagsInput.replace("###",i.tagsInputId);l=l+gFormHtml.hidden.replace("###",i.formatInputId).replace("???","format");l=l+gFormHtml.hidden.replace("###",i.startWrapperInputId).replace("???","start_wrapper");l=l+gFormHtml.hidden.replace("###",i.endWrapperInputId).replace("???","end_wrapper");l=l+gFormHtml.hidden.replace("###",i.startOffsetInputId).replace("???","start_offset");l=l+gFormHtml.hidden.replace("###",i.endOffsetInputId).replace("???","end_offset");l=l+gFormHtml.hidden.replace("###",i.keyId).replace("???","comment_key");l=l+gFormHtml.hidden.replace("###",i.editCommentId).replace("???","edit_comment_id");l=l+k+gFormHtml.formEnd;ret.bodyContent=l;return ret;};changeFormFieldsWidth=function(g,h){var f=(h-20)+"px";var e=CY.all("#"+g+" input[type='text']");if(e!=null){e.setStyle("width",f);}e=CY.all("#"+g+" textarea");if(e!=null){e.setStyle("width",f);}};addFormErrMsg=function(k,m,o){var n=document.getElementById(k);var e,l,p,i;for(e=0,i=n.elements.length;e<i;++e){l=n.elements[e];if(l.name==m){p=document.createElement("DIV");CY.DOM.addClass(p,"c-error");p.id=l.id+"-err";p.appendChild(document.createTextNode(o));if(l.parentNode.nextSibling){l.parentNode.parentNode.insertBefore(p,l.parentNode.nextSibling);}else{l.parentNode.parentNode.appendChild(p);}}}};removeFormErrMsg=function(c){var d=CY.all("#"+c+" .c-error");if(d!=null){d.each(function(a){a.get("parentNode").removeChild(a);});}};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);}};_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);}};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);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];},getCommentByKey:function(a){for(var c in this.commentsByDbId){var b=this.commentsByDbId[c];if(b.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;},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;}};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();CY.log(gPrefs.get("comments","threadpad"));var c=(gPrefs.get("comments","threadpad")=="1")?15: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();}}},_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();},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);}};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();}};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;}};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]);}}}};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;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;var b=CY.UA;var a={method:"POST",data:urlEncode(CY.merge(c,b))};CY.io("/client/",a);};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 a=false;try{a=(!CY.Lang.isUndefined(parent)&&!CY.Lang.isUndefined(parent.parent)&&parent.parent.location!=location&&CY.Lang.isFunction(parent.parent.v_toggleFrameSize));}catch(b){a=false;}return a;},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(a){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();}}};IComment=function(){this.commentId=null;var k=gLayout.getTopICommentsWidth();var a=gConf.iCommentLeftPadding;var q=gettext("change comment state to pending");var m=gettext("change comment state to approved");var e=gettext("change comment state to unapproved");var p=gettext("cancel changing the state of this comment");var c=gettext("pending");var d=gettext("approved");var l=gettext("unapproved");var b=gettext("cancel");var o=gettext("show replies");var r=gettext("change to:");var h=gettext("reply");var g=gettext("edit comment");var i=gettext("delete comment");var n=gettext("edit");var f=gettext("delete");var j=gettext("close");this.overlay=new CY.Overlay({zIndex:3,shim:false,visible:false,width:k,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+'">'+n+'</a> <a class="c-delete c-action" title="'+i+'" alt="'+i+'">'+f+'</a> </div><div class="c-state-actions displaynone">'+r+'&nbsp;<a class="c-state-pending c-action" title="'+q+'" alt="'+q+'">'+c+'</a> <a class="c-state-approved c-action" title="'+m+'" alt="'+m+'">'+d+'</a> <a class="c-state-unapproved c-action" title="'+e+'" alt="'+e+'">'+l+'</a> <a class="c-state-cancel c-action" title="'+p+'" alt="'+p+'">'+b+'</a> </div><a class="c-close c-iclose c-action" title="'+j+'" alt="'+j+'"><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="'+o+'" alt="'+o+'">'+o+'</a> <a class="c-reply c-action" title="'+h+'" alt="'+h+'">'+h+"</a>&nbsp;</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 c=d.target;var g=sv_site_url+sv_text_view_show_comment_url;if(c.get("href").indexOf(g)==0){var b=(new RegExp("comment_key=([^&]*)","g"))c(c.get("href"));if(b!=null){var a=b[1];var f=gDb.getCommentByKey(a);if(f!=null){d.halt();if(!c.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()){this.overlay.get("contentBox").query(".c-permalink").removeClass("displaynone");}},onMouseLeaveHeader:function(){if(readyForAction()&&this.isVisible()){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");this.overlay.get("contentBox").query(".c-close").addClass("c-iclose-focus");this.overlay.get("contentBox").query(".c-close").removeClass("c-iclose");},deactivate:function(){this.overlay.get("boundingBox").removeClass("c-focus-comment");this.overlay.get("contentBox").query(".c-close").addClass("c-iclose");this.overlay.get("contentBox").query(".c-close").removeClass("c-iclose-focus");},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(i){this.commentId=i.id;var b=this.overlay.get("boundingBox");var g=interpolate(gettext("last modified on %(date)s"),{date:i.modified_user_str},true);var l=(i.modified==i.created)?"":'<a title="'+g+'"> * </a>';var j=gettext("Permalink to this comment");var o='<a class="c-permalink displaynone c-action" target="_blank" title="'+j+'" href="/" >¶&nbsp;</a>';var k=interpolate(gettext("by %(name)s, created on %(date)s"),{name:i.name,date:i.created_user_str},true);var d='<span class="c-header"><div class="c-header-title">'+i.title+o+'</div><div class="c-infos">'+k+"</div></span>";var e=CY.Node.create(d);var p=b.query(".c-header");if(p==null){b.query(".icomment-header").insertBefore(e,b.one(".c-iactions"));}else{p.get("parentNode").replaceChild(e,p);}var h=CY.Node.create('<div class="c-tags"><span class="c-tags-infos">tags:</span>'+i.tags+"</div>");var n=b.query(".c-tags");if(n==null){b.query(".icomment-header").appendChild(h);}else{n.get("parentNode").replaceChild(h,n);}if(i.tags==""){h.addClass("displaynone");}var f=CY.Node.create('<span class="c-content">'+i.content_html+"</span>");var a=b.query(".c-content");if(a==null){b.query(".icomment-body").appendChild(f);}else{a.get("parentNode").replaceChild(f,a);}b.query(".c-permalink").set("href",sv_site_url+i.permalink);this.changeModeration(i);var c=this.overlay.get("contentBox").query(".c-moderate");c.set("title","click to change comment ID visibility".replace(/ID/,this.commentId).replace(/  /," "));var m=b.queryAll(".c-content a");if(m!=null){m.setAttribute("target","_blank");}m=b.queryAll(".c-header-title a");if(m!=null){m.setAttribute("target","_blank");}this.permAdapt(i);},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();}},setAnimationToPosition:function(b){var a=this.overlay.get("boundingBox");if(gPrefs.get("general","animduration")<0.011){a.setXY(b);}this.animation.set("to",{xy:b});this.animation.set("duration",gPrefs.get("general","animduration"));this["animation-handle"]=this.animation.on("end",this.onAnimationEnd,this);return this.animation;},setWidth:function(b){var a=this.overlay.get("boundingBox");a.setStyle("width",b+"px");},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)));}};_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,[]);}};hasPerm=function(a){return(-1!=CY.Array.indexOf(sv_user_permissions,a));};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("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=CY.get(".c-id-"+b.id).getY();this._showComments([b.id],a,false);if(b.replies.length>0){this._animateTo(a);}}},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();},browse:function(a,b){var c=gIComments.browse(a,b);if(c!=null){this.showSingleComment(c);}},_showComments:function(c,a,b){this._q.add({fn:function(){gShowingAllComments=b;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(!b){gIComments.activate(c[0]);var e=CY.get(".c-id-"+c[0]);if(!e.inViewportRegion()){e.scrollIntoView(true);}}else{CY.get("document").set("scrollTop",0);}}gIComments.setPosition([gConf.iCommentLeftPadding,a]);gIComments.show();}});},_animateTo:function(a){this._q.add({fn:function(){gIComments.setAnimationToPositions(a);}},{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);},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;};paintCommentScope=function(b){if(b.reply_to_id==null){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");}};CY=null;gPrefs=null;gLayout=null;gDb=null;gIComments=null;gSync=null;gGETValues=null;gConf={iCommentLeftPadding:4,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(c){c.preventDefault();var b=c.target;while(b!=null&&b.get("href")==null){b=b.get("parentNode");}if(b!=null&&b.get("href")!=null){window.open(b.get("href"));}};CY.all("#textcontainer a").on("click",a);};onDomReady=function(b){preventLinksInText();var a=new CY.AsyncQueue();a.add({fn:function(){if(gLayout.isInComentSite()){top.v_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_key" in gGETValues){var c=gGETValues.comment_key;var f=gDb.getCommentByKey(c);if(f!=null){var e=gDb.getPath(f);var d=e[e.length-1];gSync.showSingleComment(d);}}else{gSync.showAllComments();}}});a.run();};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);}}; 
  • src/cm/media/js/client/f_client-min.js

    r0 r4  
    1 onFadeEnd=function(){$(this).remove();};gLoadingMsg=null;enqueueLoadingMsg=function(){gLoadingMsg=_enqueueMsg(gettext("loading..."),"",null);};removeLoadingMsg=function(){if(gLoadingMsg!=null){gLoadingMsg.remove();gLoadingMsg=null;}};_enqueueMsg=function(d,b,c){var a=$("<span>"+d+"</span>").appendTo("#c-msg-wrapper").addClass("f-msg-cls").addClass(b);if(c){a.animate({opacity:0.95},c).fadeOut(2000,onFadeEnd);}return a;};enqueueMsg=function(c){var a="f-msg";var b=8000;_enqueueMsg(c,a,b);};enqueueErrorMsg=function(c){var a="f-msg-e";var b=4000;_enqueueMsg(c,a,b);};onFadeEnd=function(){$(this).remove();};gLoadingMsg=null;enqueueLoadingMsg=function(){gLoadingMsg=_enqueueMsg(gettext("loading..."),"",null);};removeLoadingMsg=function(){if(gLoadingMsg!=null){gLoadingMsg.remove();gLoadingMsg=null;}};_enqueueMsg=function(g,e,h){var f=$("<span>"+g+"</span>").appendTo("#c-msg-wrapper").addClass("f-msg-cls").addClass(e);if(h){f.animate({opacity:0.95},h).fadeOut(2000,onFadeEnd);}return f;};enqueueMsg=function(f){var e="f-msg";var d=8000;_enqueueMsg(f,e,d);};enqueueErrorMsg=function(f){var e="f-msg-e";var d=4000;_enqueueMsg(f,e,d);};gFormats=[{actions:["print"],extension:"html",label:gettext("print from the browser")},{actions:["export"],extension:"html",label:gettext("download html file (.html)")},{actions:["print","export"],extension:"markdown",label:gettext("download markdown file (.mkd)")},{actions:["print","export"],extension:"pdf",label:gettext("download portable object format file (.pdf)")},{actions:["print","export"],extension:"tex",label:gettext("download latex file (.tex)")},{actions:["print","export"],extension:"odt",label:gettext("download open document file (.odt)")}];gActions={print:{dialogTitle:gettext("Print text"),defaultMethod:"pdf",defaultWithColors:"no",defaultWhichComments:"all"},"export":{dialogTitle:gettext("Export text"),defaultMethod:"pdf",defaultWithColors:"no",defaultWhichComments:"all"}};gCurrentAction=null;_populateMethod=function(g){var f=$("#p_method").val();$("#p_method").html("");for(var d=0,c=gFormats.length;d<c;d++){var e=gFormats[d]["actions"];for(var b=0,a=gFormats.length;b<a;b++){if(e[b]==gCurrentAction){$("<option value='"+gFormats[d]["extension"]+"'>"+gFormats[d]["label"]+"</option>").appendTo("#p_method");}}}if(f){$("#p_method").val(f);}else{$("#p_method").val(gActions[gCurrentAction]["defaultMethod"]);}};_populateMarkersColorsChoice=function(b){var a=$("#p_color").val();$("#p_color").html("");$("<option value='0'>"+gettext("using markers only, no background colors")+"</option>").appendTo("#p_color");$("<option value='1'>"+gettext("using markers and background colors")+"</option>").appendTo("#p_color");if(a){$("#p_color").val(a);}else{$("#p_color").val(gActions[gCurrentAction]["defaultWithColors"]);}};_populateWhichComments=function(){var c=$("#p_comments").val();$("#p_comments").html("");var a=interpolate(gettext("all (%(nb_comments)s)"),{nb_comments:frames.text_view_comments.gDb.getCommentsNb(true)},true);var b=interpolate(gettext("current filtered ones (%(nb_comments)s)"),{nb_comments:frames.text_view_comments.gDb.getCommentsNb(false)},true);$("<option value='all' >"+a+"</option>").appendTo($("#p_comments"));$("<option value='none' >"+gettext("none (0)")+"</option>").appendTo($("#p_comments"));$("<option value='filtered' >"+b+"</option>").appendTo($("#p_comments"));if(c){$("#p_comments").val(c);}else{$("#p_comments").val(gActions[gCurrentAction]["defaultWhichComments"]);}};_manageMarkersColorsChoice=function(){var c=$("#p_method").val();var b=$("#p_comments").val();var a;if(gCurrentAction=="print"){a=((b=="none")||(c=="markdown")||(c=="html"));}if(gCurrentAction=="export"){a=((b=="none")||(c=="markdown"));}if(a){$("#p_color").val("no");}$("#p_color").attr("disabled",a);};_initPrintDialog=function(){$("#p_comments").add($("#p_method")).change(function(){_manageMarkersColorsChoice();_prepareOpenInNewWindow();});var a={};a[gettext("Go !")]=function(){var d=$("#p_comments").val();var c=$("#p_color").val();var e=$("#p_method").val();var b=(gCurrentAction=="export")?"1":(e=="html")?"0":"1";var f=$("#print_export_form").attr("target_action").replace(/FoRmAt/,e).replace(/DoWnLoAd/,b).replace(/WhIcHCoMmEnT/,d).replace(/WiThCoLoR/,c);$("#print_export_form").attr("action",f);document.print_export_form.submit();$(this).dialog("close");};a[gettext("Cancel")]=function(){$(this).dialog("close");};$("#dialog_print_export").dialog({bgiframe:true,autoOpen:false,width:450,modal:true,buttons:a,close:function(){}});};openPrintDialog=function(){_openPrintExportDialog("print");};openExportDialog=function(){_openPrintExportDialog("export");};_prepareOpenInNewWindow=function(){var a=$("#p_method").val();if((a=="html")&&(gCurrentAction=="print")){$("#print_export_form").attr("target","_blank");}else{$("#print_export_form").removeAttr("target");}};_openPrintExportDialog=function(a){gCurrentAction=a;$("#ui-dialog-title-dialog_print_export").html(gActions[gCurrentAction]["dialogTitle"]);$("#print_export_action").val(a);_populateWhichComments();_populateMarkersColorsChoice();_populateMethod();_manageMarkersColorsChoice();_prepareOpenInNewWindow();$("#dialog_print_export").dialog("open");};var gResetOtherFieldsOnFilterFieldChange=true;var myDefaultOuterLayoutSettings={center:{paneSelector:".outer-center"},north:{size:50,spacing_open:0,closable:false,resizable:false}};var innerNorthPaneDefaults={innerNorthPaneOpened:"0",selectedTab:"0"};onInnerNorthPaneClose=function(){_setCookie("innerNorthPaneOpened","0");$("#add_comment_btn").css("top",63);return true;};onInnerNorthPaneOpen=function(){_setCookie("innerNorthPaneOpened","1");$("#add_comment_btn").css("top",149);return true;};var myDefaultInnerLayoutSettings={north:{size:88,spacing_closed:8,slidable:false,resizable:false,togglerLength_closed:"100%",togglerLength_open:"100%",togglerAlign_closed:"center",togglerTip_closed:gettext("click to show options"),togglerTip_open:gettext("click to hide options"),initClosed:false,paneSelector:".inner-north",onopen:"onInnerNorthPaneOpen",onclose:"onInnerNorthPaneClose"}};var outerLayout,innerLayout;layoutFrames=function(){var a=$.cookie("innerNorthPaneOpened");myDefaultInnerLayoutSettings.north.initClosed=(a===null)?(innerNorthPaneDefaults.innerNorthPaneOpened=="0"):(a=="0");outerLayout=$("body").layout(myDefaultOuterLayoutSettings);innerLayout=$("div.outer-center").layout(myDefaultInnerLayoutSettings);if(myDefaultInnerLayoutSettings.north.initClosed){onInnerNorthPaneClose();}else{onInnerNorthPaneOpen();}};fillFilterTab=function(){var b=$("#c_filter");var a='<div style="float:right"><table><tr><td style="text-align:right;">'+gettext("Text")+'<td>&nbsp;</td><td><input id="filter_text" type="text"></input><input id="c_filter_btn" type="button" value="'+gettext("Search")+'"></input></td></tr><tr><td colspan="3" style="text-align:right;"><input id="c_filterreset_btn" type="button" value="'+gettext("Reset")+'"></input><input id="c_filterhideall_btn" type="button" value="'+gettext("Hide all Comments")+'"></input></td></tr></table></div><table><tr><td style="text-align:right;">'+gettext("Authors")+'</td><td>&nbsp;</td><td><select id="filter_name"></select></td><td>&nbsp;</td><td style="text-align:right;">'+gettext("States")+'</td><td>&nbsp;</td><td><select id="filter_state"></select></td></tr><tr><td style="text-align:right;">'+gettext("Dates")+'</td><td>&nbsp;</td><td><select id="filter_date"></select></td><td>&nbsp;</td><td style="text-align:right;">'+gettext("Tags")+'</td><td>&nbsp;</td><td><select id="filter_tag"></select></td></tr></table>';b.append($(a));$("#c_filter input[type='text']").add("#c_filter select").addClass("c_filter_field");$("#filter_name").add("#filter_date").add("#filter_tag").add("#filter_state").change(function(){if(frames.text_view_comments.readyForAction()){var c=$(this);frames.text_view_comments.checkForOpenedDialog(null,function(){applyFilter(c);});}});$("#c_filter_btn").click(function(){if(frames.text_view_comments.readyForAction()){var c=$("#filter_text");frames.text_view_comments.checkForOpenedDialog(null,function(){applyFilter(c);});}});$("#filter_text").keyup(function(c){if(c.keyCode==13){$("#c_filter_btn").click();}});$("#c_filterreset_btn").click(function(){if(frames.text_view_comments.readyForAction()){frames.text_view_comments.checkForOpenedDialog(null,function(){resetFilter();});}});$("#c_filterhideall_btn").click(function(){if(frames.text_view_comments.readyForAction()){frames.text_view_comments.checkForOpenedDialog(null,function(){frames.text_view_comments.hideAll();});}});};fillTopToolbar=function(){var o=$("#outer-north");var b=gettext("view previous comment");var e=gettext("view next comment");var n=gettext("view first comment");var k=gettext("view last next comment");var g=gettext("view all comments");var c=gettext("toggle advance interface");var a=gettext("print document with/without comments");var l=gettext("export document with/without comments");var m=gettext("toggle full screen view");var p=gettext("text feed");var f=gettext("add a comment");var j='<div id="c-right-btn"><img id="c_advanced_btn" src="'+sv_media_url+'/img/lightbulb_small.png" title="'+c+'" alt="'+c+'"/><img id="c_fullscreen_btn" src="'+sv_media_url+'/img/arrow_out.png" title="'+m+'" alt="'+m+'"/><img id="c_print_btn" src="'+sv_media_url+'/img/printer.png" title="'+a+'" alt="'+a+'"/><img id="c_export_btn" src="'+sv_media_url+'/img/page_go.png" title="'+l+'" alt="'+l+'"/><a target="_blank" href="'+frames.text_view_comments.sv_text_feed_url+'"><img id="c_feed_btn" src="'+sv_media_url+'/img/feed.png" title="'+p+'" alt="'+p+'"/></a></div><div id="c-msg-wrapper"></div><table style="margin-bottom:.3em;"><tbody><tr><td><span id="c_filter_results" ><b>&nbsp;<span id="c_f_res_nb_dis"></span></b>&nbsp;'+gettext("discussions")+'<span id="c_f_res_details">&nbsp;('+gettext("filter:")+'&nbsp;<span id="c_f_res_nb_com"></span>/<span id="c_f_res_nb_tot_com"></span>&nbsp;'+gettext("comments")+',&nbsp;<span id="c_f_res_nb_rep"></span>/<span id="c_f_res_nb_tot_rep"></span>&nbsp;'+gettext("replies")+')</span></span></td><td><span id="browse_section">, '+gettext("browse by:")+' <select id="browse_by"><option value="scope">'+gettext("location")+'</option><option value="modif_thread">'+gettext("modification")+'</option></select></span></td><td width="40" align="right"><a href="#" id="c_browse_first"><img title="'+n+'" alt="'+n+'" src="'+sv_media_url+'/img/control_fastbackward_blue.png"/></a><a href="#" id="c_browse_prev"><img title="'+b+'" alt="'+b+'" src="'+sv_media_url+'/img/control_playback_blue.png"/></a></td><td width="50" align="center"><span id="c_browse_indx_scope">-</span><span id="c_browse_indx_modif_thread" style="display: none;">-</span>/<span id="c_browse_indx_total"></span></td><td width="40" align="left"><a href="#" id="c_browse_next"><img title="'+e+'" alt="'+e+'" src="'+sv_media_url+'/img/control_play_blue.png"/></a><a href="#" id="c_browse_last"><img title="'+k+'" alt="'+k+'" src="'+sv_media_url+'/img/control_fastforward_blue.png"/></a></td><td width="20" align="left"><a href="#" id="c_browse_all"><img title="'+g+'" alt="'+g+'" src="'+sv_media_url+'/img/view_all.png"/></a></td></tr></tbody></table>';o.prepend($(j));$("#add_comment_btn").click(function(){if(frames.text_view_comments.readyForAction()){frames.text_view_comments.checkForOpenedDialog(null,function(){frames.text_view_comments.gSync.showCommentForm(null);});}});var i=function(){$("#browse_by option").each(function(){$("#c_browse_indx_"+this.value).hide();});$("#c_browse_indx_"+$("#browse_by").val()).show();};var d=$.cookie("browse_by");d=(d==null)?"location":d;_setCookie("browse_by",$("#browse_by").val());$("#browse_by option[value="+d+"]").attr("selected",true);i();$("#browse_by").change(function(){_setCookie("browse_by",$("#browse_by").val());i();});var h=function(q){if(frames.text_view_comments.readyForAction()){frames.text_view_comments.checkForOpenedDialog(null,function(){frames.text_view_comments.browse($("#browse_by").val(),q);});}};$("#c_browse_prev").click(function(){h("prev");});$("#c_browse_next").click(function(){h("next");});$("#c_browse_first").click(function(){h("first");});$("#c_browse_last").click(function(){h("last");});$("#c_browse_all").click(function(){if(frames.text_view_comments.readyForAction()){frames.text_view_comments.checkForOpenedDialog(null,function(){frames.text_view_comments.gSync.showAllComments();});}});$("#c_print_btn").click(function(){if(frames.text_view_comments.readyForAction()){var q=frames.text_view_comments.gDb.getFilteredCommentIdsAsString();frames.text_view_comments.CY.log($("#filteredIds").val(q));openPrintDialog();}});$("#c_export_btn").click(function(){if(frames.text_view_comments.readyForAction()){var q=frames.text_view_comments.gDb.getFilteredCommentIdsAsString();frames.text_view_comments.CY.log($("#filteredIds").val(q));openExportDialog();}});$("#c_fullscreen_btn").click(function(){if(frames.text_view_comments.gLayout.isInComentSite()){top.v_toggleFrameSize();}});$("#c_advanced_btn").click(function(){$(".ui-layout-toggler").click();});};onSliderStop=function(){var a=$("#c_slider").slider("value");if(a>(frames.text_view_comments.gConf.sliderFixedMin*100)){$("#c_slider").slider("value",[90]);}if(a<(frames.text_view_comments.gConf.sliderFixedMax*100)){$("#c_slider").slider("value",[10]);}frames.text_view_comments.c_setCommentsColWidth(a);frames.text_view_comments.c_persistPreference("layout","comments_col_width",a);};fillTextPreferencesTab=function(){var d=$("#c_text_preferences");d.append($("<table><tr><td>"+gettext("Text style")+'</td><td>&nbsp;</td><td><select id="c_textpref_style"></select></td></tr></table>'));var e=frames.text_view_comments.gTextStyles;for(var c in e){$("#c_textpref_style").append($("<option value='"+c+"'>"+e[c]+"</option>"));}var a=function(){var g=frames.text_view_comments.gTextStyles;var h=$("#c_textpref_style").val();for(var f in g){if(f==h){frames.text_view_comments.CY.get("#textcontainer").addClass(g[f]);}else{frames.text_view_comments.CY.get("#textcontainer").removeClass(g[f]);}}};var b=function(){var f=frames.text_view_comments.c_readPreference("text","style");$("#c_textpref_style").val(f);};$("#c_textpref_style").change(function(f){frames.text_view_comments.c_persistPreference("text","style",$("#c_textpref_style").val());a();});b();a();};fillPreferencesTab=function(){var b=$("#c_preferences");var a='<div style="float:right"><input id="c_pref_save_btn" type="button" value="'+gettext("Save")+'"></input><input id="c_pref_reset_btn" type="button" value="'+gettext("Reset")+'"></input></div><table><tr><td>'+gettext("Animation duration")+'</td><td>&nbsp;</td><td><input id="c_pref_animduration" type="text" style="width:3em" value="" /></td><td>&nbsp;</td><td>'+gettext("Use padding to show discussion threads")+'</td><td>&nbsp;</td><td><input id="c_pref_threadpad" type="checkbox"/></td></tr><tr><td><span class="frame_helptext">'+gettext("(0.001 to 1 second)")+"</span></td><td></td><td></td><td></td><td></td></tr></table>";b.append($(a));setPreferencesFieldsValue=function(){var c=frames.text_view_comments.c_readPreference("general","animduration");$("#c_pref_animduration").val(c);c=frames.text_view_comments.c_readPreference("comments","threadpad");$("#c_pref_threadpad").attr("checked",(c=="1"));};setPreferencesFieldsValue();$("#c_pref_animduration").blur(function(){var c=parseFloat($(this).val());if(isNaN(c)||(c<=0)||(c>1)){c=frames.text_view_comments.c_readDefaultPreference("general","animduration");}$(this).val(c);});$("#c_pref_reset_btn").click(function(){frames.text_view_comments.c_resetPreferences(["general","comments"]);setPreferencesFieldsValue();enqueueMsg(gettext("preferences reset (will apply on next load)"));});$("#c_pref_save_btn").click(function(){var c=$("#c_pref_threadpad").attr("checked")?"1":"0";frames.text_view_comments.c_persistPreference("comments","threadpad",c);frames.text_view_comments.c_persistPreference("general","animduration",$("#c_pref_animduration").val());enqueueMsg(gettext("preferences saved (will apply on next load)"));});};initFrame=function(){_initYesNoDialog();_initPrintDialog();$(window).resize(function(){onSliderStop();});$("#c_slider").slider({animate:true,range:"min",value:frames.text_view_comments.c_readPreference("layout","comments_col_width"),min:1,iframeFix:true,max:100,slide:function(a,b){var c=b.value;frames.text_view_comments.c_setCommentsColWidth(c);},stop:function(a,b){onSliderStop();}});_initTabs();f_interfaceFreeze();};_initTabs=function(){$(".inner-north").tabs();var a=$.cookie("selectedTab");a=(a===null)?innerNorthPaneDefaults.selectedTab:parseInt(a);$(".inner-north").tabs("select",a);$(".inner-north").bind("tabsselect",function(b,c){_setCookie("selectedTab",c.index);});};_initYesNoDialog=function(){$("#dialog_h").dialog({autoOpen:false,modal:true});};_setCookie=function(a,c){var b=new Date();b.setFullYear(2100,0,1);$.cookie(a,c,{expires:b,path:"/"});};f_getFrameFilterData=function(){var c=$("#filter_name").val();var b=$("#filter_date").val();var e=$("#filter_text").val();var a=$("#filter_tag").val();var d=$("#filter_state").val();return{name:c,date:b,text:e,tag:a,state:d};};f_setFilterValue=function(a){for(key in a){if(key.indexOf("filter_")==0){$("#"+key).val(a[key]);}}};f_isFrameFilterFieldsInit=function(){var b=f_getFrameFilterData();var a=true;for(key in b){a=a&&(b[key]=="");}return a;};initFilterFields=function(){$(".c_filter_field").val("");};resetFilter=function(){initFilterFields();frames.text_view_comments.reinit();enqueueMsg(gettext("filter reset"));};applyFilter=function(a){var b=a.val();if(gResetOtherFieldsOnFilterFieldChange){initFilterFields();a.val(b);}frames.text_view_comments.reinit();enqueueMsg(gettext("filter applied"));};f_updateFilterCountResult=function(d,a,b,e,c){$("#c_f_res_nb_dis").html(d);$("#c_f_res_nb_com").html(a);$("#c_f_res_nb_tot_com").html(e);$("#c_f_res_nb_rep").html(b);$("#c_f_res_nb_tot_rep").html(c);$("#c_browse_indx_total").html(d);$("#c_filter_results").show();};f_updateFilterCountDetailed=function(a){if(a){$("#c_f_res_details").show();$("c_browse_all").val("View all (filtered) comments");}else{$("#c_f_res_details").hide();$("#c_browse_all").val("View all comments");}};f_updateFilterData=function(e){var g=$("#filter_name option:selected").attr("name");var k=gettext("all");$("#filter_name option").remove();$("#filter_name").append($("<option name='c_f2_user_all' value=''>"+k+"</option>"));for(var c=0,b=e.names.length;c<b;c++){var l=e.names[c];$("#filter_name").append($("<option name='c_f2_user_"+l.name+"' value='"+l.name+"'>"+l.name+"("+l.nb_comments+")</option>"));}$("#filter_name option[name="+g+"]").attr("selected",true);var a=$("#filter_date option:selected").attr("name");$("#filter_date option").remove();$("#filter_date").append($("<option name='c_f_date_all' value=''>"+k+"</option>"));for(var c=0,b=e.dates.length;c<b;c++){var l=e.dates[c];var f=ngettext("last 24 hours (%(nb_comments)s)","last %(nb_days)s days (%(nb_comments)s)",l.nb_day);var j=interpolate(f,{nb_days:l.nb_day,nb_comments:l.nb_comments},true);$("#filter_date").append($("<option name='c_f_date_"+l.nb_day+"' value='"+l.nb_day_date+"'>"+j+"</option>"));}$("#filter_date option[name="+a+"]").attr("selected",true);var h=$("#filter_tag option:selected").attr("name");$("#filter_tag option").remove();$("#filter_tag").append($("<option name='c_f2_tag_all' value=''>"+k+"</option>"));for(var c=0,b=e.tags.length;c<b;c++){var l=e.tags[c];$("#filter_tag").append($("<option name='c_f2_tag_"+l.name+"' value='"+l.name+"'>"+l.name+"("+l.nb_comments+")</option>"));}$("#filter_tag option[name="+h+"]").attr("selected",true);var d=$("#filter_state option:selected").attr("state");$("#filter_state option").remove();$("#filter_state").append($("<option name='c_f2_state_all' value=''>"+k+"</option>"));for(var c=0,b=e.states.length;c<b;c++){var l=e.states[c];$("#filter_state").append($("<option name='c_f2_state_"+l.state+"' value='"+l.state+"'>"+gettext(l.state)+"("+l.nb_comments+")</option>"));}$("#filter_state option[name="+d+"]").attr("selected",true);};f_interfaceUnfreeze=function(){for(var b=0,a=$(".c_tab").length;b<a;b++){$(".inner-north").tabs("enable",b);}$(".inner-north select").add(".inner-north input").add("#outer-north select").add("#outer-north input").each(function(){$(this).attr("disabled",false);});$("#c_slider").slider("enable");};f_interfaceFreeze=function(){for(var b=0,a=$(".c_tab").length;b<a;b++){$(".inner-north").tabs("disable",b);}$(".inner-north select").add(".inner-north input").add("#outer-north select").add("#outer-north input").each(function(){$(this).attr("disabled",true);});$("#c_slider").slider("disable");};f_enqueueMsg=function(a){enqueueMsg(a);};f_enqueueErrorMsg=function(a){enqueueErrorMsg(a);};f_removeLoadingMsg=function(){removeLoadingMsg();};f_initFrame=function(){initFrame();};f_layoutFrames=function(){layoutFrames();};f_fillTextPreferencesTab=function(){fillTextPreferencesTab();};f_fillPreferencesTab=function(){fillPreferencesTab();};f_fillBrowseSection=function(){fillBrowseSection();};f_fillFilterTab=function(){fillFilterTab();};f_fillTopToolbar=function(){fillTopToolbar();};f_yesNoDialog=function(d,g,e,b,c,h,a,j){$("#dialog_h").html(d);$("#dialog_h").dialog("option","title",g);function k(){if(e!=null){e.call(b,c);}}function i(){if(h!=null){h.call(a,j);}}var f={};f[gettext("No")]=function(){$(this).dialog("close");k();};f[gettext("Yes")]=function(){$(this).dialog("close");i();};$("#dialog_h").dialog("option","buttons",f);$("#dialog_h").dialog("open");};f_setCookie=function(a,b){_setCookie(a,b);}; 
     1onFadeEnd=function(){$(this).remove();};gLoadingMsg=null;enqueueLoadingMsg=function(){gLoadingMsg=_enqueueMsg(gettext("loading..."),"",null);};removeLoadingMsg=function(){if(gLoadingMsg!=null){gLoadingMsg.remove();gLoadingMsg=null;}};_enqueueMsg=function(d,b,c){var a=$("<span>"+d+"</span>").appendTo("#c-msg-wrapper").addClass("f-msg-cls").addClass(b);if(c){a.animate({opacity:0.95},c).fadeOut(2000,onFadeEnd);}return a;};enqueueMsg=function(c){var a="f-msg";var b=8000;_enqueueMsg(c,a,b);};enqueueErrorMsg=function(c){var a="f-msg-e";var b=4000;_enqueueMsg(c,a,b);};onFadeEnd=function(){$(this).remove();};gLoadingMsg=null;enqueueLoadingMsg=function(){gLoadingMsg=_enqueueMsg(gettext("loading..."),"",null);};removeLoadingMsg=function(){if(gLoadingMsg!=null){gLoadingMsg.remove();gLoadingMsg=null;}};_enqueueMsg=function(g,e,h){var f=$("<span>"+g+"</span>").appendTo("#c-msg-wrapper").addClass("f-msg-cls").addClass(e);if(h){f.animate({opacity:0.95},h).fadeOut(2000,onFadeEnd);}return f;};enqueueMsg=function(f){var e="f-msg";var d=8000;_enqueueMsg(f,e,d);};enqueueErrorMsg=function(f){var e="f-msg-e";var d=4000;_enqueueMsg(f,e,d);};gFormats=[{actions:["print"],extension:"html",label:gettext("print from the browser")},{actions:["export"],extension:"html",label:gettext("download html file (.html)")},{actions:["print","export"],extension:"markdown",label:gettext("download markdown file (.mkd)")},{actions:["print","export"],extension:"pdf",label:gettext("download portable object format file (.pdf)")},{actions:["print","export"],extension:"tex",label:gettext("download latex file (.tex)")},{actions:["print","export"],extension:"odt",label:gettext("download open document file (.odt)")}];gActions={print:{dialogTitle:gettext("Print text"),defaultMethod:"pdf",defaultWithColors:"no",defaultWhichComments:"all"},"export":{dialogTitle:gettext("Export text"),defaultMethod:"pdf",defaultWithColors:"no",defaultWhichComments:"all"}};gCurrentAction=null;_populateMethod=function(g){var f=$("#p_method").val();$("#p_method").html("");for(var d=0,c=gFormats.length;d<c;d++){var e=gFormats[d]["actions"];for(var b=0,a=gFormats.length;b<a;b++){if(e[b]==gCurrentAction){$("<option value='"+gFormats[d]["extension"]+"'>"+gFormats[d]["label"]+"</option>").appendTo("#p_method");}}}if(f){$("#p_method").val(f);}else{$("#p_method").val(gActions[gCurrentAction]["defaultMethod"]);}};_populateMarkersColorsChoice=function(b){var a=$("#p_color").val();$("#p_color").html("");$("<option value='0'>"+gettext("using markers only, no background colors")+"</option>").appendTo("#p_color");$("<option value='1'>"+gettext("using markers and background colors")+"</option>").appendTo("#p_color");if(a){$("#p_color").val(a);}else{$("#p_color").val(gActions[gCurrentAction]["defaultWithColors"]);}};_populateWhichComments=function(){var c=$("#p_comments").val();$("#p_comments").html("");var a=interpolate(gettext("all (%(nb_comments)s)"),{nb_comments:frames.text_view_comments.gDb.getCommentsNb(true)},true);var b=interpolate(gettext("current filtered ones (%(nb_comments)s)"),{nb_comments:frames.text_view_comments.gDb.getCommentsNb(false)},true);$("<option value='all' >"+a+"</option>").appendTo($("#p_comments"));$("<option value='none' >"+gettext("none (0)")+"</option>").appendTo($("#p_comments"));$("<option value='filtered' >"+b+"</option>").appendTo($("#p_comments"));if(c){$("#p_comments").val(c);}else{$("#p_comments").val(gActions[gCurrentAction]["defaultWhichComments"]);}};_manageMarkersColorsChoice=function(){var c=$("#p_method").val();var b=$("#p_comments").val();var a;if(gCurrentAction=="print"){a=((b=="none")||(c=="markdown")||(c=="html"));}if(gCurrentAction=="export"){a=((b=="none")||(c=="markdown"));}if(a){$("#p_color").val("no");}$("#p_color").attr("disabled",a);};_initPrintDialog=function(){$("#p_comments").add($("#p_method")).change(function(){_manageMarkersColorsChoice();_prepareOpenInNewWindow();});var a={};a[gettext("Go !")]=function(){var d=$("#p_comments").val();var c=$("#p_color").val();var e=$("#p_method").val();var b=(gCurrentAction=="export")?"1":(e=="html")?"0":"1";var f=$("#print_export_form").attr("target_action").replace(/FoRmAt/,e).replace(/DoWnLoAd/,b).replace(/WhIcHCoMmEnT/,d).replace(/WiThCoLoR/,c);$("#print_export_form").attr("action",f);document.print_export_form.submit();$(this).dialog("close");};a[gettext("Cancel")]=function(){$(this).dialog("close");};$("#dialog_print_export").dialog({bgiframe:true,autoOpen:false,width:450,modal:true,buttons:a,close:function(){}});};openPrintDialog=function(){_openPrintExportDialog("print");};openExportDialog=function(){_openPrintExportDialog("export");};_prepareOpenInNewWindow=function(){var a=$("#p_method").val();if((a=="html")&&(gCurrentAction=="print")){$("#print_export_form").attr("target","_blank");}else{$("#print_export_form").removeAttr("target");}};_openPrintExportDialog=function(a){gCurrentAction=a;$("#ui-dialog-title-dialog_print_export").html(gActions[gCurrentAction]["dialogTitle"]);$("#print_export_action").val(a);_populateWhichComments();_populateMarkersColorsChoice();_populateMethod();_manageMarkersColorsChoice();_prepareOpenInNewWindow();$("#dialog_print_export").dialog("open");};var gResetOtherFieldsOnFilterFieldChange=true;var myDefaultOuterLayoutSettings={center:{paneSelector:".outer-center"},north:{size:50,spacing_open:0,closable:false,resizable:false}};var innerNorthPaneDefaults={innerNorthPaneOpened:"0",selectedTab:"0"};onInnerNorthPaneClose=function(){_setCookie("innerNorthPaneOpened","0");$("#add_comment_btn").css("top",63);return true;};onInnerNorthPaneOpen=function(){_setCookie("innerNorthPaneOpened","1");$("#add_comment_btn").css("top",149);return true;};var myDefaultInnerLayoutSettings={north:{size:88,spacing_closed:8,slidable:false,resizable:false,togglerLength_closed:"100%",togglerLength_open:"100%",togglerAlign_closed:"center",togglerTip_closed:gettext("click to show options"),togglerTip_open:gettext("click to hide options"),initClosed:false,paneSelector:".inner-north",onopen:"onInnerNorthPaneOpen",onclose:"onInnerNorthPaneClose"}};var outerLayout,innerLayout;layoutFrames=function(){var a=$.cookie("innerNorthPaneOpened");myDefaultInnerLayoutSettings.north.initClosed=(a===null)?(innerNorthPaneDefaults.innerNorthPaneOpened=="0"):(a=="0");outerLayout=$("body").layout(myDefaultOuterLayoutSettings);innerLayout=$("div.outer-center").layout(myDefaultInnerLayoutSettings);if(myDefaultInnerLayoutSettings.north.initClosed){onInnerNorthPaneClose();}else{onInnerNorthPaneOpen();}};fillFilterTab=function(){var b=$("#c_filter");var a='<div style="float:right"><table><tr><td style="text-align:right;">'+gettext("Text")+'<td>&nbsp;</td><td><input id="filter_text" type="text"></input><input id="c_filter_btn" type="button" value="'+gettext("Search")+'"></input></td></tr><tr><td colspan="3" style="text-align:right;"><input id="c_filterreset_btn" type="button" value="'+gettext("Reset")+'"></input><input id="c_filterhideall_btn" type="button" value="'+gettext("Hide all Comments")+'"></input></td></tr></table></div><table><tr><td style="text-align:right;">'+gettext("Authors")+'</td><td>&nbsp;</td><td><select id="filter_name"></select></td><td>&nbsp;</td><td style="text-align:right;">'+gettext("States")+'</td><td>&nbsp;</td><td><select id="filter_state"></select></td></tr><tr><td style="text-align:right;">'+gettext("Dates")+'</td><td>&nbsp;</td><td><select id="filter_date"></select></td><td>&nbsp;</td><td style="text-align:right;">'+gettext("Tags")+'</td><td>&nbsp;</td><td><select id="filter_tag"></select></td></tr></table>';b.append($(a));$("#c_filter input[type='text']").add("#c_filter select").addClass("c_filter_field");$("#filter_name").add("#filter_date").add("#filter_tag").add("#filter_state").change(function(){if(frames.text_view_comments.readyForAction()){var c=$(this);frames.text_view_comments.checkForOpenedDialog(null,function(){applyFilter(c);});}});$("#c_filter_btn").click(function(){if(frames.text_view_comments.readyForAction()){var c=$("#filter_text");frames.text_view_comments.checkForOpenedDialog(null,function(){applyFilter(c);});}});$("#filter_text").keyup(function(c){if(c.keyCode==13){$("#c_filter_btn").click();}});$("#c_filterreset_btn").click(function(){if(frames.text_view_comments.readyForAction()){frames.text_view_comments.checkForOpenedDialog(null,function(){resetFilter();});}});$("#c_filterhideall_btn").click(function(){if(frames.text_view_comments.readyForAction()){frames.text_view_comments.checkForOpenedDialog(null,function(){frames.text_view_comments.hideAll();});}});};fillTopToolbar=function(){var o=$("#outer-north");var b=gettext("view previous comment");var e=gettext("view next comment");var n=gettext("view first comment");var k=gettext("view last next comment");var g=gettext("view all comments");var c=gettext("toggle advance interface");var a=gettext("print document with/without comments");var l=gettext("export document with/without comments");var m=gettext("toggle full screen view");var p=gettext("text feed");var f=gettext("add a comment");var j='<div id="c-right-btn"><img id="c_fullscreen_btn" src="'+sv_media_url+'/img/arrow_out.png" title="'+m+'" alt="'+m+'"/><img id="c_print_btn" src="'+sv_media_url+'/img/printer.png" title="'+a+'" alt="'+a+'"/><img id="c_export_btn" src="'+sv_media_url+'/img/page_go.png" title="'+l+'" alt="'+l+'"/><a target="_blank" href="'+frames.text_view_comments.sv_text_feed_url+'"><img id="c_feed_btn" src="'+sv_media_url+'/img/feed.png" title="'+p+'" alt="'+p+'"/></a></div><div id="c-msg-wrapper"></div><table style="margin-bottom:.3em;"><tbody><tr><td><span id="c_filter_results" ><b>&nbsp;<span id="c_f_res_nb_dis"></span></b>&nbsp;<span id="c_f_res_nb_dis_txt"></span><span id="c_f_res_details">&nbsp;('+gettext("filter:")+'&nbsp;<span id="c_f_res_nb_com"></span>/<span id="c_f_res_nb_tot_com"></span>&nbsp;<span id="c_f_res_nb_com_txt"></span>&nbsp;<span id="c_f_res_nb_rep"></span>/<span id="c_f_res_nb_tot_rep"></span><span id="c_f_res_nb_rep_txt"></span>)</span></span></td><td><span id="browse_section">, '+gettext("browse by:")+' <select id="browse_by"><option value="scope">'+gettext("location")+'</option><option value="modif_thread">'+gettext("modification")+'</option></select></span></td><td width="40" align="right"><a href="#" id="c_browse_first"><img title="'+n+'" alt="'+n+'" src="'+sv_media_url+'/img/control_fastbackward_blue.png"/></a><a href="#" id="c_browse_prev"><img title="'+b+'" alt="'+b+'" src="'+sv_media_url+'/img/control_playback_blue.png"/></a></td><td width="50" align="center"><span id="c_browse_indx_scope">-</span><span id="c_browse_indx_modif_thread" style="display: none;">-</span>/<span id="c_browse_indx_total"></span></td><td width="40" align="left"><a href="#" id="c_browse_next"><img title="'+e+'" alt="'+e+'" src="'+sv_media_url+'/img/control_play_blue.png"/></a><a href="#" id="c_browse_last"><img title="'+k+'" alt="'+k+'" src="'+sv_media_url+'/img/control_fastforward_blue.png"/></a></td><td width="20" align="left"><a href="#" id="c_browse_all"><img title="'+g+'" alt="'+g+'" src="'+sv_media_url+'/img/view_all.png"/></a></td><td width="20" align="left"><a href="#" id="c_advanced_btn"><img title="'+c+'" alt="'+c+'" src="'+sv_media_url+'/img/application_split.png"/></a></td><td width="20" align="left"><a href="#" id="c_thread_unthread"><img id="c_thread_unthread_img"/></a></td></tr></tbody></table>';o.prepend($(j));$("#add_comment_btn").click(function(){if(frames.text_view_comments.readyForAction()){frames.text_view_comments.checkForOpenedDialog(null,function(){frames.text_view_comments.gSync.showCommentForm(null);});}});var i=function(){$("#browse_by option").each(function(){$("#c_browse_indx_"+this.value).hide();});$("#c_browse_indx_"+$("#browse_by").val()).show();};var d=$.cookie("browse_by");d=(d==null)?"location":d;_setCookie("browse_by",$("#browse_by").val());$("#browse_by option[value="+d+"]").attr("selected",true);i();$("#browse_by").change(function(){_setCookie("browse_by",$("#browse_by").val());i();});var h=function(q){if(frames.text_view_comments.readyForAction()){frames.text_view_comments.checkForOpenedDialog(null,function(){frames.text_view_comments.browse($("#browse_by").val(),q);});}};$("#c_browse_prev").click(function(){h("prev");});$("#c_browse_next").click(function(){h("next");});$("#c_browse_first").click(function(){h("first");});$("#c_browse_last").click(function(){h("last");});$("#c_browse_all").click(function(){if(frames.text_view_comments.readyForAction()){frames.text_view_comments.checkForOpenedDialog(null,function(){frames.text_view_comments.gSync.showAllComments();});}});$("#c_print_btn").click(function(){if(frames.text_view_comments.readyForAction()){var q=frames.text_view_comments.gDb.getFilteredCommentIdsAsString();frames.text_view_comments.CY.log($("#filteredIds").val(q));openPrintDialog();}});$("#c_export_btn").click(function(){if(frames.text_view_comments.readyForAction()){var q=frames.text_view_comments.gDb.getFilteredCommentIdsAsString();frames.text_view_comments.CY.log($("#filteredIds").val(q));openExportDialog();}});if(frames.text_view_comments.gLayout.isInComentSite()){$("#c_fullscreen_btn").click(function(){top.v_toggleFrameSize();});}$("#c_advanced_btn").click(function(){$(".ui-layout-toggler").click();});setThreadPref=function(){var r=frames.text_view_comments.c_readPreference("comments","threadpad");var s=sv_media_url+"/img/unthread_box.png";var q=gettext("unthread discussions");if(r=="0"){s=sv_media_url+"/img/thread_box.png";q=gettext("thread discussions");}$("#c_thread_unthread_img").attr("src",s).attr("alt",q).attr("title",q);};setThreadPref();$("#c_thread_unthread").click(function(){var r=frames.text_view_comments.c_readPreference("comments","threadpad");var q=(r=="0")?"1":"0";frames.text_view_comments.c_persistPreference("comments","threadpad",q);setThreadPref();frames.text_view_comments.gSync.animateToTop();});};onSliderStop=function(){var a=$("#c_slider").slider("value");if(a>(frames.text_view_comments.gConf.sliderFixedMin*100)){$("#c_slider").slider("value",[90]);}if(a<(frames.text_view_comments.gConf.sliderFixedMax*100)){$("#c_slider").slider("value",[10]);}frames.text_view_comments.c_setCommentsColWidth(a);frames.text_view_comments.c_persistPreference("layout","comments_col_width",a);};fillTextPreferencesTab=function(){var d=$("#c_text_preferences");d.append($("<table><tr><td>"+gettext("Text style")+'</td><td>&nbsp;</td><td><select id="c_textpref_style"></select></td></tr></table>'));var e=frames.text_view_comments.gTextStyles;for(var c in e){$("#c_textpref_style").append($("<option value='"+c+"'>"+e[c]+"</option>"));}var a=function(){var g=frames.text_view_comments.gTextStyles;var h=$("#c_textpref_style").val();for(var f in g){if(f==h){frames.text_view_comments.CY.get("#textcontainer").addClass(g[f]);}else{frames.text_view_comments.CY.get("#textcontainer").removeClass(g[f]);}}};var b=function(){var f=frames.text_view_comments.c_readPreference("text","style");$("#c_textpref_style").val(f);};$("#c_textpref_style").change(function(f){frames.text_view_comments.c_persistPreference("text","style",$("#c_textpref_style").val());a();});b();a();};fillPreferencesTab=function(){var b=$("#c_preferences");var a='<div style="float:right"><input id="c_pref_save_btn" type="button" value="'+gettext("Save")+'"></input><input id="c_pref_reset_btn" type="button" value="'+gettext("Reset")+'"></input></div><table><tr><td>'+gettext("Animation duration")+'</td><td>&nbsp;</td><td><input id="c_pref_animduration" type="text" style="width:3em" value="" /></td></tr><tr><td><span class="frame_helptext">'+gettext("(0.001 to 1 second)")+"</span></td><td></td><td></td></tr></table>";b.append($(a));setPreferencesFieldsValue=function(){var c=frames.text_view_comments.c_readPreference("general","animduration");$("#c_pref_animduration").val(c);};setPreferencesFieldsValue();$("#c_pref_animduration").blur(function(){var c=parseFloat($(this).val());if(isNaN(c)||(c<=0)||(c>1)){c=frames.text_view_comments.c_readDefaultPreference("general","animduration");}$(this).val(c);});$("#c_pref_reset_btn").click(function(){frames.text_view_comments.c_resetPreferences(["general"]);setPreferencesFieldsValue();enqueueMsg(gettext("preferences reset (will apply on next load)"));});$("#c_pref_save_btn").click(function(){frames.text_view_comments.c_persistPreference("general","animduration",$("#c_pref_animduration").val());enqueueMsg(gettext("preferences saved (will apply on next load)"));});};initFrame=function(){_initYesNoDialog();_initPrintDialog();$(window).resize(function(){onSliderStop();});$("#c_slider").slider({animate:true,range:"min",value:frames.text_view_comments.c_readPreference("layout","comments_col_width"),min:1,iframeFix:true,max:100,slide:function(a,b){var c=b.value;frames.text_view_comments.c_setCommentsColWidth(c);},stop:function(a,b){onSliderStop();}});_initTabs();f_interfaceFreeze();};_initTabs=function(){$(".inner-north").tabs();var a=$.cookie("selectedTab");a=(a===null)?innerNorthPaneDefaults.selectedTab:parseInt(a);$(".inner-north").tabs("select",a);$(".inner-north").bind("tabsselect",function(b,c){_setCookie("selectedTab",c.index);});};_initYesNoDialog=function(){$("#dialog_h").dialog({autoOpen:false,modal:true});};_setCookie=function(a,c){var b=new Date();b.setFullYear(2100,0,1);$.cookie(a,c,{expires:b,path:"/"});};f_getFrameFilterData=function(){var c=$("#filter_name").val();var b=$("#filter_date").val();var e=$("#filter_text").val();var a=$("#filter_tag").val();var d=$("#filter_state").val();return{name:c,date:b,text:e,tag:a,state:d};};f_setFilterValue=function(a){for(key in a){if(key.indexOf("filter_")==0){$("#"+key).val(a[key]);}}};f_isFrameFilterFieldsInit=function(){var b=f_getFrameFilterData();var a=true;for(key in b){a=a&&(b[key]=="");}return a;};initFilterFields=function(){$(".c_filter_field").val("");};resetFilter=function(){initFilterFields();frames.text_view_comments.reinit();enqueueMsg(gettext("filter reset"));};applyFilter=function(a){var b=a.val();if(gResetOtherFieldsOnFilterFieldChange){initFilterFields();a.val(b);}frames.text_view_comments.reinit();enqueueMsg(gettext("filter applied"));};f_updateFilterCountResult=function(d,a,b,e,c){$("#c_f_res_nb_dis").html(d);$("#c_f_res_nb_dis_txt").html(ngettext("discussion","discussions",d));$("#c_f_res_nb_com").html(a);$("#c_f_res_nb_tot_com").html(e);$("#c_f_res_nb_com_txt").html(ngettext("comment","comments",a));$("#c_f_res_nb_rep").html(b);$("#c_f_res_nb_tot_rep").html(c);$("#c_f_res_nb_rep_txt").html(ngettext("&nbsp;reply","&nbsp;replies",b));$("#c_browse_indx_total").html(d);$("#c_filter_results").show();};f_updateFilterCountDetailed=function(a){if(a){$("#c_f_res_details").show();$("c_browse_all").val("View all (filtered) comments");}else{$("#c_f_res_details").hide();$("#c_browse_all").val("View all comments");}};f_updateFilterData=function(e){var g=$("#filter_name option:selected").attr("name");var k=gettext("all");$("#filter_name option").remove();$("#filter_name").append($("<option name='c_f2_user_all' value=''>"+k+"</option>"));for(var c=0,b=e.names.length;c<b;c++){var l=e.names[c];$("#filter_name").append($("<option name='c_f2_user_"+l.name+"' value='"+l.name+"'>"+l.name+"("+l.nb_comments+")</option>"));}$("#filter_name option[name="+g+"]").attr("selected",true);var a=$("#filter_date option:selected").attr("name");$("#filter_date option").remove();$("#filter_date").append($("<option name='c_f_date_all' value=''>"+k+"</option>"));for(var c=0,b=e.dates.length;c<b;c++){var l=e.dates[c];var f=ngettext("last 24 hours (%(nb_comments)s)","last %(nb_days)s days (%(nb_comments)s)",l.nb_day);var j=interpolate(f,{nb_days:l.nb_day,nb_comments:l.nb_comments},true);$("#filter_date").append($("<option name='c_f_date_"+l.nb_day+"' value='"+l.nb_day_date+"'>"+j+"</option>"));}$("#filter_date option[name="+a+"]").attr("selected",true);var h=$("#filter_tag option:selected").attr("name");$("#filter_tag option").remove();$("#filter_tag").append($("<option name='c_f2_tag_all' value=''>"+k+"</option>"));for(var c=0,b=e.tags.length;c<b;c++){var l=e.tags[c];$("#filter_tag").append($("<option name='c_f2_tag_"+l.name+"' value='"+l.name+"'>"+l.name+"("+l.nb_comments+")</option>"));}$("#filter_tag option[name="+h+"]").attr("selected",true);var d=$("#filter_state option:selected").attr("state");$("#filter_state option").remove();$("#filter_state").append($("<option name='c_f2_state_all' value=''>"+k+"</option>"));for(var c=0,b=e.states.length;c<b;c++){var l=e.states[c];$("#filter_state").append($("<option name='c_f2_state_"+l.state+"' value='"+l.state+"'>"+gettext(l.state)+"("+l.nb_comments+")</option>"));}$("#filter_state option[name="+d+"]").attr("selected",true);};f_interfaceUnfreeze=function(){for(var b=0,a=$(".c_tab").length;b<a;b++){$(".inner-north").tabs("enable",b);}$(".inner-north select").add(".inner-north input").add("#outer-north select").add("#outer-north input").each(function(){$(this).attr("disabled",false);});$("#c_slider").slider("enable");};f_interfaceFreeze=function(){for(var b=0,a=$(".c_tab").length;b<a;b++){$(".inner-north").tabs("disable",b);}$(".inner-north select").add(".inner-north input").add("#outer-north select").add("#outer-north input").each(function(){$(this).attr("disabled",true);});$("#c_slider").slider("disable");};f_enqueueMsg=function(a){enqueueMsg(a);};f_enqueueErrorMsg=function(a){enqueueErrorMsg(a);};f_removeLoadingMsg=function(){removeLoadingMsg();};f_initFrame=function(){initFrame();};f_layoutFrames=function(){layoutFrames();};f_fillTextPreferencesTab=function(){fillTextPreferencesTab();};f_fillPreferencesTab=function(){fillPreferencesTab();};f_fillBrowseSection=function(){fillBrowseSection();};f_fillFilterTab=function(){fillFilterTab();};f_fillTopToolbar=function(){fillTopToolbar();};f_yesNoDialog=function(d,g,e,b,c,h,a,j){$("#dialog_h").html(d);$("#dialog_h").dialog("option","title",g);function k(){if(e!=null){e.call(b,c);}}function i(){if(h!=null){h.call(a,j);}}var f={};f[gettext("No")]=function(){$(this).dialog("close");k();};f[gettext("Yes")]=function(){$(this).dialog("close");i();};$("#dialog_h").dialog("option","buttons",f);$("#dialog_h").dialog("open");};f_setCookie=function(a,b){_setCookie(a,b);}; 
  • src/cm/templates/site/text_view_comments.html

    r0 r4  
    102102<script type="text/javascript" src="{{ MEDIA_URL }}js/site/c_text_view_comments.js"></script>  
    103103{% else %} 
    104 <script type="text/javascript" src="{{ MEDIA_URL }}js/client/c_client-min.js?1258465065"></script>  
     104<script type="text/javascript" src="{{ MEDIA_URL }}js/client/c_client-min.js?1258992363"></script>  
    105105{% endif %} 
    106106 
  • src/cm/templates/site/text_view_frame.html

    r0 r4  
    3737    <script type="text/javascript" src="{{ MEDIA_URL }}js/site/f_text_view_frame.js"></script> 
    3838{% else %} 
    39     <script type="text/javascript" src="{{ MEDIA_URL }}js/client/f_client-min.js?1258465065"></script>  
     39    <script type="text/javascript" src="{{ MEDIA_URL }}js/client/f_client-min.js?1258992363"></script>  
    4040{% endif %} 
    4141    <style type="text/css">