Permalink
Browse files

Merge pull request #55 from lupo49/master

new configuration option which enables a button for toggling the visibility of the discussion section
  • Loading branch information...
2 parents e3e14ca + 4617840 commit 8a643d9a08271774e62ed297d87c5abf0e867b94 @lupo49 lupo49 committed Jun 29, 2011
Showing with 60 additions and 1 deletion.
  1. +17 −1 action.php
  2. +2 −0 conf/default.php
  3. +2 −0 conf/metadata.php
  4. +2 −0 lang/de/settings.php
  5. +2 −0 lang/en/settings.php
  6. +19 −0 script.js
  7. +16 −0 style.css
View
@@ -358,7 +358,7 @@ function _show($reply = NULL, $edit = NULL) {
$show = true;
// section title
$title = ($data['title'] ? hsc($data['title']) : $this->getLang('discussion'));
- ptln('<div class="comment_wrapper">');
+ ptln('<div class="comment_wrapper" id="comment_wrapper">'); // the id value is used for visibility toggling the section
ptln('<h2><a name="discussion__section" id="discussion__section">', 2);
ptln($title, 4);
ptln('</a></h2>', 2);
@@ -387,6 +387,12 @@ function _show($reply = NULL, $edit = NULL) {
ptln('</div>', 2); // level2 hfeed
ptln('</div>'); // comment_wrapper
}
+
+ // check for toggle print configuration
+ if($this->getConf('visibilityButton')) {
+ // print the hide/show discussion section button
+ $this->_print_toggle_button();
+ }
return true;
}
@@ -654,6 +660,7 @@ function _print($cid, &$data, $parent = '', $reply = '', $visible = true) {
$this->_print_replies($cid, $data, $reply, $visible);
// reply form
$this->_print_form($cid, $reply);
+
}
function _print_comment($cid, &$data, $parent, $reply, $visible, $hidden)
@@ -795,6 +802,15 @@ function _get_style()
}
/**
+ * Show the button which toggle the visibility of the discussion section
+ */
+ function _print_toggle_button() {
+ ptln('<div id="toggle_button" class="toggle_button" style="text-align: right;">');
+ ptln('<input type="submit" id="discussion__btn_toggle_visibility" title="Toggle Visibiliy" class="button" value="Hide/Show">');
+ ptln('</div>');
+ }
+
+ /**
* Outputs the comment form
*/
function _form($raw = '', $act = 'add', $cid = NULL) {
View
@@ -22,4 +22,6 @@
$conf['threads_formposition'] = 'bottom'; // position of new thread form
+$conf['visibilityButton'] = 0; // show/hide button to hide the discussion section
+
//Setup VIM: ex: et ts=2 enc=utf-8 :
View
@@ -28,4 +28,6 @@
'_choices' => array('off', 'top', 'bottom')
);
+$meta['visibilityButton'] = array('onoff');
+
//Setup VIM: ex: et ts=2 enc=utf-8 :
View
@@ -28,4 +28,6 @@
$lang['threads_formposition_o_top'] = 'oben';
$lang['threads_formposition_o_bottom'] = 'unten';
+$lang['visibilityButton'] = 'Schaltfläche anzeigen, mit der der Discussion-Abschnitt aus-/eingeblendet werden kann';
+
//Setup VIM: ex: et ts=2 enc=utf-8 :
View
@@ -29,4 +29,6 @@
$lang['threads_formposition_o_top'] = 'top';
$lang['threads_formposition_o_bottom'] = 'bottom';
+$lang['visibilityButton'] = 'Enable button for toggling the visibility of the discussion section';
+
//Setup VIM: ex: et ts=2 enc=utf-8 :
View
@@ -80,6 +80,18 @@ function discussion_ajax_preview() {
ajax.runAJAX();
}
+/**
+ * Toggle the visibility of the discussion section
+ */
+function discussion_toggle_visibility() {
+ discussion_section = $('comment_wrapper');
+ if(discussion_section.style.display == "none") {
+ discussion_section.style.display = "block";
+ } else {
+ discussion_section.style.display = "none";
+ }
+}
+
// init toolbar
addInitEvent(function() {
if(typeof window.initToolbar == 'function') {
@@ -100,3 +112,10 @@ addInitEvent(function() {
if(!form) return;
addEvent(form, 'submit', function() { return validate(form); });
});
+
+// toggle section visibility
+addInitEvent(function() {
+ var togglebtn = $('discussion__btn_toggle_visibility');
+ if(!togglebtn) return;
+ addEvent(togglebtn, 'click', discussion_toggle_visibility);
+})
View
@@ -108,6 +108,22 @@ div.dokuwiki div.comment_buttons input.button {
margin: 0 0 0 0.5em;
}
+div.dokuwiki div.toggle_button {
+ text-align: right;
+
+}
+
+div.dokuwiki div.toggle_button input.button {
+ border: 1px solid __border__;
+ color: __text__;
+ background-color: __background__;
+ vertical-align: middle;
+ text-decoration: none;
+ padding: 0;
+ margin: 0 12px 0 0;
+ font-size: 10px;
+}
+
div.dokuwiki div.newthread_form {
clear: both;
text-align: center;

0 comments on commit 8a643d9

Please sign in to comment.