Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions scripts/mixins/tree.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ define ['backbone'], (Backbone) ->
# Perform a Breadth First Search, returning the first element that matches
findDescendantBFS: (compare) ->
#Check children first and then descendants
return @getChildren().find(compare) or @getChildren().find (node) -> node.findDescendantBFS(compare)
return @getChildren().find(compare) or @getChildren().find (node) -> node.findDescendantBFS?(compare)

# Perform a Depth First Search, returning the first element that matches
findDescendantDFS: (compare) ->
Expand All @@ -78,7 +78,7 @@ define ['backbone'], (Backbone) ->
# because `.find` returns the element, not what was returned to find
@getChildren().each (node) ->
return if ret # if something is found, stop searching
found = node.findDescendantDFS(compare)
found = node.findDescendantDFS?(compare)
ret = found
return ret

Expand Down
2 changes: 1 addition & 1 deletion scripts/views/layouts/workspace/sidebar.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ define [

onShow: () ->
model = @model
collection = @collection or model.getChildren()
collection = @collection or model.getChildren?()

if model
# This is a tree sidebar
Expand Down
8 changes: 4 additions & 4 deletions scripts/views/workspace/sidebar/toc-branch.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ define [

# if the user hasn't set the state yet make sure the active file is visible
if @model.expanded == undefined
hasDescendant = @model.findDescendantBFS (child) ->
hasDescendant = @model.findDescendantBFS? (child) ->
# Dereference if the child is a pointer-node
child = child.dereferencePointer?() or child
return child.get('_selected')
Expand Down Expand Up @@ -177,7 +177,7 @@ define [

return {
isPicker: @options.isPicker
childIsSelected: @model.findDescendantBFS (child) -> (child.dereferencePointer?() or child).get('_selected')
childIsSelected: @model.findDescendantBFS? (child) -> (child.dereferencePointer?() or child).get('_selected')
selected: model.get('_selected')
ancestorSelected: @options.ancestorSelected
mediaType: model.mediaType
Expand Down Expand Up @@ -219,9 +219,9 @@ define [
model = @model
if not model.getRoot?()
# Find the 1st leaf node (editable model)
model = model.findDescendantDFS (model) -> return model.getChildren().isEmpty()
model = model.findDescendantDFS? (model) -> return model.getChildren().isEmpty()

controller.goEdit(model, model.getRoot())
controller.goEdit(model, model.getRoot?())


editSettings: ->
Expand Down