From 97cc62128f425938227af3a6d21c5e70278e3eca Mon Sep 17 00:00:00 2001 From: mistic100 Date: Sun, 14 Jul 2013 16:43:22 +0000 Subject: bug:2944 Performance issues when creating an album git-svn-id: http://piwigo.org/svn/trunk@23944 68402e56-0260-453c-a942-63ccdbb3a9ee --- .../default/template/include/add_album.inc.tpl | 109 +++++++++------------ 1 file changed, 49 insertions(+), 60 deletions(-) (limited to 'admin/themes/default') diff --git a/admin/themes/default/template/include/add_album.inc.tpl b/admin/themes/default/template/include/add_album.inc.tpl index 1fe8cea21..d950ad5ce 100644 --- a/admin/themes/default/template/include/add_album.inc.tpl +++ b/admin/themes/default/template/include/add_album.inc.tpl @@ -1,81 +1,67 @@ {footer_script}{literal} jQuery(document).ready(function(){ - function fillCategoryListbox(selectId, selectedValue) { - jQuery.getJSON( - "ws.php?format=json&method=pwg.categories.getList", - { - recursive: true, - fullname: true, - format: "json", - }, - function(data) { - jQuery.each( - data.result.categories, - function(i,category) { - var selected = null; - if (category.id == selectedValue) { - selected = "selected"; - } - - jQuery("') + .append(jQuery("#albumSelect").html()) + .val(jQuery("#albumSelect").val()); } }); - jQuery("#addAlbumForm form").submit(function(){ + jQuery("#addAlbumForm form").submit(function() { jQuery("#categoryNameError").text(""); + + var parent_id = jQuery("select[name=category_parent] option:selected").val(), + name = jQuery("input[name=category_name]").val(); jQuery.ajax({ - url: "ws.php?format=json&method=pwg.categories.add", + url: "ws.php", + dataType: 'json', data: { - parent: jQuery("select[name=category_parent] option:selected").val(), - name: jQuery("input[name=category_name]").val(), + format: 'json', + method: 'pwg.categories.add', + parent: parent_id, + name: name }, beforeSend: function() { jQuery("#albumCreationLoading").show(); }, - success:function(html) { + success: function(data) { jQuery("#albumCreationLoading").hide(); - - var newAlbum = jQuery.parseJSON(html).result.id; jQuery(".addAlbumOpen").colorbox.close(); - jQuery("#albumSelect").find("option").remove(); - fillCategoryListbox("albumSelect", newAlbum); - - /* we refresh the album creation form, in case the user wants to create another album */ - jQuery("#category_parent").find("option").remove(); - - jQuery("