Commit ea98c24e authored by Randall Leeds's avatar Randall Leeds

improve fix for #788

This frees us up to remove the other mouse events, which makes this
a bit cleaner to my eyes. It also avoids passing the selection
through the scope, storing no state between events.
parent ffdf6eda
......@@ -213,20 +213,21 @@ tabReveal = ['$parse', ($parse) ->
]
thread = ->
thread = ['$window', ($window) ->
# Helper -- true if selection ends inside the target and is non-empty
ignoreClick = (event) ->
sel = $window.getSelection()
if sel.focusNode?.compareDocumentPosition(event.target) & 8
if sel.toString().length
return true
return false
link: (scope, elem, attr, ctrl) ->
childrenEditing = {}
sel = window.getSelection()
scope.toggleCollapsedDown = (event) ->
event.stopPropagation()
scope.oldSelection = sel.toString()
scope.toggleCollapsed = (event) ->
event.stopPropagation()
# If we have selected something, then don't bother
return unless sel.toString() is scope.oldSelection
return unless Object.keys(childrenEditing).length is 0
return if (ignoreClick event) or Object.keys(childrenEditing).length
scope.collapsed = !scope.collapsed
scope.openDetails scope.annotation unless scope.collapsed
......@@ -251,6 +252,8 @@ thread = ->
else
delete childrenEditing[$id]
restrict: 'C'
]
userPicker = ->
restrict: 'ACE'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment