michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: %notificationDTD; michael@0: ]> michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: 1 michael@0: 2 michael@0: 3 michael@0: 4 michael@0: 5 michael@0: 6 michael@0: 7 michael@0: 8 michael@0: 9 michael@0: 10 michael@0: michael@0: null michael@0: michael@0: null michael@0: null michael@0: false michael@0: michael@0: michael@0: michael@0: if (val) michael@0: this.setAttribute('notificationshidden', true); michael@0: else this.removeAttribute('notificationshidden'); michael@0: return val; michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: = 0; n--) { michael@0: if (aValue == notifications[n].getAttribute("value")) michael@0: return notifications[n]; michael@0: } michael@0: return null; michael@0: ]]> michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: this.PRIORITY_CRITICAL_BLOCK) michael@0: throw "Invalid notification priority " + aPriority; michael@0: michael@0: // check for where the notification should be inserted according to michael@0: // priority. If two are equal, the existing one appears on top. michael@0: var notifications = this.allNotifications; michael@0: var insertPos = null; michael@0: for (var n = notifications.length - 1; n >= 0; n--) { michael@0: if (notifications[n].priority < aPriority) michael@0: break; michael@0: insertPos = notifications[n]; michael@0: } michael@0: michael@0: const XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; michael@0: var newitem = document.createElementNS(XULNS, "notification"); michael@0: newitem.setAttribute("label", aLabel); michael@0: newitem.setAttribute("value", aValue); michael@0: if (aImage) michael@0: newitem.setAttribute("image", aImage); michael@0: newitem.eventCallback = aEventCallback; michael@0: michael@0: if (aButtons) { michael@0: // The notification-button-default class is added to the button michael@0: // with isDefault set to true. If there is no such button, it is michael@0: // added to the first button (unless that button has isDefault michael@0: // set to false). There cannot be multiple default buttons. michael@0: var defaultElem; michael@0: michael@0: for (var b = 0; b < aButtons.length; b++) { michael@0: var button = aButtons[b]; michael@0: var buttonElem = document.createElementNS(XULNS, "button"); michael@0: buttonElem.setAttribute("label", button.label); michael@0: buttonElem.setAttribute("accesskey", button.accessKey); michael@0: buttonElem.classList.add("notification-button"); michael@0: michael@0: if (button.isDefault || michael@0: b == 0 && !("isDefault" in button)) michael@0: defaultElem = buttonElem; michael@0: michael@0: newitem.appendChild(buttonElem); michael@0: buttonElem.buttonInfo = button; michael@0: } michael@0: michael@0: if (defaultElem) michael@0: defaultElem.classList.add("notification-button-default"); michael@0: } michael@0: michael@0: newitem.setAttribute("priority", aPriority); michael@0: if (aPriority >= this.PRIORITY_CRITICAL_LOW) michael@0: newitem.setAttribute("type", "critical"); michael@0: else if (aPriority <= this.PRIORITY_INFO_HIGH) michael@0: newitem.setAttribute("type", "info"); michael@0: else michael@0: newitem.setAttribute("type", "warning"); michael@0: michael@0: if (!insertPos) { michael@0: newitem.style.position = "fixed"; michael@0: newitem.style.top = "100%"; michael@0: newitem.style.marginTop = "-15px"; michael@0: newitem.style.opacity = "0"; michael@0: } michael@0: this.insertBefore(newitem, insertPos); michael@0: if (!insertPos) michael@0: this._showNotification(newitem, true); michael@0: michael@0: // Fire event for accessibility APIs michael@0: var event = document.createEvent("Events"); michael@0: event.initEvent("AlertActive", true, true); michael@0: newitem.dispatchEvent(event); michael@0: michael@0: return newitem; michael@0: ]]> michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: = 0; n--) { michael@0: if (aImmediate) michael@0: this._removeNotificationElement(notifications[n]); michael@0: else michael@0: this.removeNotification(notifications[n]); michael@0: } michael@0: this.currentNotification = null; michael@0: michael@0: // Must clear up any currently animating notification michael@0: if (aImmediate) michael@0: this._finishAnimation(); michael@0: ]]> michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: = 0; n--) { michael@0: var notification = notifications[n]; michael@0: if (notification.persistence) michael@0: notification.persistence--; michael@0: else if (Date.now() > notification.timeout) michael@0: this.removeNotification(notification); michael@0: } michael@0: ]]> michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: = 0) ? notifications[idx] : null; michael@0: michael@0: if (skipAnimation) { michael@0: this._removeNotificationElement(this._closedNotification); michael@0: this._closedNotification = null; michael@0: this._setBlockingState(this.currentNotification); michael@0: return; michael@0: } michael@0: michael@0: aNotification.style.marginTop = -height + "px"; michael@0: aNotification.style.opacity = 0; michael@0: } michael@0: michael@0: this._animating = true; michael@0: ]]> michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: 0 michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: &learnMore; michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: document.getAnonymousElementByAttribute(this, "anonid", "closebutton"); michael@0: michael@0: michael@0: document.getAnonymousElementByAttribute(this, "anonid", "button"); michael@0: michael@0: michael@0: document.getAnonymousElementByAttribute(this, "anonid", "menupopup"); michael@0: michael@0: michael@0: michael@0: