Browse Source

- Rewrite + comment Notifs widget

- Fix a CSS error for Webkit browsers
- Add Notification item removing support
pull/16/head
Jaussoin Timothée 13 years ago
parent
commit
d12e8c8c00
  1. 3
      system/RPC.php
  2. 70
      system/Widget/widgets/Notifs/Notifs.php
  3. 14
      system/Widget/widgets/Notifs/notifs.css
  4. 4
      system/Widget/widgets/Profile/profile.css
  5. 2
      system/Widget/widgets/Vcard/vcard.js

3
system/RPC.php

@ -79,9 +79,6 @@ class RPC
println('</funcall>');
}
println('</movimcontainer>');
$xml = ob_get_flush();
file_put_contents('debug', $xml . "\n" . var_export(self::$funcalls, true));
}
/**

70
system/Widget/widgets/Notifs/Notifs.php

@ -25,32 +25,48 @@ class Notifs extends WidgetCommon
$this->addcss('notifs.css');
$this->addjs('notifs.js');
$this->registerEvent('notification', 'onNotification');
$this->registerEvent('notificationdelete', 'onNotificationDelete');
$this->registerEvent('notifications', 'displayNotifications');
$this->registerEvent('nonotification', 'onNoNotification');
}
/*
* Retrieve all the notifications
*/
function ajaxGetNotifications() {
$p = new moxl\NotificationGet();
$p->setTo($this->user->getLogin())
->request();
}
/*
* Delete a notification item
*/
function ajaxDeleteNotification($id) {
$d = new moxl\NotificationItemDelete();
$d->setTo($this->user->getLogin())
->setId($id)
->request();
}
/*
* Create the notification element from the inbox item
* @param SimpleXMLElement $item
*/
function onNotification($item) {
$arr = explodeURI((string)$item->entry->link[0]->attributes()->href);
$post = end(explode('/', $arr['node']));
$notifs = Cache::c('activenotifs');
$html = '';
foreach($notifs as $key => $value)
$html .= $this->prepareNotifs($key, $value);
$explodedurn = explodeURI((string)$item->entry->link[0]->attributes()->href);
$id = end(explode('/', $explodedurn['node']));
$request = $this->genCallAjax(
"ajaxGetComments",
"'".$this->user->getLogin()."'",
"'".$id."'");
"'".$post."'");
$delete = $this->genCallAjax(
"ajaxDeleteNotification",
"'".(string)$item->attributes()->id."'");
$nhtml = '
@ -62,20 +78,48 @@ class Notifs extends WidgetCommon
</span> - '.prepareDate(strtotime((string)$item->entry->published)).'<br />'.
(string)$item->entry->content.'
</a>
<a class="delete" href="#" onclick="'.$delete.'">'.t('Delete').'</a>
<div class="clear"></div>
</li>
';
$notifs[(string)$item->attributes()->id] = $nhtml;
RPC::call('movim_fill', 'notifs', RPC::cdata($html));
Cache::c('activenotifs', $notifs);
}
/*
* In notification deletion
* @param string $id
*/
function onNotificationDelete($id) {
$notifs = Cache::c('activenotifs');
unset($notifs[$id]);
Cache::c('activenotifs', $notifs);
RPC::call('movim_fill', 'notifs', RPC::cdata($this->prepareNotifs()));
}
/*
* Display all the notifications to the browser
*/
function displayNotifications() {
RPC::call('movim_fill', 'notifs', RPC::cdata($this->prepareNotifs()));
}
/*
* Display all the notifications to the browser if there is no new
* notifications
*/
function onNoNotification() {
RPC::call('movim_fill', 'notifs', RPC::cdata($this->prepareNotifs()));
}
/*
* Create the list of notifications
* @return string
*/
function prepareNotifs()
{
$notifsnum = 0;
@ -211,6 +255,10 @@ class Notifs extends WidgetCommon
RPC::commit();
}
/*
* Prepare a notification for incoming invitation
* @return string
*/
function prepareNotifInvitation($from) {
$html .= '
<li>

14
system/Widget/widgets/Notifs/notifs.css

@ -52,6 +52,7 @@
overflow: hidden;
border: 1px solid rgba(0, 0, 0, 0.5);
max-height: 400px;
width: 300px;
overflow-y: auto;
overflow-x: hidden;
}
@ -80,8 +81,7 @@
padding: 5px;
line-height: 28px;
width: 100%;
width: 250px;
/*max-height: 56px;*/
display: block;
border-top: 1px solid #333;
}
@ -101,6 +101,7 @@
padding: 0px 8px;
border-radius: 3px;
margin-left: 10px;
margin-right: 10px;
}
#notifslist ul li:hover {
@ -142,6 +143,15 @@ display: none;
display: block;
}
#notifslist ul li a.delete {
float: right;
margin-right: 10px;
}
#notifslist ul li a.delete:hover {
text-decoration: underline;
}
#notifslist ul li:hover a {
color: black;
}

4
system/Widget/widgets/Profile/profile.css

@ -1 +1,3 @@
#profile textarea#status {
overflow: hidden;
}

2
system/Widget/widgets/Vcard/vcard.js

@ -37,7 +37,7 @@ function vCardImageResize(img) {
canvas.style.width = 200;
canvas.style.height = 200;
var base64 = canvas.toDataURL('image/jpeg', 0.8);
var base64 = canvas.toDataURL('image/jpeg', 0.9);
var bin = base64.split(",");
document.querySelector('#vCardPhotoPreview').src = base64;
document.querySelector('input[name="phototype"]').value = 'image/jpeg';

Loading…
Cancel
Save