Skip to content

Commit

Permalink
NewFeature: view/hide option for code block
Browse files Browse the repository at this point in the history
Signed-off-by: Taggic <taggic@t-online.de>
  • Loading branch information
Taggic committed Jun 22, 2012
1 parent 029e4fd commit dbc97ed
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 6 deletions.
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
2012-02-10
2012-06-22
Binary file added images/enfold.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion plugin.info.txt
Expand Up @@ -3,7 +3,7 @@
base xssnipper
author Taggic
email taggic@t-online.de
date 2012-02-10
date 2012-06-22
name xssnipper
desc provides syntax plugin to retrieve code snippeds from files
url http://www.dokuwiki.org/plugin:xssnipper
Expand Down
8 changes: 8 additions & 0 deletions style.css
Expand Up @@ -38,4 +38,12 @@
}
table.xssnipper pre {
border: 0 !important;
}

.img_clipclap {
background-image:url(images/enfold.png);
background-repeat:no-repeat;
height:19px;
background-position: 0 0;
margin-left: 2em;
}
46 changes: 42 additions & 4 deletions syntax.php
Expand Up @@ -64,7 +64,7 @@ function handle($match, $state, $pos, &$handler) {


if (!$params) {
msg('Syntax of xssnipper detected but an unknown parameter was attached.', -1);
msg('Syntax of xssnipper detected but parameter missing.', -1);
}
elseif($params[0] == ''){
// 0 1 2 3
Expand All @@ -76,6 +76,7 @@ function handle($match, $state, $pos, &$handler) {
$alpha = explode(' ',$params[2]);
$xssnipper['type'] = $alpha[0];
$xssnipper['file'] = $alpha[1];
$xssnipper['block'] = $alpha[2];
$xssnipper['code'] = $params[3];
}
else {
Expand All @@ -87,6 +88,7 @@ function handle($match, $state, $pos, &$handler) {
$alpha = explode(' ',$params[3]);
$xssnipper['type'] = $alpha[0];
$xssnipper['file'] = $alpha[1];
$xssnipper['block'] = $alpha[2];
}
return $xssnipper;
}
Expand Down Expand Up @@ -137,9 +139,29 @@ function render($mode, &$renderer, $xssnipper) {
<dl class="code">
<dt>
<a href="'.$xs_path.'&codeblock='.$this->_codeblock.'" title="Download Snippet" class="mediafile mf_'.$xssnipper['type'].'">'.$xssnipper['file'].'</a>
</dt>
<dd style="display : none;">'.$code_lines.'</dd>'.$text.'
</dl>'.NL;
</dt>';

// returns the javascript function for clip-clap of block if downloadblock is used
$clipclap_flag = false;
if($xssnipper['block']) {
$code_block .= '<br />'.$this->__scripts_html();
$clipclap_id = microtime();
$img_ID = 'img_'.$clipclap_id;
$clipclap_img .= '<img id="'.$img_ID.'"
src="'.DOKU_BASE.'lib/plugins/xssnipper/images/enfold.png"
alt="show" />'.NL;

$code_block .= '<span id="'.$clipclap_id.'" style="display : none;">'.NL;
$clipclap_flag = true;
}

$code_block .= '<dd style="display : none;">'.$code_lines.'</dd>'.$text.NL;

if($clipclap_flag == true) {
$code_block .= '</span>'.NL;
$code_block .= '<div class="img_clipclap" onClick="span_open(\''.$clipclap_id.'\',\''.$img_ID.'\')"></div>'.NL;
}
$code_block .= '</dl>'.NL;

$renderer->doc .= $code_block;

Expand All @@ -154,5 +176,21 @@ function render($mode, &$renderer, $xssnipper) {
$this->_codeblock++;

}
/******************************************************************************/
function __scripts_html() {
$ret .= '<span><script>
function span_open(blink_id, img_id)
{ if (document.getElementById(blink_id).style.display == "block")
{ document.getElementById(blink_id).style.display = "none";
document.getElementById(img_id).style.backgroundPosition = "0px 0px";
}
else
{ document.getElementById(blink_id).style.display = "block";
document.getElementById(img_id).style.backgroundPosition = "0px -19px";
}
}
</script></span>'.NL;
return $ret;
}
}
?>

0 comments on commit dbc97ed

Please sign in to comment.