Bug 330523 --> replace animated scrolling with a fade in / fade out effect for the new mail alert notification. sr=bienvenu

This commit is contained in:
scott%scott-macgregor.org 2006-03-15 01:17:53 +00:00
Родитель f814fd1ca7
Коммит cd7679909f
5 изменённых файлов: 55 добавлений и 67 удалений

Просмотреть файл

@ -451,11 +451,9 @@ pref("bidi.numeral", 1);
pref("browser.throbber.url","chrome://navigator-region/locale/region.properties");
// pref to control the alert notification
pref("alerts.slideIncrement", 1);
pref("alerts.slideIncrementTime", 10);
pref("alerts.totalOpenTime", 4000);
pref("alerts.height", 50);
// prefs to control the mail alert notification
pref("alerts.slideIncrementTime", 50);
pref("alerts.totalOpenTime", 3000);
// 0 opens the download manager
// 1 opens a progress dialog

Просмотреть файл

@ -36,26 +36,24 @@
*
* ***** END LICENSE BLOCK ***** */
var gFinalHeight = 60;
var gSlideIncrement = 1;
var gSlideTime = 10;
var gSlideTime = 50;
var gNumNewMsgsToShowInAlert = 4; // the more messages we show in the alert, the larger it will be
var gOpenTime = 3000; // total time the alert should stay up once we are done animating.
var gAlertCookie = "";
var gAlertListener = null;
var gPendingPreviewFetchRequests = 0;
var gAnimateOnOpen = true;
var gUserInitiated = false;
var gFadeIncrement = .05;
function prefillAlertInfo()
{
// unwrap all the args....
// arguments[0] --> array of folders with new mail
// arguments[1] --> the observer to call back with notifications about the alert
// arguments[2] --> animation boolean. Set to true if we should animate the alert, false
// if we should open the alert and leave it open until the user closes it.
// arguments[2] --> user initiated boolean. true if the user initiated opening the alert
// (which means skip the fade effect and don't auto close the alert)
var foldersWithNewMail = window.arguments[0];
gAlertListener = window.arguments[1];
gAnimateOnOpen = window.arguments[2];
gUserInitiated = window.arguments[2];
// for now just grab the first folder which should be a root folder
// for the account that has new mail.
@ -118,14 +116,12 @@ function onAlertLoad()
var prefService = Components.classes["@mozilla.org/preferences-service;1"].getService();
prefService = prefService.QueryInterface(Components.interfaces.nsIPrefService);
var prefBranch = prefService.getBranch(null);
gSlideIncrement = prefBranch.getIntPref("alerts.slideIncrement");
gSlideTime = prefBranch.getIntPref("alerts.slideIncrementTime");
gOpenTime = prefBranch.getIntPref("alerts.totalOpenTime");
} catch (ex) {}
// we need to still do this so the alert gets
// moved off screen until we are ready for it.
resizeAlert();
// bogus call to make sure the window is moved offscreen until we are ready for it.
resizeAlert(true);
// if we aren't waiting to fetch preview text, then go ahead and
// start showing the alert.
@ -134,28 +130,26 @@ function onAlertLoad()
// a chance to recompute the styles and widths for our alert text.
}
// helper routine which kicks off the animated alert if we have messages
// in our folder summary info object. Otherwise we turn around and just close the alert.
// If the user initiated the alert, show it right away, otherwise start opening the alert with
// the fade effect.
function showAlert()
{
resizeAlert();
if (!gUserInitiated) // set the initial opacity before we resize the window
document.getElementById('alertContainer').style.opacity = 0;
// resize the alert based on our current content
resizeAlert(false);
if (document.getElementById('folderSummaryInfo').hasMessages)
{
if (gAnimateOnOpen)
setTimeout(animateOpen, gSlideTime);
else
{
// restore the alert to its full height so we can open it right away.
window.outerHeight = gFinalHeight;
// now move the alert back to a visible location...
window.moveTo( (screen.availLeft + screen.availWidth - window.outerWidth) - 10, screen.availTop + screen.availHeight - window.outerHeight);
}
if (!gUserInitiated) // don't fade in if the user opened the alert
setTimeout(fadeOpen, gSlideTime);
}
else
animateClose();
closeAlert(); // no mail, so don't bother showing the alert...
}
function resizeAlert()
function resizeAlert(aMoveOffScreen)
{
// sizeToContent is not working. It isn't honoring the max widths we are attaching to our inner
// objects like the folder summary element. While the folder summary element is cropping,
@ -170,46 +164,42 @@ function resizeAlert()
document.getBoxObjectFor(document.getElementById('folderSummaryInfo')).width);
resizeTo(windowWidth + document.getBoxObjectFor(document.getElementById('alertImageBox')).width + 30,
document.getBoxObjectFor(document.getElementById('alertBox')).height + 10);
gFinalHeight = window.outerHeight;
window.outerHeight = 1;
// leftover hack to get the window properly hidden when we first open it
if (aMoveOffScreen)
window.outerHeight = 1;
// be sure to offset the alert by 10 pixels from the far right edge of the screen
window.moveTo( (screen.availLeft + screen.availWidth - window.outerWidth) - 10, screen.availTop + screen.availHeight - window.outerHeight);
}
function animateOpen()
function fadeOpen()
{
if (window.outerHeight < gFinalHeight)
{
window.screenY -= gSlideIncrement;
window.outerHeight += gSlideIncrement;
setTimeout(animateOpen, gSlideTime);
}
else
setTimeout(animateClose, gOpenTime);
var alertContainer = document.getElementById('alertContainer');
var newOpacity = parseFloat(window.getComputedStyle(alertContainer, "").opacity) + gFadeIncrement;
alertContainer.style.opacity = newOpacity;
if (newOpacity < 1.0)
setTimeout(fadeOpen, gSlideTime);
else // switch gears and start closing the alert
setTimeout(fadeClose, gOpenTime);
}
function animateClose()
function fadeClose()
{
if (window.outerHeight > 1)
{
window.screenY += gSlideIncrement;
window.outerHeight -= gSlideIncrement;
setTimeout(animateClose, gSlideTime);
}
else
var alertContainer = document.getElementById('alertContainer');
var newOpacity = parseFloat(window.getComputedStyle(alertContainer, "").opacity) - gFadeIncrement;
alertContainer.style.opacity = newOpacity;
if (newOpacity <= 0)
closeAlert();
else
setTimeout(fadeClose, gSlideTime);
}
function closeAlert()
{
if (gAlertListener)
gAlertListener.observe(null, "alertfinished", gAlertCookie);
gAlertListener.observe(null, "alertfinished", "");
window.close();
}
function onAlertClick()
{
if (gAlertListener && gAlertTextClickable)
gAlertListener.observe(null, "alertclickcallback", gAlertCookie);
}

