Commit 8a500a03 authored by Randall Leeds's avatar Randall Leeds

Track diff per-target and set/unset showDiff

parent fbd715dd
...@@ -45,6 +45,8 @@ AnnotationController = [ ...@@ -45,6 +45,8 @@ AnnotationController = [
@preview = 'no' @preview = 'no'
@editing = false @editing = false
@embedded = false @embedded = false
@hasDiff = false
@showDiff = undefined
highlight = annotator.tool is 'highlight' highlight = annotator.tool is 'highlight'
model = $scope.annotationGet() model = $scope.annotationGet()
...@@ -206,8 +208,10 @@ AnnotationController = [ ...@@ -206,8 +208,10 @@ AnnotationController = [
@annotation.tags = ({text} for text in (model.tags or [])) @annotation.tags = ({text} for text in (model.tags or []))
# Calculate the visual diff flags # Calculate the visual diff flags
@hasDiff = @annotation.target.filter((t) -> t.diffHTML?).length > 0 @hasDiff = false
@showDiff ?= @hasDiff && @annotation.target.filter((t) -> t.diffHTML? and not t.diffCaseOnly).length > 0 for t in @annotation.target or [] when t.diffHTML? and not t.diffCaseOnly
@hasDiff = t.hasDiff = true
@showDiff ?= @hasDiff or undefined
# Export the baseURI for the share link # Export the baseURI for the share link
this.baseURI = documentHelpers.baseURI this.baseURI = documentHelpers.baseURI
......
...@@ -44,14 +44,14 @@ ...@@ -44,14 +44,14 @@
<section class="annotation-target" <section class="annotation-target"
ng-repeat="target in vm.annotation.target track by $index"> ng-repeat="target in vm.annotation.target track by $index">
<blockquote class="annotation-quote" <blockquote class="annotation-quote"
ng-hide="vm.showDiff" ng-hide="target.hasDiff && vm.showDiff"
ng-bind-html="selector.exact" ng-bind-html="selector.exact"
ng-repeat="selector in target.selector ng-repeat="selector in target.selector
| filter : {'type': 'TextQuoteSelector'} | filter : {'type': 'TextQuoteSelector'}
track by $index"></blockquote> track by $index"></blockquote>
<blockquote class="annotation-quote" <blockquote class="annotation-quote"
ng-bind-html="target.diffHTML" ng-bind-html="target.diffHTML"
ng-show="vm.showDiff"></blockquote> ng-show="target.hasDiff && vm.showDiff"></blockquote>
</section> </section>
<div class="small pull-right" <div class="small pull-right"
ng-show="vm.hasDiff"> ng-show="vm.hasDiff">
......
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