Feuerwehr-eppingen/public/js/admin-script.js
Marco Glietsch 369e9fb0af Hinzugefügt
- Berechtigungen für Kurzmitteilungen
- Adminscript für Modelle ohne Veröffentlichungen angepasst
2020-11-19 21:45:01 +01:00

1100 lines
32 KiB
JavaScript

/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "/";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 4);
/******/ })
/************************************************************************/
/******/ ({
/***/ "./resources/assets/js/admin-script.js":
/*!*********************************************!*\
!*** ./resources/assets/js/admin-script.js ***!
\*********************************************/
/*! no static exports found */
/***/ (function(module, exports) {
/**
* Created by Marco Glietsch on 03.12.2018.
*/
$(document).ready(function () {
var is_ajax_fire = 0;
var itemsPerPage = $('#itemsPerPage').find(":selected").val();
var page = 1;
var current_page = 1;
var total_page = 0;
var orderColumn = '';
var orderDirection = '';
var searchText = '';
var p_orderColumn = '';
var p_orderDirection = '';
var p_searchText = '';
var wizardStates = {
CLOSED: 0,
FORWARD_TO_STEP_FORM: 1,
STEP_FORM: 2,
FORWARD_TO_STEP_FILES: 3,
BACK_TO_STEP_FORM: 4,
STEP_FILES: 5,
FORWARD_TO_STEP_PUBLISH: 6,
BACK_TO_STEP_FILES: 7,
STEP_PUBLISH: 8,
SAVE: 9,
CANCEL: 10,
CLOSE: 11
};
var wizardState = wizardStates.CLOSED;
var wizardButtonStates = {
NONE: 0,
BUTTON_BACK: 1,
BUTTON_NEXT: 2,
BUTTON_SAVE: 3,
BUTTON_CANCEL: 4
};
toastr.options = {
'newestOnTop': false,
'timeOut': 5000
};
reloadPagination();
function reloadPagination() {
var type = $('.pagination-sm').data('type');
if (type == undefined) {
type = $('#ajax-container').data('type');
}
var p_orderColumn = '';
var p_orderDirection = '';
var p_searchText = '';
if (orderColumn != '') {
p_orderColumn = '&orderBy=' + orderColumn;
}
if (orderDirection != '') {
p_orderDirection = '&orderDirection=' + orderDirection;
}
if (searchText != '') {
p_searchText = '&search=' + searchText;
}
$.ajax({
url: '/admin/' + type + '-index-ajax?page=' + page + p_orderColumn + p_orderDirection + p_searchText,
data: '',
success: function success(data) {
if (data.status.error == false) {
if (data.content.models) {
total_page = data.content.models.last_page;
current_page = data.content.models.current_page;
} else {
total_page = 1;
current_page = 1;
}
if ($('.pagination-sm').data('twbsPagination')) {
$('.pagination-sm').twbsPagination('destroy');
}
$('.pagination-sm').twbsPagination({
totalPages: total_page,
visiblePages: 10,
startPage: current_page,
first: '<<',
prev: '<',
next: '>',
last: '>>',
nextClass: 'btn btn-outline-primary',
prevClass: 'btn btn-outline-primary',
lastClass: 'btn btn-outline-primary',
firstClass: 'btn btn-outline-primary',
pageClass: 'btn btn-outline-primary',
activeClass: 'active',
disabledClass: 'disabled',
anchorClass: '',
onPageClick: function onPageClick(event, pageL) {
page = pageL;
if (is_ajax_fire != 0) {
getPageData(type);
}
}
});
$('#ajax-container').html(data.content.html);
is_ajax_fire = 1;
}
}
});
}
/* Get Page Data*/
function getPageData(type) {
////////////////////////
// Fallunterscheidung //
////////////////////////
// Es handelt sich um den Adminbereich: Die Liste mit den Posts wird per Ajax neu geladen
if ($('#ajax-container').length) {
var accordion = $('#ajax-container #accordion .collapse.show').data('page');
if (accordion !== undefined) {
page = accordion;
}
$.ajax({
url: '/admin/' + type + '-index-ajax',
dataType: 'json',
data: {
page: page,
orderBy: orderColumn,
orderDirection: orderDirection,
itemsPerPage: itemsPerPage,
search: searchText
},
success: function success(data) {
if (data.status.error == false) {
$('#ajax-container').html(data.content.html);
}
}
});
} // Es handelt sich um ein Inline-Edit: Es wird die ganze Seite neu geladen
else {
location.reload();
}
}
$(document).on('click', 'tr', function (e) {
// e.preventDefault();
navigateTableElement(this);
});
function updateWizardForm(data) {
var wizardButtonState = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : wizardButtonStates.NONE;
var id = $('#crudForm input[name=id]').val();
var type = $('#crudForm').data('type');
if (wizardButtonState == wizardButtonStates.CANCEL) {
wizardState = wizardStates.CANCEL;
}
switch (wizardState) {
// Der Dialog wird noch nicht angezeigt
case wizardStates.CLOSED:
// Formulardaten laden
$('#modalDialogContainer').html(data.content.html); // Navigationstabs verstecken und den nächsten Tab anzeigen
$('.nav-tabs').hide();
$('.nav-tabs a[href="#general-details"]').tab('show');
var tabcount = $('#modal-tab-header-container li').length; // Nur benötigte Schaltflächen anzeigen
$('.btn.wizard_step_back').hide();
if (tabcount < 1) {
$('.btn.wizard_step_forward').hide();
$('.btn.save').hide();
} else if (tabcount == 1) {
$('.btn.wizard_step_forward').hide();
$('.btn.save').show();
} else {
$('.btn.wizard_step_forward').show();
$('.btn.save').hide();
} // Schaltflächen-Events registrieren
$('.modal-footer').on('click', '.wizard_step_back', function (e) {
e.preventDefault();
updateWizardForm(null, wizardButtonStates.BUTTON_BACK);
});
$('.modal-footer').on('click', '.wizard_step_forward', function (e) {
e.preventDefault();
updateWizardForm(null, wizardButtonStates.BUTTON_NEXT);
});
$('.modal-footer').on('click', '.save', function (e) {
e.preventDefault();
updateWizardForm(null, wizardButtonStates.BUTTON_SAVE);
});
$('.modal-footer').on('click', '.cancel', function (e) {
e.preventDefault();
updateWizardForm(null, wizardButtonStates.BUTTON_CANCEL);
}); // Dropzone registrieren
Dropzone.discover(); // Dialog anzeigen
$('#modalDialogContainer').modal('show');
$('#modalDialogContainer').on('hidden.bs.modal', function (e) {
e.stopImmediatePropagation();
if (wizardState != wizardStates.CLOSED) {
wizardState = wizardStates.CANCEL;
updateWizardForm(null);
}
});
wizardState = wizardStates.STEP_FORM;
break;
case wizardStates.FORWARD_TO_STEP_FORM:
break;
case wizardStates.STEP_FORM:
// Überprüfe, welche Schaltfläche betätigt wurde
switch (wizardButtonState) {
case wizardButtonStates.BUTTON_NEXT:
// Überprüfe die Formulareingabe
$.ajax({
type: 'PUT',
url: '/admin/' + type + '/' + id + '/check?wizard=wizard',
data: $('#crudForm').serialize() + "&wizard=wizard",
success: function success(data) {
var validatedForm = $(data.content.html).find('#crudForm').html();
$('#crudForm').html(validatedForm);
var publishForm = $(data.content.html).find('#publish-details').html();
$('#publish-details').html(publishForm);
if (data.status.error == true) {
// Es sind Eingabefehler im Formular vorhanden
showMessages(data.messages);
} else {
// Eingabe war in Ordnung
wizardState = wizardStates.FORWARD_TO_STEP_FILES;
updateWizardForm(null);
}
}
});
break;
case wizardButtonStates.BUTTON_SAVE:
wizardState = wizardStates.SAVE;
updateWizardForm(null);
break;
}
break;
case wizardStates.FORWARD_TO_STEP_FILES:
// Tab "Dateien" anzeigen
$('.nav-tabs a[href="#files-details"]').tab('show'); // Nur benötigte Schaltflächen anzeigen
$('.btn.wizard_step_back').show();
if ($(".nav-item a[href='#files-details']").length) {
$('.btn.wizard_step_forward').show();
$('.btn.save').hide();
wizardState = wizardStates.STEP_FILES;
} else {
wizardState = wizardStates.FORWARD_TO_STEP_PUBLISH;
updateWizardForm(null);
}
break;
case wizardStates.BACK_TO_STEP_FORM:
// Tab "Allgemein" anzeigen
$('.nav-tabs a[href="#general-details"]').tab('show'); // Nur benötigte Schaltflächen anzeigen
$('.btn.wizard_step_back').hide();
$('.btn.wizard_step_forward').show();
$('.btn.save').hide();
wizardState = wizardStates.STEP_FORM;
break;
case wizardStates.STEP_FILES:
// Überprüfe, welche Schaltfläche betätigt wurde
switch (wizardButtonState) {
case wizardButtonStates.BUTTON_BACK:
wizardState = wizardStates.BACK_TO_STEP_FORM;
updateWizardForm(null);
break;
case wizardButtonStates.BUTTON_NEXT:
wizardState = wizardStates.FORWARD_TO_STEP_PUBLISH;
updateWizardForm(null);
break;
case wizardButtonStates.BUTTON_SAVE:
wizardState = wizardStates.SAVE;
updateWizardForm(null);
break;
}
break;
break;
case wizardStates.FORWARD_TO_STEP_PUBLISH:
// Tab "Veröffentlichen" anzeigen
$('.nav-tabs a[href="#publish-details"]').tab('show'); // Nur benötigte Schaltflächen anzeigen
$('.btn.wizard_step_back').show();
$('.btn.wizard_step_forward').hide();
$('.btn.save').show();
wizardState = wizardStates.STEP_PUBLISH;
break;
case wizardStates.BACK_TO_STEP_FILES:
// Tab "Veröffentlichen" anzeigen
$('.nav-tabs a[href="#files-details"]').tab('show'); // Nur benötigte Schaltflächen anzeigen
$('.btn.wizard_step_back').show();
$('.btn.wizard_step_forward').show();
$('.btn.save').hide();
wizardState = wizardStates.STEP_FILES;
break;
case wizardStates.STEP_PUBLISH:
// Überprüfe, welche Schaltfläche betätigt wurde
switch (wizardButtonState) {
case wizardButtonStates.BUTTON_BACK:
wizardState = wizardStates.BACK_TO_STEP_FILES;
updateWizardForm(null);
break;
case wizardButtonStates.BUTTON_SAVE:
wizardState = wizardStates.SAVE;
updateWizardForm(null);
break;
}
break;
case wizardStates.SAVE:
// Daten speichern und Dialog schließen
// Überprüfe die Formulareingabe
$.ajax({
type: 'PUT',
url: $('#crudForm').attr('action') + '?wizard=wizard',
data: createFormData(true),
success: function success(data) {
if (data.status.error == true) {
// Es sind Eingabefehler im Formular vorhanden
var validatedForm = $(data.content.html).find('#crudForm').html();
$('#crudForm').html(validatedForm);
showMessages(data.messages);
wizardStates.FORWARD_TO_STEP_FILES;
updateWizardForm(null);
} else {
// Eingabe war in Ordnung
showMessages(data.messages);
wizardState = wizardStates.CLOSE;
updateWizardForm(null);
}
}
});
break;
case wizardStates.CANCEL:
if (wizardState != wizardStates.CLOSED) {
$.ajax({
type: 'DELETE',
url: '/admin/' + type + '/' + id,
data: {
'_token': $('input[name=_token]').val(),
'_method': 'DELETE',
'wizard': true
},
success: function success(data) {
if (data.status.error == true) {} else {}
}
});
}
// Kein break
case wizardStates.CLOSE:
wizardState = wizardStates.CLOSED;
getPageData(type);
closeDialog();
break;
}
}
function closeDialog() {
$('.modal').modal('hide');
$('.modal-backdrop').remove();
}
function registerEditForm(data) {
var allreadyOpened = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
if (allreadyOpened == false) {
$('.modal-backdrop').remove();
}
$('#modalDialogContainer').html(data.content.html);
Dropzone.discover();
$('#modalDialogContainer').modal('show');
$('#crudForm').on('submit', function (e) {
e.preventDefault();
submitEditForm();
});
$('.modal-footer').on('click', '.save', function (e) {
submitEditForm();
});
}
function submitEditForm() {
var type = $('#ajax-container').data('type');
if (type == undefined) {
var type = $('#crudForm').data('type');
}
$.ajax({
type: 'PUT',
url: $('#crudForm').attr('action'),
data: createFormData(),
success: function success(data) {
if (data.status.error == true) {
setTimeout(function () {
registerEditForm(data);
showMessages(data.messages);
}, 500);
} else {
getPageData(type);
showMessages(data.messages);
$('#modalDialogContainer').modal('hide');
}
}
});
}
function showMessages(messages) {
$.each(messages, function (key, message) {
if (message.title && message.message) {
switch (message.type.toUpperCase()) {
case 'SUCCESS':
toastr.success(message.message, message.title);
break;
case 'INFO':
toastr.info(message.message, message.title);
break;
case 'WARNING':
toastr.warning(message.message, message.title);
break;
case 'ERROR':
toastr.error(message.message, message.title);
break;
}
}
});
}
function createFormData() {
var wizard = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
var element;
element = $('#publish_website');
var publish_website = '';
if (element.length) {
publish_website = '&publish_website=' + (element.is(':checked') ? 'true' : 'false');
}
element = $('#publish_facebook');
var publish_facebook = '';
if (element.length) {
publish_facebook = '&publish_facebook=' + (element.is(':checked') ? 'true' : 'false');
}
element = $('#publish_twitter');
var publish_twitter = '';
if (element.length) {
publish_twitter = '&publish_twitter=' + (element.is(':checked') ? 'true' : 'false');
}
element = $('#publish_stadtanzeiger');
var publish_stadtanzeiger = '';
if (element.length) {
publish_stadtanzeiger = '&publish_stadtanzeiger=' + (element.is(':checked') ? 'true' : 'false');
}
var is_wizard = '';
if (wizard == true) {
is_wizard = wizard == true ? '&wizard=wizard' : '';
}
var data = $('#crudForm').serialize() + publish_website + publish_facebook + publish_twitter + publish_stadtanzeiger + is_wizard;
return data;
}
/**/
// add a new post
$(document).on('click', '.add-modal', function (e) {
e.preventDefault();
var type = $(this).data('type');
var title = $(this).data('title');
$('.modal-title').text(title + ' erstellen');
$.ajax({
type: 'GET',
url: '/admin/' + type + '/erstellen',
success: function success(data) {
if (data.status.error == false) {
wizardState = wizardStates.CLOSED;
updateWizardForm(data);
} else {
toastr.error('Fehler beim Erstellen', "Fehler");
}
}
});
}); // Show a post
$(document).on('click', '.show-modal', function (e) {
e.preventDefault();
var id = $(this).data('id');
var type = $(this).data('type');
var title = $(this).data('title');
showPostDetails(id, type);
});
function showPostDetails(id, type) {
$.ajax({
type: 'GET',
url: '/admin/' + type + '/' + id + '/details',
success: function success(data) {
if (data.status.error == false) {
$('.modal-backdrop').remove();
$('#modalDialogContainer').html(data.content.html);
$('#modalDialogContainer').modal('show');
} else {
toastr.error('Fehler beim öffnen', "Fehler");
}
}
});
}
$(document).on('click', '.move-up', function (e) {
e.preventDefault();
var id = $(this).data('id');
var type = $(this).data('type');
$.ajax({
type: 'GET',
url: '/admin/' + type + '/' + id + '/auf',
success: function success(data) {
if (data.status.error == false) {
getPageData(type);
} else {
toastr.error('Fehler beim bearbeiten', "Fehler");
}
}
});
});
$(document).on('click', '.move-down', function (e) {
e.preventDefault();
var id = $(this).data('id');
var type = $(this).data('type');
$.ajax({
type: 'GET',
url: '/admin/' + type + '/' + id + '/ab',
success: function success(data) {
if (data.status.error == false) {
getPageData(type);
} else {
toastr.error('Fehler beim bearbeiten', "Fehler");
}
}
});
}); // Edit a post
$(document).on('click', '.edit-modal', function (e) {
e.preventDefault();
var id = $(this).data('id');
var type = $(this).data('type');
editPost(id, type);
});
function editPost(id, type) {
$.ajax({
type: 'GET',
url: '/admin/' + type + '/' + id + '/bearbeiten',
success: function success(data) {
if (data.status.error == false) {
registerEditForm(data);
} else {
toastr.error('Fehler beim bearbeiten', "Fehler");
}
}
});
}
$('.modal-footer').on('click', '.edit', function (e) {
submitEditForm();
}); // Restore a post
$(document).off('click', '.restore-modal');
$(document).on('click', '.restore-modal', function (e) {
e.preventDefault();
var id = $(this).data('id');
var type = $(this).data('type');
$.ajax({
type: 'PUT',
url: '/admin/' + type + '/' + id,
data: {
'_token': $('input[name=_token]').val(),
'_method': 'PUT',
'restore': true
},
success: function success(data) {
if (data.status.error == true) {
setTimeout(function () {
showMessages(data.messages);
}, 500);
} else {
getPageData(type);
showMessages(data.messages);
}
}
});
}); // delete a post
$(document).on('click', '.delete-modal', function (e) {
var id = $(this).data('id');
var type = $(this).data('type');
var title = $(this).data('title');
deletePost(id, type, title);
});
function deletePost(id, type, title) {
$('.modal-title').text(title + ' löschen');
$('.modal-body').text('Wirklich löschen?').data('id', id).data('type', type).data('title', title);
$('#deleteModal').modal('show');
}
$('.modal-footer').on('click', '.delete', function () {
var id = $('.modal-body').data('id');
var type = $('.modal-body').data('type');
var title = $('.modal-body').data('title');
$.ajax({
type: 'DELETE',
url: '/admin/' + type + '/' + id,
data: {
'_token': $('input[name=_token]').val(),
'_method': 'DELETE'
},
success: function success(data) {
if (data.status.error == true) {
setTimeout(function () {
showMessages(data.messages);
}, 500);
} else {
getPageData(type);
showMessages(data.messages);
$('#editModal').modal('hide');
}
}
});
});
$(document).on('click', '.publish-modal', function (e) {
e.preventDefault();
checked = $(this).data('value') == 1 ? true : false;
checked = !checked;
var id = $(this).data('id');
var type = $(this).data('type');
$.ajax({
type: 'PUT',
url: '/admin/' + type + '/' + id,
data: {
'_token': $('input[name=_token]').val(),
'_method': 'PUT',
'publish_website_action': checked
},
success: function success(data) {
if (data.status.error == true) {
setTimeout(function () {
showMessages(data.messages);
}, 500);
} else {
getPageData(type);
showMessages(data.messages);
}
}
});
});
/**/
$(document).on('change', '#itemsPerPage', function (e) {
itemsPerPage = $(this).find(":selected").val();
page = 1;
$('.pagination-sm').twbsPagination('show', 1);
}); // Auswerten von Tasteneingaben
$(document).keydown(function (e) {
//console.log(e.keyCode);
switch (e.keyCode) {
// Enter
case 13:
if (nothingHasFocus()) {
var currentRow = $('.table .table-info'); // Ist eine Zeile markiert?
if (currentRow.length) {
// Ist der Details-Dialog bereits geöffnet?
if (isModalDialogActive()) {} else {
var id = currentRow.data('id');
var type = currentRow.data('type');
editPost(id, type);
}
}
}
break;
// ESC
case 27:
if (nothingHasFocus()) {
e.preventDefault(); // Ist der Details-Dialog bereits geöffnet?
if (isModalDialogActive()) {
closeDialog();
}
}
break;
// Leertaste
case 32:
if (nothingHasFocus()) {
e.preventDefault();
var currentRow = $('.table .table-info'); // Ist eine Zeile markiert?
if (currentRow.length) {
// Ist der Details-Dialog bereits geöffnet?
if (isModalDialogActive()) {
closeDialog();
} else {
var id = currentRow.data('id');
var type = currentRow.data('type');
showPostDetails(id, type);
}
}
}
break;
// Ende
case 35:
if (nothingHasFocus()) {
e.preventDefault();
if (!isModalDialogActive()) {
page = total_page;
$('.pagination-sm').twbsPagination('show', page);
}
}
break;
// Position 1
case 36:
if (nothingHasFocus()) {
e.preventDefault();
if (!isModalDialogActive()) {
page = 1;
$('.pagination-sm').twbsPagination('show', page);
}
}
break;
// Pfeiltaste links
case 37:
if (nothingHasFocus()) {
e.preventDefault();
if (!isModalDialogActive()) {
if (page > 1) {
page--;
$('.pagination-sm').twbsPagination('show', page);
}
} // Details-Dialog
else if ($('#crudModal').data('action') == 'details') {
$('#crudModal .nav-item .active').parent().prev().find('.nav-link').tab('show');
}
}
break;
// Pfeiltaste auf
case 38:
if (nothingHasFocus()) {
e.preventDefault();
if (!isModalDialogActive()) {
navigateTable(-1);
}
}
break;
// Pfeiltaste rechts
case 39:
if (nothingHasFocus()) {
e.preventDefault();
if (!isModalDialogActive()) {
if (page < total_page) {
page++;
$('.pagination-sm').twbsPagination('show', page);
}
} // Details-Dialog
else if ($('#crudModal').data('action') == 'details') {
$('#crudModal .nav-item .active').parent().next().find('.nav-link').tab('show');
}
}
break;
// Pfeiltaste ab
case 40:
if (nothingHasFocus()) {
e.preventDefault();
if (!isModalDialogActive()) {
navigateTable(1);
}
}
break;
// Entfernen
case 46:
if (nothingHasFocus()) {
e.preventDefault();
var currentRow = $('.table .table-info'); // Ist eine Zeile markiert?
if (currentRow.length) {
// Ist der Details-Dialog bereits geöffnet?
if (isModalDialogActive()) {} else {
var id = currentRow.data('id');
var type = currentRow.data('type');
var title = currentRow.data('title');
deletePost(id, type, title);
}
}
}
break;
}
});
function nothingHasFocus() {
return !hasSomethingFocus();
}
function hasSomethingFocus() {
return $(':focus').length > 0 ? true : false;
}
function isModalDialogActive() {
return $('.modal').is(':visible');
}
function navigateTableElement(element) {
var index;
if ($(element).is('tr')) {
index = $(element).index();
} else {
index = $(element).parents('tr').index();
}
navigateTableIndex(index);
}
function navigateTableIndex(index) {
var currentRow = $('.table .table-info');
var rows = $('.table tbody tr'); // Aktuelle Zeile nicht mehr markieren
currentRow.removeClass('table-info');
rows.eq(index).addClass('table-info');
}
function navigateTable() {
var step = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
// Suche nach einer Tabellenzeile mit der Klasse table-info
var currentRow = $('.table .table-info');
var rows = $('.table tbody tr');
var rowCount = rows.length;
if (currentRow.length) {
// Hole den Index der aktuellen Zeile
var index = currentRow.index(); // Verrechne den index mit dem Schritt
index += step; // Korrigiere ggfs. den index
if (index < 0) {
index = rowCount - 1;
} else if (index >= rowCount) {
index = 0;
}
navigateTableIndex(index);
} // Es existiert noch keine markierte Zeile.
else {
if (step < 0) {
navigateTableIndex(rowCount - 1);
} else {
navigateTableIndex(0);
}
}
}
$(document).on('click', '.column-sortable', function (e) {
page = 1;
var clickedColumn = $(this).data('name'); // Initialisierung, wenn noch keine Sortierspalte und -richtung festgelegt wurde
if (orderDirection == '') {
orderDirection = $(this).data('sort-direction');
}
if (orderColumn != clickedColumn) {
orderColumn = clickedColumn;
orderDirection = 'ASC';
} else {
if (orderDirection == 'ASC') {
orderDirection = 'DESC';
} else {
orderDirection = 'ASC';
}
}
page = 1;
$('.pagination-sm').twbsPagination('show', page); // reloadPagination();
});
$(document).on('submit', '#searchForm', function (e) {
e.preventDefault();
$('#searchForm input[type="text"]').blur();
reloadPagination();
});
$('#searchForm input[type="text"]').on('input propertyChange', function () {
var visible = Boolean($(this).val());
$(this).siblings('#searchClear').toggleClass('d-none', !visible);
searchText = $(this).val();
});
$(document).on('click', '#searchClear', function () {
$(this).siblings('input[type="text"]').val('').trigger('propertyChange').focus();
$('#searchForm').submit();
}); // Workaround, um in einem modalen Bootstrap-Dialog im TinyMCE Editor Links, Bilder und Videos bearbeiten zu können
$(document).on('focusin', function (e) {
if ($(e.target).closest('.mce-window').length) {
e.stopImmediatePropagation();
}
});
$('.quickedit.hidden').parent().hover(function () {
$(this).find('.quickedit').eq(0).slideDown(200);
}, function () {
$(this).find('.quickedit').eq(0).slideUp(200);
});
$('.quickedit.hidden').parent().on('touchstart', function (e) {
var element = $(this).find('.quickedit').eq(0);
if (element.is(':visible')) {
if ($(e.touches[0].target).closest('.quickedit').length == 0) {
element.slideUp(200);
}
} else {
element.slideDown(200);
}
});
});
/***/ }),
/***/ 4:
/*!***************************************************!*\
!*** multi ./resources/assets/js/admin-script.js ***!
\***************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(/*! /Users/marcoglietsch/Projekte/Homepages/Feuerwehr Eppingen/ffw_laravel/resources/assets/js/admin-script.js */"./resources/assets/js/admin-script.js");
/***/ })
/******/ });