Browse Source

- Add Notification widget

- Add Notification event on some widgets
- Add Attention support in Chat
pull/16/head
Jaussoin Timothée 13 years ago
parent
commit
0cf40fcd2d
  1. 1
      system/Widget/widgets/Bookmark/Bookmark.php
  2. 24
      system/Widget/widgets/Chat/Chat.php
  3. 1
      system/Widget/widgets/Config/Config.php
  4. 1
      system/Widget/widgets/ContactManage/ContactManage.php
  5. 12
      system/Widget/widgets/Feed/Feed.php
  6. 4
      system/Widget/widgets/GroupConfig/GroupConfig.php
  7. 51
      system/Widget/widgets/Notification/Notification.php
  8. BIN
      system/Widget/widgets/Notification/img/error.png
  9. BIN
      system/Widget/widgets/Notification/img/info.png
  10. BIN
      system/Widget/widgets/Notification/img/success.png
  11. BIN
      system/Widget/widgets/Notification/img/warning.png
  12. 69
      system/Widget/widgets/Notification/notification.css
  13. 4
      system/Widget/widgets/Notification/notification.js
  14. 3
      system/Widget/widgets/Profile/Profile.php
  15. 15
      system/Widget/widgets/ProfileData/ProfileData.php
  16. 1
      system/Widget/widgets/Roster/Roster.php
  17. 14
      system/Widget/widgets/ServerNodes/ServerNodes.php
  18. 1
      system/Widget/widgets/Vcard/Vcard.php
  19. 2
      themes/movim/css/forms.css
  20. 1
      themes/movim/page.tpl

1
system/Widget/widgets/Bookmark/Bookmark.php

@ -69,6 +69,7 @@ class Bookmark extends WidgetBase
Cache::c('bookmark', $arr);
$html = $this->prepareBookmark($arr);
RPC::call('movim_fill', 'bookmarks', $html);
Notification::appendNotification(t('Bookmarks updated'), 'info');
}
function ajaxGetBookmark()

24
system/Widget/widgets/Chat/Chat.php

