<?php /** * DokuWiki Bootstrap3 Template: Theme Switcher * * @link http://dokuwiki.org/template:bootstrap3 * @author Giuseppe Di Terlizzi <*****@*****.**> * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) */ // must be run from within DokuWiki if (!defined('DOKU_INC')) { die; } if (bootstrap3_conf('showThemeSwitcher')) { global $ID; $bootswatch_theme = bootstrap3_bootswatch_theme(); ?> <!-- theme-switcher --> <ul class="nav navbar-nav" id="dw__themes"> <li class="dropdown"> <a href="<?php wl($ID); ?> " class="dropdown-toggle" data-toggle="dropdown" data-target="#" role="button" aria-haspopup="true" aria-expanded="false"><i class="fa fa-fw fa-tint"></i> <span class="<?php echo in_array('themes', bootstrap3_conf('navbarLabels')) ? '' : 'hidden-lg hidden-md hidden-sm'; ?> "><?php echo tpl_getLang('themes'); ?> </span> <span class="caret"></span></a>
/** * Load the template assets (Bootstrap, AnchorJS, etc) * * @author Giuseppe Di Terlizzi <*****@*****.**> * * @param Doku_Event $event * @param array $param */ function bootstrap3_metaheaders(Doku_Event &$event, $param) { global $INPUT; global $ACT; // Bootstrap Theme $bootstrap_styles = array(); $bootstrap_theme = bootstrap3_conf('bootstrapTheme'); $fixed_top_navbar = bootstrap3_conf('fixedTopNavbar'); switch ($bootstrap_theme) { case 'optional': $bootstrap_styles[] = tpl_basedir() . 'assets/bootstrap/default/bootstrap.min.css'; $bootstrap_styles[] = tpl_basedir() . 'assets/bootstrap/default/bootstrap-theme.min.css'; break; case 'custom': $bootstrap_styles[] = bootstrap3_conf('customTheme'); break; case 'bootswatch': $bootswatch_theme = bootstrap3_bootswatch_theme(); $bootswatch_url = bootstrap3_conf('useLocalBootswatch') ? tpl_basedir() . 'assets/bootstrap' : '//maxcdn.bootstrapcdn.com/bootswatch/3.3.6'; $bootstrap_styles[] = "{$bootswatch_url}/{$bootswatch_theme}/bootstrap.min.css"; break; case 'default': default: $bootstrap_styles[] = tpl_basedir() . 'assets/bootstrap/default/bootstrap.min.css'; break; } foreach ($bootstrap_styles as $style) { array_unshift($event->data['link'], array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => $style)); } $event->data['link'][] = array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => tpl_basedir() . 'assets/font-awesome/css/font-awesome.min.css'); $event->data['script'][] = array('type' => 'text/javascript', 'src' => tpl_basedir() . 'assets/bootstrap/js/bootstrap.min.js'); $event->data['script'][] = array('type' => 'text/javascript', 'src' => tpl_basedir() . 'assets/anchorjs/anchor.min.js'); // Apply some FIX if ($ACT || defined('DOKU_MEDIADETAIL')) { // Default Padding $navbar_padding = 20; if ($fixed_top_navbar) { if ($bootstrap_theme == 'bootswatch') { // Set the navbar height for all Bootswatch Themes (values from @navbar-height in bootswatch/*/variables.less) switch (bootstrap3_bootswatch_theme()) { case 'simplex': case 'superhero': $navbar_height = 40; break; case 'yeti': $navbar_height = 45; break; case 'cerulean': case 'cosmo': case 'custom': case 'cyborg': case 'lumen': case 'slate': case 'spacelab': case 'united': $navbar_height = 50; break; case 'darkly': case 'flatly': case 'journal': case 'sandstone': $navbar_height = 60; break; case 'paper': $navbar_height = 64; break; case 'readable': $navbar_height = 65; break; default: $navbar_height = 50; } } else { $navbar_height = 50; } $navbar_padding += $navbar_height; } $style = ''; $style .= '@media screen {'; $style .= " body { padding-top: {$navbar_padding}px; }"; $style .= ' #dokuwiki__toc.affix { top: ' . ($navbar_padding - 10) . 'px; position: fixed !important; }'; if (bootstrap3_conf('tocCollapseSubSections')) { $style .= ' #dokuwiki__toc .nav .nav .nav { display: none; }'; } $style .= '}'; $event->data['style'][] = array('type' => 'text/css', '_data' => $style); $js = ''; $js .= "jQuery('body').scrollspy({ target: '#dokuwiki__toc', offset: " . ($navbar_padding + 10) . " });"; if (bootstrap3_conf('tocAffix')) { $js .= 'jQuery("#dokuwiki__toc").affix({ offset: { top: (jQuery("main").position().top), bottom: (jQuery(document).height() - jQuery("main").height()) } });'; } if ($fixed_top_navbar) { $js .= "if (location.hash) { setTimeout(function() { scrollBy(0, -{$navbar_padding}); }, 1); }"; } if (bootstrap3_conf('useAnchorJS')) { $js .= "jQuery(document).trigger('bootstrap3:anchorjs');"; } $event->data['script'][] = array('type' => 'text/javascript', '_data' => "jQuery(document).ready(function() { {$js} });"); } }