diff options
author | Unknwon <u@gogs.io> | 2015-11-25 20:10:25 -0500 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2015-11-25 20:10:25 -0500 |
commit | 2b10fdc4dcb987b347b031f460cf4f02fd48a31a (patch) | |
tree | f3f723c75684c4213a58d57a2ce0b6afdc597d25 /public/js/gogs.js | |
parent | 2f28a0310b0f391dd74bb3a2ab0ae06379a4fb1a (diff) | |
download | gitea-2b10fdc4dcb987b347b031f460cf4f02fd48a31a.tar.gz gitea-2b10fdc4dcb987b347b031f460cf4f02fd48a31a.zip |
Wiki: UI for page new
Diffstat (limited to 'public/js/gogs.js')
-rw-r--r-- | public/js/gogs.js | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/public/js/gogs.js b/public/js/gogs.js index 5002f64118..d9e00eb713 100644 --- a/public/js/gogs.js +++ b/public/js/gogs.js @@ -445,6 +445,53 @@ function initRepository() { } } +function initWiki() { + if ($('.repository.wiki').length == 0) { + return; + } + + + if ($('.repository.wiki.new').length > 0) { + var $edit_area = $('#edit-area'); + var simplemde = new SimpleMDE({ + autoDownloadFontAwesome: false, + element: $edit_area[0], + previewRender: function (plainText, preview) { // Async method + setTimeout(function () { + if ($('.editor-preview-active').length == 0) { + return; + } + + $.post($edit_area.data('url'), { + "_csrf": csrf, + "mode": "gfm", + "context": $edit_area.data('context'), + "text": plainText + }, + function (data) { + preview.innerHTML = '<div class="markdown">' + data + '</div>'; + emojify.run($('.editor-preview')[0]); + } + ); + }, 0); + + return "Loading..."; + }, + renderingConfig: { + singleLineBreaks: false + }, + spellChecker: false, + tabSize: 4, + toolbar: ["bold", "italic", "strikethrough", "|", + "heading", "heading-1", "heading-2", "heading-3", "|", + "code", "quote", "|", + "unordered-list", "ordered-list", "|", + "link", "image", "horizontal-rule", "|", + "preview", "fullscreen"] + }) + } +} + function initOrganization() { if ($('.organization').length == 0) { return; @@ -835,6 +882,7 @@ $(document).ready(function () { initCommentForm(); initInstall(); initRepository(); + initWiki(); initOrganization(); initUser(); initWebhook(); |