forked from chadsmith/OpenVBX-Plugin-Subscriptions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
subscriptions.js
83 lines (83 loc) · 3.4 KB
/
subscriptions.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
$(function(){
$('#button-import-list').click(function() {
$('.vbx-subscriptions form:not(.import-list), .vbx-subscriptions .subscriber').slideUp();
$('.vbx-subscriptions form.import-list').slideToggle();
return false;
});
$('#button-export-list').click(function() {
$('.vbx-subscriptions form:not(.export-list), .vbx-subscriptions .subscriber').slideUp();
$('.vbx-subscriptions form.export-list').slideToggle();
return false;
});
$('#button-add-list').click(function() {
$('.vbx-subscriptions form:not(.add-list), .vbx-subscriptions .subscriber').slideUp();
$('.vbx-subscriptions form.add-list').slideToggle();
return false;
});
$('.vbx-subscriptions a.subscribers').click(function() {
var $list = $(this).parent().parent().parent();
var id = $list.attr('id');
var $form=$('.vbx-subscriptions form:not(.add):visible');
$('.vbx-subscriptions .subscriber:not(.' + id + '):visible').slideUp();
$('.vbx-subscriptions .subscriber.' + id).slideToggle();
$form[id.match(/([\d]+)/)[1] != $form.find('input[name="list"]').val() ? 'slideUp' : 'show']();
return false;
});
$('.vbx-subscriptions .list a.delete').click(function() {
var $list = $(this).parent().parent().parent();
var id = $list.attr('id');
if(confirm('You are about to delete "' + $list.children().children('span').eq(0).text() + '" and all its subscribers.'))
$.ajax({
type: 'POST',
url: window.location,
data: { remove: id.match(/([\d]+)/)[1] },
success: function() {
$list.add('.vbx-subscriptions .subscriber.' + id).hide(500);
},
dataType: 'text'
});
return false;
});
$('.vbx-subscriptions .subscriber a.delete').click(function() {
var $subscriber = $(this).parent().parent().parent();
var id = $subscriber.attr('id').split('_');
var $list = $('#list_' + id[1]);
var $num = $list.find('span').eq(1);
if(confirm('You are about to remove ' + $subscriber.children().children('span').eq(0).text() + ' from "' + $list.find('span').eq(0).text() + '".'))
$.ajax({
type: 'POST',
url: window.location,
data: { remove: id[2], list: id[1] },
success: function() {
$subscriber.hide(500);
$num.text(parseInt($num.text()) - 1);
},
dataType: 'text'
});
return false;
});
$('.vbx-subscriptions a.sms').click(function() {
var $list = $(this).parent().parent().parent();
var id = $list.attr('id');
var list = id.match(/([\d]+)/)[1];
var $input = $('.vbx-subscriptions form.update-sms input[name="list"]');
var $form = $('.vbx-subscriptions form.update-sms');
$('.vbx-subscriptions form:visible').not($form).add('.vbx-subscriptions .subscriber:not(.' + id + ')').slideUp();
$form[list == $input.val() ? 'slideToggle' : 'slideDown']();
$form.children('h3').children('span').text($list.children().children('span').eq(0).text());
$input.val(list);
return false;
});
$('.vbx-subscriptions a.call').click(function() {
var $list = $(this).parent().parent().parent();
var id = $list.attr('id');
var list = id.match(/([\d]+)/)[1];
var $input = $('.vbx-subscriptions form.update-dial input[name="list"]');
var $form = $('.vbx-subscriptions form.update-dial');
$('.vbx-subscriptions form:visible').not($form).add('.vbx-subscriptions .subscriber:not(.' + id + ')').slideUp();
$form[list == $input.val() ? 'slideToggle' : 'slideDown']();
$form.children('h3').children('span').text($list.children().children('span').eq(0).text());
$input.val(list);
return false;
});
});