DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:drop_me

This is an old revision of the document!


Drop Me Plugin

Compatible with DokuWiki

No compatibility info given!

plugin Creates drop down menu's by using CSS and JavaScript

Last updated on
2007-07-05
Provides
Syntax
Conflicts with
drop_all

The missing download url means that this extension cannot be installed via the Extension Manager. Please see Publishing a Plugin on dokuwiki.org. Recommended are public repository hosts like GitHub, GitLab or Bitbucket.

This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.

Extension name contains underscore, will not generate popularity points.

Tagged with javascript, menu, navigation

Syntax

<drop arg1/arg2>content</drop>
what to create name
arg1 link name of menu space
arg2 menu name of menu space

example

<drop link/test>Sysadm</drop> <drop menu/test>

  • Drucker
    • coe

</drop>

How to install

download source code save php to lib/plugins/drop_me/syntax.php

open you main template add JavaScript to header

<script TYPE="text/javascript">
function showhide(name) {
         var display = document.getElementById(name).style.display;
 	if (display == 'block') {
  	document.getElementById(name).style.display='none';
     }else{
        document.getElementById(name).style.display='block';
       }
	}
</script>

TODO

learn English ;-)

changelog

0.1 alpha

  • released

source

<?php
 
 
 
/**
 * Plugin Drop Me (Great dropdown menus (by click))
 * 
 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
 * @author     Jan-Philipp Warmers <Progamler@freakz-at-work.de>
 */
 
// must be run within DokuWiki
if (!defined('DOKU_INC'))
	die();
 
if (!defined('DOKU_PLUGIN'))
	define('DOKU_PLUGIN', DOKU_INC . 'lib/plugins/');
require_once (DOKU_PLUGIN . 'syntax.php');
 
/**
 * All DokuWiki plugins to extend the parser/rendering mechanism
 * need to inherit from this class
 */
class syntax_plugin_drop_me extends DokuWiki_Syntax_Plugin {
 
	/**
	 * return some info
	 */
	function getInfo() {
		return array (
			'author' => 'Jan-Philipp Warmers',
			'email' => 'Progamler@freakz-at-work.de',
			'date' => '2007-07-04',
			'name' => 'Drop ME',
			'desc' => 'Creat menüs with display and JavaScript',
			'url' => '',
 
 
		);
	}
 
	function getType() {
		return 'container';
	}
	function getAllowedTypes() {
		return array (
			'formatting',
			'substition',
			'disabled',
			'container'
		);
	}
	function getSort() {
		return 158;
	}
	function connectTo($mode) {
		$this->Lexer->addEntryPattern('<drop.*?>(?=.*?</drop>)', $mode, 'plugin_drop_me');
	}
	function postConnect() {
		$this->Lexer->addExitPattern('</drop>', 'plugin_drop_me');
	}
 
	/**
	 * Handle the match
	 */
	function handle($match, $state, $pos, & $handler) {
		global $ende;
		switch ($state) {
			case DOKU_LEXER_ENTER :
				list ($color, $background) = preg_split("/\//u", substr($match, 5, -1), 2);
				if ($color = $this->_link($color, $background)) {
					$color = $color;
					$ende = $this->_ende($color);
				}
				return array (
					$state,
					array (
						$color,
						$background
					)
				);
 
			case DOKU_LEXER_UNMATCHED :
				return array (
					$state,
					$match
				);
			case DOKU_LEXER_EXIT :
				return array (
					$state,
					$ende
				);
		}
		return array ();
	}
 
	/**
	 * Create output
	 */
	function render($mode, & $renderer, $data) {
 
		if ($mode == 'xhtml') {
			list ($state, $match) = $data;
			switch ($state) {
				case DOKU_LEXER_ENTER :
					list ($color, $background) = $match;
					$renderer->doc .= $color;
 
					break;
 
				case DOKU_LEXER_UNMATCHED :
					$renderer->doc .= $renderer->_xmlEntities($match);
					break;
				case DOKU_LEXER_EXIT :
					list ($ende) = $match;
 
					if ($ende == "a")
						$renderer->doc .= "</a>";
					if ($ende == "d")
						$renderer->doc .= "</div>";
 
					break;
			}
			return true;
		}
		return false;
	}
//creat <drop>
	function _link($c, $o) {
		$c = trim($c);
		if ($c == "link") {
			return "<a href=javascript:showhide('$o')  onclik=showhide('$o')>";
		}
		elseif ($c == "menu") {
			return "<div id=\"$o\" style=\"display:none;\">";
		}
	}
	//creat </drop>
	function _ende($ende) {
		$c = trim($ende);
		$c = substr($c, "1", "1");
 
		if ($c == "a") {
 
			return "a";
		}
		elseif ($c == "d") {
 
			return "d";
		}
	}
}
?>

Jan-Philipp Warmers 2007-07-05 14:26

plugin/drop_me.1299491462.txt.gz · Last modified: 2011-03-07 10:51 by nanite

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki