r9458 - in apps/gobi/trunk/code: Global Page Page/skins

[email protected]
Newsgroups gmane.comp.java.helma.cvs
Message-ID <[email protected]>
Author: hannes
Date: 2008-12-22 12:05:21 +0100 (Mon, 22 Dec 2008)
New Revision: 9458

Modified:
   apps/gobi/trunk/code/Global/Messages.js
   apps/gobi/trunk/code/Page/PageActions.js
   apps/gobi/trunk/code/Page/skins/commentForm.skin
   apps/gobi/trunk/code/Page/skins/javascript.skin
   apps/gobi/trunk/code/Page/skins/stylesheet.skin
Log:
Update comment submission: use jquery ajax for preview, plus various minor improvements.

Details at http://dev.helma.org/trac/helma/changeset/9458

Modified: apps/gobi/trunk/code/Global/Messages.js
===================================================================
--- apps/gobi/trunk/code/Global/Messages.js	2008-12-22 09:55:02 UTC (rev 9457)
+++ apps/gobi/trunk/code/Global/Messages.js	2008-12-22 11:05:21 UTC (rev 9458)
@@ -4,6 +4,7 @@
     cancel: "Cancel",
     comment_header: "Comments",
     comment_add: "Add Comment",
+    comment_label: "Add Comment:",
     comment_preview: "Preview Comment",
     comment_preview_message: "Click 'Save Comment' to save the comment once you are happy with it!",
     comment_added: "Your comment has been submitted!",
@@ -96,6 +97,7 @@
     cancel: "Abbrechen",
     comment_header: "Kommentare",
     comment_add: "Kommentar Hinzufügen",
+    comment_label: "Kommentar Hinzufügen:",    
     comment_preview: "Voransicht",
     comment_preview_message: "Klicken Sie 'Kommentar Speichern' um den Kommentar zu speichern",
     comment_added: "Ihr Kommentar wurde hinzugefügt!",

Modified: apps/gobi/trunk/code/Page/PageActions.js
===================================================================
--- apps/gobi/trunk/code/Page/PageActions.js	2008-12-22 09:55:02 UTC (rev 9457)
+++ apps/gobi/trunk/code/Page/PageActions.js	2008-12-22 11:05:21 UTC (rev 9458)
@@ -433,6 +433,9 @@
             res.message = msg("comment_preview_message")
             this.renderSkin("page");
             return;            
+        } else if (req.data.ajax) {
+            cmt.renderSkin("body#preview");
+            return;
         }
     }
     res.redirect(this.href());

Modified: apps/gobi/trunk/code/Page/skins/commentForm.skin
===================================================================
--- apps/gobi/trunk/code/Page/skins/commentForm.skin	2008-12-22 09:55:02 UTC (rev 9457)
+++ apps/gobi/trunk/code/Page/skins/commentForm.skin	2008-12-22 11:05:21 UTC (rev 9458)
@@ -1,12 +1,15 @@
-<p><a href="#" onclick="return toggleCommentForm();" class="commentLink commentToggle"><%
+<p><a href="#" onclick="return commentToggle();" class="commentLink commentToggle"><%
     msg name='comment_add' %></a></p>
 <form action="<% this.href action='comment' %>" method="post"
-      class="commentToggle" style="display: none;">
+      class="commentToggle" id="commentForm" style="display: none;">
+    <div><label for="body"><% msg name='comment_label' %></label></div> 
+    <textarea name="body" id="commentInput"></textarea>
     <p>
-    <textarea name="body" id="commentInput"></textarea>
-    </p>
-    <input type="submit" value="<% msg name='comment_preview' %>" name="preview" />
+    <input type="submit" value="<% msg name='comment_preview' %>" name="preview"
+       onclick="return commentPreview(this.form);"/>
     <input type="submit" value="<% msg name='comment_save' %>" name="save" />
-    <a href="#" onclick="return toggleCommentForm();" class="commentLink"><%
+    <a href="#" onclick="return commentCancel();" class="commentLink"><%
         msg name='cancel' %></a>
-</form>
\ No newline at end of file
+    </p>
+    <div id="commentPreview"></div>
+</form>

Modified: apps/gobi/trunk/code/Page/skins/javascript.skin
===================================================================
--- apps/gobi/trunk/code/Page/skins/javascript.skin	2008-12-22 09:55:02 UTC (rev 9457)
+++ apps/gobi/trunk/code/Page/skins/javascript.skin	2008-12-22 11:05:21 UTC (rev 9458)
@@ -90,13 +90,6 @@
       return toggleElement(id);
   }
 
-  function toggleCommentForm() {
-      $('.commentToggle').toggle();
-      $('#commentInput').focus();
-      return false;
-  }
-
-
   function toggleCheckbox(checkbox) {
       if (checkbox.checked)
           checkbox.checked = "";
@@ -153,6 +146,34 @@
      }
      return;
   }
+
+  function commentToggle() {
+      $('.commentToggle').toggle();
+      $('#commentInput').focus();
+      $('html,body').animate({
+          scrollTop: $('#commentForm').offset().top
+      });
+      return false;
+  }
+
+  function commentCancel() {
+      // $('#commentInput').val('');
+      $('#commentPreview').html('');
+      $('.commentToggle').toggle();
+      return false;
+  }
+
+  function commentPreview(form) {
+      $('#commentPreview').load(form.action, {
+          ajax: true,
+          body: $('#commentInput').val()
+      });
+      $('html,body').animate({
+          scrollTop: $(form).offset().top
+      });
+      $('#commentInput').focus();
+      return false;
+  }
     
   function buildList(name, link) {
       var safeName = name.replace(/\s/g, "_");

Modified: apps/gobi/trunk/code/Page/skins/stylesheet.skin
===================================================================
--- apps/gobi/trunk/code/Page/skins/stylesheet.skin	2008-12-22 09:55:02 UTC (rev 9457)
+++ apps/gobi/trunk/code/Page/skins/stylesheet.skin	2008-12-22 11:05:21 UTC (rev 9458)
@@ -393,8 +393,8 @@
   }
   
   hr {
-      height: 1px; 
-      width: 100%; 
+      height: 1px;
+      width: 100%;
       border: 0;
       color: #dddddd; 
       background-color: #dddddd;
@@ -418,7 +418,7 @@
       width: 80%;
       font-size:0.9em;
       color: #669;
-      background-color: #ff9;
+      background-color: #eee;
       border: thin solid #669;
       padding: 0 1em;
       margin-top: 2em;
@@ -429,7 +429,7 @@
   }
 
   .commentLink {
-      font-size:0.9em;
+      font-size: 0.9em;
   }
 
   #commentInput {

_______________________________________________
Helma-CVS mailing list
[email protected]
http://helma.org/mailman/listinfo/helma-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.