# HG changeset patch # User raph # Date 1279203838 -7200 # Node ID c2c262ac12731bfd410e6f4fa7530fa48da94c75 # Parent 2c52e4453bf761b9fad3bf095b16990ad2b97250 do not show permalink if prefix is used in embed params / minified client update diff -r 2c52e4453bf7 -r c2c262ac1273 src/cm/media/js/client/c_client-min.js --- a/src/cm/media/js/client/c_client-min.js Thu Jul 15 16:10:55 2010 +0200 +++ b/src/cm/media/js/client/c_client-min.js Thu Jul 15 16:23:58 2010 +0200 @@ -1,1 +1,1 @@ -hasPerm=function(a){return(-1!=CY.Array.indexOf(sv_user_permissions,a));};Layout=function(){};Layout.prototype={init:function(){},isInFrame:function(){return(!CY.Lang.isUndefined(parent)&&parent.location!=location&&CY.Lang.isFunction(parent.f_getFrameFilterData));},isInComentSite:function(){var 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();}}};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;b0){this._animateTo(a);}}},showSingleComment:function(a){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this._showSingleComment(a);this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},browse:function(a,b){var c=gIComments.browse(a,b);if(c!=null){this.showSingleComment(c);}},_showComments:function(c,b,a){this._q.add({fn:function(){gShowingAllComments=a;gIComments.hide();var d=CY.Array.map(c,function(g){return gDb.getComment(g);});var f=gDb.getThreads(d);gIComments.fetch(f);if(c.length>0){if(a){CY.get("document").set("scrollTop",0);}else{gIComments.activate(c[0]);var e=CY.get(".c-id-"+c[0]);if(e&&!e.inViewportRegion()){e.scrollIntoView(true);}}}gIComments.setPosition([gConf.iCommentLeftPadding,b]);gIComments.show();}});},_animateTo:function(a){this._q.add({fn:function(){gIComments.setAnimationToPositions(a);}},{id:"animationRun",autoContinue:false,fn:CY.bind(gIComments.runAnimations,gIComments)});},_animateToTop:function(){var a=gIComments.getTopPosition();if(a!=null){this._animateTo(a[1]);}},animateToTop:function(){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this._animateToTop();this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},showAllComments:function(){checkForOpenedDialog(null,function(){gShowingAllComments=true;var a=CY.Array.map(gDb.comments,function(b){return b.id;});this.showComments(a,[0,0],true);},this,null);},showScopeRemovedComments:function(){checkForOpenedDialog(null,function(){gShowingAllComments=true;var b=CY.Array.filter(gDb.comments,function(c){return(c.start_wrapper==-1);});var a=CY.Array.map(b,function(d){return d.id;});this.showComments(a,[0,0],true);},this,null);},showComments:function(c,b,a){checkForOpenedDialog(null,function(){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this._showComments(c,b[1],a);this._animateTo(b[1]);this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},this,null);},openComment:function(a){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});var b=gIComments.getTopPosition()[1];this._q.add({fn:function(){gIComments.open(a.commentId);gIComments.refresh(a.commentId);}});this._animateTo(b);this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},closeComment:function(a){checkForOpenedDialog(a,function(){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});var b=gIComments.getTopPosition()[1];this._q.add({fn:function(){var c=gDb.getComment(a.commentId);gIComments.close(a.commentId);if(c.reply_to_id!=null){gIComments.refresh(c.reply_to_id);}}});this._animateTo(b);this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},this,null);},activate:function(a){gIComments.activate(a.commentId);}};readyForAction=function(){return !gSync._iPreventClick;};getWrapperAncestor=function(a){var b=a;while(b!=null){if(CY.DOM.hasClass(b,"c-s")){return b;}b=b.parentNode;}return null;};hasWrapperAncestor=function(a){return(getWrapperAncestor(a)!=null);};getSelectionInfo=function(){var J=null,m=null,D=0,c=0,h="";if(window.getSelection){var r=window.getSelection();if(r.rangeCount>0){var l=r.getRangeAt(0);h=l.toString();if(h!=""){var E=document.createRange();E.setStart(r.anchorNode,r.anchorOffset);E.collapse(true);var B=document.createRange();B.setEnd(r.focusNode,r.focusOffset);B.collapse(false);var I=(B.compareBoundaryPoints(2,E)==1);J=(I)?r.anchorNode.parentNode:r.focusNode.parentNode;innerStartNode=(I)?r.anchorNode:r.focusNode;m=(I)?r.focusNode.parentNode:r.anchorNode.parentNode;innerEndNode=(I)?r.focusNode:r.anchorNode;D=(I)?r.anchorOffset:r.focusOffset;c=(I)?r.focusOffset:r.anchorOffset;if(!hasWrapperAncestor(m)&&hasWrapperAncestor(J)){var z=document.createRange();z.setStart(innerStartNode,D);var b=getWrapperAncestor(J);var q=b;z.setEndAfter(q);var f=parseInt(b.id.substring("sv_".length));while(z.toString().lengthv.compareBoundaryPoints(2,l))){J=k.firstChild;D=0;m=F.lastChild;c=CY.DOM.getText(F).length;w=true;break;}}if(w){break;}}}}}E.detach();B.detach();}else{return null;}}else{return null;}}else{if(document.selection){var d=document.selection.createRange();if(d.text.length==0){return null;}var a=d.parentElement();var H=d.duplicate();var u=d.duplicate();H.collapse(true);u.collapse(false);J=H.parentElement();while(H.moveStart("character",-1)!=0){if(H.parentElement()!=J){break;}D++;}m=u.parentElement();while(u.moveEnd("character",-1)!=0){if(u.parentElement()!=m){break;}c++;}h=d.text;}}if(!hasWrapperAncestor(J)||!hasWrapperAncestor(m)){return null;}return{text:h,start:{elt:J,offset:D},end:{elt:m,offset:c}};};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;cm[l.id]){m[l.id]=d;}}}for(var b in m){var h=this.allCommentsByDbId[b].id;var r=false;for(var k=0,c=n.length;k0){a=a.concat(this.getThreads(c[b].replies));}}return a;},_getPath:function(b,e){var a=[e];var d=e;while(d.reply_to_id!=null){d=b[d.reply_to_id];a.push(d);}return a;},getPath:function(a){return this._getPath(this.commentsByDbId,a);},getComment:function(a){return this.commentsByDbId[a];},getCommentByIdKey:function(a){for(var c in this.commentsByDbId){var b=this.commentsByDbId[c];if(b.id_key==a){return b;}}return null;},isChild:function(d,b){var c=this.commentsByDbId[d];var a=(d==b);while((!a)&&(c.reply_to_id!=null)){c=this.commentsByDbId[c.reply_to_id];a=(c.id==b);}return a;},initToReadOnly:function(f,c){for(var b=0,a=this.allComments.length;b0){var g=-1;if((f=="prev")||(f=="next")){for(var e=0;e=0)&&(ea.length){break;}}CY.error("internal error in db browse (could not find any filtered comment)");}return null;},computeFilterResults:function(n){var a={};if(n){for(key in n){if(key.indexOf("filter_")==0){a[key.substr("filter_".length)]=n[key];}}}else{if(gLayout.isInFrame()){a=parent.f_getFrameFilterData();}}var v=[];var w=[];var b="";if("name" in a){b=a.name;}this.filterByName(b,v,w);var p=[];var c=[];var C="";if("date" in a){C=a.date;}this.filterByDate(C,p,c);var g=[];var f=[];var t="";if("text" in a){t=a.text;}this.filterByText(t,g,f);var x=[];var m=[];var A="";if("tag" in a){A=a.tag;}this.filterByTag(A,x,m);var u=[];var e=[];var k="";if("state" in a){k=a.state;}this.filterByState(k,u,e);var d=[];var z=[];for(var y=0,j=v.length;yc){if(e.reply_to_id==null){d.push(e.id);}else{a.push(e.id);}}}},getCommentsAndRepliesCounts:function(d){var b=0;var f=0;var a=(d)?this.allComments:this.comments;var e=this.getThreads(a);for(var c=0;c
'+t+'
-X',bodyContent:'"});this.overlay.get("contentBox").addClass("c-comment");this.overlay.render("#leftcolumn");this.animation=new CY.Anim({node:this.overlay.get("boundingBox"),duration:gPrefs.get("general","animduration"),easing:CY.Easing.easeOut});this.overlay.get("contentBox").query(".c-close").on("click",this.onCloseCommentClick,this);this.overlay.get("contentBox").query(".c-moderate").on("click",this.onModerateCommentClick,this);this.overlay.get("contentBox").query(".c-state-pending").on("click",this.onPendingCommentClick,this);this.overlay.get("contentBox").query(".c-state-approved").on("click",this.onApprovedCommentClick,this);this.overlay.get("contentBox").query(".c-state-unapproved").on("click",this.onUnapprovedCommentClick,this);this.overlay.get("contentBox").query(".c-state-cancel").on("click",this.onCancelStateChangeClick,this);this.overlay.get("contentBox").query(".c-edit").on("click",this.onEditCommentClick,this);this.overlay.get("contentBox").query(".c-delete").on("click",this.onDeleteCommentClick,this);this.overlay.get("contentBox").query(".c-reply").on("click",this.onReplyCommentClick,this);this.overlay.get("contentBox").query(".c-readreplies").on("click",this.onReadRepliesCommentClick,this);this.overlay.get("contentBox").query(".icomment-header").on("mouseenter",this.onMouseEnterHeader,this);this.overlay.get("contentBox").query(".icomment-header").on("mouseleave",this.onMouseLeaveHeader,this);this.overlay.get("contentBox").on("click",this.onCommentClick,this);};IComment.prototype={onCloseCommentClick:function(a){a.halt();if(readyForAction()&&this.isVisible()){gSync.closeComment(this);}},onModerateCommentClick:function(a){a.halt();if(readyForAction()&&this.isVisible()){this.overlay.get("contentBox").query(".c-iactions").addClass("displaynone");this.overlay.get("contentBox").query(".c-state-actions").removeClass("displaynone");}},onPendingCommentClick:function(a){a.halt();if(readyForAction()&&this.isVisible()){gSync.moderateComment(this,"pending");}},onApprovedCommentClick:function(a){a.halt();if(readyForAction()&&this.isVisible()){gSync.moderateComment(this,"approved");}},onUnapprovedCommentClick:function(a){a.halt();if(readyForAction()&&this.isVisible()){gSync.moderateComment(this,"unapproved");}},onCancelStateChangeClick:function(a){a.halt();if(readyForAction()&&this.isVisible()){this.overlay.get("contentBox").query(".c-iactions").removeClass("displaynone");this.overlay.get("contentBox").query(".c-state-actions").addClass("displaynone");}},onDeleteCommentClick:function(a){a.halt();if(readyForAction()&&this.isVisible()){gSync.removeComment(this);}},onEditCommentClick:function(a){a.halt();if(readyForAction()&&this.isVisible()){gSync.showEditForm(this);}},onReplyCommentClick:function(a){a.halt();if(readyForAction()&&this.isVisible()){gSync.showReplyForm(this);}},onReadRepliesCommentClick:function(a){a.halt();if(readyForAction()&&this.isVisible()){gSync.openComment(this);}},onCommentClick:function(d){if(readyForAction()&&this.isVisible()){if(d.target.get("target")=="_blank"){var b=d.target;var g=sv_site_url+sv_text_view_show_comment_url;if(b.get("href").indexOf(g)==0){var a=(new RegExp("comment_id_key=([^&]*)","g")).exec(b.get("href"));if(a!=null){var c=a[1];var f=gDb.getCommentByIdKey(c);if(f!=null){d.halt();if(!b.hasClass("c-permalink")){checkForOpenedDialog(null,function(){gSync.showSingleComment(f);});}}}}}else{if(gShowingAllComments){if(!this._isHostingAForm()){var f=gDb.getComment(this.commentId);checkForOpenedDialog(null,function(){if(f!=null){gSync.showSingleComment(f);}});}}else{gSync.activate(this);}}}},onMouseEnterHeader:function(){if(readyForAction()&&this.isVisible()){this.overlay.get("contentBox").query(".c-permalink").removeClass("displaynone");}},onMouseLeaveHeader:function(){if(readyForAction()&&this.isVisible()){this.overlay.get("contentBox").query(".c-permalink").addClass("displaynone");}},setWidth:function(a){this.overlay.get("boundingBox").setStyle("width",a+"px");},activate:function(){this.overlay.get("boundingBox").addClass("c-focus-comment");},deactivate:function(){this.overlay.get("boundingBox").removeClass("c-focus-comment");},hide:function(){if(gIComments.isTopActive(this.commentId)){if(!gIComments.activateVisibleNext()){gIComments.deactivate();}}if(this.isVisible()){this.overlay.hide();this.overlay.blur();}},hideContent:function(){this.overlay.get("contentBox").query(".icomment-header").addClass("displaynone");this.overlay.get("contentBox").query(".icomment-body").addClass("displaynone");},showContent:function(){this.overlay.get("contentBox").query(".icomment-header").removeClass("displaynone");this.overlay.get("contentBox").query(".icomment-body").removeClass("displaynone");},isVisible:function(){return this.overlay.get("visible");},show:function(){this.hideReadRepliesLnk();return this.overlay.show();},showReadRepliesLnk:function(){this.overlay.get("contentBox").query(".c-readreplies").removeClass("displaynone");},hideReadRepliesLnk:function(){this.overlay.get("contentBox").query(".c-readreplies").addClass("displaynone");},changeModeration:function(b){var a=this.overlay.get("contentBox").query(".c-moderate");a.set("innerHTML",gettext(b.state));a.removeClass("c-state-approved");a.removeClass("c-state-pending");a.removeClass("c-state-unapproved");a.addClass("c-state-"+b.state);this.overlay.get("contentBox").query(".c-iactions").removeClass("displaynone");this.overlay.get("contentBox").query(".c-state-actions").addClass("displaynone");},isfetched:function(){return(this.commentId!=null);},unfetch:function(){this.commentId=null;},fetch:function(h){this.commentId=h.id;var b=this.overlay.get("boundingBox");if(h.start_wrapper!=-1){b.addClass("c-has-scope");b.removeClass("c-has-no-scope");}else{b.addClass("c-has-no-scope");b.removeClass("c-has-scope");}if(h.reply_to_id!=null){b.addClass("c-is-reply");}else{b.removeClass("c-is-reply");}var f=interpolate(gettext("last modified on %(date)s"),{date:h.modified_user_str},true);var k=(h.modified==h.created)?"":' * ';var i=gettext("Permalink to this comment");var n='¶ ';var j=interpolate(gettext("by %(name)s, created on %(date)s"),{name:h.name,date:h.created_user_str},true);var c='
'+h.title+n+'
'+j+"
";var d=CY.Node.create(c);var o=b.query(".c-header");if(o==null){b.query(".icomment-header").insertBefore(d,b.one(".c-iactions"));}else{o.get("parentNode").replaceChild(d,o);}var g=CY.Node.create('
tags:'+h.tags+"
");var m=b.query(".c-tags");if(m==null){b.query(".icomment-header").appendChild(g);}else{m.get("parentNode").replaceChild(g,m);}if(h.tags==""){g.addClass("displaynone");}var e=CY.Node.create(''+h.content_html+"");var a=b.query(".c-content");if(a==null){b.query(".icomment-body").appendChild(e);}else{a.get("parentNode").replaceChild(e,a);}b.query(".c-permalink").set("href",sv_site_url+h.permalink);this.changeModeration(h);var l=b.queryAll(".c-content a");if(l!=null){l.setAttribute("target","_blank");}l=b.queryAll(".c-header-title a");if(l!=null){l.setAttribute("target","_blank");}this.permAdapt(h);},permAdapt:function(e){var b=this.overlay.get("contentBox").query(".c-delete");if(b){if(!e.can_delete){b.addClass("displaynone");}else{b.removeClass("displaynone");}}var a=this.overlay.get("contentBox").query(".c-edit");if(a){if(!e.can_edit){a.addClass("displaynone");}else{a.removeClass("displaynone");}}var d=this.overlay.get("contentBox").query(".c-reply");if(d){if(!hasPerm("can_create_comment")){d.addClass("displaynone");}else{d.removeClass("displaynone");}}var c=this.overlay.get("contentBox").query(".c-moderate");if(c){if(!e.can_moderate){c.addClass("displaynone");}else{c.removeClass("displaynone");}}},setThreadPad:function(a){this.overlay.get("contentBox").query(".yui-widget-hd").setStyle("paddingLeft",a+"px");this.overlay.get("contentBox").query(".yui-widget-bd").setStyle("paddingLeft",a+"px");},setPosition:function(b){var a=this.overlay.get("boundingBox");a.setStyle("opacity",1);a.setXY(b);},getPosition:function(b){var a=this.overlay.get("boundingBox");return a.getXY();},onAnimationEnd:function(){if(!CY.Lang.isUndefined(this["animation-handle"])&&!CY.Lang.isNull(this["animation-handle"])){this["animation-handle"].detach();this["animation-handle"]=null;}gIComments.signalAnimationEnd();if(gIComments.animationsEnded()){gIComments.whenAnimationsEnd();}},setAnimationToPosition:function(b){var a=this.overlay.get("boundingBox");if(gPrefs.get("general","animduration")<0.011){a.setXY(b);}this.animation.set("to",{xy:b});this.animation.set("duration",gPrefs.get("general","animduration"));this["animation-handle"]=this.animation.on("end",this.onAnimationEnd,this);return this.animation;},getHeight:function(){return this.overlay.get("boundingBox").get("offsetHeight");},scrollIntoView:function(){if(!this.overlay.get("contentBox").inViewportRegion()){this.overlay.get("contentBox").scrollIntoView(true);}},_isHostingAForm:function(){return(this.isVisible()&&((gNewReplyHost!=null&&gNewReplyHost==this)||(gEditICommentHost!=null&&gEditICommentHost==this)));}};gEditICommentHost=null;gEdit=null;dbgc=null;showEditForm=function(a){if(gEdit==null){gEdit={ids:{formId:CY.guid(),formTitleId:CY.guid(),nameInputId:CY.guid(),emailInputId:CY.guid(),titleInputId:CY.guid(),contentInputId:CY.guid(),tagsInputId:CY.guid(),formatInputId:CY.guid(),startWrapperInputId:CY.guid(),endWrapperInputId:CY.guid(),startOffsetInputId:CY.guid(),endOffsetInputId:CY.guid(),changeScopeInputId:CY.guid(),changeScopeInputWrapper:CY.guid(),selectionPlaceId:CY.guid(),keyId:CY.guid(),editCommentId:CY.guid(),currentSelId:CY.guid(),currentSelIdI:CY.guid(),addBtnId:CY.guid(),cancelBtnId:CY.guid()},handlers:{}};}gEditICommentHost=a;gEditICommentHost.hideContent();var c=getHtml(gEdit.ids);var b='
'+c.headerContent+"
";var e='
'+c.bodyContent+"
";gEditICommentHost.overlay.setStdModContent(CY.WidgetStdMod.HEADER,CY.Node.create(b),CY.WidgetStdMod.AFTER);gEditICommentHost.overlay.setStdModContent(CY.WidgetStdMod.BODY,CY.Node.create(e),CY.WidgetStdMod.AFTER);CY.get("#"+gEdit.ids["formTitleId"]).set("innerHTML",gettext("Edit comment"));var f=gDb.getComment(gEditICommentHost.commentId);CY.get("#"+gEdit.ids["editCommentId"]).set("value",f.id);CY.get("#"+gEdit.ids["keyId"]).set("value",f.key);CY.get("#"+gEdit.ids["changeScopeInputId"]+" input").set("checked",false);if(f.reply_to_id!=null){CY.get("#"+gEdit.ids["changeScopeInputId"]).addClass("displaynone");}changeScopeFormClick();CY.get("#"+gEdit.ids["nameInputId"]).set("value",f.name);CY.get("#"+gEdit.ids["emailInputId"]).set("value",f.email);if(f.logged_author){CY.get("#"+gEdit.ids["nameInputId"]).setAttribute("disabled",true);CY.get("#"+gEdit.ids["emailInputId"]).setAttribute("disabled",true);}CY.get("#"+gEdit.ids["titleInputId"]).set("value",f.title);CY.get("#"+gEdit.ids["contentInputId"]).set("value",f.content);CY.get("#"+gEdit.ids["tagsInputId"]).set("value",f.tags);CY.get("#"+gEdit.ids["formatInputId"]).set("value",gConf.defaultCommentFormat);var d=gLayout.getTopICommentsWidth();changeFormFieldsWidth(gEdit.ids["formId"],d);gEdit.handlers["addBtnId"]=CY.on("click",onEditSaveClick,"#"+gEdit.ids["addBtnId"]);gEdit.handlers["cancelBtnId"]=CY.on("click",onEditCancelClick,"#"+gEdit.ids["cancelBtnId"]);gEdit.handlers["changeScope"]=CY.on("click",onChangeScopeClick,"#"+gEdit.ids["changeScopeInputId"]);};onEditSaveClick=function(a){if(readyForAction()){gSync.editComment();}};onEditCancelClick=function(a){if(readyForAction()){gSync.cancelEdit();}};onChangeScopeClick=function(){if(readyForAction()){gSync.changeScopeFormClick();}else{var a=CY.get("#"+gEdit.ids["changeScopeInputId"]+" input");var b=a.get("checked");a.set("checked",!b);}};changeScopeFormClick=function(){var a=CY.get("#"+gEdit.ids["currentSelId"]);if(CY.get("#"+gEdit.ids["changeScopeInputId"]+" input").get("checked")){a.removeClass("displaynone");}else{a.addClass("displaynone");}};cancelEditForm=function(){if(gEditICommentHost!=null){for(var b in gEdit.handlers){if(gEdit.handlers[b]!=null){gEdit.handlers[b].detach();gEdit.handlers[b]=null;}}var a=gEditICommentHost.overlay.get("contentBox").query(".icomment-edit-body");a.get("parentNode").removeChild(a);a=gEditICommentHost.overlay.get("contentBox").query(".icomment-edit-header");a.get("parentNode").removeChild(a);gEditICommentHost.showContent();gEditICommentHost=null;}};var gtest={renaud:"RENAUD",random:Math.random(),bernard:"BERNARD",myFunc:function(){doExchange("theServerFun",{},null,this.myRetFunc,this,["foo","bar"]);},myRetFunc:function(a){CY.log("this.renaud : "+this.renaud);CY.log("this.random : "+this.random);CY.log("arg.returned : "+a.returned);CY.log(a.returned);CY.log("arg.success : "+a.success);CY.log(a.success);}};doExchange=function(h,e,g,f,d,c,b){e.fun=h;e.key=sv_key;e.version_key=sv_version_key;var a={method:"POST",data:urlEncode(e),on:{success:function(l,k,j){var i={};if(k.responseText){i=CY.JSON.parse(k.responseText);}if(gLayout.isInFrame()&&("msg" in i)){parent.f_enqueueMsg(i.msg);}j.returned=i;j.successfull=true;f.call(d,j);},failure:function(k,j,i){if(gLayout.isInFrame()){parent.f_enqueueErrorMsg(gettext("error:")+b);}i.successfull=false;f.call(d,i);}},arguments:{success:c,failure:c}};if(g!=null){a.form={id:g};}CY.io(sv_client_url,a);};warn_server=function(c){c.fun="warn";c.key=sv_key;c.version_key=sv_version_key;var b=CY.UA;var a={method:"POST",data:urlEncode(CY.merge(c,b))};CY.io("/client/",a);};paintCommentScope=function(b){if(b.reply_to_id==null&&b.start_wrapper!=-1){var a={start:{elt:document.getElementById("sv_"+b.start_wrapper),offset:b.start_offset},end:{elt:document.getElementById("sv_"+b.end_wrapper),offset:b.end_offset}};if(document.getElementById("sv_"+b.start_wrapper)==null){warn_server({from:"paintCommentScope",start_wrapper:b.start_wrapper});}else{if(document.getElementById("sv_"+b.end_wrapper)==null){warn_server({from:"paintCommentScope",end_wrapper:b.end_wrapper});}else{a.start=_convertSelectionFromCSToCC(a.start);a.end=_convertSelectionFromCSToCC(a.end);renderComment(a,b.id);}}}};getCommentIdsFromClasses=function(b){var a=[];var e=b.className.split(" ");for(var d=0,c=e.length;d=d.offset){a.elt=e;a.offset=d.offset-b;break;}e=e.nextSibling;}return a;};unpaintCommentScope=function(k){var j=k.id;var r="c-id-"+j;var m=[];var t=CY.all("."+r);if(t!=null){for(var h=0,d=t.size();h0){this._animateTo(f);}}},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();},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();var c=CY.Array.map(f,function(h){return gDb.getComment(h);});var a=gDb.getThreads(c);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);}}}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)});},_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;});this.showComments(b,[0,0],true);},this,null);},showScopeRemovedComments:function(){checkForOpenedDialog(null,function(){gShowingAllComments=true;var c=CY.Array.filter(gDb.comments,function(a){return(a.start_wrapper==-1);});var d=CY.Array.map(c,function(a){return a.id;});this.showComments(d,[0,0],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(d){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});var c=gIComments.getTopPosition()[1];this._q.add({fn:function(){gIComments.open(d.commentId);gIComments.refresh(d.commentId);}});this._animateTo(c);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;};getWrapperAncestor=function(d){var c=d;while(c!=null){if(CY.DOM.hasClass(c,"c-s")){return c;}c=c.parentNode;}return null;};hasWrapperAncestor=function(b){return(getWrapperAncestor(b)!=null);};getSelectionInfo=function(){var j=null,ac=null,T=0,aj=0,af="";if(window.getSelection){var V=window.getSelection();if(V.rangeCount>0){var ad=V.getRangeAt(0);af=ad.toString();if(af!=""){var R=document.createRange();R.setStart(V.anchorNode,V.anchorOffset);R.collapse(true);var W=document.createRange();W.setEnd(V.focusNode,V.focusOffset);W.collapse(false);var K=(W.compareBoundaryPoints(2,R)==1);j=(K)?V.anchorNode.parentNode:V.focusNode.parentNode;innerStartNode=(K)?V.anchorNode:V.focusNode;ac=(K)?V.focusNode.parentNode:V.anchorNode.parentNode;innerEndNode=(K)?V.focusNode:V.anchorNode;T=(K)?V.anchorOffset:V.focusOffset;aj=(K)?V.focusOffset:V.anchorOffset;if(!hasWrapperAncestor(ac)&&hasWrapperAncestor(j)){var e=document.createRange();e.setStart(innerStartNode,T);var ak=getWrapperAncestor(j);var X=ak;e.setEndAfter(X);var ah=parseInt(ak.id.substring("sv_".length));while(e.toString().lengthN.compareBoundaryPoints(2,ad))){j=ae.firstChild;T=0;ac=Q.lastChild;aj=CY.DOM.getText(Q).length;M=true;break;}}if(M){break;}}}}}R.detach();W.detach();}else{return null;}}else{return null;}}else{if(document.selection){var ai=document.selection.createRange();if(ai.text.length==0){return null;}var al=ai.parentElement();var L=ai.duplicate();var P=ai.duplicate();L.collapse(true);P.collapse(false);j=L.parentElement();while(L.moveStart("character",-1)!=0){if(L.parentElement()!=j){break;}T++;}ac=P.parentElement();while(P.moveEnd("character",-1)!=0){if(P.parentElement()!=ac){break;}aj++;}af=ai.text;}}if(!hasWrapperAncestor(j)||!hasWrapperAncestor(ac)){return null;}return{text:af,start:{elt:j,offset:T},end:{elt:ac,offset:aj}};};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(i,l,j){var k=l[j];for(var n=0;nu[v.id]){u[v.id]=B;}}}for(var D in u){var x=this.allCommentsByDbId[D].id;var a=false;for(var w=0,C=t.length;w0){e=e.concat(this.getThreads(f[d].replies));}}return e;},_getPath:function(c,g){var f=[g];var h=g;while(h.reply_to_id!=null){h=c[h.reply_to_id];f.push(h);}return f;},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(R){var ad={};if(R){for(key in R){if(key.indexOf("filter_")==0){ad[key.substr("filter_".length)]=R[key];}}}else{if(gLayout.isInFrame()){ad=parent.f_getFrameFilterData();}}var G=[];var F=[];var ac="";if("name" in ad){ac=ad.name;}this.filterByName(ac,G,F);var P=[];var ab=[];var L="";if("date" in ad){L=ad.date;}this.filterByDate(L,P,ab);var X=[];var Y=[];var I="";if("text" in ad){I=ad.text;}this.filterByText(I,X,Y);var E=[];var S=[];var O="";if("tag" in ad){O=ad.tag;}this.filterByTag(O,E,S);var H=[];var Z=[];var U="";if("state" in ad){U=ad.state;}this.filterByState(U,H,Z);var aa=[];var i=[];for(var D=0,V=G.length;Dl){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;l
'+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(w){this.commentId=w.id;var C=this.overlay.get("boundingBox");if(w.start_wrapper!=-1){C.addClass("c-has-scope");C.removeClass("c-has-no-scope");}else{C.addClass("c-has-no-scope");C.removeClass("c-has-scope");}if(w.reply_to_id!=null){C.addClass("c-is-reply");}else{C.removeClass("c-is-reply");}var y=interpolate(gettext("last modified on %(date)s"),{date:w.modified_user_str},true);var t=(w.modified==w.created)?"":' * ';var v=gettext("Permalink to this comment");var q='¶ ';var u=interpolate(gettext("by %(name)s, created on %(date)s"),{name:w.name,date:w.created_user_str},true);var B='
'+w.title+q+'
'+u+"
";var A=CY.Node.create(B);var p=C.query(".c-header");if(p==null){C.query(".icomment-header").insertBefore(A,C.one(".c-iactions"));}else{p.get("parentNode").replaceChild(A,p);}var x=CY.Node.create('
tags:'+w.tags+"
");var r=C.query(".c-tags");if(r==null){C.query(".icomment-header").appendChild(x);}else{r.get("parentNode").replaceChild(x,r);}if(w.tags==""){x.addClass("displaynone");}var z=CY.Node.create(''+w.content_html+"");var D=C.query(".c-content");if(D==null){C.query(".icomment-body").appendChild(z);}else{D.get("parentNode").replaceChild(z,D);}C.query(".c-permalink").set("href",sv_site_url+w.permalink);this.changeModeration(w);var s=C.queryAll(".c-content a");if(s!=null){s.setAttribute("target","_blank");}s=C.queryAll(".c-header-title a");if(s!=null){s.setAttribute("target","_blank");}this.permAdapt(w);},permAdapt:function(h){var f=this.overlay.get("contentBox").query(".c-delete");if(f){if(!h.can_delete){f.addClass("displaynone");}else{f.removeClass("displaynone");}}var g=this.overlay.get("contentBox").query(".c-edit");if(g){if(!h.can_edit){g.addClass("displaynone");}else{g.removeClass("displaynone");}}var i=this.overlay.get("contentBox").query(".c-reply");if(i){if(!hasPerm("can_create_comment")){i.addClass("displaynone");}else{i.removeClass("displaynone");}}var j=this.overlay.get("contentBox").query(".c-moderate");if(j){if(!h.can_moderate){j.addClass("displaynone");}else{j.removeClass("displaynone");}}},setThreadPad:function(b){this.overlay.get("contentBox").query(".yui-widget-hd").setStyle("paddingLeft",b+"px");this.overlay.get("contentBox").query(".yui-widget-bd").setStyle("paddingLeft",b+"px");},setPosition:function(c){var d=this.overlay.get("boundingBox");d.setStyle("opacity",1);d.setXY(c);},getPosition:function(c){var d=this.overlay.get("boundingBox");return d.getXY();},onAnimationEnd:function(){if(!CY.Lang.isUndefined(this["animation-handle"])&&!CY.Lang.isNull(this["animation-handle"])){this["animation-handle"].detach();this["animation-handle"]=null;}gIComments.signalAnimationEnd();if(gIComments.animationsEnded()){gIComments.whenAnimationsEnd();}},setAnimationToPosition:function(c){var d=this.overlay.get("boundingBox");if(gPrefs.get("general","animduration")<0.011){d.setXY(c);}this.animation.set("to",{xy:c});this.animation.set("duration",gPrefs.get("general","animduration"));this["animation-handle"]=this.animation.on("end",this.onAnimationEnd,this);return this.animation;},getHeight:function(){return this.overlay.get("boundingBox").get("offsetHeight");},scrollIntoView:function(){if(!this.overlay.get("contentBox").inViewportRegion()){this.overlay.get("contentBox").scrollIntoView(true);}},_isHostingAForm:function(){return(this.isVisible()&&((gNewReplyHost!=null&&gNewReplyHost==this)||(gEditICommentHost!=null&&gEditICommentHost==this)));}};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(),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");}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);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 d=CY.get("#"+gEdit.ids.changeScopeInputId+" input");var c=d.get("checked");d.set("checked",!c);}};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 c in gEdit.handlers){if(gEdit.handlers[c]!=null){gEdit.handlers[c].detach();gEdit.handlers[c]=null;}}var d=gEditICommentHost.overlay.get("contentBox").query(".icomment-edit-body");d.get("parentNode").removeChild(d);d=gEditICommentHost.overlay.get("contentBox").query(".icomment-edit-header");d.get("parentNode").removeChild(d);gEditICommentHost.showContent();gEditICommentHost=null;}};var gtest={renaud:"RENAUD",random:Math.random(),bernard:"BERNARD",myFunc:function(){doExchange("theServerFun",{},null,this.myRetFunc,this,["foo","bar"]);},myRetFunc:function(b){CY.log("this.renaud : "+this.renaud);CY.log("this.random : "+this.random);CY.log("arg.returned : "+b.returned);CY.log(b.returned);CY.log("arg.success : "+b.success);CY.log(b.success);}};doExchange=function(k,n,l,m,o,p,i){n.fun=k;n.key=sv_key;n.version_key=sv_version_key;var j={method:"POST",data:urlEncode(n),on:{success:function(a,b,c){var d={};if(b.responseText){d=CY.JSON.parse(b.responseText);}if(gLayout.isInFrame()&&("msg" in d)){parent.f_enqueueMsg(d.msg);}c.returned=d;c.successfull=true;m.call(o,c);},failure:function(a,b,c){if(gLayout.isInFrame()){parent.f_enqueueErrorMsg(gettext("error:")+i);}c.successfull=false;m.call(o,c);}},arguments:{success:p,failure:p}};if(l!=null){j.form={id:l};}CY.io(sv_client_url,j);};warn_server=function(f){f.fun="warn";f.key=sv_key;f.version_key=sv_version_key;var d=CY.UA;var e={method:"POST",data:urlEncode(CY.merge(f,d))};CY.io("/client/",e);};paintCommentScope=function(c){if(c.reply_to_id==null&&c.start_wrapper!=-1){var d={start:{elt:document.getElementById("sv_"+c.start_wrapper),offset:c.start_offset},end:{elt:document.getElementById("sv_"+c.end_wrapper),offset:c.end_offset}};if(document.getElementById("sv_"+c.start_wrapper)==null){warn_server({from:"paintCommentScope",start_wrapper:c.start_wrapper});}else{if(document.getElementById("sv_"+c.end_wrapper)==null){warn_server({from:"paintCommentScope",end_wrapper:c.end_wrapper});}else{d.start=_convertSelectionFromCSToCC(d.start);d.end=_convertSelectionFromCSToCC(d.end);renderComment(d,c.id);}}}};getCommentIdsFromClasses=function(f){var g=[];var h=f.className.split(" ");for(var i=0,j=h.length;i=k.offset){h.elt=j;h.offset=k.offset-g;break;}j=j.nextSibling;}return h;};unpaintCommentScope=function(v){var w=v.id;var c="c-id-"+w;var p=[];var E=CY.all("."+c);if(E!=null){for(var x=0,B=E.size();x";var e=gFormHtml.formStart.replace("###",gNewReply.ids["formId"]);if(!sv_loggedIn){e=e+gFormHtml.nameInput.replace("###",gNewReply.ids["nameInputId"])+gFormHtml.emailInput.replace("###",gNewReply.ids["emailInputId"]);}e=e+gFormHtml.titleInput.replace("###",gNewReply.ids["titleInputId"])+gFormHtml.contentInput.replace("###",gNewReply.ids["contentInputId"])+gFormHtml.tagsInput.replace("###",gNewReply.ids["tagsInputId"]);e=e+gFormHtml.hidden.replace("###",gNewReply.ids["keyInputId"]).replace("???","comment_key");e=e+gFormHtml.hidden.replace("###",gNewReply.ids["formatInputId"]).replace("???","format");e=e+gFormHtml.hidden.replace("###",gNewReply.ids["parentCommentId"]).replace("???","reply_to_id");var h=gFormHtml.btns.replace("###",gNewReply.ids["addBtnId"]).replace("???",gNewReply.ids["cancelBtnId"]);gNewReplyHost.overlay.setStdModContent(CY.WidgetStdMod.FOOTER,b+e+h);var c=gNewReplyHost.overlay.getStdModNode(CY.WidgetStdMod.FOOTER);var f=gDb.getComment(i.commentId);var a="Re: ";var g=(gNewReply.val["title"]==""||gNewReply.val["title"].substring(0,a.length)==a)?a+f.title:gNewReply.val["title"];if(!sv_loggedIn){c.query(".n_name").set("value",gNewReply.val["name"]);c.query(".n_email").set("value",gNewReply.val["email"]);}c.query(".n_title").set("value",g);c.query(".n_content").set("value",gNewReply.val["content"]);c.query(".n_tags").set("value",gNewReply.val["tags"]);c.query("#"+gNewReply.ids["parentCommentId"]).set("value",i.commentId);c.query("#"+gNewReply.ids["formatInputId"]).set("value",gConf.defaultCommentFormat);gNewReplyHost.overlay.get("contentBox").query(".c-reply").addClass("displaynone");gNewReply.handlers["addBtnId"]=CY.on("click",onAddNewReplyClick,"#"+gNewReply.ids["addBtnId"]);gNewReply.handlers["cancelBtnId"]=CY.on("click",onCancelNewReplyClick,"#"+gNewReply.ids["cancelBtnId"]);var d=gLayout.getTopICommentsWidth();changeFormFieldsWidth(gNewReply.ids["formId"],d);};cleanNewReplyForm=function(){if(gNewReplyHost!=null){var a=gNewReplyHost.overlay.getStdModNode(CY.WidgetStdMod.FOOTER);a.queryAll(".comment_input").set("value","");}};cancelNewReplyForm=function(){if(gNewReplyHost!=null){for(var b in gNewReply.handlers){if(gNewReply.handlers[b]!=null){gNewReply.handlers[b].detach();gNewReply.handlers[b]=null;}}gNewReplyHost.overlay.get("contentBox").query(".c-reply").removeClass("displaynone");var a=gNewReplyHost.overlay.getStdModNode(CY.WidgetStdMod.FOOTER);if(!sv_loggedIn){gNewReply.val["name"]=a.query(".n_name").get("value");gNewReply.val["email"]=a.query(".n_email").get("value");}gNewReply.val["title"]=a.query(".n_title").get("value");gNewReply.val["content"]=a.query(".n_content").get("value");gNewReply.val["tags"]=a.query(".n_tags").get("value");a.set("innerHTML","");gNewReplyHost=null;}};onAddNewReplyClick=function(){if(!sv_loggedIn){var b=CY.get("#"+gNewReply.ids["nameInputId"]).get("value");gPrefs.persist("user","name",b);var a=CY.get("#"+gNewReply.ids["emailInputId"]).get("value");gPrefs.persist("user","email",a);}gSync.saveComment(gNewReply.ids["formId"]);};onCancelNewReplyClick=function(){gSync.cancelReply();};_changeIds=function(a,b){if(a.id){a.id=a.id+b;}var d=a.firstChild;while(d!=null){_changeIds(d,b);d=d.nextSibling;}};suffix=0;domDuplicate=function(a){var b=a.cloneNode(true);suffix++;_changeIds(b,"-"+suffix);return b;};getDuplicated=function(a){return document.getElementById(a.id+"-"+suffix);};logSel=function(a){log("text :"+a.text+", start id : "+a.start["elt"].id+" , start offset : "+a.start["offset"]+" , end id : "+a.end["elt"].id+"end offset : "+a.end["offset"]);};log=function(b){var a=document.getElementById("log");a.innerHTML=a.innerHTML+"
  • "+b+"
  • ";};urlEncode=function(h){if(!h){return"";}var c=[];for(var f in h){var e=h[f],b=encodeURIComponent(f);var g=typeof e;if(g=="undefined"){c.push(b,"=&");}else{if(g!="function"&&g!="object"){c.push(b,"=",encodeURIComponent(e),"&");}else{if(CY.Lang.isArray(e)){if(e.length){for(var d=0,a=e.length;de[d]){b=e[g];e[g]=e[d];e[d]=b;}return;}a=e[parseInt((g+d)/2)];e[parseInt((g+d)/2)]=e[g];e[g]=a;c=g+1;f=d;do{while(c<=f&&e[c]<=a){c++;}while(e[f]>a){f--;}if(c0){b.showReadRepliesLnk();}else{b.hideReadRepliesLnk();}},remove:function(a){this._remove(this._getChildren(a));},close:function(a){CY.Array.each(this._getChildren(a),function(b){b.hide();});},open:function(a){CY.Array.each(this._getChildren(a),function(b){b.show();});},fetch:function(b){for(var a=0;a=0)&&e<=(this._c.length-1);){var c=this._c[e];if(c.commentId!=null&&c.isVisible()){a=a||(gDb.isChild(c.commentId,this._topActiveCommentDbId));if(a&&(!gDb.isChild(c.commentId,this._topActiveCommentDbId))){this.activate(c.commentId);return true;}}e=(d==0)?e+1:e-1;}}}return false;},browse:function(b,c){var a=c;if((c=="prev")&&!this.isAnyActive()){a="last";}if((c=="next")&&!this.isAnyActive()){a="first";}return gDb.browse(b,a,this._topActiveCommentDbId);}};_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,[]);}};gNoSelectionYet=gettext("No selection yet");gFormHtml={formStart:'
    ',nameInput:gettext("Username:")+'
    ',emailInput:gettext("E-mail address:")+'
    ',titleInput:gettext("Title:")+'
    ',contentInput:gettext("Content:")+'
    ',tagsInput:gettext("Tag:")+'
    ',hidden:'',formEnd:"
    ",changeScope:'
    '+gettext("Modify comment's scope:")+'
    ',headerTitle:'
    ',currentSel:'
    '+gettext("Comment will apply to this selection:")+'
    '+gNoSelectionYet+"
    #hiddeninput#
    ",btns:'
    ',closeIcon:'      '};getHtml=function(f){ret={};ret.headerContent="";if("closeBtnId" in f){ret.headerContent+=gFormHtml.closeIcon.replace("###",f.closeBtnId);}ret.headerContent+=gFormHtml.headerTitle.replace("###",f.formTitleId);var b="";if("changeScopeInputId" in f){b=gFormHtml.changeScope.replace("###",f.changeScopeInputId);}var e="
    "+gFormHtml.hidden.replace("###",f.selectionPlaceId).replace("???","selection_place")+"
    ";var a=gFormHtml.currentSel.replace("###",f.currentSelId).replace("???",f.currentSelIdI).replace("#hiddeninput#",e);var d=gFormHtml.btns.replace("###",f.addBtnId).replace("???",f.cancelBtnId);var c=gFormHtml.formStart.replace("###",f.formId)+b+a;if("nameInputId" in f){c=c+gFormHtml.nameInput.replace("###",f.nameInputId);}if("emailInputId" in f){c=c+gFormHtml.emailInput.replace("###",f.emailInputId);}c=c+gFormHtml.titleInput.replace("###",f.titleInputId)+gFormHtml.contentInput.replace("###",f.contentInputId)+gFormHtml.tagsInput.replace("###",f.tagsInputId);c=c+gFormHtml.hidden.replace("###",f.formatInputId).replace("???","format");c=c+gFormHtml.hidden.replace("###",f.startWrapperInputId).replace("???","start_wrapper");c=c+gFormHtml.hidden.replace("###",f.endWrapperInputId).replace("???","end_wrapper");c=c+gFormHtml.hidden.replace("###",f.startOffsetInputId).replace("???","start_offset");c=c+gFormHtml.hidden.replace("###",f.endOffsetInputId).replace("???","end_offset");c=c+gFormHtml.hidden.replace("###",f.keyId).replace("???","comment_key");c=c+gFormHtml.hidden.replace("###",f.editCommentId).replace("???","edit_comment_id");c=c+d+gFormHtml.formEnd;ret.bodyContent=c;return ret;};changeFormFieldsWidth=function(d,c){var a=(c-20)+"px";var b=CY.all("#"+d+" input[type='text']");if(b!=null){b.setStyle("width",a);}b=CY.all("#"+d+" textarea");if(b!=null){b.setStyle("width",a);}};addFormErrMsg=function(j,g,d){var f=document.getElementById(j);var b,h,c,a;for(b=0,a=f.elements.length;bb){var a=i.substring(0,(i.substring(0,b/2)).lastIndexOf(" "));var d=i.substring(i.length-b/2);var c=d.substring(d.indexOf(" "));f=a+" ... "+c;}var e=_convertSelectionFromCCToCS(h.start);var g=_convertSelectionFromCCToCS(h.end);_updateICommentFormSelection(gICommentForm,f,e,g);if(gEdit!=null){_updateICommentFormSelection(gEdit.ids,f,e,g);}positionICommentForm();}};showICommentForm=function(){removeFormErrMsg(gICommentForm.formId);if(!sv_loggedIn){if(CY.get("#"+gICommentForm.nameInputId).get("value")==""){CY.get("#"+gICommentForm.nameInputId).set("value",gPrefs.get("user","name"));}if(CY.get("#"+gICommentForm.emailInputId).get("value")==""){CY.get("#"+gICommentForm.emailInputId).set("value",gPrefs.get("user","email"));}}gIComments.hide();positionICommentForm();gICommentForm.overlay.show();CY.get("#"+gICommentForm.titleInputId).focus();};isICommentFormVisible=function(){if(gICommentForm!=null){return gICommentForm.overlay.get("visible");}return false;};positionICommentForm=function(){if(gICommentForm!=null){var b=gICommentForm.overlay;var a=b.get("boundingBox");var c=a.get("offsetHeight");var e=a.get("winHeight");var d=gICommentForm.position;if(c>e){d=[CY.WidgetPositionExt.BL,CY.WidgetPositionExt.BL];}b.set("align",{points:d});a.setX(a.getX()+gConf.iCommentLeftPadding);}};c_persistPreference=function(b,a,c){gPrefs.persist(b,a,c);};c_readDefaultPreference=function(b,a){return gConf.defaultPrefs[b][a];};c_readPreference=function(b,a){return gPrefs.get(b,a);};c_resetPreferences=function(a){gPrefs.reset(a);};c_applyTextStyle=function(a){CY.use(a);};sliderValToPx=function(d){var a=CY.DOM.winWidth();if(gLayout.isInFrame()){a=parent.$(parent).width();}var b=d/100;b=Math.min(b,gConf.sliderFixedMin);b=Math.max(b,gConf.sliderFixedMax);var c=b*a;return Math.floor(c);};c_setCommentsColWidth=function(c){var a=sliderValToPx(c);gLayout.setLeftColumnWidth(a);var b=gLayout.getTopICommentsWidthFromWidth(a);gIComments.setWidth(b);gICommentForm.overlay.get("boundingBox").setStyle("width",b+"px");changeFormFieldsWidth(gICommentForm.formId,b);if(gNewReply){changeFormFieldsWidth(gNewReply.ids["formId"],b);}if(gEdit){changeFormFieldsWidth(gEdit.ids["formId"],b);}};CY=null;gPrefs=null;gLayout=null;gDb=null;gIComments=null;gSync=null;gGETValues=null;gConf={iCommentLeftPadding:4,iCommentThreadPadding:12,defaultCommentFormat:"markdown",sliderFixedMin:0.9,sliderFixedMax:0.1,iCommentsInitAlloc:2,defaultPrefs:{text:{style:"text-modern-style"},user:{name:"",email:""},general:{animduration:"0.4"},comments:{threadpad:"1"},layout:{comments_col_width:"25"}}};gTextStyles={"text-modern-style":gettext("modern"),"text-classic-style":gettext("classic"),"text-code-style":gettext("code")};YUI({base:sv_media_url+"/js/lib/yui/"+c_yui_base+"/build/",timeout:10000}).use("text-modern-style","cookie","json","overlay","io-form","async-queue","event-mouseenter","anim","collection",function(a){CY=a;gPrefs=new Preferences();gPrefs.init();gLayout=new Layout();gLayout.init();if(sv_withComments){gDb=new Db();gDb.init();gIComments=new IComments();gIComments.init();}gSync=new Sync();gSync.init();CY.on("domready",onDomReady,this);});_reinit=function(a){gIComments.hide();gDb.initComments(a.commentIds);unpaintAllComments();renderCommentScopes();updateFilterResultsCount(a.nbDiscussions,a.nbComments,a.nbReplies);};reinit=function(b){var a=gDb.computeFilterResults(b);_reinit(a);};hideAll=function(){_reinit({commentIds:[],nbDiscussions:0,nbComments:0,nbReplies:0});};updateFilterResultsCount=function(f,a,b){var e=gDb.getCommentsAndRepliesCounts(true);var g=e[0],d=e[1];var c=(a!=0||b!=0)&&(g!=a||d!=b);if(gLayout.isInFrame()){parent.f_updateFilterCountDetailed(c);parent.f_updateFilterCountResult(f,a,b,g,d);}};updateResetFilterResultsCount=function(){var c=gDb.getCommentsAndRepliesCounts(false);var a=c[0],b=c[1];var d=a;updateFilterResultsCount(d,a,b);};renderCommentScopes=function(){for(var a=0;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();}},timeout:5},{fn:function(){gGETValues=CY.JSON.parse(sv_get_params);CY.get("#maincontainer").setStyle("display","block");CY.get("#textcontainer").setStyle("display","block");var e=(sv_withComments)?gPrefs.get("layout","comments_col_width"):0;var d=sliderValToPx(e);gLayout.setLeftColumnWidth(d);if(gLayout.isInFrame()){parent.f_initFrame();parent.f_layoutFrames();if(sv_withComments){parent.f_fillTopToolbar();if(hasPerm("can_create_comment")){parent.$("#add_comment_btn").removeClass("initially_hidden");}parent.f_fillFilterTab();parent.f_fillPreferencesTab();var c=CY.JSON.parse(sv_filter_data);parent.f_updateFilterData(c);parent.f_setFilterValue(gGETValues);}parent.f_fillTextPreferencesTab();}if(gLayout.isInComentSite()){parent.$("#c_fullscreen_btn").show();}else{parent.$("#c_fullscreen_btn").hide();}},timeout:5},{fn:function(){if(sv_withComments){reinit(gGETValues);initialConnect();}},timeout:5},{fn:function(){if(gLayout.isInFrame()){parent.f_interfaceUnfreeze();parent.f_removeLoadingMsg();}if("comment_id_key" in gGETValues){var d=gGETValues.comment_id_key;var f=gDb.getCommentByIdKey(d);if(f!=null){var e=gDb.getPath(f);var c=e[e.length-1];gSync.showSingleComment(c);}}if("comments_auto_display" in gGETValues){gSync.showAllComments();}}});a.run();}; \ No newline at end of file +hasPerm=function(a){return(-1!=CY.Array.indexOf(sv_user_permissions,a));};Layout=function(){};Layout.prototype={init:function(){},isInFrame:function(){return(!CY.Lang.isUndefined(parent)&&parent.location!=location&&CY.Lang.isFunction(parent.f_getFrameFilterData));},isInComentSite:function(){var 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();}}};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;b0){this._animateTo(a);}}},showSingleComment:function(a){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this._showSingleComment(a);this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},browse:function(a,b){var c=gIComments.browse(a,b);if(c!=null){this.showSingleComment(c);}},_showComments:function(c,b,a){this._q.add({fn:function(){gShowingAllComments=a;gIComments.hide();var d=CY.Array.map(c,function(g){return gDb.getComment(g);});var f=gDb.getThreads(d);gIComments.fetch(f);if(c.length>0){if(a){CY.get("document").set("scrollTop",0);}else{gIComments.activate(c[0]);var e=CY.get(".c-id-"+c[0]);if(e&&!e.inViewportRegion()){e.scrollIntoView(true);}}}gIComments.setPosition([gConf.iCommentLeftPadding,b]);gIComments.show();}});},_animateTo:function(a){this._q.add({fn:function(){gIComments.setAnimationToPositions(a);}},{id:"animationRun",autoContinue:false,fn:CY.bind(gIComments.runAnimations,gIComments)});},_animateToTop:function(){var a=gIComments.getTopPosition();if(a!=null){this._animateTo(a[1]);}},animateToTop:function(){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this._animateToTop();this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},showAllComments:function(){checkForOpenedDialog(null,function(){gShowingAllComments=true;var a=CY.Array.map(gDb.comments,function(b){return b.id;});this.showComments(a,[0,0],true);},this,null);},showScopeRemovedComments:function(){checkForOpenedDialog(null,function(){gShowingAllComments=true;var b=CY.Array.filter(gDb.comments,function(c){return(c.start_wrapper==-1);});var a=CY.Array.map(b,function(d){return d.id;});this.showComments(a,[0,0],true);},this,null);},showComments:function(c,b,a){checkForOpenedDialog(null,function(){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});this._showComments(c,b[1],a);this._animateTo(b[1]);this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},this,null);},openComment:function(a){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});var b=gIComments.getTopPosition()[1];this._q.add({fn:function(){gIComments.open(a.commentId);gIComments.refresh(a.commentId);}});this._animateTo(b);this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},closeComment:function(a){checkForOpenedDialog(a,function(){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});var b=gIComments.getTopPosition()[1];this._q.add({fn:function(){var c=gDb.getComment(a.commentId);gIComments.close(a.commentId);if(c.reply_to_id!=null){gIComments.refresh(c.reply_to_id);}}});this._animateTo(b);this._q.add({fn:CY.bind(this.setPreventClickOff,this)});this._q.run();},this,null);},activate:function(a){gIComments.activate(a.commentId);}};readyForAction=function(){return !gSync._iPreventClick;};getWrapperAncestor=function(a){var b=a;while(b!=null){if(CY.DOM.hasClass(b,"c-s")){return b;}b=b.parentNode;}return null;};hasWrapperAncestor=function(a){return(getWrapperAncestor(a)!=null);};getSelectionInfo=function(){var J=null,m=null,D=0,c=0,h="";if(window.getSelection){var r=window.getSelection();if(r.rangeCount>0){var l=r.getRangeAt(0);h=l.toString();if(h!=""){var E=document.createRange();E.setStart(r.anchorNode,r.anchorOffset);E.collapse(true);var B=document.createRange();B.setEnd(r.focusNode,r.focusOffset);B.collapse(false);var I=(B.compareBoundaryPoints(2,E)==1);J=(I)?r.anchorNode.parentNode:r.focusNode.parentNode;innerStartNode=(I)?r.anchorNode:r.focusNode;m=(I)?r.focusNode.parentNode:r.anchorNode.parentNode;innerEndNode=(I)?r.focusNode:r.anchorNode;D=(I)?r.anchorOffset:r.focusOffset;c=(I)?r.focusOffset:r.anchorOffset;if(!hasWrapperAncestor(m)&&hasWrapperAncestor(J)){var z=document.createRange();z.setStart(innerStartNode,D);var b=getWrapperAncestor(J);var q=b;z.setEndAfter(q);var f=parseInt(b.id.substring("sv_".length));while(z.toString().lengthv.compareBoundaryPoints(2,l))){J=k.firstChild;D=0;m=F.lastChild;c=CY.DOM.getText(F).length;w=true;break;}}if(w){break;}}}}}E.detach();B.detach();}else{return null;}}else{return null;}}else{if(document.selection){var d=document.selection.createRange();if(d.text.length==0){return null;}var a=d.parentElement();var H=d.duplicate();var u=d.duplicate();H.collapse(true);u.collapse(false);J=H.parentElement();while(H.moveStart("character",-1)!=0){if(H.parentElement()!=J){break;}D++;}m=u.parentElement();while(u.moveEnd("character",-1)!=0){if(u.parentElement()!=m){break;}c++;}h=d.text;}}if(!hasWrapperAncestor(J)||!hasWrapperAncestor(m)){return null;}return{text:h,start:{elt:J,offset:D},end:{elt:m,offset:c}};};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;cm[l.id]){m[l.id]=d;}}}for(var b in m){var h=this.allCommentsByDbId[b].id;var r=false;for(var k=0,c=n.length;k0){a=a.concat(this.getThreads(c[b].replies));}}return a;},_getPath:function(b,e){var a=[e];var d=e;while(d.reply_to_id!=null){d=b[d.reply_to_id];a.push(d);}return a;},getPath:function(a){return this._getPath(this.commentsByDbId,a);},getComment:function(a){return this.commentsByDbId[a];},getCommentByIdKey:function(a){for(var c in this.commentsByDbId){var b=this.commentsByDbId[c];if(b.id_key==a){return b;}}return null;},isChild:function(d,b){var c=this.commentsByDbId[d];var a=(d==b);while((!a)&&(c.reply_to_id!=null)){c=this.commentsByDbId[c.reply_to_id];a=(c.id==b);}return a;},initToReadOnly:function(f,c){for(var b=0,a=this.allComments.length;b0){var g=-1;if((f=="prev")||(f=="next")){for(var e=0;e=0)&&(ea.length){break;}}CY.error("internal error in db browse (could not find any filtered comment)");}return null;},computeFilterResults:function(n){var a={};if(n){for(key in n){if(key.indexOf("filter_")==0){a[key.substr("filter_".length)]=n[key];}}}else{if(gLayout.isInFrame()){a=parent.f_getFrameFilterData();}}var v=[];var w=[];var b="";if("name" in a){b=a.name;}this.filterByName(b,v,w);var p=[];var c=[];var C="";if("date" in a){C=a.date;}this.filterByDate(C,p,c);var g=[];var f=[];var t="";if("text" in a){t=a.text;}this.filterByText(t,g,f);var x=[];var m=[];var A="";if("tag" in a){A=a.tag;}this.filterByTag(A,x,m);var u=[];var e=[];var k="";if("state" in a){k=a.state;}this.filterByState(k,u,e);var d=[];var z=[];for(var y=0,j=v.length;yc){if(e.reply_to_id==null){d.push(e.id);}else{a.push(e.id);}}}},getCommentsAndRepliesCounts:function(d){var b=0;var f=0;var a=(d)?this.allComments:this.comments;var e=this.getThreads(a);for(var c=0;c
    '+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()&&(sv_prefix=="")){this.overlay.get("contentBox").query(".c-permalink").removeClass("displaynone");}},onMouseLeaveHeader:function(){if(readyForAction()&&this.isVisible()&&(sv_prefix=="")){this.overlay.get("contentBox").query(".c-permalink").addClass("displaynone");}},setWidth:function(a){this.overlay.get("boundingBox").setStyle("width",a+"px");},activate:function(){this.overlay.get("boundingBox").addClass("c-focus-comment");},deactivate:function(){this.overlay.get("boundingBox").removeClass("c-focus-comment");},hide:function(){if(gIComments.isTopActive(this.commentId)){if(!gIComments.activateVisibleNext()){gIComments.deactivate();}}if(this.isVisible()){this.overlay.hide();this.overlay.blur();}},hideContent:function(){this.overlay.get("contentBox").query(".icomment-header").addClass("displaynone");this.overlay.get("contentBox").query(".icomment-body").addClass("displaynone");},showContent:function(){this.overlay.get("contentBox").query(".icomment-header").removeClass("displaynone");this.overlay.get("contentBox").query(".icomment-body").removeClass("displaynone");},isVisible:function(){return this.overlay.get("visible");},show:function(){this.hideReadRepliesLnk();return this.overlay.show();},showReadRepliesLnk:function(){this.overlay.get("contentBox").query(".c-readreplies").removeClass("displaynone");},hideReadRepliesLnk:function(){this.overlay.get("contentBox").query(".c-readreplies").addClass("displaynone");},changeModeration:function(b){var a=this.overlay.get("contentBox").query(".c-moderate");a.set("innerHTML",gettext(b.state));a.removeClass("c-state-approved");a.removeClass("c-state-pending");a.removeClass("c-state-unapproved");a.addClass("c-state-"+b.state);this.overlay.get("contentBox").query(".c-iactions").removeClass("displaynone");this.overlay.get("contentBox").query(".c-state-actions").addClass("displaynone");},isfetched:function(){return(this.commentId!=null);},unfetch:function(){this.commentId=null;},fetch:function(h){this.commentId=h.id;var b=this.overlay.get("boundingBox");if(h.start_wrapper!=-1){b.addClass("c-has-scope");b.removeClass("c-has-no-scope");}else{b.addClass("c-has-no-scope");b.removeClass("c-has-scope");}if(h.reply_to_id!=null){b.addClass("c-is-reply");}else{b.removeClass("c-is-reply");}var f=interpolate(gettext("last modified on %(date)s"),{date:h.modified_user_str},true);var k=(h.modified==h.created)?"":' * ';var i=gettext("Permalink to this comment");var n="";if(sv_prefix==""){n='¶ ';}var j=interpolate(gettext("by %(name)s, created on %(date)s"),{name:h.name,date:h.created_user_str},true);var c='
    '+h.title+n+'
    '+j+"
    ";var d=CY.Node.create(c);var o=b.query(".c-header");if(o==null){b.query(".icomment-header").insertBefore(d,b.one(".c-iactions"));}else{o.get("parentNode").replaceChild(d,o);}var g=CY.Node.create('
    tags:'+h.tags+"
    ");var m=b.query(".c-tags");if(m==null){b.query(".icomment-header").appendChild(g);}else{m.get("parentNode").replaceChild(g,m);}if(h.tags==""){g.addClass("displaynone");}var e=CY.Node.create(''+h.content_html+"");var a=b.query(".c-content");if(a==null){b.query(".icomment-body").appendChild(e);}else{a.get("parentNode").replaceChild(e,a);}if(sv_prefix==""){b.query(".c-permalink").set("href",sv_site_url+h.permalink);}this.changeModeration(h);var l=b.queryAll(".c-content a");if(l!=null){l.setAttribute("target","_blank");}l=b.queryAll(".c-header-title a");if(l!=null){l.setAttribute("target","_blank");}this.permAdapt(h);},permAdapt:function(e){var b=this.overlay.get("contentBox").query(".c-delete");if(b){if(!e.can_delete){b.addClass("displaynone");}else{b.removeClass("displaynone");}}var a=this.overlay.get("contentBox").query(".c-edit");if(a){if(!e.can_edit){a.addClass("displaynone");}else{a.removeClass("displaynone");}}var d=this.overlay.get("contentBox").query(".c-reply");if(d){if(!hasPerm("can_create_comment")){d.addClass("displaynone");}else{d.removeClass("displaynone");}}var c=this.overlay.get("contentBox").query(".c-moderate");if(c){if(!e.can_moderate){c.addClass("displaynone");}else{c.removeClass("displaynone");}}},setThreadPad:function(a){this.overlay.get("contentBox").query(".yui-widget-hd").setStyle("paddingLeft",a+"px");this.overlay.get("contentBox").query(".yui-widget-bd").setStyle("paddingLeft",a+"px");},setPosition:function(b){var a=this.overlay.get("boundingBox");a.setStyle("opacity",1);a.setXY(b);},getPosition:function(b){var a=this.overlay.get("boundingBox");return a.getXY();},onAnimationEnd:function(){if(!CY.Lang.isUndefined(this["animation-handle"])&&!CY.Lang.isNull(this["animation-handle"])){this["animation-handle"].detach();this["animation-handle"]=null;}gIComments.signalAnimationEnd();if(gIComments.animationsEnded()){gIComments.whenAnimationsEnd();}},setAnimationToPosition:function(b){var a=this.overlay.get("boundingBox");if(gPrefs.get("general","animduration")<0.011){a.setXY(b);}this.animation.set("to",{xy:b});this.animation.set("duration",gPrefs.get("general","animduration"));this["animation-handle"]=this.animation.on("end",this.onAnimationEnd,this);return this.animation;},getHeight:function(){return this.overlay.get("boundingBox").get("offsetHeight");},scrollIntoView:function(){if(!this.overlay.get("contentBox").inViewportRegion()){this.overlay.get("contentBox").scrollIntoView(true);}},_isHostingAForm:function(){return(this.isVisible()&&((gNewReplyHost!=null&&gNewReplyHost==this)||(gEditICommentHost!=null&&gEditICommentHost==this)));}};gEditICommentHost=null;gEdit=null;dbgc=null;showEditForm=function(a){if(gEdit==null){gEdit={ids:{formId:CY.guid(),formTitleId:CY.guid(),nameInputId:CY.guid(),emailInputId:CY.guid(),titleInputId:CY.guid(),contentInputId:CY.guid(),tagsInputId:CY.guid(),formatInputId:CY.guid(),startWrapperInputId:CY.guid(),endWrapperInputId:CY.guid(),startOffsetInputId:CY.guid(),endOffsetInputId:CY.guid(),changeScopeInputId:CY.guid(),changeScopeInputWrapper:CY.guid(),selectionPlaceId:CY.guid(),keyId:CY.guid(),editCommentId:CY.guid(),currentSelId:CY.guid(),currentSelIdI:CY.guid(),addBtnId:CY.guid(),cancelBtnId:CY.guid()},handlers:{}};}gEditICommentHost=a;gEditICommentHost.hideContent();var c=getHtml(gEdit.ids);var b='
    '+c.headerContent+"
    ";var e='
    '+c.bodyContent+"
    ";gEditICommentHost.overlay.setStdModContent(CY.WidgetStdMod.HEADER,CY.Node.create(b),CY.WidgetStdMod.AFTER);gEditICommentHost.overlay.setStdModContent(CY.WidgetStdMod.BODY,CY.Node.create(e),CY.WidgetStdMod.AFTER);CY.get("#"+gEdit.ids["formTitleId"]).set("innerHTML",gettext("Edit comment"));var f=gDb.getComment(gEditICommentHost.commentId);CY.get("#"+gEdit.ids["editCommentId"]).set("value",f.id);CY.get("#"+gEdit.ids["keyId"]).set("value",f.key);CY.get("#"+gEdit.ids["changeScopeInputId"]+" input").set("checked",false);if(f.reply_to_id!=null){CY.get("#"+gEdit.ids["changeScopeInputId"]).addClass("displaynone");}changeScopeFormClick();CY.get("#"+gEdit.ids["nameInputId"]).set("value",f.name);CY.get("#"+gEdit.ids["emailInputId"]).set("value",f.email);if(f.logged_author){CY.get("#"+gEdit.ids["nameInputId"]).setAttribute("disabled",true);CY.get("#"+gEdit.ids["emailInputId"]).setAttribute("disabled",true);}CY.get("#"+gEdit.ids["titleInputId"]).set("value",f.title);CY.get("#"+gEdit.ids["contentInputId"]).set("value",f.content);CY.get("#"+gEdit.ids["tagsInputId"]).set("value",f.tags);CY.get("#"+gEdit.ids["formatInputId"]).set("value",gConf.defaultCommentFormat);var d=gLayout.getTopICommentsWidth();changeFormFieldsWidth(gEdit.ids["formId"],d);gEdit.handlers["addBtnId"]=CY.on("click",onEditSaveClick,"#"+gEdit.ids["addBtnId"]);gEdit.handlers["cancelBtnId"]=CY.on("click",onEditCancelClick,"#"+gEdit.ids["cancelBtnId"]);gEdit.handlers["changeScope"]=CY.on("click",onChangeScopeClick,"#"+gEdit.ids["changeScopeInputId"]);};onEditSaveClick=function(a){if(readyForAction()){gSync.editComment();}};onEditCancelClick=function(a){if(readyForAction()){gSync.cancelEdit();}};onChangeScopeClick=function(){if(readyForAction()){gSync.changeScopeFormClick();}else{var a=CY.get("#"+gEdit.ids["changeScopeInputId"]+" input");var b=a.get("checked");a.set("checked",!b);}};changeScopeFormClick=function(){var a=CY.get("#"+gEdit.ids["currentSelId"]);if(CY.get("#"+gEdit.ids["changeScopeInputId"]+" input").get("checked")){a.removeClass("displaynone");}else{a.addClass("displaynone");}};cancelEditForm=function(){if(gEditICommentHost!=null){for(var b in gEdit.handlers){if(gEdit.handlers[b]!=null){gEdit.handlers[b].detach();gEdit.handlers[b]=null;}}var a=gEditICommentHost.overlay.get("contentBox").query(".icomment-edit-body");a.get("parentNode").removeChild(a);a=gEditICommentHost.overlay.get("contentBox").query(".icomment-edit-header");a.get("parentNode").removeChild(a);gEditICommentHost.showContent();gEditICommentHost=null;}};var gtest={renaud:"RENAUD",random:Math.random(),bernard:"BERNARD",myFunc:function(){doExchange("theServerFun",{},null,this.myRetFunc,this,["foo","bar"]);},myRetFunc:function(a){CY.log("this.renaud : "+this.renaud);CY.log("this.random : "+this.random);CY.log("arg.returned : "+a.returned);CY.log(a.returned);CY.log("arg.success : "+a.success);CY.log(a.success);}};doExchange=function(h,e,g,f,d,c,b){e.fun=h;e.key=sv_key;e.version_key=sv_version_key;var a={method:"POST",data:urlEncode(e),on:{success:function(l,k,j){var i={};if(k.responseText){i=CY.JSON.parse(k.responseText);}if(gLayout.isInFrame()&&("msg" in i)){parent.f_enqueueMsg(i.msg);}j.returned=i;j.successfull=true;f.call(d,j);},failure:function(k,j,i){if(gLayout.isInFrame()){parent.f_enqueueErrorMsg(gettext("error:")+b);}i.successfull=false;f.call(d,i);}},arguments:{success:c,failure:c}};if(g!=null){a.form={id:g};}CY.io(sv_client_url,a);};warn_server=function(c){c.fun="warn";c.key=sv_key;c.version_key=sv_version_key;var b=CY.UA;var a={method:"POST",data:urlEncode(CY.merge(c,b))};CY.io("/client/",a);};paintCommentScope=function(b){if(b.reply_to_id==null&&b.start_wrapper!=-1){var a={start:{elt:document.getElementById("sv_"+b.start_wrapper),offset:b.start_offset},end:{elt:document.getElementById("sv_"+b.end_wrapper),offset:b.end_offset}};if(document.getElementById("sv_"+b.start_wrapper)==null){warn_server({from:"paintCommentScope",start_wrapper:b.start_wrapper});}else{if(document.getElementById("sv_"+b.end_wrapper)==null){warn_server({from:"paintCommentScope",end_wrapper:b.end_wrapper});}else{a.start=_convertSelectionFromCSToCC(a.start);a.end=_convertSelectionFromCSToCC(a.end);renderComment(a,b.id);}}}};getCommentIdsFromClasses=function(b){var a=[];var e=b.className.split(" ");for(var d=0,c=e.length;d=d.offset){a.elt=e;a.offset=d.offset-b;break;}e=e.nextSibling;}return a;};unpaintCommentScope=function(k){var j=k.id;var r="c-id-"+j;var m=[];var t=CY.all("."+r);if(t!=null){for(var h=0,d=t.size();h0){this._animateTo(f);}}},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();},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();var c=CY.Array.map(f,function(h){return gDb.getComment(h);});var a=gDb.getThreads(c);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);}}}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)});},_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;});this.showComments(b,[0,0],true);},this,null);},showScopeRemovedComments:function(){checkForOpenedDialog(null,function(){gShowingAllComments=true;var c=CY.Array.filter(gDb.comments,function(a){return(a.start_wrapper==-1);});var d=CY.Array.map(c,function(a){return a.id;});this.showComments(d,[0,0],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(d){this._q.add({fn:CY.bind(this.setPreventClickOn,this)});var c=gIComments.getTopPosition()[1];this._q.add({fn:function(){gIComments.open(d.commentId);gIComments.refresh(d.commentId);}});this._animateTo(c);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;};getWrapperAncestor=function(d){var c=d;while(c!=null){if(CY.DOM.hasClass(c,"c-s")){return c;}c=c.parentNode;}return null;};hasWrapperAncestor=function(b){return(getWrapperAncestor(b)!=null);};getSelectionInfo=function(){var j=null,ac=null,T=0,aj=0,af="";if(window.getSelection){var V=window.getSelection();if(V.rangeCount>0){var ad=V.getRangeAt(0);af=ad.toString();if(af!=""){var R=document.createRange();R.setStart(V.anchorNode,V.anchorOffset);R.collapse(true);var W=document.createRange();W.setEnd(V.focusNode,V.focusOffset);W.collapse(false);var K=(W.compareBoundaryPoints(2,R)==1);j=(K)?V.anchorNode.parentNode:V.focusNode.parentNode;innerStartNode=(K)?V.anchorNode:V.focusNode;ac=(K)?V.focusNode.parentNode:V.anchorNode.parentNode;innerEndNode=(K)?V.focusNode:V.anchorNode;T=(K)?V.anchorOffset:V.focusOffset;aj=(K)?V.focusOffset:V.anchorOffset;if(!hasWrapperAncestor(ac)&&hasWrapperAncestor(j)){var e=document.createRange();e.setStart(innerStartNode,T);var ak=getWrapperAncestor(j);var X=ak;e.setEndAfter(X);var ah=parseInt(ak.id.substring("sv_".length));while(e.toString().lengthN.compareBoundaryPoints(2,ad))){j=ae.firstChild;T=0;ac=Q.lastChild;aj=CY.DOM.getText(Q).length;M=true;break;}}if(M){break;}}}}}R.detach();W.detach();}else{return null;}}else{return null;}}else{if(document.selection){var ai=document.selection.createRange();if(ai.text.length==0){return null;}var al=ai.parentElement();var L=ai.duplicate();var P=ai.duplicate();L.collapse(true);P.collapse(false);j=L.parentElement();while(L.moveStart("character",-1)!=0){if(L.parentElement()!=j){break;}T++;}ac=P.parentElement();while(P.moveEnd("character",-1)!=0){if(P.parentElement()!=ac){break;}aj++;}af=ai.text;}}if(!hasWrapperAncestor(j)||!hasWrapperAncestor(ac)){return null;}return{text:af,start:{elt:j,offset:T},end:{elt:ac,offset:aj}};};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(i,l,j){var k=l[j];for(var n=0;nu[v.id]){u[v.id]=B;}}}for(var D in u){var x=this.allCommentsByDbId[D].id;var a=false;for(var w=0,C=t.length;w0){e=e.concat(this.getThreads(f[d].replies));}}return e;},_getPath:function(c,g){var f=[g];var h=g;while(h.reply_to_id!=null){h=c[h.reply_to_id];f.push(h);}return f;},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(R){var ad={};if(R){for(key in R){if(key.indexOf("filter_")==0){ad[key.substr("filter_".length)]=R[key];}}}else{if(gLayout.isInFrame()){ad=parent.f_getFrameFilterData();}}var G=[];var F=[];var ac="";if("name" in ad){ac=ad.name;}this.filterByName(ac,G,F);var P=[];var ab=[];var L="";if("date" in ad){L=ad.date;}this.filterByDate(L,P,ab);var X=[];var Y=[];var I="";if("text" in ad){I=ad.text;}this.filterByText(I,X,Y);var E=[];var S=[];var O="";if("tag" in ad){O=ad.tag;}this.filterByTag(O,E,S);var H=[];var Z=[];var U="";if("state" in ad){U=ad.state;}this.filterByState(U,H,Z);var aa=[];var i=[];for(var D=0,V=G.length;Dl){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;l
    '+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()&&(sv_prefix=="")){this.overlay.get("contentBox").query(".c-permalink").removeClass("displaynone");}},onMouseLeaveHeader:function(){if(readyForAction()&&this.isVisible()&&(sv_prefix=="")){this.overlay.get("contentBox").query(".c-permalink").addClass("displaynone");}},setWidth:function(b){this.overlay.get("boundingBox").setStyle("width",b+"px");},activate:function(){this.overlay.get("boundingBox").addClass("c-focus-comment");},deactivate:function(){this.overlay.get("boundingBox").removeClass("c-focus-comment");},hide:function(){if(gIComments.isTopActive(this.commentId)){if(!gIComments.activateVisibleNext()){gIComments.deactivate();}}if(this.isVisible()){this.overlay.hide();this.overlay.blur();}},hideContent:function(){this.overlay.get("contentBox").query(".icomment-header").addClass("displaynone");this.overlay.get("contentBox").query(".icomment-body").addClass("displaynone");},showContent:function(){this.overlay.get("contentBox").query(".icomment-header").removeClass("displaynone");this.overlay.get("contentBox").query(".icomment-body").removeClass("displaynone");},isVisible:function(){return this.overlay.get("visible");},show:function(){this.hideReadRepliesLnk();return this.overlay.show();},showReadRepliesLnk:function(){this.overlay.get("contentBox").query(".c-readreplies").removeClass("displaynone");},hideReadRepliesLnk:function(){this.overlay.get("contentBox").query(".c-readreplies").addClass("displaynone");},changeModeration:function(c){var d=this.overlay.get("contentBox").query(".c-moderate");d.set("innerHTML",gettext(c.state));d.removeClass("c-state-approved");d.removeClass("c-state-pending");d.removeClass("c-state-unapproved");d.addClass("c-state-"+c.state);this.overlay.get("contentBox").query(".c-iactions").removeClass("displaynone");this.overlay.get("contentBox").query(".c-state-actions").addClass("displaynone");},isfetched:function(){return(this.commentId!=null);},unfetch:function(){this.commentId=null;},fetch:function(w){this.commentId=w.id;var C=this.overlay.get("boundingBox");if(w.start_wrapper!=-1){C.addClass("c-has-scope");C.removeClass("c-has-no-scope");}else{C.addClass("c-has-no-scope");C.removeClass("c-has-scope");}if(w.reply_to_id!=null){C.addClass("c-is-reply");}else{C.removeClass("c-is-reply");}var y=interpolate(gettext("last modified on %(date)s"),{date:w.modified_user_str},true);var t=(w.modified==w.created)?"":' * ';var v=gettext("Permalink to this comment");var q="";if(sv_prefix==""){q='¶ ';}var u=interpolate(gettext("by %(name)s, created on %(date)s"),{name:w.name,date:w.created_user_str},true);var B='
    '+w.title+q+'
    '+u+"
    ";var A=CY.Node.create(B);var p=C.query(".c-header");if(p==null){C.query(".icomment-header").insertBefore(A,C.one(".c-iactions"));}else{p.get("parentNode").replaceChild(A,p);}var x=CY.Node.create('
    tags:'+w.tags+"
    ");var r=C.query(".c-tags");if(r==null){C.query(".icomment-header").appendChild(x);}else{r.get("parentNode").replaceChild(x,r);}if(w.tags==""){x.addClass("displaynone");}var z=CY.Node.create(''+w.content_html+"");var D=C.query(".c-content");if(D==null){C.query(".icomment-body").appendChild(z);}else{D.get("parentNode").replaceChild(z,D);}if(sv_prefix==""){C.query(".c-permalink").set("href",sv_site_url+w.permalink);}this.changeModeration(w);var s=C.queryAll(".c-content a");if(s!=null){s.setAttribute("target","_blank");}s=C.queryAll(".c-header-title a");if(s!=null){s.setAttribute("target","_blank");}this.permAdapt(w);},permAdapt:function(h){var f=this.overlay.get("contentBox").query(".c-delete");if(f){if(!h.can_delete){f.addClass("displaynone");}else{f.removeClass("displaynone");}}var g=this.overlay.get("contentBox").query(".c-edit");if(g){if(!h.can_edit){g.addClass("displaynone");}else{g.removeClass("displaynone");}}var i=this.overlay.get("contentBox").query(".c-reply");if(i){if(!hasPerm("can_create_comment")){i.addClass("displaynone");}else{i.removeClass("displaynone");}}var j=this.overlay.get("contentBox").query(".c-moderate");if(j){if(!h.can_moderate){j.addClass("displaynone");}else{j.removeClass("displaynone");}}},setThreadPad:function(b){this.overlay.get("contentBox").query(".yui-widget-hd").setStyle("paddingLeft",b+"px");this.overlay.get("contentBox").query(".yui-widget-bd").setStyle("paddingLeft",b+"px");},setPosition:function(c){var d=this.overlay.get("boundingBox");d.setStyle("opacity",1);d.setXY(c);},getPosition:function(c){var d=this.overlay.get("boundingBox");return d.getXY();},onAnimationEnd:function(){if(!CY.Lang.isUndefined(this["animation-handle"])&&!CY.Lang.isNull(this["animation-handle"])){this["animation-handle"].detach();this["animation-handle"]=null;}gIComments.signalAnimationEnd();if(gIComments.animationsEnded()){gIComments.whenAnimationsEnd();}},setAnimationToPosition:function(c){var d=this.overlay.get("boundingBox");if(gPrefs.get("general","animduration")<0.011){d.setXY(c);}this.animation.set("to",{xy:c});this.animation.set("duration",gPrefs.get("general","animduration"));this["animation-handle"]=this.animation.on("end",this.onAnimationEnd,this);return this.animation;},getHeight:function(){return this.overlay.get("boundingBox").get("offsetHeight");},scrollIntoView:function(){if(!this.overlay.get("contentBox").inViewportRegion()){this.overlay.get("contentBox").scrollIntoView(true);}},_isHostingAForm:function(){return(this.isVisible()&&((gNewReplyHost!=null&&gNewReplyHost==this)||(gEditICommentHost!=null&&gEditICommentHost==this)));}};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(),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");}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);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 d=CY.get("#"+gEdit.ids.changeScopeInputId+" input");var c=d.get("checked");d.set("checked",!c);}};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 c in gEdit.handlers){if(gEdit.handlers[c]!=null){gEdit.handlers[c].detach();gEdit.handlers[c]=null;}}var d=gEditICommentHost.overlay.get("contentBox").query(".icomment-edit-body");d.get("parentNode").removeChild(d);d=gEditICommentHost.overlay.get("contentBox").query(".icomment-edit-header");d.get("parentNode").removeChild(d);gEditICommentHost.showContent();gEditICommentHost=null;}};var gtest={renaud:"RENAUD",random:Math.random(),bernard:"BERNARD",myFunc:function(){doExchange("theServerFun",{},null,this.myRetFunc,this,["foo","bar"]);},myRetFunc:function(b){CY.log("this.renaud : "+this.renaud);CY.log("this.random : "+this.random);CY.log("arg.returned : "+b.returned);CY.log(b.returned);CY.log("arg.success : "+b.success);CY.log(b.success);}};doExchange=function(k,n,l,m,o,p,i){n.fun=k;n.key=sv_key;n.version_key=sv_version_key;var j={method:"POST",data:urlEncode(n),on:{success:function(a,b,c){var d={};if(b.responseText){d=CY.JSON.parse(b.responseText);}if(gLayout.isInFrame()&&("msg" in d)){parent.f_enqueueMsg(d.msg);}c.returned=d;c.successfull=true;m.call(o,c);},failure:function(a,b,c){if(gLayout.isInFrame()){parent.f_enqueueErrorMsg(gettext("error:")+i);}c.successfull=false;m.call(o,c);}},arguments:{success:p,failure:p}};if(l!=null){j.form={id:l};}CY.io(sv_client_url,j);};warn_server=function(f){f.fun="warn";f.key=sv_key;f.version_key=sv_version_key;var d=CY.UA;var e={method:"POST",data:urlEncode(CY.merge(f,d))};CY.io("/client/",e);};paintCommentScope=function(c){if(c.reply_to_id==null&&c.start_wrapper!=-1){var d={start:{elt:document.getElementById("sv_"+c.start_wrapper),offset:c.start_offset},end:{elt:document.getElementById("sv_"+c.end_wrapper),offset:c.end_offset}};if(document.getElementById("sv_"+c.start_wrapper)==null){warn_server({from:"paintCommentScope",start_wrapper:c.start_wrapper});}else{if(document.getElementById("sv_"+c.end_wrapper)==null){warn_server({from:"paintCommentScope",end_wrapper:c.end_wrapper});}else{d.start=_convertSelectionFromCSToCC(d.start);d.end=_convertSelectionFromCSToCC(d.end);renderComment(d,c.id);}}}};getCommentIdsFromClasses=function(f){var g=[];var h=f.className.split(" ");for(var i=0,j=h.length;i=k.offset){h.elt=j;h.offset=k.offset-g;break;}j=j.nextSibling;}return h;};unpaintCommentScope=function(v){var w=v.id;var c="c-id-"+w;var p=[];var E=CY.all("."+c);if(E!=null){for(var x=0,B=E.size();x";var e=gFormHtml.formStart.replace("###",gNewReply.ids["formId"]);if(!sv_loggedIn){e=e+gFormHtml.nameInput.replace("###",gNewReply.ids["nameInputId"])+gFormHtml.emailInput.replace("###",gNewReply.ids["emailInputId"]);}e=e+gFormHtml.titleInput.replace("###",gNewReply.ids["titleInputId"])+gFormHtml.contentInput.replace("###",gNewReply.ids["contentInputId"])+gFormHtml.tagsInput.replace("###",gNewReply.ids["tagsInputId"]);e=e+gFormHtml.hidden.replace("###",gNewReply.ids["keyInputId"]).replace("???","comment_key");e=e+gFormHtml.hidden.replace("###",gNewReply.ids["formatInputId"]).replace("???","format");e=e+gFormHtml.hidden.replace("###",gNewReply.ids["parentCommentId"]).replace("???","reply_to_id");var h=gFormHtml.btns.replace("###",gNewReply.ids["addBtnId"]).replace("???",gNewReply.ids["cancelBtnId"]);gNewReplyHost.overlay.setStdModContent(CY.WidgetStdMod.FOOTER,b+e+h);var c=gNewReplyHost.overlay.getStdModNode(CY.WidgetStdMod.FOOTER);var f=gDb.getComment(i.commentId);var a="Re: ";var g=(gNewReply.val["title"]==""||gNewReply.val["title"].substring(0,a.length)==a)?a+f.title:gNewReply.val["title"];if(!sv_loggedIn){c.query(".n_name").set("value",gNewReply.val["name"]);c.query(".n_email").set("value",gNewReply.val["email"]);}c.query(".n_title").set("value",g);c.query(".n_content").set("value",gNewReply.val["content"]);c.query(".n_tags").set("value",gNewReply.val["tags"]);c.query("#"+gNewReply.ids["parentCommentId"]).set("value",i.commentId);c.query("#"+gNewReply.ids["formatInputId"]).set("value",gConf.defaultCommentFormat);gNewReplyHost.overlay.get("contentBox").query(".c-reply").addClass("displaynone");gNewReply.handlers["addBtnId"]=CY.on("click",onAddNewReplyClick,"#"+gNewReply.ids["addBtnId"]);gNewReply.handlers["cancelBtnId"]=CY.on("click",onCancelNewReplyClick,"#"+gNewReply.ids["cancelBtnId"]);var d=gLayout.getTopICommentsWidth();changeFormFieldsWidth(gNewReply.ids["formId"],d);};cleanNewReplyForm=function(){if(gNewReplyHost!=null){var a=gNewReplyHost.overlay.getStdModNode(CY.WidgetStdMod.FOOTER);a.queryAll(".comment_input").set("value","");}};cancelNewReplyForm=function(){if(gNewReplyHost!=null){for(var b in gNewReply.handlers){if(gNewReply.handlers[b]!=null){gNewReply.handlers[b].detach();gNewReply.handlers[b]=null;}}gNewReplyHost.overlay.get("contentBox").query(".c-reply").removeClass("displaynone");var a=gNewReplyHost.overlay.getStdModNode(CY.WidgetStdMod.FOOTER);if(!sv_loggedIn){gNewReply.val["name"]=a.query(".n_name").get("value");gNewReply.val["email"]=a.query(".n_email").get("value");}gNewReply.val["title"]=a.query(".n_title").get("value");gNewReply.val["content"]=a.query(".n_content").get("value");gNewReply.val["tags"]=a.query(".n_tags").get("value");a.set("innerHTML","");gNewReplyHost=null;}};onAddNewReplyClick=function(){if(!sv_loggedIn){var b=CY.get("#"+gNewReply.ids["nameInputId"]).get("value");gPrefs.persist("user","name",b);var a=CY.get("#"+gNewReply.ids["emailInputId"]).get("value");gPrefs.persist("user","email",a);}gSync.saveComment(gNewReply.ids["formId"]);};onCancelNewReplyClick=function(){gSync.cancelReply();};_changeIds=function(a,b){if(a.id){a.id=a.id+b;}var d=a.firstChild;while(d!=null){_changeIds(d,b);d=d.nextSibling;}};suffix=0;domDuplicate=function(a){var b=a.cloneNode(true);suffix++;_changeIds(b,"-"+suffix);return b;};getDuplicated=function(a){return document.getElementById(a.id+"-"+suffix);};logSel=function(a){log("text :"+a.text+", start id : "+a.start["elt"].id+" , start offset : "+a.start["offset"]+" , end id : "+a.end["elt"].id+"end offset : "+a.end["offset"]);};log=function(b){var a=document.getElementById("log");a.innerHTML=a.innerHTML+"
  • "+b+"
  • ";};urlEncode=function(h){if(!h){return"";}var c=[];for(var f in h){var e=h[f],b=encodeURIComponent(f);var g=typeof e;if(g=="undefined"){c.push(b,"=&");}else{if(g!="function"&&g!="object"){c.push(b,"=",encodeURIComponent(e),"&");}else{if(CY.Lang.isArray(e)){if(e.length){for(var d=0,a=e.length;de[d]){b=e[g];e[g]=e[d];e[d]=b;}return;}a=e[parseInt((g+d)/2)];e[parseInt((g+d)/2)]=e[g];e[g]=a;c=g+1;f=d;do{while(c<=f&&e[c]<=a){c++;}while(e[f]>a){f--;}if(c0){b.showReadRepliesLnk();}else{b.hideReadRepliesLnk();}},remove:function(a){this._remove(this._getChildren(a));},close:function(a){CY.Array.each(this._getChildren(a),function(b){b.hide();});},open:function(a){CY.Array.each(this._getChildren(a),function(b){b.show();});},fetch:function(b){for(var a=0;a=0)&&e<=(this._c.length-1);){var c=this._c[e];if(c.commentId!=null&&c.isVisible()){a=a||(gDb.isChild(c.commentId,this._topActiveCommentDbId));if(a&&(!gDb.isChild(c.commentId,this._topActiveCommentDbId))){this.activate(c.commentId);return true;}}e=(d==0)?e+1:e-1;}}}return false;},browse:function(b,c){var a=c;if((c=="prev")&&!this.isAnyActive()){a="last";}if((c=="next")&&!this.isAnyActive()){a="first";}return gDb.browse(b,a,this._topActiveCommentDbId);}};_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,[]);}};gNoSelectionYet=gettext("No selection yet");gFormHtml={formStart:'
    ',nameInput:gettext("Username:")+'
    ',emailInput:gettext("E-mail address:")+'
    ',titleInput:gettext("Title:")+'
    ',contentInput:gettext("Content:")+'
    ',tagsInput:gettext("Tag:")+'
    ',hidden:'',formEnd:"
    ",changeScope:'
    '+gettext("Modify comment's scope:")+'
    ',headerTitle:'
    ',currentSel:'
    '+gettext("Comment will apply to this selection:")+'
    '+gNoSelectionYet+"
    #hiddeninput#
    ",btns:'
    ',closeIcon:'      '};getHtml=function(f){ret={};ret.headerContent="";if("closeBtnId" in f){ret.headerContent+=gFormHtml.closeIcon.replace("###",f.closeBtnId);}ret.headerContent+=gFormHtml.headerTitle.replace("###",f.formTitleId);var b="";if("changeScopeInputId" in f){b=gFormHtml.changeScope.replace("###",f.changeScopeInputId);}var e="
    "+gFormHtml.hidden.replace("###",f.selectionPlaceId).replace("???","selection_place")+"
    ";var a=gFormHtml.currentSel.replace("###",f.currentSelId).replace("???",f.currentSelIdI).replace("#hiddeninput#",e);var d=gFormHtml.btns.replace("###",f.addBtnId).replace("???",f.cancelBtnId);var c=gFormHtml.formStart.replace("###",f.formId)+b+a;if("nameInputId" in f){c=c+gFormHtml.nameInput.replace("###",f.nameInputId);}if("emailInputId" in f){c=c+gFormHtml.emailInput.replace("###",f.emailInputId);}c=c+gFormHtml.titleInput.replace("###",f.titleInputId)+gFormHtml.contentInput.replace("###",f.contentInputId)+gFormHtml.tagsInput.replace("###",f.tagsInputId);c=c+gFormHtml.hidden.replace("###",f.formatInputId).replace("???","format");c=c+gFormHtml.hidden.replace("###",f.startWrapperInputId).replace("???","start_wrapper");c=c+gFormHtml.hidden.replace("###",f.endWrapperInputId).replace("???","end_wrapper");c=c+gFormHtml.hidden.replace("###",f.startOffsetInputId).replace("???","start_offset");c=c+gFormHtml.hidden.replace("###",f.endOffsetInputId).replace("???","end_offset");c=c+gFormHtml.hidden.replace("###",f.keyId).replace("???","comment_key");c=c+gFormHtml.hidden.replace("###",f.editCommentId).replace("???","edit_comment_id");c=c+d+gFormHtml.formEnd;ret.bodyContent=c;return ret;};changeFormFieldsWidth=function(d,c){var a=(c-20)+"px";var b=CY.all("#"+d+" input[type='text']");if(b!=null){b.setStyle("width",a);}b=CY.all("#"+d+" textarea");if(b!=null){b.setStyle("width",a);}};addFormErrMsg=function(j,g,d){var f=document.getElementById(j);var b,h,c,a;for(b=0,a=f.elements.length;bb){var a=i.substring(0,(i.substring(0,b/2)).lastIndexOf(" "));var d=i.substring(i.length-b/2);var c=d.substring(d.indexOf(" "));f=a+" ... "+c;}var e=_convertSelectionFromCCToCS(h.start);var g=_convertSelectionFromCCToCS(h.end);_updateICommentFormSelection(gICommentForm,f,e,g);if(gEdit!=null){_updateICommentFormSelection(gEdit.ids,f,e,g);}positionICommentForm();}};showICommentForm=function(){removeFormErrMsg(gICommentForm.formId);if(!sv_loggedIn){if(CY.get("#"+gICommentForm.nameInputId).get("value")==""){CY.get("#"+gICommentForm.nameInputId).set("value",gPrefs.get("user","name"));}if(CY.get("#"+gICommentForm.emailInputId).get("value")==""){CY.get("#"+gICommentForm.emailInputId).set("value",gPrefs.get("user","email"));}}gIComments.hide();positionICommentForm();gICommentForm.overlay.show();CY.get("#"+gICommentForm.titleInputId).focus();};isICommentFormVisible=function(){if(gICommentForm!=null){return gICommentForm.overlay.get("visible");}return false;};positionICommentForm=function(){if(gICommentForm!=null){var b=gICommentForm.overlay;var a=b.get("boundingBox");var c=a.get("offsetHeight");var e=a.get("winHeight");var d=gICommentForm.position;if(c>e){d=[CY.WidgetPositionExt.BL,CY.WidgetPositionExt.BL];}b.set("align",{points:d});a.setX(a.getX()+gConf.iCommentLeftPadding);}};c_persistPreference=function(b,a,c){gPrefs.persist(b,a,c);};c_readDefaultPreference=function(b,a){return gConf.defaultPrefs[b][a];};c_readPreference=function(b,a){return gPrefs.get(b,a);};c_resetPreferences=function(a){gPrefs.reset(a);};c_applyTextStyle=function(a){CY.use(a);};sliderValToPx=function(d){var a=CY.DOM.winWidth();if(gLayout.isInFrame()){a=parent.$(parent).width();}var b=d/100;b=Math.min(b,gConf.sliderFixedMin);b=Math.max(b,gConf.sliderFixedMax);var c=b*a;return Math.floor(c);};c_setCommentsColWidth=function(c){var a=sliderValToPx(c);gLayout.setLeftColumnWidth(a);var b=gLayout.getTopICommentsWidthFromWidth(a);gIComments.setWidth(b);gICommentForm.overlay.get("boundingBox").setStyle("width",b+"px");changeFormFieldsWidth(gICommentForm.formId,b);if(gNewReply){changeFormFieldsWidth(gNewReply.ids["formId"],b);}if(gEdit){changeFormFieldsWidth(gEdit.ids["formId"],b);}};CY=null;gPrefs=null;gLayout=null;gDb=null;gIComments=null;gSync=null;gGETValues=null;gConf={iCommentLeftPadding:4,iCommentThreadPadding:12,defaultCommentFormat:"markdown",sliderFixedMin:0.9,sliderFixedMax:0.1,iCommentsInitAlloc:2,defaultPrefs:{text:{style:"text-modern-style"},user:{name:"",email:""},general:{animduration:"0.4"},comments:{threadpad:"1"},layout:{comments_col_width:"25"}}};gTextStyles={"text-modern-style":gettext("modern"),"text-classic-style":gettext("classic"),"text-code-style":gettext("code")};YUI({base:sv_media_url+"/js/lib/yui/"+c_yui_base+"/build/",timeout:10000}).use("text-modern-style","cookie","json","overlay","io-form","async-queue","event-mouseenter","anim","collection",function(a){CY=a;gPrefs=new Preferences();gPrefs.init();gLayout=new Layout();gLayout.init();if(sv_withComments){gDb=new Db();gDb.init();gIComments=new IComments();gIComments.init();}gSync=new Sync();gSync.init();CY.on("domready",onDomReady,this);});_reinit=function(a){gIComments.hide();gDb.initComments(a.commentIds);unpaintAllComments();renderCommentScopes();updateFilterResultsCount(a.nbDiscussions,a.nbComments,a.nbReplies);};reinit=function(b){var a=gDb.computeFilterResults(b);_reinit(a);};hideAll=function(){_reinit({commentIds:[],nbDiscussions:0,nbComments:0,nbReplies:0});};updateFilterResultsCount=function(f,a,b){var e=gDb.getCommentsAndRepliesCounts(true);var g=e[0],d=e[1];var c=(a!=0||b!=0)&&(g!=a||d!=b);if(gLayout.isInFrame()){parent.f_updateFilterCountDetailed(c);parent.f_updateFilterCountResult(f,a,b,g,d);}};updateResetFilterResultsCount=function(){var c=gDb.getCommentsAndRepliesCounts(false);var a=c[0],b=c[1];var d=a;updateFilterResultsCount(d,a,b);};renderCommentScopes=function(){for(var a=0;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();}},timeout:5},{fn:function(){gGETValues=CY.JSON.parse(sv_get_params);CY.get("#maincontainer").setStyle("display","block");CY.get("#textcontainer").setStyle("display","block");var e=(sv_withComments)?gPrefs.get("layout","comments_col_width"):0;var d=sliderValToPx(e);gLayout.setLeftColumnWidth(d);if(gLayout.isInFrame()){parent.f_initFrame();parent.f_layoutFrames();if(sv_withComments){parent.f_fillTopToolbar();if(hasPerm("can_create_comment")){parent.$("#add_comment_btn").removeClass("initially_hidden");}parent.f_fillFilterTab();parent.f_fillPreferencesTab();var c=CY.JSON.parse(sv_filter_data);parent.f_updateFilterData(c);parent.f_setFilterValue(gGETValues);}parent.f_fillTextPreferencesTab();}if(gLayout.isInComentSite()){parent.$("#c_fullscreen_btn").show();}else{parent.$("#c_fullscreen_btn").hide();}},timeout:5},{fn:function(){if(sv_withComments){reinit(gGETValues);initialConnect();}},timeout:5},{fn:function(){if(gLayout.isInFrame()){parent.f_interfaceUnfreeze();parent.f_removeLoadingMsg();}if("comment_id_key" in gGETValues){var d=gGETValues.comment_id_key;var f=gDb.getCommentByIdKey(d);if(f!=null){var e=gDb.getPath(f);var c=e[e.length-1];gSync.showSingleComment(c);}}if("comments_auto_display" in gGETValues){gSync.showAllComments();}}});a.run();}; \ No newline at end of file diff -r 2c52e4453bf7 -r c2c262ac1273 src/cm/media/js/client/c_icomment.js --- a/src/cm/media/js/client/c_icomment.js Thu Jul 15 16:10:55 2010 +0200 +++ b/src/cm/media/js/client/c_icomment.js Thu Jul 15 16:23:58 2010 +0200 @@ -198,13 +198,13 @@ }, onMouseEnterHeader : function () { - if (readyForAction() && this.isVisible()) { + if (readyForAction() && this.isVisible() && (sv_prefix=="")) { this.overlay.get('contentBox').query(".c-permalink").removeClass('displaynone'); } }, onMouseLeaveHeader : function () { - if (readyForAction() && this.isVisible()) { + if (readyForAction() && this.isVisible() && (sv_prefix=="")) { this.overlay.get('contentBox').query(".c-permalink").addClass('displaynone'); } }, @@ -302,7 +302,10 @@ var modifDateTooltip = (comment.modified == comment.created) ? '' : ' * ' ; var permaTitle = gettext('Permalink to this comment') ; - var permalink = '¶ ' ; + var permalink = ""; + if (sv_prefix=="") { + permalink = '¶ ' ; + } var infos = interpolate(gettext('by %(name)s, created on %(date)s'),{'name':comment.name, 'date':comment.created_user_str}, true) ; @@ -335,7 +338,9 @@ prevContentNode.get('parentNode').replaceChild(newContentNode, prevContentNode) ; // PERMALINK - boundingBoxNode.query(".c-permalink").set("href",sv_site_url + comment.permalink) ; + if (sv_prefix=="") { + boundingBoxNode.query(".c-permalink").set("href",sv_site_url + comment.permalink) ; + } // MODERATION this.changeModeration(comment) ; diff -r 2c52e4453bf7 -r c2c262ac1273 src/cm/templates/site/text_view_comments.html --- a/src/cm/templates/site/text_view_comments.html Thu Jul 15 16:10:55 2010 +0200 +++ b/src/cm/templates/site/text_view_comments.html Thu Jul 15 16:23:58 2010 +0200 @@ -107,7 +107,7 @@ {% else %} - + {% endif %} diff -r 2c52e4453bf7 -r c2c262ac1273 src/cm/templates/site/text_view_frame.html --- a/src/cm/templates/site/text_view_frame.html Thu Jul 15 16:10:55 2010 +0200 +++ b/src/cm/templates/site/text_view_frame.html Thu Jul 15 16:23:58 2010 +0200 @@ -36,7 +36,7 @@ {% else %} - + {% endif %}