var Comments={id:"Comments",title:"Comments",image:"comments16.gif",allowItems:true,allowFolders:false,AddDialog:"adddialog/60097927.js",UpdateDialog:"updatedialog/60098069.js",UpdateSectionDialog:"updateSectionDialog/68657157.js",itemName:"Comment",itemTagName:"TR",_0:true,initSection:function(s){var sp=s.permissions;if(sp.addComment){sp.addContent=true;sp.editOwnContent=true;sp.deleteOwnContent=true}},defaultLayout:"List",detailLayout:"Detail",dataGrid:{getCommand:"comments/getitems",ownerLayouts:["ManagementDetails"],itemId:"CommentId",getSelectionTitle:function(item){return'"'+item.title+'"'}},updateSection:function(s){Module.showDialog(Comments,"UpdateSectionDialog",{section:s})},sendMessage:function(item,dlg){var us=item.userSummary;var user=(us?us.userName:item.createdBy);dlg.to=user},onBeforeUpdateSection:function(s,props){var t=Comments;if(props.maxItems||props.lid){t._1(s)}},onSectionMessage:function(s,msg,args){var t=Comments;if(msg=="changed"){t._1(s)}},_1:function(s){var t=Comments;t._2(s,{sortDescending:false})},_4:function(s){var e=Dom.getElement(s.nodeId+".CommentsDisplayMessage");if(e){e.innerHTML="Retrieving Comments"}},_2:function(s,args){var t=Comments;t._4(s);args.page=page.pageId;args.section=s.nodeId;args.layout=s.lid||t.defaultLayout;var state={sid:s.nodeId};C.beginExec("comments/getitems",args,t._6,state)},_6:function(response,state){var t=Comments;var s=page.nodes[state.sid];if(s&&!response.error){var result=response.result;if(result){ContentItem.initItems(s,result.section.items);Object.extend(s,result.section);Section.refreshInnerHtml(s)}}},renderViewPanel:function(w,s){var lid=s.lid||Comments.defaultLayout;if(!lid||!lid.contains("Management")){var count=Array.getLength(s.items);var total=s.count||0;if(count<total){var href=WebPath.fromPathKey(page.pageId+"/"+s.nodeId);var msg=" "+count.toN0()+" of";w("<div class='section-padding font-sys' style='background-color: ",Theme.c0.lightest,";'>","<div style='float: right;'>","<a href=# onclick='Comments.addItems("+s.nodeId+");return false;'>Add</a>"," | ","<a href='",href,"'>See All</a>","</div>",msg," <a href='",href,"'>",total.toCount("Comment"),"</a>.","</div>")}}},renderStyle:function(w){var tc=Theme.c0;w(".dg-odd {background-color: ",tc.lightest,";}")},layouts:{Compact:{refreshSection:true,renderItemsHeader:function(w,s,items){w("<table width=100%>","<col width=1 />")},renderItemsFooter:function(w,s,items){w("</table>")},renderItemAttributes:function(w,item){w(" valign=top")},renderItemDivider:function(w){w("<td><div style='margin-top:3px;margin-bottom:3px;border-top:1px solid rgb(191,218,239);'><div></td>")},renderItemContent:function(w,item){var user=item.userSummary||page.site;var name="";if(user){name=user.displayName||user.userName}w("<td>","<div>","<span style='float:right'>");w("</span>",User.formatLink(user,true));if(item.created){var dt=Date.fromSeconds(item.created);if(dt){w("<span class='commentsAge color-red'> - ");if(Comments._0){var ageElement=new AgeBinding(dt);w("<span id='",ageElement.id,"'>",ageElement.text,"</span> ago")}else{w(dt.toString2())}w("</span>")}}w("</div>","<div class=commentsBody>",item.text,"</div>","</td>")}},List:{refreshSection:true,renderItemsHeader:function(w,s,items){w("<table width=100%>","<col width=1 />")},renderItemsFooter:function(w,s,items){w("</table>")},renderItemAttributes:function(w,item){w(" valign=top")},renderItemContent:function(w,item){var user=item.userSummary||page.site;var name="";if(user){name=user.displayName||user.userName}w("<td>",User.formatUserImage2(user,true),"</td>","<td>","<div class=commentsHeader>","<span style='float:right'>");w("</span>","<a href='",WebPath.fromPathKey(user.userName),"' target='",A.targetWindowName,"'>",name,"</a>");if(item.created){var dt=Date.fromSeconds(item.created);if(dt){w("<span class='commentsAge color-red'> - ");if(Comments._0){var ageElement=new AgeBinding(dt);w("<span id='",ageElement.id,"'>",ageElement.text,"</span> ago")}else{w(dt.toString2())}w("</span>")}}w("</div>","<div class=commentsBody>",item.text,"</div>","</td>")}},Detail:{refreshSection:true,renderItemsHeader:function(w,s,items){w("<table width=100%><col width=1/><col width=1/>")},renderItemsFooter:function(w,s,items){w("</table>")},renderItemAttributes:function(w,item){w(" valign=top")},renderItemContent:function(w,item){var d=Date.fromSeconds(item.created);var age=(item.created&&d)?"- "+Date.formatAge(d)+" ago":null;var user=item.userSummary;var nodeId=item.nodeId;var comment=item.text;var eid=Dom.getElementId(item);var img=user?User.formatUserImage(user.image,user.userName):"";w("<td width=1>",img,"</td>","<td>","<div style='width:100%'>",User.formatLink(user)," <span class='commentsAge color-red'>",age,"</span><br/>","<span id='"+eid+"_"+"text' class=commentsText>",comment,"</span>","</div>","</td>","<td>");w("</td>")}},ManagementDetails:{refreshSection:true,title:"Details",kind:1,renderItemsHeader:function(w,s,items){this._5(w,s);w("<table width=100%>","<col width=1 />")},renderItemsFooter:function(w,s,items){w("</table>")},renderItemAttributes:function(w,item,index){w(" valign=top");if(index%2)w(" class='dg-odd'")},renderItemContent:function(w,item){var user=item.userSummary||page.site;var name="";if(user){name=user.displayName||user.userName}w("<td>",User.formatUserImage2(user,true),"</td>","<td>","<div class=commentsHeader>","<span style='float:right'>");w("</span>","<a href='",WebPath.fromPathKey(user.userName),"' target='",A.targetWindowName,"'>",name,"</a>");if(item.created){var dt=Date.fromSeconds(item.created);if(dt){w("<span class='commentsAge color-red'> - ");if(Comments._0){var ageElement=new AgeBinding(dt);w("<span id='",ageElement.id,"'>",ageElement.text,"</span> ago")}else{w(dt.toString2())}w("</span>")}}w("</div>","<div class=commentsBody>",item.text,"</div>","</td>")},_5:function(w,s){var tc=Theme.c0;s.selectAll=false;this._3(w,s);w("<div style='border-bottom: 1px solid ",tc.dark,"; margin-bottom: 10px;' >");DataGrid.renderNavBar(w,s);w("</div>")},_3:function(w,s){var rb=CommandBar.renderButtonTd;w("<table cellpadding=5><tr>");if(s.permissions.addComment){rb(w,{onclick:"Comments.addItems("+s.nodeId+")",title:"Add Comment"},-216,"Add Comment")}w("</tr></table>")}}},renderQuickAdd:function(w,s){var count=Array.getLength(s.items);var total=s.count||0;if(count>=total){CommandBar.renderButton(w,{onclick:"Comments.addItems("+s.nodeId+")"},-216,"Add Comments")}},addItems:function(s){Module.showDialog(Comments,"AddDialog",{parentId:s,beforeId:-2})},updateItem:function(i){if(i){Module.showDialog(Comments,"UpdateDialog",{item:page.nodes[i]})}},deleteItem:function(i){if(i){ContentItem.onDeleteItem(i);C.beginExec("comments/delete",{item:i})}}};Module.add(Comments);