Topic: AJAX post preview 1.0

##
##
##        Mod title:  AJAX post preview
##
##      Mod version:  1.0
##   Works on PunBB:  1.2, 1.2.10
##     Release date:  2005-12-08
##           Author:  bedroom
##
##      Description:  This mod uses the xajax library to quickly display the
##                    preview of a post (or errors in the post)
##
##                    (see: http://xajax.sourceforge.net)
##
##                    Nothing fancy, it does what the "Preview" button does,
##                    only without posting the form and reloading the page.
##
##                    Note that if javascript is disabled, the "Preview"
##                    button will still work the usual way (This is called 
##                    graceful degradation, folks :) )
##
##   Affected files:  header.php
##                    post.php
##
##       Affects DB:  No
##
##            Notes:  Tested with Firefox 1.5, Internet Explorer 6.0,
##                    Opera 8.51
##
##       DISCLAIMER:  Please note that "mods" are not officially supported by
##                    PunBB. Installation of this modification is done at your
##                    own risk. Backup your forum database and any and all
##                    applicable files before proceeding.
##
##

Download here

2 (edited by bedroom 2005-12-08 17:53)

Re: AJAX post preview 1.0

Additional notes : no, it's not an earth-shattering extension, since the default behavior for the preview button is pretty fast, but this mod is intended for those of us who like to live in the warp-speed lane smile
(also, because I use the "preview" button about a zillion times before posting)

If you really want to mimic the "preview" button's original behavior, you should use this on step 13 of the install :

<!-- MOD AJAX post preview -->
<p><input type="submit" name="submit" value="<?php echo $lang_common['Submit'] ?>" tabindex="<?php echo $cur_index++ ?>" accesskey="s" /><input type="submit" onclick="xajax_getpreview(xajax.getFormValues('post')); document.location.href='#punwrap'; return false;" name="preview" value="<?php echo $lang_post['Preview'] ?>" tabindex="<?php echo $cur_index++ ?>" accesskey="p" /><a href="javascript:history.go(-1)"><?php echo $lang_common['Go back'] ?></a></p>
<!--// MOD AJAX post preview -->

This tells the browser to go to #punwrap, the top of the page, whereas my version goes to #ajaxpostpreview, the preview block.

It doesn't work so well with Opera, because the document.location.href = '#ajaxpostpreview' instruction seems to work only once... if you click "preview" again, the window doesn't scroll back to the right place (Opera's lazy, man). If anybody out there has a fix for this, I'll be glad to know it.