DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:drop_me

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
plugin:drop_me [2011-03-08 07:10] 24.85.247.169plugin:drop_me [2016-01-25 17:34] (current) – old revision restored (2015-10-19 15:36) Aleksandr
Line 17: Line 17:
 ==== Syntax ==== ==== Syntax ====
  
-<code> +  <drop arg1/arg2>content</drop> 
-<drop arg1/arg2>content</drop></code> + 
- ^what to create ^name ^ +      ^ what to create  ^ name                
-|arg1 | link | name of menu space| +| arg1  | link            | name of menu space  
-|arg2 | menu | name of menu space|+| arg2  | menu            | name of menu space  |
  
 **example** **example**
  
-<drop link/test>Sysadm</drop> +  <drop link/test>Sysadm</drop> 
-<drop menu/test> +  <drop menu/test> 
-  * Drucker +    * Drucker 
-     * coe +       * coe 
-</drop>+  </drop>
  
  
Line 36: Line 36:
  
 [[plugin:drop_me#source|download source code]] [[plugin:drop_me#source|download source code]]
-save php to lib/plugins/drop_me/syntax.php+save php to lib/plugins/dropMe/syntax.php
  
 open you main template add JavaScript to header open you main template add JavaScript to header
Line 53: Line 53:
 </code> </code>
  
 +My Bootstrap3 theme causing running script twice. This little workaround makes dropdown workable.
 +<code java>
 +    <script TYPE="text/javascript">
 +        var clicked_duplicated = false;
 +        function showhide(name) {
 +            clicked_duplicated = !clicked_duplicated;
 +            var display = document.getElementById(name).style.display;
 +            if (display == 'block' && !clicked_duplicated) {
 +                document.getElementById(name).style.display = 'none';
 +                ;
 +            } else if (display == 'none' && !clicked_duplicated) {
 +                document.getElementById(name).style.display = 'block';
 +            }
 +        }
 +    </script>
 +</code>
 ==== TODO ==== ==== TODO ====
 learn English ;-) learn English ;-)
Line 67: Line 83:
 <code php> <code php>
 <?php <?php
- 
- 
- 
 /** /**
  * Plugin Drop Me (Great dropdown menus (by click))  * Plugin Drop Me (Great dropdown menus (by click))
- + *
  * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)  * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
  * @author     Jan-Philipp Warmers <Progamler@freakz-at-work.de>  * @author     Jan-Philipp Warmers <Progamler@freakz-at-work.de>
Line 79: Line 92:
 // must be run within DokuWiki // must be run within DokuWiki
 if (!defined('DOKU_INC')) if (!defined('DOKU_INC'))
- die();+    die();
  
 if (!defined('DOKU_PLUGIN')) if (!defined('DOKU_PLUGIN'))
- define('DOKU_PLUGIN', DOKU_INC . 'lib/plugins/');+    define('DOKU_PLUGIN', DOKU_INC . 'lib/plugins/');
 require_once (DOKU_PLUGIN . 'syntax.php'); require_once (DOKU_PLUGIN . 'syntax.php');
  
Line 89: Line 102:
  * need to inherit from this class  * need to inherit from this class
  */  */
