268 lines
9.7 KiB
PHP
268 lines
9.7 KiB
PHP
@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;
|
|
}
|
|
.modal {
|
|
display: none; /* Hidden by default */
|
|
position: fixed; /* Stay in place */
|
|
z-index: 1; /* Sit on top */
|
|
padding-top: 100px; /* Location of the box */
|
|
left: 0;
|
|
top: 0;
|
|
width: 100%; /* Full width */
|
|
height: 100%; /* Full height */
|
|
overflow: auto; /* Enable scroll if needed */
|
|
background-color: rgb(0,0,0); /* Fallback color */
|
|
background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
|
|
}
|
|
|
|
/* Modal Content */
|
|
.modal-content {
|
|
background-color: #fefefe;
|
|
margin: auto;
|
|
padding: 20px;
|
|
border: 1px solid #888;
|
|
width: 330px;
|
|
min-width: 400px;
|
|
}
|
|
|
|
/* The Close Button */
|
|
.close {
|
|
color: #aaaaaa;
|
|
float: right;
|
|
font-size: 28px;
|
|
font-weight: bold;
|
|
}
|
|
</style>
|
|
<link href="{{ asset("/css/quill/quill.snow.css") }}" rel="stylesheet">
|
|
<h1 id="errormesseages" >Opret Vejledning</h1>
|
|
<form method="post" action="{{ route("guides.store") }}" enctype="multipart/form-data">
|
|
@csrf
|
|
<label for="title">Titel på guiden</label>
|
|
<label hidden id="error" for="errormesseages">Navn findes allerede</label>
|
|
<input type="text" name="name" id="title" required>
|
|
<div id="selectDiv">
|
|
<select name="guide_category_id" id="guidesCategory" required>
|
|
<option disabled selected value> -- Vælg en kategori -- </option>
|
|
@foreach(\App\GuidesCategory::query()->get() as $guideCategory)
|
|
<option value="{{ $guideCategory->id }}">{{ $guideCategory->guidesCategoryName }}</option>
|
|
@endforeach
|
|
</select> <label>Vælg en kategori</label>
|
|
<i class="btn btn-inline btn-sde-blue mb-0 ml-1" aria-hidden="true" onclick="modalContent()"><img src="{{ asset('/images/icons/plus.svg') }}" alt="Create">Opret kategori</i>
|
|
</div>
|
|
<label for="editor">Vejledning</label>
|
|
<small class="form-text text-muted">For at kunne indsætte et link, skal du markere den text du vil lave som et link først.</small>
|
|
<div id="editor"></div>
|
|
<textarea name="guide_articles" class="d-none" id="hiddenArea"></textarea>
|
|
<label class="toggle">
|
|
<input id="isNews" class="toggle__input" type="checkbox" name="newsoption" onclick="change()">
|
|
<span class="toggle__label">
|
|
<span class="toggle__text">Opret som nyhed</span>
|
|
</span>
|
|
</label>
|
|
<div class="form-group d-flex flex-column" id="delete_event">
|
|
<label for="date">Dato til når nyheden skal slettes (valgfri):</label>
|
|
<input type="datetime-local" name="news_expiration_date" id="date">
|
|
</div>
|
|
<label id="fileuploadee"for="fileuploade">Baggrundsbillede til nyheden (Valgfri):</label>
|
|
<input id="fileuploade" type="file" name="resource" accept="image/*">
|
|
<input type="submit" id="disable" class="btn btn-dark text-white" value="Opret">
|
|
</form>
|
|
<div id="myModal" class="modal zindex-100">
|
|
<div id="modal-content" class="modal-content text-black-50 d-block">
|
|
<span class="close" onclick="closeModal()">×</span>
|
|
<form id="modal-form" onsubmit="return createLocation()">
|
|
<label hidden id="errorModal" for="errormesseages">Kategori findes allerede</label>
|
|
<input type="text" name="category_name" id="category_name" placeholder="Bygning A" required>
|
|
<input type="submit" id="disableModal" class="btn btn-dark text-white" value="Opret">
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<script src="{{ asset("/js/quill/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', 'image', 'video' ],
|
|
[ '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")
|
|
<!-- Modal Script -->
|
|
<script>
|
|
// Get the modal
|
|
var modal = document.getElementById("myModal");
|
|
|
|
// Close the modal when you click on the span (x)
|
|
function closeModal() {
|
|
modal.style.display = "none";
|
|
}
|
|
|
|
// When the user clicks anywhere outside of the modal, close it
|
|
window.onmousedown = function(event) {
|
|
if (event.target == modal) {
|
|
modal.style.display = "none";
|
|
}
|
|
}
|
|
|
|
function modalContent() {
|
|
modal.style.display = "block";
|
|
}
|
|
|
|
function createLocation() {
|
|
$category_name = $('#category_name').val();
|
|
|
|
$.ajax({
|
|
type: 'get',
|
|
url: '{{route('guides-category.guideCategoryCreate')}}',
|
|
data: { guidesCategoryName: $category_name },
|
|
success:function (data) {
|
|
if(data) {
|
|
$("#errorModal").show(100);
|
|
$("#errorModal").css('color', 'red');
|
|
$("#disableModal").prop('disabled', true);
|
|
$('#disableModal').css('cursor','not-allowed');
|
|
} else {
|
|
$("#error").hide();
|
|
$("#disable").prop('disabled', false);
|
|
$('#disable').css('cursor','pointer');
|
|
|
|
//Load Categories again
|
|
// There has to be a space between " and # or it will not load correctly
|
|
$('#selectDiv').load(" #selectDiv");
|
|
|
|
modal.style.display = "none";
|
|
}
|
|
},
|
|
error:function (data) {
|
|
console.log(data);
|
|
}
|
|
});
|
|
return false;
|
|
}
|
|
</script>
|
|
<script>
|
|
$(function() {
|
|
$('form').areYouSure(
|
|
{
|
|
message: 'It looks like you have been editing something. '
|
|
+ 'If you leave before saving, your changes will be lost.'
|
|
}
|
|
);
|
|
});
|
|
|
|
|
|
//Dont delete me, if the user reloads the pages with text in the text-box this code runs.
|
|
$(document).ready(function () {
|
|
$value = $('#title').val();
|
|
$.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);
|
|
}
|
|
});
|
|
});
|
|
|
|
$('#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);
|
|
}
|
|
});
|
|
})
|
|
|
|
|
|
$(document).ready(function (){
|
|
change();
|
|
})
|
|
|
|
|
|
|
|
function change() {
|
|
$('#delete_event').hide();
|
|
if ($('#isNews').is(":checked"))
|
|
{
|
|
$('#delete_event').show(400);
|
|
}else {
|
|
$('#delete_event').hide(400);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
</script>
|
|
@endsection
|