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
|
/**
* Set up autocomplete on the server path list
*
*/
$("document").ready(function() {
var previous_search = "";
$("#gLocalImportAdmin input").autocomplete({
url: base_url + "admin/local_import/autocomplete",
mustMatch: true,
});
ajaxify_form({
form: "#gLocalImportAdmin form",
url: "admin/local_import/",
returnCode: 200,
callback: function(xhr, statusText) {
$("#gImportLocalDirList").html(xhr.responseText);
setDroppable("#gImportLocalDirList #gRemoveDir");
setDraggable("#gImportLocalDirList li");
}
});
setDroppable("#gImportLocalDirList #gRemoveDir");
setDraggable("#gImportLocalDirList li");
});
function setDraggable(selector) {
$(selector).draggable({
helper: 'clone',
// containment: "#gImportLocalDirList",
opacity: .6,
revert: "invalid"
});
}
function setDroppable(selector) {
$(selector).droppable({
accept: "#gImportLocalDirList li",
drop: function(ev, ui) {
var element = ui.draggable[0];
if (confirm("Do you really want to remove " + element.textContent)) {
$.ajax({
data: "path=" + element.textContent,
url: base_url + "admin/local_import/remove",
success: function(data, textStatus) {
$("#gImportLocalDirList").html(data);
setDroppable("#gImportLocalDirList #gRemoveDir");
setDraggable("#gImportLocalDirList li");
},
error: function(xhr, textStatus, errorThrown) {
alert("Text Status: " + textStatus + " Http Error Code: " + xhr.status);
},
type: "POST"
});
}
}
});
}
function ajaxify_form(options) {
$(options.form).ajaxForm({
complete:function(xhr, statusText) {
options.callback(xhr, statusText);
$(options.form).clearForm();
}
});
}
|