forked from neuralyzer/dokuwiki-plugin-revealjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.php
52 lines (46 loc) · 2.08 KB
/
action.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
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_revealjs extends DokuWiki_Action_Plugin {
function register(Doku_Event_Handler $controller) {
$controller->register_hook('RENDERER_CONTENT_POSTPROCESS', 'BEFORE', $this, '_renderer_content_postprocess');
}
function _renderer_content_postprocess(&$event, $param) {
if ($_GET['do'] !== 'export_revealjs' && $this->getConf('revealjs_active')) {
/* close last edit section correctly (missing </div>), because we close sections
only when a new one is opened - and this logic fails for the last section in the
document */
$search = '<!-- EDIT';
$replace = '</div><!-- EDIT';
$pos = strrpos($event->data[1],$search);
if ($pos !== false) {
$event->data[1] = substr_replace($event->data[1], $replace, $pos, strlen($search));
//dbglog('Plugin revealjs - hook RENDERER_CONTENT_POSTPROCESS - closing last edit section (missing </div>).', __FILE__.' line '.__LINE__);
}
// correct link for PDF export and fixing unknown slide directions in wiki page with jQuery
$event->data[1] .='
<script>
jQuery(document).ready(function(){
jQuery(".slide-export-link a:last").each(function(){
var elem = jQuery(this);
var count = (elem.attr("href").match(/\?/g) || []).length;
if (count == 0) {
elem.attr("href", elem.attr("href").replace("&print-pdf","?print-pdf"));
}
});'.($this->getConf('slides_with_unknown_direction')?'
jQuery(".fix-my-direction").each(function(){
var elem = jQuery(this);
elem.removeClass("fix-my-direction");
if (elem.next().find("h1'.($this->getConf('horizontal_slide_level')==2?',h2':'').'").length > 0) {
elem.text("→" + elem.text());
}
else {
elem.text("↓" + elem.text());
}
});':'').'
});
</script>';
}
}
}