* 'log' - (boolean) Enable logging.
* 'noalerts' - (string) The localized string to display when no log entries
* are present.
+ * 'info' - (string) The localized string to display as an information message
+ * at the top of the log.
*
* Custom Events:
* --------------
* Fired on TODO
* params: NONE
*
+ * Growler:toggled
+ * Fired on toggling of the backlog
+ * params: The state after the toggling
+ *
*
* Growler has been tested with Safari 3(Mac|Win), Firefox 3(Mac|Win), IE6,
* IE7, and Opera.
growlerOptions = {
location: 'tr',
log: false,
- noalerts: 'No Alerts'
+ noalerts: 'No Alerts',
+ info: 'This is the notification backlog'
},
IE6 = Prototype.Browser.IE
initialize: function(opts)
{
var ch, cw, sl, st;
- opts = Object.extend(Object.clone(growlerOptions), opts || {});
+ this.opts = Object.extend(Object.clone(growlerOptions), opts || {});
this.growler = new Element('DIV', { id: 'Growler' }).setStyle({ position: IE6 ? 'absolute' : 'fixed', padding: '10px', zIndex: 50000 }).hide();
cw = '0 - this.offsetWidth + ( document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body.clientWidth )';
sl = '( document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft )';
st = '( document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop )';
- } else if (opts.log) {
- this.growlerlog = new Element('DIV', { id: 'GrowlerLog' }).insert(new Element('DIV').hide().insert(new Element('UL').insert(new Element('LI', { className: 'NoAlerts' }).insert(opts.noalerts))));
+ } else if (this.opts.log) {
+ var logExit = new Element('DIV', { className: 'GrowlerNoticeExit' }).update("×");
+ logExit.observe('click', this.toggleLog.bind(this));
+ this.growlerlog = new Element('DIV', { id: 'GrowlerLog' })
+ .insert(new Element('DIV').hide()
+ .insert(new Element('UL')
+ .insert(new Element('LI', { className: 'GrowlerInfo' })
+ .insert(this.opts.info)
+ .insert(logExit))
+ .insert(new Element('LI', { className: 'GrowlerNoAlerts' })
+ .insert(this.opts.noalerts))));
$(document.body).insert(this.growlerlog);
}
- switch (opts.location) {
+ switch (this.opts.location) {
case 'br':
if (IE6) {
this.growler.style.setExpression('left', "( " + cw + " + " + sl + " ) + 'px'");
if (opts.log && this.growlerlog) {
tmp = this.growlerlog.down('DIV UL');
- if (tmp.down().hasClassName('NoAlerts')) {
+ if (tmp.down().hasClassName('GrowlerNoAlerts')) {
tmp.down().remove();
}
- log = new Element('LI', { className: opts.className.empty() ? null : opts.className }).insert(msg).insert(new Element('SPAN', { className: 'alertdate'} ).insert('[' + (new Date).toLocaleString() + ']'));
+ log = new Element('LI', { className: opts.className.empty() ? null : opts.className }).insert(msg).insert(new Element('SPAN', { className: 'GrowlerAlertDate'} ).insert('[' + (new Date).toLocaleString() + ']'));
logExit = new Element('DIV', { className: 'GrowlerNoticeExit' }).update("×");
logExit.observe('click', removeLog.curry(log));
log.insert(logExit);
}
});
this.logvisible = !this.logvisible;
+ this.growlerlog.fire('Growler:toggled', { visible: this.logvisible });
return this.logvisible;
},
logSize: function()
{
- return (this.growlerlog && this.growlerlog.down('.NoAlerts'))
+ return (this.growlerlog && this.growlerlog.down('.GrowlerNoAlerts'))
? 0
: this.growlerlog.down('UL').childElements().size();
}
#GrowlerLog ul li:last-child {
border: 0;
}
-#GrowlerLog li.NoAlerts {
+#GrowlerLog li.GrowlerInfo {
font-weight: bold;
background: #999;
}
-#GrowlerLog span.alertdate {
+#GrowlerLog li.GrowlerNoAlerts {
+ background: #999;
+}
+#GrowlerLog span.GrowlerAlertDate {
font-size: 90%;
font-style: italic;
padding-left: 10px;
case 'alertsloglink':
DimpCore.Growler.toggleLog();
- $('alertsloglink').down('A').update(DimpCore.Growler.logVisible() ? DIMP.text.hidealog : DIMP.text.showalog);
break;
case 'applyfilterlink':
this.Growler = new Growler({
location: 'br',
log: this.growler_log,
- noalerts: DIMP.text.noalerts
+ noalerts: DIMP.text.noalerts,
+ info: DIMP.text.growlerinfo
});
+ this.Growler.growlerlog.observe('Growler:toggled', function(e) {
+ $('alertsloglink')
+ .down('A')
+ .update(e.memo.visible ? DIMP.text.hidealog : DIMP.text.showalog);
+ }.bindAsEventListener(this));
/* Add click handler. */
document.observe('click', DimpCore.clickHandler.bindAsEventListener(DimpCore));
'createsub_prompt' => _("Create subfolder:"),
'delete_folder' => _("Permanently delete %s?"),
'empty_folder' => _("Permanently delete all messages in %s?"),
+ 'growlerinfo' => _("This is the notification backlog"),
'hidealog' => Horde::highlightAccessKey(_("Hide Alerts _Log"), Horde::getAccessKey(_("Alerts _Log"), true)),
'listmsg_wait' => _("The server is still generating the message list."),
'listmsg_timeout' => _("The server was unable to generate the message list."),
break;
case 'kronolithNotifications':
- var img = elt.down('img'), iconName;
- if (this.Growler.toggleLog()) {
- elt.title = Kronolith.text.hidelog;
- elt.addClassName('kronolithClose');
- } else {
- elt.title = Kronolith.text.alerts.interpolate({ count: this.growls });
- elt.removeClassName('kronolithClose');
- }
- Horde_ToolTips.detach(elt);
- Horde_ToolTips.attach(elt);
+ this.Growler.toggleLog();
break;
case 'kronolithEventDialog':
this.Growler = new Growler({
log: true,
location: 'br',
- noalerts: Kronolith.text.noalerts
+ noalerts: Kronolith.text.noalerts,
+ info: Kronolith.text.growlerinfo,
});
+ this.Growler.growlerlog.observe('Growler:toggled', function(e) {
+ var button = $('kronolithNotifications');
+ if (e.memo.visible) {
+ button.title = Kronolith.text.hidelog;
+ button.addClassName('kronolithClose');
+ } else {
+ button.title = Kronolith.text.alerts.interpolate({ count: this.growls });
+ button.removeClassName('kronolithClose');
+ }
+ Horde_ToolTips.detach(button);
+ Horde_ToolTips.attach(button);
+ }.bindAsEventListener(this));
if (Kronolith.conf.is_ie6) {
/* Disable text selection in preview pane for IE 6. */
'noalerts' => _("No Notifications"),
'alerts' => sprintf(_("%s notifications"), '#{count}'),
'hidelog' => _("Hide Notifications"),
+ 'growlerinfo' => _("This is the notification backlog"),
'agenda' => _("Agenda"),
'searching' => sprintf(_("Events matching \"%s\""), '#{term}'),
'allday' => _("All day"),