Commit 1ed655fd authored by Randall Leeds's avatar Randall Leeds Committed by Aron Carroll

Remove unused dynamic bucket code

parent 94a56244
...@@ -140,13 +140,6 @@ class Annotator.Guest extends Annotator ...@@ -140,13 +140,6 @@ class Annotator.Guest extends Annotator
.bind('onEditorHide', this.onEditorHide) .bind('onEditorHide', this.onEditorHide)
.bind('onEditorSubmit', this.onEditorSubmit) .bind('onEditorSubmit', this.onEditorSubmit)
.bind('setDynamicBucketMode', (ctx, value) =>
return unless @plugins.BucketBar
return if @plugins.BucketBar.dynamicBucket is value
@plugins.BucketBar.dynamicBucket = value
if value then @plugins.BucketBar._update()
)
.bind('focusAnnotations', (ctx, tags=[]) => .bind('focusAnnotations', (ctx, tags=[]) =>
for hl in @getHighlights() for hl in @getHighlights()
if hl.annotation.$$tag in tags if hl.annotation.$$tag in tags
...@@ -285,9 +278,6 @@ class Annotator.Guest extends Annotator ...@@ -285,9 +278,6 @@ class Annotator.Guest extends Annotator
# #
# toggle: should this toggle membership in an existing selection? # toggle: should this toggle membership in an existing selection?
selectAnnotations: (annotations, toggle) => selectAnnotations: (annotations, toggle) =>
# Switch off dynamic mode; we are going to "Selection" scope
@plugins.BucketBar.dynamicBucket = false
if toggle if toggle
# Tell sidebar to add these annotations to the sidebar # Tell sidebar to add these annotations to the sidebar
this.toggleAnnotationSelection annotations this.toggleAnnotationSelection annotations
......
...@@ -27,9 +27,6 @@ class Annotator.Plugin.BucketBar extends Annotator.Plugin ...@@ -27,9 +27,6 @@ class Annotator.Plugin.BucketBar extends Annotator.Plugin
# tab elements # tab elements
tabs: null tabs: null
# whether to update the viewer as the window is scrolled
dynamicBucket: true
constructor: (element, options) -> constructor: (element, options) ->
super $(@html), options super $(@html), options
...@@ -336,11 +333,9 @@ class Annotator.Plugin.BucketBar extends Annotator.Plugin ...@@ -336,11 +333,9 @@ class Annotator.Plugin.BucketBar extends Annotator.Plugin
# If it's the upper tab, scroll to next anchor above # If it's the upper tab, scroll to next anchor above
if (@isUpper bucket) if (@isUpper bucket)
@dynamicBucket = true
@_jumpMinMax @buckets[bucket], "up" @_jumpMinMax @buckets[bucket], "up"
# If it's the lower tab, scroll to next anchor below # If it's the lower tab, scroll to next anchor below
else if (@isLower bucket) else if (@isLower bucket)
@dynamicBucket = true
@_jumpMinMax @buckets[bucket], "down" @_jumpMinMax @buckets[bucket], "down"
else else
annotations = @buckets[bucket].slice() annotations = @buckets[bucket].slice()
...@@ -349,9 +344,6 @@ class Annotator.Plugin.BucketBar extends Annotator.Plugin ...@@ -349,9 +344,6 @@ class Annotator.Plugin.BucketBar extends Annotator.Plugin
this._buildTabs(@tabs, @buckets) this._buildTabs(@tabs, @buckets)
if @dynamicBucket
@annotator.updateAnnotations this._getDynamicBucket()
_buildTabs: -> _buildTabs: ->
@tabs.each (d, el) => @tabs.each (d, el) =>
el = $(el) el = $(el)
...@@ -376,22 +368,5 @@ class Annotator.Plugin.BucketBar extends Annotator.Plugin ...@@ -376,22 +368,5 @@ class Annotator.Plugin.BucketBar extends Annotator.Plugin
if bucket if bucket
el.html("<div class='label'>#{bucketLength}</div>") el.html("<div class='label'>#{bucketLength}</div>")
_getDynamicBucket: -> isUpper: (i) -> i == 1
top = window.pageYOffset isLower: (i) -> i == @index.length - 2
bottom = top + $(window).innerHeight()
anchors = @annotator.getHighlights()
visible = anchors.reduce (acc, hl) =>
if top <= hl.getTop() <= bottom
if hl.annotation not in acc
acc.push hl.annotation
acc
, []
isUpper: (i) => i == 1
isLower: (i) => i == @index.length - 2
isComment: (i) => i is @_getCommentBucket()
# Simulate clicking on the comments tab
commentClick: =>
@dynamicBucket = false
annotator.showAnnotations @buckets[@_getCommentBucket()]
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