'+gettext("Comment will apply to this selection:")+'
'+gNoSelectionYet+"
#hiddeninput#
",btns:'
',closeIcon:''};getHtml=function(g){ret={};ret.headerContent="";if("closeBtnId" in g){ret.headerContent+=gFormHtml.closeIcon.replace("###",g.closeBtnId);}ret.headerContent+=gFormHtml.headerTitle.replace("###",g.formTitleId);var b="";if("changeScopeInputId" in g){b=gFormHtml.changeScope.replace("###",g.changeScopeInputId);}var f="
";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");if(CY.get("#"+gEdit.ids["categoryInputId"])){CY.get("#"+gEdit.ids["categoryInputId"]).addClass("displaynone");CY.get("#"+gEdit.ids["categoryInputId"]).ancestor().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);if(CY.get("#"+gEdit.ids["categoryInputId"])){CY.get("#"+gEdit.ids["categoryInputId"]).set("value",f.category);}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;}};IComment=function(){this.commentId=null;var l=gLayout.getTopICommentsWidth();var a=gConf.iCommentLeftPadding;var r=gettext("change comment state to pending");var n=gettext("change comment state to approved");var e=gettext("change comment state to unapproved");var q=gettext("cancel changing the state of this comment");var c=gettext("pending");var d=gettext("approved");var m=gettext("unapproved");var b=gettext("cancel");var p=gettext("show replies");var s=gettext("change to:");var i=ngettext("reply","replies",1);var g=gettext("edit comment");var j=gettext("delete comment");var o=gettext("edit");var f=gettext("delete");var k=gettext("close");var h=gettext("show scope");var t=gettext("Comment is detached: it was created on a previous version and text it applied to has been modified or removed.");this.overlay=new CY.Overlay({zIndex:3,shim:false,visible:false,width:l,xy:[a,0],headerContent:'
'+gettext("Comment will apply to this selection:")+'
'+gNoSelectionYet+"
#hiddeninput#
",btns:'
',closeIcon:''};getHtml=function(j){ret={};ret.headerContent="";if("closeBtnId" in j){ret.headerContent+=gFormHtml.closeIcon.replace("###",j.closeBtnId);}ret.headerContent+=gFormHtml.headerTitle.replace("###",j.formTitleId);var h="";if("changeScopeInputId" in j){h=gFormHtml.changeScope.replace("###",j.changeScopeInputId);}var k="
";var i=gFormHtml.currentSel.replace("###",j.currentSelId).replace("???",j.currentSelIdI).replace("#hiddeninput#",k);var l=gFormHtml.btns.replace("###",j.addBtnId).replace("???",j.cancelBtnId);var m=gFormHtml.formStart.replace("###",j.formId)+h+i;if("nameInputId" in j){m=m+gFormHtml.nameInput.replace("###",j.nameInputId);}if("emailInputId" in j){m=m+gFormHtml.emailInput.replace("###",j.emailInputId);}m=m+gFormHtml.titleInput.replace("###",j.titleInputId)+gFormHtml.contentInput.replace("###",j.contentInputId);categories=CY.JSON.parse(sv_categories);if(categories.hasOwnProperty("0")){category_options="";for(c in categories){category_options+='";}gFormHtml.categoryInput=gettext("Category:")+' ";m=m+''+gFormHtml.categoryInput.replace("###",j.categoryInputId)+" ";}m=m+gFormHtml.tagsInput.replace("###",j.tagsInputId);m=m+gFormHtml.hidden.replace("###",j.formatInputId).replace("???","format");m=m+gFormHtml.hidden.replace("###",j.startWrapperInputId).replace("???","start_wrapper");m=m+gFormHtml.hidden.replace("###",j.endWrapperInputId).replace("???","end_wrapper");m=m+gFormHtml.hidden.replace("###",j.startOffsetInputId).replace("???","start_offset");m=m+gFormHtml.hidden.replace("###",j.endOffsetInputId).replace("???","end_offset");m=m+gFormHtml.hidden.replace("###",j.keyId).replace("???","comment_key");m=m+gFormHtml.hidden.replace("###",j.editCommentId).replace("???","edit_comment_id");m=m+l+gFormHtml.formEnd;ret.bodyContent=m;return ret;};changeFormFieldsWidth=function(h,i){var g=(i-20)+"px";var f=CY.all("#"+h+" input[type='text']");if(f!=null){f.setStyle("width",g);}f=CY.all("#"+h+" textarea");if(f!=null){f.setStyle("width",g);}};addFormErrMsg=function(l,n,p){var o=document.getElementById(l);var e,m,q,i;for(e=0,i=o.elements.length;e0){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;if(j.nodeName=="mi"||j.nodeName=="mo"){j=j.parentElement.parentElement.parentElement.parentElement;}innerStartNode=(K)?V.anchorNode:V.focusNode;ac=(K)?V.focusNode.parentNode:V.anchorNode.parentNode;if(ac.nodeName=="mi"||ac.nodeName=="mo"){ac=ac.parentElement.parentElement.parentElement.parentElement;}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}};};_afterDlg=function(g){var f=g[0];var h=g[1];var e=g[2];f.call(h,e);};_abortNewCommentConfirmed=function(b){if(isICommentFormVisible()){if(gLayout.isInFrame()){gSync.hideICommentForm({fn:function(){_afterDlg(b);}});gSync.resume();}}};_abortNewReplyConfirmed=function(b){if(gNewReplyHost!=null){if(gLayout.isInFrame()){cancelNewReplyForm();_afterDlg(b);}}};_abortNewEditConfirmed=function(b){if(gEditICommentHost!=null){if(gLayout.isInFrame()){cancelEditForm();_afterDlg(b);}}};checkForOpenedDialog=function(h,f,i,j){var g=[];if(h!=null){g=CY.Array.map(gDb.getThreads([gDb.getComment(h.commentId)]),function(a){return a.id;});}if(isICommentFormVisible()||(gNewReplyHost!=null&&(h==null||CY.Array.indexOf(g,gNewReplyHost.commentId)!=-1))||(gEditICommentHost!=null&&(h==null||CY.Array.indexOf(g,gEditICommentHost.commentId)!=-1))){if(gLayout.isInFrame()){if(isICommentFormVisible()){parent.f_yesNoDialog(gettext("New comment will be canceled, continue?"),gettext("Warning"),null,null,null,_abortNewCommentConfirmed,this,[f,i,j]);}else{if(gNewReplyHost!=null){parent.f_yesNoDialog(gettext("Started reply will be canceled, continue?"),gettext("Warning"),null,null,null,_abortNewReplyConfirmed,this,[f,i,j]);}else{if(gEditICommentHost!=null){parent.f_yesNoDialog(gettext("Started comment edition will be canceled, continue?"),gettext("Warning"),null,null,null,_abortNewEditConfirmed,this,[f,i,j]);}}}}}else{f.call(i,[]);}};paintCommentScope=function(d){if(d.reply_to_id==null&&d.start_wrapper!=-1){var e={start:{elt:document.getElementById("sv_"+d.start_wrapper),offset:d.start_offset},end:{elt:document.getElementById("sv_"+d.end_wrapper),offset:d.end_offset}};if(document.getElementById("sv_"+d.start_wrapper)==null){warn_server({from:"paintCommentScope",start_wrapper:d.start_wrapper});}else{if(document.getElementById("sv_"+d.end_wrapper)==null){warn_server({from:"paintCommentScope",end_wrapper:d.end_wrapper});}else{e.start=_convertSelectionFromCSToCC(e.start);e.end=_convertSelectionFromCSToCC(e.end);renderComment(e,d.id);}}}};getCommentIdsFromClasses=function(f){var g=[];var h=f.className.split(" ");for(var i=0,j=h.length;i=l){if(j.category){CY.DOM.addClass(k,"cat"+j.category);}}}}};_recAddComment=function(f,e){if(CY.DOM.hasClass(f,"c-c")){_addIdClass(f,e);}else{var g=f.firstChild;while(g!=null){_recAddComment(g,e);g=g.nextSibling;}}};_findCommonAncestor=function(f,e){if(_bruteContains(f,e)){return f;}else{var d=e;while((d!=null)&&!_bruteContains(d,f)){d=d.parentNode;}return d;}};_cregexCache={};_cgetRegExp=function(d,e){e=e||"";if(!_cregexCache[d+e]){_cregexCache[d+e]=new RegExp(d,e);}return _cregexCache[d+e];};_updateCommentCounter=function(e){var h=_cgetRegExp("(?:^|\\s+)c-id-(?:\\d+)","g");var g=e.className.match(h);var f=(g==null)?0:gDb.getThreads(CY.Array.map(g,function(a){return gDb.getComment(parseInt(a.replace(/\D/g,"")));})).length;h=_cgetRegExp("(?:^|\\s+)c-count-(?:\\d+)","g");e.className=e.className.replace(h," ");CY.DOM.addClass(e,"c-count-"+f+" ");if(f>0){e.setAttribute("title",f+ngettext(" comment"," comments",f));if(f>25){CY.DOM.addClass(e,"c-count-25");}}};_convertSelectionFromCCToCS=function(e){var g=e.offset;var f=e.elt.parentNode;var h=e.elt.previousSibling;while(h!=null){g+=_getTextNodeContent(h).length;h=h.previousSibling;}return{elt:f,offset:g};};_convertSelectionFromCSToCC=function(k){var h={elt:null,offset:-1};var i=null;var j=k.elt.firstChild;var l=0;while(j!=null){var g=l;l+=_getTextNodeContent(j).length;if(l>=k.offset){h.elt=j;h.offset=k.offset-g;break;}j=j.nextSibling;}return h;};unpaintCommentScope=function(w){var x=w.id;var i="c-id-"+x;var u=[];var F=CY.all("."+i);if(F!=null){for(var y=0,C=F.size();yj){j=g;}}return j;},_upd:function(i,k,j){var l=false;for(var m=0,h=i.length;m0){e=e.concat(this.getThreads(f[d].replies));}}return e;},_getPath:function(f,h){var g=[h];var i=h;while(i.reply_to_id!=null){i=f[i.reply_to_id];g.push(i);}return g;},getPath:function(b){return this._getPath(this.commentsByDbId,b);},getComment:function(b){return this.commentsByDbId[b];},getCommentByIdKey:function(e){for(var f in this.commentsByDbId){var d=this.commentsByDbId[f];if(d.id_key==e){return d;}}return null;},isChild:function(g,e){var h=this.commentsByDbId[g];var f=(g==e);while((!f)&&(h.reply_to_id!=null)){h=this.commentsByDbId[h.reply_to_id];f=(h.id==e);}return f;},initToReadOnly:function(i,l){for(var g=0,h=this.allComments.length;g0){var l=-1;if((m=="prev")||(m=="next")){for(var n=0;n=0)&&(nj.length){break;}}CY.error("internal error in db browse (could not find any filtered comment)");}return null;},computeFilterResults:function(T){var aj={};if(T){for(key in T){if(key.indexOf("filter_")==0){aj[key.substr("filter_".length)]=T[key];}}}else{if(gLayout.isInFrame()){aj=parent.f_getFrameFilterData();}}var G=[];var i=[];var ah="";if("name" in aj){ah=aj.name;}this.filterByName(ah,G,i);var O=[];var af=[];var L="";if("date" in aj){L=aj.date;}this.filterByDate(L,O,af);var aa=[];var ab=[];var I="";if("text" in aj){I=aj.text;}this.filterByText(I,aa,ab);var U=[];var V=[];var P="";if("tag" in aj){P=aj.tag;}this.filterByTag(P,U,V);var ai=[];var ad=[];var ag="";if("cat" in aj){ag=aj.cat;}this.filterByCat(ag,ai,ad);var H=[];var ac=[];var X="";if("state" in aj){X=aj.state;}this.filterByState(X,H,ac);var ae=[];var R=[];for(var S=0,Y=G.length;Sl){if(j.reply_to_id==null){k.push(j.id);}else{h.push(j.id);}}}},getCommentsAndRepliesCounts:function(k){var g=0;var i=0;var h=(k)?this.allComments:this.comments;var j=this.getThreads(h);for(var l=0;l0){this._animateTo();}}},_showFocusSingleComment:function(g,h,e){if(g!=null){var f=0;if(g.start_wrapper!=-1){f=CY.get(".c-id-"+g.id).getY();}else{f=CY.get(the_scrolling_part).get("scrollTop");}this._showComments([g.id],f,false);if(g.replies.length>0||e){this._animateToAndFocus(f,h.id,e);}}},showSingleComment:function(b){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this._showSingleComment(b);this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},showFocusSingleComment:function(f,d,e){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this._showFocusSingleComment(f,d,e);this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},browse:function(e,d){var f=gIComments.browse(e,d);if(f!=null){this.showSingleComment(f);}},_showComments:function(f,d,e){this._q.add({fn:function(){gShowingAllComments=e;gIComments.hide();hideToc();var g=CY.Array.map(f,function(h){return gDb.getComment(h);});var a=gDb.getThreads(g);gIComments.fetch(a);if(f.length>0){if(e){CY.get(the_scrolling_part).set("scrollTop",0);}else{gIComments.activate(f[0]);var b=CY.get(".c-id-"+f[0]);if(b&&!b.inViewportRegion()){b.scrollIntoView(true);if(parent){parent.document.getElementById("outer-north").scrollIntoView(true);}if(safari_mobile){d=add_comment_offset;}else{d+=add_comment_offset;}}}}gIComments.setPosition([gConf.iCommentLeftPadding,d]);gIComments.show();}});},_animateTo:function(b){this._q.add({fn:function(){gIComments.setAnimationToPositions(b);}},{id:"animationRun",autoContinue:false,fn:CY.bind(gIComments.runAnimations,gIComments)});},_animateToAndFocus:function(e,f,d){this._q.add({fn:function(){gIComments.setAnimationToPositionsAndFocus(e,f,d);}},{id:"animationRun",autoContinue:false,fn:CY.bind(gIComments.runAnimations,gIComments)});},_animateToTop:function(){var b=gIComments.getTopPosition();if(b!=null){this._animateTo(b[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 b=CY.Array.map(gDb.comments,function(a){return a.id;});if(parent.$("#browse_by").val()=="scope"){b.sort(function(a,e){if(gDb.ordered_comment_ids.scope.indexOf(a)gDb.ordered_comment_ids.scope.indexOf(e)){return 1;}return 0;});}this.showComments(b,[0,add_comment_offset],true);},this,null);},showScopeRemovedComments:function(){checkForOpenedDialog(null,function(){gShowingAllComments=true;var d=CY.Array.filter(gDb.comments,function(a){return(a.start_wrapper==-1);});var e=CY.Array.map(d,function(a){return a.id;});if(parent.$("#browse_by").val()=="scope"){e.sort(function(a,b){if(gDb.ordered_comment_ids.scope.indexOf(a)gDb.ordered_comment_ids.scope.indexOf(b)){return 1;}return 0;});}this.showComments(e,[0,add_comment_offset],true);},this,null);},showComments:function(f,d,e){checkForOpenedDialog(null,function(){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this._showComments(f,d[1],e);this._animateTo();this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},this,null);},openComment:function(e){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});var d=gIComments.getTopPosition()[1];this._q.add({fn:function(){gIComments.open(e.commentId);gIComments.refresh(e.commentId);}});this._animateTo(d);this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},closeComment:function(b){checkForOpenedDialog(b,function(){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});var a=gIComments.getTopPosition()[1];this._q.add({fn:function(){var d=gDb.getComment(b.commentId);gIComments.close(b.commentId);if(d.reply_to_id!=null){gIComments.refresh(d.reply_to_id);}}});this._animateTo(a);this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},this,null);},activate:function(b){gIComments.activate(b.commentId);}};readyForAction=function(){return !gSync._iPreventClick;};gEditICommentHost=null;gEdit=null;dbgc=null;showEditForm=function(h){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(),categoryInputId: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=h;gEditICommentHost.hideContent();var l=getHtml(gEdit.ids);var g='
'+l.headerContent+"
";var j='
'+l.bodyContent+"
";gEditICommentHost.overlay.setStdModContent(CY.WidgetStdMod.HEADER,CY.Node.create(g),CY.WidgetStdMod.AFTER);gEditICommentHost.overlay.setStdModContent(CY.WidgetStdMod.BODY,CY.Node.create(j),CY.WidgetStdMod.AFTER);CY.get("#"+gEdit.ids.formTitleId).set("innerHTML",gettext("Edit comment"));var i=gDb.getComment(gEditICommentHost.commentId);CY.get("#"+gEdit.ids.editCommentId).set("value",i.id);CY.get("#"+gEdit.ids.keyId).set("value",i.key);CY.get("#"+gEdit.ids.changeScopeInputId+" input").set("checked",false);if(i.reply_to_id!=null){CY.get("#"+gEdit.ids.changeScopeInputId).addClass("displaynone");if(CY.get("#"+gEdit.ids.categoryInputId)){CY.get("#"+gEdit.ids.categoryInputId).addClass("displaynone");CY.get("#"+gEdit.ids.categoryInputId).ancestor().addClass("displaynone");}}changeScopeFormClick();CY.get("#"+gEdit.ids.nameInputId).set("value",i.name);CY.get("#"+gEdit.ids.emailInputId).set("value",i.email);if(i.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",i.title);CY.get("#"+gEdit.ids.contentInputId).set("value",i.content);CY.get("#"+gEdit.ids.tagsInputId).set("value",i.tags);if(CY.get("#"+gEdit.ids.categoryInputId)){CY.get("#"+gEdit.ids.categoryInputId).set("value",i.category);}CY.get("#"+gEdit.ids.formatInputId).set("value",gConf.defaultCommentFormat);var k=gLayout.getTopICommentsWidth();changeFormFieldsWidth(gEdit.ids.formId,k);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(b){if(readyForAction()){gSync.editComment();}};onEditCancelClick=function(b){if(readyForAction()){gSync.cancelEdit();}};onChangeScopeClick=function(){if(readyForAction()){gSync.changeScopeFormClick();}else{var e=CY.get("#"+gEdit.ids.changeScopeInputId+" input");var d=e.get("checked");e.set("checked",!d);}};changeScopeFormClick=function(){var b=CY.get("#"+gEdit.ids.currentSelId);if(CY.get("#"+gEdit.ids.changeScopeInputId+" input").get("checked")){b.removeClass("displaynone");}else{b.addClass("displaynone");}};cancelEditForm=function(){if(gEditICommentHost!=null){for(var d in gEdit.handlers){if(gEdit.handlers[d]!=null){gEdit.handlers[d].detach();gEdit.handlers[d]=null;}}var e=gEditICommentHost.overlay.get("contentBox").query(".icomment-edit-body");e.get("parentNode").removeChild(e);e=gEditICommentHost.overlay.get("contentBox").query(".icomment-edit-header");e.get("parentNode").removeChild(e);gEditICommentHost.showContent();gEditICommentHost=null;}};IComment=function(){this.commentId=null;var C=gLayout.getTopICommentsWidth();var N=gConf.iCommentLeftPadding;var w=gettext("change comment state to pending");var A=gettext("change comment state to approved");var J=gettext("change comment state to unapproved");var x=gettext("cancel changing the state of this comment");var L=gettext("pending");var K=gettext("approved");var B=gettext("unapproved");var M=gettext("cancel");var y=gettext("show replies");var v=gettext("change to:");var F=ngettext("reply","replies",1);var H=gettext("edit comment");var E=gettext("delete comment");var z=gettext("edit");var I=gettext("delete");var D=gettext("close");var G=gettext("show scope");var u=gettext("Comment is detached: it was created on a previous version and text it applied to has been modified or removed.");this.overlay=new CY.Overlay({zIndex:3,shim:false,visible:false,width:C,xy:[N,0],headerContent:'
',closeIcon:''};getHtml=function(g){ret={};ret.headerContent="";if("closeBtnId" in g){ret.headerContent+=gFormHtml.closeIcon.replace("###",g.closeBtnId);}ret.headerContent+=gFormHtml.headerTitle.replace("###",g.formTitleId);var b="";if("changeScopeInputId" in g){b=gFormHtml.changeScope.replace("###",g.changeScopeInputId);}var f="
";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");if(CY.get("#"+gEdit.ids["categoryInputId"])){CY.get("#"+gEdit.ids["categoryInputId"]).addClass("displaynone");CY.get("#"+gEdit.ids["categoryInputId"]).ancestor().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);if(CY.get("#"+gEdit.ids["categoryInputId"])){CY.get("#"+gEdit.ids["categoryInputId"]).set("value",f.category);}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;}};IComment=function(){this.commentId=null;var l=gLayout.getTopICommentsWidth();var a=gConf.iCommentLeftPadding;var r=gettext("change comment state to pending");var n=gettext("change comment state to approved");var e=gettext("change comment state to unapproved");var q=gettext("cancel changing the state of this comment");var c=gettext("pending");var d=gettext("approved");var m=gettext("unapproved");var b=gettext("cancel");var p=gettext("show replies");var s=gettext("change to:");var i=ngettext("reply","replies",1);var g=gettext("edit comment");var j=gettext("delete comment");var o=gettext("edit");var f=gettext("delete");var k=gettext("close");var h=gettext("show scope");var t=gettext("Comment is detached: it was created on a previous version and text it applied to has been modified or removed.");this.overlay=new CY.Overlay({zIndex:3,shim:false,visible:false,width:l,xy:[a,0],headerContent:'
'+gettext("Comment will apply to this selection:")+'
'+gNoSelectionYet+"
#hiddeninput#
",btns:'
',closeIcon:''};getHtml=function(j){ret={};ret.headerContent="";if("closeBtnId" in j){ret.headerContent+=gFormHtml.closeIcon.replace("###",j.closeBtnId);}ret.headerContent+=gFormHtml.headerTitle.replace("###",j.formTitleId);var h="";if("changeScopeInputId" in j){h=gFormHtml.changeScope.replace("###",j.changeScopeInputId);}var k="
";var i=gFormHtml.currentSel.replace("###",j.currentSelId).replace("???",j.currentSelIdI).replace("#hiddeninput#",k);var l=gFormHtml.btns.replace("###",j.addBtnId).replace("???",j.cancelBtnId);var m=gFormHtml.formStart.replace("###",j.formId)+h+i;if("nameInputId" in j){m=m+gFormHtml.nameInput.replace("###",j.nameInputId);}if("emailInputId" in j){m=m+gFormHtml.emailInput.replace("###",j.emailInputId);}m=m+gFormHtml.titleInput.replace("###",j.titleInputId)+gFormHtml.contentInput.replace("###",j.contentInputId);categories=CY.JSON.parse(sv_categories);if(categories.hasOwnProperty("0")){category_options="";for(c in categories){category_options+='";}gFormHtml.categoryInput=gettext("Category:")+' ";m=m+''+gFormHtml.categoryInput.replace("###",j.categoryInputId)+" ";}m=m+gFormHtml.tagsInput.replace("###",j.tagsInputId);m=m+gFormHtml.hidden.replace("###",j.formatInputId).replace("???","format");m=m+gFormHtml.hidden.replace("###",j.startWrapperInputId).replace("???","start_wrapper");m=m+gFormHtml.hidden.replace("###",j.endWrapperInputId).replace("???","end_wrapper");m=m+gFormHtml.hidden.replace("###",j.startOffsetInputId).replace("???","start_offset");m=m+gFormHtml.hidden.replace("###",j.endOffsetInputId).replace("???","end_offset");m=m+gFormHtml.hidden.replace("###",j.keyId).replace("???","comment_key");m=m+gFormHtml.hidden.replace("###",j.editCommentId).replace("???","edit_comment_id");m=m+l+gFormHtml.formEnd;ret.bodyContent=m;return ret;};changeFormFieldsWidth=function(h,i){var g=(i-20)+"px";var f=CY.all("#"+h+" input[type='text']");if(f!=null){f.setStyle("width",g);}f=CY.all("#"+h+" textarea");if(f!=null){f.setStyle("width",g);}};addFormErrMsg=function(l,n,p){var o=document.getElementById(l);var e,m,q,i;for(e=0,i=o.elements.length;e0){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;if(j.nodeName=="mi"||j.nodeName=="mo"){j=j.parentElement.parentElement.parentElement.parentElement;}innerStartNode=(K)?V.anchorNode:V.focusNode;ac=(K)?V.focusNode.parentNode:V.anchorNode.parentNode;if(ac.nodeName=="mi"||ac.nodeName=="mo"){ac=ac.parentElement.parentElement.parentElement.parentElement;}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}};};_afterDlg=function(g){var f=g[0];var h=g[1];var e=g[2];f.call(h,e);};_abortNewCommentConfirmed=function(b){if(isICommentFormVisible()){if(gLayout.isInFrame()){gSync.hideICommentForm({fn:function(){_afterDlg(b);}});gSync.resume();}}};_abortNewReplyConfirmed=function(b){if(gNewReplyHost!=null){if(gLayout.isInFrame()){cancelNewReplyForm();_afterDlg(b);}}};_abortNewEditConfirmed=function(b){if(gEditICommentHost!=null){if(gLayout.isInFrame()){cancelEditForm();_afterDlg(b);}}};checkForOpenedDialog=function(h,f,i,j){var g=[];if(h!=null){g=CY.Array.map(gDb.getThreads([gDb.getComment(h.commentId)]),function(a){return a.id;});}if(isICommentFormVisible()||(gNewReplyHost!=null&&(h==null||CY.Array.indexOf(g,gNewReplyHost.commentId)!=-1))||(gEditICommentHost!=null&&(h==null||CY.Array.indexOf(g,gEditICommentHost.commentId)!=-1))){if(gLayout.isInFrame()){if(isICommentFormVisible()){parent.f_yesNoDialog(gettext("New comment will be canceled, continue?"),gettext("Warning"),null,null,null,_abortNewCommentConfirmed,this,[f,i,j]);}else{if(gNewReplyHost!=null){parent.f_yesNoDialog(gettext("Started reply will be canceled, continue?"),gettext("Warning"),null,null,null,_abortNewReplyConfirmed,this,[f,i,j]);}else{if(gEditICommentHost!=null){parent.f_yesNoDialog(gettext("Started comment edition will be canceled, continue?"),gettext("Warning"),null,null,null,_abortNewEditConfirmed,this,[f,i,j]);}}}}}else{f.call(i,[]);}};paintCommentScope=function(d){if(d.reply_to_id==null&&d.start_wrapper!=-1){var e={start:{elt:document.getElementById("sv_"+d.start_wrapper),offset:d.start_offset},end:{elt:document.getElementById("sv_"+d.end_wrapper),offset:d.end_offset}};if(document.getElementById("sv_"+d.start_wrapper)==null){warn_server({from:"paintCommentScope",start_wrapper:d.start_wrapper});}else{if(document.getElementById("sv_"+d.end_wrapper)==null){warn_server({from:"paintCommentScope",end_wrapper:d.end_wrapper});}else{e.start=_convertSelectionFromCSToCC(e.start);e.end=_convertSelectionFromCSToCC(e.end);renderComment(e,d.id);}}}};getCommentIdsFromClasses=function(f){var g=[];var h=f.className.split(" ");for(var i=0,j=h.length;i=l){if(j.category){CY.DOM.addClass(k,"cat"+j.category);}}}}};_recAddComment=function(f,e){if(CY.DOM.hasClass(f,"c-c")){_addIdClass(f,e);}else{var g=f.firstChild;while(g!=null){_recAddComment(g,e);g=g.nextSibling;}}};_findCommonAncestor=function(f,e){if(_bruteContains(f,e)){return f;}else{var d=e;while((d!=null)&&!_bruteContains(d,f)){d=d.parentNode;}return d;}};_cregexCache={};_cgetRegExp=function(d,e){e=e||"";if(!_cregexCache[d+e]){_cregexCache[d+e]=new RegExp(d,e);}return _cregexCache[d+e];};_updateCommentCounter=function(e){var h=_cgetRegExp("(?:^|\\s+)c-id-(?:\\d+)","g");var g=e.className.match(h);var f=(g==null)?0:gDb.getThreads(CY.Array.map(g,function(a){return gDb.getComment(parseInt(a.replace(/\D/g,"")));})).length;h=_cgetRegExp("(?:^|\\s+)c-count-(?:\\d+)","g");e.className=e.className.replace(h," ");CY.DOM.addClass(e,"c-count-"+f+" ");if(f>0){e.setAttribute("title",f+ngettext(" comment"," comments",f));if(f>25){CY.DOM.addClass(e,"c-count-25");}}};_convertSelectionFromCCToCS=function(e){var g=e.offset;var f=e.elt.parentNode;var h=e.elt.previousSibling;while(h!=null){g+=_getTextNodeContent(h).length;h=h.previousSibling;}return{elt:f,offset:g};};_convertSelectionFromCSToCC=function(k){var h={elt:null,offset:-1};var i=null;var j=k.elt.firstChild;var l=0;while(j!=null){var g=l;l+=_getTextNodeContent(j).length;if(l>=k.offset){h.elt=j;h.offset=k.offset-g;break;}j=j.nextSibling;}return h;};unpaintCommentScope=function(w){var x=w.id;var i="c-id-"+x;var u=[];var F=CY.all("."+i);if(F!=null){for(var y=0,C=F.size();yj){j=g;}}return j;},_upd:function(i,k,j){var l=false;for(var m=0,h=i.length;m0){e=e.concat(this.getThreads(f[d].replies));}}return e;},_getPath:function(f,h){var g=[h];var i=h;while(i.reply_to_id!=null){i=f[i.reply_to_id];g.push(i);}return g;},getPath:function(b){return this._getPath(this.commentsByDbId,b);},getComment:function(b){return this.commentsByDbId[b];},getCommentByIdKey:function(e){for(var f in this.commentsByDbId){var d=this.commentsByDbId[f];if(d.id_key==e){return d;}}return null;},isChild:function(g,e){var h=this.commentsByDbId[g];var f=(g==e);while((!f)&&(h.reply_to_id!=null)){h=this.commentsByDbId[h.reply_to_id];f=(h.id==e);}return f;},initToReadOnly:function(i,l){for(var g=0,h=this.allComments.length;g0){var l=-1;if((m=="prev")||(m=="next")){for(var n=0;n=0)&&(nj.length){break;}}CY.error("internal error in db browse (could not find any filtered comment)");}return null;},computeFilterResults:function(T){var aj={};if(T){for(key in T){if(key.indexOf("filter_")==0){aj[key.substr("filter_".length)]=T[key];}}}else{if(gLayout.isInFrame()){aj=parent.f_getFrameFilterData();}}var G=[];var i=[];var ah="";if("name" in aj){ah=aj.name;}this.filterByName(ah,G,i);var O=[];var af=[];var L="";if("date" in aj){L=aj.date;}this.filterByDate(L,O,af);var aa=[];var ab=[];var I="";if("text" in aj){I=aj.text;}this.filterByText(I,aa,ab);var U=[];var V=[];var P="";if("tag" in aj){P=aj.tag;}this.filterByTag(P,U,V);var ai=[];var ad=[];var ag="";if("cat" in aj){ag=aj.cat;}this.filterByCat(ag,ai,ad);var H=[];var ac=[];var X="";if("state" in aj){X=aj.state;}this.filterByState(X,H,ac);var ae=[];var R=[];for(var S=0,Y=G.length;Sl){if(j.reply_to_id==null){k.push(j.id);}else{h.push(j.id);}}}},getCommentsAndRepliesCounts:function(k){var g=0;var i=0;var h=(k)?this.allComments:this.comments;var j=this.getThreads(h);for(var l=0;l0){this._animateTo();}}},_showFocusSingleComment:function(g,h,e){if(g!=null){var f=0;if(g.start_wrapper!=-1){f=CY.get(".c-id-"+g.id).getY();}else{f=CY.get(the_scrolling_part).get("scrollTop");}this._showComments([g.id],f,false);if(g.replies.length>0||e){this._animateToAndFocus(f,h.id,e);}}},showSingleComment:function(b){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this._showSingleComment(b);this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},showFocusSingleComment:function(f,d,e){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this._showFocusSingleComment(f,d,e);this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},browse:function(e,d){var f=gIComments.browse(e,d);if(f!=null){this.showSingleComment(f);}},_showComments:function(f,d,e){this._q.add({fn:function(){gShowingAllComments=e;gIComments.hide();hideToc();var g=CY.Array.map(f,function(h){return gDb.getComment(h);});var a=gDb.getThreads(g);gIComments.fetch(a);if(f.length>0){if(e){CY.get(the_scrolling_part).set("scrollTop",0);}else{gIComments.activate(f[0]);var b=CY.get(".c-id-"+f[0]);if(b&&!b.inViewportRegion()){b.scrollIntoView(true);if(parent){parent.document.getElementById("outer-north").scrollIntoView(true);}if(safari_mobile){d=add_comment_offset;}else{d+=add_comment_offset;}}}}gIComments.setPosition([gConf.iCommentLeftPadding,d]);gIComments.show();}});},_animateTo:function(b){this._q.add({fn:function(){gIComments.setAnimationToPositions(b);}},{id:"animationRun",autoContinue:false,fn:CY.bind(gIComments.runAnimations,gIComments)});},_animateToAndFocus:function(e,f,d){this._q.add({fn:function(){gIComments.setAnimationToPositionsAndFocus(e,f,d);}},{id:"animationRun",autoContinue:false,fn:CY.bind(gIComments.runAnimations,gIComments)});},_animateToTop:function(){var b=gIComments.getTopPosition();if(b!=null){this._animateTo(b[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 b=CY.Array.map(gDb.comments,function(a){return a.id;});if(parent.$("#browse_by").val()=="scope"){b.sort(function(a,e){if(gDb.ordered_comment_ids.scope.indexOf(a)gDb.ordered_comment_ids.scope.indexOf(e)){return 1;}return 0;});}this.showComments(b,[0,add_comment_offset],true);},this,null);},showScopeRemovedComments:function(){checkForOpenedDialog(null,function(){gShowingAllComments=true;var d=CY.Array.filter(gDb.comments,function(a){return(a.start_wrapper==-1);});var e=CY.Array.map(d,function(a){return a.id;});if(parent.$("#browse_by").val()=="scope"){e.sort(function(a,b){if(gDb.ordered_comment_ids.scope.indexOf(a)gDb.ordered_comment_ids.scope.indexOf(b)){return 1;}return 0;});}this.showComments(e,[0,add_comment_offset],true);},this,null);},showComments:function(f,d,e){checkForOpenedDialog(null,function(){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this._showComments(f,d[1],e);this._animateTo();this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},this,null);},openComment:function(e){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});var d=gIComments.getTopPosition()[1];this._q.add({fn:function(){gIComments.open(e.commentId);gIComments.refresh(e.commentId);}});this._animateTo(d);this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},closeComment:function(b){checkForOpenedDialog(b,function(){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});var a=gIComments.getTopPosition()[1];this._q.add({fn:function(){var d=gDb.getComment(b.commentId);gIComments.close(b.commentId);if(d.reply_to_id!=null){gIComments.refresh(d.reply_to_id);}}});this._animateTo(a);this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},this,null);},activate:function(b){gIComments.activate(b.commentId);}};readyForAction=function(){return !gSync._iPreventClick;};gEditICommentHost=null;gEdit=null;dbgc=null;showEditForm=function(h){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(),categoryInputId: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=h;gEditICommentHost.hideContent();var l=getHtml(gEdit.ids);var g='
'+l.headerContent+"
";var j='
'+l.bodyContent+"
";gEditICommentHost.overlay.setStdModContent(CY.WidgetStdMod.HEADER,CY.Node.create(g),CY.WidgetStdMod.AFTER);gEditICommentHost.overlay.setStdModContent(CY.WidgetStdMod.BODY,CY.Node.create(j),CY.WidgetStdMod.AFTER);CY.get("#"+gEdit.ids.formTitleId).set("innerHTML",gettext("Edit comment"));var i=gDb.getComment(gEditICommentHost.commentId);CY.get("#"+gEdit.ids.editCommentId).set("value",i.id);CY.get("#"+gEdit.ids.keyId).set("value",i.key);CY.get("#"+gEdit.ids.changeScopeInputId+" input").set("checked",false);if(i.reply_to_id!=null){CY.get("#"+gEdit.ids.changeScopeInputId).addClass("displaynone");if(CY.get("#"+gEdit.ids.categoryInputId)){CY.get("#"+gEdit.ids.categoryInputId).addClass("displaynone");CY.get("#"+gEdit.ids.categoryInputId).ancestor().addClass("displaynone");}}changeScopeFormClick();CY.get("#"+gEdit.ids.nameInputId).set("value",i.name);CY.get("#"+gEdit.ids.emailInputId).set("value",i.email);if(i.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",i.title);CY.get("#"+gEdit.ids.contentInputId).set("value",i.content);CY.get("#"+gEdit.ids.tagsInputId).set("value",i.tags);if(CY.get("#"+gEdit.ids.categoryInputId)){CY.get("#"+gEdit.ids.categoryInputId).set("value",i.category);}CY.get("#"+gEdit.ids.formatInputId).set("value",gConf.defaultCommentFormat);var k=gLayout.getTopICommentsWidth();changeFormFieldsWidth(gEdit.ids.formId,k);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(b){if(readyForAction()){gSync.editComment();}};onEditCancelClick=function(b){if(readyForAction()){gSync.cancelEdit();}};onChangeScopeClick=function(){if(readyForAction()){gSync.changeScopeFormClick();}else{var e=CY.get("#"+gEdit.ids.changeScopeInputId+" input");var d=e.get("checked");e.set("checked",!d);}};changeScopeFormClick=function(){var b=CY.get("#"+gEdit.ids.currentSelId);if(CY.get("#"+gEdit.ids.changeScopeInputId+" input").get("checked")){b.removeClass("displaynone");}else{b.addClass("displaynone");}};cancelEditForm=function(){if(gEditICommentHost!=null){for(var d in gEdit.handlers){if(gEdit.handlers[d]!=null){gEdit.handlers[d].detach();gEdit.handlers[d]=null;}}var e=gEditICommentHost.overlay.get("contentBox").query(".icomment-edit-body");e.get("parentNode").removeChild(e);e=gEditICommentHost.overlay.get("contentBox").query(".icomment-edit-header");e.get("parentNode").removeChild(e);gEditICommentHost.showContent();gEditICommentHost=null;}};IComment=function(){this.commentId=null;var C=gLayout.getTopICommentsWidth();var N=gConf.iCommentLeftPadding;var w=gettext("change comment state to pending");var A=gettext("change comment state to approved");var J=gettext("change comment state to unapproved");var x=gettext("cancel changing the state of this comment");var L=gettext("pending");var K=gettext("approved");var B=gettext("unapproved");var M=gettext("cancel");var y=gettext("show replies");var v=gettext("change to:");var F=ngettext("reply","replies",1);var H=gettext("edit comment");var E=gettext("delete comment");var z=gettext("edit");var I=gettext("delete");var D=gettext("close");var G=gettext("show scope");var u=gettext("Comment is detached: it was created on a previous version and text it applied to has been modified or removed.");this.overlay=new CY.Overlay({zIndex:3,shim:false,visible:false,width:C,xy:[N,0],headerContent:'