Просмотреть файл

@ -51,7 +51,7 @@
<script type="application/x-javascript" src="chrome://messenger/content/newmailalert.js"/>
<stack>
<stack id="alertContainer">
<hbox id="alertBox">
<hbox id ="alertImageBox" align="center" valign="center">
<image id="alertImage"/>

Просмотреть файл

@ -187,7 +187,7 @@ static void CALLBACK delayedSingleClick(HWND msgWindow, UINT msg, INT_PTR idEven
// we know we are dealing with the windows integration object
nsMessengerWinIntegration * winIntegrationService = NS_STATIC_CAST(nsMessengerWinIntegration*,
NS_STATIC_CAST(nsIMessengerOSIntegration*, integrationService.get()));
winIntegrationService->ShowNewAlertNotification(PR_FALSE);
winIntegrationService->ShowNewAlertNotification(PR_TRUE);
}
#endif
}
@ -513,9 +513,9 @@ nsresult nsMessengerWinIntegration::ShowAlertMessage(const PRUnichar * aAlertTit
}
#else
// Opening Thunderbird's new mail alert notification window
// aUseAnimation --> true if the window should be opened with animation, false if we want to
// just open the window and leave it open until the user closes it.
nsresult nsMessengerWinIntegration::ShowNewAlertNotification(PRBool aUseAnimation)
// aUserInitiated --> true if we are opening the alert notification in response to a user action
// like clicking on the biff icon
nsresult nsMessengerWinIntegration::ShowNewAlertNotification(PRBool aUserInitiated)
{
nsresult rv;
@ -551,10 +551,10 @@ nsresult nsMessengerWinIntegration::ShowNewAlertNotification(PRBool aUseAnimatio
argsArray->AppendElement(ifptr);
// pass in the animation flag
nsCOMPtr<nsISupportsPRBool> scriptableUseAnimation (do_CreateInstance(NS_SUPPORTS_PRBOOL_CONTRACTID, &rv));
nsCOMPtr<nsISupportsPRBool> scriptableUserInitiated (do_CreateInstance(NS_SUPPORTS_PRBOOL_CONTRACTID, &rv));
NS_ENSURE_SUCCESS(rv, rv);
scriptableUseAnimation->SetData(aUseAnimation);
argsArray->AppendElement(scriptableUseAnimation);
scriptableUserInitiated->SetData(aUserInitiated);
argsArray->AppendElement(scriptableUserInitiated);
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID));
nsCOMPtr<nsIDOMWindow> newWindow;
@ -681,7 +681,7 @@ void nsMessengerWinIntegration::FillToolTipInfo()
#ifndef MOZ_THUNDERBIRD
ShowAlertMessage(accountName, animatedAlertText.get(), "");
#else
ShowNewAlertNotification(PR_TRUE);
ShowNewAlertNotification(PR_FALSE);
#endif
}
else

Просмотреть файл

@ -86,7 +86,7 @@ public:
NS_DECL_NSIOBSERVER
#ifdef MOZ_THUNDERBIRD
nsresult ShowNewAlertNotification(PRBool aAnimateAlert);
nsresult ShowNewAlertNotification(PRBool aUserInitiated);
#endif
private: