Browse Source

- Merge with nodpounod

- Add inhibit function in Notification (to disable the notifications for n seconds)
- Clean the CSS
- Fix a JS error in movim_websocket
- Inhibit the notifications on login
- Fix fatar error in Avatar
pull/16/head
Jaussoin Timothée 11 years ago
parent
commit
7cad48525d
  1. 14
      app/assets/js/movim_websocket.js
  2. 4
      app/helpers/StringHelper.php
  3. 7
      app/views/login.tpl
  4. 4
      app/widgets/Avatar/Avatar.php
  5. 11
      app/widgets/Chat/Chat.php
  6. 4
      app/widgets/Config/Config.php
  7. 35
      app/widgets/Config/_config_form.tpl
  8. 4
      app/widgets/Config/locales.ini
  9. 15
      app/widgets/Notification/notification.js
  10. 4
      app/widgets/Presence/Presence.php
  11. 3
      app/widgets/Presence/presence.js
  12. 3
      app/widgets/Roster/Roster.php
  13. 4
      app/widgets/Roster/roster.js
  14. 12
      app/widgets/Roster/roster.tpl
  15. 3
      bootstrap.php
  16. 56
      lib/Lazy.php
  17. 5
      themes/material/css/list.css
  18. 3
      themes/material/css/style.css

14
app/assets/js/movim_websocket.js

