Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Merge pull request #5802 from Liunkae/reload-dropdown
Browse files Browse the repository at this point in the history
Add context menu to reload button
  • Loading branch information
bsclifton authored Dec 4, 2016
2 parents 7c38d20 + cd9df96 commit c6822d2
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 15 deletions.
14 changes: 2 additions & 12 deletions app/browser/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,19 +219,9 @@ const createViewSubmenu = () => {
click: function (item, focusedWindow) {
CommonMenu.sendToFocusedWindow(focusedWindow, [messages.SHORTCUT_ACTIVE_FRAME_STOP])
}
}, {
label: locale.translation('reloadPage'),
accelerator: 'CmdOrCtrl+R',
click: function (item, focusedWindow) {
CommonMenu.sendToFocusedWindow(focusedWindow, [messages.SHORTCUT_ACTIVE_FRAME_RELOAD])
}
}, {
label: locale.translation('cleanReload'),
accelerator: 'CmdOrCtrl+Shift+R',
click: function (item, focusedWindow) {
CommonMenu.sendToFocusedWindow(focusedWindow, [messages.SHORTCUT_ACTIVE_FRAME_CLEAN_RELOAD])
}
},
CommonMenu.reloadPageMenuItem(),
CommonMenu.cleanReloadMenuItem(),
CommonMenu.separatorMenuItem,
/*
{
Expand Down
20 changes: 20 additions & 0 deletions app/common/commonMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,3 +348,23 @@ module.exports.braveryPaymentsMenuItem = () => {
}
}
}

module.exports.reloadPageMenuItem = () => {
return {
label: locale.translation('reloadPage'),
accelerator: 'CmdOrCtrl+R',
click: function (item, focusedWindow) {
module.exports.sendToFocusedWindow(focusedWindow, [messages.SHORTCUT_ACTIVE_FRAME_RELOAD])
}
}
}

module.exports.cleanReloadMenuItem = () => {
return {
label: locale.translation('cleanReload'),
accelerator: 'CmdOrCtrl+Shift+R',
click: function (item, focusedWindow) {
module.exports.sendToFocusedWindow(focusedWindow, [messages.SHORTCUT_ACTIVE_FRAME_CLEAN_RELOAD])
}
}
}
13 changes: 11 additions & 2 deletions js/components/navigationBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@ const siteUtil = require('../state/siteUtil')
const eventUtil = require('../lib/eventUtil')
const getSetting = require('../settings').getSetting
const windowStore = require('../stores/windowStore')
const contextMenus = require('../contextMenus')
const LongPressButton = require('./longPressButton')

class NavigationBar extends ImmutableComponent {
constructor () {
super()
this.onToggleBookmark = this.onToggleBookmark.bind(this)
this.onStop = this.onStop.bind(this)
this.onReload = this.onReload.bind(this)
this.onReloadLongPress = this.onReloadLongPress.bind(this)
this.onNoScript = this.onNoScript.bind(this)
}

Expand All @@ -53,6 +56,10 @@ class NavigationBar extends ImmutableComponent {
}
}

onReloadLongPress (target) {
contextMenus.onReloadContextMenu(target)
}

onHome () {
getSetting(settings.HOMEPAGE).split('|')
.forEach((homepage, i) => {
Expand Down Expand Up @@ -136,9 +143,11 @@ class NavigationBar extends ImmutableComponent {
onClick={this.onStop} />
</span>
: <span className='navigationButtonContainer'>
<button data-l10n-id='reloadButton'
<LongPressButton
l10nId='reloadButton'
className='navigationButton reloadButton'
onClick={this.onReload} />
onClick={this.onReload}
onLongPress={this.onReloadLongPress} />
</span>
}
{
Expand Down
17 changes: 16 additions & 1 deletion js/contextMenus.js
Original file line number Diff line number Diff line change
Expand Up @@ -1482,6 +1482,20 @@ function onForwardButtonHistoryMenu (activeFrame, history, target) {
}))
}

function onReloadContextMenu (target) {
const rect = target.getBoundingClientRect()
const menuTemplate = [
CommonMenu.reloadPageMenuItem(),
CommonMenu.cleanReloadMenuItem()
]

windowActions.setContextMenuDetail(Immutable.fromJS({
left: rect.left,
top: rect.bottom + 2,
template: menuTemplate
}))
}

module.exports = {
onHamburgerMenu,
onMainContextMenu,
Expand All @@ -1498,5 +1512,6 @@ module.exports = {
onShowAutofillMenu,
onMoreBookmarksMenu,
onBackButtonHistoryMenu,
onForwardButtonHistoryMenu
onForwardButtonHistoryMenu,
onReloadContextMenu
}

0 comments on commit c6822d2

Please sign in to comment.