r9460 - in apps/gobi/trunk/code: Comment Page Page/skins

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

Modified:
   apps/gobi/trunk/code/Comment/edit.skin
   apps/gobi/trunk/code/Page/PageActions.js
   apps/gobi/trunk/code/Page/skins/commentForm.skin
   apps/gobi/trunk/code/Page/skins/create.skin
   apps/gobi/trunk/code/Page/skins/edit.skin
   apps/gobi/trunk/code/Page/skins/javascript.skin
Log:
Unify page preview, apply it to create page.

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

Modified: apps/gobi/trunk/code/Comment/edit.skin
===================================================================
--- apps/gobi/trunk/code/Comment/edit.skin	2008-12-22 11:40:57 UTC (rev 9459)
+++ apps/gobi/trunk/code/Comment/edit.skin	2008-12-22 12:00:18 UTC (rev 9460)
@@ -1,4 +1,4 @@
-<form action="<% this.href action='edit' %>" method="post" name="edit" enctype="multipart/form-data">
+<form method="post" name="edit" enctype="multipart/form-data">
 
 <% this.formEditor %>
 
@@ -7,11 +7,11 @@
 
 <p>
   <input type="submit" value="<% msg name='comment_preview' %>" name="preview"
-    onclick="return commentPreview(this.form);"/>
+    onclick="return pagePreview(this.form);"/>
   <input type="submit" value="<% msg name='comment_save' %>" name="save" />
   <a href="<% page.href %>" class="commentLink"><% msg name='cancel' %></a>
 </p>
-<div id="commentPreview"></div>
+<div id="pagePreview"></div>
 </form>
 
 

Modified: apps/gobi/trunk/code/Page/PageActions.js
===================================================================
--- apps/gobi/trunk/code/Page/PageActions.js	2008-12-22 11:40:57 UTC (rev 9459)
+++ apps/gobi/trunk/code/Page/PageActions.js	2008-12-22 12:00:18 UTC (rev 9460)
@@ -241,6 +241,9 @@
             res.message = msg("preview_message")
             this.renderSkin("page");
             return;
+        } else if (req.data.ajax) {
+            it.renderSkin("body#preview");
+            return;
         }
     }
     // if childform is set and user is not admin skip the type chooser

Modified: apps/gobi/trunk/code/Page/skins/commentForm.skin
===================================================================
--- apps/gobi/trunk/code/Page/skins/commentForm.skin	2008-12-22 11:40:57 UTC (rev 9459)
+++ apps/gobi/trunk/code/Page/skins/commentForm.skin	2008-12-22 12:00:18 UTC (rev 9460)
@@ -6,10 +6,10 @@
     <textarea name="body" id="commentInput"></textarea>
     <p>
     <input type="submit" value="<% msg name='comment_preview' %>" name="preview"
-       onclick="return commentPreview(this.form);"/>
+       onclick="return pagePreview(this.form);"/>
     <input type="submit" value="<% msg name='comment_save' %>" name="save" />
     <a href="#" onclick="return commentCancel();" class="commentLink"><%
         msg name='cancel' %></a>
     </p>
-    <div id="commentPreview"></div>
+    <div id="pagePreview"></div>
 </form>

Modified: apps/gobi/trunk/code/Page/skins/create.skin
===================================================================
--- apps/gobi/trunk/code/Page/skins/create.skin	2008-12-22 11:40:57 UTC (rev 9459)
+++ apps/gobi/trunk/code/Page/skins/create.skin	2008-12-22 12:00:18 UTC (rev 9460)
@@ -23,11 +23,12 @@
 <% this.textArea name="body" rows="18" class="horizontalFill" %></p>
 
 <p>
-    <input type="submit" name="preview"
-          value="<% msg name='preview_button' %>">
+    <input type="submit" name="preview" value="<% msg name='preview_button' %>"
+          onclick="return pagePreview(this.form);">
     <input type="submit" name="save"
           value="<% msg name='create_button' %>">
     <a href="<% page.href %>" class="commentLink">
           <% msg name='cancel' %></a>
 </p>
+<div id="pagePreview"></div>
 </form>
\ No newline at end of file

Modified: apps/gobi/trunk/code/Page/skins/edit.skin
===================================================================
--- apps/gobi/trunk/code/Page/skins/edit.skin	2008-12-22 11:40:57 UTC (rev 9459)
+++ apps/gobi/trunk/code/Page/skins/edit.skin	2008-12-22 12:00:18 UTC (rev 9460)
@@ -1,4 +1,4 @@
-<form action="<% this.href action="edit" %>" method="post" name="edit" enctype="multipart/form-data">
+<form method="post" name="edit" enctype="multipart/form-data">
 
 <% this.input name="name" class="name horizontalFill"
               prefix="<p>Name<br />" suffix="</p>" %>

Modified: apps/gobi/trunk/code/Page/skins/javascript.skin
===================================================================
--- apps/gobi/trunk/code/Page/skins/javascript.skin	2008-12-22 11:40:57 UTC (rev 9459)
+++ apps/gobi/trunk/code/Page/skins/javascript.skin	2008-12-22 12:00:18 UTC (rev 9460)
@@ -158,39 +158,34 @@
 
   function commentCancel() {
       // $('#commentInput').val('');
-      $('#commentPreview').html('');
+      $('#pagePreview').html('');
       $('.commentToggle').toggle();
       return false;
   }
 
-  function commentPreview(form) {
-      var input = $('#commentInput');
-      $('#commentPreview').load(form.action, {
+  function pagePreview(form) {
+      var input = $(form).find('[name=body]');
+      var action = form.action || location.href;
+      $('#pagePreview').load(action, {
           ajax: true,
+          name: $(form).find('[name=name]').val(),
           body: input.val()
       });
       $('html,body').animate({
-          scrollTop: $(form).offset().top
+          scrollTop: $('#pagePreview').offset().top
       });
       input.focus();
       return false;
   }
 
-  function pagePreview(form) {
-      var input = $(form).find('[name=body]');
-      $('#pagePreview').load(form.action, {
-          ajax: true,
-          name: $(form).find('[name=name]').val(),
-          body: input.val()
-      });
+  function continueEditing(form) {
       $('html,body').animate({
-          scrollTop: $('#pagePreview').offset().top
+          scrollTop: $(form).offset().top
       });
-      input.focus();
+      $(form).find('[name=body]').focus();
       return false;
   }
 
-
   function buildList(name, link) {
       var safeName = name.replace(/\s/g, "_");
       var value = getElement(name+"_links").value;
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.