mirror of https://github.com/BTCPrivate/copay.git
Merge pull request #317 from maraoz/add/unmute-by-defaultwq
add confvideo directive -- awesome!!
This commit is contained in:
commit
c72b1c6e22
|
@ -287,6 +287,7 @@ hr { margin: 2.25rem 0;}
|
||||||
float: right;
|
float: right;
|
||||||
}
|
}
|
||||||
.online {
|
.online {
|
||||||
|
background-color: black;
|
||||||
border: 3px solid green;
|
border: 3px solid green;
|
||||||
}
|
}
|
||||||
.offline {
|
.offline {
|
||||||
|
|
|
@ -124,13 +124,14 @@
|
||||||
<div class="bottom-copay"
|
<div class="bottom-copay"
|
||||||
ng-repeat="c in $root.wallet.getRegisteredPeerIds()">
|
ng-repeat="c in $root.wallet.getRegisteredPeerIds()">
|
||||||
<video
|
<video
|
||||||
ng-class="($root.wallet.getOnlinePeerIDs().indexOf(c.peerId) != -1) ? 'online' : 'offline'"
|
ng-if="$root.videoInfo[c.peerId]"
|
||||||
class="video-small"
|
class="video-small"
|
||||||
autoplay ng-show="$root.videoSrc[c.peerId]"
|
autoplay
|
||||||
|
confvideo
|
||||||
|
peer="{{c.peerId}}"
|
||||||
ng-src="{{$root.getVideoURL(c.peerId)}}"
|
ng-src="{{$root.getVideoURL(c.peerId)}}"
|
||||||
id="{{c.peerId + '-video'}}" muted="true"
|
|
||||||
title="{{c.peerId + (c.peerId == $root.wallet.network.peerId?' (You)':'')}}" ></video>
|
title="{{c.peerId + (c.peerId == $root.wallet.network.peerId?' (You)':'')}}" ></video>
|
||||||
<img ng-show="!$root.videoSrc[c.peerId]"
|
<img ng-if="!$root.videoInfo[c.peerId]"
|
||||||
ng-class="($root.wallet.getOnlinePeerIDs().indexOf(c.peerId) != -1) ? 'online' : 'offline'"
|
ng-class="($root.wallet.getOnlinePeerIDs().indexOf(c.peerId) != -1) ? 'online' : 'offline'"
|
||||||
class="video-small"
|
class="video-small"
|
||||||
src="./img/satoshi.gif"
|
src="./img/satoshi.gif"
|
||||||
|
|
131
js/directives.js
131
js/directives.js
|
@ -1,81 +1,86 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copay.directives')
|
angular.module('copay.directives')
|
||||||
.directive('validAddress', [function() {
|
.directive('validAddress', [
|
||||||
|
|
||||||
var bitcore = require('bitcore');
|
function() {
|
||||||
var Address = bitcore.Address;
|
|
||||||
|
|
||||||
return {
|
var bitcore = require('bitcore');
|
||||||
require: 'ngModel',
|
var Address = bitcore.Address;
|
||||||
link: function (scope, elem, attrs, ctrl) {
|
|
||||||
var validator = function(value){
|
|
||||||
var a = new Address(value);
|
|
||||||
ctrl.$setValidity('validAddress', a.isValid());
|
|
||||||
return value;
|
|
||||||
};
|
|
||||||
|
|
||||||
ctrl.$parsers.unshift(validator);
|
return {
|
||||||
ctrl.$formatters.unshift(validator);
|
require: 'ngModel',
|
||||||
}
|
link: function(scope, elem, attrs, ctrl) {
|
||||||
};
|
var validator = function(value) {
|
||||||
}])
|
var a = new Address(value);
|
||||||
.directive('notification', ['$rootScope', function($rootScope){
|
ctrl.$setValidity('validAddress', a.isValid());
|
||||||
return {
|
return value;
|
||||||
restrict: 'A',
|
};
|
||||||
link: function(scope, element, attrs, ctrl) {
|
|
||||||
setTimeout(function(){
|
ctrl.$parsers.unshift(validator);
|
||||||
scope.$apply(function() {
|
ctrl.$formatters.unshift(validator);
|
||||||
$rootScope.flashMessage = {};
|
}
|
||||||
});
|
};
|
||||||
}, 5000);
|
}
|
||||||
}
|
])
|
||||||
};
|
.directive('notification', ['$rootScope',
|
||||||
}])
|
function($rootScope) {
|
||||||
.directive('enoughAmount', ['$rootScope', function($rootScope){
|
return {
|
||||||
return {
|
restrict: 'A',
|
||||||
require: 'ngModel',
|
link: function(scope, element, attrs, ctrl) {
|
||||||
link: function(scope, element, attrs, ctrl) {
|
setTimeout(function() {
|
||||||
var val = function(value) {
|
scope.$apply(function() {
|
||||||
var vStr = new String(value);
|
$rootScope.flashMessage = {};
|
||||||
var vNum = Number(vStr);
|
});
|
||||||
if (typeof vNum == "number" && vNum > 0) {
|
}, 5000);
|
||||||
if ($rootScope.availableBalance <= vNum) {
|
}
|
||||||
ctrl.$setValidity('enoughAmount', false);
|
};
|
||||||
scope.notEnoughAmount = 'Insufficient funds!';
|
}
|
||||||
}
|
])
|
||||||
else {
|
.directive('enoughAmount', ['$rootScope',
|
||||||
ctrl.$setValidity('enoughAmount', true);
|
function($rootScope) {
|
||||||
|
return {
|
||||||
|
require: 'ngModel',
|
||||||
|
link: function(scope, element, attrs, ctrl) {
|
||||||
|
var val = function(value) {
|
||||||
|
var vStr = new String(value);
|
||||||
|
var vNum = Number(vStr);
|
||||||
|
if (typeof vNum == "number" && vNum > 0) {
|
||||||
|
if ($rootScope.availableBalance <= vNum) {
|
||||||
|
ctrl.$setValidity('enoughAmount', false);
|
||||||
|
scope.notEnoughAmount = 'Insufficient funds!';
|
||||||
|
} else {
|
||||||
|
ctrl.$setValidity('enoughAmount', true);
|
||||||
|
scope.notEnoughAmount = null;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
scope.notEnoughAmount = null;
|
scope.notEnoughAmount = null;
|
||||||
}
|
}
|
||||||
} else {
|
return value;
|
||||||
scope.notEnoughAmount = null;
|
|
||||||
}
|
}
|
||||||
return value;
|
ctrl.$parsers.unshift(val);
|
||||||
|
ctrl.$formatters.unshift(val);
|
||||||
}
|
}
|
||||||
ctrl.$parsers.unshift(val);
|
};
|
||||||
ctrl.$formatters.unshift(val);
|
}
|
||||||
}
|
])
|
||||||
};
|
.directive('loading', function() {
|
||||||
}])
|
|
||||||
.directive('loading', function () {
|
|
||||||
return {
|
return {
|
||||||
restrict: 'A',
|
restrict: 'A',
|
||||||
link: function (scope, element, attr) {
|
link: function(scope, element, attr) {
|
||||||
var a = element.html();
|
var a = element.html();
|
||||||
var text = attr.loading;
|
var text = attr.loading;
|
||||||
scope.$watch('loading', function (val) {
|
scope.$watch('loading', function(val) {
|
||||||
if (val) {
|
if (val) {
|
||||||
element.html('<img src="img/loading.gif"> ' + text + '...' );
|
element.html('<img src="img/loading.gif"> ' + text + '...');
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
element.html(a);
|
element.html(a);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.directive('ngFileSelect',function() {
|
.directive('ngFileSelect', function() {
|
||||||
return {
|
return {
|
||||||
link: function($scope, el) {
|
link: function($scope, el) {
|
||||||
el.bind('change', function(e) {
|
el.bind('change', function(e) {
|
||||||
|
@ -84,5 +89,15 @@ angular.module('copay.directives')
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}).directive('confvideo', function($rootScope) {
|
||||||
|
return {
|
||||||
|
link: function(scope, element, attrs) {
|
||||||
|
var peer = attrs.peer;
|
||||||
|
element.addClass(($rootScope.wallet.getOnlinePeerIDs().indexOf(peer) != -1) ? 'online' : 'offline');
|
||||||
|
var muted = $rootScope.getVideoMutedStatus(peer);
|
||||||
|
if (muted) {
|
||||||
|
element.attr("muted", true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -3,17 +3,26 @@
|
||||||
angular.module('copay.controllerUtils')
|
angular.module('copay.controllerUtils')
|
||||||
.factory('controllerUtils', function($rootScope, $sce, $location, Socket, video) {
|
.factory('controllerUtils', function($rootScope, $sce, $location, Socket, video) {
|
||||||
var root = {};
|
var root = {};
|
||||||
$rootScope.videoSrc = {};
|
$rootScope.videoInfo = {};
|
||||||
$rootScope.loading = false;
|
$rootScope.loading = false;
|
||||||
|
|
||||||
$rootScope.getVideoURL = function(copayer) {
|
$rootScope.getVideoURL = function(copayer) {
|
||||||
var encoded = $rootScope.videoSrc[copayer];
|
var vi = $rootScope.videoInfo[copayer]
|
||||||
if (!encoded) return;
|
if (!vi) return;
|
||||||
|
var encoded = vi.url;
|
||||||
var url = decodeURI(encoded);
|
var url = decodeURI(encoded);
|
||||||
var trusted = $sce.trustAsResourceUrl(url);
|
var trusted = $sce.trustAsResourceUrl(url);
|
||||||
return trusted;
|
return trusted;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$rootScope.getVideoMutedStatus = function(copayer) {
|
||||||
|
var vi = $rootScope.videoInfo[copayer]
|
||||||
|
if (!vi) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return vi.muted;
|
||||||
|
};
|
||||||
|
|
||||||
$rootScope.getWalletDisplay = function() {
|
$rootScope.getWalletDisplay = function() {
|
||||||
var w = $rootScope.wallet;
|
var w = $rootScope.wallet;
|
||||||
return w && (w.name || w.id);
|
return w && (w.name || w.id);
|
||||||
|
@ -24,7 +33,7 @@ angular.module('copay.controllerUtils')
|
||||||
delete $rootScope['wallet'];
|
delete $rootScope['wallet'];
|
||||||
$rootScope.totalBalance = 0;
|
$rootScope.totalBalance = 0;
|
||||||
video.close();
|
video.close();
|
||||||
$rootScope.videoSrc = {};
|
$rootScope.videoInfo = {};
|
||||||
$location.path('signin');
|
$location.path('signin');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -41,10 +50,13 @@ angular.module('copay.controllerUtils')
|
||||||
root.startNetwork = function(w) {
|
root.startNetwork = function(w) {
|
||||||
var handlePeerVideo = function(err, peerID, url) {
|
var handlePeerVideo = function(err, peerID, url) {
|
||||||
if (err) {
|
if (err) {
|
||||||
delete $rootScope.videoSrc[peerID];
|
delete $rootScope.videoInfo[peerID];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$rootScope.videoSrc[peerID] = encodeURI(url);
|
$rootScope.videoInfo[peerID] = {
|
||||||
|
url: encodeURI(url),
|
||||||
|
muted: peerID === w.network.peerId
|
||||||
|
};
|
||||||
$rootScope.$digest();
|
$rootScope.$digest();
|
||||||
};
|
};
|
||||||
w.on('badMessage', function(peerId) {
|
w.on('badMessage', function(peerId) {
|
||||||
|
|
Loading…
Reference in New Issue