Browse Source

- Merge with nodpounod and fix the roster

- Fix the Presence update form
pull/16/head
Jaussoin Timothée 11 years ago
parent
commit
11cca6a7a2
  1. 1
      app/views/conf.tpl
  2. 3
      app/views/page.tpl
  3. 11
      app/widgets/Notification/notification.js
  4. 37
      app/widgets/Presence/Presence.php
  5. 10
      app/widgets/Presence/_presence.tpl
  6. 25
      app/widgets/Presence/presence.js
  7. 11
      app/widgets/Presence/presence.tpl
  8. 6
      app/widgets/Roster/roster.css
  9. 52
      app/widgets/Roster/roster.js
  10. 5
      app/widgets/Roster/roster.tpl
  11. 6
      themes/material/css/style.css

1
app/views/conf.tpl

@ -5,6 +5,7 @@
<?php //$this->widget('VisioExt');?>
<nav class="color dark">
<?php $this->widget('Presence');?>
<?php $this->widget('Navigation');?>
</nav>

3
app/views/page.tpl

@ -87,7 +87,7 @@
</noscript>
<div id="snackbar" class="snackbar"></div>
<?php $this->widget('Dialog');?>
<?php $this->widget('Notification');?>
<?php $this->content();?>
<!--
@ -101,7 +101,6 @@
<!--
<div id="content">
<?php $this->widget('Notification');?>
<?php //$this->widget('Ack');?>
<?php //$this->content();?>

11
app/widgets/Notification/notification.js

@ -1,6 +1,9 @@
function removeDiff(id, html, id2) {
target = document.getElementById(id);
if(target) {
target.innerHTML = html;
/*
target.insertAdjacentHTML('beforeend', html);
var nodes = target.childNodes;
@ -14,6 +17,12 @@ function removeDiff(id, html, id2) {
if(n.parentNode) n.parentNode.removeChild(n);
},
6000);
}
}*/
}
setTimeout(function() {
target = document.getElementById(id);
target.innerHTML = '';
},
3000);
}

37
app/widgets/Presence/Presence.php

