-
Notifications
You must be signed in to change notification settings - Fork 1
/
angular-avbuttons.js
42 lines (34 loc) · 1011 Bytes
/
angular-avbuttons.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/**
* Created by ticup on 18/11/13.
*/
// Availability Buttons
////////////////////////
angular
.module('avbuttons', ['cloudtypes'])
.directive('avbuttons', function avbuttons($client) {
return function (scope, elem, attrs) {
var cnButton = $(attrs.connect);
var dcButton = $(attrs.disconnect);
function showConnect() {
dcButton.removeClass('active');
cnButton.addClass('active');
}
function showDisconnect() {
cnButton.removeClass('active');
dcButton.addClass('active');
}
$client.onConnect(showConnect);
$client.onReconnect(showConnect);
$client.onDisconnect(showDisconnect);
cnButton.click(function () {
if (!cnButton.hasClass('active')) {
$client.reconnect();
}
});
dcButton.click(function () {
if (!dcButton.hasClass('active')) {
$client.disconnect();
}
});
};
});