I was trying to make the comment preview plugin work, but for some reason
it wasn't working, also, I prefered showing the comment preview in a popup,
that is why I wrote this code!
What do you get
A new button near the submit comment in the comment form, when clicked
it opens a new popup (you can change the size and attributes) with a nice
table that shows the correct comment preview with linebreaks bbcodes and smilies!
It is also checking if the comment is empty, it shows a message accordingly,
and last it has a 'close' button that will close the popup.
What took me a bit time was making the button open the popup and send the information
there, and then making the submit button work too, it is all done and works perfectly!
Installation
1. Download th .rar file and extract the file "commpreview.php" in your site's root folder.
2. Enter CNR, then Templates, your wanted template, and then choose "Comment Form"
3. Now look for the submit button (should start with <input type="submit"... etc')
And Replace it with the following code:
- Code: Select all
<script type="text/javascript">
function normals()
{
document.form.setAttribute('target', '_self');
document.form.setAttribute('action', '');
document.form.setAttribute('onClick', 'form.action="";');
document.form.submit();
}
function process()
{
window.open('commpreview.php', 'popup', 'width=420,height=310,resizeable=yes,scrollbars=yes');
document.form.setAttribute('target', 'popup');
document.form.setAttribute('action', 'commpreview.php');
document.form.setAttribute('onClick', 'form.action="commpreview.php";');
document.form.submit();
}
</script>
<input type="submit" tabindex="4" name="submit" value="Submit" onClick="normals()" />
<input type="submit" tabindex="5" name="preview" value="Preivew" onClick="process()" />
<br>
* You can change the code as you like, check that the relative path to 'commpreview.php' is right
* You can also change the commpreview.php design as you like
Edit: Fixed the bug in IE, now it works perfectly (was checked in FireFox and Chrome too)
That's it! now you have a neat awesome comments preview!
Hope you liked it, I'de be glad to hear what you think, if it all works for you etc
DarkSlim
