# HG changeset patch # User raph # Date 1269252159 -3600 # Node ID cc85d241b81d6fd652cab56b8333dbcb614c535e # Parent dfc53876028cc22696ef008d42b8c9a049f1eff0# Parent 849f10e1beec1446cb030ec31448be1e82c81a6f Merge with 849f10e1beec1446cb030ec31448be1e82c81a6f diff -r dfc53876028c -r cc85d241b81d src/cm/media/js/client/c_client-min.js --- a/src/cm/media/js/client/c_client-min.js Mon Mar 22 11:00:34 2010 +0100 +++ b/src/cm/media/js/client/c_client-min.js Mon Mar 22 11:02:39 2010 +0100 @@ -1,1 +1,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='
'+gettext("New reply")+"
";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().lengthv.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:'
',nameInput:gettext("Username:")+'
',emailInput:gettext("E-mail address:")+'
',titleInput:gettext("Title:")+'
',contentInput:gettext("Content:")+'
',tagsInput:gettext("Tag:")+'
',hidden:'',formEnd:"
",changeScope:'
'+gettext("Modify comment's scope:")+'
',headerTitle:'
',currentSel:'
'+gettext("Comment will apply to this selection:")+'
'+gNoSelectionYet+"
#hiddeninput#
",btns:'
',closeIcon:'      '};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="
"+gFormHtml.hidden.replace("###",f.selectionPlaceId).replace("???","selection_place")+"
";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";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().lengthN.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:'
',nameInput:gettext("Username:")+'
',emailInput:gettext("E-mail address:")+'
',titleInput:gettext("Title:")+'
',contentInput:gettext("Content:")+'
',tagsInput:gettext("Tag:")+'
',hidden:'',formEnd:"
",changeScope:'
'+gettext("Modify comment's scope:")+'
',headerTitle:'
',currentSel:'
'+gettext("Comment will apply to this selection:")+'
'+gNoSelectionYet+"
#hiddeninput#
",btns:'
',closeIcon:'      '};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="
"+gFormHtml.hidden.replace("###",i.selectionPlaceId).replace("???","selection_place")+"
";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;eb){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+"
  • "+b+"
  • ";};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;de[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(cm[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;k0){a=a.concat(this.getThreads(c[b].replies));}}return a;},_getPath:function(b,e){var a=[e];var d=e;while(d.reply_to_id!=null){d=b[d.reply_to_id];a.push(d);}return a;},getPath:function(a){return this._getPath(this.commentsByDbId,a);},getComment:function(a){return this.commentsByDbId[a];},getCommentByIdKey:function(a){for(var c in this.commentsByDbId){var b=this.commentsByDbId[c];if(b.id_key==a){return b;}}return null;},isChild:function(d,b){var c=this.commentsByDbId[d];var a=(d==b);while((!a)&&(c.reply_to_id!=null)){c=this.commentsByDbId[c.reply_to_id];a=(c.id==b);}return a;},initToReadOnly:function(f,c){for(var b=0,a=this.allComments.length;b0){var g=-1;if((f=="prev")||(f=="next")){for(var e=0;e=0)&&(ea.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;yc){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;c0){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=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='
    '+c.headerContent+"
    ";var e='
    '+c.bodyContent+"
    ";gEditICommentHost.overlay.setStdModContent(CY.WidgetStdMod.HEADER,CY.Node.create(b),CY.WidgetStdMod.AFTER);gEditICommentHost.overlay.setStdModContent(CY.WidgetStdMod.BODY,CY.Node.create(e),CY.WidgetStdMod.AFTER);CY.get("#"+gEdit.ids["formTitleId"]).set("innerHTML",gettext("Edit comment"));var f=gDb.getComment(gEditICommentHost.commentId);CY.get("#"+gEdit.ids["editCommentId"]).set("value",f.id);CY.get("#"+gEdit.ids["keyId"]).set("value",f.key);CY.get("#"+gEdit.ids["changeScopeInputId"]+" input").set("checked",false);if(f.reply_to_id!=null){CY.get("#"+gEdit.ids["changeScopeInputId"]).addClass("displaynone");}changeScopeFormClick();CY.get("#"+gEdit.ids["nameInputId"]).set("value",f.name);CY.get("#"+gEdit.ids["emailInputId"]).set("value",f.email);if(f.logged_author){CY.get("#"+gEdit.ids["nameInputId"]).setAttribute("disabled",true);CY.get("#"+gEdit.ids["emailInputId"]).setAttribute("disabled",true);}CY.get("#"+gEdit.ids["titleInputId"]).set("value",f.title);CY.get("#"+gEdit.ids["contentInputId"]).set("value",f.content);CY.get("#"+gEdit.ids["tagsInputId"]).set("value",f.tags);CY.get("#"+gEdit.ids["formatInputId"]).set("value",gConf.defaultCommentFormat);var d=gLayout.getTopICommentsWidth();changeFormFieldsWidth(gEdit.ids["formId"],d);gEdit.handlers["addBtnId"]=CY.on("click",onEditSaveClick,"#"+gEdit.ids["addBtnId"]);gEdit.handlers["cancelBtnId"]=CY.on("click",onEditCancelClick,"#"+gEdit.ids["cancelBtnId"]);gEdit.handlers["changeScope"]=CY.on("click",onChangeScopeClick,"#"+gEdit.ids["changeScopeInputId"]);};onEditSaveClick=function(a){if(readyForAction()){gSync.editComment();}};onEditCancelClick=function(a){if(readyForAction()){gSync.cancelEdit();}};onChangeScopeClick=function(){if(readyForAction()){gSync.changeScopeFormClick();}else{var a=CY.get("#"+gEdit.ids["changeScopeInputId"]+" input");var b=a.get("checked");a.set("checked",!b);}};changeScopeFormClick=function(){var a=CY.get("#"+gEdit.ids["currentSelId"]);if(CY.get("#"+gEdit.ids["changeScopeInputId"]+" input").get("checked")){a.removeClass("displaynone");}else{a.addClass("displaynone");}};cancelEditForm=function(){if(gEditICommentHost!=null){for(var b in gEdit.handlers){if(gEdit.handlers[b]!=null){gEdit.handlers[b].detach();gEdit.handlers[b]=null;}}var a=gEditICommentHost.overlay.get("contentBox").query(".icomment-edit-body");a.get("parentNode").removeChild(a);a=gEditICommentHost.overlay.get("contentBox").query(".icomment-edit-header");a.get("parentNode").removeChild(a);gEditICommentHost.showContent();gEditICommentHost=null;}};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
    '+t+'
    -X',bodyContent:'"});this.overlay.get("contentBox").addClass("c-comment");this.overlay.render("#leftcolumn");this.animation=new CY.Anim({node:this.overlay.get("boundingBox"),duration:gPrefs.get("general","animduration"),easing:CY.Easing.easeOut});this.overlay.get("contentBox").query(".c-close").on("click",this.onCloseCommentClick,this);this.overlay.get("contentBox").query(".c-moderate").on("click",this.onModerateCommentClick,this);this.overlay.get("contentBox").query(".c-state-pending").on("click",this.onPendingCommentClick,this);this.overlay.get("contentBox").query(".c-state-approved").on("click",this.onApprovedCommentClick,this);this.overlay.get("contentBox").query(".c-state-unapproved").on("click",this.onUnapprovedCommentClick,this);this.overlay.get("contentBox").query(".c-state-cancel").on("click",this.onCancelStateChangeClick,this);this.overlay.get("contentBox").query(".c-edit").on("click",this.onEditCommentClick,this);this.overlay.get("contentBox").query(".c-delete").on("click",this.onDeleteCommentClick,this);this.overlay.get("contentBox").query(".c-reply").on("click",this.onReplyCommentClick,this);this.overlay.get("contentBox").query(".c-readreplies").on("click",this.onReadRepliesCommentClick,this);this.overlay.get("contentBox").query(".icomment-header").on("mouseenter",this.onMouseEnterHeader,this);this.overlay.get("contentBox").query(".icomment-header").on("mouseleave",this.onMouseLeaveHeader,this);this.overlay.get("contentBox").on("click",this.onCommentClick,this);};IComment.prototype={onCloseCommentClick:function(a){a.halt();if(readyForAction()&&this.isVisible()){gSync.closeComment(this);}},onModerateCommentClick:function(a){a.halt();if(readyForAction()&&this.isVisible()){this.overlay.get("contentBox").query(".c-iactions").addClass("displaynone");this.overlay.get("contentBox").query(".c-state-actions").removeClass("displaynone");}},onPendingCommentClick:function(a){a.halt();if(readyForAction()&&this.isVisible()){gSync.moderateComment(this,"pending");}},onApprovedCommentClick:function(a){a.halt();if(readyForAction()&&this.isVisible()){gSync.moderateComment(this,"approved");}},onUnapprovedCommentClick:function(a){a.halt();if(readyForAction()&&this.isVisible()){gSync.moderateComment(this,"unapproved");}},onCancelStateChangeClick:function(a){a.halt();if(readyForAction()&&this.isVisible()){this.overlay.get("contentBox").query(".c-iactions").removeClass("displaynone");this.overlay.get("contentBox").query(".c-state-actions").addClass("displaynone");}},onDeleteCommentClick:function(a){a.halt();if(readyForAction()&&this.isVisible()){gSync.removeComment(this);}},onEditCommentClick:function(a){a.halt();if(readyForAction()&&this.isVisible()){gSync.showEditForm(this);}},onReplyCommentClick:function(a){a.halt();if(readyForAction()&&this.isVisible()){gSync.showReplyForm(this);}},onReadRepliesCommentClick:function(a){a.halt();if(readyForAction()&&this.isVisible()){gSync.openComment(this);}},onCommentClick:function(d){if(readyForAction()&&this.isVisible()){if(d.target.get("target")=="_blank"){var b=d.target;var g=sv_site_url+sv_text_view_show_comment_url;if(b.get("href").indexOf(g)==0){var a=(new RegExp("comment_id_key=([^&]*)","g")).exec(b.get("href"));if(a!=null){var c=a[1];var f=gDb.getCommentByIdKey(c);if(f!=null){d.halt();if(!b.hasClass("c-permalink")){checkForOpenedDialog(null,function(){gSync.showSingleComment(f);});}}}}}else{if(gShowingAllComments){if(!this._isHostingAForm()){var f=gDb.getComment(this.commentId);checkForOpenedDialog(null,function(){if(f!=null){gSync.showSingleComment(f);}});}}else{gSync.activate(this);}}}},onMouseEnterHeader:function(){if(readyForAction()&&this.isVisible()){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");},deactivate:function(){this.overlay.get("boundingBox").removeClass("c-focus-comment");},hide:function(){if(gIComments.isTopActive(this.commentId)){if(!gIComments.activateVisibleNext()){gIComments.deactivate();}}if(this.isVisible()){this.overlay.hide();this.overlay.blur();}},hideContent:function(){this.overlay.get("contentBox").query(".icomment-header").addClass("displaynone");this.overlay.get("contentBox").query(".icomment-body").addClass("displaynone");},showContent:function(){this.overlay.get("contentBox").query(".icomment-header").removeClass("displaynone");this.overlay.get("contentBox").query(".icomment-body").removeClass("displaynone");},isVisible:function(){return this.overlay.get("visible");},show:function(){this.hideReadRepliesLnk();return this.overlay.show();},showReadRepliesLnk:function(){this.overlay.get("contentBox").query(".c-readreplies").removeClass("displaynone");},hideReadRepliesLnk:function(){this.overlay.get("contentBox").query(".c-readreplies").addClass("displaynone");},changeModeration:function(b){var a=this.overlay.get("contentBox").query(".c-moderate");a.set("innerHTML",gettext(b.state));a.removeClass("c-state-approved");a.removeClass("c-state-pending");a.removeClass("c-state-unapproved");a.addClass("c-state-"+b.state);this.overlay.get("contentBox").query(".c-iactions").removeClass("displaynone");this.overlay.get("contentBox").query(".c-state-actions").addClass("displaynone");},isfetched:function(){return(this.commentId!=null);},unfetch:function(){this.commentId=null;},fetch:function(h){this.commentId=h.id;var b=this.overlay.get("boundingBox");if(h.start_wrapper!=-1){b.addClass("c-has-scope");b.removeClass("c-has-no-scope");}else{b.addClass("c-has-no-scope");b.removeClass("c-has-scope");}if(h.reply_to_id!=null){b.addClass("c-is-reply");}else{b.removeClass("c-is-reply");}var f=interpolate(gettext("last modified on %(date)s"),{date:h.modified_user_str},true);var k=(h.modified==h.created)?"":' * ';var i=gettext("Permalink to this comment");var n='¶ ';var j=interpolate(gettext("by %(name)s, created on %(date)s"),{name:h.name,date:h.created_user_str},true);var c='
    '+h.title+n+'
    '+j+"
    ";var d=CY.Node.create(c);var o=b.query(".c-header");if(o==null){b.query(".icomment-header").insertBefore(d,b.one(".c-iactions"));}else{o.get("parentNode").replaceChild(d,o);}var g=CY.Node.create('
    tags:'+h.tags+"
    ");var m=b.query(".c-tags");if(m==null){b.query(".icomment-header").appendChild(g);}else{m.get("parentNode").replaceChild(g,m);}if(h.tags==""){g.addClass("displaynone");}var e=CY.Node.create(''+h.content_html+"");var a=b.query(".c-content");if(a==null){b.query(".icomment-body").appendChild(e);}else{a.get("parentNode").replaceChild(e,a);}b.query(".c-permalink").set("href",sv_site_url+h.permalink);this.changeModeration(h);var l=b.queryAll(".c-content a");if(l!=null){l.setAttribute("target","_blank");}l=b.queryAll(".c-header-title a");if(l!=null){l.setAttribute("target","_blank");}this.permAdapt(h);},permAdapt:function(e){var b=this.overlay.get("contentBox").query(".c-delete");if(b){if(!e.can_delete){b.addClass("displaynone");}else{b.removeClass("displaynone");}}var a=this.overlay.get("contentBox").query(".c-edit");if(a){if(!e.can_edit){a.addClass("displaynone");}else{a.removeClass("displaynone");}}var d=this.overlay.get("contentBox").query(".c-reply");if(d){if(!hasPerm("can_create_comment")){d.addClass("displaynone");}else{d.removeClass("displaynone");}}var c=this.overlay.get("contentBox").query(".c-moderate");if(c){if(!e.can_moderate){c.addClass("displaynone");}else{c.removeClass("displaynone");}}},setThreadPad:function(a){this.overlay.get("contentBox").query(".yui-widget-hd").setStyle("paddingLeft",a+"px");this.overlay.get("contentBox").query(".yui-widget-bd").setStyle("paddingLeft",a+"px");},setPosition:function(b){var a=this.overlay.get("boundingBox");a.setStyle("opacity",1);a.setXY(b);},getPosition:function(b){var a=this.overlay.get("boundingBox");return a.getXY();},onAnimationEnd:function(){if(!CY.Lang.isUndefined(this["animation-handle"])&&!CY.Lang.isNull(this["animation-handle"])){this["animation-handle"].detach();this["animation-handle"]=null;}gIComments.signalAnimationEnd();if(gIComments.animationsEnded()){gIComments.whenAnimationsEnd();}},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("ask_for_notification" in g){if(g.ask_for_notification){parent.f_yesNoDialog(gettext("Do you want to be notified of all replies in all discussions you participated in?"),gettext("Reply notification"),function(){var m={method:"POST",data:urlEncode({fun:"ownNotify",key:sv_key,version_key:sv_version_key,email:g.email,active:false})};CY.io(sv_client_url,m);},this,null,function(){var m={method:"POST",data:urlEncode({fun:"ownNotify",key:sv_key,version_key:sv_version_key,email:g.email,active:true})};CY.io(sv_client_url,m);},this,null);}}if("comment" in g){var f=g.comment;gDb.upd(f);var a=gLayout.isInFrame()&&!parent.f_isFrameFilterFieldsInit();if(a){parent.resetFilter();}else{if(f.reply_to_id==null){unpaintCommentScope(f);paintCommentScope(f);}}var j=g.filterData;if(gLayout.isInFrame()){parent.f_updateFilterData(j);updateResetFilterResultsCount();}if(b()){if(!a){this._insertReply(f);}}else{this._showSingleComment(f);}}else{this._animateToTop();}}}else{this._q.add({id:"expl",fn:function(){CY.log("in example .........");}});this._q.promote("expl");}this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this.resume();},example:function(){CY.log("in example .........");},moderateComment:function(a,b){var c=gDb.getComment(a.commentId);this._q.add({fn:CY.bind(this.setPreventClickOn,this)},{autoContinue:false,fn:CY.bind(doExchange,null,"editComment",{comment_key:c.key,state:b},null,this.moderateCommentRet,this,{iComment:a},gettext("could not save comment"))}).run();},_saveComment:function(b,a){this._q.add({fn:CY.bind(this.setPreventClickOn,this)},{autoContinue:false,fn:CY.bind(doExchange,null,b,{},a,this.saveCommentRet,this,{formId:a},gettext("could not save comment"))}).run();},editComment:function(){this._saveComment("editComment",gEdit.ids["formId"]);},saveComment:function(a){this._saveComment("addComment",a);},removeComment:function(a){checkForOpenedDialog(a,function(){if(gLayout.isInFrame()){parent.f_yesNoDialog(gettext("Are you sure you want to delete this comment?"),gettext("Warning"),function(){this.animateToTop();},this,null,function(){var b=gDb.getComment(a.commentId);this._q.add({fn:CY.bind(this.setPreventClickOn,this)},{autoContinue:false,fn:CY.bind(doExchange,null,"removeComment",{comment_key:b.key},null,this.removeCommentRet,this,{iComment:a},gettext("could not remove comment"))}).run();},this,null);}},this,null);},resume:function(b,a){this._q.run();},resetAutoContinue:function(a){this._q.getCallback(a).autoContinue=true;},hideICommentForm:function(a){this._q.add({autoContinue:false,fn:CY.bind(gICommentForm.animationHide.run,gICommentForm.animationHide)});if(a){this._q.add(a);}},showCommentForm:function(a){checkForOpenedDialog(null,function(){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this._q.add({fn:function(){if(a==null){var b=getSelectionInfo();updateICommentFormSelection(b);}showICommentForm(a);}});this._q.add({autoContinue:false,fn:CY.bind(gICommentForm.animationShow.run,gICommentForm.animationShow)},{fn:CY.bind(this.setPreventClickOff,this)}).run();},this,null);},showEditForm:function(a){checkForOpenedDialog(null,function(){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this._q.add({fn:function(){showEditForm(a);}});this._animateToTop();this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},this,null);},showReplyForm:function(a){checkForOpenedDialog(null,function(){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this._q.add({fn:function(){instanciateNewReplyForm(a);}});this._animateToTop();this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},this,null);},cancelICommentForm:function(){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this.hideICommentForm();this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},cancelEdit:function(){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this._q.add({fn:function(){cancelEditForm();}});this._animateToTop();this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},cancelReply:function(){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this._q.add({fn:function(){cancelNewReplyForm();}});this._animateToTop();this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},changeScopeFormClick:function(){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this._q.add({fn:function(){changeScopeFormClick();}});this._animateToTop();this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},_hideNewReplyForm:function(){this._q.add({fn:function(){cleanNewReplyForm();cancelNewReplyForm();}});},_hideEditForm:function(){this._q.add({fn:function(){cancelEditForm();}});},_insertReply:function(a){this._q.add({fn:function(){var g=gDb.getComment(a.reply_to_id);var e=gDb.getThreads([g]);var c=e[e.length-2];var d=gIComments.insertAfter(c,a);var h=gIComments.getPosition(a.reply_to_id);d.setPosition(h);var b=gDb.getPath(a);var f=b[b.length-1];if(gIComments.isTopActive(f.id)){d.activate();}d.show();}});this._animateToTop();},_showSingleComment:function(d){if(d!=null){var c=gDb.getPath(d);var b=c[c.length-1];var a=0;if(d.start_wrapper!=-1){a=CY.get(".c-id-"+b.id).getY();}else{a=CY.get("document").get("scrollTop");}this._showComments([b.id],a,false);if(b.replies.length>0){this._animateTo(a);}}},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,b,a){this._q.add({fn:function(){gShowingAllComments=a;gIComments.hide();var d=CY.Array.map(c,function(g){return gDb.getComment(g);});var f=gDb.getThreads(d);gIComments.fetch(f);if(c.length>0){if(a){CY.get("document").set("scrollTop",0);}else{gIComments.activate(c[0]);var e=CY.get(".c-id-"+c[0]);if(e&&!e.inViewportRegion()){e.scrollIntoView(true);}}}gIComments.setPosition([gConf.iCommentLeftPadding,b]);gIComments.show();}});},_animateTo:function(a){this._q.add({fn:function(){gIComments.setAnimationToPositions(a);}},{id:"animationRun",autoContinue:false,fn:CY.bind(gIComments.runAnimations,gIComments)});},_animateToTop:function(){var a=gIComments.getTopPosition();if(a!=null){this._animateTo(a[1]);}},animateToTop:function(){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this._animateToTop();this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},showAllComments:function(){checkForOpenedDialog(null,function(){gShowingAllComments=true;var a=CY.Array.map(gDb.comments,function(b){return b.id;});this.showComments(a,[0,0],true);},this,null);},showScopeRemovedComments:function(){checkForOpenedDialog(null,function(){gShowingAllComments=true;var b=CY.Array.filter(gDb.comments,function(c){return(c.start_wrapper==-1);});var a=CY.Array.map(b,function(d){return d.id;});this.showComments(a,[0,0],true);},this,null);},showComments:function(c,b,a){checkForOpenedDialog(null,function(){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this._showComments(c,b[1],a);this._animateTo(b[1]);this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},this,null);},openComment:function(a){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});var b=gIComments.getTopPosition()[1];this._q.add({fn:function(){gIComments.open(a.commentId);gIComments.refresh(a.commentId);}});this._animateTo(b);this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},closeComment:function(a){checkForOpenedDialog(a,function(){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});var b=gIComments.getTopPosition()[1];this._q.add({fn:function(){var c=gDb.getComment(a.commentId);gIComments.close(a.commentId);if(c.reply_to_id!=null){gIComments.refresh(c.reply_to_id);}}});this._animateTo(b);this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},this,null);},activate:function(a){gIComments.activate(a.commentId);}};readyForAction=function(){return !gSync._iPreventClick;};paintCommentScope=function(b){if(b.reply_to_id==null&&b.start_wrapper!=-1){var a={start:{elt:document.getElementById("sv_"+b.start_wrapper),offset:b.start_offset},end:{elt:document.getElementById("sv_"+b.end_wrapper),offset:b.end_offset}};if(document.getElementById("sv_"+b.start_wrapper)==null){warn_server({from:"paintCommentScope",start_wrapper:b.start_wrapper});}else{if(document.getElementById("sv_"+b.end_wrapper)==null){warn_server({from:"paintCommentScope",end_wrapper:b.end_wrapper});}else{a.start=_convertSelectionFromCSToCC(a.start);a.end=_convertSelectionFromCSToCC(a.end);renderComment(a,b.id);}}}};getCommentIdsFromClasses=function(b){var a=[];var e=b.className.split(" ");for(var d=0,c=e.length;d=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();h0){checkForOpenedDialog(null,function(){gSync.showComments(a,[f.pageX,f.pageY],false);});}}}}};gLastScrollTime=null;checkForAlignement=function(){var a=(new Date()).getTime();if((gLastScrollTime!=null)&&(a-gLastScrollTime)>200){positionICommentForm();gLastScrollTime=null;}};onFrameScroll=function(){gLastScrollTime=(new Date()).getTime();};browse=function(a,b){gSync.browse(a,b);};initialConnect=function(){CY.on("mouseup",onTextMouseUp,"#textcontainer");gTimer=CY.Lang.later(200,this,checkForAlignement,[],true);CY.on("scroll",onFrameScroll,window,this,true);CY.on("resize",onFrameScroll,window,this,true);};preventLinksInText=function(){var a=function(g){var c=g.target;var d=null;while(c!=null&&d==null){c=c.get("parentNode");d=c.get("href");}if(c!=null&&d!=null){var b=window.location.href;var f=b.indexOf("#");if(f!=-1){b=b.substring(0,f);}if(d.indexOf(b)==-1){window.open(c.get("href"));g.preventDefault();}}};CY.all("#textcontainer a").on("click",a);};onDomReady=function(b){preventLinksInText();var a=new CY.AsyncQueue();a.add({fn:function(){if(gLayout.isInComentSite()){parent.toInitialSize();}if(sv_withComments){instanciateICommentForm();}},timeout:5},{fn:function(){gGETValues=CY.JSON.parse(sv_get_params);CY.get("#maincontainer").setStyle("display","block");CY.get("#textcontainer").setStyle("display","block");var e=(sv_withComments)?gPrefs.get("layout","comments_col_width"):0;var d=sliderValToPx(e);gLayout.setLeftColumnWidth(d);if(gLayout.isInFrame()){parent.f_initFrame();parent.f_layoutFrames();if(sv_withComments){parent.f_fillTopToolbar();if(hasPerm("can_create_comment")){parent.$("#add_comment_btn").removeClass("initially_hidden");}parent.f_fillFilterTab();parent.f_fillPreferencesTab();var c=CY.JSON.parse(sv_filter_data);parent.f_updateFilterData(c);parent.f_setFilterValue(gGETValues);}parent.f_fillTextPreferencesTab();}if(gLayout.isInComentSite()){parent.$("#c_fullscreen_btn").show();}else{parent.$("#c_fullscreen_btn").hide();}},timeout:5},{fn:function(){if(sv_withComments){reinit(gGETValues);initialConnect();}},timeout:5},{fn:function(){if(gLayout.isInFrame()){parent.f_interfaceUnfreeze();parent.f_removeLoadingMsg();}if("comment_id_key" in gGETValues){var d=gGETValues.comment_id_key;var f=gDb.getCommentByIdKey(d);if(f!=null){var e=gDb.getPath(f);var c=e[e.length-1];gSync.showSingleComment(c);}}}});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);}}; \ No newline at end of file +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='
    '+gettext("New reply")+"
    ";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().lengthv.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:'
    ',nameInput:gettext("Username:")+'
    ',emailInput:gettext("E-mail address:")+'
    ',titleInput:gettext("Title:")+'
    ',contentInput:gettext("Content:")+'
    ',tagsInput:gettext("Tag:")+'
    ',hidden:'',formEnd:"
    ",changeScope:'
    '+gettext("Modify comment's scope:")+'
    ',headerTitle:'
    ',currentSel:'
    '+gettext("Comment will apply to this selection:")+'
    '+gNoSelectionYet+"
    #hiddeninput#
    ",btns:'
    ',closeIcon:'      '};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="
    "+gFormHtml.hidden.replace("###",f.selectionPlaceId).replace("???","selection_place")+"
    ";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";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().lengthN.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:'
    ',nameInput:gettext("Username:")+'
    ',emailInput:gettext("E-mail address:")+'
    ',titleInput:gettext("Title:")+'
    ',contentInput:gettext("Content:")+'
    ',tagsInput:gettext("Tag:")+'
    ',hidden:'',formEnd:"
    ",changeScope:'
    '+gettext("Modify comment's scope:")+'
    ',headerTitle:'
    ',currentSel:'
    '+gettext("Comment will apply to this selection:")+'
    '+gNoSelectionYet+"
    #hiddeninput#
    ",btns:'
    ',closeIcon:'      '};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="
    "+gFormHtml.hidden.replace("###",i.selectionPlaceId).replace("???","selection_place")+"
    ";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;eb){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+"
  • "+b+"
  • ";};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;de[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(cm[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;k0){a=a.concat(this.getThreads(c[b].replies));}}return a;},_getPath:function(b,e){var a=[e];var d=e;while(d.reply_to_id!=null){d=b[d.reply_to_id];a.push(d);}return a;},getPath:function(a){return this._getPath(this.commentsByDbId,a);},getComment:function(a){return this.commentsByDbId[a];},getCommentByIdKey:function(a){for(var c in this.commentsByDbId){var b=this.commentsByDbId[c];if(b.id_key==a){return b;}}return null;},isChild:function(d,b){var c=this.commentsByDbId[d];var a=(d==b);while((!a)&&(c.reply_to_id!=null)){c=this.commentsByDbId[c.reply_to_id];a=(c.id==b);}return a;},initToReadOnly:function(f,c){for(var b=0,a=this.allComments.length;b0){var g=-1;if((f=="prev")||(f=="next")){for(var e=0;e=0)&&(ea.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;yc){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;c0){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=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='
    '+c.headerContent+"
    ";var e='
    '+c.bodyContent+"
    ";gEditICommentHost.overlay.setStdModContent(CY.WidgetStdMod.HEADER,CY.Node.create(b),CY.WidgetStdMod.AFTER);gEditICommentHost.overlay.setStdModContent(CY.WidgetStdMod.BODY,CY.Node.create(e),CY.WidgetStdMod.AFTER);CY.get("#"+gEdit.ids["formTitleId"]).set("innerHTML",gettext("Edit comment"));var f=gDb.getComment(gEditICommentHost.commentId);CY.get("#"+gEdit.ids["editCommentId"]).set("value",f.id);CY.get("#"+gEdit.ids["keyId"]).set("value",f.key);CY.get("#"+gEdit.ids["changeScopeInputId"]+" input").set("checked",false);if(f.reply_to_id!=null){CY.get("#"+gEdit.ids["changeScopeInputId"]).addClass("displaynone");}changeScopeFormClick();CY.get("#"+gEdit.ids["nameInputId"]).set("value",f.name);CY.get("#"+gEdit.ids["emailInputId"]).set("value",f.email);if(f.logged_author){CY.get("#"+gEdit.ids["nameInputId"]).setAttribute("disabled",true);CY.get("#"+gEdit.ids["emailInputId"]).setAttribute("disabled",true);}CY.get("#"+gEdit.ids["titleInputId"]).set("value",f.title);CY.get("#"+gEdit.ids["contentInputId"]).set("value",f.content);CY.get("#"+gEdit.ids["tagsInputId"]).set("value",f.tags);CY.get("#"+gEdit.ids["formatInputId"]).set("value",gConf.defaultCommentFormat);var d=gLayout.getTopICommentsWidth();changeFormFieldsWidth(gEdit.ids["formId"],d);gEdit.handlers["addBtnId"]=CY.on("click",onEditSaveClick,"#"+gEdit.ids["addBtnId"]);gEdit.handlers["cancelBtnId"]=CY.on("click",onEditCancelClick,"#"+gEdit.ids["cancelBtnId"]);gEdit.handlers["changeScope"]=CY.on("click",onChangeScopeClick,"#"+gEdit.ids["changeScopeInputId"]);};onEditSaveClick=function(a){if(readyForAction()){gSync.editComment();}};onEditCancelClick=function(a){if(readyForAction()){gSync.cancelEdit();}};onChangeScopeClick=function(){if(readyForAction()){gSync.changeScopeFormClick();}else{var a=CY.get("#"+gEdit.ids["changeScopeInputId"]+" input");var b=a.get("checked");a.set("checked",!b);}};changeScopeFormClick=function(){var a=CY.get("#"+gEdit.ids["currentSelId"]);if(CY.get("#"+gEdit.ids["changeScopeInputId"]+" input").get("checked")){a.removeClass("displaynone");}else{a.addClass("displaynone");}};cancelEditForm=function(){if(gEditICommentHost!=null){for(var b in gEdit.handlers){if(gEdit.handlers[b]!=null){gEdit.handlers[b].detach();gEdit.handlers[b]=null;}}var a=gEditICommentHost.overlay.get("contentBox").query(".icomment-edit-body");a.get("parentNode").removeChild(a);a=gEditICommentHost.overlay.get("contentBox").query(".icomment-edit-header");a.get("parentNode").removeChild(a);gEditICommentHost.showContent();gEditICommentHost=null;}};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
    '+t+'
    -X',bodyContent:'"});this.overlay.get("contentBox").addClass("c-comment");this.overlay.render("#leftcolumn");this.animation=new CY.Anim({node:this.overlay.get("boundingBox"),duration:gPrefs.get("general","animduration"),easing:CY.Easing.easeOut});this.overlay.get("contentBox").query(".c-close").on("click",this.onCloseCommentClick,this);this.overlay.get("contentBox").query(".c-moderate").on("click",this.onModerateCommentClick,this);this.overlay.get("contentBox").query(".c-state-pending").on("click",this.onPendingCommentClick,this);this.overlay.get("contentBox").query(".c-state-approved").on("click",this.onApprovedCommentClick,this);this.overlay.get("contentBox").query(".c-state-unapproved").on("click",this.onUnapprovedCommentClick,this);this.overlay.get("contentBox").query(".c-state-cancel").on("click",this.onCancelStateChangeClick,this);this.overlay.get("contentBox").query(".c-edit").on("click",this.onEditCommentClick,this);this.overlay.get("contentBox").query(".c-delete").on("click",this.onDeleteCommentClick,this);this.overlay.get("contentBox").query(".c-reply").on("click",this.onReplyCommentClick,this);this.overlay.get("contentBox").query(".c-readreplies").on("click",this.onReadRepliesCommentClick,this);this.overlay.get("contentBox").query(".icomment-header").on("mouseenter",this.onMouseEnterHeader,this);this.overlay.get("contentBox").query(".icomment-header").on("mouseleave",this.onMouseLeaveHeader,this);this.overlay.get("contentBox").on("click",this.onCommentClick,this);};IComment.prototype={onCloseCommentClick:function(a){a.halt();if(readyForAction()&&this.isVisible()){gSync.closeComment(this);}},onModerateCommentClick:function(a){a.halt();if(readyForAction()&&this.isVisible()){this.overlay.get("contentBox").query(".c-iactions").addClass("displaynone");this.overlay.get("contentBox").query(".c-state-actions").removeClass("displaynone");}},onPendingCommentClick:function(a){a.halt();if(readyForAction()&&this.isVisible()){gSync.moderateComment(this,"pending");}},onApprovedCommentClick:function(a){a.halt();if(readyForAction()&&this.isVisible()){gSync.moderateComment(this,"approved");}},onUnapprovedCommentClick:function(a){a.halt();if(readyForAction()&&this.isVisible()){gSync.moderateComment(this,"unapproved");}},onCancelStateChangeClick:function(a){a.halt();if(readyForAction()&&this.isVisible()){this.overlay.get("contentBox").query(".c-iactions").removeClass("displaynone");this.overlay.get("contentBox").query(".c-state-actions").addClass("displaynone");}},onDeleteCommentClick:function(a){a.halt();if(readyForAction()&&this.isVisible()){gSync.removeComment(this);}},onEditCommentClick:function(a){a.halt();if(readyForAction()&&this.isVisible()){gSync.showEditForm(this);}},onReplyCommentClick:function(a){a.halt();if(readyForAction()&&this.isVisible()){gSync.showReplyForm(this);}},onReadRepliesCommentClick:function(a){a.halt();if(readyForAction()&&this.isVisible()){gSync.openComment(this);}},onCommentClick:function(d){if(readyForAction()&&this.isVisible()){if(d.target.get("target")=="_blank"){var b=d.target;var g=sv_site_url+sv_text_view_show_comment_url;if(b.get("href").indexOf(g)==0){var a=(new RegExp("comment_id_key=([^&]*)","g")).exec(b.get("href"));if(a!=null){var c=a[1];var f=gDb.getCommentByIdKey(c);if(f!=null){d.halt();if(!b.hasClass("c-permalink")){checkForOpenedDialog(null,function(){gSync.showSingleComment(f);});}}}}}else{if(gShowingAllComments){if(!this._isHostingAForm()){var f=gDb.getComment(this.commentId);checkForOpenedDialog(null,function(){if(f!=null){gSync.showSingleComment(f);}});}}else{gSync.activate(this);}}}},onMouseEnterHeader:function(){if(readyForAction()&&this.isVisible()){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");},deactivate:function(){this.overlay.get("boundingBox").removeClass("c-focus-comment");},hide:function(){if(gIComments.isTopActive(this.commentId)){if(!gIComments.activateVisibleNext()){gIComments.deactivate();}}if(this.isVisible()){this.overlay.hide();this.overlay.blur();}},hideContent:function(){this.overlay.get("contentBox").query(".icomment-header").addClass("displaynone");this.overlay.get("contentBox").query(".icomment-body").addClass("displaynone");},showContent:function(){this.overlay.get("contentBox").query(".icomment-header").removeClass("displaynone");this.overlay.get("contentBox").query(".icomment-body").removeClass("displaynone");},isVisible:function(){return this.overlay.get("visible");},show:function(){this.hideReadRepliesLnk();return this.overlay.show();},showReadRepliesLnk:function(){this.overlay.get("contentBox").query(".c-readreplies").removeClass("displaynone");},hideReadRepliesLnk:function(){this.overlay.get("contentBox").query(".c-readreplies").addClass("displaynone");},changeModeration:function(b){var a=this.overlay.get("contentBox").query(".c-moderate");a.set("innerHTML",gettext(b.state));a.removeClass("c-state-approved");a.removeClass("c-state-pending");a.removeClass("c-state-unapproved");a.addClass("c-state-"+b.state);this.overlay.get("contentBox").query(".c-iactions").removeClass("displaynone");this.overlay.get("contentBox").query(".c-state-actions").addClass("displaynone");},isfetched:function(){return(this.commentId!=null);},unfetch:function(){this.commentId=null;},fetch:function(h){this.commentId=h.id;var b=this.overlay.get("boundingBox");if(h.start_wrapper!=-1){b.addClass("c-has-scope");b.removeClass("c-has-no-scope");}else{b.addClass("c-has-no-scope");b.removeClass("c-has-scope");}if(h.reply_to_id!=null){b.addClass("c-is-reply");}else{b.removeClass("c-is-reply");}var f=interpolate(gettext("last modified on %(date)s"),{date:h.modified_user_str},true);var k=(h.modified==h.created)?"":' * ';var i=gettext("Permalink to this comment");var n='¶ ';var j=interpolate(gettext("by %(name)s, created on %(date)s"),{name:h.name,date:h.created_user_str},true);var c='
    '+h.title+n+'
    '+j+"
    ";var d=CY.Node.create(c);var o=b.query(".c-header");if(o==null){b.query(".icomment-header").insertBefore(d,b.one(".c-iactions"));}else{o.get("parentNode").replaceChild(d,o);}var g=CY.Node.create('
    tags:'+h.tags+"
    ");var m=b.query(".c-tags");if(m==null){b.query(".icomment-header").appendChild(g);}else{m.get("parentNode").replaceChild(g,m);}if(h.tags==""){g.addClass("displaynone");}var e=CY.Node.create(''+h.content_html+"");var a=b.query(".c-content");if(a==null){b.query(".icomment-body").appendChild(e);}else{a.get("parentNode").replaceChild(e,a);}b.query(".c-permalink").set("href",sv_site_url+h.permalink);this.changeModeration(h);var l=b.queryAll(".c-content a");if(l!=null){l.setAttribute("target","_blank");}l=b.queryAll(".c-header-title a");if(l!=null){l.setAttribute("target","_blank");}this.permAdapt(h);},permAdapt:function(e){var b=this.overlay.get("contentBox").query(".c-delete");if(b){if(!e.can_delete){b.addClass("displaynone");}else{b.removeClass("displaynone");}}var a=this.overlay.get("contentBox").query(".c-edit");if(a){if(!e.can_edit){a.addClass("displaynone");}else{a.removeClass("displaynone");}}var d=this.overlay.get("contentBox").query(".c-reply");if(d){if(!hasPerm("can_create_comment")){d.addClass("displaynone");}else{d.removeClass("displaynone");}}var c=this.overlay.get("contentBox").query(".c-moderate");if(c){if(!e.can_moderate){c.addClass("displaynone");}else{c.removeClass("displaynone");}}},setThreadPad:function(a){this.overlay.get("contentBox").query(".yui-widget-hd").setStyle("paddingLeft",a+"px");this.overlay.get("contentBox").query(".yui-widget-bd").setStyle("paddingLeft",a+"px");},setPosition:function(b){var a=this.overlay.get("boundingBox");a.setStyle("opacity",1);a.setXY(b);},getPosition:function(b){var a=this.overlay.get("boundingBox");return a.getXY();},onAnimationEnd:function(){if(!CY.Lang.isUndefined(this["animation-handle"])&&!CY.Lang.isNull(this["animation-handle"])){this["animation-handle"].detach();this["animation-handle"]=null;}gIComments.signalAnimationEnd();if(gIComments.animationsEnded()){gIComments.whenAnimationsEnd();}},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;},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("ask_for_notification" in g){if(g.ask_for_notification){parent.f_yesNoDialog(gettext("Do you want to be notified of all replies in all discussions you participated in?"),gettext("Reply notification"),function(){var m={method:"POST",data:urlEncode({fun:"ownNotify",key:sv_key,version_key:sv_version_key,email:g.email,active:false})};CY.io(sv_client_url,m);},this,null,function(){var m={method:"POST",data:urlEncode({fun:"ownNotify",key:sv_key,version_key:sv_version_key,email:g.email,active:true})};CY.io(sv_client_url,m);},this,null);}}if("comment" in g){var f=g.comment;gDb.upd(f);var a=gLayout.isInFrame()&&!parent.f_isFrameFilterFieldsInit();if(a){parent.resetFilter();}else{if(f.reply_to_id==null){unpaintCommentScope(f);paintCommentScope(f);}}var j=g.filterData;if(gLayout.isInFrame()){parent.f_updateFilterData(j);updateResetFilterResultsCount();}if(b()){if(!a){this._insertReply(f);}}else{this._showSingleComment(f);}}else{this._animateToTop();}}}else{this._q.add({id:"expl",fn:function(){CY.log("in example .........");}});this._q.promote("expl");}this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this.resume();},example:function(){CY.log("in example .........");},moderateComment:function(a,b){var c=gDb.getComment(a.commentId);this._q.add({fn:CY.bind(this.setPreventClickOn,this)},{autoContinue:false,fn:CY.bind(doExchange,null,"editComment",{comment_key:c.key,state:b},null,this.moderateCommentRet,this,{iComment:a},gettext("could not save comment"))}).run();},_saveComment:function(b,a){this._q.add({fn:CY.bind(this.setPreventClickOn,this)},{autoContinue:false,fn:CY.bind(doExchange,null,b,{},a,this.saveCommentRet,this,{formId:a},gettext("could not save comment"))}).run();},editComment:function(){this._saveComment("editComment",gEdit.ids["formId"]);},saveComment:function(a){this._saveComment("addComment",a);},removeComment:function(a){checkForOpenedDialog(a,function(){if(gLayout.isInFrame()){parent.f_yesNoDialog(gettext("Are you sure you want to delete this comment?"),gettext("Warning"),function(){this.animateToTop();},this,null,function(){var b=gDb.getComment(a.commentId);this._q.add({fn:CY.bind(this.setPreventClickOn,this)},{autoContinue:false,fn:CY.bind(doExchange,null,"removeComment",{comment_key:b.key},null,this.removeCommentRet,this,{iComment:a},gettext("could not remove comment"))}).run();},this,null);}},this,null);},resume:function(b,a){this._q.run();},resetAutoContinue:function(a){this._q.getCallback(a).autoContinue=true;},hideICommentForm:function(a){this._q.add({autoContinue:false,fn:CY.bind(gICommentForm.animationHide.run,gICommentForm.animationHide)});if(a){this._q.add(a);}},showCommentForm:function(a){checkForOpenedDialog(null,function(){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this._q.add({fn:function(){if(a==null){var b=getSelectionInfo();updateICommentFormSelection(b);}showICommentForm(a);}});this._q.add({autoContinue:false,fn:CY.bind(gICommentForm.animationShow.run,gICommentForm.animationShow)},{fn:CY.bind(this.setPreventClickOff,this)}).run();},this,null);},showEditForm:function(a){checkForOpenedDialog(null,function(){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this._q.add({fn:function(){showEditForm(a);}});this._animateToTop();this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},this,null);},showReplyForm:function(a){checkForOpenedDialog(null,function(){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this._q.add({fn:function(){instanciateNewReplyForm(a);}});this._animateToTop();this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},this,null);},cancelICommentForm:function(){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this.hideICommentForm();this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},cancelEdit:function(){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this._q.add({fn:function(){cancelEditForm();}});this._animateToTop();this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},cancelReply:function(){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this._q.add({fn:function(){cancelNewReplyForm();}});this._animateToTop();this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},changeScopeFormClick:function(){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this._q.add({fn:function(){changeScopeFormClick();}});this._animateToTop();this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},_hideNewReplyForm:function(){this._q.add({fn:function(){cleanNewReplyForm();cancelNewReplyForm();}});},_hideEditForm:function(){this._q.add({fn:function(){cancelEditForm();}});},_insertReply:function(a){this._q.add({fn:function(){var g=gDb.getComment(a.reply_to_id);var e=gDb.getThreads([g]);var c=e[e.length-2];var d=gIComments.insertAfter(c,a);var h=gIComments.getPosition(a.reply_to_id);d.setPosition(h);var b=gDb.getPath(a);var f=b[b.length-1];if(gIComments.isTopActive(f.id)){d.activate();}d.show();}});this._animateToTop();},_showSingleComment:function(d){if(d!=null){var c=gDb.getPath(d);var b=c[c.length-1];var a=0;if(d.start_wrapper!=-1){a=CY.get(".c-id-"+b.id).getY();}else{a=CY.get("document").get("scrollTop");}this._showComments([b.id],a,false);if(b.replies.length>0){this._animateTo(a);}}},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,b,a){this._q.add({fn:function(){gShowingAllComments=a;gIComments.hide();var d=CY.Array.map(c,function(g){return gDb.getComment(g);});var f=gDb.getThreads(d);gIComments.fetch(f);if(c.length>0){if(a){CY.get("document").set("scrollTop",0);}else{gIComments.activate(c[0]);var e=CY.get(".c-id-"+c[0]);if(e&&!e.inViewportRegion()){e.scrollIntoView(true);}}}gIComments.setPosition([gConf.iCommentLeftPadding,b]);gIComments.show();}});},_animateTo:function(a){this._q.add({fn:function(){gIComments.setAnimationToPositions(a);}},{id:"animationRun",autoContinue:false,fn:CY.bind(gIComments.runAnimations,gIComments)});},_animateToTop:function(){var a=gIComments.getTopPosition();if(a!=null){this._animateTo(a[1]);}},animateToTop:function(){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this._animateToTop();this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},showAllComments:function(){checkForOpenedDialog(null,function(){gShowingAllComments=true;var a=CY.Array.map(gDb.comments,function(b){return b.id;});this.showComments(a,[0,0],true);},this,null);},showScopeRemovedComments:function(){checkForOpenedDialog(null,function(){gShowingAllComments=true;var b=CY.Array.filter(gDb.comments,function(c){return(c.start_wrapper==-1);});var a=CY.Array.map(b,function(d){return d.id;});this.showComments(a,[0,0],true);},this,null);},showComments:function(c,b,a){checkForOpenedDialog(null,function(){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this._showComments(c,b[1],a);this._animateTo(b[1]);this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},this,null);},openComment:function(a){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});var b=gIComments.getTopPosition()[1];this._q.add({fn:function(){gIComments.open(a.commentId);gIComments.refresh(a.commentId);}});this._animateTo(b);this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},closeComment:function(a){checkForOpenedDialog(a,function(){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});var b=gIComments.getTopPosition()[1];this._q.add({fn:function(){var c=gDb.getComment(a.commentId);gIComments.close(a.commentId);if(c.reply_to_id!=null){gIComments.refresh(c.reply_to_id);}}});this._animateTo(b);this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},this,null);},activate:function(a){gIComments.activate(a.commentId);}};readyForAction=function(){return !gSync._iPreventClick;};paintCommentScope=function(b){if(b.reply_to_id==null&&b.start_wrapper!=-1){var a={start:{elt:document.getElementById("sv_"+b.start_wrapper),offset:b.start_offset},end:{elt:document.getElementById("sv_"+b.end_wrapper),offset:b.end_offset}};if(document.getElementById("sv_"+b.start_wrapper)==null){warn_server({from:"paintCommentScope",start_wrapper:b.start_wrapper});}else{if(document.getElementById("sv_"+b.end_wrapper)==null){warn_server({from:"paintCommentScope",end_wrapper:b.end_wrapper});}else{a.start=_convertSelectionFromCSToCC(a.start);a.end=_convertSelectionFromCSToCC(a.end);renderComment(a,b.id);}}}};getCommentIdsFromClasses=function(b){var a=[];var e=b.className.split(" ");for(var d=0,c=e.length;d=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();h0){checkForOpenedDialog(null,function(){gSync.showComments(a,[f.pageX,f.pageY],false);});}}}}};gLastScrollTime=null;checkForAlignement=function(){var a=(new Date()).getTime();if((gLastScrollTime!=null)&&(a-gLastScrollTime)>200){positionICommentForm();gLastScrollTime=null;}};onFrameScroll=function(){gLastScrollTime=(new Date()).getTime();};browse=function(a,b){gSync.browse(a,b);};initialConnect=function(){CY.on("mouseup",onTextMouseUp,"#textcontainer");gTimer=CY.Lang.later(200,this,checkForAlignement,[],true);CY.on("scroll",onFrameScroll,window,this,true);CY.on("resize",onFrameScroll,window,this,true);};preventLinksInText=function(){var a=function(g){var c=g.target;var d=null;while(c!=null&&d==null){c=c.get("parentNode");d=c.get("href");}if(c!=null&&d!=null){var b=window.location.href;var f=b.indexOf("#");if(f!=-1){b=b.substring(0,f);}if(d.indexOf(b)==-1){window.open(c.get("href"));g.preventDefault();}}};CY.all("#textcontainer a").on("click",a);};onDomReady=function(b){preventLinksInText();var a=new CY.AsyncQueue();a.add({fn:function(){if(gLayout.isInComentSite()){parent.toInitialSize();}if(sv_withComments){instanciateICommentForm();}},timeout:5},{fn:function(){gGETValues=CY.JSON.parse(sv_get_params);CY.get("#maincontainer").setStyle("display","block");CY.get("#textcontainer").setStyle("display","block");var e=(sv_withComments)?gPrefs.get("layout","comments_col_width"):0;var d=sliderValToPx(e);gLayout.setLeftColumnWidth(d);if(gLayout.isInFrame()){parent.f_initFrame();parent.f_layoutFrames();if(sv_withComments){parent.f_fillTopToolbar();if(hasPerm("can_create_comment")){parent.$("#add_comment_btn").removeClass("initially_hidden");}parent.f_fillFilterTab();parent.f_fillPreferencesTab();var c=CY.JSON.parse(sv_filter_data);parent.f_updateFilterData(c);parent.f_setFilterValue(gGETValues);}parent.f_fillTextPreferencesTab();}if(gLayout.isInComentSite()){parent.$("#c_fullscreen_btn").show();}else{parent.$("#c_fullscreen_btn").hide();}},timeout:5},{fn:function(){if(sv_withComments){reinit(gGETValues);initialConnect();}},timeout:5},{fn:function(){if(gLayout.isInFrame()){parent.f_interfaceUnfreeze();parent.f_removeLoadingMsg();}if("comment_id_key" in gGETValues){var d=gGETValues.comment_id_key;var f=gDb.getCommentByIdKey(d);if(f!=null){var e=gDb.getPath(f);var c=e[e.length-1];gSync.showSingleComment(c);}}}});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);}}; \ No newline at end of file diff -r dfc53876028c -r cc85d241b81d src/cm/media/js/client/c_icomment.js --- a/src/cm/media/js/client/c_icomment.js Mon Mar 22 11:00:34 2010 +0100 +++ b/src/cm/media/js/client/c_icomment.js Mon Mar 22 11:02:39 2010 +0100 @@ -434,12 +434,6 @@ return this.animation ; }, - setWidth : function(width) { - var boundingBoxNode = this.overlay.get('boundingBox') ; - - // POSITION - boundingBoxNode.setStyle("width", width + 'px'); - }, getHeight : function() { return this.overlay.get('boundingBox').get('offsetHeight') ; }, diff -r dfc53876028c -r cc85d241b81d src/cm/media/js/client/c_icomments.js --- a/src/cm/media/js/client/c_icomments.js Mon Mar 22 11:00:34 2010 +0100 +++ b/src/cm/media/js/client/c_icomments.js Mon Mar 22 11:02:39 2010 +0100 @@ -152,7 +152,7 @@ setAnimationToPositions : function (y) { this._initAnimations(); //CY.log(gPrefs.get('comments','threadpad')) ; - var lpad = (gPrefs.get('comments','threadpad') == '1') ? 15 : 0 ; // gIThreadPad ... TODO 'configurize' + var lpad = (gPrefs.get('comments','threadpad') == '1') ? gConf['iCommentThreadPadding'] : 0 ; // gIThreadPad ... TODO 'configurize' var nextY = y ; for (var i = 0 ; i < this._c.length;i++) { diff -r dfc53876028c -r cc85d241b81d src/cm/media/js/client/c_layout.js --- a/src/cm/media/js/client/c_layout.js Mon Mar 22 11:00:34 2010 +0100 +++ b/src/cm/media/js/client/c_layout.js Mon Mar 22 11:02:39 2010 +0100 @@ -45,7 +45,8 @@ }, getTopICommentsWidthFromWidth : function(val) { - return val - 7; + var ret = val - ( 2 * gConf['iCommentThreadPadding']) ; // PhA said : a threaded discussion with a depth of 2 still shoudn't hide the text 20100317 + return ret - 7; }, setLeftColumnWidth : function (colWidth) { diff -r dfc53876028c -r cc85d241b81d src/cm/media/js/site/c_text_view_comments.js --- a/src/cm/media/js/site/c_text_view_comments.js Mon Mar 22 11:00:34 2010 +0100 +++ b/src/cm/media/js/site/c_text_view_comments.js Mon Mar 22 11:02:39 2010 +0100 @@ -7,6 +7,7 @@ gGETValues = null; gConf = {'iCommentLeftPadding':4, + 'iCommentThreadPadding':12, 'defaultCommentFormat':'markdown', 'sliderFixedMin':.9, 'sliderFixedMax':.1, diff -r dfc53876028c -r cc85d241b81d src/cm/templates/site/text_view_comments.html --- a/src/cm/templates/site/text_view_comments.html Mon Mar 22 11:00:34 2010 +0100 +++ b/src/cm/templates/site/text_view_comments.html Mon Mar 22 11:02:39 2010 +0100 @@ -106,7 +106,7 @@ {% else %} - + {% endif %} diff -r dfc53876028c -r cc85d241b81d src/cm/templates/site/text_view_frame.html --- a/src/cm/templates/site/text_view_frame.html Mon Mar 22 11:00:34 2010 +0100 +++ b/src/cm/templates/site/text_view_frame.html Mon Mar 22 11:02:39 2010 +0100 @@ -36,7 +36,7 @@ {% else %} - + {% endif %}