Fix #1189 notifications display is broken

This commit is contained in:
Nicolas Le Goff
2013-05-30 18:58:05 +02:00
parent e4516c39cb
commit 53cafa7117
4 changed files with 12 additions and 13 deletions

View File

@@ -103,9 +103,9 @@ class Notifications implements ControllerProviderInterface
$app->abort(400);
}
$page = (int) $request->query->get('page', 1);
$page = (int) $request->query->get('page', 0);
return $app->json($app['events-manager']->get_json_notifications(($page < 1 ? 1 : $page)));
return $app->json($app['events-manager']->get_notifications_as_array(($page < 0 ? 0 : $page)));
}
/**

View File

@@ -111,7 +111,7 @@ class eventsmanager_broker
return true;
}
public function get_json_notifications($page = 0)
public function get_notifications_as_array($page = 0)
{
$unread = 0;
$total = 0;
@@ -178,7 +178,7 @@ class eventsmanager_broker
$data['next'] = '<a href="#" onclick="print_notifications(' . ((int) $page + 1) . ');return false;">' . _('charger d\'avantages de notifications') . '</a>';
}
return p4string::jsonencode($data);
return $data;
}
public function get_unread_notifications_number()

View File

@@ -135,11 +135,6 @@
</span>
</a>
</li>
<div style="display:none;z-index:30000;" id="notification_box">
{% set notifications = app['events-manager'].get_notifications %}
{% include 'prod/notifications.html.twig' %}
</div>
{% endif %}
<li>
{% if app['authentication'].isAuthenticated() %}
@@ -194,8 +189,12 @@
{% endif %}
</li>
</ol>
</div>
</div>
{% if app['authentication'].isAuthenticated() and (module == "client" or module == "prod") %}
<div style="display:none;z-index:30000;" id="notification_box">
{% set notifications = app['events-manager'].get_notifications %}
{% include 'prod/notifications.html.twig' %}
</div>
{% endif %}

View File

@@ -129,7 +129,7 @@ function set_notif_position()
if(trigger.length === 0)
return;
$('#notification_box').css({
'left':Math.round(trigger.offset().left)
'left':Math.round(trigger.offset().left - 1)
});
}
$(window).bind('resize', function(){
@@ -173,7 +173,7 @@ function print_notifications(page)
$.ajax({
type: "POST",
type: "GET",
url: "/user/notifications/",
dataType : 'json',
data: {