Bug 268590, add notification widget, r=mconnor

git-svn-id: svn://10.0.0.236/trunk@194704 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
enndeakin%sympatico.ca
2006-04-19 20:50:25 +00:00
parent 996051e745
commit a5e6be5064
12 changed files with 559 additions and 429 deletions

View File

@@ -328,9 +328,24 @@ const gPopupBlockerObserver = {
else
message = bundle_browser.getFormattedString("popupWarning", [brandShortName]);
gBrowser.showMessage(gBrowser.selectedBrowser, "chrome://browser/skin/Info.png",
message, popupButtonText, null, null, "blockedPopupOptions",
"top", true, popupButtonAccesskey);
var notificationBox = gBrowser.getNotificationBox();
var notification = notificationBox.getNotificationWithValue("popup-blocked");
if (notification) {
notification.label = message;
}
else {
var buttons = [{
label: popupButtonText,
accessKey: popupButtonAccesskey,
popup: "blockedPopupOptions",
callback: null
}];
const priority = notificationBox.PRIORITY_WARNING_MEDIUM;
notificationBox.appendNotification(message, "popup-blocked",
"chrome://browser/skin/Info.png",
priority, buttons);
}
}
}
else
@@ -346,7 +361,7 @@ const gPopupBlockerObserver = {
var perm = shouldBlock ? this._kIPM.DENY_ACTION : this._kIPM.ALLOW_ACTION;
pm.add(currentURI, "popup", perm);
gBrowser.hideMessage(null, "top");
gBrowser.getNotificationBox().removeCurrentNotification();
},
fillPopupList: function (aEvent)
@@ -515,7 +530,7 @@ const gPopupBlockerObserver = {
gPrefService.setBoolPref("privacy.popups.showBrowserMessage", !showMessage);
gBrowser.hideMessage(null, "top");
gBrowser.getNotificationBox().removeCurrentNotification();
},
_displayPageReportFirstTime: function ()
@@ -564,82 +579,86 @@ const gXPInstallObserver = {
if (browser) {
var host = browser.docShell.QueryInterface(Components.interfaces.nsIWebNavigation).currentURI.host;
var brandShortName = brandBundle.getString("brandShortName");
var iconURL, messageKey, buttonKey, buttonAccesskeyKey;
if (aData == "install-chrome") {
var notificationName, messageString, buttons;
if (!gPrefService.getBoolPref("xpinstall.enabled")) {
notificationName = "xpinstall-disabled"
if (gPrefService.prefIsLocked("xpinstall.enabled")) {
messageString = browserBundle.getString("xpinstallDisabledMessageLocked");
buttons = [];
}
else {
messageString = browserBundle.getFormattedString("xpinstallDisabledMessage",
[brandShortName, host]);
buttons = [{
label: browserBundle.getString("xpinstallDisabledButton"),
accessKey: browserBundle.getString("xpinstallDisabledButton.accesskey"),
popup: null,
callback: function editPrefs() {
gPrefService.setBoolPref("xpinstall.enabled", true);
return false;
}
}];
}
}
else {
// XXXben - use regular software install warnings for now until we can
// properly differentiate themes. It's likely in fact that themes won't
// be blocked so this code path will only be reached for extensions.
iconURL = "chrome://mozapps/skin/xpinstall/xpinstallItemGeneric.png";
messageKey = "xpinstallWarning";
buttonKey = "xpinstallWarningButton";
buttonAccesskeyKey = "xpinstallWarningButton.accesskey";
}
else {
iconURL = "chrome://mozapps/skin/xpinstall/xpinstallItemGeneric.png";
messageKey = "xpinstallWarning";
buttonKey = "xpinstallWarningButton";
buttonAccesskeyKey = "xpinstallWarningButton.accesskey";
}
var messageString, buttonString, buttonAccesskeyString;
if (!gPrefService.getBoolPref("xpinstall.enabled")) {
if (gPrefService.prefIsLocked("xpinstall.enabled")) {
messageString = browserBundle.getString("xpinstallDisabledMessageLocked");
buttonString = ""; // don't show the button
}
else {
messageString = browserBundle.getString("xpinstallDisabledMessage");
buttonString = browserBundle.getString("xpinstallDisabledButton");
buttonAccesskeyString = browserBundle.getString("xpinstallDisabledButton.accesskey");
}
getBrowser().showMessage(browser, iconURL, messageString, buttonString,
null, "xpinstall-install-edit-prefs",
null, "top", true, buttonAccesskeyString);
}
else {
messageString = browserBundle.getFormattedString(messageKey, [brandShortName, host]);
buttonString = browserBundle.getString(buttonKey);
buttonAccesskeyString = browserBundle.getString(buttonAccesskeyKey);
webNav = shell.QueryInterface(Components.interfaces.nsIWebNavigation);
getBrowser().showMessage(browser, iconURL, messageString, buttonString,
shell, "xpinstall-install-edit-permissions",
null, "top", false, buttonAccesskeyString);
}
}
break;
case "xpinstall-install-edit-prefs":
gPrefService.setBoolPref("xpinstall.enabled", true);
getBrowser().hideMessage(null, "top");
break;
case "xpinstall-install-edit-permissions":
browser = this._getBrowser(aSubject.QueryInterface(Components.interfaces.nsIDocShell));
if (browser) {
var bundlePreferences = document.getElementById("bundle_preferences");
webNav = aSubject.QueryInterface(Components.interfaces.nsIWebNavigation);
var params = { blockVisible : false,
sessionVisible : false,
allowVisible : true,
prefilledHost : webNav.currentURI.host,
permissionType : "install",
windowTitle : bundlePreferences.getString("installpermissionstitle"),
introText : bundlePreferences.getString("installpermissionstext") };
wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator);
var existingWindow = wm.getMostRecentWindow("Browser:Permissions");
if (existingWindow) {
existingWindow.initWithParams(params);
existingWindow.focus();
}
else
window.openDialog("chrome://browser/content/preferences/permissions.xul",
"_blank", "resizable,dialog=no,centerscreen", params);
notificationName = "xpinstall"
messageString = browserBundle.getFormattedString("xpinstallWarning",
[brandShortName, host]);
getBrowser().hideMessage(null, "top");
buttons = [{
label: browserBundle.getString("xpinstallWarningButton"),
accessKey: browserBundle.getString("xpinstallWarningButton.accesskey"),
popup: null,
callback: function() { return xpinstallEditPermissions(browser.docShell); }
}];
}
var notificationBox = gBrowser.getNotificationBox(browser);
if (!notificationBox.getNotificationWithValue(notificationName)) {
const priority = notificationBox.PRIORITY_WARNING_MEDIUM;
const iconURL = "chrome://mozapps/skin/xpinstall/xpinstallItemGeneric.png";
notificationBox.appendNotification(messageString, notificationName,
iconURL, priority, buttons);
}
}
break;
}
}
};
function xpinstallEditPermissions(aDocShell)
{
var browser = gXPInstallObserver._getBrowser(aDocShell);
if (browser) {
var bundlePreferences = document.getElementById("bundle_preferences");
var webNav = aDocShell.QueryInterface(Components.interfaces.nsIWebNavigation);
var params = { blockVisible : false,
sessionVisible : false,
allowVisible : true,
prefilledHost : webNav.currentURI.host,
permissionType : "install",
windowTitle : bundlePreferences.getString("installpermissionstitle"),
introText : bundlePreferences.getString("installpermissionstext") };
wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator);
var existingWindow = wm.getMostRecentWindow("Browser:Permissions");
if (existingWindow) {
existingWindow.initWithParams(params);
existingWindow.focus();
}
else
window.openDialog("chrome://browser/content/preferences/permissions.xul",
"_blank", "resizable,dialog=no,centerscreen", params);
return false;
}
return true;
}
function BrowserStartup()
{
gBrowser = document.getElementById("content");
@@ -846,9 +865,6 @@ function delayedStartup()
var os = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
os.addObserver(gSessionHistoryObserver, "browser:purge-session-history", false);
os.addObserver(gXPInstallObserver, "xpinstall-install-blocked", false);
os.addObserver(gXPInstallObserver, "xpinstall-install-edit-prefs", false);
os.addObserver(gXPInstallObserver, "xpinstall-install-edit-permissions", false);
os.addObserver(gMissingPluginInstaller, "missing-plugin", false);
if (!gPrefService)
gPrefService = Components.classes["@mozilla.org/preferences-service;1"]
@@ -1007,9 +1023,6 @@ function BrowserShutdown()
.getService(Components.interfaces.nsIObserverService);
os.removeObserver(gSessionHistoryObserver, "browser:purge-session-history");
os.removeObserver(gXPInstallObserver, "xpinstall-install-blocked");
os.removeObserver(gXPInstallObserver, "xpinstall-install-edit-permissions");
os.removeObserver(gXPInstallObserver, "xpinstall-install-edit-prefs");
os.removeObserver(gMissingPluginInstaller, "missing-plugin");
try {
gBrowser.removeProgressListener(window.XULBrowserWindow);
@@ -2443,9 +2456,9 @@ function toggleAffectedChrome(aHide)
gChromeState.sidebarOpen = !sidebar.hidden;
gSidebarCommand = sidebar.getAttribute("sidebarcommand");
var message = gBrowser.getMessageForBrowser(gBrowser.selectedBrowser, "top");
gChromeState.messageOpen = !message.hidden;
message.hidden = aHide;
var notificationBox = gBrowser.getNotificationBox();
gChromeState.notificationsOpen = !notificationBox.notificationsHidden;
notificationBox.notificationsHidden = aHide;
var statusbar = document.getElementById("status-bar");
gChromeState.statusbarOpen = !statusbar.hidden;
@@ -2456,9 +2469,8 @@ function toggleAffectedChrome(aHide)
gFindBar.closeFindBar();
}
else {
if (gChromeState.messageOpen) {
var message = gBrowser.getMessageForBrowser(gBrowser.selectedBrowser, "top");
message.hidden = aHide;
if (gChromeState.notificationsOpen) {
gBrowser.getNotificationBox().notificationsHidden = aHide;
}
if (gChromeState.statusbarOpen) {
@@ -3523,7 +3535,7 @@ nsBrowserStatusHandler.prototype =
if (newIndexOfHash != -1)
newSpec = newSpec.substr(0, newSpec.indexOf("#"));
if (newSpec != oldSpec) {
getBrowser().hideMessage(null, "both");
gBrowser.getNotificationBox(selectedBrowser).removeAllNotifications(true);
}
}
selectedBrowser.lastURI = aLocation;
@@ -6003,7 +6015,8 @@ missingPluginInstaller.prototype.installSinglePlugin = function(aEvent){
if (missingPluginsArray) {
window.openDialog("chrome://mozapps/content/plugins/pluginInstallerWizard.xul",
"PFSWindow", "modal,chrome,resizable=yes", {plugins: missingPluginsArray, tab: tabbrowser.mCurrentTab});
"PFSWindow", "modal,chrome,resizable=yes",
{plugins: missingPluginsArray, tab: tabbrowser.mCurrentTab});
}
aEvent.preventDefault();
@@ -6049,32 +6062,35 @@ missingPluginInstaller.prototype.newMissingPlugin = function(aEvent){
tab.missingPlugins[pluginInfo.mimetype] = pluginInfo;
var browser = tabbrowser.getBrowserAtIndex(i);
var iconURL = "chrome://mozapps/skin/xpinstall/xpinstallItemGeneric.png";
var notificationBox = gBrowser.getNotificationBox(browser);
if (!notificationBox.getNotificationWithValue("missing-plugins")) {
var bundle_browser = document.getElementById("bundle_browser");
var messageString = bundle_browser.getString("missingpluginsMessage.title");
var buttons = [{
label: bundle_browser.getString("missingpluginsMessage.button.label"),
accessKey: bundle_browser.getString("missingpluginsMessage.button.accesskey"),
popup: null,
callback: pluginsMissing
}];
var bundle_browser = document.getElementById("bundle_browser");
var messageString = bundle_browser.getString("missingpluginsMessage.title");
var buttonString = bundle_browser.getString("missingpluginsMessage.button.label");
var buttonAccesskeyString = bundle_browser.getString("missingpluginsMessage.button.accesskey");
tabbrowser.showMessage(browser, iconURL, messageString, buttonString,"",
"missing-plugin", null, "top", true, buttonAccesskeyString);
}
missingPluginInstaller.prototype.observe = function(aSubject, aTopic, aData){
switch (aTopic) {
case "missing-plugin":
// get the urls of missing plugins
var tabbrowser = getBrowser();
var missingPluginsArray = tabbrowser.mCurrentTab.missingPlugins;
if (missingPluginsArray) {
window.openDialog("chrome://mozapps/content/plugins/pluginInstallerWizard.xul",
"PFSWindow", "modal,chrome,resizable=yes", {plugins: missingPluginsArray, tab: tabbrowser.mCurrentTab});
}
break;
const priority = notificationBox.PRIORITY_WARNING_MEDIUM;
const iconURL = "chrome://mozapps/skin/xpinstall/xpinstallItemGeneric.png";
notificationBox.appendNotification(messageString, "missing-plugins",
iconURL, priority, buttons);
}
}
function pluginsMissing()
{
// get the urls of missing plugins
var tabbrowser = getBrowser();
var missingPluginsArray = tabbrowser.mCurrentTab.missingPlugins;
if (missingPluginsArray) {
window.openDialog("chrome://mozapps/content/plugins/pluginInstallerWizard.xul",
"PFSWindow", "modal,chrome,resizable=yes", {plugins: missingPluginsArray, tab: tabbrowser.mCurrentTab});
}
}
var gMissingPluginInstaller = new missingPluginInstaller();
function convertFromUnicode(charset, str)

View File

@@ -878,30 +878,6 @@ tabpanels.plain {
background-color: #fff !important;
}
browsermessage {
background-color: #E6E6E6;
border: 1px solid #C8C8C8;
-moz-border-radius: 7px;
margin: 6px;
padding: 4px;
font: icon;
color: #505050;
}
.messageImage {
margin: 0px 6px 0px 2px;
}
.messageText {
margin: 0px 0px 0px 1px;
}
.messageButton {
font-weight: normal;
color: #000;
margin: 0px 4px 0px 8px;
}
#places-bookmark {
list-style-image: url("chrome://browser/skin/places/bookmarksToolbar.png");
}

View File

@@ -48,6 +48,7 @@ toolkit.jar:
*+ content/global/bindings/menu.xml (widgets/menu.xml)
*+ content/global/bindings/menulist.xml (widgets/menulist.xml)
*+ content/global/bindings/nativescrollbar.xml (widgets/nativescrollbar.xml)
*+ content/global/bindings/notification.xml (widgets/notification.xml)
*+ content/global/bindings/popup.xml (widgets/popup.xml)
*+ content/global/bindings/preferences.xml (widgets/preferences.xml)
*+ content/global/bindings/progressmeter.xml (widgets/progressmeter.xml)

View File

@@ -919,184 +919,5 @@
</handlers>
</binding>
<binding id="browsermessage" extends="xul:hbox">
<content align="center">
<xul:hbox align="center" flex="1">
<xul:image anonid="messageImage" class="messageImage"/>
<xul:description anonid="messageText" class="messageText" flex="1"/>
</xul:hbox>
<xul:button anonid="messageButton" class="messageButton"/>
<xul:spacer class="tabs-right"/>
<xul:hbox hidden="true" anonid="messageClose" class="tabs-closebutton-box"
align="center" pack="end">
<xul:toolbarbutton ondblclick="event.stopPropagation();"
class="tabs-closebutton close-button"
oncommand="this.parentNode.parentNode.hide();"/>
</xul:hbox>
</content>
<implementation implements="nsIAccessibleProvider">
<property name="accessible">
<getter>
<![CDATA[
var accService = Components.classes["@mozilla.org/accessibilityService;1"].getService(Components.interfaces.nsIAccessibilityService);
return accService.createXULAlertAccessible(this);
]]>
</getter>
</property>
<property name="type" onget="return this.getAttribute('type');"
onset="this.setAttribute('type', val); return val;"/>
<field name="_imageElement">
document.getAnonymousElementByAttribute(this, "anonid", "messageImage");
</field>
<property name="image">
<getter>
<![CDATA[
return this._imageElement.getAttribute("src");
]]>
</getter>
<setter>
<![CDATA[
this._imageElement.setAttribute("src", val);
return val;
]]>
</setter>
</property>
<field name="docShell">
null;
</field>
<field name="source">
"";
</field>
<field name="_popup">
"";
</field>
<property name="popup">
<setter>
<![CDATA[
this._popup = val;
// store scope
var myThis = this;
var lambda = function (event) {myThis.showPopup(event);}
if (val) {
document.getAnonymousElementByAttribute(this, "anonid", "messageButton").addEventListener("command", lambda, false);
} else {
document.getAnonymousElementByAttribute(this, "anonid", "messageButton").removeEventListener("command", lambda, false);
}
return val;
]]>
</setter>
<getter>
<![CDATA[
return this._popup;
]]>
</getter>
</property>
<field name="_textElement">
document.getAnonymousElementByAttribute(this, "anonid", "messageText");
</field>
<field name="_text">
"";
</field>
<property name="text">
<getter>
<![CDATA[
return this._text;
]]>
</getter>
<setter>
<![CDATA[
this._text = val;
while (this._textElement.hasChildNodes())
this._textElement.removeChild(this._textElement.firstChild);
this._textElement.appendChild(document.createTextNode(val));
return val;
]]>
</setter>
</property>
<field name="_buttonElement">
document.getAnonymousElementByAttribute(this, "anonid", "messageButton");
</field>
<property name="buttonText">
<getter>
<![CDATA[
return this._buttonElement.label;
]]>
</getter>
<setter>
<![CDATA[
if (val != "") {
this._buttonElement.removeAttribute("style");
this._buttonElement.label = val;
}
else
this._buttonElement.setAttribute("style", "max-width: 1px; visibility: hidden;");
return val;
]]>
</setter>
</property>
<property name="buttonAccesskey">
<getter>
<![CDATA[
return this._buttonElement.getAttribute("accesskey");
]]>
</getter>
<setter>
<![CDATA[
this._buttonElement.setAttribute("accesskey", val);
return val;
]]>
</setter>
</property>
<property name="closeButton">
<getter>
<![CDATA[
return document.getAnonymousElementByAttribute(this, "anonid", "messageClose");
]]>
</getter>
<setter>
<![CDATA[
var elm = document.getAnonymousElementByAttribute(this, "anonid", "messageClose");
elm.hidden = !val;
return val;
]]>
</setter>
</property>
<method name="hide">
<body>
<![CDATA[
this.hidden = true;
]]>
</body>
</method>
<method name="showPopup">
<parameter name="event"/>
<body>
<![CDATA[
document.getElementById(this.popup).showPopup(event.originalTarget, -1, -1, "popup", "bottomleft", "topleft");
]]>
</body>
</method>
</implementation>
<handlers>
<handler event="command">
if (event.originalTarget.getAttribute("anonid") == "messageButton") {
var os = Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService);
var subject = this.docShell ? this.docShell : null;
os.notifyObservers(subject, this.source, "");
}
</handler>
</handlers>
</binding>
</bindings>

View File

@@ -0,0 +1,321 @@
<?xml version="1.0"?>
<bindings id="notificationBindings"
xmlns="http://www.mozilla.org/xbl"
xmlns:xbl="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<binding id="notificationbox">
<content>
<xul:stack anonid="stack" class="notificationbox-stack"
xbl:inherits="hidden=notificationshidden">
<xul:spacer/>
<children includes="notification"/>
</xul:stack>
<children/>
</content>
<implementation>
<field name="PRIORITY_INFO_LOW" readonly="true">1</field>
<field name="PRIORITY_INFO_MEDIUM" readonly="true">2</field>
<field name="PRIORITY_INFO_HIGH" readonly="true">3</field>
<field name="PRIORITY_WARNING_LOW" readonly="true">4</field>
<field name="PRIORITY_WARNING_MEDIUM" readonly="true">5</field>
<field name="PRIORITY_WARNING_HIGH" readonly="true">6</field>
<field name="PRIORITY_CRITICAL_LOW" readonly="true">7</field>
<field name="PRIORITY_CRITICAL_MEDIUM" readonly="true">8</field>
<field name="PRIORITY_CRITICAL_HIGH" readonly="true">9</field>
<field name="PRIORITY_CRITICAL_BLOCK" readonly="true">10</field>
<field name="currentNotification">null</field>
<field name="slideSteps">4</field>
<field name="_timer">null</field>
<field name="_blockBox">null</field>
<property name="notificationsHidden"
onget="return this.getAttribute('notificationshidden') == 'true';">
<setter>
if (val)
this.setAttribute('notificationshidden', true);
else this.removeAttribute('notificationshidden');
</setter>
</property>
<property name="allNotifications" readonly="true"
onget="return this.getElementsByTagName('notification');"/>
<method name="getNotificationWithValue">
<parameter name="aValue"/>
<body>
<![CDATA[
var notifications = this.allNotifications;
for (var n = notifications.length - 1; n >= 0; n--) {
if (aValue == notifications[n].value)
return notifications[n];
}
return null;
]]>
</body>
</method>
<method name="appendNotification">
<parameter name="aLabel"/>
<parameter name="aValue"/>
<parameter name="aImage"/>
<parameter name="aPriority"/>
<parameter name="aButtons"/>
<body>
<![CDATA[
if (aPriority < this.PRIORITY_INFO_LOW ||
aPriority > this.PRIORITY_CRITICAL_BLOCK)
throw "Invalid notification priority " + aPriority;
// check for where the notification should be inserted according to
// priority. If two are equal, the existing one appears on top.
var notifications = this.allNotifications;
var insertPos = null;
for (n = notifications.length - 1; n >= 0; n--) {
if (notifications[n].priority < aPriority)
break;
insertPos = notifications[n];
}
const XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
var newitem = document.createElementNS(XULNS, "notification");
newitem.setAttribute("label", aLabel);
newitem.setAttribute("value", aValue);
newitem.setAttribute("image", aImage);
this.insertBefore(newitem, insertPos);
if (aButtons) {
for (var b = 0; b < aButtons.length; b++) {
var button = aButtons[b];
var buttonElem = document.createElementNS(XULNS, "button");
buttonElem.setAttribute("label", button.label);
buttonElem.setAttribute("accesskey", button.accessKey);
newitem.appendChild(buttonElem);
buttonElem.buttonInfo = button;
}
}
newitem.priority = aPriority;
if (aPriority >= this.PRIORITY_CRITICAL_LOW)
newitem.type = "critical";
else if (aPriority <= this.PRIORITY_INFO_HIGH)
newitem.type = "info";
else
newitem.type = "warning";
// Fire event for accessibility APIs
var event = document.createEvent("Events");
event.initEvent("AlertActive", true, true);
this.dispatchEvent(event);
if (!insertPos)
this._showNotification(newitem, true);
return newitem;
]]>
</body>
</method>
<method name="removeNotification">
<parameter name="aItem"/>
<body>
<![CDATA[
if (aItem == this.currentNotification)
this.removeCurrentNotification();
else
this.removeChild(aItem);
return aItem;
]]>
</body>
</method>
<method name="removeCurrentNotification">
<body>
<![CDATA[
this._showNotification(this.currentNotification, false);
return null;
]]>
</body>
</method>
<method name="removeAllNotifications">
<parameter name="aImmediate"/>
<body>
<![CDATA[
var notifications = this.allNotifications;
for (var n = notifications.length - 1; n >= 0; n--) {
if (aImmediate)
this.removeChild(notifications[n]);
else
this.removeNotification(notifications[n]);
}
this.currentNotification = null;
]]>
</body>
</method>
<method name="_showNotification">
<parameter name="aNotification"/>
<parameter name="aSlideIn"/>
<body>
<![CDATA[
var height = aNotification.boxObject.height;
var change = height / this.slideSteps;
if (aSlideIn) {
aNotification.style.marginTop = -height + "px";
aNotification.style.opacity = 0;
}
else {
change = -change;
}
opacitychange = change / height;
var self = this;
var slide = function slideInFn()
{
var done = false;
var style = window.getComputedStyle(aNotification, null);
var margin = style.getPropertyCSSValue("margin-top").
getFloatValue(CSSPrimitiveValue.CSS_PX);
if (change > 0 && margin + change >= 0) {
aNotification.style.marginTop = "0px";
aNotification.style.opacity = 1;
done = true;
}
else if (change < 0 && margin + change <= -height) {
aNotification.style.marginTop = -height + "px";
done = true;
}
else {
aNotification.style.marginTop = (margin + change) + "px";
if (opacitychange)
aNotification.style.opacity =
Number(aNotification.style.opacity) + opacitychange;
}
if (done) {
clearInterval(self._timer);
var newitem;
if (aSlideIn) {
newitem = aNotification;
}
else {
aNotification.parentNode.removeChild(aNotification);
var notifications = self.allNotifications;
var idx = notifications.length - 1;
if (idx >= 0)
newitem = notifications[idx];
}
if (newitem)
self.currentNotification = newitem;
}
}
this._timer = setInterval(slide, 50);
]]>
</body>
</method>
</implementation>
</binding>
<binding id="notification">
<content>
<xul:hbox class="notification-inner outset" flex="1" xbl:inherits="type">
<xul:hbox anonid="details" align="center" flex="1"
oncommand="this.parentNode.parentNode._doButtonCommand(event);">
<xul:image anonid="messageImage" class="messageImage" xbl:inherits="src=image"/>
<xul:description anonid="messageText" class="messageText" flex="1" xbl:inherits="xbl:text=label"/>
<xul:spacer flex="1"/>
<children/>
</xul:hbox>
<xul:toolbarbutton ondblclick="event.stopPropagation();"
class="messageCloseButton"
xbl:inherits="hidden=hideclose"
oncommand="document.getBindingParent(this).close();"/>
</xul:hbox>
</content>
<resources>
<stylesheet src="chrome://global/skin/notification.css"/>
</resources>
<implementation implements="nsIAccessibleProvider">
<property name="accessible" readonly="true">
<getter>
<![CDATA[
var accService = Components.classes["@mozilla.org/accessibilityService;1"].getService(Components.interfaces.nsIAccessibilityService);
return accService.createXULAlertAccessible(this);
]]>
</getter>
</property>
<property name="label" onset="return this.setAttribute('label', val);"
onget="return this.getAttribute('label');"/>
<property name="value" onset="return this.setAttribute('value', val);"
onget="return this.getAttribute('value');"/>
<property name="image" onset="return this.setAttribute('image', val);"
onget="return this.getAttribute('image');"/>
<property name="type" onget="return this.getAttribute('type');"
onset="this.setAttribute('type', val); return val;"/>
<property name="priority" onget="return this.getAttribute('priority');"
onset="this.setAttribute('priority', val); return val;"/>
<property name="control" readonly="true">
<getter>
<![CDATA[
var parent = this.parentNode;
while (parent) {
if (parent.localName == "notificationbox")
return parent;
parent = parent.parentNode;
}
return null;
]]>
</getter>
</property>
<method name="close">
<body>
<![CDATA[
var control = this.control;
if (control)
control.removeNotification(this);
else
this.hidden = true;
]]>
</body>
</method>
<method name="_doButtonCommand">
<parameter name="aEvent"/>
<body>
<![CDATA[
if (!("buttonInfo" in aEvent.target))
return;
var button = aEvent.target.buttonInfo;
if (button.popup) {
document.getElementById(button.popup).
showPopup(aEvent.originalTarget, -1, -1, "popup", "bottomleft", "topleft");
aEvent.stopPropagation();
}
else {
var callback = button.callback;
if (callback) {
var result = callback(this, button);
if (!result)
this.close();
aEvent.stopPropagation();
}
}
]]>
</body>
</method>
</implementation>
</binding>
</bindings>

View File

@@ -111,11 +111,10 @@
</xul:tabs>
</xul:hbox>
<xul:tabpanels flex="1" class="plain" selectedIndex="0" anonid="panelcontainer">
<xul:vbox flex="1">
<xul:browsermessage hidden="true" type="top"/>
<xul:browser flex="1" type="content-primary" message="true" disablehistory="true" xbl:inherits="tooltip=contenttooltip,contextmenu=contentcontextmenu,autocompletepopup"/>
<xul:browsermessage hidden="true" type="bottom"/>
</xul:vbox>
<xul:notificationbox flex="1">
<xul:browser flex="1" type="content-primary" message="true" disablehistory="true"
xbl:inherits="tooltip=contenttooltip,contextmenu=contentcontextmenu,autocompletepopup"/>
</xul:notificationbox>
</xul:tabpanels>
</xul:tabbox>
<children/>
@@ -215,68 +214,15 @@
</body>
</method>
<method name="getMessageForBrowser">
<method name="getNotificationBox">
<parameter name="aBrowser"/>
<parameter name="aTopBottom"/>
<body>
<![CDATA[
return aBrowser[aTopBottom == "top" ? "previousSibling" : "nextSibling"];
]]>
</body>
</method>
<method name="showMessage">
<parameter name="aBrowser"/>
<parameter name="aIconURL"/>
<parameter name="aMessage"/>
<parameter name="aButtonLabel"/>
<parameter name="aDocShell"/>
<parameter name="aSource"/>
<parameter name="aPopup"/>
<parameter name="aTopBottom"/>
<parameter name="aShowCloseButton"/>
<parameter name="aButtonAccesskey"/>
<body>
<![CDATA[
var message = this.getMessageForBrowser(aBrowser, aTopBottom);
message.image = aIconURL;
message.text = aMessage;
message.buttonText = aButtonLabel;
message.buttonAccesskey =
typeof(aButtonAccesskey) == "undefined" ? ""
: aButtonAccesskey;
message.hidden = false;
if (aSource) {
message.source = aSource;
message.popup = null;
}
else if (aPopup) {
message.popup = aPopup;
message.source = null;
}
message.docShell = aDocShell;
message.closeButton = aShowCloseButton;
aBrowser.isShowingMessage = true;
// Fire event for accessibility APIs
var event = document.createEvent("Events");
event.initEvent("AlertActive", true, true);
message.dispatchEvent(event);
]]>
</body>
</method>
<method name="hideMessage">
<parameter name="aBrowser"/>
<parameter name="aTopBottom"/>
<body>
<![CDATA[
var browser = aBrowser || this.mCurrentBrowser;
if (aTopBottom != "both")
this.getMessageForBrowser(browser, aTopBottom).hidden = true;
else {
this.getMessageForBrowser(browser, "top").hidden = true;
this.getMessageForBrowser(browser, "bottom").hidden = true;
}
if (aBrowser)
return aBrowser.parentNode;
else if (this.mCurrentBrowser)
return this.mCurrentBrowser.parentNode;
return null;
]]>
</body>
</method>
@@ -897,7 +843,7 @@
var i = 0;
for ( ; i < this.parentNode.parentNode.childNodes.length; i++) {
if (this.parentNode.parentNode.childNodes[i].firstChild.nextSibling == this)
if (this.parentNode.parentNode.childNodes[i].firstChild == this)
break;
}
@@ -1037,19 +983,6 @@
</body>
</method>
<method name="_createMessage">
<parameter name="aType"/>
<body>
<![CDATA[
var message = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
"browsermessage");
message.hidden = true;
message.setAttribute("type", aType);
return message;
]]>
</body>
</method>
<method name="loadOneTab">
<parameter name="aURI"/>
<parameter name="aReferrerURI"/>
@@ -1172,14 +1105,13 @@
b.setAttribute("autocompletepopup", this.getAttribute("autocompletepopup"));
// Add the Message and the Browser to the box
var vbox = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
"vbox");
vbox.setAttribute("flex", "1");
vbox.appendChild(this._createMessage("top"));
vbox.appendChild(b);
vbox.appendChild(this._createMessage("bottom"));
var notificationbox = document.createElementNS(
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
"notificationbox");
notificationbox.setAttribute("flex", "1");
notificationbox.appendChild(b);
b.setAttribute("flex", "1");
this.mPanelContainer.appendChild(vbox);
this.mPanelContainer.appendChild(notificationbox);
b.addEventListener("DOMTitleChanged", this.onTitleChanged, false);
@@ -2213,7 +2145,7 @@
<constructor>
<![CDATA[
this.mCurrentBrowser = this.mPanelContainer.childNodes[0].firstChild.nextSibling;
this.mCurrentBrowser = this.mPanelContainer.childNodes[0].firstChild;
this.mCurrentTab = this.mTabContainer.firstChild;
document.addEventListener("keypress", this._keyEventHandler, false);
@@ -2221,7 +2153,7 @@
this.mPanelContainer.childNodes[0].id = uniqueId;
this.mTabContainer.childNodes[0].linkedPanel = uniqueId;
this.mTabContainer.childNodes[0]._tPos = 0;
this.mTabContainer.childNodes[0].linkedBrowser = this.mPanelContainer.childNodes[0].firstChild.nextSibling;
this.mTabContainer.childNodes[0].linkedBrowser = this.mPanelContainer.childNodes[0].firstChild;
]]>
</constructor>

