Commit ce139154 authored by Sean Roberts's avatar Sean Roberts

Merge branch 'master' into mobile-scrolling

* master:
  Add tests for sidebar closing when user clicks or taps in document
  Fixing tapping anchored annotations not opening sidebar
  Fixing sidebar not closing on outside content click issue
  eslint: Ignore docs/_build
  Update ESLint to v3.18.0
parents 03ab296f b82424e2
build/**
**/vendor/**/*.js
**/coverage/**
docs/_build/*
......@@ -7,6 +7,10 @@
"mocha"
],
"rules": {
"mocha/no-exclusive-tests": "error"
"mocha/no-exclusive-tests": "error",
"indent": ["error", 2, {
"ArrayExpression": "first",
"ObjectExpression": "first"
}]
},
}
......@@ -333,22 +333,20 @@ gulp.task('serve-package', function () {
servePackage(3001, packageServerHostname());
});
gulp.task('build',
['build-js',
'build-css',
'build-fonts',
'build-images'],
gulp.task('build', ['build-js',
'build-css',
'build-fonts',
'build-images'],
generateManifest);
gulp.task('watch',
['serve-package',
'serve-live-reload',
'watch-js',
'watch-css',
'watch-fonts',
'watch-images',
'watch-manifest',
'watch-templates']);
gulp.task('watch', ['serve-package',
'serve-live-reload',
'watch-js',
'watch-css',
'watch-fonts',
'watch-images',
'watch-manifest',
'watch-templates']);
function runKarma(baseConfig, opts, done) {
// See https://github.com/karma-runner/karma-mocha#configuration
......
This diff is collapsed.
......@@ -40,7 +40,7 @@
"end-of-stream": "^1.1.0",
"escape-html": "^1.0.3",
"escape-string-regexp": "^1.0.5",
"eslint": "^3.0.1",
"eslint": "^3.18.0",
"eslint-config-hypothesis": "^1.0.0",
"eslint-plugin-mocha": "^4.8.0",
"exorcist": "^0.4.0",
......
......@@ -47,6 +47,16 @@ module.exports = class Sidebar extends Host
@element.on 'click', (event) =>
if !@selectedTargets?.length
this.hide()
# Mobile browsers do not register click events on
# elements without cursor: pointer. So instead of
# adding that to every element, we can add the initial
# touchstart event which is always registered to
# make up for the lack of click support for all elements.
@element.on 'touchstart', (event) =>
if !@selectedTargets?.length
this.hide()
return this
_setupSidebarEvents: ->
......@@ -166,6 +176,9 @@ module.exports = class Sidebar extends Host
.removeClass('h-icon-chevron-right')
.addClass('h-icon-chevron-left')
isOpen: ->
!@frame.hasClass('annotator-collapsed')
createAnnotation: (annotation = {}) ->
super
this.show() unless annotation.$highlight
......
......@@ -173,3 +173,16 @@ describe 'Sidebar', ->
hide = sandbox.stub(sidebar, 'hide')
sidebar.onSwipe({type: 'swiperight'})
assert.calledOnce(hide)
describe 'document events', ->
sidebar = null
beforeEach ->
sidebar = createSidebar({})
it 'closes the sidebar when the user taps or clicks in the page', ->
for event in ['click', 'touchstart']
sidebar.show()
sidebar.element.trigger(event)
assert.isFalse(sidebar.isOpen())
......@@ -116,8 +116,8 @@ var update = {
SELECT_TAB: function (state, action) {
// Do nothing if the "new tab" is not a valid tab.
if ([uiConstants.TAB_ANNOTATIONS,
uiConstants.TAB_NOTES,
uiConstants.TAB_ORPHANS].indexOf(action.tab) === -1) {
uiConstants.TAB_NOTES,
uiConstants.TAB_ORPHANS].indexOf(action.tab) === -1) {
return {};
}
// Shortcut if the tab is already correct, to avoid resetting the sortKey
......
......@@ -139,7 +139,7 @@ describe('oauth auth', function () {
'https://hypothes.is/api/token',
expectedBody,
{headers: {'Content-Type': 'application/x-www-form-urlencoded'},
});
});
};
}
......
......@@ -9,6 +9,13 @@ $base-font-size: 14px;
.annotator-highlights-always-on {
.annotator-hl {
background-color: $highlight-color;
// cursor pointer gives mobile devices click
// event support. Using the pointer:coarse gives
// us good targeting to mobile devices that this effects
@media (pointer:coarse) {
cursor: pointer;
}
}
.annotator-hl .annotator-hl {
......
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