DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:jsreplacements

JS replacements Plugin

Compatible with DokuWiki

  • 2018-04-22 "Greebo" yes
  • 2017-02-19 "Frusterick Manners" unknown
  • 2016-06-26 "Elenor Of Tsort" unknown
  • 2015-08-10 "Detritus" unknown

plugin Extends JSINFO with 'replacements' for usage in JS scripts

Last updated on
2020-05-10
Provides
Action
Repository
Source

Tagged with javascript, jquery

Installation

Install the plugin using the Plugin Manager and the download URL above, which points to latest version of the plugin. Refer to Plugins on how to install plugins manually.

Usage

This plugins exposes the replacements through the JavaScript JSINFO environment variable.

Examples/Usage

Adaptive Site width when sidebar is present

Some templates with support for sidebar shrink the content width when the sidebar is present. With given the html structure they have, the only way to provide a pure css solution would be to have the relational pseudo class :has (level 4 css), provided that you can select the dokuwiki site when the sidebar is present.

However, :has is still not supported by any major browser, and only jQuery provides the required support. In other words, to solve this you need to use javascript by for example using the conf/userscript.js file.

This example ensures that your content will keep the width when you include sidebar to templates in the family of the starter template, specially the dokuwiki template, which provides the __site_width__ and the __sidebar_width__ placeholder variables.

conf/userscript.js
(function (window, document, undefined) {
  jQuery(document).ready(function() {  
    $sidebar     = jQuery("#dokuwiki__aside");
    $site        = jQuery("#dokuwiki__site");
    replacements = JSINFO.replacements;
    var site_width, sidebar_width;
 
    if ($sidebar.length && $site.length && replacements) {
      site_width    = replacements.__site_width__    || ($site.css('max-width') + "px");
      sidebar_width = replacements.__sidebar_width__ || ($sidebar.css('max-width') + "px");
 
      if (site_width && sidebar_width) {
        //console.log("adapting site max-width to", site_width + ' + ' + sidebar_width, "from", $site.css('max-width'));
        $site.css({'max-width': 'calc(' + site_width + ' + ' + sidebar_width + ')'});
        //console.log("new site max-width", $site.css('max-width'), $site);
      }
    }
 
  });
})(window, document);

Development

Change Log

Known Bugs and Issues

Please report bugs or feature requests at the Bug tracker.

ToDo/Wish List

  • add admin configuration to expose other configuration settings
plugin/jsreplacements.txt · Last modified: 2020-05-10 03:46 by rellampec