Commit be70f716 authored by Randall Leeds's avatar Randall Leeds

code style

 - less instance-wide state
 - shorter lines (< 80 columns)
 - consistentCamelCase
parent 0a537623
...@@ -69,9 +69,14 @@ class Annotator.Host extends Annotator ...@@ -69,9 +69,14 @@ class Annotator.Host extends Annotator
@frame.css({ "width": "", "margin-left" : "" }) @frame.css({ "width": "", "margin-left" : "" })
setFrameWidth: (width) => setFrameWidth: (width) =>
@frame.css({ "width": width, "margin-left" : (-1)*width }) @frame.css({ "width": width, "margin-left" : (-1)*width })
addtoFrameWidth: (width, innerWidth) => addToFrameWidth: (width, innerWidth) =>
if isNaN(parseInt(@frame[0].style.width)) then old = innerWidth else old = parseInt(@frame[0].style.width) if isNaN(parseInt(@frame[0].style.width))
@frame.css({ "width": (old + width), "margin-left" : (-1)*(old + width) }) old = innerWidth
else
old = parseInt(@frame[0].style.width)
@frame.css
width: old + width
'margin-left': -(old + width)
getHighlights: => getHighlights: =>
highlights: $(@wrapper).find('.annotator-hl').map -> highlights: $(@wrapper).find('.annotator-hl').map ->
offset: $(this).offset() offset: $(this).offset()
......
...@@ -5,7 +5,6 @@ class Hypothesis extends Annotator ...@@ -5,7 +5,6 @@ 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 this::lastWidth = 0 # * Frame's width before close
# Plugin configuration # Plugin configuration
...@@ -170,6 +169,7 @@ class Hypothesis extends Annotator ...@@ -170,6 +169,7 @@ class Hypothesis extends Annotator
this this
_setupDocumentEvents: -> _setupDocumentEvents: ->
dragStart = 0
@element.find('#toolbar .tri').click => @element.find('#toolbar .tri').click =>
if @visible if @visible
this.hide() this.hide()
...@@ -177,14 +177,13 @@ class Hypothesis extends Annotator ...@@ -177,14 +177,13 @@ 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) => .on 'dragstart', (event) =>
@dragstartposX = event.screenX dragStart = event.screenX
document.getElementById('toolbar').addEventListener 'dragend', (event) => .on 'dragend', (event) =>
@provider.addtoFrameWidth(@dragstartposX - event.screenX, window.innerWidth) @provider.addToFrameWidth (dragStart - event.screenX), window.innerWidth
document.getElementById('toolbar').addEventListener 'drag', (event) => .on 'drag', (event) =>
if event.screenX > 0 if event.screenX > 0
@provider.addtoFrameWidth((@dragstartposX - event.screenX), window.innerWidth) @provider.addToFrameWidth (dragStart - event.screenX), window.innerWidth
@dragstartposX = event.screenX
this this
_setupDynamicStyle: -> _setupDynamicStyle: ->
......
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