@ -27,9 +27,8 @@ class Chat extends WidgetBase
$this->registerEvent('message', 'onMessage');
$this->registerEvent('composing', 'onComposing');
$this->registerEvent('paused', 'onPaused');
$this->registerEvent('attention', 'onAttention');
$this->registerEvent('presence', 'onPresence');
$this->cached = false;
}
function onPresence($presence)
@ -142,6 +141,25 @@ class Chat extends WidgetBase
}
}
function onAttention($jid)
{
$rc = new \modl\ContactDAO();
$contact = $rc->getRosterItem(echapJid($jid));
$html = '
<div style="font-weight: bold; color: black;" class="message" >
<span class="date">'.date('G:i', time()).'</span>'.
t('%s needs your attention', $contact->getTrueName()).'
</div>';
RPC::call('movim_append',
'messages'.$jid,
$html);
RPC::call('scrollTalk',
'messages'.$jid);
}
/**
* Open a new talk
@ -297,7 +315,7 @@ class Chat extends WidgetBase
<div class="messages" id="messages'.$contact->jid.'">
'.$messageshtml.'
<div style="display: none;" class="message" id="composing'.$contact->jid.'">'.t('Composing...').'</div>
<div style="display: none;" class="message" id="paused'.$contact->jid.'">'.t('Paused...').'</div>
<div style="display: none;" class="message" id="paused'.$contact->jid.'">'.t('Paused...').'</div>
</div>
<div class="text">

1
system/Widget/widgets/Config/Config.php

@ -30,6 +30,7 @@ class Config extends WidgetBase
function onConfig(array $data)
{
$this->user->setConfig($data);
Notification::appendNotification(t('Configuration updated'));
}
function ajaxSubmit($data) {

1
system/Widget/widgets/ContactManage/ContactManage.php

@ -30,6 +30,7 @@ class ContactManage extends WidgetCommon
->setName(htmlspecialchars($form['alias']))
->setGroup(htmlspecialchars($form['group']))
->request();
Notification::appendNotification(t('Contact updated'));
}
private function prepareContactManage($jid) {

12
system/Widget/widgets/Feed/Feed.php

@ -51,12 +51,13 @@ class Feed extends WidgetCommon {
->setData(serialize($config))
->request();
$html .=
/*$html .=
'<div class="message error">'.
t("Your server doesn't support post publication, you can only read contact's feeds").'
</div>';
RPC::call('movim_fill', 'feednotifs', $html);
RPC::commit();
RPC::commit();*/
Notification::appendNotification(t("Your server doesn't support post publication, you can only read contact's feeds"), 'error');
}
function onCommentPublishError() {
@ -85,9 +86,7 @@ class Feed extends WidgetCommon {
}
function onPostPublishError($error) {
$html .=
'<div class="message error">'.t('An error occured : ').$error.'</div>';
RPC::call('movim_fill', 'feednotifs', $html);
Notification::appendNotification(t('An error occured : ').$error, 'error');
}
function prepareHead() {
@ -161,9 +160,6 @@ class Feed extends WidgetCommon {
</tr>
</tbody>
</table>
<div id="feednotifs"></div>';
}

4
system/Widget/widgets/GroupConfig/GroupConfig.php

@ -85,9 +85,9 @@ class GroupConfig extends WidgetBase
function build()
{
?>
<div class="tabelem" title="<?php echo t('Configuration'); ?>" id="groupconfig">
<div class="tabelem padded" title="<?php echo t('Configuration'); ?>" id="groupconfig">
<div id="groupconfiguration">
<a class="button tiny icon" onclick="<?php echo $this->genCallAjax('ajaxGroupConfig', "'".$_GET['s']."'", "'".$_GET['n']."'"); ?>"><?php echo t("Configure your group");?></a>
<a class="button tiny icon next" onclick="<?php echo $this->genCallAjax('ajaxGroupConfig', "'".$_GET['s']."'", "'".$_GET['n']."'"); ?>"><?php echo t("Configure your group");?></a>
<a class="button tiny icon" onclick="<?php echo $this->genCallAjax('ajaxGroupDelete', "'".$_GET['s']."'", "'".$_GET['n']."'"); ?>"><?php echo t("Delete this group");?></a>
</div>
</div>

51
system/Widget/widgets/Notification/Notification.php

@ -0,0 +1,51 @@
<?php
/**
* @package Widgets
*
* @file Notifs.php
* This file is part of MOVIM.
*
* @brief The notification widget
*
* @author Timothée Jaussoin <edhelas@gmail.com>
*
* @version 1.0
* @date 16 juin 2011
*
* Copyright (C)2010 MOVIM project
*
* See COPYING for licensing information.
*/
class Notification extends WidgetCommon
{
function WidgetLoad()
{
$this->addcss('notification.css');
$this->addjs('notification.js');
}
static function appendNotification($message, $type = 'info')
{
$id = sha1($message.rand(0, 1500));
$html = '
<div
class="notif notificationAnim '.$type.'"
id="'.$id.'"
>'.$message.'</div>';
RPC::call('movim_append', 'notification', $html);
RPC::call('removeDiff', $id);
RPC::commit();
}
function build()
{
?>
<div id="notification">
</div>
<?php
}
}

BIN
system/Widget/widgets/Notification/img/error.png

After

Width: 16  |  Height: 16  |  Size: 246 B

BIN
system/Widget/widgets/Notification/img/info.png

After

Width: 16  |  Height: 16  |  Size: 237 B

BIN
system/Widget/widgets/Notification/img/success.png

After

Width: 16  |  Height: 16  |  Size: 319 B

BIN
system/Widget/widgets/Notification/img/warning.png

After

Width: 16  |  Height: 16  |  Size: 138 B

69
system/Widget/widgets/Notification/notification.css

@ -0,0 +1,69 @@
#notification {
position: fixed;
bottom: 0px;
left: 0px;
z-index: 5;
}
#notification .notif {
background-color: rgba(0, 0, 0, 0.8);
width: 250px;
margin: 5px;
border-radius: 2px;
box-shadow: 0px 0px 5px black;
color: white;
padding: 1em;
padding-left: 3em;
opacity: 1;
background-repeat: no-repeat;
background-position: 1em 1em;
background-image: url(img/success.png);
}
#notification .notif.error {
background-image: url(img/error.png);
}
#notification .notif.warning {
background-image: url(img/warning.png);
}
#notification .notif.info {
background-image: url(img/info.png);
}
#notification .notif:hover {
opacity: 0.4;
}
.notificationAnim {
opacity: 0;
visibility: hidden;
position: relative;
-webkit-animation: fadeOut 5s linear;
-moz-animation: fadeOut 5s linear;
-ms-animation: fadeOut 5s linear;
-o-animation: fadeOut 5s linear;
animation: fadeOut 5s linear;
}
@-webkit-keyframes fadeOut {
0% { opacity: 1; visibility: visible; left: 0px; }
90% { opacity: 1; visibility: visible; left: 0px; }
100% { opacity: 0; visibility: hidden; left: -300px; }
}
@-moz-keyframes fadeOut {
0% { opacity: 0; visibility: visible; left: 0px; }
5% { opacity: 1; visibility: visible; left: 0px; }
90% { opacity: 1; visibility: visible; left: 0px; }
100% { opacity: 0; visibility: hidden; left: -300px; }
}
@-ms-keyframes fadeOut {
0% { opacity: 1; visibility: visible; left: 0px; }
90% { opacity: 1; visibility: visible; left: 0px; }
100% { opacity: 0; visibility: hidden; left: -300px; }
}

