mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-04-09 06:15:49 +02:00
Limit some $TD functions to browser/notification, change displayTooltip params
This commit is contained in:
parent
bb7cbde38f
commit
f956f696f4
Core
Resources/Scripts
@ -10,7 +10,7 @@
|
||||
using TweetDuck.Resources;
|
||||
|
||||
namespace TweetDuck.Core.Bridge{
|
||||
sealed class TweetDeckBridge{
|
||||
class TweetDeckBridge{
|
||||
public static string FontSize { get; private set; }
|
||||
public static string NotificationHeadLayout { get; private set; }
|
||||
|
||||
@ -45,41 +45,77 @@ public static void RestoreSessionData(IFrame frame){
|
||||
private readonly FormBrowser form;
|
||||
private readonly FormNotificationMain notification;
|
||||
|
||||
public TweetDeckBridge(FormBrowser form, FormNotificationMain notification){
|
||||
protected TweetDeckBridge(FormBrowser form, FormNotificationMain notification){
|
||||
this.form = form;
|
||||
this.notification = notification;
|
||||
}
|
||||
|
||||
public void OnIntroductionClosed(bool showGuide, bool allowDataCollection){
|
||||
form.InvokeAsyncSafe(() => {
|
||||
form.OnIntroductionClosed(showGuide, allowDataCollection);
|
||||
});
|
||||
// Browser only
|
||||
|
||||
public sealed class Browser : TweetDeckBridge{
|
||||
public Browser(FormBrowser form, FormNotificationMain notification) : base(form, notification){}
|
||||
|
||||
public void OpenContextMenu(){
|
||||
form.InvokeAsyncSafe(form.OpenContextMenu);
|
||||
}
|
||||
|
||||
public void OnIntroductionClosed(bool showGuide, bool allowDataCollection){
|
||||
form.InvokeAsyncSafe(() => {
|
||||
form.OnIntroductionClosed(showGuide, allowDataCollection);
|
||||
});
|
||||
}
|
||||
|
||||
public void LoadNotificationLayout(string fontSize, string headLayout){
|
||||
form.InvokeAsyncSafe(() => {
|
||||
FontSize = fontSize;
|
||||
NotificationHeadLayout = headLayout;
|
||||
});
|
||||
}
|
||||
|
||||
public void SetLastHighlightedTweet(string tweetUrl, string quoteUrl, string authors, string imageList){
|
||||
form.InvokeAsyncSafe(() => {
|
||||
LastHighlightedTweetUrl = tweetUrl;
|
||||
LastHighlightedQuoteUrl = quoteUrl;
|
||||
LastHighlightedTweetAuthors = authors;
|
||||
LastHighlightedTweetImages = imageList;
|
||||
});
|
||||
}
|
||||
|
||||
public void DisplayTooltip(string text){
|
||||
form.InvokeAsyncSafe(() => form.DisplayTooltip(text));
|
||||
}
|
||||
|
||||
public void SetSessionData(string key, string value){
|
||||
form.InvokeSafe(() => { // do not use InvokeAsyncSafe, return only after invocation
|
||||
SessionData.Add(key, value);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void LoadNotificationLayout(string fontSize, string headLayout){
|
||||
form.InvokeAsyncSafe(() => {
|
||||
FontSize = fontSize;
|
||||
NotificationHeadLayout = headLayout;
|
||||
});
|
||||
// Notification only
|
||||
|
||||
public sealed class Notification : TweetDeckBridge{
|
||||
public Notification(FormBrowser form, FormNotificationMain notification) : base(form, notification){}
|
||||
|
||||
public void DisplayTooltip(string text){
|
||||
notification.InvokeAsyncSafe(() => notification.DisplayTooltip(text));
|
||||
}
|
||||
|
||||
public void LoadNextNotification(){
|
||||
notification.InvokeAsyncSafe(notification.FinishCurrentNotification);
|
||||
}
|
||||
|
||||
public void ShowTweetDetail(){
|
||||
notification.InvokeAsyncSafe(notification.ShowTweetDetail);
|
||||
}
|
||||
}
|
||||
|
||||
// Global
|
||||
|
||||
public void SetLastRightClickInfo(string type, string link){
|
||||
form.InvokeAsyncSafe(() => ContextMenuBase.SetContextInfo(type, link));
|
||||
}
|
||||
|
||||
public void SetLastHighlightedTweet(string tweetUrl, string quoteUrl, string authors, string imageList){
|
||||
form.InvokeAsyncSafe(() => {
|
||||
LastHighlightedTweetUrl = tweetUrl;
|
||||
LastHighlightedQuoteUrl = quoteUrl;
|
||||
LastHighlightedTweetAuthors = authors;
|
||||
LastHighlightedTweetImages = imageList;
|
||||
});
|
||||
}
|
||||
|
||||
public void OpenContextMenu(){
|
||||
form.InvokeAsyncSafe(form.OpenContextMenu);
|
||||
}
|
||||
|
||||
public void OnTweetPopup(string columnId, string chirpId, string columnName, string tweetHtml, int tweetCharacters, string tweetUrl, string quoteUrl){
|
||||
notification.InvokeAsyncSafe(() => {
|
||||
form.OnTweetNotification();
|
||||
@ -94,29 +130,6 @@ public void OnTweetSound(){
|
||||
});
|
||||
}
|
||||
|
||||
public void DisplayTooltip(string text, bool showInNotification){
|
||||
if (showInNotification){
|
||||
notification.InvokeAsyncSafe(() => notification.DisplayTooltip(text));
|
||||
}
|
||||
else{
|
||||
form.InvokeAsyncSafe(() => form.DisplayTooltip(text));
|
||||
}
|
||||
}
|
||||
|
||||
public void SetSessionData(string key, string value){
|
||||
form.InvokeSafe(() => { // do not use InvokeAsyncSafe, return only after invocation
|
||||
SessionData.Add(key, value);
|
||||
});
|
||||
}
|
||||
|
||||
public void LoadNextNotification(){
|
||||
notification.InvokeAsyncSafe(notification.FinishCurrentNotification);
|
||||
}
|
||||
|
||||
public void ShowNotificationTweetDetail(){
|
||||
notification.InvokeAsyncSafe(notification.ShowTweetDetail);
|
||||
}
|
||||
|
||||
public void ScreenshotTweet(string html, int width, int height){
|
||||
form.InvokeAsyncSafe(() => form.OnTweetScreenshotReady(html, width, height));
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ public FormBrowser(UpdaterSettings updaterSettings){
|
||||
this.notification = new FormNotificationTweet(this, plugins);
|
||||
this.notification.Show();
|
||||
|
||||
this.browser = new TweetDeckBrowser(this, plugins, new TweetDeckBridge(this, notification));
|
||||
this.browser = new TweetDeckBrowser(this, plugins, new TweetDeckBridge.Browser(this, notification));
|
||||
this.browser.PageLoaded += browser_PageLoaded;
|
||||
|
||||
this.contextMenu = ContextMenuBrowser.CreateMenu(this);
|
||||
|
@ -83,7 +83,7 @@ protected FormNotificationMain(FormBrowser owner, PluginManager pluginManager, b
|
||||
|
||||
browser.KeyboardHandler = new KeyboardHandlerNotification(this);
|
||||
|
||||
browser.RegisterAsyncJsObject("$TD", new TweetDeckBridge(owner, this));
|
||||
browser.RegisterAsyncJsObject("$TD", new TweetDeckBridge.Notification(owner, this));
|
||||
browser.RegisterAsyncJsObject("$TDP", plugins.Bridge);
|
||||
|
||||
browser.LoadingStateChanged += Browser_LoadingStateChanged;
|
||||
|
@ -395,7 +395,7 @@
|
||||
}
|
||||
else{
|
||||
tooltipTimer = window.setTimeout(function(){
|
||||
$TD.displayTooltip(me.attr("data-full-url"), false);
|
||||
$TD.displayTooltip(me.attr("data-full-url"));
|
||||
tooltipDisplayed = true;
|
||||
}, 400);
|
||||
}
|
||||
@ -412,13 +412,13 @@
|
||||
|
||||
if (tooltipDisplayed){
|
||||
tooltipDisplayed = false;
|
||||
$TD.displayTooltip(null, false);
|
||||
$TD.displayTooltip(null);
|
||||
}
|
||||
},
|
||||
|
||||
mousemove: function(e){
|
||||
if (tooltipDisplayed && (prevMouseX !== e.clientX || prevMouseY !== e.clientY)){
|
||||
$TD.displayTooltip($(this).attr("data-full-url"), false);
|
||||
$TD.displayTooltip($(this).attr("data-full-url"));
|
||||
prevMouseX = e.clientX;
|
||||
prevMouseY = e.clientY;
|
||||
}
|
||||
|
@ -62,7 +62,7 @@
|
||||
}
|
||||
else{
|
||||
tooltipTimer = window.setTimeout(function(){
|
||||
$TD.displayTooltip(url, true);
|
||||
$TD.displayTooltip(url);
|
||||
tooltipDisplayed = true;
|
||||
}, 400);
|
||||
}
|
||||
@ -83,7 +83,7 @@
|
||||
|
||||
if (tooltipDisplayed){
|
||||
tooltipDisplayed = false;
|
||||
$TD.displayTooltip(null, true);
|
||||
$TD.displayTooltip(null);
|
||||
}
|
||||
});
|
||||
|
||||
@ -92,7 +92,7 @@
|
||||
var url = e.currentTarget.getAttribute("data-full-url");
|
||||
return if !url;
|
||||
|
||||
$TD.displayTooltip(url, true);
|
||||
$TD.displayTooltip(url);
|
||||
prevMouseX = e.clientX;
|
||||
prevMouseY = e.clientY;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user