blob: 539017f3579db03649e45b222fad38cc28600ddc (
plain)
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
|
$(document).ready(function(){
// Handler functions
function addSiteEventHandler(event) {
event.preventDefault();
saveSites();
}
function deleteButtonEventHandler(event) {
event.preventDefault();
if($(this).parent().is(':only-child')) {
$(this).parent().children('input').val('');
$(this).parent().children('select').val('');
} else {
$(this).tipsy('hide');
$(this).parent().remove();
}
saveSites();
}
function saveSites() {
var post = $('#external').serialize();
OC.msg.startSaving('#external .msg');
$.post( OC.filePath('external','ajax','setsites.php') , post, function(data) {
OC.msg.finishedSaving('#external .msg', data);
});
}
function showDeleteButton() {
$(this).find('img.delete_button').fadeIn(100);
}
function hideDeleteButton() {
$(this).find('img.delete_button').fadeOut(100);
}
// Initialize events
$('input[name^=site_]').change(addSiteEventHandler);
$('select[name^=site_]').change(addSiteEventHandler);
$('img.delete_button').click(deleteButtonEventHandler);
$('img.delete_button').tipsy();
$('#external li').hover(showDeleteButton, hideDeleteButton);
$('#add_external_site').click(function(event) {
event.preventDefault();
$('#external ul li:last').clone().appendTo('#external ul');
$('#external ul li:last input').val('');
$('#external ul li:last select').val('');
$('input.site_url:last').prev('input.site_name').andSelf().change(addSiteEventHandler);
$('img.delete_button').click(deleteButtonEventHandler);
$('img.delete_button:last').tipsy();
$('#external li:last').hover(showDeleteButton, hideDeleteButton);
});
});
|