@Html.EJS().FileManager("file").AjaxSettings(new Syncfusion.EJ2.FileManager.FileManagerAjaxSettings
{
Url = "/Home/FileOperations",
GetImageUrl = "/Home/GetImage",
UploadUrl = "/Home/Upload",
DownloadUrl = "/Home/Download"
}).View(Syncfusion.EJ2.FileManager.ViewType.Details).BeforePopupOpen("beforeOpen").ShowThumbnail(false).FileLoad("fileLoad").FileOpen("fileOpen").Render()
function beforeOpen(args) {
if (args.popupName == "Image Preview") {
if (args.popupModule.target == "BODY") {
var element = args.popupModule.dlgContainer.querySelector(
".e-dlg-header-content"
);
// Create a two button in dialog component.
var newItem = document.createElement("BUTTON");
newItem.setAttribute("class", "next");
newItem.appendChild(document.createTextNode("Next"));
var newItem1 = document.createElement("BUTTON");
newItem1.setAttribute("class", "previous");
newItem1.appendChild(document.createTextNode("previous"));
element.insertBefore(newItem, element.children[2]);
element.insertBefore(newItem1, element.children[2]);
newItem.addEventListener("click", Next_button.bind(this));
newItem1.addEventListener("click", Next_button.bind(this));
}
if (args.popupModule.target !== "BODY") {
args.cancel = true;
args.popupModule.target = "BODY";
args.popupModule.minHeight = "200px";
args.popupModule.dataBind();
}
}
} |
function Next_button(args) {
//fetch the image element in dialog.
var image_element = document.querySelector(".e-image");
// split the image src.
var src_array = (image_element).src.split("&")[0].split("/");
// fetch the file name in src url.
var image_value = image_array.indexOf(src_array[src_array.length - 1]);
// check if the button is next or previous.
if (args.target.innerText == "Next") {
var next_data = image_array[image_value + 1];
if (next_data) {
// update the dialog title when changing the data.
document.querySelector(
"#file_img_dialog_title"
).innerHTML = next_data;
src_array[src_array.length - 1] = next_data;
// changing the alt data of corresponding image.
(image_element).alt = image_array[image_value + 1];
}
} else if (args.target.innerText == "previous") {
var previous_data = image_array[image_value - 1];
if (previous_data) {
document.querySelector(
"#file_img_dialog_title"
).innerHTML = previous_data;
src_array[src_array.length - 1] = previous_data;
(image_element).alt = previous_data;
}
}
// changing the src value of corresponding image.
(image_element).src = src_array.join().replaceAll(",", "/");
} |