Add updateDecorationForMarker()

This commit is contained in:
Ben Ogle
2014-07-01 17:33:51 -07:00
parent 15da69287e
commit 7b19152a58
2 changed files with 20 additions and 0 deletions

View File

@@ -795,6 +795,21 @@ class DisplayBuffer extends Model
@decorationsByMarkerId[marker.id].push(decoration)
@emit 'decoration-added', marker, decoration
updateDecorationForMarker: (marker, decorationPattern, newDecoration) ->
unless marker?
console.warn 'A null marker cannot be decorated'
return
marker = @getMarker(marker.id)
return unless decorations = @decorationsByMarkerId[marker.id]
for decoration, i in decorations
if @decorationMatchesPattern(decoration, decorationPattern) and not _.isEqual(decoration, newDecoration)
decorations[i] = newDecoration
@emit 'decoration-updated', marker, decoration, newDecoration
return
removeDecorationForMarker: (marker, decorationPattern) ->
unless marker?
console.warn 'A decoration cannot be removed from a null marker'