summaryrefslogtreecommitdiff
path: root/lib/scripts/tree.js
diff options
context:
space:
mode:
authorAdrian Lang <mail@adrianlang.de>2011-07-11 22:17:27 +0200
committerAdrian Lang <mail@adrianlang.de>2011-07-11 23:03:28 +0200
commita1dee2b998bc3dc8436bb076435d405ec412e054 (patch)
treed1c7609b4085ac6f2be349b1a478f939eea8771a /lib/scripts/tree.js
parent2d57e114e1b33b0965a48b2838ec5dd38888c3b6 (diff)
downloadrpg-a1dee2b998bc3dc8436bb076435d405ec412e054.tar.gz
rpg-a1dee2b998bc3dc8436bb076435d405ec412e054.tar.bz2
Fix some bugs and glitches in (mediamanager) tree
* Fix selector in subtree loading callback * Remove HTML inconsistencies between AJAX and plain PHP lists * Unify icon and CSS class switching in dw_tree and dw_mediamanager
Diffstat (limited to 'lib/scripts/tree.js')
-rw-r--r--lib/scripts/tree.js28
1 files changed, 15 insertions, 13 deletions
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) {