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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
<div id="edit-modal" class="modal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<div id="edit-modal-title" class="modal-title w-75">
<div class="placeholder-wave">
<span class="placeholder placeholder-lg" style="width: 200px;"></span>
</div>
</div>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div id="edit-modal-body" class="modal-body">
<div class="placeholder-wave">
<span class="placeholder placeholder-lg w-100 mb-4"></span>
<span class="placeholder placeholder-lg w-100 mb-4"></span>
<span class="placeholder placeholder-lg w-100 mb-4"></span>
</div>
</div>
<div class="modal-footer">
<div id="edit-modal-tools" class="me-auto"></div>
<button id="contact-save" type="button" class="btn btn-primary"></button>
</div>
</div>
</div>
</div>
<script>
let poi;
let section = 'roles';
let sub_section;
$('#edit-modal').on('hidden.bs.modal', function (e) {
if (window.location.hash) {
history.replaceState(null, '', 'connections');
}
})
if (window.location.hash) {
poi = window.location.hash.substr(1);
init_contact_edit(poi);
}
window.onhashchange = function() {
if (window.location.hash) {
poi = window.location.hash.substr(1);
init_contact_edit(poi);
}
};
$(document).on('click', '.contact-edit', function (e) {
e.preventDefault();
poi = this.dataset.id
init_contact_edit(poi);
});
$(document).on('click', '#contact-save', function () {
let form_data = $('#contact-edit-form').serialize() + '§ion=' + section + '&sub_section=' + sub_section;
$.post('contactedit/' + poi, form_data, function(data) {
if (!data.success) {
$.jGrowl(data.message, {sticky: false, theme: 'notice', life: 10000});
return;
}
activate(data);
$.jGrowl(data.message, {sticky: false, theme: ((data.success) ? 'info' : 'notice'), life: ((data.success) ? 3000 : 10000)});
// $('#edit-modal').modal('hide');
});
});
$(document).on('click', '.contact-tool', function (e) {
e.preventDefault();
let cmd = this.dataset.cmd;
$.get('contactedit/' + poi + '/' + cmd, function(data) {
$('#edit-modal-tools').html(data.tools);
$.jGrowl(data.message, {sticky: false, theme: ((data.success) ? 'info' : 'notice'), life: ((data.success) ? 3000 : 10000)});
if (cmd === 'drop') {
if ($('#contact-entry-wrapper-' + poi).length) {
$('#contact-entry-wrapper-' + poi).fadeOut();
}
$('#edit-modal').modal('hide');
}
});
});
$(document).on('click', '.section', function () {
section = this.dataset.section;
sub_section = '';
});
$(document).on('click', '.sub_section', function () {
if ($(this).hasClass('sub_section_active')) {
$(this).removeClass('sub_section_active');
sub_section = '';
}
else {
$(this).addClass('sub_section_active');
sub_section = this.dataset.section;
}
});
function init_contact_edit(poi) {
if (!poi)
return
$.get('contactedit/' + poi, function(data) {
if (!data.success) {
$.jGrowl(data.message, {sticky: false, theme: 'notice', life: 10000});
return;
}
$('#edit-modal').modal('show');
activate(data);
});
}
function activate(data) {
$('#edit-modal-title').css('filter', 'blur(0px)');
$('#edit-modal-body').css('filter', 'blur(0px)');
$('#contact-save').removeClass('disabled');
$('#contact-tools').removeClass('disabled');
if (data.title) {
$('#edit-modal-title').html(data.title);
}
if (data.body) {
$('#edit-modal-body').html(data.body);
}
if (data.tools) {
$('#edit-modal-tools').html(data.tools);
}
if (data.submit) {
$('#contact-save').html(data.submit);
}
if (data.role && $('#contact-role-' + poi).length) {
$('#contact-role-' + poi).html(data.role);
}
if (data.pending) {
$('#contact-save').removeClass('btn-primary');
$('#contact-save').addClass('btn-success');
}
else {
$('#contact-save').addClass('btn-primary');
$('#contact-save').removeClass('btn-success');
}
}
</script>
|