SEBWIN-852: Ensured page zoom via CTRL+MOUSEWHEEL also works according to the respective configuration value.
This commit is contained in:
parent
4c0f3cfa6c
commit
d5b182ae2f
6 changed files with 43 additions and 3 deletions
|
@ -18,6 +18,7 @@ namespace SafeExamBrowser.Browser.Content
|
||||||
|
|
||||||
private string api;
|
private string api;
|
||||||
private string clipboard;
|
private string clipboard;
|
||||||
|
private string pageZoom;
|
||||||
|
|
||||||
internal ContentLoader(IText text)
|
internal ContentLoader(IText text)
|
||||||
{
|
{
|
||||||
|
@ -97,5 +98,22 @@ namespace SafeExamBrowser.Browser.Content
|
||||||
|
|
||||||
return clipboard;
|
return clipboard;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal string LoadPageZoom()
|
||||||
|
{
|
||||||
|
if (pageZoom == default)
|
||||||
|
{
|
||||||
|
var assembly = Assembly.GetAssembly(typeof(ContentLoader));
|
||||||
|
var path = $"{typeof(ContentLoader).Namespace}.PageZoom.js";
|
||||||
|
|
||||||
|
using (var stream = assembly.GetManifestResourceStream(path))
|
||||||
|
using (var reader = new StreamReader(stream))
|
||||||
|
{
|
||||||
|
pageZoom = reader.ReadToEnd();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return pageZoom;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
16
SafeExamBrowser.Browser/Content/PageZoom.js
Normal file
16
SafeExamBrowser.Browser/Content/PageZoom.js
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||||
|
*
|
||||||
|
* 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/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function disableMouseWheelZoom(e) {
|
||||||
|
if (e.ctrlKey) {
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener('wheel', disableMouseWheelZoom, { passive: false });
|
|
@ -40,9 +40,15 @@ namespace SafeExamBrowser.Browser.Handlers
|
||||||
var configurationKey = keyGenerator.CalculateConfigurationKeyHash(settings.ConfigurationKey, frame.Url);
|
var configurationKey = keyGenerator.CalculateConfigurationKeyHash(settings.ConfigurationKey, frame.Url);
|
||||||
var api = contentLoader.LoadApi(browserExamKey, configurationKey, appConfig.ProgramBuildVersion);
|
var api = contentLoader.LoadApi(browserExamKey, configurationKey, appConfig.ProgramBuildVersion);
|
||||||
var clipboardScript = contentLoader.LoadClipboard();
|
var clipboardScript = contentLoader.LoadClipboard();
|
||||||
|
var pageZoomScript = contentLoader.LoadPageZoom();
|
||||||
|
|
||||||
frame.ExecuteJavaScriptAsync(api);
|
frame.ExecuteJavaScriptAsync(api);
|
||||||
|
|
||||||
|
if (!settings.AllowPageZoom)
|
||||||
|
{
|
||||||
|
frame.ExecuteJavaScriptAsync(pageZoomScript);
|
||||||
|
}
|
||||||
|
|
||||||
if (!settings.AllowPrint)
|
if (!settings.AllowPrint)
|
||||||
{
|
{
|
||||||
frame.ExecuteJavaScriptAsync($"window.print = function() {{ alert('{text.Get(TextKey.Browser_PrintNotAllowed)}') }}");
|
frame.ExecuteJavaScriptAsync($"window.print = function() {{ alert('{text.Get(TextKey.Browser_PrintNotAllowed)}') }}");
|
||||||
|
|
|
@ -194,7 +194,9 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<EmbeddedResource Include="Content\Clipboard.js" />
|
<EmbeddedResource Include="Content\Clipboard.js" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup />
|
<ItemGroup>
|
||||||
|
<EmbeddedResource Include="Content\PageZoom.js" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<PostBuildEvent>
|
<PostBuildEvent>
|
||||||
|
|
|
@ -533,7 +533,6 @@ if (typeof __SEB_focusElement === 'undefined') {
|
||||||
ForwardButton.Visibility = WindowSettings.AllowForwardNavigation ? Visibility.Visible : Visibility.Collapsed;
|
ForwardButton.Visibility = WindowSettings.AllowForwardNavigation ? Visibility.Visible : Visibility.Collapsed;
|
||||||
HomeButton.IsEnabled = WindowSettings.ShowHomeButton;
|
HomeButton.IsEnabled = WindowSettings.ShowHomeButton;
|
||||||
HomeButton.Visibility = WindowSettings.ShowHomeButton ? Visibility.Visible : Visibility.Collapsed;
|
HomeButton.Visibility = WindowSettings.ShowHomeButton ? Visibility.Visible : Visibility.Collapsed;
|
||||||
MenuButton.IsEnabled = settings.AllowPageZoom || WindowSettings.AllowDeveloperConsole;
|
|
||||||
ReloadButton.IsEnabled = WindowSettings.AllowReloading;
|
ReloadButton.IsEnabled = WindowSettings.AllowReloading;
|
||||||
ReloadButton.Visibility = WindowSettings.ShowReloadButton ? Visibility.Visible : Visibility.Collapsed;
|
ReloadButton.Visibility = WindowSettings.ShowReloadButton ? Visibility.Visible : Visibility.Collapsed;
|
||||||
Toolbar.Visibility = WindowSettings.ShowToolbar ? Visibility.Visible : Visibility.Collapsed;
|
Toolbar.Visibility = WindowSettings.ShowToolbar ? Visibility.Visible : Visibility.Collapsed;
|
||||||
|
|
|
@ -528,7 +528,6 @@ if (typeof __SEB_focusElement === 'undefined') {
|
||||||
ForwardButton.Visibility = WindowSettings.AllowForwardNavigation ? Visibility.Visible : Visibility.Collapsed;
|
ForwardButton.Visibility = WindowSettings.AllowForwardNavigation ? Visibility.Visible : Visibility.Collapsed;
|
||||||
HomeButton.IsEnabled = WindowSettings.ShowHomeButton;
|
HomeButton.IsEnabled = WindowSettings.ShowHomeButton;
|
||||||
HomeButton.Visibility = WindowSettings.ShowHomeButton ? Visibility.Visible : Visibility.Collapsed;
|
HomeButton.Visibility = WindowSettings.ShowHomeButton ? Visibility.Visible : Visibility.Collapsed;
|
||||||
MenuButton.IsEnabled = settings.AllowPageZoom || WindowSettings.AllowDeveloperConsole;
|
|
||||||
ReloadButton.IsEnabled = WindowSettings.AllowReloading;
|
ReloadButton.IsEnabled = WindowSettings.AllowReloading;
|
||||||
ReloadButton.Visibility = WindowSettings.ShowReloadButton ? Visibility.Visible : Visibility.Collapsed;
|
ReloadButton.Visibility = WindowSettings.ShowReloadButton ? Visibility.Visible : Visibility.Collapsed;
|
||||||
Toolbar.Visibility = WindowSettings.ShowToolbar ? Visibility.Visible : Visibility.Collapsed;
|
Toolbar.Visibility = WindowSettings.ShowToolbar ? Visibility.Visible : Visibility.Collapsed;
|
||||||
|
|
Loading…
Reference in a new issue