Salome HOME
63a063469e0d00a7f48ae7f11c5ecdce6c4f42af
[tools/siman.git] / Workspace / Siman / WebContent / jsp / commentPane.jsp
1 <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
2     pageEncoding="ISO-8859-1"%>
3 <%@ taglib prefix="s" uri="/struts-tags"%>
4 <%@ taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles"%>
5
6 <div id="display_comments_div">
7     <s:action name="display-comments" namespace="/study" executeResult="true" />
8 </div>
9
10
11 <!-- edit comment functionality -->
12 <form name="edit_comment_form" id="edit_comment_form" action="edit-comment" method="post"
13     style="display: none; position: absolute; background: white;">
14   <input type="hidden" name="commentId" id="commentToEditId" value="0"/>
15   <table width="100%" cellpadding="0" cellspacing="0" border="0" class="attribute">
16         <tr valign="top">
17           <td width="20" height="20" align="center">
18             <img id="cancel_edit_comment_button" src="<s:url value="/skin/icon.undo.png"/>"
19                 title="<s:text name="tooltip.cancel"/>" />
20           </td>
21           <td>
22             <input type="text" name="commentTitle" id="commentToEditTitle">
23             <script language='JavaScript'>
24                 displayTextEditor('commentToEditValue', '', 650, 150);
25             </script>   
26           </td>
27         </tr>
28   </table> 
29 </form>
30
31 <script>
32     $("#edit_comment_form").ajaxForm({
33         target: '#display_comments_div'
34     });
35     
36     var commentToEditId;
37     function redrawEditor() {
38         document.getElementById('edit_comment_form').style.top = 
39             $('#comment_'+commentToEditId+'_tbody').offset().top+'px';
40     }
41
42     function editComment(commentId) {
43         var comment = document.getElementById('comment_'+commentId+'_tbody');
44         var editor = document.getElementById('edit_comment_form');
45         editor.style.display = 'block';
46         
47         document.getElementById('commentToEditId').value = commentId;
48         document.getElementById('commentToEditTitle').value = 
49                 trim(document.getElementById('comment_'+commentId+'_title').innerHTML);
50         document.getElementById('commentToEditValue').contentDocument.body.innerHTML = 
51                 trim(document.getElementById('comment_'+commentId+'_body').innerHTML);
52
53         commentToEditId = commentId;
54         redrawEditor();
55         document.onchange = redrawEditor;
56     }
57
58     function hideEditCommentEditor() {
59         document.getElementById('edit_comment_form').style.display = 'none';
60     }
61     
62     // Bind the cancel button
63     $("#cancel_edit_comment_button").click(hideEditCommentEditor);
64     
65     // Bind the submit event
66     $('#edit_comment_form').on('submit', hideEditCommentEditor);
67 </script>
68
69 <!-- remove comment functionality -->
70 <form name="remove_comment_form" id="remove_comment_form" action="remove-comment" method="post">
71     <input type="hidden" name="commentId" id="commentId" value="<s:property value="openStudy.index"/>"/>
72 </form>
73
74 <script>
75     function removeComment(commentId) {
76         document.getElementById("commentId").value=commentId;
77         $("#remove_comment_form").ajaxSubmit({
78                    target: '#display_comments_div'
79               });
80     }
81 </script>
82
83 <!-- add comment functionality -->
84 <s:if test="%{writeAccess == 'true' && stepEnabled == 'true'}">
85         <script type="text/javascript">
86             $(document).ready(function(){
87                 $("#comments_form").ajaxForm({
88                     target: '#display_comments_div'
89                 });
90                 
91             function showCommentEditor(commentTitle, commentBody) {
92                 document.getElementById('commentTitle').value=commentTitle;
93                 document.getElementById(currentRTE).contentDocument.body.innerHTML=commentBody;
94                 document.getElementById('add_comment_button_div').style.display = 'none';
95                 document.getElementById('add_comment_div').style.display = 'block';
96             }
97
98             
99                 // Bind the add button
100                     $("#add_comment_button").click(function() {showCommentEditor('','');});
101                     
102                     function hideCommentEditor() {
103                   document.getElementById("add_comment_button_div").style.display = 'block';
104                   document.getElementById("add_comment_div").style.display = 'none';
105                 }
106                     
107                     // Bind the cancel button
108                     $("#cancel_add_comment_button").click(hideCommentEditor);
109                     
110                     // Bind the submit event
111                 $('#comments_form').on('submit', hideCommentEditor);
112             });
113         </script>
114         
115         <div id="add_comment_button_div">
116           <table width="100%" cellpadding="0" cellspacing="0" border="0" class="attribute">
117             <tr>
118               <td width="20" height="20" align="center">
119                 <img id="add_comment_button" src="<s:url value="/skin/icon.add.png"/>" onMouseOver=this.src="<s:url value="/skin/icon.addhot.png"/>"
120                     onMouseOut=this.src="<s:url value="/skin/icon.add.png"/>" title="<s:text name="tooltip.addcomment"/>"/>
121                </td>
122               <td>&nbsp;</td>
123             </tr>
124           </table>
125         </div>
126         
127         <div id="add_comment_div" style="display: none;">
128         <form name="comments_form" id="comments_form" action="create-stepComment" method="post">
129           <table width="100%" cellpadding="0" cellspacing="0" border="0" class="attribute">
130             <tr valign="top">
131               <td width="20" height="20" align="center">
132                 <img id="cancel_add_comment_button" src="<s:url value="/skin/icon.undo.png"/>"
133                     title="<s:text name="tooltip.cancel"/>" />
134               </td>
135               <td>
136             <input type="text" name="commentTitle" id="commentTitle">
137                 <script language='JavaScript'>
138                     displayTextEditor('commentValue', '', 650, 150);
139                 </script>   
140               </td>
141             </tr>
142           </table> 
143         </form>
144         </div>
145 </s:if>