diff options
author | Andreas Gohr <andi@splitbrain.org> | 2013-08-09 23:55:39 +0200 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2013-08-09 23:55:39 +0200 |
commit | 72dda0b4378651b271f5fb516fb8e21a80ac3ebf (patch) | |
tree | 051174bdce5b4b228ae2676fcb585edccf04efbf | |
parent | 75e063084d865a011e074c29c5edb8569fe2cfe1 (diff) | |
download | rpg-72dda0b4378651b271f5fb516fb8e21a80ac3ebf.tar.gz rpg-72dda0b4378651b271f5fb516fb8e21a80ac3ebf.tar.bz2 |
added AJAX detail infos
-rw-r--r-- | lib/plugins/extension/action.php | 51 | ||||
-rw-r--r-- | lib/plugins/extension/helper/list.php | 5 | ||||
-rw-r--r-- | lib/plugins/extension/script.js | 29 |
3 files changed, 82 insertions, 3 deletions
diff --git a/lib/plugins/extension/action.php b/lib/plugins/extension/action.php new file mode 100644 index 000000000..b35c1cb13 --- /dev/null +++ b/lib/plugins/extension/action.php @@ -0,0 +1,51 @@ +<?php +/** DokuWiki Plugin extension (Action Component) + * + * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html + * @author Andreas Gohr <andi@splitbrain.org> + */ + +// must be run within Dokuwiki +if(!defined('DOKU_INC')) die(); + +class action_plugin_extension extends DokuWiki_Action_Plugin { + + /** + * Registers a callback function for a given event + * + * @param Doku_Event_Handler $controller DokuWiki's event controller object + * @return void + */ + public function register(Doku_Event_Handler &$controller) { + + $controller->register_hook('AJAX_CALL_UNKNOWN', 'BEFORE', $this, 'info'); + + } + + public function info(Doku_Event &$event, $param){ + global $INPUT; + if($event->data != 'plugin_extension') return; + $event->preventDefault(); + $event->stopPropagation(); + + header('Content-Type: text/html; charset=utf-8'); + + $ext = $INPUT->str('ext'); + if(!$ext) { + echo 'no extension given'; + return; + } + + /** @var helper_plugin_extension_extension $extension */ + $extension = plugin_load('helper', 'extension_extension'); + $extension->setExtension($ext); + + /** @var helper_plugin_extension_list $list */ + $list = plugin_load('helper', 'extension_list'); + + + echo $list->make_info($extension); + } + +} + diff --git a/lib/plugins/extension/helper/list.php b/lib/plugins/extension/helper/list.php index 767a8ed40..6b1d41f78 100644 --- a/lib/plugins/extension/helper/list.php +++ b/lib/plugins/extension/helper/list.php @@ -224,11 +224,12 @@ class helper_plugin_extension_list extends DokuWiki_Plugin { if($showinfo){ $url = $this->gui->tabURL(''); - $return .= '<a href="'.$url.'#extensionplugin__'.$extension->getID().'" class="info close">'.$this->getLang('btn_info').'</a>'; + $class = 'close'; }else{ $url = $this->gui->tabURL('', array('info' => $extension->getID())); - $return .= '<a href="'.$url.'#extensionplugin__'.$extension->getID().'" class="info">'.$this->getLang('btn_info').'</a>'; + $class = ''; } + $return .= '<a href="'.$url.'#extensionplugin__'.$extension->getID().'" class="info '.$class.'" data-extid="'.$extension->getID().'">'.$this->getLang('btn_info').'</a>'; if ($showinfo) { $return .= $this->make_info($extension); diff --git a/lib/plugins/extension/script.js b/lib/plugins/extension/script.js index f2a6aae50..7480801ac 100644 --- a/lib/plugins/extension/script.js +++ b/lib/plugins/extension/script.js @@ -5,7 +5,7 @@ jQuery(function(){ * very simple lightbox * @link http://webdesign.tutsplus.com/tutorials/htmlcss-tutorials/super-simple-lightbox-with-css-and-jquery/ */ - jQuery('a.extension_screenshot').click(function(e) { + jQuery('#extension__manager a.extension_screenshot').click(function(e) { e.preventDefault(); //Get clicked link href @@ -31,4 +31,31 @@ jQuery(function(){ return false; }); + /** + * AJAX detail infos + */ + jQuery('#extension__manager a.info').click(function(e){ + e.preventDefault(); + + var $link = jQuery(this); + var $details = $link.parent().find('dl.details'); + if($details.length){ + $link.toggleClass('close'); + $details.toggle(); + return; + } + + $link.addClass('close'); + jQuery.get( + DOKU_BASE + 'lib/exe/ajax.php', + { + call: 'plugin_extension', + ext: $link.data('extid') + }, + function(data){ + $link.parent().append(data); + } + ); + }); + });
\ No newline at end of file |