Skip to content

Commit ea5a63e

Browse files
committed
fixed height calculation
1 parent 07d030c commit ea5a63e

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

jquery.nestedlist.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jquery.nestedlist.src.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jQuery.fn.nestedList = function(config) {
5656
// height of <li> elements
5757
var li = child.filter("li")
5858
var nextHeight = 0
59-
for(i=0; i<li.length; i+=1) { nextHeight += li.outerHeight() }
59+
for(var i=0; i<li.length; i+=1) { nextHeight += li.eq(i).outerHeight() }
6060

6161
// animate problems in FF - container shown empty\white while animating, IE - container is empty\white and never shows again
6262
// container.animate({ height: nextHeight }, { duration: 500 })
@@ -66,10 +66,12 @@ jQuery.fn.nestedList = function(config) {
6666
return li
6767
}
6868

69-
// the upButton is one container that is moved around and inserted into an <li> when and where it is needed
69+
// the upButton is one container that by default is moved around and inserted into the active <li> where needed, but if the upButtonSelector and upButtonShow options are specified,
70+
// then the upButton can be anywhere stationary
7071
var upButton
7172
if(config && config.upButtonSelector) {
72-
upButton = (typeof upButton == "string") ? $(config.upButtonSelector) : config.upButtonSelector
73+
upButton = (typeof config.upButtonSelector == "string") ? container.nextAll(config.upButtonSelector) : config.upButtonSelector
74+
upButton.hide()
7375
}
7476
else {
7577
upButton = container.nextAll(".nestedlist-up")
@@ -142,6 +144,7 @@ jQuery.fn.nestedList = function(config) {
142144
activeItem.siblings().show()
143145
if(nextList.hasClass(toplevelClass)) {
144146
setActive(false)
147+
upButton.hide()
145148
} else {
146149
config.upButtonShow(upButton, nextList)
147150
setActive(nextList.parent("li"))
@@ -168,7 +171,7 @@ jQuery.fn.nestedList = function(config) {
168171
function listItemClick(event) {
169172
var li = $(this)
170173
// prevent repeated clicks on the same list item or leaf item. leaf items are handled by another function
171-
if(container.is(":animated")) return false
174+
if(li.hasClass("active") || container.is(":animated")) return false
172175
openList(li)
173176
// important because containers with this click event handler may be nested -
174177
// the event would bubble up and would be created multiple times

0 commit comments

Comments
 (0)