Permalink
Browse files

NewFeature: view/hide option for code block

Signed-off-by: Taggic <taggic@t-online.de>
  • Loading branch information...
Taggic committed Jun 22, 2012
1 parent 029e4fd commit dbc97eda42e8a4bf34228025adb20011e17b5ba2
Showing with 52 additions and 6 deletions.
  1. +1 −1 VERSION
  2. BIN images/enfold.png
  3. +1 −1 plugin.info.txt
  4. +8 −0 style.css
  5. +42 −4 syntax.php
View
@@ -1 +1 @@
2012-02-10
2012-06-22
View
BIN +767 Bytes images/enfold.png
Binary file not shown.
View
@@ -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
View
@@ -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;
}
View
@@ -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
@@ -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 {
@@ -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;
}
@@ -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;
@@ -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.