diff options
Diffstat (limited to 'modules/server_add/js/server_add.js')
-rw-r--r-- | modules/server_add/js/server_add.js | 70 |
1 files changed, 60 insertions, 10 deletions
diff --git a/modules/server_add/js/server_add.js b/modules/server_add/js/server_add.js index e2526dbe..568ef91f 100644 --- a/modules/server_add/js/server_add.js +++ b/modules/server_add/js/server_add.js @@ -1,3 +1,62 @@ +/** + * We've clicked the + icon next to a directory. Load up children of this + * directory from the server and display them. + */ +function open_close_branch(path, id) { + var parent = $("#file_" + id); + var children = $("#tree_" + id); + var icon = parent.find(".ui-icon:first"); + + if (!children.html()) { + parent.addClass("gLoadingSmall"); + $.ajax({ + url: GET_CHILDREN_URL.replace("__PATH__", path), + success: function(data, textStatus) { + children.html(data); + parent.removeClass("gLoadingSmall"); + + // Propagate checkbox value + children.find("input[type=checkbox]").attr( + "checked", parent.find("input[type=checkbox]:first").attr("checked")); + }, + }); + } + + children.slideToggle("fast", function() { + if (children.is(":hidden")) { + icon.addClass("ui-icon-plus"); + icon.removeClass("ui-icon-minus"); + } else { + icon.addClass("ui-icon-minus"); + icon.removeClass("ui-icon-plus"); + parent.removeClass("gCollapsed"); + } + }); +} + +/** + * We've clicked a checkbox. Propagate the value downwards as necessary. + */ +function click_node(checkbox) { + var parent = $(checkbox).parents("li").get(0); + var checked = $(checkbox).attr("checked"); + $(parent).find("input[type=checkbox]").attr("checked", checked); + + // @todo if we uncheck all the children for a parent, we should uncheck the + // parent itself, otherwise in the code we'll add the entire parent since if + // we find an album as a leaf, we assume that it's never been expanded in the UI. + if ($("#gServerAddTree").find("input[type=checkbox]").is(":checked")) { + $("#gServerAddAddButton").enable(true); + $("#gServerAddAddButton").removeClass("ui-state-disabled"); + } else { + $("#gServerAddAddButton").enable(false); + $("#gServerAddAddButton").addClass("ui-state-disabled"); + } +} + +/* ================================================================================ */ + +/* var paused = false; var task = null; @@ -82,16 +141,6 @@ function get_url(uri, task_id) { return url; } -function checkbox_click(checkbox) { - var parent = $(checkbox).parents("li").get(0); - var checked = $(checkbox).attr("checked"); - if (!$(parent).hasClass("gCollapsed")) { - $(parent).find(".gCheckboxTree input[type=checkbox]").attr("checked", checked); - } - var checkboxes = $("#gServerAdd :checkbox[checked]"); - $("#gServerAdd form :submit").attr("disabled", checkboxes.length == 0); -} - function load_children(icon) { $("#gDialog").addClass("gDialogLoadingLarge"); var parent = icon.parentNode; @@ -203,3 +252,4 @@ function display_upload_error(error) { }); } +*/ |