# HG changeset patch # User gibus # Date 1381831970 -7200 # Node ID ee0c833d19697ef77b7cadb392a80d80ddedda3c # Parent 723261fb23fbc2a13259e8f138ff8c351948e2ad Fix bug in edition of a reply when no category are defined. diff -r 723261fb23fb -r ee0c833d1969 src/cm/media/js/client/c_client-min.js --- a/src/cm/media/js/client/c_client-min.js Thu Oct 10 11:16:05 2013 +0200 +++ b/src/cm/media/js/client/c_client-min.js Tue Oct 15 12:12:50 2013 +0200 @@ -1,1 +1,1 @@ -Layout=function(){};Layout.prototype={init:function(){},isInFrame:function(){return(!CY.Lang.isUndefined(parent)&&parent.location!=location&&CY.Lang.isFunction(parent.f_getFrameFilterData));},isInComentSite:function(){var b=false;try{if(!CY.Lang.isUndefined(sv_site_url)&&!CY.Lang.isUndefined(parent)&&!CY.Lang.isUndefined(parent.parent)){var a=new String(parent.parent.location);b=(a.indexOf(sv_site_url)==0);}}catch(c){b=false;}return b;},sliderValToPx:function(d){var a=CY.DOM.winWidth();if(this.isInFrame()){a=parent.$(parent).width();}var b=d/100;b=Math.min(b,gConf.sliderFixedMin);b=Math.max(b,gConf.sliderFixedMax);var c=b*a;return Math.floor(c);},getTopICommentsWidth:function(){return this.getTopICommentsWidthFromWidth(this.sliderValToPx(gPrefs.get("layout","comments_col_width")));},getTopICommentsWidthFromWidth:function(b){var a=b-(2*gConf.iCommentThreadPadding);return a-7;},setLeftColumnWidth:function(a){CY.get("#contentcolumn").setStyle("marginLeft",a+"px");CY.get("#leftcolumn").setStyle("width",a+"px");},parentInterfaceUnfreeze:function(){if(this.isInFrame()){parent.f_interfaceUnfreeze();}}};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(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="
"+gFormHtml.hidden.replace("###",g.selectionPlaceId).replace("???","selection_place")+"
";var a=gFormHtml.currentSel.replace("###",g.currentSelId).replace("???",g.currentSelIdI).replace("#hiddeninput#",f);var e=gFormHtml.btns.replace("###",g.addBtnId).replace("???",g.cancelBtnId);var d=gFormHtml.formStart.replace("###",g.formId)+b+a;if("nameInputId" in g){d=d+gFormHtml.nameInput.replace("###",g.nameInputId);}if("emailInputId" in g){d=d+gFormHtml.emailInput.replace("###",g.emailInputId);}d=d+gFormHtml.titleInput.replace("###",g.titleInputId)+gFormHtml.contentInput.replace("###",g.contentInputId);categories=CY.JSON.parse(sv_categories);if(categories.hasOwnProperty("0")){category_options="";for(c in categories){category_options+='";}gFormHtml.categoryInput=gettext("Category:")+' ";d=d+''+gFormHtml.categoryInput.replace("###",g.categoryInputId)+"
";}d=d+gFormHtml.tagsInput.replace("###",g.tagsInputId);d=d+gFormHtml.hidden.replace("###",g.formatInputId).replace("???","format");d=d+gFormHtml.hidden.replace("###",g.startWrapperInputId).replace("???","start_wrapper");d=d+gFormHtml.hidden.replace("###",g.endWrapperInputId).replace("???","end_wrapper");d=d+gFormHtml.hidden.replace("###",g.startOffsetInputId).replace("???","start_offset");d=d+gFormHtml.hidden.replace("###",g.endOffsetInputId).replace("???","end_offset");d=d+gFormHtml.hidden.replace("###",g.keyId).replace("???","comment_key");d=d+gFormHtml.hidden.replace("###",g.editCommentId).replace("???","edit_comment_id");d=d+e+gFormHtml.formEnd;ret.bodyContent=d;return ret;};changeFormFieldsWidth=function(e,d){var a=(d-20)+"px";var b=CY.all("#"+e+" input[type='text']");if(b!=null){b.setStyle("width",a);}b=CY.all("#"+e+" textarea");if(b!=null){b.setStyle("width",a);}};addFormErrMsg=function(k,h,f){var g=document.getElementById(k);var b,j,d,a;for(b=0,a=g.elements.length;b0){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;if(J.nodeName=="mi"||J.nodeName=="mo"){J=J.parentElement.parentElement.parentElement.parentElement;}innerStartNode=(I)?r.anchorNode:r.focusNode;m=(I)?r.focusNode.parentNode:r.anchorNode.parentNode;if(m.nodeName=="mi"||m.nodeName=="mo"){m=m.parentElement.parentElement.parentElement.parentElement;}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}};};_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,[]);}};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=e){if(g.category){CY.DOM.addClass(f,"cat"+g.category);}}}}};_recAddComment=function(a,b){if(CY.DOM.hasClass(a,"c-c")){_addIdClass(a,b);}else{var d=a.firstChild;while(d!=null){_recAddComment(d,b);d=d.nextSibling;}}};_findCommonAncestor=function(c,a){if(_bruteContains(c,a)){return c;}else{var b=a;while((b!=null)&&!_bruteContains(b,c)){b=b.parentNode;}return b;}};_cregexCache={};_cgetRegExp=function(b,a){a=a||"";if(!_cregexCache[b+a]){_cregexCache[b+a]=new RegExp(b,a);}return _cregexCache[b+a];};_updateCommentCounter=function(b){var c=_cgetRegExp("(?:^|\\s+)c-id-(?:\\d+)","g");var d=b.className.match(c);var a=(d==null)?0:gDb.getThreads(CY.Array.map(d,function(e){return gDb.getComment(parseInt(e.replace(/\D/g,"")));})).length;c=_cgetRegExp("(?:^|\\s+)c-count-(?:\\d+)","g");b.className=b.className.replace(c," ");CY.DOM.addClass(b,"c-count-"+a+" ");if(a>0){b.setAttribute("title",a+ngettext(" comment"," comments",a));if(a>25){CY.DOM.addClass(b,"c-count-25");}}};_convertSelectionFromCCToCS=function(b){var d=b.offset;var a=b.elt.parentNode;var c=b.elt.previousSibling;while(c!=null){d+=_getTextNodeContent(c).length;c=c.previousSibling;}return{elt:a,offset:d};};_convertSelectionFromCSToCC=function(d){var a={elt:null,offset:-1};var f=null;var e=d.elt.firstChild;var c=0;while(e!=null){var b=c;c+=_getTextNodeContent(e).length;if(c>=d.offset){a.elt=e;a.offset=d.offset-b;break;}e=e.nextSibling;}return a;};unpaintCommentScope=function(k){var j=k.id;var r="c-id-"+j;var m=[];var t=CY.all("."+r);if(t!=null){for(var h=0,d=t.size();hc){c=a;}}return c;},_upd:function(a,f,g){var e=false;for(var d=0,b=a.length;d0){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(q){var a={};if(q){for(key in q){if(key.indexOf("filter_")==0){a[key.substr("filter_".length)]=q[key];}}}else{if(gLayout.isInFrame()){a=parent.f_getFrameFilterData();}}var y=[];var z=[];var c="";if("name" in a){c=a.name;}this.filterByName(c,y,z);var s=[];var e=[];var F="";if("date" in a){F=a.date;}this.filterByDate(F,s,e);var k=[];var j=[];var w="";if("text" in a){w=a.text;}this.filterByText(w,k,j);var A=[];var p=[];var D="";if("tag" in a){D=a.tag;}this.filterByTag(D,A,p);var b=[];var g=[];var d="";if("cat" in a){d=a.cat;}this.filterByCat(d,b,g);var x=[];var h=[];var n="";if("state" in a){n=a.state;}this.filterByState(n,x,h);var f=[];var C=[];for(var B=0,m=y.length;Bc){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){this._animateTo(a);}}},_showFocusSingleComment:function(d,c,b){if(d!=null){var a=0;if(d.start_wrapper!=-1){a=CY.get(".c-id-"+d.id).getY();}else{a=CY.get("document").get("scrollTop");}this._showComments([d.id],a,false);if(d.replies.length>0||b){this._animateToAndFocus(a,c.id,b);}}},showSingleComment:function(a){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this._showSingleComment(a);this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},showFocusSingleComment:function(c,b,a){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this._showFocusSingleComment(c,b,a);this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},browse:function(a,b){var c=gIComments.browse(a,b);if(c!=null){this.showSingleComment(c);}},_showComments:function(c,b,a){this._q.add({fn:function(){gShowingAllComments=a;gIComments.hide();hideToc();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);if(parent){parent.document.getElementById("outer-north").scrollIntoView(true);}}}}gIComments.setPosition([gConf.iCommentLeftPadding,b]);gIComments.show();}});},_animateTo:function(a){this._q.add({fn:function(){gIComments.setAnimationToPositions(a);}},{id:"animationRun",autoContinue:false,fn:CY.bind(gIComments.runAnimations,gIComments)});},_animateToAndFocus:function(a,c,b){this._q.add({fn:function(){gIComments.setAnimationToPositionsAndFocus(a,c,b);}},{id:"animationRun",autoContinue:false,fn:CY.bind(gIComments.runAnimations,gIComments)});},_animateToTop:function(){var a=gIComments.getTopPosition();if(a!=null){this._animateTo(a[1]);}},animateToTop:function(){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this._animateToTop();this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},showAllComments:function(){checkForOpenedDialog(null,function(){gShowingAllComments=true;var a=CY.Array.map(gDb.comments,function(b){return b.id;});if(parent.$("#browse_by").val()=="scope"){a.sort(function(d,c){if(gDb.ordered_comment_ids.scope.indexOf(d)gDb.ordered_comment_ids.scope.indexOf(c)){return 1;}return 0;});}this.showComments(a,[0,30],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;});if(parent.$("#browse_by").val()=="scope"){a.sort(function(d,c){if(gDb.ordered_comment_ids.scope.indexOf(d)gDb.ordered_comment_ids.scope.indexOf(c)){return 1;}return 0;});}this.showComments(a,[0,30],true);},this,null);},showComments:function(c,b,a){checkForOpenedDialog(null,function(){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this._showComments(c,b[1],a);this._animateTo(b[1]);this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},this,null);},openComment:function(a){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});var b=gIComments.getTopPosition()[1];this._q.add({fn:function(){gIComments.open(a.commentId);gIComments.refresh(a.commentId);}});this._animateTo(b);this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},closeComment:function(a){checkForOpenedDialog(a,function(){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});var b=gIComments.getTopPosition()[1];this._q.add({fn:function(){var c=gDb.getComment(a.commentId);gIComments.close(a.commentId);if(c.reply_to_id!=null){gIComments.refresh(c.reply_to_id);}}});this._animateTo(b);this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},this,null);},activate:function(a){gIComments.activate(a.commentId);}};readyForAction=function(){return !gSync._iPreventClick;};gEditICommentHost=null;gEdit=null;dbgc=null;showEditForm=function(a){if(gEdit==null){gEdit={ids:{formId:CY.guid(),formTitleId:CY.guid(),nameInputId:CY.guid(),emailInputId:CY.guid(),titleInputId:CY.guid(),contentInputId:CY.guid(),tagsInputId:CY.guid(),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=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");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:'',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(i){this.commentId=i.id;var c=this.overlay.get("boundingBox");if(i.start_wrapper!=-1){c.addClass("c-has-scope");c.removeClass("c-has-no-scope");}else{c.addClass("c-has-no-scope");c.removeClass("c-has-scope");}if(i.reply_to_id!=null){c.addClass("c-is-reply");}else{c.removeClass("c-is-reply");}var g=interpolate(gettext("last modified on %(date)s"),{date:i.modified_user_str},true);var m=(i.modified==i.created)?"":' * ';var k=gettext("Permalink to this comment");var p='ΒΆ ';var l=interpolate(gettext("by %(name)s, created on %(date)s"),{name:i.name,date:i.created_user_str},true);var d='
'+i.title+p+'
'+l+"
";var e=CY.Node.create(d);var q=c.query(".c-header");if(q==null){c.query(".icomment-header").insertBefore(e,c.query(".c-iactions"));}else{q.get("parentNode").replaceChild(e,q);}var h=CY.Node.create('
tags:'+i.tags+"
");var o=c.query(".c-tags");if(o==null){c.query(".icomment-header").appendChild(h);}else{o.get("parentNode").replaceChild(h,o);}if(i.tags==""){h.addClass("displaynone");}var a=CY.Node.create('
'+gettext("category")+': '+categories[i.category]+"
");var j=c.query(".c-cat");if(j==null){c.query(".icomment-header").appendChild(a);}else{j.get("parentNode").replaceChild(a,j);}if(i.category==0){a.addClass("displaynone");}var f=CY.Node.create(''+i.content_html+"");var b=c.query(".c-content");if(b==null){c.query(".icomment-body").appendChild(f);}else{b.get("parentNode").replaceChild(f,b);}if(sv_prefix==""){c.query(".c-permalink").set("href",sv_site_url+i.permalink);}else{comment_id_delta_prefix=sv_delta!=""?Array(parseInt(sv_delta)+1).join(","):"";c.query(".c-permalink").set("href",top.location.protocol+"//"+top.location.hostname+top.location.pathname+"?comment_id_key="+comment_id_delta_prefix+i.id_key);}this.changeModeration(i);var n=c.queryAll(".c-content a");if(n!=null){n.setAttribute("target","_blank");}n=c.queryAll(".c-header-title a");if(n!=null){n.setAttribute("target","_blank");}this.permAdapt(i);},permAdapt:function(e){var b=this.overlay.get("contentBox").query(".c-delete");if(b){if(!e.can_delete){b.addClass("displaynone");}else{b.removeClass("displaynone");}}var a=this.overlay.get("contentBox").query(".c-edit");if(a){if(!e.can_edit){a.addClass("displaynone");}else{a.removeClass("displaynone");}}var d=this.overlay.get("contentBox").query(".c-reply");if(d){if(!hasPerm("can_create_comment")){d.addClass("displaynone");}else{d.removeClass("displaynone");}}var c=this.overlay.get("contentBox").query(".c-moderate");if(c){if(!e.can_moderate){c.addClass("displaynone");}else{c.removeClass("displaynone");}}},setThreadPad:function(a){this.overlay.get("contentBox").query(".yui-widget-hd").setStyle("paddingLeft",a+"px");this.overlay.get("contentBox").query(".yui-widget-bd").setStyle("paddingLeft",a+"px");},setPosition:function(b){var a=this.overlay.get("boundingBox");a.setStyle("opacity",1);a.setXY(b);},getPosition:function(b){var a=this.overlay.get("boundingBox");return a.getXY();},onAnimationEnd:function(){if(!CY.Lang.isUndefined(this["animation-handle"])&&!CY.Lang.isNull(this["animation-handle"])){this["animation-handle"].detach();this["animation-handle"]=null;}gIComments.signalAnimationEnd();if(gIComments.animationsEnded()){gIComments.whenAnimationsEnd();}},onAnimationEndFocus:function(){if(!CY.Lang.isUndefined(this["animation-handle"])&&!CY.Lang.isNull(this["animation-handle"])){this["animation-handle"].detach();this["animation-handle"]=null;}gIComments.signalAnimationEnd();if(gIComments.animationsEnded()){gIComments.whenAnimationsEndFocus();}},onAnimationEndReply: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.whenAnimationsEndReply();}},setAnimationToPosition:function(d,a,c){var b=this.overlay.get("boundingBox");if(gPrefs.get("general","animduration")<0.011){b.setXY(d);}this.animation.set("to",{xy:d});this.animation.set("duration",gPrefs.get("general","animduration"));if(a){if(c){this["animation-handle"]=this.animation.on("end",this.onAnimationEndReply,this);}else{this["animation-handle"]=this.animation.on("end",this.onAnimationEndFocus,this);}}else{this["animation-handle"]=this.animation.on("end",this.onAnimationEnd,this);}return this.animation;},getHeight:function(){return this.overlay.get("boundingBox").get("offsetHeight");},scrollIntoView:function(){if(!this.overlay.get("contentBox").inViewportRegion()){this.overlay.get("contentBox").scrollIntoView(true);}},_isHostingAForm:function(){return(this.isVisible()&&((gNewReplyHost!=null&&gNewReplyHost==this)||(gEditICommentHost!=null&&gEditICommentHost==this)));}};gToc=null;instanciateToc=function(){gToc={tocId:CY.guid(),tocTitleId:CY.guid(),closeBtnId:CY.guid(),empty:false};var c={};c.headerContent='

