From 5230aad30fc717fad72fd64eeae245434aaaf7b9 Mon Sep 17 00:00:00 2001 From: John Livingston Date: Sun, 21 Feb 2021 00:13:29 +0100 Subject: [PATCH] =?UTF-8?q?The=20=C2=ABopen=20in=20new=20window=C2=BB=20bu?= =?UTF-8?q?tton=20is=20now=20optional.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + README.md | 6 ++++++ client/videowatch-client-plugin.js | 14 ++++++++------ main.js | 7 +++++++ 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 89c2a6e2..99594ded 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ * Optional Builtin ConverseJS * Option for enabling live only on local videos +* The «open in new window» button is optional ## v0.0.8 diff --git a/README.md b/README.md index 6bc4ade6..c67e4375 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,12 @@ There are several options in the plugin settings page. If checked, the chat will be loaded as soon as you are on the video page. +### Show the «open in new window» button + +If your webchat can be opened in a full window, you can add a button to do so. + +NB: The builtin ConverseJS is compatible with this feature. + ### Chats are only available for local videos Peertube is a federated service. Plugins are only available on the server you are browsing. diff --git a/client/videowatch-client-plugin.js b/client/videowatch-client-plugin.js index d8d32fa1..7c227dfd 100644 --- a/client/videowatch-client-plugin.js +++ b/client/videowatch-client-plugin.js @@ -76,7 +76,7 @@ function register ({ registerHook, peertubeHelpers }) { buttons.prepend(button) } - function displayChatButtons (peertubeHelpers, uuid) { + function displayChatButtons (peertubeHelpers, uuid, showOpenBlank) { logger.log('Adding buttons in the DOM...') const p = new Promise((resolve, reject) => { Promise.all([ @@ -93,10 +93,12 @@ function register ({ registerHook, peertubeHelpers }) { if (!iframeUri) { return reject(new Error('No uri, cant display the buttons.')) } - displayButton(buttons, 'openblank', labelOpenBlank, () => { - closeChat() - window.open(iframeUri) - }) + if (showOpenBlank) { + displayButton(buttons, 'openblank', labelOpenBlank, () => { + closeChat() + window.open(iframeUri) + }) + } displayButton(buttons, 'open', labelOpen, () => openChat()) displayButton(buttons, 'close', labelClose, () => closeChat()) @@ -212,7 +214,7 @@ function register ({ registerHook, peertubeHelpers }) { return } - displayChatButtons(peertubeHelpers, uuid).then(() => { + displayChatButtons(peertubeHelpers, uuid, !!settings['chat-open-blank']).then(() => { if (settings['chat-auto-display']) { openChat() } else { diff --git a/main.js b/main.js index 71b17391..58238cd2 100644 --- a/main.js +++ b/main.js @@ -19,6 +19,13 @@ async function register ({ default: false, private: false }) + registerSetting({ + name: 'chat-open-blank', + label: 'Show the «open in new window» button', + private: false, + type: 'input-checkbox', + default: false + }) registerSetting({ name: 'chat-only-locals', label: 'Chats are only available for local videos.',