-class syntax_plugin_drop_me extends DokuWiki_Syntax_Plugin {+class syntax_plugin_dropMe extends DokuWiki_Syntax_Plugin {
  
- /** +    /** 
-  * return some info +     * return some info 
-  */ +     */ 
- function getInfo() { +    function getInfo() { 
- return array ( +        return array ( 
- 'author' => 'Jan-Philipp Warmers', +            'author' => 'Jan-Philipp Warmers', 
- 'email' => 'Progamler@freakz-at-work.de', +            'email' => 'Progamler@freakz-at-work.de', 
- 'date' => '2007-07-04', +            'date' => '2007-07-04', 
- 'name' => 'Drop ME', +            'name' => 'DropME', 
- 'desc' => 'Creat menüs with display and JavaScript', +            'desc' => 'Creat menüs with display and JavaScript', 
- 'url' => '',+            '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'); +
- }+
  
- /** +    function getType() { 
- * Handle the match +        return 'container'
- */ +    } 
- function handle($match, $state, $pos, & $handler) { +    function getAllowedTypes() { 
- global $ende+        return array ( 
- switch ($state) { +            'formatting', 
- case DOKU_LEXER_ENTER : +            'substition', 
- list ($color$background) = preg_split("/\//u"substr($match5, -1), 2); +            'disabled', 
- if ($color = $this->_link($color, $background)) { +            'container' 
- $color = $color+        ); 
- $ende = $this->_ende($color); +    } 
- +    function getSort() { 
- return array +        return 158
- $state, +    } 
- array ( +    function connectTo($mode) { 
- $color, +        $this->Lexer->addEntryPattern('<drop.*?>(?=.*?</drop>)', $mode, 'plugin_dropMe'); 
- $background +    
- +    function postConnect() { 
- );+        $this->Lexer->addExitPattern('</drop>''plugin_dropMe'); 
 +    }
  
- case DOKU_LEXER_UNMATCHED : +    /** 
- return array ( +     * Handle the match 
- $state, +     */ 
- $match +    function handle($match, $state, $pos, & $handler) { 
- ); +        global $ende; 
- case DOKU_LEXER_EXIT +        switch ($state{ 
- return array +            case DOKU_LEXER_ENTER 
- $state+                list ($color, $background) = preg_split("/\//u", substr($match, 5, -1), 2); 
- $ende +                if ($color = $this->_link($color$background)) { 
- ); +                    $color = $color; 
- +                    $ende = $this->_ende($color); 
- return array (); +                
- }+                return array ( 
 +                    $state, 
 +                    array ( 
 +                        $color, 
 +                        $background 
 +                    
 +                );
  
- /** +            case DOKU_LEXER_UNMATCHED : 
-  * Create output +                return array ( 
-  */ +                    $state, 
- function render($mode$renderer, $data{+                    $match 
 +                ); 
 +            case DOKU_LEXER_EXIT : 
 +                return array ( 
 +                    $state, 
 +                    $ende 
 +                )
 +        } 
 +        return array (); 
 +    }
  
- if ($mode == 'xhtml') { +    /** 
- list ($state$match) = $data+     * Create output 
- switch ($state) { +     */ 
- case DOKU_LEXER_ENTER : +    function render($mode, & $renderer, $data) {
- list ($color, $background) = $match; +
- $renderer->doc .= $color;+
  
- break;+        if ($mode == 'xhtml') { 
 +            list ($state, $match) = $data; 
 +            switch ($state) { 
 +                case DOKU_LEXER_ENTER : 
 +                    list ($color, $background) = $match; 
 +                    $renderer->doc .= $color;
  
- case DOKU_LEXER_UNMATCHED : +                    break;
- $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; +                case DOKU_LEXER_UNMATCHED : 
- +                    $renderer->doc .= $renderer->_xmlEntities($match); 
- return true; +                    break; 
- +                case DOKU_LEXER_EXIT : 
- return false; +                    list ($ende) = $match; 
- }+ 
 +                    if ($ende == "a"
 +                        $renderer->doc .= "</a>"; 
 +                    if ($ende == "d"
 +                        $renderer->doc .= "</div>"; 
 + 
 +                    break; 
 +            
 +            return true; 
 +        
 +        return false; 
 +    }
 //creat <drop> //creat <drop>
- function _link($c, $o) { +    function _link($c, $o) { 
- $c = trim($c); +        $c = trim($c); 
- if ($c == "link") { +        if ($c == "link") { 
- return "<a href=javascript:showhide('$o')  onclik=showhide('$o')>"; +            return "<a href=javascript:showhide('$o')  onclick=showhide('$o')>"; 
- +        
- elseif ($c == "menu") { +        elseif ($c == "menu") { 
- return "<div id=\"$o\" style=\"display:none;\">"; +            return "<div id=\"$o\" style=\"display:none;\">"; 
- +        
-+    
- //creat </drop> +    //creat </drop> 
- function _ende($ende) { +    function _ende($ende) { 
- $c = trim($ende); +        $c = trim($ende); 
- $c = substr($c, "1", "1");+        $c = substr($c, "1", "1");
  
- if ($c == "a") {+        if ($c == "a") {
  
- return "a"; +            return "a"; 
- +        
- elseif ($c == "d") {+        elseif ($c == "d") {
  
- return "d"; +            return "d"; 
- +        
- }+    }
 } }
 ?> ?>
 </code> </code>
  --- //[[progamler@freakz-at-work.de|Jan-Philipp Warmers]] 2007-07-05 14:26//  --- //[[progamler@freakz-at-work.de|Jan-Philipp Warmers]] 2007-07-05 14:26//
plugin/drop_me.1299564616.txt.gz · 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 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki