MEDIUM: Update plugin folded to v2017-05-30
This commit is contained in:
parent
f7a5a38b19
commit
ff7e25de21
|
@ -18,6 +18,7 @@ class action_plugin_folded extends DokuWiki_Action_Plugin {
|
|||
*/
|
||||
function register(Doku_Event_Handler $controller) {
|
||||
$controller->register_hook('DOKUWIKI_STARTED', 'AFTER', $this, 'addhidereveal');
|
||||
$controller->register_hook('TEMPLATE_PAGETOOLS_DISPLAY', 'BEFORE', $this, 'add_button', array());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -37,4 +38,30 @@ class action_plugin_folded extends DokuWiki_Action_Plugin {
|
|||
'reveal' => $reveal
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add 'fold/unfold all'-button to pagetools
|
||||
*
|
||||
* @param Doku_Event $event
|
||||
* @param mixed $param not defined
|
||||
*/
|
||||
public function add_button(&$event, $param) {
|
||||
global $ID, $REV;
|
||||
|
||||
if($this->getConf('show_fold_unfold_all_button') && $event->data['view'] == 'main') {
|
||||
$params = array('do' => 'fold_unfold_all');
|
||||
if($REV) $params['rev'] = $REV;
|
||||
|
||||
// insert button at position before last (up to top)
|
||||
$event->data['items'] = array_slice($event->data['items'], 0, -1, true) +
|
||||
array('fold_unfold_all' =>
|
||||
'<li>'
|
||||
.'<a href="javascript:void(0);" class="fold_unfold_all" onclick="fold_unfold_all();" rel="nofollow" title="'.$this->getLang('fold_unfold_all_button').'">'
|
||||
.'<span>'.$this->getLang('fold_unfold_all_button').'</span>'
|
||||
.'</a>'
|
||||
.'</li>'
|
||||
) +
|
||||
array_slice($event->data['items'], -1 , 1, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,4 +5,6 @@
|
|||
* @author Christopher Smith <chris@jalakai.co.uk>
|
||||
*/
|
||||
$conf['hide'] = ''; // hide tooltip, if empty will use localised string
|
||||
$conf['reveal'] = ''; // reveal tooltip, if empty will use localised string
|
||||
$conf['reveal'] = ''; // reveal tooltip, if empty will use localised string
|
||||
$conf['unfold_default'] = 0; // unfold all text per default
|
||||
$conf['show_fold_unfold_all_button'] = 1; // show a button in the pagetool-area that folds/unfolds all texts of the current page
|
||||
|
|
|
@ -6,3 +6,5 @@
|
|||
*/
|
||||
$meta['hide'] = array('string');
|
||||
$meta['reveal'] = array('string');
|
||||
$meta['unfold_default'] = array('onoff');
|
||||
$meta['show_fold_unfold_all_button'] = array('onoff');
|
||||
|
|
|
@ -1,16 +1,11 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Czech language file
|
||||
*
|
||||
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
||||
* @author Esther Brunner <esther@kaffeehaus.ch>
|
||||
*
|
||||
* @author Esther Brunner <esther@kaffeehaus.ch>
|
||||
*/
|
||||
|
||||
// custom language strings for the plugin
|
||||
$lang['reveal'] = 'zobrazit';
|
||||
$lang['reveallong'] = 'zobrazit skrytý obsah';
|
||||
|
||||
$lang['hide'] = 'skrýt';
|
||||
$lang['hidelong'] = 'skrýt obsah';
|
||||
|
||||
//Setup VIM: ex: et ts=2 enc=utf-8 :
|
||||
$lang['reveal'] = 'zobrazit';
|
||||
$lang['reveallong'] = 'zobrazit skrytý obsah';
|
||||
$lang['hide'] = 'skrýt';
|
||||
$lang['hidelong'] = 'skrýt obsah';
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
||||
*
|
||||
* @author Jaroslav Lichtblau <jlichtblau@seznam.cz>
|
||||
*/
|
||||
$lang['hide'] = 'Zasunout skrývací nabídku<br />(nechat prázdné pro použití přeložených textů)';
|
||||
$lang['reveal'] = 'Vysunout skrývací nabídku<br />(nechat prázdné pro použití přeložených textů)';
|
|
@ -13,4 +13,6 @@ $lang['reveallong'] = 'zeige den eingeklappten Inhalt';
|
|||
$lang['hide'] = 'zuklappen';
|
||||
$lang['hidelong'] = 'verberge den Inhalt';
|
||||
|
||||
//Setup VIM: ex: et ts=2 enc=utf-8 :
|
||||
$lang['fold_unfold_all_button'] = 'Alles aus-/einklappen';
|
||||
|
||||
//Setup VIM: ex: et ts=2 enc=utf-8 :
|
||||
|
|
|
@ -9,3 +9,5 @@
|
|||
// for the configuration manager
|
||||
$lang['hide'] = 'Tooltip zum Zuklappen<br />(Feld leer lassen um den Standardwert zu nutzen)';
|
||||
$lang['reveal'] = 'Tooltip zum Aufklappen<br />(Feld leer lassen um den Standardwert zu nutzen)';
|
||||
$lang['unfold_default'] = 'Standardmäßig alles aufklappen';
|
||||
$lang['show_fold_unfold_all_button'] = 'Button zum Zuklappen/Aufklappen aller Text der aktuellen Seite anzeigen';
|
||||
|
|
|
@ -13,4 +13,6 @@ $lang['reveallong'] = 'reveal hidden content';
|
|||
$lang['hide'] = 'hide';
|
||||
$lang['hidelong'] = 'hide content';
|
||||
|
||||
//Setup VIM: ex: et ts=2 enc=utf-8 :
|
||||
$lang['fold_unfold_all_button'] = 'Fold/unfold all';
|
||||
|
||||
//Setup VIM: ex: et ts=2 enc=utf-8 :
|
||||
|
|
|
@ -9,3 +9,5 @@
|
|||
// for the configuration manager
|
||||
$lang['hide'] = 'Folding tooltip to hide<br />(leave empty to use localised string)';
|
||||
$lang['reveal'] = 'Folding tooltip to reveal<br />(leave empty to use localised string)';
|
||||
$lang['unfold_default'] = 'Unfold everything by default';
|
||||
$lang['show_fold_unfold_all_button'] = 'Show a button in the pagetool-area that folds/unfolds all texts of the current page';
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
||||
*
|
||||
* @author Sam01 <m.sajad079@gmail.com>
|
||||
*/
|
||||
$lang['reveal'] = 'آشکارسازی';
|
||||
$lang['reveallong'] = 'آشکارسازی محتوای پنهان';
|
||||
$lang['hide'] = 'مخفیسازی';
|
||||
$lang['hidelong'] = 'مخفیسازی محتوا';
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
||||
*
|
||||
* @author Sam01 <m.sajad079@gmail.com>
|
||||
*/
|
||||
$lang['hide'] = 'جاسازی راهنمای ابزار برای مخفی کردن<br />(خالی گذاشتن برای استفاده از رشته محلی)';
|
||||
$lang['reveal'] = 'جاسازی راهنمای ابزار برای آشکار کردن<br />(خالی گذاشتن برای استفاده از رشته محلی)';
|
|
@ -2,11 +2,13 @@
|
|||
|
||||
/**
|
||||
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
||||
*
|
||||
*
|
||||
* @author Esther Brunner <esther@kaffeehaus.ch>
|
||||
* @author Fabrice Dejaigher <fabrice@chtiland.com>
|
||||
* @author Schplurtz le Déboulonné <schplurtz@laposte.net>
|
||||
*/
|
||||
$lang['reveal'] = 'révéler';
|
||||
$lang['reveallong'] = 'révéler le contenu masqué';
|
||||
$lang['hide'] = 'masquer';
|
||||
$lang['hidelong'] = 'masquer le contenu';
|
||||
$lang['fold_unfold_all_button'] = 'Tout plier/déplier';
|
||||
|
|
|
@ -2,8 +2,11 @@
|
|||
|
||||
/**
|
||||
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
||||
*
|
||||
*
|
||||
* @author Fabrice Dejaigher <fabrice@chtiland.com>
|
||||
* @author Schplurtz le Déboulonné <schplurtz@laposte.net>
|
||||
*/
|
||||
$lang['hide'] = 'Contenu de l\'infobulle de l\'élément à masquer.<br/>(laissez vide pour utiliser la chaîne localisée)';
|
||||
$lang['reveal'] = 'Contenu de l\'infobulle de l\'élément à révéler.<br/>(laissez vide pour utiliser la chaîne localisée)';
|
||||
$lang['unfold_default'] = 'Tout déplier par défaut';
|
||||
$lang['show_fold_unfold_all_button'] = 'Ajouter un bouton dans la zone des outils de page pour plier et déplier tous les textes de la page courante';
|
||||
|
|
|
@ -1,16 +1,11 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* norwegian language file
|
||||
*
|
||||
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
||||
* @author Matthias Schulte <mailinglist@lupo49.de>
|
||||
*
|
||||
* @author Matthias Schulte <mailinglist@lupo49.de>
|
||||
*/
|
||||
|
||||
// custom language strings for the plugin
|
||||
$lang['reveal'] = 'vis';
|
||||
$lang['reveallong'] = 'vis skjult innhold ';
|
||||
|
||||
$lang['hide'] = 'skjul';
|
||||
$lang['hidelong'] = 'skjul innhold';
|
||||
|
||||
//Setup VIM: ex: et ts=2 :
|
||||
$lang['reveal'] = 'vis';
|
||||
$lang['reveallong'] = 'vis skjult innhold ';
|
||||
$lang['hide'] = 'skjul';
|
||||
$lang['hidelong'] = 'skjul innhold';
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
||||
*
|
||||
* @author Arne Hanssen <arne.hanssen@getmail.no>
|
||||
*/
|
||||
$lang['hide'] = 'Infoboble for å skjule<br />(la stå tom for å bruke oversatt tekst)';
|
||||
$lang['reveal'] = 'Infoboble for å vise<br />(la stå tom for å bruke oversatt tekst)';
|
|
@ -1,16 +1,13 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* turkish language file
|
||||
*
|
||||
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
||||
* @author Chris Smith <chris@jalakai.co.uk>
|
||||
*
|
||||
* @author Chris Smith <chris@jalakai.co.uk>
|
||||
* @author Mustafa Icer <info@flyhost.de>
|
||||
*/
|
||||
|
||||
// custom language strings for the plugin
|
||||
$lang['reveal'] = 'göster';
|
||||
$lang['reveallong'] = 'gizlenen içeri?i göster';
|
||||
|
||||
$lang['hide'] = 'gizle';
|
||||
$lang['hidelong'] = 'içeri?i gizle';
|
||||
|
||||
//Setup VIM: ex: et ts=2 enc=utf-8 :
|
||||
$lang['reveal'] = 'göster';
|
||||
$lang['reveallong'] = 'gizlenen içeriği göster';
|
||||
$lang['hide'] = 'gizle';
|
||||
$lang['hidelong'] = 'içeriği gizle';
|
||||
$lang['fold_unfold_all_button'] = 'katla/tüm katlamalari aç';
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
||||
*
|
||||
* @author Mustafa Icer <info@flyhost.de>
|
||||
*/
|
||||
$lang['unfold_default'] = 'standart olarak tüm katlamalari aç';
|
||||
$lang['show_fold_unfold_all_button'] = 'tüm sayfanin yazılarını katlamak/katlamalari açmak icin,
|
||||
pagetool sayfasında buton göster';
|
Binary file not shown.
After Width: | Height: | Size: 369 B |
|
@ -1,7 +1,7 @@
|
|||
base folded
|
||||
author Michael Hamann, Fabian van-de-l_Isle, Christopher Smith, Esther Brunner
|
||||
email michael@content-space.de
|
||||
date 2014-07-21
|
||||
date 2017-05-30
|
||||
name folded plugin
|
||||
desc Foldable page sections
|
||||
url http://dokuwiki.org/plugin:folded
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
jQuery(function() {
|
||||
// containers for localised reveal/hide strings,
|
||||
// populated from the content set by the action plugin
|
||||
if(!JSINFO || !JSINFO['plugin_folded']) return;
|
||||
var folded_reveal = JSINFO['plugin_folded']['reveal'];
|
||||
var folded_hide = JSINFO['plugin_folded']['hide'];
|
||||
|
||||
|
@ -23,7 +24,7 @@ jQuery(function() {
|
|||
* toggle the folded element via className change also adjust the classname and
|
||||
* title tooltip on the folding link
|
||||
*/
|
||||
jQuery('.folder').click(function folded_toggle(evt) {
|
||||
jQuery('.dokuwiki .folder').click(function folded_toggle(evt) {
|
||||
var id = this.href.match(/(#.*)$/)[1];
|
||||
var $id = jQuery(id);
|
||||
|
||||
|
@ -44,6 +45,46 @@ jQuery(function() {
|
|||
});
|
||||
});
|
||||
|
||||
function fold_unfold_all() {
|
||||
var hide = -1;
|
||||
var cpt = 1;
|
||||
|
||||
var folders = document.getElementsByClassName("folder");
|
||||
var i;
|
||||
for (i = 0; i < folders.length; i++) {
|
||||
// initially, find out whether we want to hide or unhide
|
||||
if (hide == -1) {
|
||||
if (folders[i].className.search("open") == -1) {
|
||||
hide = 0;
|
||||
} else {
|
||||
hide = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (hide == 1) {
|
||||
folders[i].className = folders[i].className.replace(/open/g, "");
|
||||
} else {
|
||||
folders[i].className = folders[i].className + " open";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// get first folded_ object
|
||||
var obj = document.getElementById("folded_" + cpt++);
|
||||
while ( obj != null ) {
|
||||
if (hide == 1) {
|
||||
obj.className = obj.className.replace(/open/g, "");
|
||||
obj.className = obj.className + " hidden";
|
||||
} else {
|
||||
obj.className = obj.className.replace(/hidden/g, "");
|
||||
obj.className = obj.className + " open";
|
||||
}
|
||||
|
||||
// get next folded_ object
|
||||
obj = document.getElementById("folded_" + cpt++);
|
||||
}
|
||||
}
|
||||
|
||||
// support graceful js degradation, this hides the folded blocks from view
|
||||
// before they are shown,
|
||||
// whilst still allowing non-js user to see any folded content.
|
||||
|
|
|
@ -21,6 +21,28 @@ span.indicator {
|
|||
visibility: hidden;
|
||||
}
|
||||
|
||||
/* fold/unfold all button in pagetools area */
|
||||
#dokuwiki__pagetools ul li a.fold_unfold_all {
|
||||
background-position: right 0;
|
||||
}
|
||||
|
||||
#dokuwiki__pagetools ul li a.fold_unfold_all:before {
|
||||
content: url(pagetools-close-open-sprite.png);
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
#dokuwiki__pagetools:hover ul li a.fold_unfold_all,
|
||||
#dokuwiki__pagetools ul li a.fold_unfold_all:focus,
|
||||
#dokuwiki__pagetools ul li a.fold_unfold_all:active {
|
||||
background-image: url(pagetools-close-open-sprite.png);
|
||||
}
|
||||
|
||||
#dokuwiki__pagetools ul li a.fold_unfold_all:hover,
|
||||
#dokuwiki__pagetools ul li a.fold_unfold_all:active,
|
||||
#dokuwiki__pagetools ul li a.fold_unfold_all:focus {
|
||||
background-position: right -45px;
|
||||
}
|
||||
|
||||
/* below style rules are created by javascript
|
||||
.folded.hidden { display: none; }
|
||||
.folder span.indicator { visibility: visible; }
|
||||
|
|
|
@ -8,9 +8,8 @@
|
|||
* @author Esther Brunner <esther@kaffeehaus.ch>
|
||||
*/
|
||||
|
||||
if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
|
||||
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
|
||||
require_once(DOKU_PLUGIN.'syntax.php');
|
||||
// must be run within DokuWiki
|
||||
if(!defined('DOKU_INC')) die();
|
||||
|
||||
// maintain a global count of the number of folded elements in the page,
|
||||
// this allows each to be uniquely identified
|
||||
|
@ -61,12 +60,20 @@ class syntax_plugin_folded_div extends DokuWiki_Syntax_Plugin {
|
|||
switch ($state){
|
||||
case DOKU_LEXER_ENTER:
|
||||
$plugin_folded_count++;
|
||||
$renderer->doc .= '<p><a class="folder" href="#folded_'.$plugin_folded_count.'">';
|
||||
if ($this->getConf('unfold_default')) {
|
||||
$renderer->doc .= '<p><a class="folder open" href="#folded_'.$plugin_folded_count.'">';
|
||||
} else {
|
||||
$renderer->doc .= '<p><a class="folder" href="#folded_'.$plugin_folded_count.'">';
|
||||
}
|
||||
|
||||
if ($cdata)
|
||||
$renderer->doc .= ' '.$renderer->cdata($cdata);
|
||||
|
||||
$renderer->doc .= '</a></p><div class="folded hidden" id="folded_'.$plugin_folded_count.'">';
|
||||
if ($this->getConf('unfold_default')) {
|
||||
$renderer->doc .= '</a></p><div class="folded" id="folded_'.$plugin_folded_count.'">';
|
||||
} else {
|
||||
$renderer->doc .= '</a></p><div class="folded hidden" id="folded_'.$plugin_folded_count.'">';
|
||||
}
|
||||
break;
|
||||
|
||||
case DOKU_LEXER_UNMATCHED: // defensive, shouldn't occur
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
/**
|
||||
* Folded text Plugin, header component:
|
||||
* Render headers included in folded blocks.
|
||||
*
|
||||
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
||||
* @author LarsDW223
|
||||
*/
|
||||
// must be run within Dokuwiki
|
||||
if(!defined('DOKU_INC')) die();
|
||||
|
||||
/**
|
||||
* This class handles header syntax inside folded blocks.
|
||||
* A found header syntax will be rendered as an html header element but
|
||||
* is not a DokuWiki header (no section edit, do not appear in toc).
|
||||
*/
|
||||
class syntax_plugin_folded_header extends DokuWiki_Syntax_Plugin {
|
||||
|
||||
function getType(){ return 'formatting'; }
|
||||
function getPType() { return 'block'; }
|
||||
function getSort(){ return 50; }
|
||||
function connectTo($mode) {
|
||||
if ($mode != 'plugin_folded_div') return;
|
||||
|
||||
// Copied from parser: we're not picky about the closing ones, two are enough
|
||||
$this->Lexer->addSpecialPattern(
|
||||
'[ \t]*={2,}[^\n]+={2,}[ \t]*(?=\n)',
|
||||
$mode,
|
||||
'plugin_folded_header'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the match
|
||||
*/
|
||||
function handle($match, $state, $pos, Doku_Handler $handler){
|
||||
// Copied from parser: get level and title
|
||||
$title = trim($match);
|
||||
$level = 7 - strspn($title,'=');
|
||||
if($level < 1) $level = 1;
|
||||
$title = trim($title,'=');
|
||||
$title = trim($title);
|
||||
return array($title,$level,$pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create output
|
||||
*/
|
||||
function render($mode, Doku_Renderer $renderer, $data) {
|
||||
if($mode != 'xhtml') return;
|
||||
|
||||
list($text,$level,$pos) = $data;
|
||||
|
||||
// Write the header
|
||||
$renderer->doc .= DOKU_LF.'<h'.$level.'>';
|
||||
$renderer->cdata($text);
|
||||
$renderer->doc .= "</h$level>".DOKU_LF;
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -8,9 +8,8 @@
|
|||
* @author Esther Brunner <esther@kaffeehaus.ch>
|
||||
*/
|
||||
|
||||
if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
|
||||
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
|
||||
require_once(DOKU_PLUGIN.'syntax.php');
|
||||
// must be run within DokuWiki
|
||||
if(!defined('DOKU_INC')) die();
|
||||
|
||||
// maintain a global count of the number of folded elements in the page,
|
||||
// this allows each to be uniquely identified
|
||||
|
@ -60,12 +59,20 @@ class syntax_plugin_folded_span extends DokuWiki_Syntax_Plugin {
|
|||
switch ($state){
|
||||
case DOKU_LEXER_ENTER:
|
||||
$plugin_folded_count++;
|
||||
$renderer->doc .= '<a class="folder" href="#folded_'.$plugin_folded_count.'">';
|
||||
if ($this->getConf('unfold_default')) {
|
||||
$renderer->doc .= '<a class="folder open" href="#folded_'.$plugin_folded_count.'">';
|
||||
} else {
|
||||
$renderer->doc .= '<a class="folder" href="#folded_'.$plugin_folded_count.'">';
|
||||
}
|
||||
|
||||
if ($cdata)
|
||||
$renderer->doc .= ' '.$renderer->cdata($cdata);
|
||||
|
||||
$renderer->doc .= '</a><span class="folded hidden" id="folded_'.$plugin_folded_count.'">';
|
||||
if ($this->getConf('unfold_default')) {
|
||||
$renderer->doc .= '</a><span class="folded" id="folded_'.$plugin_folded_count.'">';
|
||||
} else {
|
||||
$renderer->doc .= '</a><span class="folded hidden" id="folded_'.$plugin_folded_count.'">';
|
||||
}
|
||||
break;
|
||||
|
||||
case DOKU_LEXER_UNMATCHED:
|
||||
|
|
Loading…
Reference in New Issue