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 = [ ...@@ -205,9 +205,9 @@ AnnotationController = [
# Form the tags for ngTagsInput. # Form the tags for ngTagsInput.
@annotation.tags = ({text} for text in (model.tags or [])) @annotation.tags = ({text} for text in (model.tags or []))
# Calculate the visual diff flag # Calculate the visual diff flags
@annotation.target?.forEach (t) -> @hasDiff = @annotation.target.filter((t) -> t.diffHTML?).length > 0
t.showDiff ?= t.diffHTML? and not t.diffCaseOnly @showDiff ?= @hasDiff && @annotation.target.filter((t) -> t.diffHTML? and not t.diffCaseOnly).length > 0
# Export the baseURI for the share link # Export the baseURI for the share link
this.baseURI = documentHelpers.baseURI this.baseURI = documentHelpers.baseURI
......
...@@ -44,22 +44,22 @@ ...@@ -44,22 +44,22 @@
<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="target.showDiff" ng-hide="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="target.showDiff"></blockquote> ng-show="vm.showDiff"></blockquote>
<div class="small pull-right" </section>
ng-show="target.diffHTML"> <div class="small pull-right"
ng-show="vm.hasDiff">
<input type="checkbox" <input type="checkbox"
ng-model="target.showDiff" ng-model="vm.showDiff"
ng-click="$event.stopPropagation()"> Show differences</input> ng-click="$event.stopPropagation()"> Show differences</input>
</div> </div>
</section>
<!-- / Excerpts -- > <!-- / Excerpts -- >
<!-- Body --> <!-- 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