Skip to content

Commit

Permalink
Use 'touch' instead of 'mobile'
Browse files Browse the repository at this point in the history
Using touch as a variable name instead of mobile as this is what we are
testing for.
  • Loading branch information
JakeHartnell committed Apr 1, 2015
1 parent 242ba32 commit 0fbc56d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
6 changes: 3 additions & 3 deletions h/static/scripts/annotator/guest.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ module.exports = class Guest extends Annotator
"document onselectionchange": "userSelectionChanged"

# We bind different events depending on whether the browser supports touch.
mobile = 'ontouchstart' in window or window.DocumentTouch and document instanceof DocumentTouch
if mobile
touch = 'ontouchstart' in window or window.DocumentTouch and document instanceof DocumentTouch
if touch
# This hack is needed for iOS Safari.
$(window).bind 'selectionEnd', ->
# reset selection timeout
Expand Down Expand Up @@ -209,7 +209,7 @@ module.exports = class Guest extends Annotator
_setupViewer: -> this
_setupEditor: -> this
_setupDocumentEvents: ->
if not mobile
if not touch
$(document).bind({
"mousedown": @checkForStartSelection
})
Expand Down
4 changes: 3 additions & 1 deletion h/static/scripts/annotator/plugin/textselection.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ class Annotator.Plugin.TextSelection extends Annotator.Plugin
@Annotator = Annotator
@$ = Annotator.$

touch = 'ontouchstart' in window or window.DocumentTouch and document instanceof DocumentTouch

# Register the event handlers required for creating a selection
if /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)
if touch
$(document).bind({
"touchend": @checkForEndSelection
})
Expand Down
9 changes: 4 additions & 5 deletions h/static/scripts/annotator/plugin/toolbar.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,17 @@ makeButton = (item) ->
class Annotator.Plugin.Toolbar extends Annotator.Plugin
PUSHED_CLASS = 'annotator-pushed'

mobile = 'ontouchstart' in window or window.DocumentTouch and document instanceof DocumentTouch
touch = 'ontouchstart' in window or window.DocumentTouch and document instanceof DocumentTouch

events:
'setVisibleHighlights': 'onSetVisibleHighlights'

html: '<div class="annotator-toolbar"></div>'

pluginInit: ->
# On mobile, we don't hide the toolbar.
@annotator.toolbar = @toolbar = $(@html)
if mobile
# When there is a selection on mobile show/hide highlighter
if touch
# When there is a selection on touch devices show/hide highlighter
document.addEventListener "selectstart", ->
if window.getSelection().toString() != ""
annotator.plugins.Toolbar.showHighlightButton(false)
Expand Down Expand Up @@ -103,7 +102,7 @@ class Annotator.Plugin.Toolbar extends Annotator.Plugin
$(@buttons[1]).children().addClass('h-icon-visibility-off')

_updateStickyButtons: ->
# The highlight button is hidden except when there is a selection on mobile
# The highlight button is hidden except when there is a selection on touch devices
if $(@buttons[3]).css('display') == 'none'
height = 105
else height = 140
Expand Down

0 comments on commit 0fbc56d

Please sign in to comment.