Skip to content

Instantly share code, notes, and snippets.

@BlairDuncan
Created June 12, 2010 18:51
Show Gist options
  • Save BlairDuncan/435973 to your computer and use it in GitHub Desktop.
Save BlairDuncan/435973 to your computer and use it in GitHub Desktop.
- (void)collapseItem:(id)anItem
{
if (!anItem)
return;
var itemInfo = _itemInfosForItems[[anItem UID]];
if (!itemInfo)
return;
if (!itemInfo.isExpanded)
return;
[self _noteItemWillCollapse:anItem];
itemInfo.isExpanded = NO;
[self reloadItem:anItem reloadChildren:YES]; // this line and the next have been exchanged
[self _noteItemDidCollapse:anItem];
}
- (void)expandItem:(id)anItem expandChildren:(BOOL)shouldExpandChildren
{
var itemInfo = null;
if (!anItem)
itemInfo = _rootItemInfo;
else
itemInfo = _itemInfosForItems[[anItem UID]];
if (!itemInfo)
return;
// to prevent items which are already expanded from firing notifications
if (!itemInfo.isExpanded)
{
[self _noteItemWillExpand:anItem];
itemInfo.isExpanded = YES;
[self reloadItem:anItem reloadChildren:YES]; // this line and the next have been exchanged
[self _noteItemDidExpand:anItem];
}
if (shouldExpandChildren)
{
var children = itemInfo.children,
childIndex = children.length;
while (childIndex--)
[self expandItem:children[childIndex] expandChildren:YES];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment