Немного доработана страница написания статьи

This commit is contained in:
Krivchikov Dmitry 2015-09-12 23:16:21 +03:00
parent 430ea5df5a
commit 1f437e193d
1 changed files with 14 additions and 9 deletions

View File

@ -22,6 +22,7 @@
articleText = document.getElementById('articleText'); articleText = document.getElementById('articleText');
imgText = '\n[img|#' + $(this).attr('photoid') + ']\n'; imgText = '\n[img|#' + $(this).attr('photoid') + ']\n';
insertAtCursor(articleText, imgText); insertAtCursor(articleText, imgText);
markdown();
}); });
}); });
} }
@ -68,10 +69,11 @@
<tr> <tr>
<td style="width: 50%;"> <td style="width: 50%;">
<label for="articleText">Текст статьи</label> <label for="articleText">Текст статьи</label>
<textarea name="text" id="articleText" class="form-control" onscroll="monitor.scrollTop=scrollTop" style="height: 500px; resize: none;" ><?= $article->text ?></textarea> <textarea name="text" id="articleText" class="form-control" onscroll="monitor.scrollTop=scrollTop" style="height: 250px; resize: none;" ><?= $article->text ?></textarea>
</td> </td>
<td style="width: 50%;"> <td style="width: 50%; padding-left: 3px;">
<div id="monitor" style="height: 500px; width: 100%; background-color: white; margin-top: 25px; overflow-y: scroll; padding: 5px 10px;"></div> <label for="monitor">Предпросмотр</label>
<div id="monitor" style="height: 250px; width: 100%; background-color: white; overflow-y: scroll; padding: 5px 10px; border: solid 1px #ccc; border-radius: 4px;"></div>
</td> </td>
</tr> </tr>
</table> </table>
@ -111,12 +113,17 @@
<script> <script>
var monitorTimeout; var monitorTimeout;
function markdown()
{
$.post('/articles/markdown', {text: $('#articleText').val()}, function (data) {
$('#monitor').html(data);
});
}
$('#articleText').keyup(function () { $('#articleText').keyup(function () {
clearTimeout(monitorTimeout); clearTimeout(monitorTimeout);
monitorTimeout = setTimeout(function () { monitorTimeout = setTimeout(function () {
$.post('/articles/markdown', {text: $('#articleText').val()}, function (data) { markdown();
$('#monitor').html(data);
});
}, 300); }, 300);
}).keydown(function () { }).keydown(function () {
clearTimeout(monitorTimeout) clearTimeout(monitorTimeout)
@ -129,9 +136,7 @@
}); });
$(document).ready(function(){ $(document).ready(function(){
$.post('/articles/markdown', {text: $('#articleText').val()}, function (data) { markdown();
$('#monitor').html(data);
});
}); });
</script> </script>