Commit 1d928309 authored by Jehan's avatar Jehan

Merge pull request #214 from gergely-ujvari/26-add-handle-to-left-edge-of-the-sidebar-to-resize-it

26 add handle to left edge of the sidebar to resize it
parents 31619902 10dafb0e
...@@ -65,6 +65,13 @@ class Annotator.Host extends Annotator ...@@ -65,6 +65,13 @@ class Annotator.Host extends Annotator
onEditorSubmit: this.onEditorSubmit onEditorSubmit: this.onEditorSubmit
showFrame: => @frame.removeClass('annotator-collapsed') showFrame: => @frame.removeClass('annotator-collapsed')
hideFrame: => @frame.addClass('annotator-collapsed') hideFrame: => @frame.addClass('annotator-collapsed')
resetFrameWidth: =>
@frame.css({ "width": "", "margin-left" : "" })
setFrameWidth: (width) =>
@frame.css({ "width": width, "margin-left" : (-1)*width })
addtoFrameWidth: (width, innerWidth) =>
if isNaN(parseInt(@frame[0].style.width)) then old = innerWidth else old = parseInt(@frame[0].style.width)
@frame.css({ "width": (old + width), "margin-left" : (-1)*(old + width) })
getHighlights: => getHighlights: =>
highlights: $(@wrapper).find('.annotator-hl').map -> highlights: $(@wrapper).find('.annotator-hl').map ->
offset: $(this).offset() offset: $(this).offset()
...@@ -149,7 +156,7 @@ class Annotator.Host extends Annotator ...@@ -149,7 +156,7 @@ class Annotator.Host extends Annotator
do update do update
document.addEventListener 'touchstart', => document.addEventListener 'touchstart', =>
touch = true touch = true
do update do update
$(window).on 'resize scroll', update $(window).on 'resize scroll', update
$(document.body).on 'resize scroll', '*', util.debounce => @consumer.update() $(document.body).on 'resize scroll', '*', util.debounce => @consumer.update()
super super
......
...@@ -5,6 +5,8 @@ class Hypothesis extends Annotator ...@@ -5,6 +5,8 @@ class Hypothesis extends Annotator
this::hash = -1 # * cheap UUID :cake: this::hash = -1 # * cheap UUID :cake:
this::cache = {} # * object cache this::cache = {} # * object cache
this::visible = false # * Whether the sidebar is visible this::visible = false # * Whether the sidebar is visible
this::dragstartposX =0# * Frame's draggin start position
this::lastWidth = 0 # * Frame's width before close
# Plugin configuration # Plugin configuration
options: options:
...@@ -61,6 +63,9 @@ class Hypothesis extends Annotator ...@@ -61,6 +63,9 @@ class Hypothesis extends Annotator
onEditorSubmit: {} onEditorSubmit: {}
showFrame: {} showFrame: {}
hideFrame: {} hideFrame: {}
resetFrameWidth: {}
setFrameWidth: {}
addtoFrameWidth: {}
getHighlights: {} getHighlights: {}
setActiveHighlights: {} setActiveHighlights: {}
getMaxBottom: {} getMaxBottom: {}
...@@ -123,6 +128,14 @@ class Hypothesis extends Annotator ...@@ -123,6 +128,14 @@ class Hypothesis extends Annotator
if @viewer.isShown() and @bucket == -1 if @viewer.isShown() and @bucket == -1
this._fillDynamicBucket() this._fillDynamicBucket()
this.show() this.show()
document.getElementsByClassName('tri')[0].addEventListener 'dragstart', (event) =>
@dragstartposX = event.screenX
document.getElementById('toolbar').addEventListener 'dragend', (event) =>
@provider.addtoFrameWidth(@dragstartposX - event.screenX, window.innerWidth)
document.getElementById('toolbar').addEventListener 'drag', (event) =>
if event.screenX > 0
@provider.addtoFrameWidth((@dragstartposX - event.screenX), window.innerWidth)
@dragstartposX = event.screenX
this this
_setupDynamicStyle: -> _setupDynamicStyle: ->
...@@ -545,16 +558,20 @@ class Hypothesis extends Annotator ...@@ -545,16 +558,20 @@ class Hypothesis extends Annotator
annotations = @heatmap.buckets[@bucket]?.map (a) => a.hash.valueOf() annotations = @heatmap.buckets[@bucket]?.map (a) => a.hash.valueOf()
@visible = true @visible = true
if @lastWidth > 0 then @provider.setFrameWidth(@lastWidth)
@provider.setActiveHighlights annotations @provider.setActiveHighlights annotations
@provider.showFrame() @provider.showFrame()
$("#toolbar").addClass "shown" $("#toolbar").addClass "shown"
document.getElementsByClassName('tri')[0].draggable = true
hide: => hide: =>
@lastWidth = window.innerWidth
@visible = false @visible = false
@provider.setActiveHighlights [] @provider.setActiveHighlights []
@provider.resetFrameWidth()
@provider.hideFrame() @provider.hideFrame()
$("#toolbar").removeClass "shown" $("#toolbar").removeClass "shown"
document.getElementsByClassName('tri')[0].draggable = false
threadId: (annotation) -> threadId: (annotation) ->
if annotation?.thread? if annotation?.thread?
......
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