Browse Source

Improve buddy sorting. Remove join create extra buddys.

pull/119/head
Evan Theurer 12 years ago
parent
commit
e416c01b7f
  1. 41
      src/styles/components/_buddycondensed.scss
  2. 21
      static/js/directives/buddycondensed.js

41
src/styles/components/_buddycondensed.scss

@ -22,6 +22,15 @@
display: inline-block; display: inline-block;
position: fixed; position: fixed;
padding-left: 20px; padding-left: 20px;
@media (max-width: 1125px) {
display: none;
}
@media (max-width: 480px) {
display: none;
padding-left: 0;
position: relative;
width: 80%;
}
} }
.buddycondensed { .buddycondensed {
&.buddy { &.buddy {
@ -36,20 +45,36 @@
} }
} }
.defaultDisplayNum { .defaultDisplayNum {
@media (max-width: 480px) {
padding: 10px 0px;
}
} }
.overDefaultDisplayNum { .overDefaultDisplayNum {
background: #f8f8f8; background: #f8f8f8;
display: none; display: none;
max-width: 80%;
position: fixed; position: fixed;
top: 49px; top: 49px;
@media (max-width: 480px) {
overflow-y: auto;
max-height: 400px;
top: 109px;
}
} }
.desc { .desc {
display: none; display: none;
font-weight: bold; font-weight: bold;
padding-left: 10px; padding-left: 10px;
cursor: default; cursor: default;
@media (max-width: 480px) {
position: absolute;
top: 50px;
}
&.overNum { &.overNum {
display: inline-block; display: inline-block;
@media (max-width: 480px) {
display: block;
}
} }
} }
.actions { .actions {
@ -61,13 +86,21 @@
cursor: default; cursor: default;
height: 51px; height: 51px;
padding: 0 15px; padding: 0 15px;
bottom: 10px; bottom: 12px;
position: relative; position: relative;
white-space: nowrap; white-space: nowrap;
z-index: 10; z-index: 10;
@media (max-width: 480px) {
height: 60px;
padding: 0 5px;
bottom: 22px;
}
.btn-group { .btn-group {
margin-bottom: 5px; margin-bottom: 5px;
width: 55px; width: 55px;
@media (max-width: 480px) {
display: block;
}
} }
.btn-primary { .btn-primary {
padding: 2px 4px; padding: 2px 4px;
@ -79,10 +112,14 @@
} }
.displayName { .displayName {
margin-right: 10px; margin-right: 10px;
@media (max-width: 480px) {
line-height: 22px;
display: block;
}
} }
} }
.buddyPicture { .buddyPicture {
cursor: pointer; cursor: default;
overflow: visible; overflow: visible;
} }
} }

21
static/js/directives/buddycondensed.js

@ -34,15 +34,14 @@ define(['angular', 'jquery', 'text!partials/buddycondensed.html', 'hoverIntent']
return session && session.Id ? session.Id : null; return session && session.Id ? session.Id : null;
}; };
var empty = function(x) { var empty = function(x) {
return x === null || x === undefined || isNaN(x) || x === ""; return x === null || x === undefined || x === "";
}; };
var sortCondensed = function() { var sortCondensed = function() {
var unnamed = buddycondensed.length;
buddycondensed.sort(function(current, next) { buddycondensed.sort(function(current, next) {
if(!current.Status || current.Status && empty(current.Status.displayName)) { if (!current.Status || current.Status && empty(current.Status.displayName)) {
return 1; return 1;
} else { } else {
if(next.Status && !empty(next.Status.displayName)) { if (next.Status && !empty(next.Status.displayName)) {
if (current.Status.displayName < next.Status.displayName) { if (current.Status.displayName < next.Status.displayName) {
return -1; return -1;
} else if (current.Status.displayName > next.Status.displayName) { } else if (current.Status.displayName > next.Status.displayName) {
@ -58,11 +57,10 @@ define(['angular', 'jquery', 'text!partials/buddycondensed.html', 'hoverIntent']
}; };
var joined = function(buddy) { var joined = function(buddy) {
buddycondensed.push(buddy); buddycondensed.push(buddy);
buddycondensed.push(angular.extend({}, buddy));
}; };
var left = function(id) { var left = function(id) {
for (var i in buddycondensed) { for (var i in buddycondensed) {
if(buddycondensed[i].Id === id) { if (buddycondensed[i].Id === id) {
buddycondensed.splice(i,1); buddycondensed.splice(i,1);
break; break;
} }
@ -74,14 +72,13 @@ define(['angular', 'jquery', 'text!partials/buddycondensed.html', 'hoverIntent']
var hasSession = false; var hasSession = false;
for (var i in buddycondensed) { for (var i in buddycondensed) {
// replace session data with contact data // replace session data with contact data
if(buddycondensed[i].Userid === data.Userid) { if (buddycondensed[i].Userid === data.Userid) {
buddycondensed[i] = data; buddycondensed[i] = data;
//console.log('contactadded replaced', 'data', data.Status && data.Status.displayName, 'buddycondensed[i]', buddycondensed[i].Status && buddycondensed[i].Status.displayName);
hasSession = true; hasSession = true;
break; break;
} }
} }
if(!hasSession) { if (!hasSession) {
joined(data); joined(data);
} }
$scope.$apply(); $scope.$apply();
@ -96,14 +93,14 @@ define(['angular', 'jquery', 'text!partials/buddycondensed.html', 'hoverIntent']
}); });
}; };
$scope.listDefault = function() { $scope.listDefault = function() {
if(buddycondensed.length >= $scope.maxBuddiesToShow) { if (buddycondensed.length >= $scope.maxBuddiesToShow) {
return buddycondensed.slice(0, $scope.maxBuddiesToShow); return buddycondensed.slice(0, $scope.maxBuddiesToShow);
} else { } else {
return buddycondensed; return buddycondensed;
} }
}; };
$scope.listOverDefault = function() { $scope.listOverDefault = function() {
if(buddycondensed.length >= $scope.maxBuddiesToShow) { if (buddycondensed.length >= $scope.maxBuddiesToShow) {
return buddycondensed.slice($scope.maxBuddiesToShow); return buddycondensed.slice($scope.maxBuddiesToShow);
} else { } else {
return []; return [];
@ -148,7 +145,7 @@ define(['angular', 'jquery', 'text!partials/buddycondensed.html', 'hoverIntent']
} else if (event.currentTarget === overDefaultDisplayNum.get(0)) { } else if (event.currentTarget === overDefaultDisplayNum.get(0)) {
aboveElem2 = false; aboveElem2 = false;
} }
if(!aboveElem1 && !aboveElem2) { if (!aboveElem1 && !aboveElem2) {
overDefaultDisplayNum.hide(); overDefaultDisplayNum.hide();
} }
}; };

Loading…
Cancel
Save