116 lines
4.3 KiB
PHP
116 lines
4.3 KiB
PHP
|
|
<script>
|
|||
|
|
function buildFileGalleryUrl(target, mode, ajaxFunction, nocache) {
|
|||
|
|
var base = "/module/knowledgecenter_update/Plugins/filesgallery.php?";
|
|||
|
|
var startPath = (typeof window.kcPostGalleryPath === "string")
|
|||
|
|
? window.kcPostGalleryPath.replace(/^\/+|\/+$/g, "")
|
|||
|
|
: "";
|
|||
|
|
var params = "input_id=" + encodeURIComponent(target) +
|
|||
|
|
"&mode=" + encodeURIComponent(mode) +
|
|||
|
|
"&saveajax=" + encodeURIComponent(ajaxFunction || "") +
|
|||
|
|
"&kc_lock_path=" + encodeURIComponent(startPath) +
|
|||
|
|
"&nocache=" + nocache;
|
|||
|
|
|
|||
|
|
if (startPath.length > 0) {
|
|||
|
|
return base + encodeURIComponent(startPath) + "&" + params;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return base + params;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function showMessage(message, isSuccess) {
|
|||
|
|
var $msg = $("#message");
|
|||
|
|
|
|||
|
|
// Vorherige Animationen stoppen und Opazität zurücksetzen
|
|||
|
|
$msg.stop(true, true).css("opacity", 1);
|
|||
|
|
|
|||
|
|
// Styling je nach Erfolg oder Fehler
|
|||
|
|
if (isSuccess) {
|
|||
|
|
$msg.css({
|
|||
|
|
"color": "green",
|
|||
|
|
"position": "relative",
|
|||
|
|
"background-color": "#d4edda",
|
|||
|
|
"margin-bottom": "10px",
|
|||
|
|
"border": "1px solid green"
|
|||
|
|
});
|
|||
|
|
} else {
|
|||
|
|
$msg.css({
|
|||
|
|
"color": "red",
|
|||
|
|
"position": "relative",
|
|||
|
|
"background-color": "#f8d7da",
|
|||
|
|
"margin-bottom": "10px",
|
|||
|
|
"border": "1px solid red"
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$msg.text(message).show();
|
|||
|
|
setTimeout(function () {
|
|||
|
|
$msg.animate({ opacity: 0 }, 500, function () {
|
|||
|
|
$msg.hide();
|
|||
|
|
});
|
|||
|
|
}, 3000);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Popup-Öffnen für die Files Gallery
|
|||
|
|
$(".openFileGallery").on("click", function () {
|
|||
|
|
var target = $(this).data("target");
|
|||
|
|
// Hole den Funktionsnamen aus data-ajax-function, Standardwert falls nicht definiert:
|
|||
|
|
var ajaxFunction = $(this).data("ajax-function");
|
|||
|
|
var nocache = new Date().getTime(); // Erzeugt einen Zeitstempel
|
|||
|
|
window.open(buildFileGalleryUrl(target, "single", ajaxFunction, nocache),
|
|||
|
|
"FileGallery", "width=1000,height=600");
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$(".openFileGalleryMulti").on("click", function () {
|
|||
|
|
var target = $(this).data("target");
|
|||
|
|
var ajaxFunction = $(this).data("ajax-function");
|
|||
|
|
var nocache = new Date().getTime(); // Zeitstempel zur Cache-Vermeidung
|
|||
|
|
window.open(buildFileGalleryUrl(target, "multi", ajaxFunction, nocache),
|
|||
|
|
"FileGallery", "width=1000,height=600");
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// Funktion, die vom Files Gallery Popup im Parent-Fenster aufgerufen wird
|
|||
|
|
window.setFilePath = function (path) {
|
|||
|
|
if (window.fileGalleryTarget) {
|
|||
|
|
$("#" + window.fileGalleryTarget).val(path);
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
// Alternative setFilePath-Funktion im globalen Kontext
|
|||
|
|
function setFilePath(path) {
|
|||
|
|
var input = document.getElementById(input_id);
|
|||
|
|
if (input) {
|
|||
|
|
input.value = path;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Event-Handler für den Clear-Button
|
|||
|
|
$(document).on("click", ".clearImage", function () {
|
|||
|
|
// Hole den data-target Wert – z.B. "image_1"
|
|||
|
|
var targetId = $(this).data("target");
|
|||
|
|
|
|||
|
|
// Leere das versteckte Input-Feld
|
|||
|
|
$("#" + targetId).val("");
|
|||
|
|
|
|||
|
|
// Suche das Vorschaubild innerhalb des Containers (.single_image_group)
|
|||
|
|
$(this).closest('.single_image_group').find('.preview')
|
|||
|
|
.attr("src", "") // Bildquelle entfernen
|
|||
|
|
.css("background-color", "#f3f3f3"); // Standardhintergrund setzen
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
$(document).ready(function () {
|
|||
|
|
$('.toggle').on('click', function (e) {
|
|||
|
|
e.preventDefault();
|
|||
|
|
// Lese das data-toggle-target Attribut des geklickten Elements aus
|
|||
|
|
var target = $(this).data('toggle-target');
|
|||
|
|
if (target) {
|
|||
|
|
// Suche nach allen Elementen mit dem gleichen data-toggle-target,
|
|||
|
|
// schließe aber das geklickte Element (und ggf. weitere Toggle-Elemente) aus.
|
|||
|
|
var $targetElements = $('[data-toggle-target="' + target + '"]').not('.toggle');
|
|||
|
|
if ($targetElements.length) {
|
|||
|
|
$targetElements.slideToggle();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
</script>
|