WIP: Tree view spec isn't there yet

This commit is contained in:
Nathan Sobo
2012-04-26 09:32:49 -06:00
parent 5c057e11b1
commit 5156a37471
4 changed files with 21 additions and 7 deletions

View File

@@ -28,24 +28,28 @@ module.exports =
[eventName, namespace] = eventName.split('.')
eventName = undefined if eventName is ''
subscriptionCountBefore = @subscriptionCount()
if namespace
if eventName
handlers = @eventHandlersByNamespace?[namespace]?[eventName] ? []
for handler in new Array(handlers...)
_.remove(handlers, handler)
@off eventName, handler
return
else
for eventName, handlers of @eventHandlersByNamespace?[namespace] ? {}
for handler in new Array(handlers...)
_.remove(handlers, handler)
@off eventName, handler
return
else
if handler
_.remove(@eventHandlersByEventName[eventName], handler)
else
delete @eventHandlersByEventName?[eventName]
@afterUnsubscribe?()
@afterUnsubscribe?() if @subscriptionCount() < subscriptionCountBefore
subscriptionCount: ->
count = 0

View File

@@ -1,6 +1,7 @@
{View, $$} = require 'space-pen'
Directory = require 'directory'
$ = require 'jquery'
_ = require 'underscore'
module.exports =
class TreeView extends View
@@ -85,7 +86,12 @@ class DirectoryView extends View
initialize: ({@directory, isExpanded}) ->
@expand() if isExpanded
@disclosureArrow.on 'click', => @toggleExpansion()
@on 'DOMNodeRemoved', (e) => @unwatchEntries() if e.target == this[0]
_.defer =>
@on 'DOMNodeRemoved', (e) =>
if e.target == this[0] and @hasClass('expanded')
console.log "unwatching!"
@unwatchEntries()
buildEntries: ->
@entries?.remove()