From: Jan Schneider Date: Tue, 2 Mar 2010 22:59:20 +0000 (+0100) Subject: Fix displaying the url to the alarm's object. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=193cdc9e9ad5a4710f3dbb6ebae70d1f3df54efe;p=horde.git Fix displaying the url to the alarm's object. Hide alarm notification if clicking the object link. Add a separate button for dismissing the alarm. --- diff --git a/kronolith/js/kronolith.js b/kronolith/js/kronolith.js index 99f5bab3f..61df8f58c 100644 --- a/kronolith/js/kronolith.js +++ b/kronolith/js/kronolith.js @@ -131,29 +131,36 @@ KronolithCore = { case 'horde.alarm': var alarm = m.flags.alarm; // Only show one instance of an alarm growl. - if (this.alarms.indexOf(alarm.id) != -1) { + if (this.alarms.include(alarm.id)) { break; } this.alarms.push(alarm.id); message = alarm.title.escapeHTML(); - if (!Object.isUndefined(alarm.ajax)) { - message = new Element('a') - .insert(message) - .observe('click', function() { this.go(alarm.ajax); }.bind(this)); - } else if (!Object.isUndefined(alarm.url)) { - message = new Element('a', { href: alarm.url }) - .insert(message); + if (!Object.isUndefined(alarm.params) && + !Object.isUndefined(alarm.params.notify)) { + if (!Object.isUndefined(alarm.params.notify.ajax)) { + message = new Element('a') + .insert(message) + .observe('click', function() { + this.Growler.ungrowl(growl); + this.go(alarm.params.notify.ajax); + }.bind(this)); + } else if (!Object.isUndefined(alarm.params.notify.url)) { + message = new Element('a', { href: alarm.params.notify.url }) + .insert(message); + } } message = new Element('div') .insert(message); if (alarm.user) { - var select = new Element('select'); - $H(Kronolith.conf.snooze).each(function(snooze) { - select.insert(new Element('option', { value: snooze.key }).insert(snooze.value)); - }); - message.insert(' ').insert(select); + var select = ''; + message.insert('

' + Kronolith.text.snooze.interpolate({ time: select, dismiss_start: '' })); } var growl = this.Growler.growl(message, { className: 'horde-alarm', @@ -171,15 +178,22 @@ KronolithCore = { }.bindAsEventListener(this)); if (alarm.user) { - select.observe('change', function() { - if (select.getValue()) { + message.down('select').observe('change', function(e) { + if (e.element().getValue()) { this.Growler.ungrowl(growl); new Ajax.Request( Kronolith.conf.URI_SNOOZE, { parameters: { alarm: alarm.id, - snooze: select.getValue() } }); + snooze: e.element().getValue() } }); } - }.bind(this)); + }.bindAsEventListener(this)); + message.down('input[type=button]').observe('click', function(e) { + this.Growler.ungrowl(growl); + new Ajax.Request( + Kronolith.conf.URI_SNOOZE, + { parameters: { alarm: alarm.id, + snooze: -1 } }); + }.bindAsEventListener(this)); } break; @@ -3680,6 +3694,25 @@ KronolithCore = { this.setTitle(ev.t); RedBox.showHtml($('kronolithEventDialog').show()); + + /* Hide alarm message for this event. */ + if (r.msgs) { + r.msgs = r.msgs.reject(function(msg) { + if (msg.type != 'horde.alarm') { + return false; + } + var alarm = msg.flags.alarm; + if (alarm.params && alarm.params.notify && + alarm.params.notify.show && + alarm.params.notify.show.calendar && + alarm.params.notify.show.event && + alarm.params.notify.show.calendar == ev.c && + alarm.params.notify.show.event == ev.id) { + return true; + } + return false; + }); + } }, /** diff --git a/kronolith/lib/Ajax/Application.php b/kronolith/lib/Ajax/Application.php index a97830638..69dd03330 100644 --- a/kronolith/lib/Ajax/Application.php +++ b/kronolith/lib/Ajax/Application.php @@ -415,6 +415,7 @@ class Kronolith_Ajax_Application extends Horde_Ajax_Application_Base */ public function ListTopTags() { + $this->notify = false; $tagger = new Kronolith_Tagger(); $result = new stdClass; $result->tags = array(); diff --git a/kronolith/lib/Event.php b/kronolith/lib/Event.php index 650311480..bff33cac4 100644 --- a/kronolith/lib/Event.php +++ b/kronolith/lib/Event.php @@ -1128,6 +1128,7 @@ abstract class Kronolith_Event '__app' => $GLOBALS['registry']->getApp(), 'event' => $this->id, 'calendar' => $this->calendar); + $methods['notify']['ajax'] = 'event:' . $this->calendarType . '|' . $this->calendar . ':' . $this->id . ':' . $start->dateString(); if (!empty($methods['notify']['sound'])) { if ($methods['notify']['sound'] == 'on') { // Handle boolean sound preferences. diff --git a/kronolith/lib/Kronolith.php b/kronolith/lib/Kronolith.php index 33efecfec..413d4f9fa 100644 --- a/kronolith/lib/Kronolith.php +++ b/kronolith/lib/Kronolith.php @@ -216,8 +216,7 @@ class Kronolith Horde_Date_Recurrence::RECUR_YEARLY_DATE => 'Yearly', Horde_Date_Recurrence::RECUR_YEARLY_DAY => 'Yearly', Horde_Date_Recurrence::RECUR_YEARLY_WEEKDAY => 'Yearly'), - 'snooze' => array('0' => _("Snooze..."), - '-1' => _("Dismiss"), + 'snooze' => array('0' => _("select..."), '5' => _("5 minutes"), '15' => _("15 minutes"), '60' => _("1 hour"), @@ -328,6 +327,7 @@ class Kronolith 'ajax_timeout' => _("There has been no contact with the calendar server for several minutes. The server may be temporarily unavailable or network problems may be interrupting your session. You will not see any updates until the connection is restored."), 'ajax_recover' => _("The connection to the calendar server has been restored."), 'alarm' => _("Alarm:"), + 'snooze' => sprintf(_("You can snooze it for %s or %s dismiss %s it entirely"), '#{time}', '#{dismiss_start}', '#{dismiss_end}'), 'noalerts' => _("No Notifications"), 'alerts' => sprintf(_("%s notifications"), '#{count}'), 'hidelog' => _("Hide Notifications"),