зеркало из https://github.com/mozilla/gecko-dev.git
Bug #312940 -> prototype for the next generation alert notification.
still a work in progress sr=bienvenu
This commit is contained in:
Родитель
5bf68bb4b2
Коммит
d7bc7d9b23
|
@ -166,6 +166,11 @@ dummy.usesMailWidgets {
|
|||
-moz-binding: url("chrome://messenger/content/mailWidgets.xml#folderSummary-popup");
|
||||
}
|
||||
|
||||
folderSummary
|
||||
{
|
||||
-moz-binding: url("chrome://messenger/content/mailWidgets.xml#folderSummary");
|
||||
}
|
||||
|
||||
folderSummaryMessage
|
||||
{
|
||||
-moz-binding: url("chrome://messenger/content/mailWidgets.xml#folderSummary-message");
|
||||
|
|
|
@ -0,0 +1,147 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Scott MacGregor <mscott@mozilla.org>
|
||||
* Jens Bannmann <jens.b@web.de>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
var gFinalHeight = 60;
|
||||
var gSlideIncrement = 1;
|
||||
var gSlideTime = 10;
|
||||
var gOpenTime = 3000; // total time the alert should stay up once we are done animating.
|
||||
var gAlertCookie = "";
|
||||
var gAlertListener = null;
|
||||
|
||||
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
|
||||
|
||||
gAlertListener = window.arguments[1];
|
||||
|
||||
// walk the array of folders with new mail.
|
||||
var foldersWithNewMail = window.arguments[0];
|
||||
// for now just grab the first folder which should be a root folder
|
||||
// for the account that has new mail.
|
||||
var rootFolder = foldersWithNewMail.GetElementAt(0).QueryInterface(Components.interfaces.nsIWeakReference).QueryReferent(Components.interfaces.nsIMsgFolder);
|
||||
|
||||
// generate an account label string based on the root folder
|
||||
var label = document.getElementById('alertTitle');
|
||||
var totalNumNewMessages = rootFolder.getNumNewMessages(true);
|
||||
label.value = document.getElementById('bundle_messenger').getFormattedString(totalNumNewMessages == 1 ? "newBiffNotification_message" : "newBiffNotification_messages",
|
||||
[rootFolder.prettiestName, totalNumNewMessages]);
|
||||
|
||||
// this is really the root folder and we have to walk through the list to find the real folder that has new mail in it...:(
|
||||
var allFolders = Components.classes["@mozilla.org/supports-array;1"].createInstance(Components.interfaces.nsISupportsArray);
|
||||
rootFolder.ListDescendents(allFolders);
|
||||
var numFolders = allFolders.Count();
|
||||
var folderSummaryInfoEl = document.getElementById('folderSummaryInfo');
|
||||
for (var folderIndex = 0; folderIndex < numFolders; folderIndex++)
|
||||
{
|
||||
var folder = allFolders.GetElementAt(folderIndex).QueryInterface(Components.interfaces.nsIMsgFolder);
|
||||
if (folder.getNumNewMessages(false /* no deep search */))
|
||||
folderSummaryInfoEl.parseFolder(folder);
|
||||
}
|
||||
}
|
||||
|
||||
function onAlertLoad()
|
||||
{
|
||||
// this delay is required because the folder summary element
|
||||
// ends up dynamically creating an arbitrary number of folderSummaryMessage xbl widgets
|
||||
// and we have to fire a timeout to wait for the various properties and methods on the folderSummaryMessage widget
|
||||
// before we can actually initialize it. Because of that timeout, we don't know the total width of the alert
|
||||
// dialog when onAlertLoad is called, so we have to delay again. This work around in turn causes the alert to flash up in the middle
|
||||
// of your window for a second until onDelayAlertLoad gets called and moves the window to the right position.
|
||||
setTimeout(onDelayAlertLoad, 0);
|
||||
}
|
||||
|
||||
function onDelayAlertLoad()
|
||||
{
|
||||
// read out our initial settings from prefs.
|
||||
try
|
||||
{
|
||||
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) {}
|
||||
|
||||
sizeToContent();
|
||||
|
||||
gFinalHeight = window.outerHeight;
|
||||
|
||||
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);
|
||||
|
||||
setTimeout(animateAlert, gSlideTime);
|
||||
}
|
||||
|
||||
function animateAlert()
|
||||
{
|
||||
if (window.outerHeight < gFinalHeight)
|
||||
{
|
||||
window.screenY -= gSlideIncrement;
|
||||
window.outerHeight += gSlideIncrement;
|
||||
setTimeout(animateAlert, gSlideTime);
|
||||
}
|
||||
else
|
||||
setTimeout(closeAlert, gOpenTime);
|
||||
}
|
||||
|
||||
function closeAlert()
|
||||
{
|
||||
if (window.outerHeight > 1)
|
||||
{
|
||||
window.screenY += gSlideIncrement;
|
||||
window.outerHeight -= gSlideIncrement;
|
||||
setTimeout(closeAlert, gSlideTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gAlertListener)
|
||||
gAlertListener.observe(null, "alertfinished", gAlertCookie);
|
||||
window.close();
|
||||
}
|
||||
}
|
||||
|
||||
function onAlertClick()
|
||||
{
|
||||
if (gAlertListener && gAlertTextClickable)
|
||||
gAlertListener.observe(null, "alertclickcallback", gAlertCookie);
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is Thunderbird New Mail Alert.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Scott MacGregor.
|
||||
# Portions created by the Initial Developer are Copyright (C) 2005
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Scott MacGregor <mscott@mozilla.org>
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
<?xml-stylesheet href="chrome://messenger/skin/newmailalert.css" type="text/css"?>
|
||||
|
||||
<window id="newMailAlertNotification"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
windowtype="alert:alert"
|
||||
xmlns:xhtml2="http://www.w3.org/TR/xhtml2"
|
||||
xmlns:wairole="http://www.w3.org/2005/01/wai-rdf/GUIRoleTaxonomy#"
|
||||
xhtml2:role="wairole:alert"
|
||||
align="start"
|
||||
onload="onAlertLoad()">
|
||||
|
||||
<stringbundle id="bundle_messenger" src="chrome://messenger/locale/messenger.properties"/>
|
||||
<script type="application/x-javascript" src="chrome://messenger/content/newmailalert.js"/>
|
||||
|
||||
<hbox id="alertBox" class="alertBox">
|
||||
|
||||
<hbox class="alertImageBox" align="center" valign="center">
|
||||
<image id="alertImage"/>
|
||||
</hbox>
|
||||
|
||||
<vbox id="alertTextBox" class="alertTextBox">
|
||||
<label id="alertTitle" class="alertTitle"/>
|
||||
<separator class="groove"/>
|
||||
<folderSummary id="folderSummaryInfo"/>
|
||||
</vbox>
|
||||
</hbox>
|
||||
|
||||
<!-- This method is called inline because we want to make sure we establish the width
|
||||
and height of the alert before we fire the onload handler. -->
|
||||
<script type="application/x-javascript">prefillAlertInfo();</script>
|
||||
</window>
|
||||
|
|
@ -48,6 +48,8 @@ messenger.jar:
|
|||
content/messenger/startpage-gecko-rtl.png (content/startpage-gecko-rtl.png)
|
||||
content/messenger/messenger.css (content/messenger.css)
|
||||
* content/messenger/search.xml (content/search.xml)
|
||||
* content/messenger/newmailalert.xul (content/newmailalert.xul)
|
||||
content/messenger/newmailalert.js (content/newmailalert.js)
|
||||
#ifdef MOZ_USE_GENERIC_BRANDING
|
||||
% content branding %content/branding/ xpcnativewrappers=yes
|
||||
content/branding/about-credits.png (content/about-credits.png)
|
||||
|
|
|
@ -325,6 +325,10 @@ senderSearchCriteria=Subject or Sender contains:
|
|||
biffNotification_message=has %1$S new message
|
||||
biffNotification_messages=has %1$S new messages
|
||||
|
||||
# LOCALIZATION NOTES(biffNotification): %1$S is the name of the account %2$S is the number of new messages
|
||||
newBiffNotification_message=%1$S has %2$S new message
|
||||
newBiffNotification_messages=%1$S has %2$S new messages
|
||||
|
||||
# For the Quota tab in the mail folder properties dialog
|
||||
quotaUsedFree=%S of %S KB used
|
||||
quotaPercentUsed=%S%% full
|
||||
|
|
|
@ -24,7 +24,8 @@ classic.jar:
|
|||
skin/classic/messenger/searchDialog.css
|
||||
skin/classic/messenger/msgSelectOffline.css
|
||||
skin/classic/messenger/filterDialog.css
|
||||
skin/classic/messenger/dialogs.css
|
||||
skin/classic/messenger/dialogs.css
|
||||
skin/classic/messenger/newmailalert.css
|
||||
skin/classic/messenger/addressbook/addressbook.css (addrbook/addressbook.css)
|
||||
skin/classic/messenger/addressbook/abContactsPanel.css (addrbook/abContactsPanel.css)
|
||||
skin/classic/messenger/addressbook/cardDialog.css (addrbook/cardDialog.css)
|
||||
|
|
|
@ -0,0 +1,102 @@
|
|||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is new mail alert CSS.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* The Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Scott MacGregor <mscott@mozilla.org>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ****** */
|
||||
|
||||
/* ===== alert.css =====================================================
|
||||
== Styles specific to the alerts dialog.
|
||||
======================================================================= */
|
||||
|
||||
@import url("chrome://messenger/skin/");
|
||||
|
||||
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
|
||||
|
||||
#newMailAlertNotification
|
||||
{
|
||||
min-height: 60px;
|
||||
border: ridge #5486DA 4px;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
#alertImage {
|
||||
list-style-image: url("chrome://branding/content/icon64.png");
|
||||
}
|
||||
|
||||
.alertImageBox
|
||||
{
|
||||
-moz-margin-start: 4px;
|
||||
-moz-margin-end: 6px;
|
||||
min-height: 46px;
|
||||
}
|
||||
|
||||
.alertTitle
|
||||
{
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.alertText
|
||||
{
|
||||
-moz-margin-end: 6px;
|
||||
}
|
||||
|
||||
.alertText[clickable="true"]
|
||||
{
|
||||
cursor: pointer;
|
||||
color: #1455D6;
|
||||
}
|
||||
|
||||
.alertText[clickable="true"]:hover:active
|
||||
{
|
||||
color: #424F63;
|
||||
}
|
||||
|
||||
.alertTextBox
|
||||
{
|
||||
-moz-padding-end: 10px;
|
||||
padding-top: 5px;
|
||||
}
|
||||
|
||||
.folderSummary-subject {
|
||||
max-width: 300px;
|
||||
padding-left: 5px;
|
||||
}
|
||||
|
||||
.folderSummary-previewText {
|
||||
color: grey;
|
||||
max-width: 400px;
|
||||
padding-left: 5px;
|
||||
}
|
|
@ -55,7 +55,7 @@
|
|||
#include "nsDirectoryServiceDefs.h"
|
||||
#include "nsAppDirectoryServiceDefs.h"
|
||||
#include "nsIDirectoryService.h"
|
||||
|
||||
#include "nsIWindowWatcher.h"
|
||||
#include "nsIWindowMediator.h"
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
|
@ -93,7 +93,7 @@
|
|||
#define MAIL_COMMANDLINE_ARG " -mail"
|
||||
#define IDI_MAILBIFF 101
|
||||
#define UNREAD_UPDATE_INTERVAL (20 * 1000) // 20 seconds
|
||||
|
||||
#define ALERT_CHROME_URL "chrome://messenger/content/newmailalert.xul"
|
||||
#define NEW_MAIL_ALERT_ICON "chrome://messenger/skin/icons/new-mail-alert.png"
|
||||
#define SHOW_ALERT_PREF "mail.biff.show_alert"
|
||||
|
||||
|
@ -466,6 +466,32 @@ nsresult nsMessengerWinIntegration::ShowAlertMessage(const PRUnichar * aAlertTit
|
|||
|
||||
if (showAlert)
|
||||
{
|
||||
#if 0
|
||||
nsCOMPtr<nsISupportsArray> argsArray;
|
||||
rv = NS_NewISupportsArray(getter_AddRefs(argsArray));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// pass in the array of folders with unread messages
|
||||
nsCOMPtr<nsISupportsInterfacePointer> ifptr = do_CreateInstance(NS_SUPPORTS_INTERFACE_POINTER_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
ifptr->SetData(mFoldersWithNewMail);
|
||||
ifptr->SetDataIID(&NS_GET_IID(nsISupportsArray));
|
||||
argsArray->AppendElement(ifptr);
|
||||
|
||||
ifptr = do_CreateInstance(NS_SUPPORTS_INTERFACE_POINTER_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr <nsISupports> supports = do_QueryInterface(NS_STATIC_CAST(nsIMessengerOSIntegration*, this));
|
||||
ifptr->SetData(supports);
|
||||
ifptr->SetDataIID(&NS_GET_IID(nsIObserver));
|
||||
argsArray->AppendElement(ifptr);
|
||||
|
||||
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID));
|
||||
nsCOMPtr<nsIDOMWindow> newWindow;
|
||||
rv = wwatch->OpenWindow(0, ALERT_CHROME_URL, "_blank",
|
||||
"chrome,dialog=yes,titlebar=no,popup=yes", argsArray,
|
||||
getter_AddRefs(newWindow));
|
||||
mAlertInProgress = PR_TRUE;
|
||||
#else
|
||||
nsCOMPtr<nsIAlertsService> alertsService (do_GetService(NS_ALERTSERVICE_CONTRACTID, &rv));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
|
@ -474,6 +500,7 @@ nsresult nsMessengerWinIntegration::ShowAlertMessage(const PRUnichar * aAlertTit
|
|||
NS_ConvertASCIItoUCS2(aFolderURI), this);
|
||||
mAlertInProgress = PR_TRUE;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!showAlert || NS_FAILED(rv)) // go straight to showing the system tray icon.
|
||||
|
|
Загрузка…
Ссылка в новой задаче