yavsc/Yavsc/Views/Blogspot/Edit.cshtml

207 lines
5.8 KiB
Plaintext

@model Yavsc.Models.Blog
@{
ViewData["Title"] = SR["Blog post edition"];
}
@section header{
<link href="~/css/quill.snow.css" rel="stylesheet">
<link href="~/css/dropzone.css" rel="stylesheet">
<style>
.box__dragndrop,
.box__uploading,
.box__success,
.box__error {
display: none;
}
.box.has-advanced-upload {
background-color: white;
outline: 2px dashed black;
outline-offset: -10px;
}
.box.has-advanced-upload .box__dragndrop {
display: inline;
}
.box.is-dragover {
background-color: grey;
}
.ql-snow.ql-toolbar {
border: outset grey 2px;
}
</style>
<script src="~/js/dropzone.js"></script>
<script src="~/js/quill.js"></script>
<script src="~/js/showdown.js"></script>
<script src="~/js/to-markdown.js"></script>
<script src="~/js/md-helpers.js"></script>
<script>
$(document).ready(function() {
var editortitre = new Quill('#Titlecnt', {
modules: { toolbar: '#Titletoolbar' },
theme: 'snow'
});
var editorcontenu = new Quill('#contentcnt', {
modules: { toolbar: '#contentbar' },
theme: 'snow'
});
editortitre.on('selection-change', function(range) {
if (range) {
$('#contentbar').addClass('hidden');
$('#Titletoolbar').removeClass('hidden');
}
});
editortitre.on('text-change',function(delta,source){
if (source=='user')
{
updateMD('Title',$('#Titlecnt').html())
}
});
editorcontenu.on('selection-change', function(range) {
if (range) {
$('#contentbar').removeClass('hidden');
$('#Titletoolbar').addClass('hidden');
}
});
editorcontenu.on('text-change',function(delta,source){
if (source=='user')
{
updateMD('Content',$('#contentcnt').html())
}
});
$('#contentcnt').focus(function(){
$('#contentbar').removeClass('hidden');
$('#Titletoolbar').addClass('hidden');
})
Dropzone.options.postfiles= {
maxFilesize: 2, // MB
autoProcessQueue: true,
accept: function(file, done) {
if (file.name == "justinbieber.jpg") {
done("Naha, you don't.");
}
else { done(); }
},
url: "/UserFiles/Create?PostId=@Model.Id"
};
});
</script>
@Html.Partial("_ValidationScriptsPartial")
}
<h2 > @SR["Blog post edition"] </h2>
<div id="Titletoolbar" class="hidden ql-snow ql-toolbar">
<button class="ql-format-button ql-bold"></button>
<button class="ql-format-button ql-italic"></button>
<button class="ql-format-button ql-underline"></button>
<button class="ql-format-button ql-strike"></button>
</div>
<h2 id="Titlecnt"><markdown>@Model.Title</markdown></h2>
<div id="contentbar" class="hidden ql-snow ql-toolbar">
<span class="ql-format-group">
<button class="ql-format-button ql-bold"></button>
<button class="ql-format-button ql-italic"></button>
<button class="ql-format-button ql-underline"></button>
<button class="ql-format-button ql-strike"></button>
<environment names="Development">
<button class="ql-format-button ql-link"></button>
<button class="ql-format-button ql-image"></button>
</environment>
</span>
<span class="ql-format-group">
<span title="List" class="ql-format-button ql-list"></span>
<span class="ql-format-separator"></span>
<span title="Bullet" class="ql-format-button ql-bullet"></span>
<span class="ql-format-separator"></span>
<select title="Text Alignment" class="ql-align">
<option value="left" label="Left" selected=""></option>
<option value="center" label="Center"></option>
<option value="right" label="Right"></option>
<option value="justify" label="Justify"></option>
</select>
</span>
</div>
<div markdown="@Model.Content" base="~/@Model.Id" site="SiteSettings.Value" id="contentcnt" ></div>
<hr>
<form asp-action="Edit" >
<div class="form-horizontal">
<hr />
<p class="text-success">@ViewData["StatusMessage"]</p>
<div asp-validation-summary="ValidationSummary.ModelOnly" class="text-danger"></div>
<input type="hidden" asp-for="Id" />
<input type="hidden" asp-for="AuthorId" />
<div class="form-group">
<label asp-for="Title" class="col-md-2 control-label"></label>
<div class="col-md-10">
<input asp-for="Title" class="form-control" />
<span asp-validation-for="Title" class="text-danger" />
</div>
</div>
<div class="form-group">
<label asp-for="Photo" class="col-md-2 control-label"></label>
<div class="col-md-10">
<input asp-for="Photo" class="form-control" />
<span asp-validation-for="Photo" class="text-danger" />
</div>
</div>
<div class="form-group">
<label asp-for="Content" class="col-md-2 control-label"></label>
<div class="col-md-10">
<textarea asp-for="Content" class="form-control" >
</textarea>
<span asp-validation-for="Content" class="text-danger" />
</div>
</div>
<div class="form-group">
<label asp-for="Visible" class="col-md-2 control-label"></label>
<div class="col-md-10">
<input asp-for="Visible" class="form-control"/>
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Save" class="btn btn-default" />
</div>
</div>
</div>
</form>
<div>
</div>
<div >
<form id="postfiles" class="dropzone" method="post" enctype="multipart/form-data">
<div class="fallback">
<input name="File[]" type="file"/>
</div>
<input type="hidden" name="postId" value="@Model.Id" />
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="button" value="Upload" class="btn btn-default" />
</div>
</div>
@Html.AntiForgeryToken()
</form>
</div>
<div>
<a asp-action="Index">Back to List</a>
</div>