Browse Source

First

master
François 4 months ago
parent
commit
697d24ab9a
  1. 3
      README.md
  2. 25
      action.php
  3. 8
      conf/default.php
  4. 9
      conf/metadata.php
  5. BIN
      images/left.png
  6. BIN
      images/right.png
  7. 7
      jquery.scrollTo.min.js
  8. 10
      lang/en/settings.php
  9. 10
      lang/fr/settings.php
  10. 7
      plugin.info.txt
  11. 47
      script.js
  12. 57
      style.css
  13. 94
      syntax.php

3
README.md

@ -1,2 +1,5 @@
# showsamples
DokuWiki Extensions : https://www.dokuwiki.org/plugin:showsamples
Installs a carousel that contains topic snippets.

25
action.php

@ -0,0 +1,25 @@
<?php
/**
* @license http://www.cecill.info/licences/Licence_CeCILL-B_V1-fr.html
* @author Francois Merciol <webmestre@fsl56.org>
*
* 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));
}
}

8
conf/default.php

@ -0,0 +1,8 @@
<?php
/**
* @license http://www.cecill.info/licences/Licence_CeCILL-B_V1-fr.html
* @author Francois Merciol <dokuplugin@merciol.fr>
*
* Options for the showSamples Plugin
*/
$conf['carouselDelai'] = 10;

9
conf/metadata.php

@ -0,0 +1,9 @@
<?php
/**
* @license http://www.cecill.info/licences/Licence_CeCILL-B_V1-fr.html
* @author Francois Merciol <dokuplugin@merciol.fr>
*
* Metadata for configuration manager plugin
* Additions for the schedule plugin
*/
$meta['carouselDelai'] = array('numeric');

BIN
images/left.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 531 B

BIN
images/right.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 534 B

7
jquery.scrollTo.min.js

@ -0,0 +1,7 @@
/**
* Copyright (c) 2007-2015 Ariel Flesler - aflesler<a>gmail<d>com | 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<b.axis.length;u&&(d/=2);b.offset=h(b.offset);b.over=h(b.over);return this.each(function(){function k(a){var k=$.extend({},b,{queue:!0,duration:d,complete:a&&function(){a.call(q,e,b)}});r.animate(f,k)}if(null!==a){var l=n(this),q=l?this.contentWindow||window:this,r=$(q),e=a,f={},t;switch(typeof e){case "number":case "string":if(/^([+-]=?)?\d+(\.\d+)?(px|%)?$/.test(e)){e= h(e);break}e=l?$(e):$(e,q);case "object":if(e.length===0)return;if(e.is||e.style)t=(e=$(e)).offset()}var v=$.isFunction(b.offset)&&b.offset(q,e)||b.offset;$.each(b.axis.split(""),function(a,c){var d="x"===c?"Left":"Top",m=d.toLowerCase(),g="scroll"+d,h=r[g](),n=p.max(q,c);t?(f[g]=t[m]+(l?0:h-r.offset()[m]),b.margin&&(f[g]-=parseInt(e.css("margin"+d),10)||0,f[g]-=parseInt(e.css("border"+d+"Width"),10)||0),f[g]+=v[m]||0,b.over[m]&&(f[g]+=e["x"===c?"width":"height"]()*b.over[m])):(d=e[m],f[g]=d.slice&& "%"===d.slice(-1)?parseFloat(d)/100*n:d);b.limit&&/^\d+$/.test(f[g])&&(f[g]=0>=f[g]?0:Math.min(f[g],n));!a&&1<b.axis.length&&(h===f[g]?f={}:u&&(k(b.onAfterFirst),f={}))});k(b.onAfter)}})};p.max=function(a,d){var b="x"===d?"Width":"Height",h="scroll"+b;if(!n(a))return a[h]-$(a)[b.toLowerCase()]();var b="client"+b,k=a.ownerDocument||a.document,l=k.documentElement,k=k.body;return Math.max(l[h],k[h])-Math.min(l[b],k[b])};$.Tween.propHooks.scrollLeft=$.Tween.propHooks.scrollTop={get:function(a){return $(a.elem)[a.prop]()}, set:function(a){var d=this.get(a);if(a.options.interrupt&&a._last&&a._last!==d)return $(a.elem).stop();var b=Math.round(a.now);d!==b&&($(a.elem)[a.prop](b),a._last=this.get(a))}};return p});

10
lang/en/settings.php

@ -0,0 +1,10 @@
<?php
/**
* @license http://www.cecill.info/licences/Licence_CeCILL-B_V1-fr.html
* @author Francois Merciol <dokuplugin@merciol.fr>
*
* English language file
*/
// for the configuration manager
$lang['carouselDelai'] = 'Carousel turn delai (sec)';

10
lang/fr/settings.php

@ -0,0 +1,10 @@
<?php
/**
* @license http://www.cecill.info/licences/Licence_CeCILL-B_V1-fr.html
* @author Francois Merciol <dokuplugin@merciol.fr>
*
* French language file
*/
// for the configuration manager
$lang['carouselDelai'] = 'Délai de rotation du carrousel (en secondes)';

7
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

47
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 ());

57
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;
}

94
syntax.php

@ -0,0 +1,94 @@
<?php
/**
* @license http://www.cecill.info/licences/Licence_CeCILL-B_V1-fr.html
* @author Francois <webmestre@fsl56.org>
*
* 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 ('<showSamples[^>]*>', $mode, 'plugin_showsamples');
}
function postConnect() {
$this->Lexer->addExitPattern ('</showSamples>', 'plugin_showsamples');
}
// ============================================================
function handle ($match, $state, $pos, Doku_Handler $handler){
switch ($state) {
case DOKU_LEXER_ENTER:
return array($state, trim (substr ($match, 12, -1))); // "<showSamples" => 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 .=
'<div class="showSamples">'.NL.
' <div class="navi">'.NL.
' <a onClick="showCarouselLeft()"><img src="'.$imgDir.'left.png" style="display:none;" class="leftside"/></a>'.NL.
' <a onClick="showCarouselRight()"><img src="'.$imgDir.'right.png" class="rightside"/></a>'.NL.
' </div>'.NL.
' <div class="slide">';
break;
case DOKU_LEXER_EXIT :
$renderer->doc .=
' </div>'.NL.
'</div>';
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 .=
' <h1>Help showSamples V1.0</h1>'.NL.
' <ul>'.NL.
' <li><b>{{showSamples [help] <b>}}</b></li>'.NL.
' </ul>'.NL.
' <p><a class="urlextern" rel="nofollow" title="'.$url.'" href="'.$url.'">'.$url.'</a></p>'.NL;
}
// ============================================================
} // syntax_plugin_showSamples
?>
Loading…
Cancel
Save