diff options
author | Kate Arzamastseva <pshns@ukr.net> | 2011-07-15 00:16:07 +0300 |
---|---|---|
committer | Kate Arzamastseva <pshns@ukr.net> | 2011-07-15 00:16:07 +0300 |
commit | 3dd4a911f6492d9dce2b58bcd44c917489f50301 (patch) | |
tree | 3bae66359cf2957253740e1dac6fae74b0e3cd15 | |
parent | c439558b00bf5429e11461bc999b63a22f066ac1 (diff) | |
parent | 1e542e417725bb148253929fac9146832d978e45 (diff) | |
download | rpg-3dd4a911f6492d9dce2b58bcd44c917489f50301.tar.gz rpg-3dd4a911f6492d9dce2b58bcd44c917489f50301.tar.bz2 |
Merge branch 'master' of git://github.com/splitbrain/dokuwiki into media-revisions
-rw-r--r-- | inc/html.php | 16 | ||||
-rw-r--r-- | inc/media.php | 9 | ||||
-rw-r--r-- | lib/exe/ajax.php | 18 | ||||
-rw-r--r-- | lib/plugins/acl/admin.php | 11 | ||||
-rw-r--r-- | lib/plugins/acl/ajax.php | 11 | ||||
-rw-r--r-- | lib/plugins/plugin/classes/ap_download.class.php | 2 | ||||
-rw-r--r-- | lib/scripts/media.js | 9 | ||||
-rw-r--r-- | lib/scripts/tree.js | 28 |
8 files changed, 47 insertions, 57 deletions
diff --git a/inc/html.php b/inc/html.php index df28a2096..b4cf27d61 100644 --- a/inc/html.php +++ b/inc/html.php @@ -807,7 +807,7 @@ function html_list_index($item){ /** * Index List item * - * This user function is used in html_build_lidt to build the + * This user function is used in html_buildlist to build the * <li> tags for namespaces when displaying the page index * it gives different classes to opened or closed "folders" * @@ -848,10 +848,20 @@ function html_li_default($item){ * @author Andreas Gohr <andi@splitbrain.org> */ function html_buildlist($data,$class,$func,$lifunc='html_li_default'){ - $level = 0; + if (count($data) === 0) { + return ''; + } + + $level = $data[0]['level']; $opens = 0; $ret = ''; + if ($level < 2) { + // Trigger building a wrapper ul if the first level is + // 0 (we have a root object) or 1 (just the root content) + --$level; + } + foreach ($data as $item){ if( $item['level'] > $level ){ @@ -867,7 +877,7 @@ function html_buildlist($data,$class,$func,$lifunc='html_li_default'){ //close higher lists $ret .= "</ul>\n</li>\n"; } - }else{ + } elseif ($ret !== '') { //close last item $ret .= "</li>\n"; } diff --git a/inc/media.php b/inc/media.php index b4a0ad114..138eb26c2 100644 --- a/inc/media.php +++ b/inc/media.php @@ -1439,15 +1439,10 @@ function media_nstree($ns){ search($data,$conf['mediadir'],'search_index',array('ns' => $ns, 'nofiles' => true)); // wrap a list with the root level around the other namespaces - $item = array( 'level' => 0, 'id' => '', - 'open' =>'true', 'label' => '['.$lang['mediaroot'].']'); + array_unshift($data, array('level' => 0, 'id' => '', 'open' =>'true', + 'label' => '['.$lang['mediaroot'].']')); - echo '<ul class="idx">'; - echo media_nstree_li($item); - echo media_nstree_item($item); echo html_buildlist($data,'idx','media_nstree_item','media_nstree_li'); - echo '</li>'; - echo '</ul>'; } /** diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php index 59953ddc3..483d65cff 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -192,12 +192,10 @@ function ajax_medians(){ $data = array(); search($data,$conf['mediadir'],'search_index',array('nofiles' => true),$dir); - foreach($data as $item){ - $item['level'] = $lvl+1; - echo media_nstree_li($item); - echo media_nstree_item($item); - echo '</li>'; + foreach(array_keys($data) as $item){ + $data[$item]['level'] = $lvl+1; } + echo html_buildlist($data, 'idx', 'media_nstree_item', 'media_nstree_li'); } /** @@ -253,14 +251,10 @@ function ajax_index(){ $data = array(); search($data,$conf['datadir'],'search_index',array('ns' => $ns),$dir); - foreach($data as $item){ - $item['level'] = $lvl+1; - echo html_li_index($item); - echo '<div class="li">'; - echo html_list_index($item); - echo '</div>'; - echo '</li>'; + foreach(array_keys($data) as $item){ + $data[$item]['level'] = $lvl+1; } + echo html_buildlist($data, 'idx', 'html_list_index', 'html_li_index'); } /** diff --git a/lib/plugins/acl/admin.php b/lib/plugins/acl/admin.php index ea4184ca3..7c12b3374 100644 --- a/lib/plugins/acl/admin.php +++ b/lib/plugins/acl/admin.php @@ -253,19 +253,12 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin { $data = $this->_get_tree($ns); // wrap a list with the root level around the other namespaces - $item = array( 'level' => 0, 'id' => '*', 'type' => 'd', - 'open' =>'true', 'label' => '['.$lang['mediaroot'].']'); + array_unshift($data, array( 'level' => 0, 'id' => '*', 'type' => 'd', + 'open' =>'true', 'label' => '['.$lang['mediaroot'].']')); - echo '<ul class="acltree">'; - echo $this->_html_li_acl($item); - echo '<div class="li">'; - echo $this->_html_list_acl($item); - echo '</div>'; echo html_buildlist($data,'acl', array($this,'_html_list_acl'), array($this,'_html_li_acl')); - echo '</li>'; - echo '</ul>'; } diff --git a/lib/plugins/acl/ajax.php b/lib/plugins/acl/ajax.php index d91586a5d..d704fa8c9 100644 --- a/lib/plugins/acl/ajax.php +++ b/lib/plugins/acl/ajax.php @@ -44,13 +44,10 @@ if($ajax == 'info'){ $data = $acl->_get_tree($ns,$ns); - foreach($data as $item){ - $item['level'] = $lvl+1; - echo $acl->_html_li_acl($item); - echo '<div class="li">'; - echo $acl->_html_list_acl($item); - echo '</div>'; - echo '</li>'; + foreach(array_keys($data) as $item){ + $data[$item]['level'] = $lvl+1; } + echo html_buildlist($data, 'acl', array($acl, '_html_list_acl'), + array($acl, '_html_li_acl')); } diff --git a/lib/plugins/plugin/classes/ap_download.class.php b/lib/plugins/plugin/classes/ap_download.class.php index e3afd142a..6aab4ba3c 100644 --- a/lib/plugins/plugin/classes/ap_download.class.php +++ b/lib/plugins/plugin/classes/ap_download.class.php @@ -114,7 +114,7 @@ class ap_download extends ap_manage { if ($tmp) $this->dir_delete($tmp); if (!$this->manager->error) { - msg(sprintf($this->lang['packageinstalled'], count($this->downloaded), (count($this->downloaded) != 1?'s':''), join(',',$this->downloaded)),1); + msg(sprintf($this->lang['packageinstalled'], count($this->downloaded), join(',',$this->downloaded)),1); $this->refresh(); return true; } diff --git a/lib/scripts/media.js b/lib/scripts/media.js index 62cc1e7bb..777eb4825 100644 --- a/lib/scripts/media.js +++ b/lib/scripts/media.js @@ -43,7 +43,7 @@ var dw_mediamanager = { $tree.dw_tree({toggle_selector: 'img', load_data: function (show_sublist, $clicky) { // get the enclosed link (is always the first one) - var $link = $clicky.siblings('a').first(); + var $link = $clicky.parent().find('div.li a.idx_dir'); jQuery.post( DOKU_BASE + 'lib/exe/ajax.php', @@ -51,13 +51,12 @@ var dw_mediamanager = { show_sublist, 'html' ); - - $clicky.attr('src', DOKU_BASE + 'lib/images/minus.gif'); }, - close: function ($clicky) { + toggle_display: function ($clicky, opening) { $clicky.attr('src', - DOKU_BASE + 'lib/images/plus.gif'); + DOKU_BASE + 'lib/images/' + + (opening ? 'minus' : 'plus') + '.gif'); }}); $tree.delegate('a', 'click', dw_mediamanager.list); diff --git a/lib/scripts/tree.js b/lib/scripts/tree.js index 46b0f6695..98d3f55d4 100644 --- a/lib/scripts/tree.js +++ b/lib/scripts/tree.js @@ -29,33 +29,34 @@ jQuery.fn.dw_tree = function(overrides) { * @author Pierre Spring <pierre.spring@caillou.ch> */ toggle: function (e) { - var $listitem, $sublist, timeout, $clicky, show_sublist, dw_tree; + var $listitem, $sublist, timeout, $clicky, show_sublist, dw_tree, opening; e.preventDefault(); + dw_tree = e.data; $clicky = jQuery(this); $listitem = $clicky.closest('li'); $sublist = $listitem.find('ul').first(); - dw_tree = e.data; + opening = $listitem.hasClass('closed'); + $listitem.toggleClass('open closed'); + dw_tree.toggle_display($clicky, opening); // if already open, close by hiding the sublist - if ($listitem.hasClass('open')) { - $sublist.dw_hide(function () { - dw_tree.close($clicky); - $listitem.addClass('closed').removeClass('open'); - }); + if (!opening) { + $sublist.dw_hide(); return; } show_sublist = function (data) { - if (!$listitem.hasClass('open') || $sublist.parent().length === 0) { - $listitem.append($sublist).addClass('open').removeClass('closed'); - } $sublist.hide(); - if (data) { + if (typeof data !== 'undefined') { $sublist.html(data); } - $sublist.dw_show(); + if ($listitem.hasClass('open')) { + // Only show if user didn’t close the list since starting + // to load the content + $sublist.dw_show(); + } }; // just show if already loaded @@ -66,6 +67,7 @@ jQuery.fn.dw_tree = function(overrides) { //prepare the new ul $sublist = jQuery('<ul class="idx"/>'); + $listitem.append($sublist); timeout = window.setTimeout( bind(show_sublist, '<li><img src="' + DOKU_BASE + 'lib/images/throbber.gif" alt="loading..." title="loading..." /></li>'), dw_tree.throbber_delay); @@ -76,7 +78,7 @@ jQuery.fn.dw_tree = function(overrides) { }, $clicky); }, - close: function ($clicky) { + toggle_display: function ($clicky, opening) { }, load_data: function (show_data, $clicky) { |