mirror of
https://github.com/slawkens/myaac.git
synced 2025-04-29 18:59:21 +02:00
Add super fancy No Refresh saving with a toast
This commit is contained in:
parent
b433615e68
commit
4d61b0ef85
@ -44,14 +44,6 @@ if (!is_array($settingsFile)) {
|
|||||||
|
|
||||||
$settingsKeyName = ($plugin == 'core' ? $plugin : $settingsFile['key']);
|
$settingsKeyName = ($plugin == 'core' ? $plugin : $settingsFile['key']);
|
||||||
|
|
||||||
if (isset($_POST['save'])) {
|
|
||||||
$settings = Settings::getInstance();
|
|
||||||
|
|
||||||
$settings->save($settingsKeyName, $_POST['settings']);
|
|
||||||
|
|
||||||
success('Saved at ' . date('H:i'));
|
|
||||||
}
|
|
||||||
|
|
||||||
$title = ($plugin == 'core' ? 'Settings' : 'Plugin Settings - ' . $plugin);
|
$title = ($plugin == 'core' ? 'Settings' : 'Plugin Settings - ' . $plugin);
|
||||||
|
|
||||||
$settingsParsed = Settings::display($settingsKeyName, $settingsFile['settings']);
|
$settingsParsed = Settings::display($settingsKeyName, $settingsFile['settings']);
|
||||||
@ -60,4 +52,5 @@ $twig->display('admin.settings.html.twig', [
|
|||||||
'settingsParsed' => $settingsParsed['content'],
|
'settingsParsed' => $settingsParsed['content'],
|
||||||
'settings' => $settingsFile['settings'],
|
'settings' => $settingsFile['settings'],
|
||||||
'script' => $settingsParsed['script'],
|
'script' => $settingsParsed['script'],
|
||||||
|
'settingsKeyName' => $settingsKeyName,
|
||||||
]);
|
]);
|
||||||
|
28
admin/tools/settings_save.php
Normal file
28
admin/tools/settings_save.php
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
const MYAAC_ADMIN = true;
|
||||||
|
|
||||||
|
require '../../common.php';
|
||||||
|
require SYSTEM . 'functions.php';
|
||||||
|
require SYSTEM . 'init.php';
|
||||||
|
require SYSTEM . 'login.php';
|
||||||
|
|
||||||
|
if(!admin()) {
|
||||||
|
http_response_code(500);
|
||||||
|
die('Access denied.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($_REQUEST['plugin'])) {
|
||||||
|
http_response_code(500);
|
||||||
|
die('Please enter plugin name.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($_POST['settings'])) {
|
||||||
|
http_response_code(500);
|
||||||
|
die('Please enter settings.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$settings = Settings::getInstance();
|
||||||
|
|
||||||
|
$settings->save($_REQUEST['plugin'], $_POST['settings']);
|
||||||
|
|
||||||
|
echo 'Saved at ' . date('H:i');
|
@ -3,7 +3,7 @@
|
|||||||
<h5 class="m-0">Settings</h5>
|
<h5 class="m-0">Settings</h5>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<form method="post">
|
<form id="settings" method="post">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<div class="box">
|
<div class="box">
|
||||||
@ -65,3 +65,27 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</script>
|
</script>
|
||||||
{{ script|raw }}
|
{{ script|raw }}
|
||||||
|
<!-- jQuery Form Submit No Refresh + Toastify -->
|
||||||
|
<link rel="stylesheet" type="text/css" href="{{ constant('BASE_URL') }}tools/css/toastify.min.css">
|
||||||
|
<script type="text/javascript" src="{{ constant('BASE_URL') }}tools/js/toastify.min.js"></script>
|
||||||
|
<script>
|
||||||
|
$('#settings').submit(function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
type: 'POST',
|
||||||
|
url: '{{ constant('ADMIN_URL') }}tools/settings_save.php?plugin={{ settingsKeyName }}',
|
||||||
|
data : $(this).serialize(),
|
||||||
|
success : function(response) {
|
||||||
|
Toastify({
|
||||||
|
position: 'center',
|
||||||
|
text: response,
|
||||||
|
duration: 3000
|
||||||
|
}).showToast();
|
||||||
|
},
|
||||||
|
error : function(response) {
|
||||||
|
alert(response.responseText);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
15
tools/css/toastify.min.css
vendored
Normal file
15
tools/css/toastify.min.css
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
/**
|
||||||
|
* Minified by jsDelivr using clean-css v5.3.0.
|
||||||
|
* Original file: /npm/toastify-js@1.12.0/src/toastify.css
|
||||||
|
*
|
||||||
|
* Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
|
||||||
|
*/
|
||||||
|
/*!
|
||||||
|
* Toastify js 1.12.0
|
||||||
|
* https://github.com/apvarun/toastify-js
|
||||||
|
* @license MIT licensed
|
||||||
|
*
|
||||||
|
* Copyright (C) 2018 Varun A P
|
||||||
|
*/
|
||||||
|
.toastify{padding:12px 20px;color:#fff;display:inline-block;box-shadow:0 3px 6px -1px rgba(0,0,0,.12),0 10px 36px -4px rgba(77,96,232,.3);background:-webkit-linear-gradient(315deg,#73a5ff,#5477f5);background:linear-gradient(135deg,#73a5ff,#5477f5);position:fixed;opacity:0;transition:all .4s cubic-bezier(.215, .61, .355, 1);border-radius:2px;cursor:pointer;text-decoration:none;max-width:calc(50% - 20px);z-index:2147483647}.toastify.on{opacity:1}.toast-close{background:0 0;border:0;color:#fff;cursor:pointer;font-family:inherit;font-size:1em;opacity:.4;padding:0 5px}.toastify-right{right:15px}.toastify-left{left:15px}.toastify-top{top:-150px}.toastify-bottom{bottom:-150px}.toastify-rounded{border-radius:25px}.toastify-avatar{width:1.5em;height:1.5em;margin:-7px 5px;border-radius:2px}.toastify-center{margin-left:auto;margin-right:auto;left:0;right:0;max-width:fit-content;max-width:-moz-fit-content}@media only screen and (max-width:360px){.toastify-left,.toastify-right{margin-left:auto;margin-right:auto;left:0;right:0;max-width:fit-content}}
|
||||||
|
/*# sourceMappingURL=/sm/cb4335d1b03e933ed85cb59fffa60cf51f07567ed09831438c60f59afd166464.map */
|
15
tools/js/toastify.min.js
vendored
Normal file
15
tools/js/toastify.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user