diff --git a/README.md b/README.md index 90bd46c..7053832 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,5 @@ # showsamples +DokuWiki Extensions : https://www.dokuwiki.org/plugin:showsamples + +Installs a carousel that contains topic snippets. diff --git a/action.php b/action.php new file mode 100644 index 0000000..9108268 --- /dev/null +++ b/action.php @@ -0,0 +1,25 @@ + + * + * Plugin showSamples: display sample from plugins + */ + +if (!defined ('DOKU_INC')) + die (); +if (!defined ('DOKU_PLUGIN')) + define ('DOKU_PLUGIN', DOKU_INC.'lib/plugins/'); +require_once (DOKU_PLUGIN.'action.php'); + +class action_plugin_showsamples extends DokuWiki_Action_Plugin { + + function register (Doku_Event_Handler $controller) { + $controller->register_hook ('DOKUWIKI_STARTED', 'AFTER', $this, '_defconf'); + } + + function _defconf (&$event, $param) { + global $JSINFO; + $JSINFO ['carousel'] = array ('delai' => ($this->getConf ('carouselDelai')*1000)); + } +} diff --git a/conf/default.php b/conf/default.php new file mode 100644 index 0000000..6160551 --- /dev/null +++ b/conf/default.php @@ -0,0 +1,8 @@ + + * + * Options for the showSamples Plugin + */ +$conf['carouselDelai'] = 10; diff --git a/conf/metadata.php b/conf/metadata.php new file mode 100644 index 0000000..227b69b --- /dev/null +++ b/conf/metadata.php @@ -0,0 +1,9 @@ + + * + * Metadata for configuration manager plugin + * Additions for the schedule plugin + */ +$meta['carouselDelai'] = array('numeric'); diff --git a/images/left.png b/images/left.png new file mode 100644 index 0000000..1b6141c Binary files /dev/null and b/images/left.png differ diff --git a/images/right.png b/images/right.png new file mode 100644 index 0000000..63fd456 Binary files /dev/null and b/images/right.png differ diff --git a/jquery.scrollTo.min.js b/jquery.scrollTo.min.js new file mode 100644 index 0000000..f927a43 --- /dev/null +++ b/jquery.scrollTo.min.js @@ -0,0 +1,7 @@ +/** + * Copyright (c) 2007-2015 Ariel Flesler - afleslergmailcom | http://flesler.blogspot.com + * Licensed under MIT + * @author Ariel Flesler + * @version 2.1.2 + */ +;(function(f){"use strict";"function"===typeof define&&define.amd?define(["jquery"],f):"undefined"!==typeof module&&module.exports?module.exports=f(require("jquery")):f(jQuery)})(function($){"use strict";function n(a){return!a.nodeName||-1!==$.inArray(a.nodeName.toLowerCase(),["iframe","#document","html","body"])}function h(a){return $.isFunction(a)||$.isPlainObject(a)?a:{top:a,left:a}}var p=$.scrollTo=function(a,d,b){return $(window).scrollTo(a,d,b)};p.defaults={axis:"xy",duration:0,limit:!0};$.fn.scrollTo=function(a,d,b){"object"=== typeof d&&(b=d,d=0);"function"===typeof b&&(b={onAfter:b});"max"===a&&(a=9E9);b=$.extend({},p.defaults,b);d=d||b.duration;var u=b.queue&&1=f[g]?0:Math.min(f[g],n));!a&&1 + * + * English language file + */ + +// for the configuration manager +$lang['carouselDelai'] = 'Carousel turn delai (sec)'; diff --git a/lang/fr/settings.php b/lang/fr/settings.php new file mode 100644 index 0000000..4c797c7 --- /dev/null +++ b/lang/fr/settings.php @@ -0,0 +1,10 @@ + + * + * French language file + */ + +// for the configuration manager +$lang['carouselDelai'] = 'Délai de rotation du carrousel (en secondes)'; diff --git a/plugin.info.txt b/plugin.info.txt new file mode 100644 index 0000000..432b385 --- /dev/null +++ b/plugin.info.txt @@ -0,0 +1,7 @@ +base showsamples +author Francois Merciol +email dokuplugin@merciol.fr +date 2021-03-31 +name showSamples Plugin +desc Show samples from plugins +url http://www.dokuwiki.org/plugin:showsamples diff --git a/script.js b/script.js new file mode 100644 index 0000000..0d9b107 --- /dev/null +++ b/script.js @@ -0,0 +1,47 @@ +/* DOKUWIKI:include_once jquery.scrollTo.min.js */ + +var showCarouselItem = 0; +var showCarouselDelai = JSINFO['carousel']['delai']; +var showCarouselMax = jQuery ('div.showSamples div.slide ul li').length; +var showCarouselTimeout; + +function showCarouselLeft () { + if (showCarouselItem < 1) + return; + showCarouselItem--; + showCarouselMove (); +} + +function showCarouselRight () { + if (showCarouselItem >= showCarouselMax) + return; + showCarouselItem++; + showCarouselMove (); +} + +function showCarouselMove () { + jQuery ("div.showSamples div.navi a img.leftside").each (function () { + this.style.display = (showCarouselItem > 0) ? "" : "none"; + }); + var showCarouselMax = jQuery ('div.showSamples div.slide ul li').length; + jQuery ("div.showSamples div.navi a img.rightside").each (function () { + this.style.display = (showCarouselItem < (showCarouselMax-1)) ? "" : "none"; + }); + jQuery ("div.showSamples div.slide").scrollTo ('li:eq('+showCarouselItem+')', 1000); +} + +function showCarousel () { + showCarouselItem = 0; + showCarouselMove (); + showCarouselTimeout = setTimeout ("showCarouselNext ()", showCarouselDelai); +} + +function showCarouselNext () { + clearTimeout (showCarouselTimeout); + if (showCarouselMax) + showCarouselItem = (showCarouselItem+1) % (jQuery ('div.showSamples div.slide ul li').length); + showCarouselMove (); + showCarouselTimeout = setTimeout ("showCarouselNext ()", showCarouselDelai); +} + +jQuery (showCarousel ()); diff --git a/style.css b/style.css new file mode 100644 index 0000000..c41ea0d --- /dev/null +++ b/style.css @@ -0,0 +1,57 @@ +div.showSamples div.navi { + z-index: 2; + position: absolute; + margin: 0; + padding: 0; + width: 200px; +} + +div.showSamples div.navi img.leftside { + float: left; +} + +div.showSamples div.navi img.rightside { + float: right; +} + +div.showSamples div.slide { + z-index: 1; + position: relative; + margin: 0; + padding: 0; + height: 200px; + width: 200px; + overflow: hidden; +} + +div.showSamples div.slide ul { + position: absolute; + list-style: none outside none; + width: 20000px; +} + +div.showSamples div.slide ul li { + float: left; + font-size: 80%; + width: 200px; +} + +div.showSamples div.slide ul li div.li { + background: none !important; + margin: 0 auto !important; + padding: 0 !important; + text-align: center; +} + +div.showSamples div.slide ul li div.highlightMenu { + border: none; +} + +div.showSamples div.slide ul li div div.tileBlog { + margin: 0 auto; +} + +div.showSamples div.slide ul li div div.glossary div { + margin: 1em auto; + width: 180px; +} \ No newline at end of file diff --git a/syntax.php b/syntax.php new file mode 100644 index 0000000..8e03597 --- /dev/null +++ b/syntax.php @@ -0,0 +1,94 @@ + + * + * Plugin showSamples: display sample from plugins + */ + +if (!defined ('DOKU_INC')) + die (); +if (!defined ('DOKU_PLUGIN')) + define ('DOKU_PLUGIN', DOKU_INC.'lib/plugins/'); +require_once (DOKU_PLUGIN.'syntax.php'); + +class syntax_plugin_showSamples extends DokuWiki_Syntax_Plugin { + + // ============================================================ + // function getInfo () { + // return confToHash (dirname (__FILE__).'/INFO.txt'); + // } + function getType () { return 'substition'; } + function getPType () { return 'block'; } + function getSort () { return 299; } + function getAllowedTypes() { return array ('container', 'baseonly', 'formatting', 'substition', 'protected', 'disabled', 'paragraphs'); } + function connectTo ($mode) { + $this->Lexer->addEntryPattern (']*>', $mode, 'plugin_showsamples'); + } + function postConnect() { + $this->Lexer->addExitPattern ('', 'plugin_showsamples'); + } + + // ============================================================ + function handle ($match, $state, $pos, Doku_Handler $handler){ + switch ($state) { + case DOKU_LEXER_ENTER: + return array($state, trim (substr ($match, 12, -1))); // " 12 ">" => 1 + case DOKU_LEXER_UNMATCHED: + return array($state, $match); + case DOKU_LEXER_EXIT: + return array($state); + } + return false; + } + + // ============================================================ + function render ($mode, Doku_Renderer $renderer, $indata) { + if ($mode != 'xhtml') + return false; + if (empty ($indata)) + return false; + list ($instr, $data) = $indata; + //$data = " ".$data." "; + $renderer->info['cache'] = FALSE; + switch ($instr) { + case DOKU_LEXER_ENTER : + if (preg_match_all ("#(\"[^\"]*\")*help(\"[^\"]*\")*#", strtolower ($data), $dumy) > 0) { + $this->help ($renderer); + return true; + } + $imgDir = DOKU_REL.'lib/plugins/showsamples/images/'; + $renderer->doc .= + '
'.NL. + ' '.NL. + '
'; + break; + case DOKU_LEXER_EXIT : + $renderer->doc .= + '
'.NL. + '
'; + break; + case DOKU_LEXER_UNMATCHED: + $renderer->doc .= $renderer->_xmlEntities($data); + break; + } + return true; + } + + // ============================================================ + function help (&$renderer) { + $url = "http://fsl56.org/admin/plugins/showSamples/"; + $renderer->doc .= + '

Help showSamples V1.0

'.NL. + ' '.NL. + '

'.$url.'

'.NL; + } + + // ============================================================ +} // syntax_plugin_showSamples +?>