mirror of
https://github.com/prurigro/hypothetical.git
synced 2024-11-09 11:16:39 -05:00
Fix the dashboard loading modal
This commit is contained in:
parent
2162c403e9
commit
3a260dceec
2 changed files with 27 additions and 26 deletions
52
resources/assets/js/dashboard.js
vendored
52
resources/assets/js/dashboard.js
vendored
|
@ -1,25 +1,25 @@
|
||||||
// global variables
|
// global variables
|
||||||
const $loadingModal = $("#loading-modal"),
|
const fadeTime = 250;
|
||||||
fadeTime = 250;
|
|
||||||
|
|
||||||
// declare a reverse function for jquery
|
// declare a reverse function for jquery
|
||||||
jQuery.fn.reverse = [].reverse;
|
jQuery.fn.reverse = [].reverse;
|
||||||
|
|
||||||
// show the loading modal
|
// show or hide the loading modal
|
||||||
function showLoadingModal() {
|
function loadingModal(action) {
|
||||||
$loadingModal.css({
|
const $loadingModal = $("#loading-modal");
|
||||||
visibility: "visible",
|
|
||||||
opacity: 1
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// hide the loading modal
|
if (action === "show") {
|
||||||
function hideLoadingModal() {
|
$loadingModal.css({
|
||||||
$loadingModal.css({ opacity: 0 });
|
visibility: "visible",
|
||||||
|
opacity: 1
|
||||||
|
});
|
||||||
|
} else if (action === "hide") {
|
||||||
|
$loadingModal.css({ opacity: 0 });
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
$loadingModal.css({ visibility: "hidden" });
|
$loadingModal.css({ visibility: "hidden" });
|
||||||
}, fadeTime);
|
}, fadeTime);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// show the confirmation modal and run the supplied command if confirm is pressed
|
// show the confirmation modal and run the supplied command if confirm is pressed
|
||||||
|
@ -380,7 +380,7 @@ function editItemInit() {
|
||||||
|
|
||||||
// functionality to run on success
|
// functionality to run on success
|
||||||
const returnSuccess = function() {
|
const returnSuccess = function() {
|
||||||
hideLoadingModal();
|
loadingModal("hide");
|
||||||
window.location.href = `/dashboard/edit/${model}/${row_id}`;
|
window.location.href = `/dashboard/edit/${model}/${row_id}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -409,7 +409,7 @@ function editItemInit() {
|
||||||
if (response === "success") {
|
if (response === "success") {
|
||||||
uploadFile(row_id, currentFile + 1);
|
uploadFile(row_id, currentFile + 1);
|
||||||
} else {
|
} else {
|
||||||
hideLoadingModal();
|
loadingModal("hide");
|
||||||
|
|
||||||
showAlert("Failed to upload file", function() {
|
showAlert("Failed to upload file", function() {
|
||||||
submitting = false;
|
submitting = false;
|
||||||
|
@ -456,7 +456,7 @@ function editItemInit() {
|
||||||
if (response === "success") {
|
if (response === "success") {
|
||||||
uploadImage(row_id, currentImage + 1);
|
uploadImage(row_id, currentImage + 1);
|
||||||
} else {
|
} else {
|
||||||
hideLoadingModal();
|
loadingModal("hide");
|
||||||
|
|
||||||
showAlert("Failed to upload image", function() {
|
showAlert("Failed to upload image", function() {
|
||||||
submitting = false;
|
submitting = false;
|
||||||
|
@ -622,7 +622,7 @@ function editItemInit() {
|
||||||
submitting = true;
|
submitting = true;
|
||||||
|
|
||||||
// show the loading modal
|
// show the loading modal
|
||||||
showLoadingModal();
|
loadingModal("show");
|
||||||
|
|
||||||
// populate the formData object
|
// populate the formData object
|
||||||
getFormData();
|
getFormData();
|
||||||
|
@ -636,7 +636,7 @@ function editItemInit() {
|
||||||
if (/^id:[0-9][0-9]*$/.test(response)) {
|
if (/^id:[0-9][0-9]*$/.test(response)) {
|
||||||
uploadImage(response.replace(/^id:/, ""), 0);
|
uploadImage(response.replace(/^id:/, ""), 0);
|
||||||
} else {
|
} else {
|
||||||
hideLoadingModal();
|
loadingModal("hide");
|
||||||
|
|
||||||
showAlert("Failed to " + operation + " record", function() {
|
showAlert("Failed to " + operation + " record", function() {
|
||||||
submitting = false;
|
submitting = false;
|
||||||
|
@ -665,7 +665,7 @@ function userProfileImageInit() {
|
||||||
|
|
||||||
askConfirmation("Update your user profile image?", function() {
|
askConfirmation("Update your user profile image?", function() {
|
||||||
// show the loading modal
|
// show the loading modal
|
||||||
showLoadingModal();
|
loadingModal("show");
|
||||||
|
|
||||||
// add the image to the form data
|
// add the image to the form data
|
||||||
file = new FormData();
|
file = new FormData();
|
||||||
|
@ -680,7 +680,7 @@ function userProfileImageInit() {
|
||||||
contentType: false,
|
contentType: false,
|
||||||
beforeSend: function(xhr) { xhr.setRequestHeader("X-CSRF-TOKEN", $token.val()); }
|
beforeSend: function(xhr) { xhr.setRequestHeader("X-CSRF-TOKEN", $token.val()); }
|
||||||
}).always(function(response) {
|
}).always(function(response) {
|
||||||
hideLoadingModal();
|
loadingModal("hide");
|
||||||
|
|
||||||
if (/\.png\?version=/.test(response)) {
|
if (/\.png\?version=/.test(response)) {
|
||||||
$display.css({ backgroundImage: `url(${response})` });
|
$display.css({ backgroundImage: `url(${response})` });
|
||||||
|
@ -772,7 +772,7 @@ function userProfileUpdateInit() {
|
||||||
$inputs.removeClass("error");
|
$inputs.removeClass("error");
|
||||||
|
|
||||||
// show the loading modal
|
// show the loading modal
|
||||||
showLoadingModal();
|
loadingModal("show");
|
||||||
|
|
||||||
// populate the formData object
|
// populate the formData object
|
||||||
getFormData();
|
getFormData();
|
||||||
|
@ -783,7 +783,7 @@ function userProfileUpdateInit() {
|
||||||
url: "/dashboard/user/profile-update",
|
url: "/dashboard/user/profile-update",
|
||||||
data: formData
|
data: formData
|
||||||
}).always(function(response) {
|
}).always(function(response) {
|
||||||
hideLoadingModal();
|
loadingModal("hide");
|
||||||
|
|
||||||
if (response === "success") {
|
if (response === "success") {
|
||||||
$submit.addClass("no-input");
|
$submit.addClass("no-input");
|
||||||
|
@ -859,7 +859,7 @@ function userPasswordUpdateInit() {
|
||||||
$inputs.removeClass("error");
|
$inputs.removeClass("error");
|
||||||
|
|
||||||
// show the loading modal
|
// show the loading modal
|
||||||
showLoadingModal();
|
loadingModal("show");
|
||||||
|
|
||||||
// populate the formData object
|
// populate the formData object
|
||||||
getFormData();
|
getFormData();
|
||||||
|
@ -880,7 +880,7 @@ function userPasswordUpdateInit() {
|
||||||
url: "/dashboard/user/password-update",
|
url: "/dashboard/user/password-update",
|
||||||
data: formData
|
data: formData
|
||||||
}).always(function(response) {
|
}).always(function(response) {
|
||||||
hideLoadingModal();
|
loadingModal("hide");
|
||||||
|
|
||||||
if (response === "success") {
|
if (response === "success") {
|
||||||
$inputs.val("").trigger("change");
|
$inputs.val("").trigger("change");
|
||||||
|
|
1
resources/assets/sass/sections/_nav.scss
vendored
1
resources/assets/sass/sections/_nav.scss
vendored
|
@ -2,6 +2,7 @@
|
||||||
$logo-offset: 10px;
|
$logo-offset: 10px;
|
||||||
$desktop-logo-width: 35px;
|
$desktop-logo-width: 35px;
|
||||||
$mobile-logo-width: 30px;
|
$mobile-logo-width: 30px;
|
||||||
|
@include font-sans-semibold;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0px;
|
top: 0px;
|
||||||
left: 0px;
|
left: 0px;
|
||||||
|
|
Loading…
Reference in a new issue