@ -42,14 +42,16 @@ var MovimWebsocket = {
var obj = JSON.parse(data);
if(obj.func == 'registered') {
MovimWebsocket.launchAttached();
}
if(obj != null) {
if(obj.func == 'registered') {
MovimWebsocket.launchAttached();
}
if(obj.func == 'disconnected') {
movim_disconnect();
if(obj.func == 'disconnected') {
movim_disconnect();
}
}
MovimWebsocket.handle(data);
};

4
app/helpers/StringHelper.php

@ -86,7 +86,7 @@ function prepareString($string) {
// Twitter hashtags
$string = preg_replace_callback(
"/ #[a-zA-Z0-9_-]*/", function ($match) {
"/ #[a-zA-Z0-9_-]{3,}/", function ($match) {
return
' <a class="twitter hastag" href="http://twitter.com/search?q='.
urlencode(trim($match[0])).
@ -97,7 +97,7 @@ function prepareString($string) {
);
$string = preg_replace_callback(
"/ @[a-zA-Z0-9_-]*/", function ($match) {
"/ @[a-zA-Z0-9_-]{3,}/", function ($match) {
return
' <a class="twitter at" href="http://twitter.com/'.
trim($match[0]).

7
app/views/login.tpl

@ -1,8 +1,9 @@
<?php /* -*- mode: html -*- */
?>
<?php $this->widget('Notification'); ?>
<?php $this->widget('Presence'); ?>
<main>
<section>
<div> <?php $this->widget('Login'); ?>
<div>
<?php $this->widget('Login'); ?>
</div>
</section>

4
app/widgets/Avatar/Avatar.php

@ -38,7 +38,7 @@ class Avatar extends WidgetBase
$html = $this->prepareForm($me);
RPC::call('movim_fill', 'avatar_form', $html);
Notification::appendNotification($this->__('avatar.updated'), 'success');
Notification::append(null, $this->__('avatar.updated'));
}
function onMyAvatarError()
@ -48,7 +48,7 @@ class Avatar extends WidgetBase
$html = $this->prepareForm($me);
RPC::call('movim_fill', 'avatar_form', $html);
Notification::appendNotification($this->__('avatar.not_updated'), 'error');
Notification::append(null, $this->__('avatar.not_updated'));
}
function prepareForm($me)

11
app/widgets/Chat/Chat.php

@ -225,12 +225,21 @@ class Chat extends WidgetCommon
$view = $this->tpl();
$contact = $cd->get($jid);
if($contact == null) {
$contact = new \Modl\Contact;
$contact->jid = $jid;
}
$me = $cd->get();
if($me == null) {
$me = new \Modl\Contact;
}
$messages = array_reverse($messages);
$view->assign('jid', $jid);
$view->assign('contact', $contact);
$view->assign('me', $cd->get());
$view->assign('me', $me);
$view->assign('messages', $messages);
$view->assign('status', $status);

4
app/widgets/Config/Config.php

@ -38,8 +38,8 @@ class Config extends WidgetBase
$view->assign('languages', loadLangArray());
$view->assign('me', $this->user->getLogin());
$view->assign('conf', $this->user->getConfig('language'));
$view->assign('color', $this->user->getConfig('color'));
$view->assign('size', $this->user->getConfig('size'));
//$view->assign('color', $this->user->getConfig('color'));
//$view->assign('size', $this->user->getConfig('size'));
if($this->user->getConfig('chatbox'))
$view->assign('chatbox', 'checked');

35
app/widgets/Config/_config_form.tpl

@ -28,6 +28,41 @@
</div>
<label for="language">{$c->__('config.language')}</label>
</div>
<div class="clear"></div>
<br />
<!--
<h3>{$c->__('config.notifications')}</h3>
<div class="block">
<div class="checkbox">
<input
type="checkbox"
id="privacy"
name="privacy"
{if="$me->privacy"}
checked
{/if}
onchange="{$privacy}">
<label for="privacy"></label>
</div>
<label for="language">{$c->__('notifications.message')}</label>
</div>
<div class="block">
<div class="checkbox">
<input
type="checkbox"
id="privacy"
name="privacy"
{if="$me->privacy"}
checked
{/if}
onchange="{$privacy}">
<label for="privacy"></label>
</div>
<label for="language">{$c->__('notifications.desktop')}</label>
</div>-->
<!--
<h3>{$c->__('config.appearence')}</h3>-->

4
app/widgets/Config/locales.ini

@ -4,6 +4,10 @@ config.language = 'Language'
config.appearence = 'Appearence'
config.background_color = 'Background color'
config.font_size = 'Font size'
config.notifications = 'Notifications'
config.pattern = 'Pattern'
config.info = 'This configuration is shared wherever you are connected !'
config.updated = 'Configuration updated'
notifications.message = 'Notifify on incoming message'
notifications.desktop = 'Use desktop notifications'

15
app/widgets/Notification/notification.js

@ -30,6 +30,17 @@
var DesktopNotification = Notification;
var Notification = {
inhibed : false,
inhibit : function(sec) {
Notification.inhibed = true;
if(sec == null) sec = 5;
setTimeout(function() {
Notification.inhibed = false;
},
sec*1000);
},
refresh : function(keys) {
var counters = document.querySelectorAll('.counter');
for(i = 0; i < counters.length; i++) {
@ -66,6 +77,8 @@ var Notification = {
3000);
},
snackbar : function(html, time) {
if(Notification.inhibed == true) return;
target = document.getElementById('snackbar');
if(target) {
@ -79,6 +92,8 @@ var Notification = {
time*1000);
},
desktop : function(title, body, picture) {
if(Notification.inhibed == true) return;
var notification = new DesktopNotification(title, { icon: picture, body: body });
}
}

4
app/widgets/Presence/Presence.php

@ -155,12 +155,12 @@ class Presence extends WidgetBase
$presence = $pd->getPresence($this->user->getLogin(), $session->ressource);
$presencetpl = $this->tpl();
$contact = $cd->get();
if($contact == null) {
$contact = new \Modl\Contact;
}
$presencetpl->assign('me', $contact);
$presencetpl->assign('presence', $presence);
$presencetpl->assign('dialog', $this->call('ajaxOpenDialog'));

3
app/widgets/Presence/presence.js

@ -1,5 +1,8 @@
function postStart() {
if(localStorage.postStart == 1) {
// We disable the notifications for a couple of seconds
Notification.inhibit(10);
Presence_ajaxSetPresence();
//Presence_ajaxConfigGet();
Presence_ajaxServerCapsGet();

3
app/widgets/Roster/Roster.php

@ -59,7 +59,7 @@ class Roster extends WidgetBase
$contacts = $packet->content;
if($contacts != null){
/*
if(is_array($contacts)) {
if(is_array($contacts) && $contacts[0]->value < 5) {
$presences = getPresences();
Notification::append(
'presence',
@ -68,7 +68,6 @@ class Roster extends WidgetBase
$contacts[0]->getPhoto('s'), 2);
}
*/
foreach($contacts as &$c) {
if($c->groupname == '')
$c->groupname = $this->__('roster.ungrouped');

4
app/widgets/Roster/roster.js

@ -1,7 +1,7 @@
(function(){
var app = angular.module("roster", []);
/* Controller for Rostermenu */
/* Controller for Rostermenu
app.controller("RosterMenuController", function($scope){
$scope.lsJid = localStorage.getItem("username").replace("@", "at");
$scope.lsRoster = localStorage.getObject($scope.lsJid + "_Roster") || {};
@ -22,7 +22,7 @@
$scope.lsOfflineShown = false;
}
}
});
});*/
/* Controller for Rosterlist */
app.controller("RosterController", function($scope){

12
app/widgets/Roster/roster.tpl

@ -5,7 +5,7 @@
<label for="search">{$c->__('roster.search')}</label>
</div>
</form>-->
<ul id="rosterlist" class="offlineshown active">
<ul id="rosterlist" class="offlineshown active all">
<!--
Also this means we can remove:
rosterCtrl.offlineIsShown() from roster.js
@ -23,11 +23,11 @@
<li ng-repeat="myjid in group.agroupitems" ng-hide="myjid.tombstone" id="{{myjid.ajid}}" class="{{myjid.ajiditems[0].rosterview.presencetxt}}" ng-attr-title="{{rosterCtrl.getContactTitle(myjid.ajiditems[0])}}">
<!-- Rostersearch look this way for an angularJS solution http://www.bennadel.com/blog/2487-filter-vs-nghide-with-ngrepeat-in-angularjs.htm -->
<ul class="contact active">
<li ng-repeat="contact in myjid.ajiditems" class="{{contact.rosterview.presencetxt}} {{contact.rosterview.inactive}}" ng-class="{condensed: contact.status != '' && contact.status != null }" ng-class="rosterCtrl.getContactClient(contact)" >
<div class="control">
<i ng-if="contact.rosterview.type == 'handheld'" class="md md-smartphone"></i>
<i ng-if="contact.rosterview.type == 'web'" class="md md-language"></i>
<i ng-if="contact.rosterview.type == 'bot'" class="md md-memory"></i>
<li ng-repeat="contact in myjid.ajiditems | limitTo : 1" class="{{contact.rosterview.presencetxt}} {{contact.rosterview.inactive}}" ng-class="{condensed: contact.status != '' && contact.status != null }" ng-class="rosterCtrl.getContactClient(contact)" >
<div class="control" ng-switch on="contact.rosterview.type">
<i ng-switch-when="handheld" class="md md-smartphone"></i>
<i ng-switch-when="web" class="md md-language"></i>
<i ng-switch-when="bot" class="md md-memory"></i>
<i ng-if="contact.rosterview.tune" class="md md-play-arrow"></i>
</div>

3
bootstrap.php

@ -183,9 +183,6 @@ class Bootstrap {
// SDPtoJingle and JingletoSDP lib :)
require_once(LIB_PATH . "SDPtoJingle.php");
require_once(LIB_PATH . "JingletoSDP.php");
// The Lazy page loader
require_once(LIB_PATH . "Lazy.php");
}
private function loadHelpers() {

56
lib/Lazy.php

@ -1,56 +0,0 @@
<?php
/**
* @file Lazy.php
* This file is part of Movim.
*
* @brief Refresh only parts of the new page
*
* @author Timothée jaussoin
*/
class Lazy {
private $_current;
private $_next;
private $_widgets = array();
public function __construct($current, $next) {
$this->_current = $current;
$this->_next = $next;
// We grab the widgets from the current view
$current_path = VIEWS_PATH . '/' . $this->_current . '.tpl';
require_once $current_path;
ob_clean();
$current_widgets = $this->_widgets;
$this->_widgets = array();
// We grab the widgets from the next view
$next_path = VIEWS_PATH . '/' . $this->_next . '.tpl';
require_once $next_path;
ob_clean();
$next_widgets = $this->_widgets;
$this->_widgets = array();
// We compare the two lists
$diff_widgets_current = array_diff($next_widgets, $current_widgets);
$diff_widgets_next = array_diff($current_widgets, $next_widgets);
\movim_log($diff_widgets_current);
\movim_log($diff_widgets_next);
$widgets = WidgetWrapper::getInstance(false);
foreach($diff_widgets as $key => $name) {
RPC::call('movim_fill', strtolower($name) . '_widget', $widgets->runWidget($name, 'build'));
}
RPC::commit();
}
private function widget($name) {
array_push($this->_widgets, $name);
}
}

5
themes/material/css/list.css

@ -59,8 +59,9 @@ ul li.subheader {
font-weight: 600;
}
ul.active li:hover,
ul.active li.active {
ul.active li:hover:not(.subheader),
ul.active.all li:hover,
ul.active li.active:not(.subheader) {
background-color: rgba(0, 0, 0, 0.05);
cursor: pointer;
}

3
themes/material/css/style.css

@ -302,13 +302,12 @@ main > section > div > div.contained > * {
main > section > div:first-child:nth-last-child(2) ~ div {
background-color: white;
width: 100%;
/*right: -100%;*/
transform: translateX(100%);
z-index: 1;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.23), 0 0 10px rgba(0, 0, 0, 0.16);
}
main > section > div:first-child:nth-last-child(2) ~ div.enabled {
/*right: 0;*/
transform: translateX(0);
}

Loading…
Cancel
Save