Commit 680d2579 authored by Nick Stenning's avatar Nick Stenning

Remove the remnants of a once-functional visual diff feature

Once upon a time, we could show a diff between what the annotation has
anchored to in the page and the original selected text. That feature has
been non-functional since at least 4f60030.
parent 746bb843
...@@ -57,8 +57,6 @@ AnnotationController = [ ...@@ -57,8 +57,6 @@ AnnotationController = [
@preview = 'no' @preview = 'no'
@editing = false @editing = false
@isSidebar = false @isSidebar = false
@hasDiff = false
@showDiff = undefined
@timestamp = null @timestamp = null
model = $scope.annotationGet() model = $scope.annotationGet()
...@@ -223,19 +221,6 @@ AnnotationController = [ ...@@ -223,19 +221,6 @@ AnnotationController = [
this.render() this.render()
this.view() this.view()
# Calculates the visual diff flags from the targets
#
# hasDiff is set to true is there are any targets with a difference
# shouldShowDiff is set to true if there are some meaningful differences
# - that is, more than just uppercase / lowercase
diffFromTargets = (targets = []) ->
hasDiff = targets.some (t) ->
t.diffHTML?
shouldShowDiff = hasDiff and targets.some (t) ->
t.diffHTML? and not t.diffCaseOnly
{hasDiff, shouldShowDiff}
# Update the given annotation domain model object with the data from the # Update the given annotation domain model object with the data from the
# given annotation view model object. # given annotation view model object.
updateDomainModel = (domainModel, viewModel) -> updateDomainModel = (domainModel, viewModel) ->
...@@ -350,17 +335,6 @@ AnnotationController = [ ...@@ -350,17 +335,6 @@ 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 flags
diffFlags = diffFromTargets(@annotation.target)
@hasDiff = diffFlags.hasDiff
if @hasDiff
# We don't want to override the showDiff value manually changed
# by the user, that's why we use a conditional assignment here,
# instead of directly setting showDiff to the calculated value
@showDiff ?= diffFlags.shouldShowDiff
else
@showDiff = undefined
updateTimestamp = (repeat=false) => updateTimestamp = (repeat=false) =>
@timestamp = time.toFuzzyString model.updated @timestamp = time.toFuzzyString model.updated
fuzzyUpdate = time.nextFuzzyUpdate model.updated fuzzyUpdate = time.nextFuzzyUpdate model.updated
......
...@@ -340,110 +340,6 @@ describe 'annotation', -> ...@@ -340,110 +340,6 @@ describe 'annotation', ->
controller.render() controller.render()
assert(controller.document.title == 'example.com') assert(controller.document.title == 'example.com')
describe 'when there are no targets', ->
beforeEach ->
annotation.target = []
controller.render()
targets = controller.annotation.target
it 'sets `hasDiff` to false and `showDiff` to undefined', ->
controller.render()
assert.isFalse(controller.hasDiff)
assert.isUndefined(controller.showDiff)
describe 'when a single target has text identical to what was in the selectors', ->
it 'sets `showDiff` to undefined and `hasDiff` to false', ->
controller.render()
assert.isFalse(controller.hasDiff)
assert.isUndefined(controller.showDiff)
describe 'when a single target has different text, compared to what was in the selector', ->
targets = null
beforeEach ->
annotation.target = [
{diffHTML: "This is <ins>not</ins> the same quote", diffCaseOnly: false},
]
controller.render()
targets = controller.annotation.target
it 'sets both `hasDiff` and `showDiff` to true', ->
controller.render()
assert.isTrue(controller.hasDiff)
assert.isTrue(controller.showDiff)
describe 'when there are only upper case/lower case difference between the text in the single target, and what was saved in a selector', ->
targets = null
beforeEach ->
annotation.target = [
{diffHTML: "<ins>s</ins><del>S</del>tuff", diffCaseOnly: true},
]
controller.render()
targets = controller.annotation.target
it 'sets `hasDiff` to true and `showDiff` to false', ->
controller.render()
assert.isTrue(controller.hasDiff)
assert.isFalse(controller.showDiff)
describe 'when there are multiple targets, some with differences in text', ->
targets = null
beforeEach ->
annotation.target = [
{otherProperty: 'bar'},
{diffHTML: "This is <ins>not</ins> the same quote", diffCaseOnly: false},
{diffHTML: "<ins>s</ins><del>S</del>tuff", diffCaseOnly: true},
]
controller.render()
targets = controller.annotation.target
it 'sets `hasDiff` to true', ->
assert.isTrue(controller.hasDiff)
it 'sets `showDiff` to true', ->
assert.isTrue(controller.showDiff)
it 'preserves the `showDiff` value on update', ->
controller.showDiff = false
annotation.target = annotation.target.slice(1)
controller.render()
assert.isFalse(controller.showDiff)
it 'unsets `hasDiff` if differences go away', ->
annotation.target = annotation.target.splice(0, 1)
controller.render()
assert.isFalse(controller.hasDiff)
describe 'when there are multiple targets, some with differences, but only upper case / lower case', ->
targets = null
beforeEach ->
annotation.target = [
{otherProperty: 'bar'},
{diffHTML: "<ins>s</ins><del>S</del>tuff", diffCaseOnly: true},
]
controller.render()
targets = controller.annotation.target
it 'sets `hasDiff` to true', ->
assert.isTrue(controller.hasDiff)
it 'sets `showDiff` to false', ->
assert.isFalse(controller.showDiff)
it 'preserves the `showDiff` value on update', ->
controller.showDiff = true
annotation.target = annotation.target.slice(1)
controller.render()
assert.isTrue(controller.showDiff)
it 'unsets `hasDiff` if differences go away', ->
annotation.target = annotation.target.splice(0, 1)
controller.render()
assert.isFalse(controller.hasDiff)
describe 'timestamp', -> describe 'timestamp', ->
clock = null clock = null
......
...@@ -122,11 +122,6 @@ ...@@ -122,11 +122,6 @@
} }
} }
.show-differences {
border-left: 3px solid #D3D3D3;
padding: 0.3em 0.615em;
}
//PRIVACY CONTROL//////////////////////////// //PRIVACY CONTROL////////////////////////////
privacy { privacy {
......
...@@ -58,21 +58,11 @@ ...@@ -58,21 +58,11 @@
ng-repeat="target in vm.annotation.target track by $index"> ng-repeat="target in vm.annotation.target track by $index">
<excerpt enabled="feature('truncate_annotations')"> <excerpt enabled="feature('truncate_annotations')">
<blockquote class="annotation-quote" <blockquote class="annotation-quote"
ng-hide="target.diffHTML && 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>
</excerpt> </excerpt>
<blockquote class="annotation-quote"
ng-bind-html="target.diffHTML"
ng-show="target.diffHTML && vm.showDiff"></blockquote>
<div class="small show-differences"
ng-show="vm.hasDiff">
<input type="checkbox"
ng-model="vm.showDiff"
ng-click="$event.stopPropagation()"> Show differences</input>
</div>
</section> </section>
<!-- / Excerpts -- > <!-- / Excerpts -- >
......
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