Commit bb1aecf0 authored by Randall Leeds's avatar Randall Leeds

Merge pull request #1626 from hypothesis/show-highlights-by-default

Show highlights by default in the Chrome Extension
parents 6d9e53be c644f1fc
function hypothesisConfig() {
// Pages on our site can include a meta tag to trigger specific behaviour
// when the extension loads.
var hypothesisIntent = document.querySelector('[name="hypothesis-intent"]');
return {
firstRun: hypothesisIntent && hypothesisIntent.content === 'first-run',
showHighlights: true
};
}
......@@ -37,6 +37,11 @@ class Annotator.Host extends Annotator.Guest
if options.firstRun
this.on 'panelReady', => this.actuallyShowFrame(transition: false)
# Host frame dictates the toolbar options.
this.on 'panelReady', =>
this.setTool('comment')
this.setVisibleHighlights(!!options.showHighlights)
if @plugins.Heatmap?
this._setupDragEvents()
@plugins.Heatmap.element.on 'click', (event) =>
......
......@@ -107,13 +107,15 @@ class Hypothesis extends Annotator
entities.push href
this.plugins.Store?.loadAnnotations()
channel.notify
method: 'setTool'
params: this.tool
channel.notify
method: 'setVisibleHighlights'
params: this.visibleHighlights
# Allow the host to define it's own state
unless source is $window.parent
channel.notify
method: 'setTool'
params: this.tool
channel.notify
method: 'setVisibleHighlights'
params: this.visibleHighlights
@providers.push
channel: channel
......
......@@ -50,6 +50,7 @@ module.exports = function(config) {
'h/static/scripts/plugin/heatmap.js',
'h/static/scripts/vendor/sinon.js',
'h/static/scripts/vendor/chai.js',
'h/static/scripts/hypothesis.js',
'h/templates/*.html',
'tests/js/**/*-test.coffee'
],
......
assert = chai.assert
sinon.assert.expose(assert, prefix: '')
describe 'Annotator.Host', ->
createHost = (options) ->
element = document.createElement('div')
return new Annotator.Host(element, options)
# Disable Annotator's ridiculous logging.
before -> sinon.stub(console, 'log')
after -> console.log.restore()
describe 'options', ->
it 'enables highlighting when showHighlights option is provided', (done) ->
host = createHost(showHighlights: true)
host.on 'panelReady', ->
assert.isTrue(host.visibleHighlights)
done()
host.publish('panelReady')
it 'does not enable highlighting when no showHighlights option is provided', (done) ->
host = createHost({})
host.on 'panelReady', ->
assert.isFalse(host.visibleHighlights)
done()
host.publish('panelReady')
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