This repository has been archived by the owner on Dec 11, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 974
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Fixes middle and right click for home button
- Loading branch information
Showing
2 changed files
with
67 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
const React = require('react') | ||
|
||
// Components | ||
const ImmutableComponent = require('../immutableComponent') | ||
|
||
// Actions | ||
const appActions = require('../../../../js/actions/appActions') | ||
|
||
// Constants | ||
const settings = require('../../../../js/constants/settings') | ||
|
||
// Utils | ||
const {getSetting} = require('../../../../js/settings') | ||
const eventUtil = require('../../../../js/lib/eventUtil') | ||
|
||
class HomeButton extends ImmutableComponent { | ||
constructor (props) { | ||
super(props) | ||
this.onHome = this.onHome.bind(this) | ||
} | ||
|
||
componentDidMount () { | ||
this.homeButton.addEventListener('auxclick', this.onHome) | ||
} | ||
|
||
componentWillUnmount () { | ||
this.homeButton.removeEventListener('auxclick', this.onHome) | ||
} | ||
|
||
onHome (e) { | ||
if (e.button === 2) { | ||
return | ||
} | ||
|
||
getSetting(settings.HOMEPAGE).split('|') | ||
.forEach((homepage, i) => { | ||
if (i === 0 && !eventUtil.isForSecondaryAction(e)) { | ||
appActions.loadURLRequested(this.props.activeTabId, homepage) | ||
} else { | ||
appActions.createTabRequested({ | ||
url: homepage, | ||
active: false | ||
}) | ||
} | ||
}) | ||
} | ||
|
||
render () { | ||
return <span className='navigationButtonContainer'> | ||
<button | ||
data-test-id='homeButton' | ||
data-l10n-id='homeButton' | ||
className='normalizeButton navigationButton homeButton' | ||
ref={(node) => { this.homeButton = node }} | ||
onClick={this.onHome} | ||
/> | ||
</span> | ||
} | ||
} | ||
|
||
module.exports = HomeButton |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters