Commit 91c24588 authored by csillag's avatar csillag

Move showDiff from target level to annotation level.

Calculate the `showDiff` flag for the whole annotation,
instead of on a per-target basis.

Benefits:
 - One less variable stored inside the annotation model
 - We can more easily avoid unwanted overrides of the manually set value.
parent 647d0126
......@@ -205,9 +205,9 @@ AnnotationController = [
# Form the tags for ngTagsInput.
@annotation.tags = ({text} for text in (model.tags or []))
# Calculate the visual diff flag
@annotation.target?.forEach (t) ->
t.showDiff ?= t.diffHTML? and not t.diffCaseOnly
# Calculate the visual diff flags
@hasDiff = @annotation.target.filter((t) -> t.diffHTML?).length > 0
@showDiff ?= @hasDiff && @annotation.target.filter((t) -> t.diffHTML? and not t.diffCaseOnly).length > 0
# Export the baseURI for the share link
this.baseURI = documentHelpers.baseURI
......
......@@ -44,22 +44,22 @@
<section class="annotation-target"
ng-repeat="target in vm.annotation.target track by $index">
<blockquote class="annotation-quote"
ng-hide="target.showDiff"
ng-hide="vm.showDiff"
ng-bind-html="selector.exact"
ng-repeat="selector in target.selector
| filter : {'type': 'TextQuoteSelector'}
track by $index"></blockquote>
<blockquote class="annotation-quote"
ng-bind-html="target.diffHTML"
ng-show="target.showDiff"></blockquote>
<div class="small pull-right"
ng-show="target.diffHTML">
<input type="checkbox"
ng-model="target.showDiff"
ng-click="$event.stopPropagation()"> Show differences</input>
</div>
ng-show="vm.showDiff"></blockquote>
</section>
<div class="small pull-right"
ng-show="vm.hasDiff">
<input type="checkbox"
ng-model="vm.showDiff"
ng-click="$event.stopPropagation()"> Show differences</input>
</div>
<!-- / Excerpts -- >
<!-- Body -->
......
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