diff options
author | Tim Almdal <tnalmdal@shaw.ca> | 2009-02-21 02:28:19 +0000 |
---|---|---|
committer | Tim Almdal <tnalmdal@shaw.ca> | 2009-02-21 02:28:19 +0000 |
commit | c2fa42cf6cf6a2742b2a40ef7fc46f95f7a734f3 (patch) | |
tree | fdb541eb6d7310ea7582a5aaaaf5bd8201f767d3 /modules/local_import/js/admin.js | |
parent | af2f7f2c565519c177e9ef7d9848419936ddf8fb (diff) |
Implementation of local import module. Still need work on better
status messages.
Diffstat (limited to 'modules/local_import/js/admin.js')
-rw-r--r-- | modules/local_import/js/admin.js | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/modules/local_import/js/admin.js b/modules/local_import/js/admin.js new file mode 100644 index 00000000..e5ceb7cf --- /dev/null +++ b/modules/local_import/js/admin.js @@ -0,0 +1,47 @@ +/** + * Set up autocomplete on the server path list + * + */ +$("document").ready(function() { + add_autocomplete(); + ajaxify_import_form(); + add_onclick(); +}); + +function add_autocomplete() { + $("#gLocalImportAdmin input:text").autocomplete(base_url + "admin/local_import/autocomplete", { + extraParams: {csrf: csrf}, + mustMatch: true, + max: 256}); +} +function ajaxify_import_form(options) { + $("#gLocalImportAdmin form").ajaxForm({ + dataType: "json", + success: function(data) { + if (data.form) { + $("#gLocalImportAdmin form").replaceWith(data.form); + ajaxify_import_form(); + add_autocomplete(); + } + if (data.result == "success") { + $("#gNoImportPaths").css("display", "none"); + $("#gAuthorizedPath").html(data.paths); + add_onclick(); + } + } + }); +} + +function add_onclick() { + $(".gRemoveDir").click(function() { + var parent = $(this).parent(); + $.post( + base_url + "admin/local_import/remove", + {csrf: csrf, + path: parent.text().replace(/^\s\s*/, "").replace(/\s\s*$/, "")}, + function(data, textStatus) { + $("#gAuthorizedPath").html(data); + add_onclick(); + }); + }); +} |