1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-04-07 09:15:50 +02:00

Replace td-example-notification attribute with .td-example body class

This commit is contained in:
chylex 2018-07-30 01:49:38 +02:00
parent 671657e2b0
commit 01244ec632
6 changed files with 28 additions and 30 deletions

View File

@ -9,7 +9,7 @@ namespace TweetDuck.Core.Notification.Example{
sealed class FormNotificationExample : FormNotificationMain{
public override bool RequiresResize => true;
protected override bool CanDragWindow => Config.NotificationPosition == TweetNotification.Position.Custom;
protected override FormBorderStyle NotificationBorderStyle{
get{
if (Config.NotificationSize == TweetNotification.Size.Custom){
@ -23,6 +23,8 @@ protected override FormBorderStyle NotificationBorderStyle{
}
}
protected override string BodyClasses => base.BodyClasses+" td-example";
public event EventHandler Ready;
private readonly TweetNotification exampleNotification;
@ -36,7 +38,7 @@ public FormNotificationExample(FormBrowser owner, PluginManager pluginManager) :
exampleTweetHTML = exampleTweetHTML.Replace("</p>", @"</p><div style='margin-top:256px'>Scrollbar test padding...</div>");
#endif
exampleNotification = TweetNotification.Example(exampleTweetHTML, 176);
exampleNotification = new TweetNotification(string.Empty, string.Empty, "Home", exampleTweetHTML, 176, string.Empty, string.Empty);
}
private void browser_LoadingStateChanged(object sender, LoadingStateChangedEventArgs e){

View File

@ -10,7 +10,7 @@
using TweetDuck.Core.Utils;
namespace TweetDuck.Core.Notification{
partial class FormNotificationBase : Form, AnalyticsFile.IProvider{
abstract partial class FormNotificationBase : Form, AnalyticsFile.IProvider{
protected static UserConfig Config => Program.Config.User;
protected static int FontSizeLevel{
@ -186,9 +186,7 @@ public virtual void ResumeNotification(){
}
}
protected virtual string GetTweetHTML(TweetNotification tweet){
return tweet.GenerateHtml(IsCursorOverBrowser ? "td-notification td-hover" : "td-notification", this);
}
protected abstract string GetTweetHTML(TweetNotification tweet);
protected virtual void LoadTweet(TweetNotification tweet){
currentNotification = tweet;

View File

@ -67,6 +67,8 @@ private int BaseClientHeight{
}
}
}
protected virtual string BodyClasses => IsCursorOverBrowser ? "td-notification td-hover" : "td-notification";
public Size BrowserSize => Config.DisplayNotificationTimer ? new Size(ClientSize.Width, ClientSize.Height-timerBarHeight) : ClientSize;
@ -181,9 +183,11 @@ private void Browser_LoadingStateChanged(object sender, LoadingStateChangedEvent
}
private void Browser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e){
if (e.Frame.IsMain && browser.Address != "about:blank"){
e.Frame.ExecuteJavaScriptAsync(PropertyBridge.GenerateScript(PropertyBridge.Environment.Notification));
ScriptLoader.ExecuteScript(e.Frame, ScriptLoader.LoadResource("notification.js", this), "root:notification");
IFrame frame = e.Frame;
if (frame.IsMain && browser.Address != "about:blank"){
frame.ExecuteJavaScriptAsync(PropertyBridge.GenerateScript(PropertyBridge.Environment.Notification));
ScriptLoader.ExecuteFile(frame, "notification.js", this);
}
}
@ -247,7 +251,7 @@ public override void ResumeNotification(){
}
protected override string GetTweetHTML(TweetNotification tweet){
string html = base.GetTweetHTML(tweet);
string html = tweet.GenerateHtml(BodyClasses, this);
foreach(InjectedHTML injection in plugins.NotificationInjections){
html = injection.InjectInto(html);

View File

@ -10,11 +10,7 @@ namespace TweetDuck.Core.Notification{
sealed class TweetNotification{
private const string DefaultHeadLayout = @"<html class=""scroll-v os-windows dark txt-size--14"" lang=""en-US"" id=""tduck"" data-td-font=""medium"" data-td-theme=""dark""><head><meta charset=""utf-8""><link href=""https://ton.twimg.com/tweetdeck-web/web/dist/bundle.4b1f87e09d.css"" rel=""stylesheet""><style type='text/css'>body { background: rgb(34, 36, 38) !important }</style>";
public static readonly ResourceLink AppLogo = new ResourceLink("https://ton.twimg.com/tduck/avatar", ResourceHandler.FromByteArray(Properties.Resources.avatar, "image/png"));
public static TweetNotification Example(string html, int characters){
return new TweetNotification(string.Empty, string.Empty, "Home", html, characters, string.Empty, string.Empty, true);
}
public enum Position{
TopLeft, TopRight, BottomLeft, BottomRight, Custom
}
@ -32,11 +28,8 @@ public enum Size{
private readonly string html;
private readonly int characters;
private readonly bool isExample;
public TweetNotification(string columnId, string chirpId, string title, string html, int characters, string tweetUrl, string quoteUrl) : this(columnId, chirpId, title, html, characters, tweetUrl, quoteUrl, false){}
private TweetNotification(string columnId, string chirpId, string title, string html, int characters, string tweetUrl, string quoteUrl, bool isExample){
public TweetNotification(string columnId, string chirpId, string title, string html, int characters, string tweetUrl, string quoteUrl){
this.ColumnId = columnId;
this.ChirpId = chirpId;
@ -46,7 +39,6 @@ private TweetNotification(string columnId, string chirpId, string title, string
this.html = html;
this.characters = characters;
this.isExample = isExample;
}
public int GetDisplayDuration(int value){
@ -70,7 +62,7 @@ public string GenerateHtml(string bodyClasses, Control sync){
build.Append(' ').Append(bodyClasses);
}
build.Append('\'').Append(isExample ? " td-example-notification" : "").Append("><div class='column' style='width:100%!important;min-height:100vh!important;height:auto!important;overflow:initial!important;'>");
build.Append("'><div class='column' style='width:100%!important;min-height:100vh!important;height:auto!important;overflow:initial!important;'>");
build.Append(html);
build.Append("</div></body>");
build.Append("</html>");

View File

@ -121,16 +121,14 @@
//
// Block: Setup a skip button.
//
if (!document.body.hasAttribute("td-example-notification")){
document.body.children[0].insertAdjacentHTML("beforeend", `
document.body.children[0].insertAdjacentHTML("beforeend", `
<svg id="td-skip" width="10" height="17" viewBox="0 0 350 600">
<path fill="#888" d="M0,151.656l102.208-102.22l247.777,247.775L102.208,544.986L0,442.758l145.546-145.547">
</svg>`);
document.getElementById("td-skip").addEventListener("click", function(){
$TD.loadNextNotification();
});
}
document.getElementById("td-skip").addEventListener("click", function(){
$TD.loadNextNotification();
});
//
// Block: Setup a hover class on body.

View File

@ -104,7 +104,7 @@ html[data-td-font='smallest'] .fullname-badged:before, html[data-td-font='small'
vertical-align: sub !important;
margin-right: 4px !important;
}
.td-notification-padded .item-img {
position: absolute;
left: 21px;
@ -159,6 +159,10 @@ html[data-td-font='smallest'] .fullname-badged:before, html[data-td-font='small'
transition: opacity 0.15s ease;
}
.td-example #td-skip {
display: none;
}
.td-hover #td-skip {
opacity: 0.75;
}