Ekapp/skolehjem/resources/views/admin/guides/create.blade.php

139 lines
4.8 KiB
PHP
Raw Normal View History

@extends("admin.layout.base")
@extends("admin.layout.header")
@section("title")
Opret Vejledning
@endsection
@section("path")
<a href="{{ route('guides.create') }}" class="text-white">Opret Vejledning</a> /
@endsection
@section("content")
<style>
.toggle__label::before, .toggle__label::after {
border-color: black;
}
.toggle__text::before {
border-color: black;
}
#editor {
margin-bottom: 1rem;
}
</style>
<link href="https://cdn.quilljs.com/1.3.6/quill.snow.css" rel="stylesheet">
2020-08-17 06:23:48 +00:00
<h1 id="errormesseages" >Opret Vejledning</h1>
<form method="post" action="{{ route("guides.store") }}" enctype="multipart/form-data">
@csrf
<label for="title">Titel guiden</label>
2020-08-17 06:23:48 +00:00
<label hidden id="error" for="errormesseages">Navn findes allerede</label>
<input type="text" name="name" id="title" required>
<div id="editor"></div>
<textarea name="guide_articles" class="d-none" id="hiddenArea"></textarea>
<label class="toggle">
<input class="toggle__input" type="checkbox" name="newsoption">
<span class="toggle__label">
<span class="toggle__text">Opret som nyhed</span>
</span>
</label>
<label id="fileuploadee"for="fileuploade">Baggrundsbillede til nyheden (Valgfri):</label>
<input id="fileuploade" type="file" name="resource">
2020-08-17 06:23:48 +00:00
<input type="submit" id="disable" class="btn btn-dark text-white" value="Opret">
</form>
<script src="https://cdn.quilljs.com/1.3.6/quill.js"></script>
<script>
var container = document.getElementById("editor");
var fullEditor = new Quill(container, {
modules: {
'toolbar': [
[ 'bold', 'italic', 'underline', 'strike' ],
[{ 'color': [] }],
[{ 'script': 'super' }, { 'script': 'sub' }],
[{ 'header': '1' }, { 'header': '2' }, 'blockquote' ],
[{ 'list': 'ordered' }, { 'list': 'bullet'}, { 'indent': '-1' }, { 'indent': '+1' }],
[ {'direction': 'rtl'}, { 'align': [] }],
[ 'link' ],
[ 'clean' ]
],
},
theme: 'snow'
});
</script>
<script>
var form = document.querySelector('form');
form.onsubmit = function() {
var myEditor = document.getElementById('editor');
var html = myEditor.children[0].innerHTML;
document.getElementById('hiddenArea').innerText = html;
}
</script>
@endsection
@section("scripts")
<script>
$(function() {
$('form').areYouSure(
{
message: 'It looks like you have been editing something. '
+ 'If you leave before saving, your changes will be lost.'
}
);
});
2020-08-17 06:23:48 +00:00
$(document).ready(function () {
$value = $('#title').val();
$.ajax({
type: 'get',
url: '{{route('guides.nameCheck')}}',
data: {'nameCheck':$value},
success:function (data) {
console.log(data);
if(data){
$("#error").show(100);
$("#error").css('color', 'red');
$("#disable").prop('disabled', true);
$('#disable').css('cursor','not-allowed');
}else{
$("#error").hide();
$("#disable").prop('disabled', false);
$('#disable').css('cursor','pointer');
}
},
error:function (data) {
console.log(data);
}
});
});
$('#title').on('keyup', function () {
$value = $(this).val();
console.log($value);
$.ajax({
type: 'get',
url: '{{route('guides.nameCheck')}}',
data: {'nameCheck':$value},
success:function (data) {
if(data){
$("#error").show(100);
$("#error").css('color', 'red');
$("#disable").prop('disabled', true);
$('#disable').css('cursor','not-allowed');
}else{
$("#error").hide();
$("#disable").prop('disabled', false);
$('#disable').css('cursor','pointer');
}
},
error:function (data) {
console.log(data);
}
});
})
</script>
@endsection