From cd9df96e539205e8e8f831ab02b3e6df140621cc Mon Sep 17 00:00:00 2001 From: Liunkae Date: Sat, 3 Dec 2016 22:55:29 -0600 Subject: [PATCH] Add context menu to reload button Fixes #5796 --- app/browser/menu.js | 14 ++------------ app/common/commonMenu.js | 20 ++++++++++++++++++++ js/components/navigationBar.js | 13 +++++++++++-- js/contextMenus.js | 17 ++++++++++++++++- 4 files changed, 49 insertions(+), 15 deletions(-) diff --git a/app/browser/menu.js b/app/browser/menu.js index 2a4866af3c0..edb656fb7d8 100644 --- a/app/browser/menu.js +++ b/app/browser/menu.js @@ -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, /* { diff --git a/app/common/commonMenu.js b/app/common/commonMenu.js index 686216e2cf4..5ce9a8e8637 100644 --- a/app/common/commonMenu.js +++ b/app/common/commonMenu.js @@ -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]) + } + } +} diff --git a/js/components/navigationBar.js b/js/components/navigationBar.js index d04647e3b7f..67546336ae1 100644 --- a/js/components/navigationBar.js +++ b/js/components/navigationBar.js @@ -20,6 +20,8 @@ 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 () { @@ -27,6 +29,7 @@ class NavigationBar extends ImmutableComponent { 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) } @@ -53,6 +56,10 @@ class NavigationBar extends ImmutableComponent { } } + onReloadLongPress (target) { + contextMenus.onReloadContextMenu(target) + } + onHome () { getSetting(settings.HOMEPAGE).split('|') .forEach((homepage, i) => { @@ -136,9 +143,11 @@ class NavigationBar extends ImmutableComponent { onClick={this.onStop} /> : -