MVC (layered variant)
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
main {
|
||||
padding-left: 50px;
|
||||
padding-right: 50px;
|
||||
}
|
||||
|
||||
.validation-summary-errors { font-weight: bold; color:#a94442;}
|
||||
.validation-summary-valid { display: none;}
|
||||
.input-validation-error{
|
||||
border-color:red;
|
||||
}
|
||||
.pagebox {
|
||||
width: 45px;
|
||||
}
|
||||
.pagebox::selection{
|
||||
background-color:grey;
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
(function () {
|
||||
function validRange(value, min, max) {
|
||||
if (!/^\d+$/.test(value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var page = parseInt(value, 10);
|
||||
return page >= min && page <= max;
|
||||
}
|
||||
|
||||
function goToPage(input) {
|
||||
var value = input.value.trim();
|
||||
var min = parseInt(input.dataset.min, 10);
|
||||
var max = parseInt(input.dataset.max, 10);
|
||||
|
||||
if (!validRange(value, min, max)) {
|
||||
input.value = input.dataset.current || "";
|
||||
return;
|
||||
}
|
||||
|
||||
var url = (input.dataset.urlTemplate || "").replace("__page__", value);
|
||||
if (!url) {
|
||||
return;
|
||||
}
|
||||
|
||||
window.location.href = url;
|
||||
}
|
||||
|
||||
document.addEventListener("focusin", function (event) {
|
||||
if (event.target.matches(".pagebox")) {
|
||||
event.target.select();
|
||||
}
|
||||
});
|
||||
|
||||
document.addEventListener("keydown", function (event) {
|
||||
if (!event.target.matches(".pagebox")) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.key === "Enter") {
|
||||
event.preventDefault();
|
||||
goToPage(event.target);
|
||||
}
|
||||
else if (event.key === "Escape") {
|
||||
event.target.value = event.target.dataset.current || "";
|
||||
}
|
||||
});
|
||||
})();
|
||||
@@ -0,0 +1,30 @@
|
||||
$(function () {
|
||||
$(document).on('click', '.delete', function (event) {
|
||||
if (!confirm("Delete entry?")) {
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function showAppToast(options) {
|
||||
var toastOptions = options || {};
|
||||
var variant = toastOptions.variant || "success";
|
||||
var title = toastOptions.title || "Notification";
|
||||
var message = toastOptions.message || "";
|
||||
var toast = document.getElementById("app-toast");
|
||||
var header = document.getElementById("app-toast-header");
|
||||
var titleElement = document.getElementById("app-toast-title");
|
||||
var body = document.getElementById("app-toast-body");
|
||||
|
||||
if (!toast || !header || !titleElement || !body) {
|
||||
return;
|
||||
}
|
||||
|
||||
toast.className = "toast border-0 shadow-sm";
|
||||
header.className = "toast-header text-bg-" + variant;
|
||||
titleElement.textContent = title;
|
||||
body.textContent = message;
|
||||
|
||||
var bootstrapToast = new bootstrap.Toast(toast);
|
||||
bootstrapToast.show();
|
||||
}
|
||||
Reference in New Issue
Block a user