Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: ni5ni6.com comments addons  (Read 3880 times)

piXelatedEmpire

  • MIA
  • ULTIMATE member
  • ******
  • Karma: 37
  • Posts: 1401
  • currently MIA
ni5ni6.com comments addons
« on: January 31, 2007, 03:26:23 AM »

now that I have your attention Mika  :lol:

I simply LOVE the little additions you have made to your 'Comments' area.  The little [preview] and [info] buttons are a FANTASTIC idea!

I was wondering, if ah, umm... *shuffles feet*... if you would perhaps be kind enough to share a little tidbit of code that you created to achieve these little addons?

 :D
Logged
my apologies to the sNews crew, but I will be MIA for the forseeable future

Mika

  • Hero Member
  • *****
  • Karma: 9
  • Posts: 1377
    • http://www.ni5ni6.com/
ni5ni6.com comments addons
« Reply #1 on: January 31, 2007, 09:22:02 AM »

Hehe, you surely have my attention :lol:

Here's the trick (coding performed inside comment($freeze_status) function):
- all the links are inside textarea <label> tag
Quote
# building [preview] and [info] links
$subLink ='[<a href="'.db('website').$categorySEF.'/'.$articleSEF.($pageNum = $pageNum > 1 ? '/'.$pageNum : '').'/';
$subLink1 = $subLink.'#preview_comment" title="Preview Comment" onclick="toggle(\'preview\')">Preview</a>]';
$subLink2 = $subLink.'#comment_info" title="Commenting rules and guidelines" onclick="toggle(\'info\')">Info</a>]';

# textarea with new set of links attached to the label value
html_input('textarea', 'text', 'txt', '', '* '.l('comment').$subLink1.$subLink2, '', '', '', '', '', '5', '5', '', '', '');
- 2 new hidden containers called onclick are required
Quote
html_input('textarea', 'text', 'txt', '', '* '.l('comment').$subLink1.$subLink2, '', '', '', '', '', '5', '5', '', '', '');
echo '<a title="preview" name="preview_comment"></a><div id="preview" style="display: none;">';
echo 'your-contents-here';
echo '</div>';
echo '<a title="info" name="comment_info"></a><div id="info" style="display: none;">';
echo 'your-contents-here';
echo '</div>';
- some public JS (add this somewhere inside snews.php file)
Quote
// Public javascript
function js_public() {
?>
<script type="text/javascript">
//<![CDATA[
   
// toggle dynamic divs
function toggle(div) {
if (document.getElementById(div).style.display == '') {
document.getElementById(div).style.display = 'none';
return true;
} document.getElementById(div).style.display = '';
}
   
// generate preview
function updatePreview() {
if (document.getElementById('txt')) {               
var body = document.getElementById('txt').value;
body = body.replace('<', '<');
body = body.replace('>', '>');
body = body.replace(/\n/g, '
');
body = body.replace(/\r/g, '
');
document.getElementById('preview').innerHTML = body;
}
}
   
// display preview
function startPreview() {window.self.setInterval("updatePreview()", 1500);}
window.onLoad = startPreview();
//]]>
</script>
<?php }
- and at the very bottom of the function title() add this line
Quote
function title() {
...
js_public();
}
For additional info please take a peek into my source code at www.ni5ni6.com
« Last Edit: September 14, 2007, 03:07:27 AM by philmoz »
Logged
http://www.ni5ni6.com/ - Tutorials, Mods and How-To's about sNews CMS
sNews 1.6 Developers Edition - commented sNews 1.6 version

piXelatedEmpire

  • MIA
  • ULTIMATE member
  • ******
  • Karma: 37
  • Posts: 1401
  • currently MIA
ni5ni6.com comments addons
« Reply #2 on: February 01, 2007, 01:23:20 AM »

thanks Mika!

I'll have a crack at adding this soon as the latest sNews is released :D
Logged
my apologies to the sNews crew, but I will be MIA for the forseeable future

philmoz

  • High flyer
  • ULTIMATE member
  • ******
  • Karma: 161
  • Posts: 1988
    • fiddle 'n fly
Re: ni5ni6.com comments addons
« Reply #3 on: September 14, 2007, 03:08:01 AM »

rectified forum transfer issue with code.
Logged
Of all the things I have lost, it is my mind that I miss the most.