]> SALOME platform Git repositories - tools/siman.git/commitdiff
Salome HOME
Comment's functionality is improved (correct validation, small code refactoring)
authormka <mka@opencascade.com>
Thu, 30 May 2013 07:48:27 +0000 (07:48 +0000)
committermka <mka@opencascade.com>
Thu, 30 May 2013 07:48:27 +0000 (07:48 +0000)
Workspace/Siman-Common/src/test/labels.properties
Workspace/Siman-Common/src/test/labels_en.properties
Workspace/Siman/WebContent/jsp/commentPane.jsp
Workspace/Siman/WebContent/jsp/descriptionPane.jsp
Workspace/Siman/WebContent/jsp/editKnowledge.jsp
Workspace/Siman/WebContent/jsp/readComment.jsp
Workspace/Siman/WebContent/jsp/readDescription.jsp
Workspace/Siman/WebContent/rtef/richtext.js
Workspace/Siman/src/labels.properties
Workspace/Siman/src/labels_en.properties

index 8611df4522d19bad9a37744a4ba7c7b1bc5c462d..e2970a8150fbf430d1814f1b756c7819b0684ba8 100644 (file)
@@ -191,6 +191,8 @@ field.context.value = Valeur
 field.fromStudy     = Source study
 field.fromScenario  = Source scenario
 field.finalStep     = Up to the step
+field.description   = Description value
+field.commentTitle  = Title of the comment
 
 
 criterion.study          = Les études
index 1acbfa6a2c031ed409653a1bee0de44f79a4dfd8..c06256eab141dce0d8856c57c25a2dee6117628d 100644 (file)
@@ -192,6 +192,8 @@ field.context.value = Value
 field.fromStudy     = Source study
 field.fromScenario  = Source scenario
 field.finalStep     = Up to the step
+field.description   = Description value
+field.commentTitle  = Title of the comment
 
 
 criterion.study          = All studies
index b3360b4f79ec02ff23e9b7b822a2fcdcdbcba971..ef18bd5439b0deb86f7273fa5bb189ddbb87dc4b 100644 (file)
 <!-- edit comment functionality -->
 <form name="edit_comment_form" id="edit_comment_form" action="edit-comment" method="post"
     style="display: none; position: absolute; background: white;">
+    
+  <div id="commentToEditTiltleErrorMessage" class="errorMessage" style="display: none" align="center">
+    <s:property value='%{getText("message.error.noenteredvalue", "-", getText("field.commentTitle"))}'/> 
+  </div>
+    
   <input type="hidden" name="commentId" id="commentToEditId" value="0"/>
   <table width="100%" cellpadding="0" cellspacing="0" border="0" class="attribute">
         <tr valign="top">
@@ -22,6 +27,7 @@
             <input type="text" name="commentTitle" id="commentToEditTitle">
             <script language='JavaScript'>
                 displayTextEditor('commentToEditValue', '', 650, 150);
+                enableRTEvalidation('commentToEditValue');
             </script>   
           </td>
         </tr>
 
 <script>
     $("#edit_comment_form").ajaxForm({
-        target: '#display_comments_div'
+        target: '#display_comments_div',
+        beforeSubmit: function(event) {
+            //validation
+               var message = document.getElementById('commentToEditTiltleErrorMessage');
+               message.style.display = 'none';
+               field = document.getElementById('commentToEditTitle');
+               if(field.value != null && (field.value == "" || field.value.replace(/^\s+|\s+$/g,"").length == 0)) {
+                message.style.display = 'block';
+                   return false;
+               } else {
+                   hideEditCommentEditor();
+               }
+           }
     });
     
     var commentToEditId;
         document.getElementById('commentToEditTitle').focus();
         redrawEditor();
         window.onresize = redrawEditor;
+        $('.editCommentIcon').hide();
     }
 
     function hideEditCommentEditor() {
         document.getElementById('edit_comment_form').style.display = 'none';
+        $('.editCommentIcon').show();
     }
     
     // Bind the cancel button
     $("#cancel_edit_comment_button").click(hideEditCommentEditor);