View File

@@ -148,10 +148,6 @@ browser {
-moz-binding: url("chrome://global/content/bindings/browser.xml#browser");
}
browsermessage {
-moz-binding: url("chrome://global/content/bindings/browser.xml#browsermessage");
}
tabbrowser {
-moz-binding: url("chrome://global/content/bindings/tabbrowser.xml#tabbrowser");
}
@@ -164,6 +160,21 @@ iframe {
-moz-binding: url("chrome://global/content/bindings/general.xml#iframe");
}
/********** notifications **********/
notificationbox {
-moz-binding: url("chrome://global/content/bindings/notification.xml#notificationbox");
-moz-box-orient: vertical;
}
notification {
-moz-binding: url("chrome://global/content/bindings/notification.xml#notification");
}
.notificationbox-stack {
overflow-y: hidden;
}
/********** image **********/
image {

View File

@@ -34,6 +34,7 @@ classic.jar:
+ skin/classic/global/listbox.css
+ skin/classic/global/menu.css
+ skin/classic/global/menulist.css
+ skin/classic/global/notification.css
+ skin/classic/global/netError.css
+ skin/classic/global/popup.css
+ skin/classic/global/progressmeter.css

View File

@@ -0,0 +1,34 @@
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
notification {
background-color: InfoBackground;
color: InfoText;
}
notification[type="info"] {
background-color: -moz-Dialog;
}
notification[type="critical"] {
background-color: red;
}
.messageImage {
width: 16px;
height: 16px;
}
.messageText {
-moz-margin-start: 5px;
}
.messageButton {
margin: 0px 5px 0px 5px;
}
.messageCloseButton {
-moz-appearance: none;
padding-right: 4px;
list-style-image: url("chrome://global/skin/icons/closetab.png") !important;
border: none;
}

View File

@@ -71,33 +71,6 @@ tab {
display: -moz-box;
}
browsermessage {
background-color: InfoBackground;
color: InfoText;
padding: 3px;
}
browsermessage[type="top"] {
border-bottom: 1px solid ThreeDDarkShadow;
}
browsermessage[type="bottom"] {
border-top: 1px solid ThreeDDarkShadow;
}
.messageImage {
width: 16px;
height: 16px;
}
.messageText {
-moz-margin-start: 5px;
}
.messageButton {
margin: 0px 5px 0px 5px;
}
/**
* In-tab close button
*/

View File

@@ -20,6 +20,7 @@ classic.jar:
skin/classic/global/listbox.css
skin/classic/global/menu.css
skin/classic/global/menulist.css
skin/classic/global/notification.css
skin/classic/global/netError.css
skin/classic/global/popup.css
skin/classic/global/preferences.css

View File

@@ -0,0 +1,43 @@
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
notification {
background-color: InfoBackground;
color: InfoText;
}
notification[type="info"] {
background-color: -moz-Dialog;
}
notification[type="critical"] {
background-color: red;
}
.messageImage {
width: 16px;
height: 16px;
}
.messageText {
-moz-margin-start: 5px;
}
.messageButton {
margin: 0px 5px 0px 5px;
}
.messageCloseButton {
list-style-image: url("chrome://global/skin/icons/close.png");
-moz-appearance: none;
-moz-image-region: rect(0px, 16px, 16px, 0px);
padding: 4px 2px;
border: none !important;
}
.messageCloseButton:hover {
-moz-image-region: rect(0px, 32px, 16px, 16px);
}
.messageCloseButton:hover:active {
-moz-image-region: rect(0px, 48px, 16px, 32px);
}