';var a=getElementsByTagNames("h2,h3,h4,h5,h6",document.getElementById("maincontainer"));var h=document.createElement("div");if(a.length>=2){for(var f=0;f]*>/ig,"");g.className="page indent"+a[f].nodeName;h.appendChild(g);var j=a[f].id||"link"+f;g.href="#"+j;a[f].id=j;}}else{h.innerHTML="";gToc.empty=true;}c.bodyContent=h.innerHTML;var b=gLayout.getTopICommentsWidth();var e=new CY.Overlay({zIndex:3,shim:false,visible:false,headerContent:c.headerContent,bodyContent:c.bodyContent,xy:[3,30],width:b});e.get("contentBox").addClass("c-toc");e.get("contentBox").set("id","the-toc");e.render("#leftcolumn");CY.get("#"+gToc.tocTitleId).set("innerHTML",gettext("Table of contents"));gToc.overlay=e;var k=null;k=new CY.Anim({node:e.get("boundingBox"),duration:0.3,easing:CY.Easing.easeOut});gToc.animationHide=k;k.set("to",{opacity:0});gToc["animationHide-handle"]=k.on("end",onTocHideAnimEnd,gToc);var d=null;d=new CY.Anim({node:e.get("boundingBox"),duration:0.3,easing:CY.Easing.easeOut});gToc.animationShow=d;d.set("to",{opacity:1});gToc["animationShow-handle"]=d.on("end",onTocShowAnimEnd,gToc);getElementsByClassName("c-toc")[0].style.width=b+"px";};toggleTocFn=function(){if(isTocVisible()){hideToc();}else{showToc();}};hideToc=function(){gToc.overlay.hide();};onTocHideAnimEnd=function(){this.overlay.hide();gSync.resume();};onTocShowAnimEnd=function(){gSync.resume();};showToc=function(){removeFormErrMsg(gToc.tocId);gIComments.hide();gToc.overlay.show();};isTocVisible=function(){if(gToc!=null){return gToc.overlay.get("visible");}return false;};function getElementsByTagNames(g,h){if(!h){var h=document;}var a=g.split(",");var f=new Array();for(var e=0;e',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(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="
"+gFormHtml.hidden.replace("###",j.selectionPlaceId).replace("???","selection_place")+"
";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(f);}}},_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("document").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("document").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);}}}}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,30],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,30],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(d[1]);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");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:'',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(b){b.halt();if(readyForAction()&&this.isVisible()){gSync.closeComment(this);}},onModerateCommentClick:function(b){b.halt();if(readyForAction()&&this.isVisible()){this.overlay.get("contentBox").query(".c-iactions").addClass("displaynone");this.overlay.get("contentBox").query(".c-state-actions").removeClass("displaynone");}},onPendingCommentClick:function(b){b.halt();if(readyForAction()&&this.isVisible()){gSync.moderateComment(this,"pending");}},onApprovedCommentClick:function(b){b.halt();if(readyForAction()&&this.isVisible()){gSync.moderateComment(this,"approved");}},onUnapprovedCommentClick:function(b){b.halt();if(readyForAction()&&this.isVisible()){gSync.moderateComment(this,"unapproved");}},onCancelStateChangeClick:function(b){b.halt();if(readyForAction()&&this.isVisible()){this.overlay.get("contentBox").query(".c-iactions").removeClass("displaynone");this.overlay.get("contentBox").query(".c-state-actions").addClass("displaynone");}},onDeleteCommentClick:function(b){b.halt();if(readyForAction()&&this.isVisible()){gSync.removeComment(this);}},onEditCommentClick:function(b){b.halt();if(readyForAction()&&this.isVisible()){gSync.showEditForm(this);}},onReplyCommentClick:function(b){b.halt();if(readyForAction()&&this.isVisible()){gSync.showReplyForm(this);}},onReadRepliesCommentClick:function(b){b.halt();if(readyForAction()&&this.isVisible()){gSync.openComment(this);}},onCommentClick:function(k){if(readyForAction()&&this.isVisible()){if(k.target.get("target")=="_blank"){var e=k.target;var i=sv_site_url+sv_text_view_show_comment_url;if(e.get("href").indexOf(i)==0){var h=(new RegExp("comment_id_key=([^&]*)","g")).exec(e.get("href"));if(h!=null){var l=h[1];var j=gDb.getCommentByIdKey(l);if(j!=null){k.halt();if(!e.hasClass("c-permalink")){checkForOpenedDialog(null,function(){gSync.showSingleComment(j);});}}}}}else{if(gShowingAllComments){if(!this._isHostingAForm()){var j=gDb.getComment(this.commentId);checkForOpenedDialog(null,function(){if(j!=null){gSync.showSingleComment(j);}});}}else{gSync.activate(this);}}}},onMouseEnterHeader:function(){if(readyForAction()&&this.isVisible()){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(b){this.overlay.get("boundingBox").setStyle("width",b+"px");},activate:function(){this.overlay.get("boundingBox").addClass("c-focus-comment");},deactivate:function(){this.overlay.get("boundingBox").removeClass("c-focus-comment");},hide:function(){if(gIComments.isTopActive(this.commentId)){if(!gIComments.activateVisibleNext()){gIComments.deactivate();}}if(this.isVisible()){this.overlay.hide();this.overlay.blur();}},hideContent:function(){this.overlay.get("contentBox").query(".icomment-header").addClass("displaynone");this.overlay.get("contentBox").query(".icomment-body").addClass("displaynone");},showContent:function(){this.overlay.get("contentBox").query(".icomment-header").removeClass("displaynone");this.overlay.get("contentBox").query(".icomment-body").removeClass("displaynone");},isVisible:function(){return this.overlay.get("visible");},show:function(){this.hideReadRepliesLnk();return this.overlay.show();},showReadRepliesLnk:function(){this.overlay.get("contentBox").query(".c-readreplies").removeClass("displaynone");},hideReadRepliesLnk:function(){this.overlay.get("contentBox").query(".c-readreplies").addClass("displaynone");},changeModeration:function(d){var e=this.overlay.get("contentBox").query(".c-moderate");e.set("innerHTML",gettext(d.state));e.removeClass("c-state-approved");e.removeClass("c-state-pending");e.removeClass("c-state-unapproved");e.addClass("c-state-"+d.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(z){this.commentId=z.id;var F=this.overlay.get("boundingBox");if(z.start_wrapper!=-1){F.addClass("c-has-scope");F.removeClass("c-has-no-scope");}else{F.addClass("c-has-no-scope");F.removeClass("c-has-scope");}if(z.reply_to_id!=null){F.addClass("c-is-reply");}else{F.removeClass("c-is-reply");}var B=interpolate(gettext("last modified on %(date)s"),{date:z.modified_user_str},true);var v=(z.modified==z.created)?"":' * ';var x=gettext("Permalink to this comment");var s='ΒΆ ';var w=interpolate(gettext("by %(name)s, created on %(date)s"),{name:z.name,date:z.created_user_str},true);var E='
'+z.title+s+'
'+w+"
";var D=CY.Node.create(E);var r=F.query(".c-header");if(r==null){F.query(".icomment-header").insertBefore(D,F.query(".c-iactions"));}else{r.get("parentNode").replaceChild(D,r);}var A=CY.Node.create('
tags:'+z.tags+"
");var t=F.query(".c-tags");if(t==null){F.query(".icomment-header").appendChild(A);}else{t.get("parentNode").replaceChild(A,t);}if(z.tags==""){A.addClass("displaynone");}var H=CY.Node.create('
'+gettext("category")+': '+categories[z.category]+"
");var y=F.query(".c-cat");if(y==null){F.query(".icomment-header").appendChild(H);}else{y.get("parentNode").replaceChild(H,y);}if(z.category==0){H.addClass("displaynone");}var C=CY.Node.create(''+z.content_html+"");var G=F.query(".c-content");if(G==null){F.query(".icomment-body").appendChild(C);}else{G.get("parentNode").replaceChild(C,G);}if(sv_prefix==""){F.query(".c-permalink").set("href",sv_site_url+z.permalink);}else{comment_id_delta_prefix=sv_delta!=""?Array(parseInt(sv_delta)+1).join(","):"";F.query(".c-permalink").set("href",top.location.protocol+"//"+top.location.hostname+top.location.pathname+"?comment_id_key="+comment_id_delta_prefix+z.id_key);}this.changeModeration(z);var u=F.queryAll(".c-content a");if(u!=null){u.setAttribute("target","_blank");}u=F.queryAll(".c-header-title a");if(u!=null){u.setAttribute("target","_blank");}this.permAdapt(z);},permAdapt:function(h){var f=this.overlay.get("contentBox").query(".c-delete");if(f){if(!h.can_delete){f.addClass("displaynone");}else{f.removeClass("displaynone");}}var g=this.overlay.get("contentBox").query(".c-edit");if(g){if(!h.can_edit){g.addClass("displaynone");}else{g.removeClass("displaynone");}}var i=this.overlay.get("contentBox").query(".c-reply");if(i){if(!hasPerm("can_create_comment")){i.addClass("displaynone");}else{i.removeClass("displaynone");}}var j=this.overlay.get("contentBox").query(".c-moderate");if(j){if(!h.can_moderate){j.addClass("displaynone");}else{j.removeClass("displaynone");}}},setThreadPad:function(b){this.overlay.get("contentBox").query(".yui-widget-hd").setStyle("paddingLeft",b+"px");this.overlay.get("contentBox").query(".yui-widget-bd").setStyle("paddingLeft",b+"px");},setPosition:function(d){var e=this.overlay.get("boundingBox");e.setStyle("opacity",1);e.setXY(d);},getPosition:function(d){var e=this.overlay.get("boundingBox");return e.getXY();},onAnimationEnd:function(){if(!CY.Lang.isUndefined(this["animation-handle"])&&!CY.Lang.isNull(this["animation-handle"])){this["animation-handle"].detach();this["animation-handle"]=null;}gIComments.signalAnimationEnd();if(gIComments.animationsEnded()){gIComments.whenAnimationsEnd();}},onAnimationEndFocus:function(){if(!CY.Lang.isUndefined(this["animation-handle"])&&!CY.Lang.isNull(this["animation-handle"])){this["animation-handle"].detach();this["animation-handle"]=null;}gIComments.signalAnimationEnd();if(gIComments.animationsEnded()){gIComments.whenAnimationsEndFocus();}},onAnimationEndReply: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.whenAnimationsEndReply();}},setAnimationToPosition:function(g,f,h){var e=this.overlay.get("boundingBox");if(gPrefs.get("general","animduration")<0.011){e.setXY(g);}this.animation.set("to",{xy:g});this.animation.set("duration",gPrefs.get("general","animduration"));if(f){if(h){this["animation-handle"]=this.animation.on("end",this.onAnimationEndReply,this);}else{this["animation-handle"]=this.animation.on("end",this.onAnimationEndFocus,this);}}else{this["animation-handle"]=this.animation.on("end",this.onAnimationEnd,this);}return this.animation;},getHeight:function(){return this.overlay.get("boundingBox").get("offsetHeight");},scrollIntoView:function(){if(!this.overlay.get("contentBox").inViewportRegion()){this.overlay.get("contentBox").scrollIntoView(true);}},_isHostingAForm:function(){return(this.isVisible()&&((gNewReplyHost!=null&&gNewReplyHost==this)||(gEditICommentHost!=null&&gEditICommentHost==this)));}};gToc=null;instanciateToc=function(){gToc={tocId:CY.guid(),tocTitleId:CY.guid(),closeBtnId:CY.guid(),empty:false};var r={};r.headerContent='

';var t=getElementsByTagNames("h2,h3,h4,h5,h6",document.getElementById("maincontainer"));var m=document.createElement("div");if(t.length>=2){for(var o=0;o]*>/ig,"");n.className="page indent"+t[o].nodeName;m.appendChild(n);var l=t[o].id||"link"+o;n.href="#"+l;t[o].id=l;}}else{m.innerHTML="";gToc.empty=true;}r.bodyContent=m.innerHTML;var s=gLayout.getTopICommentsWidth();var p=new CY.Overlay({zIndex:3,shim:false,visible:false,headerContent:r.headerContent,bodyContent:r.bodyContent,xy:[3,30],width:s});p.get("contentBox").addClass("c-toc");p.get("contentBox").set("id","the-toc");p.render("#leftcolumn");CY.get("#"+gToc.tocTitleId).set("innerHTML",gettext("Table of contents"));gToc.overlay=p;var i=null;i=new CY.Anim({node:p.get("boundingBox"),duration:0.3,easing:CY.Easing.easeOut});gToc.animationHide=i;i.set("to",{opacity:0});gToc["animationHide-handle"]=i.on("end",onTocHideAnimEnd,gToc);var q=null;q=new CY.Anim({node:p.get("boundingBox"),duration:0.3,easing:CY.Easing.easeOut});gToc.animationShow=q;q.set("to",{opacity:1});gToc["animationShow-handle"]=q.on("end",onTocShowAnimEnd,gToc);getElementsByClassName("c-toc")[0].style.width=s+"px";};toggleTocFn=function(){if(isTocVisible()){hideToc();}else{showToc();}};hideToc=function(){gToc.overlay.hide();};onTocHideAnimEnd=function(){this.overlay.hide();gSync.resume();};onTocShowAnimEnd=function(){gSync.resume();};showToc=function(){removeFormErrMsg(gToc.tocId);gIComments.hide();gToc.overlay.show();};isTocVisible=function(){if(gToc!=null){return gToc.overlay.get("visible");}return false;};function getElementsByTagNames(l,k){if(!k){var k=document;}var j=l.split(",");var m=new Array();for(var n=0;nb){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();hideToc();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});if(c<=e){b.set("y",b.get("y")+30);}a.setX(a.getX()+gConf.iCommentLeftPadding);}};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"+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(c";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);CY.get("#"+gNewReply.ids["contentInputId"]).focus();};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();};IComments=function(){this._c=[];this._a=[];this._nbEndedAnim=0;this._topActiveCommentDbId=null;};IComments.prototype={init:function(a){for(var b=0;b0){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=f){this._a.push(c.setAnimationToPosition([k,h],f,b));}else{this._a.push(c.setAnimationToPosition([k,h]));}h+=c.getHeight();}}},_initAnimations:function(){this._a=[];this._nbEndedAnim=0;},runAnimations:function(){if(this._a.length==0){gSync.resetAutoContinue("animationRun");}else{CY.each(this._a,function(a){a.run();});}},whenAnimationsEnd:function(){gSync.resume();},whenAnimationsEndFocus:function(){gGETValues=CY.JSON.parse(sv_get_params);if("comment_id_key" in gGETValues){var b=gGETValues.comment_id_key;var a=gDb.getCommentByIdKey(b);if(a!=null){gIComments.getIComment(a.id).overlay.focus();}}gSync.resume();},whenAnimationsEndReply:function(){gGETValues=CY.JSON.parse(sv_get_params);if("comment_id_key" in gGETValues){var b=gGETValues.comment_id_key;var a=gDb.getCommentByIdKey(b);if(a!=null){gSync.showReplyForm(gIComments.getIComment(a.id));}}gSync.resume();},animationsEnded:function(){return((this._a.length==0)||(this._a.length==this._nbEndedAnim));},signalAnimationEnd:function(){this._nbEndedAnim++;},isTopActive:function(a){return((a!=null)&&(this._topActiveCommentDbId==a));},isAnyActive:function(){return(this._topActiveCommentDbId!=null);},activate:function(f){if(this._topActiveCommentDbId!=null){this.deactivate();}var e=gDb.getComment(f);var b=gDb.getPath(e);var a=b[b.length-1];var c=this._getChildren(a.id);CY.Array.each(c,function(g){g.activate();});this._topActiveCommentDbId=a.id;if(gLayout.isInFrame()){var d=gDb.browsingIndex(this._topActiveCommentDbId);parent.$("#browse_by option").each(function(){var g=1+d[this.value];parent.$("#c_browse_indx_"+this.value).html(""+g);});}showScope(a.id);},deactivate:function(){if(this._topActiveCommentDbId!=null){parent.$("#browse_by option").each(function(){parent.$("#c_browse_indx_"+this.value).html("-");});hideScopeAnyway();var a=this._getChildren(this._topActiveCommentDbId);CY.Array.each(a,function(b){b.deactivate();});this._topActiveCommentDbId=null;}},activateVisibleNext:function(){if(this._topActiveCommentDbId!=null){for(var d=0;d<2;d++){var f=(d==0)?0:this._c.length-1;var a=false;for(var e=f;(e>=0)&&e<=(this._c.length-1);){var c=this._c[e];if(c.commentId!=null&&c.isVisible()){a=a||(gDb.isChild(c.commentId,this._topActiveCommentDbId));if(a&&(!gDb.isChild(c.commentId,this._topActiveCommentDbId))){this.activate(c.commentId);return true;}}e=(d==0)?e+1:e-1;}}}return false;},browse:function(b,c){var a=c;if((c=="prev")&&!this.isAnyActive()){a="last";}if((c=="next")&&!this.isAnyActive()){a="first";}return gDb.browse(b,a,this._topActiveCommentDbId);}};CY=null;gPrefs=null;gLayout=null;gDb=null;gIComments=null;gSync=null;gGETValues=null;gConf={iCommentLeftPadding:4,iCommentThreadPadding:12,defaultCommentFormat:"markdown",sliderFixedMin:0.9,sliderFixedMax:0.1,iCommentsInitAlloc:2,defaultPrefs:{text:{style:"text-modern-style"},user:{name:"",email:""},general:{animduration:"0.4"},comments:{threadpad:"1"},layout:{comments_col_width:"25"}}};if(sv_custom_font){gTextStyles={custom:gettext("custom"),modern:gettext("modern"),classic:gettext("classic"),code:gettext("code")};}else{gTextStyles={modern:gettext("modern"),classic:gettext("classic"),code:gettext("code")};}YUI({base:sv_media_url+"/js/lib/yui/"+c_yui_base+"/build/",timeout:10000}).use("text-modern-style","cookie","json","overlay","io-form","async-queue","event-mouseenter","anim","collection",function(a){CY=a;gPrefs=new Preferences();gPrefs.init();gLayout=new Layout();gLayout.init();if(sv_withComments){gDb=new Db();gDb.init();gIComments=new IComments();gIComments.init();}gSync=new Sync();gSync.init();CY.on("domready",onDomReady,this);});_reinit=function(a){gIComments.hide();gDb.initComments(a.commentIds);unpaintAllComments();renderCommentScopes();updateFilterResultsCount(a.nbDiscussions,a.nbComments,a.nbReplies);};reinit=function(b){var a=gDb.computeFilterResults(b);_reinit(a);};hideAll=function(){_reinit({commentIds:[],nbDiscussions:0,nbComments:0,nbReplies:0});};updateFilterResultsCount=function(f,a,b){var e=gDb.getCommentsAndRepliesCounts(true);var g=e[0],d=e[1];var c=(a!=0||b!=0)&&(g!=a||d!=b);if(gLayout.isInFrame()){parent.f_updateFilterCountDetailed(c);parent.f_updateFilterCountResult(f,a,b,g,d);}};updateResetFilterResultsCount=function(){var c=gDb.getCommentsAndRepliesCounts(false);var a=c[0],b=c[1];var d=a;updateFilterResultsCount(d,a,b);};renderCommentScopes=function(){for(var a=0;a0){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();}instanciateToc();},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();}if(gToc.empty){parent.$("#c_toc_btn").hide();}},timeout:5},{fn:function(){if(sv_withComments){reinit(gGETValues);initialConnect();}},timeout:5},{fn:function(){if(gLayout.isInFrame()){parent.f_interfaceUnfreeze();parent.f_removeLoadingMsg();}if("comment_id_key" in gGETValues){var e=gGETValues.comment_id_key;var g=gDb.getCommentByIdKey(e);if(g!=null){var f=gDb.getPath(g);var c=f[f.length-1];var d=gDb.getCommentByIdKey(e);if("comment_op" in gGETValues&&gGETValues.comment_op=="reply"){gSync.showFocusSingleComment(c,d,true);}else{gSync.showFocusSingleComment(c,d,false);}}}if("comments_auto_display" in gGETValues){gSync.showAllComments();}}});a.run();};c_persistPreference=function(b,a,c){gPrefs.persist(b,a,c);};c_readDefaultPreference=function(b,a){return gConf.defaultPrefs[b][a];};c_readPreference=function(b,a){return gPrefs.get(b,a);};c_resetPreferences=function(a){gPrefs.reset(a);};c_applyTextStyle=function(a){CY.use(a);};sliderValToPx=function(d){var a=CY.DOM.winWidth();if(gLayout.isInFrame()){a=parent.$(parent).width();}var b=d/100;b=Math.min(b,gConf.sliderFixedMin);b=Math.max(b,gConf.sliderFixedMax);var c=b*a;return Math.floor(c);};c_setCommentsColWidth=function(c){var a=sliderValToPx(c);gLayout.setLeftColumnWidth(a);var b=gLayout.getTopICommentsWidthFromWidth(a);gIComments.setWidth(b);gICommentForm.overlay.get("boundingBox").setStyle("width",b+"px");changeFormFieldsWidth(gICommentForm.formId,b);document.getElementById("the-toc").style.width=b+"px";if(gNewReply){changeFormFieldsWidth(gNewReply.ids["formId"],b);}if(gEdit){changeFormFieldsWidth(gEdit.ids["formId"],b);}}; \ No newline at end of file +_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,[]);}};gToc=null;instanciateToc=function(){gToc={tocId:CY.guid(),tocTitleId:CY.guid(),closeBtnId:CY.guid(),empty:false};var c={};c.headerContent='

';var a=getElementsByTagNames("h2,h3,h4,h5,h6",document.getElementById("maincontainer"));var h=document.createElement("div");if(a.length>=2){for(var f=0;f]*>/ig,"");g.className="page indent"+a[f].nodeName;h.appendChild(g);var j=a[f].id||"link"+f;g.href="#"+j;a[f].id=j;}}else{h.innerHTML="";gToc.empty=true;}c.bodyContent=h.innerHTML;var b=gLayout.getTopICommentsWidth();var e=new CY.Overlay({zIndex:3,shim:false,visible:false,headerContent:c.headerContent,bodyContent:c.bodyContent,xy:[3,30],width:b});e.get("contentBox").addClass("c-toc");e.get("contentBox").set("id","the-toc");e.render("#leftcolumn");CY.get("#"+gToc.tocTitleId).set("innerHTML",gettext("Table of contents"));gToc.overlay=e;var k=null;k=new CY.Anim({node:e.get("boundingBox"),duration:0.3,easing:CY.Easing.easeOut});gToc.animationHide=k;k.set("to",{opacity:0});gToc["animationHide-handle"]=k.on("end",onTocHideAnimEnd,gToc);var d=null;d=new CY.Anim({node:e.get("boundingBox"),duration:0.3,easing:CY.Easing.easeOut});gToc.animationShow=d;d.set("to",{opacity:1});gToc["animationShow-handle"]=d.on("end",onTocShowAnimEnd,gToc);getElementsByClassName("c-toc")[0].style.width=b+"px";};toggleTocFn=function(){if(isTocVisible()){hideToc();}else{showToc();}};hideToc=function(){gToc.overlay.hide();};onTocHideAnimEnd=function(){this.overlay.hide();gSync.resume();};onTocShowAnimEnd=function(){gSync.resume();};showToc=function(){removeFormErrMsg(gToc.tocId);gIComments.hide();gToc.overlay.show();};isTocVisible=function(){if(gToc!=null){return gToc.overlay.get("visible");}return false;};function getElementsByTagNames(g,h){if(!h){var h=document;}var a=g.split(",");var f=new Array();for(var e=0;e
'+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(i){this.commentId=i.id;var c=this.overlay.get("boundingBox");if(i.start_wrapper!=-1){c.addClass("c-has-scope");c.removeClass("c-has-no-scope");}else{c.addClass("c-has-no-scope");c.removeClass("c-has-scope");}if(i.reply_to_id!=null){c.addClass("c-is-reply");}else{c.removeClass("c-is-reply");}var g=interpolate(gettext("last modified on %(date)s"),{date:i.modified_user_str},true);var m=(i.modified==i.created)?"":' * ';var k=gettext("Permalink to this comment");var p='ΒΆ ';var l=interpolate(gettext("by %(name)s, created on %(date)s"),{name:i.name,date:i.created_user_str},true);var d='
'+i.title+p+'
'+l+"
";var e=CY.Node.create(d);var q=c.query(".c-header");if(q==null){c.query(".icomment-header").insertBefore(e,c.query(".c-iactions"));}else{q.get("parentNode").replaceChild(e,q);}var h=CY.Node.create('
tags:'+i.tags+"
");var o=c.query(".c-tags");if(o==null){c.query(".icomment-header").appendChild(h);}else{o.get("parentNode").replaceChild(h,o);}if(i.tags==""){h.addClass("displaynone");}var a=CY.Node.create('
'+gettext("category")+': '+categories[i.category]+"
");var j=c.query(".c-cat");if(j==null){c.query(".icomment-header").appendChild(a);}else{j.get("parentNode").replaceChild(a,j);}if(i.category==0){a.addClass("displaynone");}var f=CY.Node.create(''+i.content_html+"");var b=c.query(".c-content");if(b==null){c.query(".icomment-body").appendChild(f);}else{b.get("parentNode").replaceChild(f,b);}if(sv_prefix==""){c.query(".c-permalink").set("href",sv_site_url+i.permalink);}else{comment_id_delta_prefix=sv_delta!=""?Array(parseInt(sv_delta)+1).join(","):"";c.query(".c-permalink").set("href",top.location.protocol+"//"+top.location.hostname+top.location.pathname+"?comment_id_key="+comment_id_delta_prefix+i.id_key);}this.changeModeration(i);var n=c.queryAll(".c-content a");if(n!=null){n.setAttribute("target","_blank");}n=c.queryAll(".c-header-title a");if(n!=null){n.setAttribute("target","_blank");}this.permAdapt(i);},permAdapt:function(e){var b=this.overlay.get("contentBox").query(".c-delete");if(b){if(!e.can_delete){b.addClass("displaynone");}else{b.removeClass("displaynone");}}var a=this.overlay.get("contentBox").query(".c-edit");if(a){if(!e.can_edit){a.addClass("displaynone");}else{a.removeClass("displaynone");}}var d=this.overlay.get("contentBox").query(".c-reply");if(d){if(!hasPerm("can_create_comment")){d.addClass("displaynone");}else{d.removeClass("displaynone");}}var c=this.overlay.get("contentBox").query(".c-moderate");if(c){if(!e.can_moderate){c.addClass("displaynone");}else{c.removeClass("displaynone");}}},setThreadPad:function(a){this.overlay.get("contentBox").query(".yui-widget-hd").setStyle("paddingLeft",a+"px");this.overlay.get("contentBox").query(".yui-widget-bd").setStyle("paddingLeft",a+"px");},setPosition:function(b){var a=this.overlay.get("boundingBox");a.setStyle("opacity",1);a.setXY(b);},getPosition:function(b){var a=this.overlay.get("boundingBox");return a.getXY();},onAnimationEnd:function(){if(!CY.Lang.isUndefined(this["animation-handle"])&&!CY.Lang.isNull(this["animation-handle"])){this["animation-handle"].detach();this["animation-handle"]=null;}gIComments.signalAnimationEnd();if(gIComments.animationsEnded()){gIComments.whenAnimationsEnd();}},onAnimationEndFocus:function(){if(!CY.Lang.isUndefined(this["animation-handle"])&&!CY.Lang.isNull(this["animation-handle"])){this["animation-handle"].detach();this["animation-handle"]=null;}gIComments.signalAnimationEnd();if(gIComments.animationsEnded()){gIComments.whenAnimationsEndFocus();}},onAnimationEndReply: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.whenAnimationsEndReply();}},setAnimationToPosition:function(d,a,c){var b=this.overlay.get("boundingBox");if(gPrefs.get("general","animduration")<0.011){b.setXY(d);}this.animation.set("to",{xy:d});this.animation.set("duration",gPrefs.get("general","animduration"));if(a){if(c){this["animation-handle"]=this.animation.on("end",this.onAnimationEndReply,this);}else{this["animation-handle"]=this.animation.on("end",this.onAnimationEndFocus,this);}}else{this["animation-handle"]=this.animation.on("end",this.onAnimationEnd,this);}return this.animation;},getHeight:function(){return this.overlay.get("boundingBox").get("offsetHeight");},scrollIntoView:function(){if(!this.overlay.get("contentBox").inViewportRegion()){this.overlay.get("contentBox").scrollIntoView(true);}},_isHostingAForm:function(){return(this.isVisible()&&((gNewReplyHost!=null&&gNewReplyHost==this)||(gEditICommentHost!=null&&gEditICommentHost==this)));}};hasPerm=function(a){return(-1!=CY.Array.indexOf(sv_user_permissions,a));};_afterDlg=function(g){var f=g[0];var h=g[1];var e=g[2];f.call(h,e);};_abortNewCommentConfirmed=function(b){if(isICommentFormVisible()){if(gLayout.isInFrame()){gSync.hideICommentForm({fn:function(){_afterDlg(b);}});gSync.resume();}}};_abortNewReplyConfirmed=function(b){if(gNewReplyHost!=null){if(gLayout.isInFrame()){cancelNewReplyForm();_afterDlg(b);}}};_abortNewEditConfirmed=function(b){if(gEditICommentHost!=null){if(gLayout.isInFrame()){cancelEditForm();_afterDlg(b);}}};checkForOpenedDialog=function(h,f,i,j){var g=[];if(h!=null){g=CY.Array.map(gDb.getThreads([gDb.getComment(h.commentId)]),function(a){return a.id;});}if(isICommentFormVisible()||(gNewReplyHost!=null&&(h==null||CY.Array.indexOf(g,gNewReplyHost.commentId)!=-1))||(gEditICommentHost!=null&&(h==null||CY.Array.indexOf(g,gEditICommentHost.commentId)!=-1))){if(gLayout.isInFrame()){if(isICommentFormVisible()){parent.f_yesNoDialog(gettext("New comment will be canceled, continue?"),gettext("Warning"),null,null,null,_abortNewCommentConfirmed,this,[f,i,j]);}else{if(gNewReplyHost!=null){parent.f_yesNoDialog(gettext("Started reply will be canceled, continue?"),gettext("Warning"),null,null,null,_abortNewReplyConfirmed,this,[f,i,j]);}else{if(gEditICommentHost!=null){parent.f_yesNoDialog(gettext("Started comment edition will be canceled, continue?"),gettext("Warning"),null,null,null,_abortNewEditConfirmed,this,[f,i,j]);}}}}}else{f.call(i,[]);}};gToc=null;instanciateToc=function(){gToc={tocId:CY.guid(),tocTitleId:CY.guid(),closeBtnId:CY.guid(),empty:false};var r={};r.headerContent='

';var t=getElementsByTagNames("h2,h3,h4,h5,h6",document.getElementById("maincontainer"));var m=document.createElement("div");if(t.length>=2){for(var o=0;o]*>/ig,"");n.className="page indent"+t[o].nodeName;m.appendChild(n);var l=t[o].id||"link"+o;n.href="#"+l;t[o].id=l;}}else{m.innerHTML="";gToc.empty=true;}r.bodyContent=m.innerHTML;var s=gLayout.getTopICommentsWidth();var p=new CY.Overlay({zIndex:3,shim:false,visible:false,headerContent:r.headerContent,bodyContent:r.bodyContent,xy:[3,30],width:s});p.get("contentBox").addClass("c-toc");p.get("contentBox").set("id","the-toc");p.render("#leftcolumn");CY.get("#"+gToc.tocTitleId).set("innerHTML",gettext("Table of contents"));gToc.overlay=p;var i=null;i=new CY.Anim({node:p.get("boundingBox"),duration:0.3,easing:CY.Easing.easeOut});gToc.animationHide=i;i.set("to",{opacity:0});gToc["animationHide-handle"]=i.on("end",onTocHideAnimEnd,gToc);var q=null;q=new CY.Anim({node:p.get("boundingBox"),duration:0.3,easing:CY.Easing.easeOut});gToc.animationShow=q;q.set("to",{opacity:1});gToc["animationShow-handle"]=q.on("end",onTocShowAnimEnd,gToc);getElementsByClassName("c-toc")[0].style.width=s+"px";};toggleTocFn=function(){if(isTocVisible()){hideToc();}else{showToc();}};hideToc=function(){gToc.overlay.hide();};onTocHideAnimEnd=function(){this.overlay.hide();gSync.resume();};onTocShowAnimEnd=function(){gSync.resume();};showToc=function(){removeFormErrMsg(gToc.tocId);gIComments.hide();gToc.overlay.show();};isTocVisible=function(){if(gToc!=null){return gToc.overlay.get("visible");}return false;};function getElementsByTagNames(l,k){if(!k){var k=document;}var j=l.split(",");var m=new Array();for(var n=0;n
'+u+'
-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(b){b.halt();if(readyForAction()&&this.isVisible()){gSync.closeComment(this);}},onModerateCommentClick:function(b){b.halt();if(readyForAction()&&this.isVisible()){this.overlay.get("contentBox").query(".c-iactions").addClass("displaynone");this.overlay.get("contentBox").query(".c-state-actions").removeClass("displaynone");}},onPendingCommentClick:function(b){b.halt();if(readyForAction()&&this.isVisible()){gSync.moderateComment(this,"pending");}},onApprovedCommentClick:function(b){b.halt();if(readyForAction()&&this.isVisible()){gSync.moderateComment(this,"approved");}},onUnapprovedCommentClick:function(b){b.halt();if(readyForAction()&&this.isVisible()){gSync.moderateComment(this,"unapproved");}},onCancelStateChangeClick:function(b){b.halt();if(readyForAction()&&this.isVisible()){this.overlay.get("contentBox").query(".c-iactions").removeClass("displaynone");this.overlay.get("contentBox").query(".c-state-actions").addClass("displaynone");}},onDeleteCommentClick:function(b){b.halt();if(readyForAction()&&this.isVisible()){gSync.removeComment(this);}},onEditCommentClick:function(b){b.halt();if(readyForAction()&&this.isVisible()){gSync.showEditForm(this);}},onReplyCommentClick:function(b){b.halt();if(readyForAction()&&this.isVisible()){gSync.showReplyForm(this);}},onReadRepliesCommentClick:function(b){b.halt();if(readyForAction()&&this.isVisible()){gSync.openComment(this);}},onCommentClick:function(k){if(readyForAction()&&this.isVisible()){if(k.target.get("target")=="_blank"){var e=k.target;var i=sv_site_url+sv_text_view_show_comment_url;if(e.get("href").indexOf(i)==0){var h=(new RegExp("comment_id_key=([^&]*)","g")).exec(e.get("href"));if(h!=null){var l=h[1];var j=gDb.getCommentByIdKey(l);if(j!=null){k.halt();if(!e.hasClass("c-permalink")){checkForOpenedDialog(null,function(){gSync.showSingleComment(j);});}}}}}else{if(gShowingAllComments){if(!this._isHostingAForm()){var j=gDb.getComment(this.commentId);checkForOpenedDialog(null,function(){if(j!=null){gSync.showSingleComment(j);}});}}else{gSync.activate(this);}}}},onMouseEnterHeader:function(){if(readyForAction()&&this.isVisible()){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(b){this.overlay.get("boundingBox").setStyle("width",b+"px");},activate:function(){this.overlay.get("boundingBox").addClass("c-focus-comment");},deactivate:function(){this.overlay.get("boundingBox").removeClass("c-focus-comment");},hide:function(){if(gIComments.isTopActive(this.commentId)){if(!gIComments.activateVisibleNext()){gIComments.deactivate();}}if(this.isVisible()){this.overlay.hide();this.overlay.blur();}},hideContent:function(){this.overlay.get("contentBox").query(".icomment-header").addClass("displaynone");this.overlay.get("contentBox").query(".icomment-body").addClass("displaynone");},showContent:function(){this.overlay.get("contentBox").query(".icomment-header").removeClass("displaynone");this.overlay.get("contentBox").query(".icomment-body").removeClass("displaynone");},isVisible:function(){return this.overlay.get("visible");},show:function(){this.hideReadRepliesLnk();return this.overlay.show();},showReadRepliesLnk:function(){this.overlay.get("contentBox").query(".c-readreplies").removeClass("displaynone");},hideReadRepliesLnk:function(){this.overlay.get("contentBox").query(".c-readreplies").addClass("displaynone");},changeModeration:function(c){var d=this.overlay.get("contentBox").query(".c-moderate");d.set("innerHTML",gettext(c.state));d.removeClass("c-state-approved");d.removeClass("c-state-pending");d.removeClass("c-state-unapproved");d.addClass("c-state-"+c.state);this.overlay.get("contentBox").query(".c-iactions").removeClass("displaynone");this.overlay.get("contentBox").query(".c-state-actions").addClass("displaynone");},isfetched:function(){return(this.commentId!=null);},unfetch:function(){this.commentId=null;},fetch:function(z){this.commentId=z.id;var F=this.overlay.get("boundingBox");if(z.start_wrapper!=-1){F.addClass("c-has-scope");F.removeClass("c-has-no-scope");}else{F.addClass("c-has-no-scope");F.removeClass("c-has-scope");}if(z.reply_to_id!=null){F.addClass("c-is-reply");}else{F.removeClass("c-is-reply");}var B=interpolate(gettext("last modified on %(date)s"),{date:z.modified_user_str},true);var v=(z.modified==z.created)?"":' * ';var x=gettext("Permalink to this comment");var s='ΒΆ ';var w=interpolate(gettext("by %(name)s, created on %(date)s"),{name:z.name,date:z.created_user_str},true);var E='
'+z.title+s+'
'+w+"
";var D=CY.Node.create(E);var r=F.query(".c-header");if(r==null){F.query(".icomment-header").insertBefore(D,F.query(".c-iactions"));}else{r.get("parentNode").replaceChild(D,r);}var A=CY.Node.create('
tags:'+z.tags+"
");var t=F.query(".c-tags");if(t==null){F.query(".icomment-header").appendChild(A);}else{t.get("parentNode").replaceChild(A,t);}if(z.tags==""){A.addClass("displaynone");}var H=CY.Node.create('
'+gettext("category")+': '+categories[z.category]+"
");var y=F.query(".c-cat");if(y==null){F.query(".icomment-header").appendChild(H);}else{y.get("parentNode").replaceChild(H,y);}if(z.category==0){H.addClass("displaynone");}var C=CY.Node.create(''+z.content_html+"");var G=F.query(".c-content");if(G==null){F.query(".icomment-body").appendChild(C);}else{G.get("parentNode").replaceChild(C,G);}if(sv_prefix==""){F.query(".c-permalink").set("href",sv_site_url+z.permalink);}else{comment_id_delta_prefix=sv_delta!=""?Array(parseInt(sv_delta)+1).join(","):"";F.query(".c-permalink").set("href",top.location.protocol+"//"+top.location.hostname+top.location.pathname+"?comment_id_key="+comment_id_delta_prefix+z.id_key);}this.changeModeration(z);var u=F.queryAll(".c-content a");if(u!=null){u.setAttribute("target","_blank");}u=F.queryAll(".c-header-title a");if(u!=null){u.setAttribute("target","_blank");}this.permAdapt(z);},permAdapt:function(h){var f=this.overlay.get("contentBox").query(".c-delete");if(f){if(!h.can_delete){f.addClass("displaynone");}else{f.removeClass("displaynone");}}var g=this.overlay.get("contentBox").query(".c-edit");if(g){if(!h.can_edit){g.addClass("displaynone");}else{g.removeClass("displaynone");}}var i=this.overlay.get("contentBox").query(".c-reply");if(i){if(!hasPerm("can_create_comment")){i.addClass("displaynone");}else{i.removeClass("displaynone");}}var j=this.overlay.get("contentBox").query(".c-moderate");if(j){if(!h.can_moderate){j.addClass("displaynone");}else{j.removeClass("displaynone");}}},setThreadPad:function(b){this.overlay.get("contentBox").query(".yui-widget-hd").setStyle("paddingLeft",b+"px");this.overlay.get("contentBox").query(".yui-widget-bd").setStyle("paddingLeft",b+"px");},setPosition:function(c){var d=this.overlay.get("boundingBox");d.setStyle("opacity",1);d.setXY(c);},getPosition:function(c){var d=this.overlay.get("boundingBox");return d.getXY();},onAnimationEnd:function(){if(!CY.Lang.isUndefined(this["animation-handle"])&&!CY.Lang.isNull(this["animation-handle"])){this["animation-handle"].detach();this["animation-handle"]=null;}gIComments.signalAnimationEnd();if(gIComments.animationsEnded()){gIComments.whenAnimationsEnd();}},onAnimationEndFocus:function(){if(!CY.Lang.isUndefined(this["animation-handle"])&&!CY.Lang.isNull(this["animation-handle"])){this["animation-handle"].detach();this["animation-handle"]=null;}gIComments.signalAnimationEnd();if(gIComments.animationsEnded()){gIComments.whenAnimationsEndFocus();}},onAnimationEndReply: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.whenAnimationsEndReply();}},setAnimationToPosition:function(g,f,h){var e=this.overlay.get("boundingBox");if(gPrefs.get("general","animduration")<0.011){e.setXY(g);}this.animation.set("to",{xy:g});this.animation.set("duration",gPrefs.get("general","animduration"));if(f){if(h){this["animation-handle"]=this.animation.on("end",this.onAnimationEndReply,this);}else{this["animation-handle"]=this.animation.on("end",this.onAnimationEndFocus,this);}}else{this["animation-handle"]=this.animation.on("end",this.onAnimationEnd,this);}return this.animation;},getHeight:function(){return this.overlay.get("boundingBox").get("offsetHeight");},scrollIntoView:function(){if(!this.overlay.get("contentBox").inViewportRegion()){this.overlay.get("contentBox").scrollIntoView(true);}},_isHostingAForm:function(){return(this.isVisible()&&((gNewReplyHost!=null&&gNewReplyHost==this)||(gEditICommentHost!=null&&gEditICommentHost==this)));}};hasPerm=function(b){return(-1!=CY.Array.indexOf(sv_user_permissions,b));};paintCommentScope=function(b){if(b.reply_to_id==null&&b.start_wrapper!=-1){var a={start:{elt:document.getElementById("sv_"+b.start_wrapper),offset:b.start_offset},end:{elt:document.getElementById("sv_"+b.end_wrapper),offset:b.end_offset}};if(document.getElementById("sv_"+b.start_wrapper)==null){warn_server({from:"paintCommentScope",start_wrapper:b.start_wrapper});}else{if(document.getElementById("sv_"+b.end_wrapper)==null){warn_server({from:"paintCommentScope",end_wrapper:b.end_wrapper});}else{a.start=_convertSelectionFromCSToCC(a.start);a.end=_convertSelectionFromCSToCC(a.end);renderComment(a,b.id);}}}};getCommentIdsFromClasses=function(b){var a=[];var e=b.className.split(" ");for(var d=0,c=e.length;d=e){if(g.category){CY.DOM.addClass(f,"cat"+g.category);}}}}};_recAddComment=function(a,b){if(CY.DOM.hasClass(a,"c-c")){_addIdClass(a,b);}else{var d=a.firstChild;while(d!=null){_recAddComment(d,b);d=d.nextSibling;}}};_findCommonAncestor=function(c,a){if(_bruteContains(c,a)){return c;}else{var b=a;while((b!=null)&&!_bruteContains(b,c)){b=b.parentNode;}return b;}};_cregexCache={};_cgetRegExp=function(b,a){a=a||"";if(!_cregexCache[b+a]){_cregexCache[b+a]=new RegExp(b,a);}return _cregexCache[b+a];};_updateCommentCounter=function(b){var c=_cgetRegExp("(?:^|\\s+)c-id-(?:\\d+)","g");var d=b.className.match(c);var a=(d==null)?0:gDb.getThreads(CY.Array.map(d,function(e){return gDb.getComment(parseInt(e.replace(/\D/g,"")));})).length;c=_cgetRegExp("(?:^|\\s+)c-count-(?:\\d+)","g");b.className=b.className.replace(c," ");CY.DOM.addClass(b,"c-count-"+a+" ");if(a>0){b.setAttribute("title",a+ngettext(" comment"," comments",a));if(a>25){CY.DOM.addClass(b,"c-count-25");}}};_convertSelectionFromCCToCS=function(b){var d=b.offset;var a=b.elt.parentNode;var c=b.elt.previousSibling;while(c!=null){d+=_getTextNodeContent(c).length;c=c.previousSibling;}return{elt:a,offset:d};};_convertSelectionFromCSToCC=function(d){var a={elt:null,offset:-1};var f=null;var e=d.elt.firstChild;var c=0;while(e!=null){var b=c;c+=_getTextNodeContent(e).length;if(c>=d.offset){a.elt=e;a.offset=d.offset-b;break;}e=e.nextSibling;}return a;};unpaintCommentScope=function(k){var j=k.id;var r="c-id-"+j;var m=[];var t=CY.all("."+r);if(t!=null){for(var h=0,d=t.size();h0){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;if(J.nodeName=="mi"||J.nodeName=="mo"){J=J.parentElement.parentElement.parentElement.parentElement;}innerStartNode=(I)?r.anchorNode:r.focusNode;m=(I)?r.focusNode.parentNode:r.anchorNode.parentNode;if(m.nodeName=="mi"||m.nodeName=="mo"){m=m.parentElement.parentElement.parentElement.parentElement;}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}};};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',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(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="
"+gFormHtml.hidden.replace("###",g.selectionPlaceId).replace("???","selection_place")+"
";var a=gFormHtml.currentSel.replace("###",g.currentSelId).replace("???",g.currentSelIdI).replace("#hiddeninput#",f);var e=gFormHtml.btns.replace("###",g.addBtnId).replace("???",g.cancelBtnId);var d=gFormHtml.formStart.replace("###",g.formId)+b+a;if("nameInputId" in g){d=d+gFormHtml.nameInput.replace("###",g.nameInputId);}if("emailInputId" in g){d=d+gFormHtml.emailInput.replace("###",g.emailInputId);}d=d+gFormHtml.titleInput.replace("###",g.titleInputId)+gFormHtml.contentInput.replace("###",g.contentInputId);categories=CY.JSON.parse(sv_categories);if(categories.hasOwnProperty("0")){category_options="";for(c in categories){category_options+='";}gFormHtml.categoryInput=gettext("Category:")+' ";d=d+''+gFormHtml.categoryInput.replace("###",g.categoryInputId)+"
";}d=d+gFormHtml.tagsInput.replace("###",g.tagsInputId);d=d+gFormHtml.hidden.replace("###",g.formatInputId).replace("???","format");d=d+gFormHtml.hidden.replace("###",g.startWrapperInputId).replace("???","start_wrapper");d=d+gFormHtml.hidden.replace("###",g.endWrapperInputId).replace("???","end_wrapper");d=d+gFormHtml.hidden.replace("###",g.startOffsetInputId).replace("???","start_offset");d=d+gFormHtml.hidden.replace("###",g.endOffsetInputId).replace("???","end_offset");d=d+gFormHtml.hidden.replace("###",g.keyId).replace("???","comment_key");d=d+gFormHtml.hidden.replace("###",g.editCommentId).replace("???","edit_comment_id");d=d+e+gFormHtml.formEnd;ret.bodyContent=d;return ret;};changeFormFieldsWidth=function(e,d){var a=(d-20)+"px";var b=CY.all("#"+e+" input[type='text']");if(b!=null){b.setStyle("width",a);}b=CY.all("#"+e+" textarea");if(b!=null){b.setStyle("width",a);}};addFormErrMsg=function(k,h,f){var g=document.getElementById(k);var b,j,d,a;for(b=0,a=g.elements.length;b"+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(c0){this._animateTo(a);}}},_showFocusSingleComment:function(d,c,b){if(d!=null){var a=0;if(d.start_wrapper!=-1){a=CY.get(".c-id-"+d.id).getY();}else{a=CY.get("document").get("scrollTop");}this._showComments([d.id],a,false);if(d.replies.length>0||b){this._animateToAndFocus(a,c.id,b);}}},showSingleComment:function(a){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this._showSingleComment(a);this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},showFocusSingleComment:function(c,b,a){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this._showFocusSingleComment(c,b,a);this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},browse:function(a,b){var c=gIComments.browse(a,b);if(c!=null){this.showSingleComment(c);}},_showComments:function(c,b,a){this._q.add({fn:function(){gShowingAllComments=a;gIComments.hide();hideToc();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);if(parent){parent.document.getElementById("outer-north").scrollIntoView(true);}}}}gIComments.setPosition([gConf.iCommentLeftPadding,b]);gIComments.show();}});},_animateTo:function(a){this._q.add({fn:function(){gIComments.setAnimationToPositions(a);}},{id:"animationRun",autoContinue:false,fn:CY.bind(gIComments.runAnimations,gIComments)});},_animateToAndFocus:function(a,c,b){this._q.add({fn:function(){gIComments.setAnimationToPositionsAndFocus(a,c,b);}},{id:"animationRun",autoContinue:false,fn:CY.bind(gIComments.runAnimations,gIComments)});},_animateToTop:function(){var a=gIComments.getTopPosition();if(a!=null){this._animateTo(a[1]);}},animateToTop:function(){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this._animateToTop();this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},showAllComments:function(){checkForOpenedDialog(null,function(){gShowingAllComments=true;var a=CY.Array.map(gDb.comments,function(b){return b.id;});if(parent.$("#browse_by").val()=="scope"){a.sort(function(d,c){if(gDb.ordered_comment_ids.scope.indexOf(d)gDb.ordered_comment_ids.scope.indexOf(c)){return 1;}return 0;});}this.showComments(a,[0,30],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;});if(parent.$("#browse_by").val()=="scope"){a.sort(function(d,c){if(gDb.ordered_comment_ids.scope.indexOf(d)gDb.ordered_comment_ids.scope.indexOf(c)){return 1;}return 0;});}this.showComments(a,[0,30],true);},this,null);},showComments:function(c,b,a){checkForOpenedDialog(null,function(){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this._showComments(c,b[1],a);this._animateTo(b[1]);this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},this,null);},openComment:function(a){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});var b=gIComments.getTopPosition()[1];this._q.add({fn:function(){gIComments.open(a.commentId);gIComments.refresh(a.commentId);}});this._animateTo(b);this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},closeComment:function(a){checkForOpenedDialog(a,function(){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});var b=gIComments.getTopPosition()[1];this._q.add({fn:function(){var c=gDb.getComment(a.commentId);gIComments.close(a.commentId);if(c.reply_to_id!=null){gIComments.refresh(c.reply_to_id);}}});this._animateTo(b);this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},this,null);},activate:function(a){gIComments.activate(a.commentId);}};readyForAction=function(){return !gSync._iPreventClick;};gEditICommentHost=null;gEdit=null;dbgc=null;showEditForm=function(a){if(gEdit==null){gEdit={ids:{formId:CY.guid(),formTitleId:CY.guid(),nameInputId:CY.guid(),emailInputId:CY.guid(),titleInputId:CY.guid(),contentInputId:CY.guid(),tagsInputId:CY.guid(),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=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");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;}};gICommentForm=null;instanciateICommentForm=function(){gICommentForm={position:[CY.WidgetPositionExt.TL,CY.WidgetPositionExt.TL],formId:CY.guid(),formTitleId: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(),selectionPlaceId:CY.guid(),keyId:CY.guid(),currentSelId:CY.guid(),currentSelIdI:CY.guid(),addBtnId:CY.guid(),cancelBtnId:CY.guid(),closeBtnId:CY.guid()};if(!sv_loggedIn){gICommentForm.nameInputId=CY.guid();gICommentForm.emailInputId=CY.guid();}var c=getHtml(gICommentForm);var e=gLayout.getTopICommentsWidth();var b=new CY.Overlay({zIndex:3,shim:false,visible:false,headerContent:c.headerContent,bodyContent:c.bodyContent,xy:[10,10],width:e});b.get("contentBox").addClass("c-newcomment");b.render("#leftcolumn");if(!sv_loggedIn){CY.get("#"+gICommentForm.nameInputId).set("value",gPrefs.get("user","name"));CY.get("#"+gICommentForm.emailInputId).set("value",gPrefs.get("user","email"));}CY.get("#"+gICommentForm.formTitleId).set("innerHTML",gettext("New comment"));CY.get("#"+gICommentForm.formatInputId).set("value",gConf.defaultCommentFormat);CY.on("click",onSubmitICommentFormClick,"#"+gICommentForm.addBtnId);CY.on("click",onCancelICommentFormClick,"#"+gICommentForm.cancelBtnId);CY.on("click",onCancelICommentFormClick,"#"+gICommentForm.closeBtnId);gICommentForm.overlay=b;var d=null;d=new CY.Anim({node:b.get("boundingBox"),duration:0.3,easing:CY.Easing.easeOut});gICommentForm.animationHide=d;d.set("to",{opacity:0});gICommentForm["animationHide-handle"]=d.on("end",onICommentFormHideAnimEnd,gICommentForm);var a=null;a=new CY.Anim({node:b.get("boundingBox"),duration:0.3,easing:CY.Easing.easeOut});gICommentForm.animationShow=a;a.set("to",{opacity:1});gICommentForm["animationShow-handle"]=a.on("end",onICommentFormShowAnimEnd,gICommentForm);changeFormFieldsWidth(gICommentForm.formId,e);};cleanICommentForm=function(){CY.get("#"+gICommentForm.currentSelIdI).set("innerHTML",gNoSelectionYet);var a=gICommentForm.overlay.getStdModNode(CY.WidgetStdMod.BODY);a.queryAll(".comment_input").set("value","");CY.get("#"+gICommentForm.formatInputId).set("value",gConf.defaultCommentFormat);if(!sv_loggedIn){a.queryAll(".user_input").set("value","");}};onICommentFormHideAnimEnd=function(){this.overlay.hide();gSync.resume();};onICommentFormShowAnimEnd=function(){gSync.resume();};onSubmitICommentFormClick=function(){if(!sv_loggedIn){var b=CY.get("#"+gICommentForm.nameInputId).get("value");gPrefs.persist("user","name",b);var a=CY.get("#"+gICommentForm.emailInputId).get("value");gPrefs.persist("user","email",a);}gSync.saveComment(gICommentForm.formId);};onCancelICommentFormClick=function(){gSync.cancelICommentForm();};_updateICommentFormSelection=function(c,e,b,a){var d=CY.Node.get("#"+c.currentSelIdI);if(d!=null){d.set("innerHTML",e);}d=CY.get("#"+c.startWrapperInputId);if(d!=null){d.set("value",b.elt.id.substring("sv_".length));}d=CY.get("#"+c.startOffsetInputId);if(d!=null){d.set("value",b.offset);}d=CY.get("#"+c.endWrapperInputId);if(d!=null){d.set("value",a.elt.id.substring("sv_".length));}d=CY.get("#"+c.endOffsetInputId);if(d!=null){d.set("value",a.offset);}};updateICommentFormSelection=function(h){var i=(h==null)?"":h.text;if(i!=""){var f=i;var b=100;if(i.length>b){var a=i.substring(0,(i.substring(0,b/2)).lastIndexOf(" "));var d=i.substring(i.length-b/2);var c=d.substring(d.indexOf(" "));f=a+" ... "+c;}var e=_convertSelectionFromCCToCS(h.start);var g=_convertSelectionFromCCToCS(h.end);_updateICommentFormSelection(gICommentForm,f,e,g);if(gEdit!=null){_updateICommentFormSelection(gEdit.ids,f,e,g);}positionICommentForm();}};showICommentForm=function(){removeFormErrMsg(gICommentForm.formId);if(!sv_loggedIn){if(CY.get("#"+gICommentForm.nameInputId).get("value")==""){CY.get("#"+gICommentForm.nameInputId).set("value",gPrefs.get("user","name"));}if(CY.get("#"+gICommentForm.emailInputId).get("value")==""){CY.get("#"+gICommentForm.emailInputId).set("value",gPrefs.get("user","email"));}}gIComments.hide();hideToc();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});if(c<=e){b.set("y",b.get("y")+30);}a.setX(a.getX()+gConf.iCommentLeftPadding);}};Db=function(){this.comments=null;this.allComments=null;this.commentsByDbId={};this.allCommentsByDbId={};this.ordered_comment_ids={};};Db.prototype={init:function(){this.allComments=CY.JSON.parse(sv_comments);if(sv_read_only){this.initToReadOnly();}this._computeAllCommentsByDbId();this._reorder();},_del:function(a,e,g){var f=e[g];for(var c=0;cc){c=a;}}return c;},_upd:function(a,f,g){var e=false;for(var d=0,b=a.length;d0){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(q){var a={};if(q){for(key in q){if(key.indexOf("filter_")==0){a[key.substr("filter_".length)]=q[key];}}}else{if(gLayout.isInFrame()){a=parent.f_getFrameFilterData();}}var y=[];var z=[];var c="";if("name" in a){c=a.name;}this.filterByName(c,y,z);var s=[];var e=[];var F="";if("date" in a){F=a.date;}this.filterByDate(F,s,e);var k=[];var j=[];var w="";if("text" in a){w=a.text;}this.filterByText(w,k,j);var A=[];var p=[];var D="";if("tag" in a){D=a.tag;}this.filterByTag(D,A,p);var b=[];var g=[];var d="";if("cat" in a){d=a.cat;}this.filterByCat(d,b,g);var x=[];var h=[];var n="";if("state" in a){n=a.state;}this.filterByState(n,x,h);var f=[];var C=[];for(var B=0,m=y.length;Bc){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=f){this._a.push(c.setAnimationToPosition([k,h],f,b));}else{this._a.push(c.setAnimationToPosition([k,h]));}h+=c.getHeight();}}},_initAnimations:function(){this._a=[];this._nbEndedAnim=0;},runAnimations:function(){if(this._a.length==0){gSync.resetAutoContinue("animationRun");}else{CY.each(this._a,function(a){a.run();});}},whenAnimationsEnd:function(){gSync.resume();},whenAnimationsEndFocus:function(){gGETValues=CY.JSON.parse(sv_get_params);if("comment_id_key" in gGETValues){var b=gGETValues.comment_id_key;var a=gDb.getCommentByIdKey(b);if(a!=null){gIComments.getIComment(a.id).overlay.focus();}}gSync.resume();},whenAnimationsEndReply:function(){gGETValues=CY.JSON.parse(sv_get_params);if("comment_id_key" in gGETValues){var b=gGETValues.comment_id_key;var a=gDb.getCommentByIdKey(b);if(a!=null){gSync.showReplyForm(gIComments.getIComment(a.id));}}gSync.resume();},animationsEnded:function(){return((this._a.length==0)||(this._a.length==this._nbEndedAnim));},signalAnimationEnd:function(){this._nbEndedAnim++;},isTopActive:function(a){return((a!=null)&&(this._topActiveCommentDbId==a));},isAnyActive:function(){return(this._topActiveCommentDbId!=null);},activate:function(f){if(this._topActiveCommentDbId!=null){this.deactivate();}var e=gDb.getComment(f);var b=gDb.getPath(e);var a=b[b.length-1];var c=this._getChildren(a.id);CY.Array.each(c,function(g){g.activate();});this._topActiveCommentDbId=a.id;if(gLayout.isInFrame()){var d=gDb.browsingIndex(this._topActiveCommentDbId);parent.$("#browse_by option").each(function(){var g=1+d[this.value];parent.$("#c_browse_indx_"+this.value).html(""+g);});}showScope(a.id);},deactivate:function(){if(this._topActiveCommentDbId!=null){parent.$("#browse_by option").each(function(){parent.$("#c_browse_indx_"+this.value).html("-");});hideScopeAnyway();var a=this._getChildren(this._topActiveCommentDbId);CY.Array.each(a,function(b){b.deactivate();});this._topActiveCommentDbId=null;}},activateVisibleNext:function(){if(this._topActiveCommentDbId!=null){for(var d=0;d<2;d++){var f=(d==0)?0:this._c.length-1;var a=false;for(var e=f;(e>=0)&&e<=(this._c.length-1);){var c=this._c[e];if(c.commentId!=null&&c.isVisible()){a=a||(gDb.isChild(c.commentId,this._topActiveCommentDbId));if(a&&(!gDb.isChild(c.commentId,this._topActiveCommentDbId))){this.activate(c.commentId);return true;}}e=(d==0)?e+1:e-1;}}}return false;},browse:function(b,c){var a=c;if((c=="prev")&&!this.isAnyActive()){a="last";}if((c=="next")&&!this.isAnyActive()){a="first";}return gDb.browse(b,a,this._topActiveCommentDbId);}};gNewReplyHost=null;gNewReply=null;instanciateNewReplyForm=function(i){if(gNewReply==null){gNewReply={val:{name:gPrefs.get("user","name"),email:gPrefs.get("user","email"),title:"",content:"",tags:""},ids:{name:gPrefs.get("user","name"),email:gPrefs.get("user","email"),title:"",content:"",tags:"",formId:CY.guid(),nameInputId:CY.guid(),emailInputId:CY.guid(),titleInputId:CY.guid(),contentInputId:CY.guid(),keyInputId:CY.guid(),formatInputId:CY.guid(),tagsInputId:CY.guid(),parentCommentId:CY.guid(),addBtnId:CY.guid(),cancelBtnId:CY.guid()},handlers:{}};}gNewReplyHost=i;var b='
'+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);CY.get("#"+gNewReply.ids["contentInputId"]).focus();};cleanNewReplyForm=function(){if(gNewReplyHost!=null){var a=gNewReplyHost.overlay.getStdModNode(CY.WidgetStdMod.FOOTER);a.queryAll(".comment_input").set("value","");}};cancelNewReplyForm=function(){if(gNewReplyHost!=null){for(var b in gNewReply.handlers){if(gNewReply.handlers[b]!=null){gNewReply.handlers[b].detach();gNewReply.handlers[b]=null;}}gNewReplyHost.overlay.get("contentBox").query(".c-reply").removeClass("displaynone");var a=gNewReplyHost.overlay.getStdModNode(CY.WidgetStdMod.FOOTER);if(!sv_loggedIn){gNewReply.val["name"]=a.query(".n_name").get("value");gNewReply.val["email"]=a.query(".n_email").get("value");}gNewReply.val["title"]=a.query(".n_title").get("value");gNewReply.val["content"]=a.query(".n_content").get("value");gNewReply.val["tags"]=a.query(".n_tags").get("value");a.set("innerHTML","");gNewReplyHost=null;}};onAddNewReplyClick=function(){if(!sv_loggedIn){var b=CY.get("#"+gNewReply.ids["nameInputId"]).get("value");gPrefs.persist("user","name",b);var a=CY.get("#"+gNewReply.ids["emailInputId"]).get("value");gPrefs.persist("user","email",a);}gSync.saveComment(gNewReply.ids["formId"]);};onCancelNewReplyClick=function(){gSync.cancelReply();};c_persistPreference=function(b,a,c){gPrefs.persist(b,a,c);};c_readDefaultPreference=function(b,a){return gConf.defaultPrefs[b][a];};c_readPreference=function(b,a){return gPrefs.get(b,a);};c_resetPreferences=function(a){gPrefs.reset(a);};c_applyTextStyle=function(a){CY.use(a);};sliderValToPx=function(d){var a=CY.DOM.winWidth();if(gLayout.isInFrame()){a=parent.$(parent).width();}var b=d/100;b=Math.min(b,gConf.sliderFixedMin);b=Math.max(b,gConf.sliderFixedMax);var c=b*a;return Math.floor(c);};c_setCommentsColWidth=function(c){var a=sliderValToPx(c);gLayout.setLeftColumnWidth(a);var b=gLayout.getTopICommentsWidthFromWidth(a);gIComments.setWidth(b);gICommentForm.overlay.get("boundingBox").setStyle("width",b+"px");changeFormFieldsWidth(gICommentForm.formId,b);document.getElementById("the-toc").style.width=b+"px";if(gNewReply){changeFormFieldsWidth(gNewReply.ids["formId"],b);}if(gEdit){changeFormFieldsWidth(gEdit.ids["formId"],b);}};CY=null;gPrefs=null;gLayout=null;gDb=null;gIComments=null;gSync=null;gGETValues=null;gConf={iCommentLeftPadding:4,iCommentThreadPadding:12,defaultCommentFormat:"markdown",sliderFixedMin:0.9,sliderFixedMax:0.1,iCommentsInitAlloc:2,defaultPrefs:{text:{style:"text-modern-style"},user:{name:"",email:""},general:{animduration:"0.4"},comments:{threadpad:"1"},layout:{comments_col_width:"25"}}};if(sv_custom_font){gTextStyles={custom:gettext("custom"),modern:gettext("modern"),classic:gettext("classic"),code:gettext("code")};}else{gTextStyles={modern:gettext("modern"),classic:gettext("classic"),code:gettext("code")};}YUI({base:sv_media_url+"/js/lib/yui/"+c_yui_base+"/build/",timeout:10000}).use("text-modern-style","cookie","json","overlay","io-form","async-queue","event-mouseenter","anim","collection",function(a){CY=a;gPrefs=new Preferences();gPrefs.init();gLayout=new Layout();gLayout.init();if(sv_withComments){gDb=new Db();gDb.init();gIComments=new IComments();gIComments.init();}gSync=new Sync();gSync.init();CY.on("domready",onDomReady,this);});_reinit=function(a){gIComments.hide();gDb.initComments(a.commentIds);unpaintAllComments();renderCommentScopes();updateFilterResultsCount(a.nbDiscussions,a.nbComments,a.nbReplies);};reinit=function(b){var a=gDb.computeFilterResults(b);_reinit(a);};hideAll=function(){_reinit({commentIds:[],nbDiscussions:0,nbComments:0,nbReplies:0});};updateFilterResultsCount=function(f,a,b){var e=gDb.getCommentsAndRepliesCounts(true);var g=e[0],d=e[1];var c=(a!=0||b!=0)&&(g!=a||d!=b);if(gLayout.isInFrame()){parent.f_updateFilterCountDetailed(c);parent.f_updateFilterCountResult(f,a,b,g,d);}};updateResetFilterResultsCount=function(){var c=gDb.getCommentsAndRepliesCounts(false);var a=c[0],b=c[1];var d=a;updateFilterResultsCount(d,a,b);};renderCommentScopes=function(){for(var a=0;a0){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();}instanciateToc();},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();}if(gToc.empty){parent.$("#c_toc_btn").hide();}},timeout:5},{fn:function(){if(sv_withComments){reinit(gGETValues);initialConnect();}},timeout:5},{fn:function(){if(gLayout.isInFrame()){parent.f_interfaceUnfreeze();parent.f_removeLoadingMsg();}if("comment_id_key" in gGETValues){var e=gGETValues.comment_id_key;var g=gDb.getCommentByIdKey(e);if(g!=null){var f=gDb.getPath(g);var c=f[f.length-1];var d=gDb.getCommentByIdKey(e);if("comment_op" in gGETValues&&gGETValues.comment_op=="reply"){gSync.showFocusSingleComment(c,d,true);}else{gSync.showFocusSingleComment(c,d,false);}}}if("comments_auto_display" in gGETValues){gSync.showAllComments();}}});a.run();}; \ No newline at end of file diff -r 723261fb23fb -r ee0c833d1969 src/cm/media/js/client/c_edit_form.js --- a/src/cm/media/js/client/c_edit_form.js Thu Oct 10 11:16:05 2013 +0200 +++ b/src/cm/media/js/client/c_edit_form.js Tue Oct 15 12:12:50 2013 +0200 @@ -61,8 +61,10 @@ // => hides these inputs for a reply. if (comment.reply_to_id != null) { CY.get("#"+gEdit['ids']['changeScopeInputId']).addClass('displaynone') - CY.get("#"+gEdit['ids']['categoryInputId']).addClass('displaynone') - CY.get("#"+gEdit['ids']['categoryInputId']).ancestor().addClass('displaynone') + if (CY.get("#"+gEdit['ids']['categoryInputId'])) { + CY.get("#"+gEdit['ids']['categoryInputId']).addClass('displaynone') + CY.get("#"+gEdit['ids']['categoryInputId']).ancestor().addClass('displaynone') + } } changeScopeFormClick() ; // to adapt diff -r 723261fb23fb -r ee0c833d1969 src/cm/media/js/client/f_client-min.js --- a/src/cm/media/js/client/f_client-min.js Thu Oct 10 11:16:05 2013 +0200 +++ b/src/cm/media/js/client/f_client-min.js Tue Oct 15 12:12:50 2013 +0200 @@ -1,1 +1,1 @@ -onFadeEnd=function(){$(this).remove();};gLoadingMsg=null;enqueueLoadingMsg=function(){gLoadingMsg=_enqueueMsg(gettext("loading..."),"",null);};removeLoadingMsg=function(){if(gLoadingMsg!=null){gLoadingMsg.remove();gLoadingMsg=null;}};_enqueueMsg=function(d,b,c){var a=$(""+d+"").appendTo("#c-msg-wrapper").addClass("f-msg-cls").addClass(b);if(c){a.animate({opacity:0.95},c).fadeOut(2000,onFadeEnd);}return a;};enqueueMsg=function(c){var a="f-msg";var b=8000;_enqueueMsg(c,a,b);};enqueueErrorMsg=function(c){var a="f-msg-e";var b=4000;_enqueueMsg(c,a,b);};gFormats=[{actions:["print"],extension:"html",label:gettext("print from the browser")},{actions:["export"],extension:"html",label:gettext("download html file (.html)")},{actions:["export"],extension:"markdown",label:gettext("download markdown file (.mkd)")},{actions:["print"],extension:"pdf",label:gettext("print in PDF format")},{actions:["export"],extension:"pdf",label:gettext("download portable object format file (.pdf)")},{actions:["export"],extension:"latex",label:gettext("download latex file (.tex)")},{actions:["export"],extension:"odt",label:gettext("download open document file (.odt)")},{actions:["export"],extension:"doc",label:gettext("download microsoft word file (.doc)")},{actions:["export"],extension:"docx",label:gettext("download microsoft word 2007 file (.docx)")}];var pandoc_version_ary=sv_pandoc_version.split(".");if(parseInt(pandoc_version_ary[0])>1||(parseInt(pandoc_version_ary[0])==1&&parseInt(pandoc_version_ary[1])>8)){gFormats.push({actions:["export"],extension:"epub",label:gettext("download ebook (.epub)")});}gFormats.push({actions:["export"],extension:"xml",label:gettext("download XML file for re-importing text and comments")});gActions={print:{dialogTitle:gettext("Print text"),chooseFormatLabel:gettext("How do you want to print?"),defaultMethod:"pdf",defaultWithColors:"no",defaultWhichComments:"all"},"export":{dialogTitle:gettext("Export text"),chooseFormatLabel:gettext("Choose file format"),defaultMethod:"pdf",defaultWithColors:"no",defaultWhichComments:"all"}};gCurrentAction=null;_populateMethod=function(g){var f=$("#p_method").val();$("#p_method").html("");for(var d=0,c=gFormats.length;d"+gFormats[d]["label"]+"").appendTo("#p_method");}}}if(f){$("#p_method").val(f);}else{$("#p_method").val(gActions[gCurrentAction]["defaultMethod"]);}};_populateMarkersColorsChoice=function(b){var a=$("#p_color").val();$("#p_color").html("");$("").appendTo("#p_color");$("").appendTo("#p_color");if(a){$("#p_color").val(a);}else{$("#p_color").val(gActions[gCurrentAction]["defaultWithColors"]);}};_populateWhichComments=function(){var c=$("#p_comments").val();$("#p_comments").html("");var a=interpolate(gettext("all (%(nb_comments)s)"),{nb_comments:frames.text_view_comments.gDb.getCommentsNb(true)},true);var b=interpolate(gettext("current filtered ones (%(nb_comments)s)"),{nb_comments:frames.text_view_comments.gDb.getCommentsNb(false)},true);$("").appendTo($("#p_comments"));$("").appendTo($("#p_comments"));$("").appendTo($("#p_comments"));if(c){$("#p_comments").val(c);}else{$("#p_comments").val(gActions[gCurrentAction]["defaultWhichComments"]);}};_manageMarkersColorsChoice=function(){var f=$("#p_method").val();var e=$("#p_comments").val();var c=frames.text_view_comments.gDb.getCommentsNb(true);var d=frames.text_view_comments.gDb.getCommentsNb(false);var b=(e=="all")?c:d;var a;if(gCurrentAction=="print"){a=((b==0)||(e=="none"));}if(gCurrentAction=="export"){a=((b==0)||(e=="none")||(f=="markdown")||(f=="latex")||(f=="epub")||(f=="odt")||(f=="doc")||(f=="xml"));}if(a){$("#p_color").val("no");}$("#p_color").attr("disabled",a);};_initPrintDialog=function(){$("#p_comments").add($("#p_method")).change(function(){_manageMarkersColorsChoice();_prepareOpenInNewWindow();});var a={};a[gettext("Go !")]=function(){var d=$("#p_comments").val();var c=$("#p_color").val();var e=$("#p_method").val();var b=(gCurrentAction=="export")?"1":(e=="html")?"0":"1";var f=$("#print_export_form").attr("target_action").replace(/FoRmAt/,e).replace(/DoWnLoAd/,b).replace(/WhIcHCoMmEnT/,d).replace(/WiThCoLoR/,c);$("#print_export_form").attr("action",f);document.print_export_form.submit();$(this).dialog("close");};a[gettext("Cancel")]=function(){$(this).dialog("close");};$("#dialog_print_export").dialog({bgiframe:true,autoOpen:false,width:500,modal:true,buttons:a,close:function(){}});};openPrintDialog=function(){_openPrintExportDialog("print");};openExportDialog=function(){_openPrintExportDialog("export");};_prepareOpenInNewWindow=function(){var a=$("#p_method").val();if((a=="html")&&(gCurrentAction=="print")){$("#print_export_form").attr("target","_blank");}else{$("#print_export_form").removeAttr("target");}};_openPrintExportDialog=function(a){gCurrentAction=a;$("#ui-dialog-title-dialog_print_export").html(gActions[gCurrentAction]["dialogTitle"]);$("#how").html(gActions[gCurrentAction]["chooseFormatLabel"]);$("#print_export_action").val(a);_populateWhichComments();_populateMarkersColorsChoice();_populateMethod();_manageMarkersColorsChoice();_prepareOpenInNewWindow();$("#dialog_print_export").dialog("open");};var gResetOtherFieldsOnFilterFieldChange=true;var myDefaultOuterLayoutSettings={center:{paneSelector:".outer-center"},north:{size:50,spacing_open:0,closable:false,resizable:false}};var innerNorthPaneDefaults={innerNorthPaneOpened:"0",selectedTab:"0"};onInnerNorthPaneClose=function(){_setCookie("innerNorthPaneOpened","0");$("#add_comment_btn").css("top",63);if(document.getElementById("text_view_comments").contentDocument!=null){document.getElementById("text_view_comments").contentDocument.getElementById("the-toc").style.height=(parseInt(document.getElementById("text_view_comments").clientHeight)-50).toString()+"px";}return true;};onInnerNorthPaneOpen=function(){_setCookie("innerNorthPaneOpened","1");$("#add_comment_btn").css("top",159);if(document.getElementById("text_view_comments").contentDocument!=null){document.getElementById("text_view_comments").contentDocument.getElementById("the-toc").style.height=(parseInt(document.getElementById("text_view_comments").clientHeight)-50).toString()+"px";}return true;};var myDefaultInnerLayoutSettings={north:{size:98,spacing_open:8,spacing_closed:8,slidable:false,resizable:false,togglerLength_closed:"100%",togglerLength_open:"100%",togglerAlign_closed:"center",togglerTip_closed:gettext("click to show options"),togglerTip_open:gettext("click to hide options"),togglerContent_open:"arrow up",togglerContent_closed:"arrow down",initClosed:false,paneSelector:".inner-north",onopen:"onInnerNorthPaneOpen",onclose:"onInnerNorthPaneClose"}};var outerLayout,innerLayout;layoutFrames=function(){var a=$.cookie("innerNorthPaneOpened");myDefaultInnerLayoutSettings.north.initClosed=(a===null)?(innerNorthPaneDefaults.innerNorthPaneOpened=="0"):(a=="0");outerLayout=$("body").layout(myDefaultOuterLayoutSettings);innerLayout=$("div.outer-center").layout(myDefaultInnerLayoutSettings);if(myDefaultInnerLayoutSettings.north.initClosed){onInnerNorthPaneClose();}else{onInnerNorthPaneOpen();}};fillFilterTab=function(){var b=$("#c_filter");var a='
'+gettext("Text")+' 
'+gettext("Authors")+'  '+gettext("States")+' 
'+gettext("Dates")+'  '+gettext("Tags")+' 
'+gettext("Categories")+' 
';b.append($(a));$("#c_filter input[type='text']").add("#c_filter select").addClass("c_filter_field");$("#filter_name").add("#filter_date").add("#filter_tag").add("#filter_cat").add("#filter_state").change(function(){if(frames.text_view_comments.readyForAction()){var c=$(this);frames.text_view_comments.checkForOpenedDialog(null,function(){applyFilter(c);});}});$("#c_filter_btn").click(function(){if(frames.text_view_comments.readyForAction()){var c=$("#filter_text");frames.text_view_comments.checkForOpenedDialog(null,function(){applyFilter(c);});}});$("#filter_text").keyup(function(c){if(c.keyCode==13){$("#c_filter_btn").click();}});$("#c_filterreset_btn").click(function(){if(frames.text_view_comments.readyForAction()){frames.text_view_comments.checkForOpenedDialog(null,function(){resetFilter();});}});$("#c_filterhideall_btn").click(function(){if(frames.text_view_comments.readyForAction()){frames.text_view_comments.checkForOpenedDialog(null,function(){frames.text_view_comments.hideAll();});}});};fillTopToolbar=function(){var l=$("#outer-north");var g=gettext("view previous comment");var h=gettext("view next comment");var k=gettext("view first comment");var b=gettext("view last next comment");var d=gettext("view all comments");var p=gettext("view all detached comments");var m=gettext("toggle advance interface");var r=gettext("toggle table of contents");var c=gettext("print document with/without comments");var q=gettext("export document with/without comments");var a=gettext("toggle full screen view");var i=gettext("text feed");var j=gettext("add a comment");var n='
'+a+''+c+''+q+''+i+'
-/   ('+gettext("filter:")+' /  /), '+gettext("browse by:")+' '+k+''+g+''+h+''+b+''+d+''+p+''+r+'
';l.prepend($(n));$("#add_comment_btn").click(function(){if(frames.text_view_comments.readyForAction()){frames.text_view_comments.checkForOpenedDialog(null,function(){frames.text_view_comments.gSync.showCommentForm(null);});}});var f=function(){$("#browse_by option").each(function(){$("#c_browse_indx_"+this.value).hide();});$("#c_browse_indx_"+$("#browse_by").val()).show();};var e=$.cookie("browse_by");e=(e==null)?"location":e;_setCookie("browse_by",$("#browse_by").val());$("#browse_by option[value="+e+"]").attr("selected",true);f();$("#browse_by").change(function(){_setCookie("browse_by",$("#browse_by").val());f();});var o=function(s){if(frames.text_view_comments.readyForAction()){frames.text_view_comments.checkForOpenedDialog(null,function(){frames.text_view_comments.browse($("#browse_by").val(),s);});}};$("#c_browse_prev").click(function(){o("prev");});$("#c_browse_next").click(function(){o("next");});$("#c_browse_first").click(function(){o("first");});$("#c_browse_last").click(function(){o("last");});$("#c_browse_all").click(function(){if(frames.text_view_comments.readyForAction()){frames.text_view_comments.checkForOpenedDialog(null,function(){frames.text_view_comments.gSync.showAllComments();});}});$("#c_browse_scope_removed").click(function(){if(frames.text_view_comments.readyForAction()){frames.text_view_comments.checkForOpenedDialog(null,function(){frames.text_view_comments.gSync.showScopeRemovedComments();});}});$("#c_print_btn").click(function(){if(frames.text_view_comments.readyForAction()){var s=frames.text_view_comments.gDb.getFilteredCommentIdsAsString();frames.text_view_comments.CY.log($("#filteredIds").val(s));openPrintDialog();}});$("#c_export_btn").click(function(){if(frames.text_view_comments.readyForAction()){var s=frames.text_view_comments.gDb.getFilteredCommentIdsAsString();frames.text_view_comments.CY.log($("#filteredIds").val(s));openExportDialog();}});if(frames.text_view_comments.gLayout.isInComentSite()){$("#c_fullscreen_btn").click(function(){toggleFrameSize();});}$("#c_advanced_btn").click(function(){$(".ui-layout-toggler").click();});setThreadPref=function(){var t=frames.text_view_comments.c_readPreference("comments","threadpad");var u=sv_media_url+"/img/unthread_box.png";var s=gettext("unthread discussions");if(t=="0"){u=sv_media_url+"/img/thread_box.png";s=gettext("thread discussions");}$("#c_thread_unthread_img").attr("src",u).attr("alt",s).attr("title",s);};setThreadPref();$("#c_thread_unthread").click(function(){var t=frames.text_view_comments.c_readPreference("comments","threadpad");var s=(t=="0")?"1":"0";frames.text_view_comments.c_persistPreference("comments","threadpad",s);setThreadPref();frames.text_view_comments.gSync.animateToTop();});$("#c_toc_btn").click(function(){if(frames.text_view_comments.readyForAction()){frames.text_view_comments.checkForOpenedDialog(null,function(){frames.text_view_comments.toggleTocFn();});}});};onSliderStop=function(){var a=$("#c_slider").slider("value");if(a>(frames.text_view_comments.gConf.sliderFixedMin*100)){$("#c_slider").slider("value",[90]);}if(a<(frames.text_view_comments.gConf.sliderFixedMax*100)){$("#c_slider").slider("value",[10]);}frames.text_view_comments.c_setCommentsColWidth(a);frames.text_view_comments.c_persistPreference("layout","comments_col_width",a);};fillTextPreferencesTab=function(){var d=$("#c_text_preferences");d.append($("
"+gettext("Text style")+' 
'));var e=frames.text_view_comments.gTextStyles;for(var c in e){$("#c_textpref_style").append($(""));}var a=function(){var g=frames.text_view_comments.gTextStyles;var h=$("#c_textpref_style").val();for(var f in g){if(f==h){frames.text_view_comments.CY.get("#textcontainer").addClass(f);}else{frames.text_view_comments.CY.get("#textcontainer").removeClass(f);}}};var b=function(){var f=frames.text_view_comments.c_readPreference("text","style");$("#c_textpref_style").val(f);};$("#c_textpref_style").change(function(f){frames.text_view_comments.c_persistPreference("text","style",$("#c_textpref_style").val());a();});b();a();};fillPreferencesTab=function(){var b=$("#c_preferences");var a='
'+gettext("Animation duration")+' 
'+gettext("(0.001 to 1 second)")+"
";b.append($(a));setPreferencesFieldsValue=function(){var c=frames.text_view_comments.c_readPreference("general","animduration");$("#c_pref_animduration").val(c);};setPreferencesFieldsValue();$("#c_pref_animduration").blur(function(){var c=parseFloat($(this).val());if(isNaN(c)||(c<=0)||(c>1)){c=frames.text_view_comments.c_readDefaultPreference("general","animduration");}$(this).val(c);});$("#c_pref_reset_btn").click(function(){frames.text_view_comments.c_resetPreferences(["general"]);setPreferencesFieldsValue();enqueueMsg(gettext("preferences reset (will apply on next load)"));});$("#c_pref_save_btn").click(function(){frames.text_view_comments.c_persistPreference("general","animduration",$("#c_pref_animduration").val());enqueueMsg(gettext("preferences saved (will apply on next load)"));});};initFrame=function(){_initYesNoDialog();_initPrintDialog();$(window).resize(function(){onSliderStop();});$("#c_slider").slider({animate:true,range:"min",value:frames.text_view_comments.c_readPreference("layout","comments_col_width"),min:1,iframeFix:true,max:100,slide:function(a,b){var c=b.value;frames.text_view_comments.c_setCommentsColWidth(c);},stop:function(a,b){onSliderStop();}});_initTabs();f_interfaceFreeze();};_initTabs=function(){$(".inner-north").tabs();var a=$.cookie("selectedTab");a=(a===null)?innerNorthPaneDefaults.selectedTab:parseInt(a);$(".inner-north").tabs("option","active",a);$(".inner-north").bind("tabsactivate",function(b,c){_setCookie("selectedTab",c.index);});};_initYesNoDialog=function(){$("#dialog_h").dialog({autoOpen:false,modal:true});};_setCookie=function(a,c){var b=new Date();b.setFullYear(2100,0,1);$.cookie(a,c,{expires:b,path:"/"});};f_getFrameFilterData=function(){var d=$("#filter_name").val();var c=$("#filter_date").val();var f=$("#filter_text").val();var b=$("#filter_tag").val();var a=$("#filter_cat").val();var e=$("#filter_state").val();return{name:d,date:c,text:f,tag:b,cat:a,state:e};};f_setFilterValue=function(a){for(key in a){if(key.indexOf("filter_")==0){$("#"+key).val(a[key]);}}};f_isFrameFilterFieldsInit=function(){var b=f_getFrameFilterData();var a=true;for(key in b){a=a&&(b[key]=="");}return a;};initFilterFields=function(){$(".c_filter_field").val("");};resetFilter=function(){initFilterFields();frames.text_view_comments.reinit();enqueueMsg(gettext("filter reset"));};applyFilter=function(a){var b=a.val();if(gResetOtherFieldsOnFilterFieldChange){initFilterFields();a.val(b);}frames.text_view_comments.reinit();enqueueMsg(gettext("filter applied"));};f_updateFilterCountResult=function(d,a,b,e,c){$("#c_f_res_nb_dis").html(d);$("#c_f_res_nb_dis_txt").html(ngettext("discussion","discussions",d));$("#c_f_res_nb_com").html(a);$("#c_f_res_nb_tot_com").html(e);$("#c_f_res_nb_com_txt").html(ngettext("comment","comments",a));$("#c_f_res_nb_rep").html(b);$("#c_f_res_nb_tot_rep").html(c);$("#c_f_res_nb_rep_txt").html(" "+ngettext("reply","replies",b));$("#c_filter_results").show();};f_updateFilterCountDetailed=function(a){if(a){$("#c_f_res_details").show();$("c_browse_all").val("View all (filtered) comments");}else{$("#c_f_res_details").hide();$("#c_browse_all").val("View all comments");}};f_updateFilterData=function(f){var h=$("#filter_name option:selected").attr("name");var l=gettext("all");$("#filter_name option").remove();$("#filter_name").append($(""));for(var c=0,b=f.names.length;c"+m.display+" ("+m.nb_comments+")"));}$("#filter_name option[name="+h+"]").attr("selected",true);var a=$("#filter_date option:selected").attr("name");$("#filter_date option").remove();$("#filter_date").append($(""));for(var c=0,b=f.dates.length;c"+k+""));}$("#filter_date option[name="+a+"]").attr("selected",true);var j=$("#filter_tag option:selected").attr("name");$("#filter_tag option").remove();$("#filter_tag").append($(""));for(var c=0,b=f.tags.length;c"+m.name+" ("+m.nb_comments+")"));}$("#filter_tag option[name="+j+"]").attr("selected",true);var e=$("#filter_cat option:selected").attr("cat");$("#filter_cat option").remove();categories=frames.text_view_comments.CY.JSON.parse(frames.text_view_comments.sv_categories);if(categories.hasOwnProperty("0")){$("#filter_cat").append($(""));for(var c=0,b=f.categories.length;c"+categories[m.cat]+" ("+m.nb_comments+")"));}}$("#filter_cat option[name="+e+"]").attr("selected",true);}else{$("#filter_cat").remove();$("#filter_cat_label").remove();}var d=$("#filter_state option:selected").attr("state");$("#filter_state option").remove();$("#filter_state").append($(""));for(var c=0,b=f.states.length;c"+gettext(m.state)+" ("+m.nb_comments+")"));}$("#filter_state option[name="+d+"]").attr("selected",true);};f_interfaceUnfreeze=function(){for(var b=0,a=$(".c_tab").length;b1||(parseInt(pandoc_version_ary[0])==1&&parseInt(pandoc_version_ary[1])>8)){gFormats.push({actions:["export"],extension:"epub",label:gettext("download ebook (.epub)")});}gFormats.push({actions:["export"],extension:"xml",label:gettext("download XML file for re-importing text and comments")});gActions={print:{dialogTitle:gettext("Print text"),chooseFormatLabel:gettext("How do you want to print?"),defaultMethod:"pdf",defaultWithColors:"no",defaultWhichComments:"all"},"export":{dialogTitle:gettext("Export text"),chooseFormatLabel:gettext("Choose file format"),defaultMethod:"pdf",defaultWithColors:"no",defaultWhichComments:"all"}};gCurrentAction=null;_populateMethod=function(g){var f=$("#p_method").val();$("#p_method").html("");for(var d=0,c=gFormats.length;d"+gFormats[d]["label"]+"").appendTo("#p_method");}}}if(f){$("#p_method").val(f);}else{$("#p_method").val(gActions[gCurrentAction]["defaultMethod"]);}};_populateMarkersColorsChoice=function(b){var a=$("#p_color").val();$("#p_color").html("");$("").appendTo("#p_color");$("").appendTo("#p_color");if(a){$("#p_color").val(a);}else{$("#p_color").val(gActions[gCurrentAction]["defaultWithColors"]);}};_populateWhichComments=function(){var c=$("#p_comments").val();$("#p_comments").html("");var a=interpolate(gettext("all (%(nb_comments)s)"),{nb_comments:frames.text_view_comments.gDb.getCommentsNb(true)},true);var b=interpolate(gettext("current filtered ones (%(nb_comments)s)"),{nb_comments:frames.text_view_comments.gDb.getCommentsNb(false)},true);$("").appendTo($("#p_comments"));$("").appendTo($("#p_comments"));$("").appendTo($("#p_comments"));if(c){$("#p_comments").val(c);}else{$("#p_comments").val(gActions[gCurrentAction]["defaultWhichComments"]);}};_manageMarkersColorsChoice=function(){var f=$("#p_method").val();var e=$("#p_comments").val();var c=frames.text_view_comments.gDb.getCommentsNb(true);var d=frames.text_view_comments.gDb.getCommentsNb(false);var b=(e=="all")?c:d;var a;if(gCurrentAction=="print"){a=((b==0)||(e=="none"));}if(gCurrentAction=="export"){a=((b==0)||(e=="none")||(f=="markdown")||(f=="latex")||(f=="epub")||(f=="odt")||(f=="doc")||(f=="xml"));}if(a){$("#p_color").val("no");}$("#p_color").attr("disabled",a);};_initPrintDialog=function(){$("#p_comments").add($("#p_method")).change(function(){_manageMarkersColorsChoice();_prepareOpenInNewWindow();});var a={};a[gettext("Go !")]=function(){var d=$("#p_comments").val();var c=$("#p_color").val();var e=$("#p_method").val();var b=(gCurrentAction=="export")?"1":(e=="html")?"0":"1";var f=$("#print_export_form").attr("target_action").replace(/FoRmAt/,e).replace(/DoWnLoAd/,b).replace(/WhIcHCoMmEnT/,d).replace(/WiThCoLoR/,c);$("#print_export_form").attr("action",f);document.print_export_form.submit();$(this).dialog("close");};a[gettext("Cancel")]=function(){$(this).dialog("close");};$("#dialog_print_export").dialog({bgiframe:true,autoOpen:false,width:500,modal:true,buttons:a,close:function(){}});};openPrintDialog=function(){_openPrintExportDialog("print");};openExportDialog=function(){_openPrintExportDialog("export");};_prepareOpenInNewWindow=function(){var a=$("#p_method").val();if((a=="html")&&(gCurrentAction=="print")){$("#print_export_form").attr("target","_blank");}else{$("#print_export_form").removeAttr("target");}};_openPrintExportDialog=function(a){gCurrentAction=a;$("#ui-dialog-title-dialog_print_export").html(gActions[gCurrentAction]["dialogTitle"]);$("#how").html(gActions[gCurrentAction]["chooseFormatLabel"]);$("#print_export_action").val(a);_populateWhichComments();_populateMarkersColorsChoice();_populateMethod();_manageMarkersColorsChoice();_prepareOpenInNewWindow();$("#dialog_print_export").dialog("open");};onFadeEnd=function(){$(this).remove();};gLoadingMsg=null;enqueueLoadingMsg=function(){gLoadingMsg=_enqueueMsg(gettext("loading..."),"",null);};removeLoadingMsg=function(){if(gLoadingMsg!=null){gLoadingMsg.remove();gLoadingMsg=null;}};_enqueueMsg=function(d,b,c){var a=$(""+d+"").appendTo("#c-msg-wrapper").addClass("f-msg-cls").addClass(b);if(c){a.animate({opacity:0.95},c).fadeOut(2000,onFadeEnd);}return a;};enqueueMsg=function(c){var a="f-msg";var b=8000;_enqueueMsg(c,a,b);};enqueueErrorMsg=function(c){var a="f-msg-e";var b=4000;_enqueueMsg(c,a,b);};var gResetOtherFieldsOnFilterFieldChange=true;var myDefaultOuterLayoutSettings={center:{paneSelector:".outer-center"},north:{size:50,spacing_open:0,closable:false,resizable:false}};var innerNorthPaneDefaults={innerNorthPaneOpened:"0",selectedTab:"0"};onInnerNorthPaneClose=function(){_setCookie("innerNorthPaneOpened","0");$("#add_comment_btn").css("top",63);if(document.getElementById("text_view_comments").contentDocument!=null){document.getElementById("text_view_comments").contentDocument.getElementById("the-toc").style.height=(parseInt(document.getElementById("text_view_comments").clientHeight)-50).toString()+"px";}return true;};onInnerNorthPaneOpen=function(){_setCookie("innerNorthPaneOpened","1");$("#add_comment_btn").css("top",159);if(document.getElementById("text_view_comments").contentDocument!=null){document.getElementById("text_view_comments").contentDocument.getElementById("the-toc").style.height=(parseInt(document.getElementById("text_view_comments").clientHeight)-50).toString()+"px";}return true;};var myDefaultInnerLayoutSettings={north:{size:98,spacing_open:8,spacing_closed:8,slidable:false,resizable:false,togglerLength_closed:"100%",togglerLength_open:"100%",togglerAlign_closed:"center",togglerTip_closed:gettext("click to show options"),togglerTip_open:gettext("click to hide options"),togglerContent_open:"arrow up",togglerContent_closed:"arrow down",initClosed:false,paneSelector:".inner-north",onopen:"onInnerNorthPaneOpen",onclose:"onInnerNorthPaneClose"}};var outerLayout,innerLayout;layoutFrames=function(){var a=$.cookie("innerNorthPaneOpened");myDefaultInnerLayoutSettings.north.initClosed=(a===null)?(innerNorthPaneDefaults.innerNorthPaneOpened=="0"):(a=="0");outerLayout=$("body").layout(myDefaultOuterLayoutSettings);innerLayout=$("div.outer-center").layout(myDefaultInnerLayoutSettings);if(myDefaultInnerLayoutSettings.north.initClosed){onInnerNorthPaneClose();}else{onInnerNorthPaneOpen();}};fillFilterTab=function(){var b=$("#c_filter");var a='
'+gettext("Text")+' 
'+gettext("Authors")+'  '+gettext("States")+' 
'+gettext("Dates")+'  '+gettext("Tags")+' 
'+gettext("Categories")+' 
';b.append($(a));$("#c_filter input[type='text']").add("#c_filter select").addClass("c_filter_field");$("#filter_name").add("#filter_date").add("#filter_tag").add("#filter_cat").add("#filter_state").change(function(){if(frames.text_view_comments.readyForAction()){var c=$(this);frames.text_view_comments.checkForOpenedDialog(null,function(){applyFilter(c);});}});$("#c_filter_btn").click(function(){if(frames.text_view_comments.readyForAction()){var c=$("#filter_text");frames.text_view_comments.checkForOpenedDialog(null,function(){applyFilter(c);});}});$("#filter_text").keyup(function(c){if(c.keyCode==13){$("#c_filter_btn").click();}});$("#c_filterreset_btn").click(function(){if(frames.text_view_comments.readyForAction()){frames.text_view_comments.checkForOpenedDialog(null,function(){resetFilter();});}});$("#c_filterhideall_btn").click(function(){if(frames.text_view_comments.readyForAction()){frames.text_view_comments.checkForOpenedDialog(null,function(){frames.text_view_comments.hideAll();});}});};fillTopToolbar=function(){var l=$("#outer-north");var g=gettext("view previous comment");var h=gettext("view next comment");var k=gettext("view first comment");var b=gettext("view last next comment");var d=gettext("view all comments");var p=gettext("view all detached comments");var m=gettext("toggle advance interface");var r=gettext("toggle table of contents");var c=gettext("print document with/without comments");var q=gettext("export document with/without comments");var a=gettext("toggle full screen view");var i=gettext("text feed");var j=gettext("add a comment");var n='
'+a+''+c+''+q+''+i+'
-/   ('+gettext("filter:")+' /  /), '+gettext("browse by:")+' '+k+''+g+''+h+''+b+''+d+''+p+''+r+'
';l.prepend($(n));$("#add_comment_btn").click(function(){if(frames.text_view_comments.readyForAction()){frames.text_view_comments.checkForOpenedDialog(null,function(){frames.text_view_comments.gSync.showCommentForm(null);});}});var f=function(){$("#browse_by option").each(function(){$("#c_browse_indx_"+this.value).hide();});$("#c_browse_indx_"+$("#browse_by").val()).show();};var e=$.cookie("browse_by");e=(e==null)?"location":e;_setCookie("browse_by",$("#browse_by").val());$("#browse_by option[value="+e+"]").attr("selected",true);f();$("#browse_by").change(function(){_setCookie("browse_by",$("#browse_by").val());f();});var o=function(s){if(frames.text_view_comments.readyForAction()){frames.text_view_comments.checkForOpenedDialog(null,function(){frames.text_view_comments.browse($("#browse_by").val(),s);});}};$("#c_browse_prev").click(function(){o("prev");});$("#c_browse_next").click(function(){o("next");});$("#c_browse_first").click(function(){o("first");});$("#c_browse_last").click(function(){o("last");});$("#c_browse_all").click(function(){if(frames.text_view_comments.readyForAction()){frames.text_view_comments.checkForOpenedDialog(null,function(){frames.text_view_comments.gSync.showAllComments();});}});$("#c_browse_scope_removed").click(function(){if(frames.text_view_comments.readyForAction()){frames.text_view_comments.checkForOpenedDialog(null,function(){frames.text_view_comments.gSync.showScopeRemovedComments();});}});$("#c_print_btn").click(function(){if(frames.text_view_comments.readyForAction()){var s=frames.text_view_comments.gDb.getFilteredCommentIdsAsString();frames.text_view_comments.CY.log($("#filteredIds").val(s));openPrintDialog();}});$("#c_export_btn").click(function(){if(frames.text_view_comments.readyForAction()){var s=frames.text_view_comments.gDb.getFilteredCommentIdsAsString();frames.text_view_comments.CY.log($("#filteredIds").val(s));openExportDialog();}});if(frames.text_view_comments.gLayout.isInComentSite()){$("#c_fullscreen_btn").click(function(){toggleFrameSize();});}$("#c_advanced_btn").click(function(){$(".ui-layout-toggler").click();});setThreadPref=function(){var t=frames.text_view_comments.c_readPreference("comments","threadpad");var u=sv_media_url+"/img/unthread_box.png";var s=gettext("unthread discussions");if(t=="0"){u=sv_media_url+"/img/thread_box.png";s=gettext("thread discussions");}$("#c_thread_unthread_img").attr("src",u).attr("alt",s).attr("title",s);};setThreadPref();$("#c_thread_unthread").click(function(){var t=frames.text_view_comments.c_readPreference("comments","threadpad");var s=(t=="0")?"1":"0";frames.text_view_comments.c_persistPreference("comments","threadpad",s);setThreadPref();frames.text_view_comments.gSync.animateToTop();});$("#c_toc_btn").click(function(){if(frames.text_view_comments.readyForAction()){frames.text_view_comments.checkForOpenedDialog(null,function(){frames.text_view_comments.toggleTocFn();});}});};onSliderStop=function(){var a=$("#c_slider").slider("value");if(a>(frames.text_view_comments.gConf.sliderFixedMin*100)){$("#c_slider").slider("value",[90]);}if(a<(frames.text_view_comments.gConf.sliderFixedMax*100)){$("#c_slider").slider("value",[10]);}frames.text_view_comments.c_setCommentsColWidth(a);frames.text_view_comments.c_persistPreference("layout","comments_col_width",a);};fillTextPreferencesTab=function(){var d=$("#c_text_preferences");d.append($("
"+gettext("Text style")+' 
'));var e=frames.text_view_comments.gTextStyles;for(var c in e){$("#c_textpref_style").append($(""));}var a=function(){var g=frames.text_view_comments.gTextStyles;var h=$("#c_textpref_style").val();for(var f in g){if(f==h){frames.text_view_comments.CY.get("#textcontainer").addClass(f);}else{frames.text_view_comments.CY.get("#textcontainer").removeClass(f);}}};var b=function(){var f=frames.text_view_comments.c_readPreference("text","style");$("#c_textpref_style").val(f);};$("#c_textpref_style").change(function(f){frames.text_view_comments.c_persistPreference("text","style",$("#c_textpref_style").val());a();});b();a();};fillPreferencesTab=function(){var b=$("#c_preferences");var a='
'+gettext("Animation duration")+' 
'+gettext("(0.001 to 1 second)")+"
";b.append($(a));setPreferencesFieldsValue=function(){var c=frames.text_view_comments.c_readPreference("general","animduration");$("#c_pref_animduration").val(c);};setPreferencesFieldsValue();$("#c_pref_animduration").blur(function(){var c=parseFloat($(this).val());if(isNaN(c)||(c<=0)||(c>1)){c=frames.text_view_comments.c_readDefaultPreference("general","animduration");}$(this).val(c);});$("#c_pref_reset_btn").click(function(){frames.text_view_comments.c_resetPreferences(["general"]);setPreferencesFieldsValue();enqueueMsg(gettext("preferences reset (will apply on next load)"));});$("#c_pref_save_btn").click(function(){frames.text_view_comments.c_persistPreference("general","animduration",$("#c_pref_animduration").val());enqueueMsg(gettext("preferences saved (will apply on next load)"));});};initFrame=function(){_initYesNoDialog();_initPrintDialog();$(window).resize(function(){onSliderStop();});$("#c_slider").slider({animate:true,range:"min",value:frames.text_view_comments.c_readPreference("layout","comments_col_width"),min:1,iframeFix:true,max:100,slide:function(a,b){var c=b.value;frames.text_view_comments.c_setCommentsColWidth(c);},stop:function(a,b){onSliderStop();}});_initTabs();f_interfaceFreeze();};_initTabs=function(){$(".inner-north").tabs();var a=$.cookie("selectedTab");a=(a===null)?innerNorthPaneDefaults.selectedTab:parseInt(a);$(".inner-north").tabs("option","active",a);$(".inner-north").bind("tabsactivate",function(b,c){_setCookie("selectedTab",c.index);});};_initYesNoDialog=function(){$("#dialog_h").dialog({autoOpen:false,modal:true});};_setCookie=function(a,c){var b=new Date();b.setFullYear(2100,0,1);$.cookie(a,c,{expires:b,path:"/"});};f_getFrameFilterData=function(){var d=$("#filter_name").val();var c=$("#filter_date").val();var f=$("#filter_text").val();var b=$("#filter_tag").val();var a=$("#filter_cat").val();var e=$("#filter_state").val();return{name:d,date:c,text:f,tag:b,cat:a,state:e};};f_setFilterValue=function(a){for(key in a){if(key.indexOf("filter_")==0){$("#"+key).val(a[key]);}}};f_isFrameFilterFieldsInit=function(){var b=f_getFrameFilterData();var a=true;for(key in b){a=a&&(b[key]=="");}return a;};initFilterFields=function(){$(".c_filter_field").val("");};resetFilter=function(){initFilterFields();frames.text_view_comments.reinit();enqueueMsg(gettext("filter reset"));};applyFilter=function(a){var b=a.val();if(gResetOtherFieldsOnFilterFieldChange){initFilterFields();a.val(b);}frames.text_view_comments.reinit();enqueueMsg(gettext("filter applied"));};f_updateFilterCountResult=function(d,a,b,e,c){$("#c_f_res_nb_dis").html(d);$("#c_f_res_nb_dis_txt").html(ngettext("discussion","discussions",d));$("#c_f_res_nb_com").html(a);$("#c_f_res_nb_tot_com").html(e);$("#c_f_res_nb_com_txt").html(ngettext("comment","comments",a));$("#c_f_res_nb_rep").html(b);$("#c_f_res_nb_tot_rep").html(c);$("#c_f_res_nb_rep_txt").html(" "+ngettext("reply","replies",b));$("#c_filter_results").show();};f_updateFilterCountDetailed=function(a){if(a){$("#c_f_res_details").show();$("c_browse_all").val("View all (filtered) comments");}else{$("#c_f_res_details").hide();$("#c_browse_all").val("View all comments");}};f_updateFilterData=function(f){var h=$("#filter_name option:selected").attr("name");var l=gettext("all");$("#filter_name option").remove();$("#filter_name").append($(""));for(var c=0,b=f.names.length;c"+m.display+" ("+m.nb_comments+")"));}$("#filter_name option[name="+h+"]").attr("selected",true);var a=$("#filter_date option:selected").attr("name");$("#filter_date option").remove();$("#filter_date").append($(""));for(var c=0,b=f.dates.length;c"+k+""));}$("#filter_date option[name="+a+"]").attr("selected",true);var j=$("#filter_tag option:selected").attr("name");$("#filter_tag option").remove();$("#filter_tag").append($(""));for(var c=0,b=f.tags.length;c"+m.name+" ("+m.nb_comments+")"));}$("#filter_tag option[name="+j+"]").attr("selected",true);var e=$("#filter_cat option:selected").attr("cat");$("#filter_cat option").remove();categories=frames.text_view_comments.CY.JSON.parse(frames.text_view_comments.sv_categories);if(categories.hasOwnProperty("0")){$("#filter_cat").append($(""));for(var c=0,b=f.categories.length;c"+categories[m.cat]+" ("+m.nb_comments+")"));}}$("#filter_cat option[name="+e+"]").attr("selected",true);}else{$("#filter_cat").remove();$("#filter_cat_label").remove();}var d=$("#filter_state option:selected").attr("state");$("#filter_state option").remove();$("#filter_state").append($(""));for(var c=0,b=f.states.length;c"+gettext(m.state)+" ("+m.nb_comments+")"));}$("#filter_state option[name="+d+"]").attr("selected",true);};f_interfaceUnfreeze=function(){for(var b=0,a=$(".c_tab").length;b {% else %} - + {% endif %} diff -r 723261fb23fb -r ee0c833d1969 src/cm/templates/site/text_view_frame.html --- a/src/cm/templates/site/text_view_frame.html Thu Oct 10 11:16:05 2013 +0200 +++ b/src/cm/templates/site/text_view_frame.html Tue Oct 15 12:12:50 2013 +0200 @@ -29,7 +29,7 @@ {% else %} - + {% endif %}