-    
-    // Bind the submit event
-    $('#edit_comment_form').on('submit', hideEditCommentEditor);
 </script>
 
 <!-- remove comment functionality -->
     function removeComment(commentId) {
         document.getElementById("commentId").value=commentId;
         $("#remove_comment_form").ajaxSubmit({
-                   target: '#display_comments_div'
-              });
+            target: '#display_comments_div'
+        });
     }
 </script>
 
 <!-- add comment functionality -->
 <s:if test="%{writeAccess == 'true' && stepEnabled == 'true'}">
        <script type="text/javascript">
-           $(document).ready(function(){
-               $("#comments_form").ajaxForm({
-                   target: '#display_comments_div'
-               });
+           $(document).ready(function(event){
+            $("#comments_form").ajaxForm({
+                target: '#display_comments_div',
+                beforeSubmit: function(event) {
+                       //validation
+                       var message = document.getElementById('commentToAddTiltleErrorMessage');
+                       message.style.display = 'none';
+                       field = document.getElementById('commentTitle');
+                       if(field.value != null && (field.value == "" || field.value.replace(/^\s+|\s+$/g,"").length == 0)) {
+                        message.style.display = 'block';
+                           return false;
+                       } else {
+                           hideCommentEditor();
+                       }
+                   }
+            });               
                
             function showCommentEditor() {
                 document.getElementById('commentTitle').value='';
                 document.getElementById('add_comment_button_div').style.display = 'none';
                 document.getElementById('add_comment_div').style.display = 'block';
                 document.getElementById('commentTitle').focus();
+                document.getElementById('commentToAddTiltleErrorMessage').style.display = 'none';
+                $('.editCommentIcon').hide();
             }
            
                // Bind the add button
                    function hideCommentEditor() {
                  document.getElementById("add_comment_button_div").style.display = 'block';
                  document.getElementById("add_comment_div").style.display = 'none';
+              $('.editCommentIcon').show();
                }
                    
                    // Bind the cancel button
                    $("#cancel_add_comment_button").click(hideCommentEditor);
-                   
-                   // Bind the submit event
-               $('#comments_form').on('submit', hideCommentEditor);
            });
        </script>
        
          </table>
        </div>
        
-       <div id="add_comment_div" style="display: none;">
+  <div id="add_comment_div" style="display: none;">
+       <div id="commentToAddTiltleErrorMessage" class="errorMessage" style="display: none" align="center">
+         <s:property value='%{getText("message.error.noenteredvalue", "-", getText("field.commentTitle"))}'/> 
+       </div>
        <form name="comments_form" id="comments_form" action="create-stepComment" method="post">
          <table width="100%" cellpadding="0" cellspacing="0" border="0" class="attribute">
            <tr valign="top">
             <input type="text" name="commentTitle" id="commentTitle">
                <script language='JavaScript'>
                    displayTextEditor('commentValue', '', 650, 150);
+                   enableRTEvalidation('commentValue');
                </script>   
              </td>
            </tr>
          </table> 
        </form>
-       </div>
+  </div>
 </s:if>
\ No newline at end of file
index 7ec7c31cf1355c018209cedf8697f6e482d99256..44bebab7170e8406e9350db05b006d764852ce6b 100644 (file)
@@ -18,7 +18,8 @@
         </td>
         <td>
           <script language='JavaScript'>
-              displayTextEditor('descriptionValue', '', 300, 120);
+              displayTextEditor('descriptionValue', '', 360, 120);
+              enableRTEvalidation('descriptionValue');
           </script>   
         </td>
       </tr>
index 80979a22c0741ad0e2f970564ece97fe1da3c855..78451f55a726d564a6bdcee9d15d18d5bbd2e645 100644 (file)
@@ -9,21 +9,6 @@
 <%@ page import="org.splat.simer.AbstractOpenObject"%>
 <%@ page import="org.splat.simer.OpenStudy"%>
 <%@ page import="org.splat.simer.KnowledgeElementFacade"%>
-
-<script language="JavaScript">
-    //Knowledge value validation
-    $(document).ready(function() {
-        $('#setKnowledge').submit(function(event) {
-            field = document.getElementById('hdnknowledgeValue');
-            document.getElementById('knowledgeValueErrorMessage').style.display = 'none';
-            if(field.value != null && (field.value == "" || field.value.replace(/^\s+|\s+$/g,"").length == 0)) {
-                event.preventDefault();
-                document.getElementById('knowledgeValueErrorMessage').style.display = 'table-row';
-            }
-        });
-    });
-</script>
-
 <%!
     private enum Action { addKnowledge, renameKnowledge, editKnowledge };
 %><%
       List<KnowledgeElementFacade> knowelms = type.getKnowledgeElements();
       for (Iterator<KnowledgeElementFacade> iterator = knowelms.iterator(); iterator.hasNext(); ) {
         KnowledgeElementFacade kelm = iterator.next();
-        if (kelm.getIndex().equals(typenumber)) {
-%>          <tr id="knowledgeValueErrorMessage" style="display: none">
-              <td align="center" colspan="2" class="errorMessage">
-                <s:property value='%{getText("message.error.noenteredvalue", "-", getText("field.knowledgevalue"))}'/> 
-              </td>
-            </tr>
-<%      }
 %>
   <tr height=20 valign=top>
 
@@ -97,7 +75,8 @@
         if (todo == Action.editKnowledge && kelm.getIndex().equals(typenumber)) {
 %>            <td>
                 <script language='JavaScript' type='text/javascript'>
-<%        out.print("displayTextEditor('knowledgeValue', '" + kelm.getFullValue() + "', 450, 150);");
+<%        out.print("displayTextEditor('knowledgeValue', '" + kelm.getFullValue() + "', 450, 150);"
+                     + "enableRTEvalidation('knowledgeValue');");
 %>              </script>
               </td>
 <%      } else {
       }
       if (todo == Action.addKnowledge && type.getIndex().equals(typenumber)) {
 %>  <tr height=5><td></td></tr>
-    <tr id="knowledgeValueErrorMessage" style="display: none">
-      <td align="center" colspan="2" class="errorMessage">
-        <s:property value='%{getText("message.error.noenteredvalue", "-", getText("field.knowledgevalue"))}'/> 
-      </td>
-    </tr>
     <tr valign=top>
       <td>
         <s:a href="%{undo}"><img src="<s:url value="/skin/icon.undo.png"/>" border="none" title="<s:text name="tooltip.cancel"/>" /></s:a>
       </td>
       <td>
         <script language='JavaScript' type='text/javascript'>
-<%        out.print("displayTextEditor('knowledgeValue', '<p>&nbsp;</p>', 450, 150);");
+<%        out.print("displayTextEditor('knowledgeValue', '<p>&nbsp;</p>', 450, 150);"
+                 + "enableRTEvalidation('knowledgeValue');");
 %>      </script>
       </td>
     </tr>
index 1e603c0bbfdda3045e7c0d70bb72274037df002c..e14037a04d13a6478bd9ccf6756221658cc2d3dd 100644 (file)
                     onmouseover="javascript:_mouseOverContext=true;" onmouseout="javascript:_mouseOverContext=false;">
                   <jsp:include page="/jsp/menupopup.jsp" />
                 </div>
+                <div class="editCommentIcon">
                 <s:a href="popup%{id}">
                   <img src="<s:url value="/skin/icon.ed.png"/>" width=14 height=14 border="none" title=""/>
                 </s:a>
+                </div>
                  </s:if>
                </td>
                
index f1beace80df40dd94c7f34c737bbc002ed9fbbc9..deb66cea0dfe6eedad6364210ead5d0f9900cb07 100644 (file)
@@ -9,14 +9,12 @@
        function showDescriptionEditor() {
          document.getElementById("descriptionValue").contentDocument.body.innerHTML = 
             document.getElementById("description_value_div").innerHTML;
-         //document.getElementById("display_description_div").style.display = 'none';
          document.getElementById("description_div").style.display = 'none';
          document.getElementById("description_editor_div").style.display = 'block';
          document.getElementById("descriptionValue").focus();
        }
    
        function hideDescriptionEditor() {
-         //document.getElementById("display_description_div").style.display = 'block';
          document.getElementById("description_div").style.display = 'block';
          document.getElementById("description_editor_div").style.display = 'none';
        }
@@ -76,4 +74,9 @@
     }
 </script>
 
-</s:if>
\ No newline at end of file
+</s:if>
+<s:else>
+    <div id="description_value_div">
+         <s:property value="descriptionValue" escapeHtml="false"/>
+    </div>
+</s:else>
\ No newline at end of file
index 3f5671c3a7dfe3c50155fac833001fbc9136a7bd..b666b5b74c22e3310298ccce1ee88924518197e4 100644 (file)
@@ -35,7 +35,7 @@
 
 // Constants
 var ctxpath = "/siman/";
-var minWidth = 450;                                    // minumum width
+var minWidth = 400;                                    // minumum width
 var wrapWidth = 1245;                      //width at which all icons will appear on one bar
 var maxchar = 64000;                // maximum number of characters per save
 var lang = "en";                                       //xhtml language
@@ -269,7 +269,7 @@ function writeRichText(rte, html, css, width, height, buttons, readOnly, fullscr
                  document.writeln('<tbody><tr>');
                  insertBar();
                  if(fullscreen || activeCommand.get("save") != null){
-                         document.writeln('<td><input type="image" class="rteImg" src="'+imagesPath+'save.gif" alt="'+lblSave+'" title="'+lblSave+'" onmouseover="this.className=\'rteImgUp\'" onmouseout="this.className=\'rteImg\'" onmousedown="this.className=\'rteImgDn\'" onmouseup="this.className=\'rteImgUp\'" onClick="prepareSubmitEdit(currentRTE)"></td>');
+                         document.writeln('<td><input type="image" class="rteImg" id="'+rte+'SaveButton" src="'+imagesPath+'save.gif" alt="'+lblSave+'" title="'+lblSave+'" onmouseover="this.className=\'rteImgUp\'" onmouseout="this.className=\'rteImg\'" onmousedown="this.className=\'rteImgDn\'" onmouseup="this.className=\'rteImgUp\'" onClick="prepareSubmitEdit(currentRTE)"></td>');
                          nbcommand += 1;
                  }
                  if(!isSafari && !isKonqueror) {
@@ -282,13 +282,11 @@ function writeRichText(rte, html, css, width, height, buttons, readOnly, fullscr
 //                       insertImg(lblUnformat,"unformat.gif","rteCommand('"+rte+"','removeformat')");
                          insertSep();
                  }
-                 if(isIE || isSafari || isKonqueror) {
+                 if(false) {
                          addCommand("cut","rteCommand('"+rte+"','cut')");
 //                       insertImg(lblCut,"cut.gif","rteCommand('"+rte+"','cut')");
                          addCommand("copy","rteCommand('"+rte+"','copy')");
 //                       insertImg(lblCopy,"copy.gif","rteCommand('"+rte+"','copy')");
-                 }
-                 if(isSafari || isKonqueror) {
                          addCommand("paste","rteCommand('"+rte+"','InsertText')");
 //                       insertImg(lblPaste,"paste.gif","rteCommand('"+rte+"','InsertText')");
                  }
@@ -348,16 +346,15 @@ function writeRichText(rte, html, css, width, height, buttons, readOnly, fullscr
 //               insertImg(lblAlgnRight,"right_just.gif","rteCommand('"+rte+"','justifyright')");
                  addCommand("justifyfull","rteCommand('"+rte+"','justifyfull')");
 //               insertImg(lblJustifyFull,"justifyfull.gif","rteCommand('"+rte+"','justifyfull')");
-                 if(!isSafari && !isKonqueror) {
+          insertSep();
+            addCommand("numbered_list","rteCommand('"+rte+"','insertorderedlist')");
+//          insertImg(lblOL,"numbered_list.gif","rteCommand('"+rte+"','insertorderedlist')");
+            addCommand("list","rteCommand('"+rte+"','insertunorderedlist')");
+//          insertImg(lblUL,"list.gif","rteCommand('"+rte+"','insertunorderedlist')");
+            addCommand("hyperlink","dlgLaunch('"+rte+"','link')");
+//          insertImg(lblInsertLink,"hyperlink.gif","dlgLaunch('"+rte+"','link')");
+                 if(false) {
                        insertSep();
-                         addCommand("numbered_list","rteCommand('"+rte+"','insertorderedlist')");
-//                       insertImg(lblOL,"numbered_list.gif","rteCommand('"+rte+"','insertorderedlist')");
-                         addCommand("list","rteCommand('"+rte+"','insertunorderedlist')");
-//                       insertImg(lblUL,"list.gif","rteCommand('"+rte+"','insertunorderedlist')");
-                         addCommand("outdent","rteCommand('"+rte+"','outdent')");
-//                       insertImg(lblOutdent,"outdent.gif","rteCommand('"+rte+"','outdent')");
-                         addCommand("indent","rteCommand('"+rte+"','indent')");
-//                       insertImg(lblIndent,"indent.gif","rteCommand('"+rte+"','indent')");
                          insertSep();
                          addCommand("textcolor","dlgColorPalette('"+rte+"','forecolor')","forecolor_"+rte);
 //                       insertImg(lblTextColor,"textcolor.gif","dlgColorPalette('"+rte+"','forecolor')","forecolor_"+rte);
@@ -369,15 +366,17 @@ function writeRichText(rte, html, css, width, height, buttons, readOnly, fullscr
                          insertSep();
                          addCommand("special_char","dlgLaunch('"+rte+"','char')");
 //                       insertImg(lblInsertChar,"special_char.gif","dlgLaunch('"+rte+"','char')");
-                         addCommand("hyperlink","dlgLaunch('"+rte+"','link')");
-//                       insertImg(lblInsertLink,"hyperlink.gif","dlgLaunch('"+rte+"','link')");
                          addCommand("image","dlgLaunch('"+rte+"','image')");
 //                       insertImg(lblAddImage,"image.gif","dlgLaunch('"+rte+"','image')");
                          addCommand("insert_table","dlgLaunch('"+rte+"','table')");
 //                       insertImg(lblInsertTable,"insert_table.gif","dlgLaunch('"+rte+"','table')");
                  }
+          addCommand("outdent","rteCommand('"+rte+"','outdent')");
+//        insertImg(lblOutdent,"outdent.gif","rteCommand('"+rte+"','outdent')");
+          addCommand("indent","rteCommand('"+rte+"','indent')");
+//        insertImg(lblIndent,"indent.gif","rteCommand('"+rte+"','indent')");
                  insertSep();
-                 if(!isSafari && !isKonqueror) {
+                 if(false) {
                          addCommand("replace","dlgLaunch('"+rte+"','replace')");
 //                       insertImg(lblSearch,"replace.gif","dlgLaunch('"+rte+"','replace')");
                  }
@@ -438,7 +437,7 @@ function insertImg(name, image, command, id){
          if(id!=null){
            td = "<td id='"+id+"'>";
       }
-         document.writeln(td+'<img class="rteImg" src="'+imagesPath+image+'" alt="'+name+'" title="'+name+'" onMouseDown="'+command+';return false" onmouseover="this.className=\'rteImgUp\'" onmouseout="this.className=\'rteImg\'" onmousedown="this.className=\'rteImgDn\'" onmouseup="this.className=\'rteImgUp\'"></td>');
+         document.writeln(td+'<img class="rteImg" src="'+imagesPath+image+'" alt="'+name+'" title="'+name+'" onClick="'+command+';return false" onmouseover="this.className=\'rteImgUp\'" onmouseout="this.className=\'rteImg\'" onmousedown="this.className=\'rteImgDn\'" onmouseup="this.className=\'rteImgUp\'"></td>');
 }
 
 function enableDesignMode(rte, html, css, readOnly) {
@@ -482,7 +481,6 @@ function enableDesignMode(rte, html, css, readOnly) {
                                if(isGecko && !readOnly) {
                                        //attach a keyboard handler for gecko browsers to make keyboard shortcuts work
                                        oRTE.addEventListener("keypress", geckoKeyPress, true);
-                                       oRTE.addEventListener("focus", function (){dlgCleanUp();}, false);
                                }
                        } catch(e) {
                                alert(lblErrorPreload);
@@ -491,7 +489,12 @@ function enableDesignMode(rte, html, css, readOnly) {
                        //gecko may take some time to enable design mode.
                        //Keep looping until able to set.
                        if(isGecko){
-                               setTimeout("enableDesignMode('"+rte+"', '"+html+"', '"+css+"', "+readOnly+");", 200);
+                       if(!timeLeft) {
+                           timeLeft = 5000;
+                       }
+                if(timeLeft > 0) {
+                                   setTimeout("enableDesignMode('"+rte+"', '"+html+"', '"+css+"', "+readOnly+ "','"+(timeLeft-200)+"');", 200);
+                           }
                        }else{
                                return false;
                        }
@@ -818,7 +821,7 @@ function getText(rte) {
   return rtn;
 }
 
-function setFormText(popup, content){
+function setFormText(popup, content, timeLeft){
        //set link text value in dialog windows
        if(content != "undefined")
        {
@@ -830,8 +833,13 @@ function setFormText(popup, content){
          }catch(e){
                  //may take some time to create dialog window.
                  //Keep looping until able to set.
-                 setTimeout("setFormText('"+popup+"','" + content + "');", 10);
-         }
+                 if(!timeLeft) {
+                     timeLeft = 5000;
+                 }
+                 if(timeLeft > 0) {
+                     setTimeout("setFormText('"+popup+"','" + content + "','"+(timeLeft-200)+"');", 200);
+                 }
+          }
        }
 }
 
@@ -1038,14 +1046,18 @@ function setRange(rte){
        //function to store range of current selection
        var oRTE = returnRTE(rte);
        var selection;
-       if(document.all){
+       if(document.all){  //IE
                selection = oRTE.document.selection;
                if(selection != null){
       rng = selection.createRange();
     }
        }else{
                selection = oRTE.getSelection();
-               rng = selection.getRangeAt(selection.rangeCount - 1).cloneRange();
+               if(selection.rangeCount > 0) {
+                 rng = selection.getRangeAt(selection.rangeCount - 1).cloneRange();
+               } else {
+                 rng = oRTE.document.createRange();
+               }
        }
        return rng;
 }
@@ -1319,3 +1331,17 @@ function checkspell() {
                }
        }
 }
+
+//*****************
+//Validation
+//*****************
+function enableRTEvalidation(rteName) {
+    document.getElementById(rteName+'SaveButton').onclick = function(event){
+        updateRTEs();
+           field = document.getElementById('hdn'+rteName);
+           if(field.value != null && (field.value == "" || field.value.replace(/^\s+|\s+$/g,"").length == 0)) {
+               event.preventDefault();
+           }
+       };
+}
+    
\ No newline at end of file
index 8611df4522d19bad9a37744a4ba7c7b1bc5c462d..e2970a8150fbf430d1814f1b756c7819b0684ba8 100644 (file)
@@ -191,6 +191,8 @@ field.context.value = Valeur
 field.fromStudy     = Source study
 field.fromScenario  = Source scenario
 field.finalStep     = Up to the step
+field.description   = Description value
+field.commentTitle  = Title of the comment
 
 
 criterion.study          = Les études
index 1acbfa6a2c031ed409653a1bee0de44f79a4dfd8..c06256eab141dce0d8856c57c25a2dee6117628d 100644 (file)
@@ -192,6 +192,8 @@ field.context.value = Value
 field.fromStudy     = Source study
 field.fromScenario  = Source scenario
 field.finalStep     = Up to the step
+field.description   = Description value
+field.commentTitle  = Title of the comment
 
 
 criterion.study          = All studies