Commit faf39d80 authored by Sean Hammond's avatar Sean Hammond

Enable highlights by default everywhere

Enable highlights by default in the Chrome extension, bookmarklet and embed.

They were already enabled by default in the Chrome extension and
bookmarklet so this only changes the embed.

Highlights are turned on by default in annotator/host.coffee if no
showHighlights option is found.

The extension and bookmarklet no longer need to set showHighlights: true as
this is now the default. The embed (which was not setting showHighlights: true
and so was getting the default setting of false) will now get the new default
setting of true.

For people embedding h into their own pages, they can turn off highlights by
default by including:

    <script>
      window.hypothesisConfig=function(){return{showHighlights:false}};
    </script>
parent 243ba96b
...@@ -4,6 +4,5 @@ function hypothesisConfig() { ...@@ -4,6 +4,5 @@ function hypothesisConfig() {
var hypothesisIntent = document.querySelector('[name="hypothesis-intent"]'); var hypothesisIntent = document.querySelector('[name="hypothesis-intent"]');
return { return {
firstRun: hypothesisIntent && hypothesisIntent.content === 'first-run', firstRun: hypothesisIntent && hypothesisIntent.content === 'first-run',
showHighlights: true
}; };
} }
...@@ -26,7 +26,10 @@ module.exports = class Host extends Guest ...@@ -26,7 +26,10 @@ module.exports = class Host extends Guest
this.on 'panelReady', => this.on 'panelReady', =>
# Initialize tool state. # Initialize tool state.
this.setVisibleHighlights(!!options.showHighlights) if options.showHighlights == undefined
# Highlights are on by default.
options.showHighlights = true
this.setVisibleHighlights(options.showHighlights)
# Show the UI # Show the UI
@frame.css('display', '') @frame.css('display', '')
......
...@@ -42,16 +42,16 @@ describe 'Host', -> ...@@ -42,16 +42,16 @@ describe 'Host', ->
assert.equal(host.frame.css('display'), '') assert.equal(host.frame.css('display'), '')
describe 'options', -> describe 'options', ->
it 'enables highlighting when showHighlights option is provided', (done) -> it 'disables highlighting if showHighlights: false is given', (done) ->
host = createHost(showHighlights: true) host = createHost(showHighlights: false)
host.on 'panelReady', -> host.on 'panelReady', ->
assert.isTrue(host.visibleHighlights) assert.isFalse(host.visibleHighlights)
done() done()
host.publish('panelReady') host.publish('panelReady')
it 'does not enable highlighting when no showHighlights option is provided', (done) -> it 'enables highlighting when no showHighlights option is given', (done) ->
host = createHost({}) host = createHost({})
host.on 'panelReady', -> host.on 'panelReady', ->
assert.isFalse(host.visibleHighlights) assert.isTrue(host.visibleHighlights)
done() done()
host.publish('panelReady') 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