Draft new comment submitting
This commit is contained in:
parent
0f57aa267c
commit
deabd382be
3 changed files with 88 additions and 18 deletions
|
|
@ -90,13 +90,14 @@ en vaut la peine. Je l'utilise dans le cadre du projet
|
|||
<a href="https://www.framabag.org/">Framabag</a> mais je prévois d'installer ma propre
|
||||
instance d'ici peu.</p>
|
||||
</div>
|
||||
<div class="comment">
|
||||
|
||||
<div class="comment">
|
||||
<div id="submit-button">
|
||||
<a class="button-success pure-button" href="javascript:show_hide('comment-form','submit-button');">Commenter</a>
|
||||
</div>
|
||||
|
||||
<div id="comment-form" style="display:none">
|
||||
<form class="pure-form" role="form" action="" onsubmit="this.action=get_action();" method="post">
|
||||
<form class="pure-form" role="form" action="" autocomplete="off" method="post">
|
||||
<fieldset class="pure-group">
|
||||
<input class="pure-u-1-2" id="author" name="author" placeholder="Nom ou Surnom *" required="" type="text">
|
||||
<input class="pure-u-1-2" id="email" name="email" placeholder="Adresse email (non publié)" type="email">
|
||||
|
|
@ -119,8 +120,8 @@ instance d'ici peu.</p>
|
|||
<input name="article" id="article" value="972b3e0144e82a9496a2ab9a275e7368" type="hidden">
|
||||
</div>
|
||||
</fieldset>
|
||||
<button onclick="preview_markdown(); return false" class="button-warning pure-button">Prévisualiser</button>
|
||||
<button type="submit" class="button-success pure-button">Envoyer</button>
|
||||
<button type="button" onclick="preview_markdown(); return false;" class="button-warning pure-button">Prévisualiser</button>
|
||||
<button type="button" onclick="new_comment(); return false;" class="button-success pure-button">Envoyer</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,7 @@
|
|||
// --------------------------------------------------------------------------
|
||||
// Common functions
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
function show_hide(panel_id, button_id){
|
||||
if (document.getElementById(panel_id).style.display == 'none'){
|
||||
document.getElementById(panel_id).style.display = '';
|
||||
|
|
@ -7,6 +11,23 @@ function show_hide(panel_id, button_id){
|
|||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Load and display page comments
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
function initialize_comments() {
|
||||
stacosys_count(comments_initialized);
|
||||
}
|
||||
|
||||
function comments_initialized(count) {
|
||||
if (count > 0) {
|
||||
if (count > 1) {
|
||||
document.getElementById('show-comment-label').innerHTML = 'Voir les ' + count + ' commentaires';
|
||||
}
|
||||
document.getElementById('show-comments-button').style.display = '';
|
||||
}
|
||||
}
|
||||
|
||||
function show_comments() {
|
||||
stacosys_load(comments_loaded);
|
||||
}
|
||||
|
|
@ -21,18 +42,20 @@ function comments_loaded(response) {
|
|||
document.getElementById('stacosys-comments').innerHTML = rendered;
|
||||
}
|
||||
|
||||
function initialize_comments() {
|
||||
stacosys_count(comments_initialized);
|
||||
// --------------------------------------------------------------------------
|
||||
// Submit a new comment
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
function new_comment() {
|
||||
var author = document.getElementById('author').value;
|
||||
// TODO make CORS POST request
|
||||
// and asynchronously redirect depending on result
|
||||
console.log('SUBMIT ' + author);
|
||||
}
|
||||
|
||||
function comments_initialized(count) {
|
||||
if (count > 0) {
|
||||
if (count > 1) {
|
||||
document.getElementById('show-comment-label').innerHTML = 'Voir les ' + count + ' commentaires';
|
||||
}
|
||||
document.getElementById('show-comments-button').style.display = '';
|
||||
}
|
||||
}
|
||||
// --------------------------------------------------------------------------
|
||||
// Markdown preview
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
function preview_markdown() {
|
||||
if (document.getElementById('preview-container').style.display == 'none'){
|
||||
|
|
@ -50,6 +73,4 @@ function Editor(input, preview) {
|
|||
this.update();
|
||||
}
|
||||
|
||||
function get_action() {
|
||||
return '/post_a_new_comment';
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue