Browse Source

Implemented central click handler for buddy list clicks.

pull/48/head
Simon Eisenmann 11 years ago committed by Simon Eisenmann
parent
commit
a61632eda5
  1. 3
      src/styles/components/_buddylist.scss
  2. 6
      static/js/directives/buddylist.js
  3. 84
      static/js/services/buddylist.js
  4. 2
      static/partials/buddy.html
  5. 4
      static/partials/buddyactions.html

3
src/styles/components/_buddylist.scss

@ -223,6 +223,9 @@ @@ -223,6 +223,9 @@
.#{$fa-css-prefix} {
font-size: 2em;
}
i.fa {
pointer-events: none;
}
}
.buddy .buddysessions {

6
static/js/directives/buddylist.js

@ -61,6 +61,7 @@ define(['underscore', 'text!partials/buddylist.html'], function(_, template) { @@ -61,6 +61,7 @@ define(['underscore', 'text!partials/buddylist.html'], function(_, template) {
};
/*
$scope.doAudioConference = function(id) {
$scope.updateAutoAccept(id);
@ -71,7 +72,7 @@ define(['underscore', 'text!partials/buddylist.html'], function(_, template) { @@ -71,7 +72,7 @@ define(['underscore', 'text!partials/buddylist.html'], function(_, template) {
}
})
};
};*/
$scope.setRoomStatus = function(status) {
if (status !== $scope.enabled) {
@ -83,9 +84,6 @@ define(['underscore', 'text!partials/buddylist.html'], function(_, template) { @@ -83,9 +84,6 @@ define(['underscore', 'text!partials/buddylist.html'], function(_, template) {
}
};
//XXX(longsleep): Debug leftover ?? Remove this.
window.doAudioConference = $scope.doAudioConference;
var buddylist = $scope.buddylist = buddyList.buddylist($element, $scope, {});
var onJoined = _.bind(buddylist.onJoined, buddylist);
var onLeft = _.bind(buddylist.onLeft, buddylist);

84
static/js/services/buddylist.js

@ -157,22 +157,24 @@ define(['underscore', 'modernizr', 'avltree', 'text!partials/buddy.html', 'text! @@ -157,22 +157,24 @@ define(['underscore', 'modernizr', 'avltree', 'text!partials/buddy.html', 'text!
$element.on("mouseenter mouseleave", ".buddy", _.bind(function(event) {
// Hover handler for on Buddy actions.
var buddyElement = $(event.currentTarget);
this.hover(buddyElement, event.type === "mouseenter" ? true : false, buddyElement.scope().session.Id);
this.hover(buddyElement, event.type === "mouseenter" ? true : false);
}, this));
$element.on("click", ".buddy", _.bind(function(event) {
console.log("click event", event);
var buddyElement = $(event.currentTarget);
buddyElement.scope().doDefault();
//buddyElement.scope().doDefault();
this.click(buddyElement, event.target);
}, this));
$element.on("click", ".fa.contact", _.bind(function(event) {
/*$element.on("click", ".fa.contact", _.bind(function(event) {
event.stopPropagation();
var buddyElement = $(event.currentTarget);
buddyElement.scope().doDefaultContact();
}, this));
}, this));*/
$element.attr("data-xthreshold", "10");
$element.on("swipeleft", ".buddy", _.bind(function(event) {
event.preventDefault();
var buddyElement = $(event.currentTarget);
this.hover(buddyElement, !buddyElement.hasClass("hovered"), buddyElement.scope().session.Id);
this.hover(buddyElement, !buddyElement.hasClass("hovered"));
}, this));
$window.setInterval(_.bind(this.soundLoop, this), 500);
@ -211,35 +213,17 @@ define(['underscore', 'modernizr', 'avltree', 'text!partials/buddy.html', 'text! @@ -211,35 +213,17 @@ define(['underscore', 'modernizr', 'avltree', 'text!partials/buddy.html', 'text!
Buddylist.prototype.onBuddyScopeCreated = function(scope, data) {
// Init scope with our stuff.
scope.element = null;
scope.contact = null;
scope.display = {};
var session = scope.session = buddySession.create(data);
scope.doDefault = function() {
var id = scope.session.Id;
//if (scope.status.isMixer) {
// return scope.doAudioConference(id);
//}
return scope.doCall(id);
};
scope.doDefaultContact = function() {
var contact = scope.contact;
if (contact) {
return scope.doContactRemove(contact.Userid);
} else {
var id = scope.session.Id;
return scope.doContactRequest(id);
}
};
scope.session = buddySession.create(data);
scope.$on("$destroy", function() {
//console.log("destroyed");
scope.element = null;
scope.killed = true;
});
//console.log("on buddy scope", session.Userid, session);
};
Buddylist.prototype.onBuddySessionUserid = function(scope, sourceSession) {
@ -666,9 +650,50 @@ define(['underscore', 'modernizr', 'avltree', 'text!partials/buddy.html', 'text! @@ -666,9 +650,50 @@ define(['underscore', 'modernizr', 'avltree', 'text!partials/buddy.html', 'text!
};
Buddylist.prototype.hover = function(buddyElement, hover, id) {
Buddylist.prototype.click = function(buddyElement, target) {
//console.log("click handler", buddyElement, target);
var action = $(target).data("action");
if (!action) {
// Make call the default action.
action = "call";
}
var scope = buddyElement.scope();
var session = scope.session;
var sessionData = session.get()
var contact = scope.contact;
var id;
if (!sessionData) {
// TODO(longsleep): Find session with help of contact.
console.log("No sessions for this buddy.", session, contact);
} else {
id = sessionData.Id;
}
//console.log("id", id);
switch (action) {
case "call":
scope.doCall(id);
break;
case "chat":
scope.doChat(id);
break;
case "contact":
if (contact) {
scope.doContactRemove(contact.Userid);
} else {
scope.doContactRequest(id);
}
break;
}
};
Buddylist.prototype.hover = function(buddyElement, hover) {
//console.log("hover handler", event, hover, id);
//console.log("hover handler", buddyElement, hover);
var scope = buddyElement.scope();
var id = scope.session.Id;
var buddy = $(buddyElement);
var actionElements = this.actionElements;
var elem;
@ -689,11 +714,6 @@ define(['underscore', 'modernizr', 'avltree', 'text!partials/buddy.html', 'text! @@ -689,11 +714,6 @@ define(['underscore', 'modernizr', 'avltree', 'text!partials/buddy.html', 'text!
if (elem) {
buddy.addClass("hovered");
} else {
var scope = buddyData.get(id);
if (!scope) {
console.warn("No scope for buddy", id);
return;
}
var template = buddyActions;
//if (scope.status.autoCalls && _.indexOf(scope.status.autoCalls, "conference") !== -1) {
// template = buddyActionsForAudioMixer;

2
static/partials/buddy.html

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
<div class="buddy" ng-class="{'contact': contact, 'withSubline': display.subLine}">
<div class="buddyPicture"><i class="fa fa-user fa-3x"/><img ng-show="display.buddyPicture" alt ng-src="{{display.buddyPicture}}" width="46" height="46"/></div>
<div class="buddy1">{{session.Id|displayName}}</div>
<div class="buddy2"><span ng-show="session.Userid"><i class="fa contact"></i><span ng-show="session.count"> ({{session.count}})</span></span> {{display.subLine}}</div>
<div class="buddy2"><span ng-show="session.Userid"><i class="fa contact" data-action="contact"></i><span ng-show="session.count"> ({{session.count}})</span></span> {{display.subLine}}</div>
</div>

4
static/partials/buddyactions.html

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
<div class="buddyhover">
<div class="buddyactions active">
<a class="btn btn-info" title="{{_('Start video call')}}"><i class="fa fa-eye"></i></a>
<a class="btn btn-info" title="{{_('Start chat')}}" ng-click="doChat(session.Id); $event.stopPropagation()"><i class="fa fa-comments-o"></i></a>
<a class="btn btn-info" data-action="call" title="{{_('Start video call')}}"><i class="fa fa-eye"></i></a>
<a class="btn btn-info" data-action="chat" title="{{_('Start chat')}}"><i class="fa fa-comments-o"></i></a>
</div>
<div class="buddysessions" ng-if="session.count>1">
<ul>

Loading…
Cancel
Save