related to #1704 created JS file for common functions of the the new popin component

This commit is contained in:
MatthieuLP
2023-01-11 15:12:27 +01:00
parent 9e3968dd03
commit 74ba35b5f9
4 changed files with 55 additions and 104 deletions
+53
View File
@@ -0,0 +1,53 @@
function set_up_popin() {
$(".ClosePopIn").on('click', function () {
linked_albums_close();
});
}
function linked_albums_close() {
$("#addLinkedAlbum").fadeOut();
}
function linked_albums_open() {
$("#addLinkedAlbum").fadeIn();
$(".search-input").val("");
$(".search-input").focus();
$("#searchResult").empty();
$(".limitReached").html(str_no_search_in_progress);
}
function linked_albums_search(searchText) {
$(".linkedAlbumPopInContainer .searching").show();
$.ajax({
url: "ws.php?format=json&method=pwg.categories.getAdminList",
type: "POST",
dataType: "json",
data : {
search: searchText,
additional_output: "full_name_with_admin_links",
},
before: function () {
},
success: function (raw_data) {
$(".linkedAlbumPopInContainer .searching").hide();
categories = raw_data.result.categories;
fill_results(categories);
if (raw_data.result.limit_reached) {
$(".limitReached").html(str_result_limit.replace("%d", categories.length));
} else {
if (categories.length == 1) {
$(".limitReached").html(str_album_found);
} else {
$(".limitReached").html(str_albums_found.replace("%d", categories.length));
}
}
},
error: function (e) {
$(".linkedAlbumPopInContainer .searching").hide();
console.log(e.message);
}
})
}
+1 -52
View File
@@ -352,7 +352,7 @@ jQuery(document).ready(function() {
$("#linkedAlbumSearch .search-cancel-linked-album").hide();
}
if ($(this).val().length > 2) {
if ($(this).val().length > 0) {
linked_albums_search($(this).val());
} else {
$(".limitReached").html(str_no_search_in_progress);
@@ -473,57 +473,6 @@ function checkAlbumLock() {
}
// Parent album popin functions
function set_up_popin() {
$(".ClosePopIn").on('click', function () {
linked_albums_close();
});
}
function linked_albums_close() {
$("#addLinkedAlbum").fadeOut();
}
function linked_albums_open() {
$("#addLinkedAlbum").fadeIn();
$(".search-input").val("");
$(".search-input").focus();
$("#searchResult").empty();
$(".limitReached").html(str_no_search_in_progress);
}
function linked_albums_search(searchText) {
$(".linkedAlbumPopInContainer .searching").show();
$.ajax({
url: "ws.php?format=json&method=pwg.categories.getAdminList",
type: "POST",
dataType: "json",
data : {
search: searchText,
additional_output: "full_name_with_admin_links",
},
before: function () {
},
success: function (raw_data) {
$(".linkedAlbumPopInContainer .searching").hide();
categories = raw_data.result.categories;
fill_results(categories);
if (raw_data.result.limit_reached) {
$(".limitReached").html(str_result_limit.replace("%d", categories.length));
} else {
if (categories.length == 1) {
$(".limitReached").html(str_album_found);
} else {
$(".limitReached").html(str_albums_found.replace("%d", categories.length));
}
}
},
error: function (e) {
$(".linkedAlbumPopInContainer .searching").hide();
console.log(e.message);
}
})
}
function fill_results(cats) {
$("#searchResult").empty();
-52
View File
@@ -34,58 +34,6 @@ $(document).ready(function () {
})
})
function set_up_popin() {
$(".ClosePopIn").on('click', function () {
linked_albums_close();
});
}
function linked_albums_close() {
$("#addLinkedAlbum").fadeOut();
}
function linked_albums_open() {
$("#addLinkedAlbum").fadeIn();
$(".search-input").val("");
$(".search-input").focus();
$("#searchResult").empty();
$(".limitReached").html(str_no_search_in_progress);
}
function linked_albums_search(searchText) {
$(".linkedAlbumPopInContainer .searching").show();
$.ajax({
url: "ws.php?format=json&method=pwg.categories.getAdminList",
type: "POST",
dataType: "json",
data : {
search: searchText,
additional_output: "full_name_with_admin_links",
},
before: function () {
},
success: function (raw_data) {
$(".linkedAlbumPopInContainer .searching").hide();
categories = raw_data.result.categories;
fill_results(categories);
if (raw_data.result.limit_reached) {
$(".limitReached").html(str_result_limit.replace("%d", categories.length));
} else {
if (categories.length == 1) {
$(".limitReached").html(str_album_found);
} else {
$(".limitReached").html(str_albums_found.replace("%d", categories.length));
}
}
},
error: function (e) {
$(".linkedAlbumPopInContainer .searching").hide();
console.log(e.message);
}
})
}
function fill_results(cats) {
$("#searchResult").empty();
cats.forEach(cat => {
@@ -1,5 +1,6 @@
{if empty($load_mode)}{$load_mode='footer'}{/if}
{include file='include/colorbox.inc.tpl' load_mode=$load_mode}
{combine_script id='albumSelector' load_mode=$load_mode path='admin/themes/default/js/album_selector.js'}
<div id="addLinkedAlbum" class="linkedAlbumPopIn">
<div class="linkedAlbumPopInContainer">