diff options
author | Clement Ho <ClemMakesApps@gmail.com> | 2017-01-17 08:35:33 +0300 |
---|---|---|
committer | Clement Ho <ClemMakesApps@gmail.com> | 2017-01-17 09:04:47 +0300 |
commit | eb61d493f94cf27216c5d9f8fa7ddc915603703c (patch) | |
tree | 28d606c512c6a7b758c0e608dc3c50791429e54c /app/assets/javascripts/preview_markdown.js | |
parent | 78d710388fbabe27481c77cc353610904465c4df (diff) |
Autoresize markdown preview
Diffstat (limited to 'app/assets/javascripts/preview_markdown.js')
-rw-r--r-- | app/assets/javascripts/preview_markdown.js | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/app/assets/javascripts/preview_markdown.js b/app/assets/javascripts/preview_markdown.js index 89f7e976934..07eea98e737 100644 --- a/app/assets/javascripts/preview_markdown.js +++ b/app/assets/javascripts/preview_markdown.js @@ -7,6 +7,7 @@ // (function () { var lastTextareaPreviewed; + var lastTextareaHeight = null; var markdownPreview; var previewButtonSelector; var writeButtonSelector; @@ -104,10 +105,14 @@ if (!$form) { return; } + lastTextareaPreviewed = $form.find('textarea.markdown-area'); + lastTextareaHeight = lastTextareaPreviewed.height(); + // toggle tabs $form.find(writeButtonSelector).parent().removeClass('active'); $form.find(previewButtonSelector).parent().addClass('active'); + // toggle content $form.find('.md-write-holder').hide(); $form.find('.md-preview-holder').show(); @@ -119,9 +124,15 @@ return; } lastTextareaPreviewed = null; + + if (lastTextareaHeight) { + $form.find('textarea.markdown-area').height(lastTextareaHeight); + } + // toggle tabs $form.find(writeButtonSelector).parent().addClass('active'); $form.find(previewButtonSelector).parent().removeClass('active'); + // toggle content $form.find('.md-write-holder').show(); $form.find('textarea.markdown-area').focus(); |