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

Plugin name contains underscore, will not generate popularity points.

Tagged with collapsible, 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.txt · Last modified: 2011/03/08 07:10 by 24.85.247.169
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 3.0 Unported
Imprint Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki
WikiForumIRCBugsGitXRefTranslate