1
0
Fork 0
forked from mirror/pixelfed
pixelfed/resources/views/admin/pages/edit.blade.php

102 lines
3.4 KiB
PHP
Raw Normal View History

2018-11-04 04:16:40 +00:00
@extends('admin.partial.template')
2019-02-10 23:59:29 +00:00
@include('admin.settings.sidebar')
2018-11-04 04:16:40 +00:00
@section('section')
<div class="title">
<h3 class="font-weight-bold">Edit Page</h3>
2019-02-10 23:59:29 +00:00
<p class="lead">{{$page->slug}}</p>
2018-11-04 04:16:40 +00:00
</div>
<hr>
<div>
2019-02-10 23:59:29 +00:00
<input type="hidden" id="slug" name="slug" value="{{$page->slug}}">
<input class="form-control form-control-lg" id="title" name="title" placeholder="Title">
<p class="small text-muted">
Page URL: <span class="page-url font-weight-bold">{{$page->url()}}</span>
2019-06-20 02:54:01 +00:00
{{-- <span class="pl-1"><a href="#" class="font-weight-bold">Edit</a></span> --}}
2019-02-10 23:59:29 +00:00
</p>
2018-11-04 04:16:40 +00:00
<div id="editor" style="height: 400px">
2019-02-10 23:59:29 +00:00
{!!$page->content!!}
</div>
<div class="mt-3 d-flex justify-content-between">
<div>
<div class="custom-control custom-switch d-inline pr-3">
<input type="checkbox" class="custom-control-input" id="activeSwitch" {{$page->active?'checked="true"':''}}>
<label class="custom-control-label font-weight-bold" for="activeSwitch">Active</label>
</div>
2019-06-20 02:54:01 +00:00
{{-- <a class="btn btn-light font-weight-bold py-0" href="#">Set Expire Date</a> --}}
2019-02-10 23:59:29 +00:00
</div>
<div>
2019-06-20 02:54:01 +00:00
{{-- <a class="btn btn-light font-weight-bold py-0" href="#">Preview</a> --}}
<a class="btn btn-outline-danger font-weight-bold py-0 btn-delete" href="#">Delete</a>
2019-02-10 23:59:29 +00:00
<a class="btn btn-primary font-weight-bold py-0 btn-save" href="#">Save</a>
</div>
2018-11-04 04:16:40 +00:00
</div>
</div>
@endsection
@push('styles')
2019-06-20 02:54:01 +00:00
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/quill/1.3.6/quill.snow.min.css" integrity="sha256-qc/vMbPSg7/JfxMwKeMv3wlx7ojG33FXfYfO0UJIsc0=" crossorigin="anonymous" />
2018-11-04 04:16:40 +00:00
<style type="text/css">
.ql-container {
box-sizing: border-box;
font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",
Roboto,Helvetica,Arial,sans-serif;
font-size: 16px;
height: 100%;
margin: 0px;
position: relative;
}
</style>
@endpush
@push('scripts')
2019-06-20 02:54:01 +00:00
<script src="https://cdnjs.cloudflare.com/ajax/libs/quill/1.3.6/quill.min.js" integrity="sha256-3oYBiGm16EW9wQH8G1VhGh43XgivbO5KaB10RhA9phE=" crossorigin="anonymous"></script>
2018-11-04 04:16:40 +00:00
<script>
2019-02-10 23:59:29 +00:00
window.editor = new Quill('#editor', {
2018-11-04 04:16:40 +00:00
theme: 'snow'
});
2019-02-10 23:59:29 +00:00
$('.btn-save').on('click', function(e) {
e.preventDefault();
2019-06-20 02:54:01 +00:00
let confirm = window.confirm('Are you sure you want to save this page?');
if(confirm !== true) {
return;
}
2019-02-10 23:59:29 +00:00
let html = editor.container.firstChild.innerHTML;
let title = $('#title').val();
let active = $('#activeSwitch')[0].checked;
axios.post(window.location.href, {
slug: '{{$page->slug}}',
title: title,
content: html,
active: active
}).then((res) => {
window.location.href = '{{$page->url()}}';
}).catch((err) => {
console.log(err)
});
});
2019-06-20 02:54:01 +00:00
$('.btn-delete').on('click', function(e) {
e.preventDefault();
let confirm = window.confirm('Are you sure you want to delete this page?');
if(confirm == true) {
axios.post('/i/admin/settings/pages/delete', {
id: '{{$page->id}}'
}).then(res => {
window.location.href = '/i/admin/settings/pages';
}).catch(err => {
swal('Error', 'An error occured!', 'error');
console.log(err);
});
}
});
2019-02-10 23:59:29 +00:00
$('#title').on('change input', function(e) {
e.preventDefault();
let title = this.value.split(' ').join('-').toLowerCase();
})
2018-11-04 04:16:40 +00:00
</script>
@endpush