v0.9.14 - Made an Do you want email slider on settings site
This commit is contained in:
@@ -97,13 +97,14 @@
|
||||
<div>
|
||||
<label class="switch">
|
||||
@if(\App\User::query()->where('id', '=', auth()->user()->id)->first()->wants_emails == true)
|
||||
<input type="checkbox" checked>
|
||||
<input type="checkbox" onclick="ajaxCall(this)" checked>
|
||||
@else
|
||||
<input type="checkbox">
|
||||
<input type="checkbox" onclick="ajaxCall(this)">
|
||||
@endif
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
<div id="snackbar"></div>
|
||||
</main>
|
||||
<script>
|
||||
$(document).ready(function (){
|
||||
@@ -142,5 +143,39 @@
|
||||
|
||||
})
|
||||
|
||||
function snackbar(data) {
|
||||
var x = document.getElementById("snackbar");
|
||||
x.innerHTML = data;
|
||||
x.className = "show";
|
||||
|
||||
setTimeout(function(){ x.className = x.className.replace("show", ""); }, 3000);
|
||||
}
|
||||
|
||||
function ajaxCall(el) {
|
||||
if (el.hasAttribute('checked')) {
|
||||
axios.post("{{ route("users.createajaxcancel") }}", {}
|
||||
).then(function (response) {
|
||||
var data = response.data;
|
||||
|
||||
snackbar(data);
|
||||
|
||||
el.removeAttribute('checked');
|
||||
}).catch(function (error) {
|
||||
console.log(error);
|
||||
});
|
||||
} else {
|
||||
axios.post("{{ route("users.createajax") }}", {}
|
||||
).then(function (response) {
|
||||
var data = response.data;
|
||||
|
||||
snackbar(data);
|
||||
|
||||
el.setAttribute('checked', 'checked');
|
||||
}).catch(function (error) {
|
||||
console.log(error);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
@endsection
|
||||
|
||||
Reference in New Issue
Block a user