@ -32,7 +32,7 @@ class Presence extends WidgetBase
function load()
{
//$this->addcss('presence.css');
//$this->addjs('presence.js');
$this->addjs('presence.js');
$this->registerEvent('mypresence', 'onMyPresence');
}
@ -53,6 +53,7 @@ class Presence extends WidgetBase
private function setPresence($show = false, $status = false)
{
Dialog::fill('');
// We update the cache with our status and presence
$presence = Cache::c('presence');
@ -141,10 +142,30 @@ class Presence extends WidgetBase
function ajaxOpenDialog()
{
Dialog::fill($this->preparePresence());
Dialog::fill($this->preparePresenceList());
RPC::call('setPresenceActions');
}
function preparePresence()
{
$cd = new \Modl\ContactDAO();
$pd = new \Modl\PresenceDAO();
$session = \Sessionx::start();
$presence = $pd->getPresence($this->user->getLogin(), $session->ressource);
$presencetpl = $this->tpl();
$presencetpl->assign('me', $cd->get());
$presencetpl->assign('presence', $presence);
$presencetpl->assign('dialog', $this->call('ajaxOpenDialog'));
$html = $presencetpl->draw('_presence', true);
return $html;
}
function preparePresenceList()
{
$txt = getPresences();
$txts = getPresencesTxt();
@ -179,15 +200,7 @@ class Presence extends WidgetBase
function display()
{
$cd = new \Modl\ContactDAO();
$pd = new \Modl\PresenceDAO();
$session = \Sessionx::start();
$presence = $pd->getPresence($this->user->getLogin(), $session->ressource);
$this->view->assign('me', $cd->get());
$this->view->assign('presence', $presence);
$this->view->assign('dialog', $this->call('ajaxOpenDialog'));
$this->view->assign('presence', $this->preparePresence());
}
}

10
app/widgets/Presence/_presence.tpl

@ -0,0 +1,10 @@
<ul class="active divided">
<li class="condensed">
<div class="on_mobile control">
<i onclick="movim_remove_class('body > nav', 'active')" class="md md-arrow-back"></i>
</div>
<span onclick="{$dialog}" class="icon bubble" style="background-image: url({$me->getPhoto('m')})"></span>
<span onclick="{$dialog}">{$me->getTrueName()}</span>
<p onclick="{$dialog}" class="wrap">{$presence->status}</p>
</li>
</ul>

25
app/widgets/Presence/presence.js

@ -9,26 +9,29 @@ function postStart() {
}
function setPresenceActions() {
var textarea = document.querySelector('#presence_widget textarea.status');
var textarea = document.querySelector('textarea.status');
textarea.onkeypress = function(event) {
if(event.keyCode == 13) {
Presence_ajaxSetStatus(this.value);
this.blur();
}
};
if(textarea != null) {
textarea.onkeypress = function(event) {
if(event.keyCode == 13) {
Presence_ajaxSetStatus(this.value);
this.blur();
}
};
textarea.onfocus = function(event) {
movim_textarea_autoheight(this);
};
textarea.onfocus = function(event) {
movim_textarea_autoheight(this);
};
}
/*
document.querySelector('#presence_widget #tab').onclick = function(event) {
movim_toggle_class('#presence_widget', 'unfolded');
};
document.querySelector('#presence_widget #list .tab').onclick = function(event) {
movim_toggle_class('#presence_widget', 'unfolded');
};
};*/
}
MovimWebsocket.attach(function()

11
app/widgets/Presence/presence.tpl

@ -1,14 +1,5 @@
<header
id="presence_widget"
class="big">
<ul class="active divided">
<li class="condensed">
<div class="on_mobile control">
<i onclick="movim_remove_class('body > nav', 'active')" class="md md-arrow-back"></i>
</div>
<span onclick="{$dialog}" class="icon bubble" style="background-image: url({$me->getPhoto('m')})"></span>
<span onclick="{$dialog}">{$me->getTrueName()}</span>
<p onclick="{$dialog}" class="wrap">{$presence->status}</p>
</li>
</ul>
{$presence}
</header>

6
app/widgets/Roster/roster.css

@ -266,15 +266,17 @@
}
*/
/* Search */
/*
#roster ul li.subheader.search,
#roster.search ul#rosterlist.offlineshown div.groupshown > li {
display: none;
}
#roster.search ul li.subheader.search,
#roster.search ul#rosterlist.offlineshown div.groupshown > li.found {
display: list-item;
}
/*
#rostermenu {
position: fixed;
bottom: 0;

52
app/widgets/Roster/roster.js

@ -2,11 +2,26 @@
var app = angular.module("roster", []);
/* Controller for Rostermenu */
app.controller("RosterMenuController", function(){
app.controller("RosterMenuController", function($scope){
$scope.lsJid = localStorage.getItem("username").replace("@", "at");
$scope.lsRoster = localStorage.getObject($scope.lsJid + "_Roster") || {};
$scope.lsOfflineShown = "offlineShown" in $scope.lsRoster ? $scope.lsRoster.offlineShown : false;
this.checkoutAddJid = function(event){
if(event.key == "Enter")
Roster_ajaxSearchContact(event.target.value);
};
this.showHideOffline = function() {
if(!$scope.lsOfflineShown){
document.querySelector('ul#rosterlist').className = 'offlineshown';
$scope.lsOfflineShown = true;
}
else{
document.querySelector('ul#rosterlist').className = '';
$scope.lsOfflineShown = false;
}
}
});
/* Controller for Rosterlist */
@ -202,15 +217,14 @@
};
this.offlineIsShown = function(){
if($scope.lsGroupState.rosterShow_offline)
if("offlineShown" in $scope.lsRoster && $scope.lsRoster.offlineShown)
return "offlineshown";
else
return "";
};
this.getContactTitle = function(c){
console.log(c);
title = c.rosterview.name + " - " + c.jid;
title = c.rosterview.name.toLowerCase() + " - " + c.jid;
if(c.status) title += " - " + c.status;
return title;
};
@ -253,6 +267,7 @@ window.onunload = window.onbeforeunload = function(e){
// Move this to disconnection moment ??
// Keep group states in jid_Roster.groupStates
angular.element(roster).scope().lsRoster.groupState = angular.element(roster).scope().lsGroupState;
angular.element(roster).scope().lsRoster.offlineShown = angular.element(rostermenu).scope().lsOfflineShown;
localStorage.setObject(lsjid + "_Roster", angular.element(roster).scope().lsRoster);
};
@ -307,40 +322,15 @@ var ressourceCompare = function(a, b) {
};
/* Presence + alphabetical comparison */
var jidAvalCompare = function(a, b) {
if(a.ajid=="christine.ho@etu.univ-nantes.fr"){
console.log("jidAvalCompare");
console.log(a.aval);
console.log(b.ajid);
console.log(b.aval);
}
n = a.aval - b.aval;
if(n == 0){
n = a.atruename.localeCompare(b.atruename);
if(a.ajid == "christine.ho@etu.univ-nantes.fr"){
console.log("name a "+a.atruename);
console.log("name b "+b.atruename);
}
}
if(a.ajid=="christine.ho@etu.univ-nantes.fr")
console.log(n ? n < 0 ? -1 : 1 : 0);
return n ? n < 0 ? -1 : 1 : 0;
};
/* === Old functions still in use === */
function showHideOffline() {
if(!localStorage.getObject("rosterShow_offline")){
document.querySelector('ul#rosterlist').className = 'offlineshown';
localStorage.setObject("rosterShow_offline", true);
}
else{
document.querySelector('ul#rosterlist').className = '';
localStorage.setObject("rosterShow_offline", false);
}
}
MovimWebsocket.attach(function(){
Roster_ajaxGetRoster();
});
@ -367,7 +357,7 @@ movim_add_onload(function(){
}
// We clear the old search
var selector_clear = '#rosterlist div > li';
var selector_clear = '#rosterlist div > li:not(.subheader)';
var li = document.querySelectorAll(selector_clear);
for(i = 0; i < li.length; i++) {
@ -375,7 +365,7 @@ movim_add_onload(function(){
}
// We select the interesting li
var selector = '#rosterlist div > li[title*=\'' + search.value + '\']';
var selector = '#rosterlist div > li[title*="' + search.value.toLowerCase() + '"]:not(.subheader)';
var li = document.querySelectorAll(selector);
for(i = 0; i < li.length; i++) {

5
app/widgets/Roster/roster.tpl

@ -12,7 +12,8 @@
<br />
<a class="button color green" href="{$c->route('explore')}"><i class="fa fa-compass"></i> {$c->__('page.explore')}</a>
</span>
<li class="subheader search">Results **FIXME**</li>
<div ng-show="contacts != null && !group.tombstone" ng-repeat="group in contacts" id="group{{group.agroup}}" ng-class="{groupshown: rosterCtrl.groupIsShown(group.agroup)}" >
<li class="subheader" ng-click="rosterCtrl.showHideGroup(group.agroup)">{{group.agroup}}</li>
<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])}}">
@ -103,7 +104,7 @@
</li>
<li
onclick="showHideOffline()"
ng-click="rosterMenuCtrl.showHideOffline()"
title="{$c->__('roster.show_hide')}">
<a class="users" href="#"></a>
</li>

6
themes/material/css/style.css

@ -268,6 +268,10 @@ span.icon {
background-size: cover;
}
span.icon img {
width: 100%;
}
li.oppose span.icon {
left: auto;
right: 2rem;
@ -449,7 +453,7 @@ header.big p {
.toast {
background-color: #323232;
border-radius: 10rem;
border-radius: 2rem;
left: 50%;
bottom: 3rem;
margin-left: -20rem;

Loading…
Cancel
Save