4
system/Widget/widgets/Notification/notification.js

@ -0,0 +1,4 @@
function removeDiff(params) {
target = document.getElementById(params[0]);
setTimeout(function() {target.parentNode.removeChild(target);}, 5000);
}

3
system/Widget/widgets/Profile/Profile.php

@ -39,7 +39,8 @@ class Profile extends WidgetCommon
function onMyPresence()
{
RPC::call('movim_fill', 'statussaved', '✔ '.t('Saved'));
RPC::call('movim_fill', 'statussaved', '✔ '.t('Saved'));
Notification::appendNotification(t('Status updated'), 'success');
}
function ajaxSetStatus($status)

15
system/Widget/widgets/ProfileData/ProfileData.php

@ -51,10 +51,7 @@ class ProfileData extends WidgetBase
->setGeo($geo)
->request();
} else {
$html = '
<div class="message error">'.t('Wrong position').'</div>';
RPC::call('movim_fill', 'maperror', $html);
RPC::commit();
Notification::appendNotification(t('Wrong position'), 'error');
}
}
@ -63,18 +60,15 @@ class ProfileData extends WidgetBase
$html = $me->getPlace();
RPC::call('movim_fill', 'mapdata', $html);
$html = '
<div class="message success">'.t('Location updated').'</div><br />';
RPC::call('movim_fill', 'maperror', $html);
Notification::appendNotification(t('Location updated'), 'success');
RPC::call('movim_delete', 'mapdiv');
RPC::commit();
}
function onLocationPublishError($error)
{
$html = '
<div class="message error">'.$error.'</div>';
RPC::call('movim_fill', 'maperror', $html);
Notification::appendNotification($error, 'error');
RPC::call('movim_delete', 'mapdiv');
RPC::call('movim_delete', 'mapdata');
RPC::commit();
@ -99,7 +93,6 @@ class ProfileData extends WidgetBase
$html .= '
<h2>'.t('Location').'</h2>
<div id="location">
<div id="maperror"></div>
<div id="mapdata" style="margin-bottom: 10px;">'.$data.'</div>
<div id="mapdiv" style="width: auto; height: 250px; display: none;"></div>
<div class="clear"></div>

1
system/Widget/widgets/Roster/Roster.php

@ -37,6 +37,7 @@ class Roster extends WidgetBase
function onPresence($presence)
{
$arr = $presence->getPresence();
//Notification::appendNotification($arr['jid'].' '. $arr['presence_txt']);
RPC::call('incomingPresence', $arr['jid'], $arr['presence_txt']);
}

14
system/Widget/widgets/ServerNodes/ServerNodes.php

@ -68,7 +68,7 @@ class ServerNodes extends WidgetCommon
</form>
</div>';
RPC::call('movim_fill', 'servernodes', $html);
RPC::call('movim_fill', 'servernodeslist', $html);
RPC::commit();
}
@ -88,7 +88,7 @@ class ServerNodes extends WidgetCommon
$html .= '</ul>';
RPC::call('movim_fill', 'servernodes', $html);
RPC::call('movim_fill', 'servernodeslist', $html);
RPC::commit();
}
@ -121,11 +121,17 @@ class ServerNodes extends WidgetCommon
function build()
{
?>
<a class="button tiny icon" onclick="movim_toggle_display('#groupCreation')"><?php echo t("Create a new group");?></a>
<div id="servernodes" class="tabelem protect red padded">
<a
class="button tiny icon add"
onclick="movim_toggle_display('#groupCreation')">
<?php echo t("Create a new group");?>
</a>
<div id="newGroupForm"></div>
<div class="tabelem protect red" id="servernodes" title="<?php echo t('Groups');?>">
<div id="servernodeslist" title="<?php echo t('Groups');?>">
<script type="text/javascript"><?php echo $this->genCallAjax('ajaxGetNodes', "'".$_GET['s']."'"); ?></script>
</div>
</div>
<?php
}
}

1
system/Widget/widgets/Vcard/Vcard.php

@ -33,6 +33,7 @@ class Vcard extends WidgetBase
{
$html = $this->prepareInfos();
RPC::call('movim_fill', 'vcard', $html);
Notification::appendNotification(t('Profile Updated'), 'success');
RPC::commit();
}

2
themes/movim/css/forms.css

@ -125,7 +125,7 @@ form .element.simple > *:not(label):not(img):focus {
}
.element .select:before {
pointer-events:none;
pointer-events: none;
content: "▼";
font: 11px sans-serif;
font-weight: bold;

1
themes/movim/page.tpl

@ -78,6 +78,7 @@
</div>
<div id="content">
<?php $this->widget('Notification');?>
<?php $this->content();?>
<div id="footer">

Loading…
Cancel
Save