Commit c3251d61 authored by Jonas's avatar Jonas

Initial commit

parents
togglewrap Plugin for DokuWiki
Toggle wraps with checkbox
All documentation for this plugin can be found at
http://jonas.tuxfamily.org
If you install this plugin manually, make sure it is installed in
lib/plugins/togglewrap/ - if the folder is called different it
will not work!
Please refer to http://www.dokuwiki.org/plugins for additional info
on how to install plugins in DokuWiki.
----
Copyright (C) Jonas Fourquier <jonas@mythtv-fr.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
See the COPYING file in your DokuWiki folder for details
<?php
/**
* Default settings for the togglewrap plugin
*
* @author Jonas Fourquier <jonas@mythtv-fr.org>
*/
//$conf['fixme'] = 'FIXME';
<?php
/**
* Options for the togglewrap plugin
*
* @author Jonas Fourquier <jonas@mythtv-fr.org>
*/
//$meta['fixme'] = array('string');
base togglewrap
author Jonas Fourquier
email jonas@mythtv-fr.org
date 2014-10-11
name togglewrap plugin
desc Show/hide wraps with checkboxes
url https://www.dokuwiki.org/plugin:togglewrap
jQuery(function() {
jQuery(".togglewrap").each(function() {
if (this.checked) {
jQuery('.wrap_'+this.value).show();
jQuery('.wrap_not_'+this.value).hide();
}
else {
jQuery('.wrap_'+this.value).hide();
jQuery('.wrap_not_'+this.value).show();
}
});
jQuery(".togglewrap").change(function() {
if (this.checked) {
jQuery('.wrap_'+this.value).show(400);
jQuery('.wrap_not_'+this.value).hide(400);
}
else {
jQuery('.wrap_'+this.value).hide(400);
jQuery('.wrap_not_'+this.value).show(400);
}
});
});
<?php
/**
* DokuWiki Plugin togglewrap (Syntax Component)
*
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
* @author Jonas Fourquier <jonas@mythtv-fr.org>
*/
// must be run within Dokuwiki
if (!defined('DOKU_INC')) die();
class syntax_plugin_togglewrap extends DokuWiki_Syntax_Plugin {
public function getType() {
return 'substition';
}
public function getPType() {
return 'normal';
}
public function getSort() {
return 308;
}
public function connectTo($mode) {
$this->Lexer->addSpecialPattern('{{togglewrap>.*?}}',$mode,'plugin_togglewrap');
}
public function handle($match, $state, $pos, Doku_Handler &$handler){
$match = substr($match, 13, -2);
list ($opts,$label) = explode('|',$match, 2);
list ($class,$opts) = explode('&', $opts, 2);
if (!$label) $label = $class;
$opts = explode('&',$opts);
return array($class, $label, $pos, $opts);
}
public function render($mode, Doku_Renderer &$renderer, $data) {
if($mode != 'xhtml') return false;
list($class, $label, $pos, $opts) = $data;
$renderer->doc .= '<input id="togglewrap_'.$pos.'" type="checkbox" class="togglewrap" value="'.$class.'" '.(in_array('checked',$opts) ? 'checked=checked ' : '').' /><label for="togglewrap_'.$pos.'">'.$label.'</label>';
return true;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment