1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-05-03 14:34:08 +02:00

Rewrite font size handling

This commit is contained in:
chylex 2016-04-24 14:10:29 +02:00
parent 82a1e17b1d
commit b2892cc834
3 changed files with 9 additions and 20 deletions

View File

@ -71,14 +71,15 @@ public void ShowNotification(TweetNotification notification){
} }
} }
public void ShowNotificationForSettings(bool resetAnimation){ public void ShowNotificationForSettings(bool reset){
if (browser.Address == "about:blank"){ if (browser.Address == "about:blank"){
browser.Load("about:blank"); // required, otherwise shit breaks browser.Load("about:blank"); // required, otherwise shit breaks
browser.LoadHtml(TweetNotification.ExampleTweet.GenerateHtml(),"http://tweetdeck.twitter.com/"); reset = true;
resetAnimation = true;
} }
if (reset){
browser.LoadHtml(TweetNotification.ExampleTweet.GenerateHtml(),"http://tweetdeck.twitter.com/");
if (resetAnimation){
totalTime = timeLeft = TweetNotification.ExampleTweet.GetDisplayDuration(Program.UserConfig.NotificationDuration); totalTime = timeLeft = TweetNotification.ExampleTweet.GetDisplayDuration(Program.UserConfig.NotificationDuration);
timerProgress.Start(); timerProgress.Start();
} }

View File

@ -70,7 +70,7 @@ public int GetDisplayDuration(Duration modifier){
public string GenerateHtml(){ public string GenerateHtml(){
StringBuilder build = new StringBuilder(); StringBuilder build = new StringBuilder();
build.Append("<!DOCTYPE html>"); build.Append("<!DOCTYPE html>");
build.Append("<html class='os-windows ").Append(FontSizeClass).Append("'>"); build.Append("<html class='os-windows txt-base-").Append(FontSizeClass).Append("'>");
build.Append("<head>").Append(HeadTag).Append("</head>"); build.Append("<head>").Append(HeadTag).Append("</head>");
build.Append("<body class='hearty'><div class='app-columns-container'><div class='column' style='width:100%'>"); build.Append("<body class='hearty'><div class='app-columns-container'><div class='column' style='width:100%'>");
build.Append(html); build.Append(html);

View File

@ -9,11 +9,6 @@
// //
var isInitialized = false; var isInitialized = false;
//
// Variable: Previous font size class in the <html> tag.
//
var prevFontSizeClass;
// //
// Function: Initializes TweetD*ck events. Called after the website app is loaded. // Function: Initializes TweetD*ck events. Called after the website app is loaded.
// //
@ -67,6 +62,7 @@
}; };
// Finish init // Finish init
$TD.loadFontSizeClass(TD.settings.getFontSize());
isInitialized = true; isInitialized = true;
}; };
@ -192,16 +188,8 @@
// //
// Block: Observe changes in <html> class to update font size. // Block: Observe changes in <html> class to update font size.
// //
new MutationObserver(function(mutations){ TD.settings.setFontSize = extendFunction(TD.settings.setFontSize,function(name){
var fsClass = getFontSizeClass(); $TD.loadFontSizeClass(name);
if (fsClass != prevFontSizeClass){
prevFontSizeClass = fsClass;
$TD.loadFontSizeClass(fsClass);
}
}).observe(document.documentElement,{
attributes: true,
attributeFilter: [ "class" ]
}); });
// //