Skip to content

Commit

Permalink
new configuration option which enables a button for toggling the visi…
Browse files Browse the repository at this point in the history
…bility of the discussion section
  • Loading branch information
lupo49 committed Jun 29, 2011
1 parent e3e14ca commit 4617840
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 1 deletion.
18 changes: 17 additions & 1 deletion action.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -794,6 +801,15 @@ function _get_style()
return $this->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
*/
Expand Down
2 changes: 2 additions & 0 deletions conf/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 :
2 changes: 2 additions & 0 deletions conf/metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,6 @@
'_choices' => array('off', 'top', 'bottom')
);

$meta['visibilityButton'] = array('onoff');

//Setup VIM: ex: et ts=2 enc=utf-8 :
2 changes: 2 additions & 0 deletions lang/de/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 :
2 changes: 2 additions & 0 deletions lang/en/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 :
19 changes: 19 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand All @@ -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);
})
16 changes: 16 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 4617840

Please sign in to comment.