mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-05-01 08:34:11 +02:00
Add notification.js to run for notification browser instance (fixes links)
This commit is contained in:
parent
cf58ac5665
commit
ffe430a4a5
@ -38,7 +38,7 @@ public FormBrowser(){
|
|||||||
|
|
||||||
Controls.Add(browser);
|
Controls.Add(browser);
|
||||||
|
|
||||||
notification = new FormNotification(this,true);
|
notification = new FormNotification(this,bridge,true);
|
||||||
notification.Show();
|
notification.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using TweetDick.Core.Handling;
|
using TweetDick.Core.Handling;
|
||||||
using TweetDick.Configuration;
|
using TweetDick.Configuration;
|
||||||
|
using TweetDick.Resources;
|
||||||
|
|
||||||
namespace TweetDick.Core{
|
namespace TweetDick.Core{
|
||||||
partial class FormNotification : Form{
|
partial class FormNotification : Form{
|
||||||
@ -16,7 +17,9 @@ partial class FormNotification : Form{
|
|||||||
private readonly bool autoHide;
|
private readonly bool autoHide;
|
||||||
private int timeLeft, totalTime;
|
private int timeLeft, totalTime;
|
||||||
|
|
||||||
public FormNotification(Form owner, bool autoHide){
|
private readonly string notificationJS;
|
||||||
|
|
||||||
|
public FormNotification(Form owner, TweetDeckBridge bridge, bool autoHide){
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
@ -24,10 +27,26 @@ public FormNotification(Form owner, bool autoHide){
|
|||||||
|
|
||||||
owner.FormClosed += (sender, args) => Close();
|
owner.FormClosed += (sender, args) => Close();
|
||||||
|
|
||||||
|
notificationJS = ScriptLoader.LoadResource("notification.js");
|
||||||
|
|
||||||
browser = new ChromiumWebBrowser("about:blank"){ MenuHandler = new MenuHandlerEmpty() };
|
browser = new ChromiumWebBrowser("about:blank"){ MenuHandler = new MenuHandlerEmpty() };
|
||||||
|
browser.FrameLoadEnd += Browser_FrameLoadEnd;
|
||||||
|
|
||||||
|
if (bridge != null){
|
||||||
|
browser.RegisterJsObject("$TD",bridge);
|
||||||
|
}
|
||||||
|
|
||||||
panelBrowser.Controls.Add(browser);
|
panelBrowser.Controls.Add(browser);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public FormNotification(Form owner, bool autoHide) : this(owner,null,autoHide){}
|
||||||
|
|
||||||
|
private void Browser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e){
|
||||||
|
if (e.Frame.IsMain && notificationJS != null){
|
||||||
|
browser.ExecuteScriptAsync(notificationJS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void ShowNotification(TweetNotification notification){
|
public void ShowNotification(TweetNotification notification){
|
||||||
MoveToVisibleLocation();
|
MoveToVisibleLocation();
|
||||||
|
|
||||||
|
11
Resources/notification.js
Normal file
11
Resources/notification.js
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
(function($TD){
|
||||||
|
//
|
||||||
|
// Block: Hook into links to bypass default open function
|
||||||
|
//
|
||||||
|
document.body.addEventListener("click",function(e){
|
||||||
|
if (e.target.tagName == "A"){
|
||||||
|
$TD.openBrowser(e.target.getAttribute("href"));
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})($TD);
|
@ -200,6 +200,12 @@
|
|||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ContentWithTargetPath Include="Resources\notification.js">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
<TargetPath>notification.js</TargetPath>
|
||||||
|
</ContentWithTargetPath>
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
|
Loading…
Reference in New Issue
Block a user