aboutsummaryrefslogtreecommitdiff
path: root/public/js/gogs.js
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2015-11-30 20:46:19 -0500
committerUnknwon <u@gogs.io>2015-11-30 20:46:19 -0500
commitdcb391d3415a84ec893d11b788f776ea89c301c3 (patch)
treed83263075dbbe416cc79691fd87cc1255226ddf5 /public/js/gogs.js
parent5a14c3cf9854b2762a82ef6bdd781810380ab666 (diff)
parent830d00066785d131413d1de11ce301bf1f0b818a (diff)
Merge branch 'feature/wiki' into develop
Diffstat (limited to 'public/js/gogs.js')
-rw-r--r--public/js/gogs.js91
1 files changed, 72 insertions, 19 deletions
diff --git a/public/js/gogs.js b/public/js/gogs.js
index 5002f641..93af48e3 100644
--- a/public/js/gogs.js
+++ b/public/js/gogs.js
@@ -231,6 +231,11 @@ function initRepository() {
});
}
+ // Wiki
+ if ($('.repository.wiki.view').length > 0) {
+ initFilterSearchDropdown('.choose.page .dropdown');
+ }
+
// Options
if ($('.repository.settings.options').length > 0) {
$('#repo_name').keyup(function () {
@@ -314,23 +319,23 @@ function initRepository() {
$('#edit-title').click(editTitleToggle);
$('#cancel-edit-title').click(editTitleToggle);
$('#save-edit-title').click(editTitleToggle).
- click(function () {
- if ($edit_input.val().length == 0 ||
- $edit_input.val() == $issue_title.text()) {
- $edit_input.val($issue_title.text());
- return false;
- }
+ click(function () {
+ if ($edit_input.val().length == 0 ||
+ $edit_input.val() == $issue_title.text()) {
+ $edit_input.val($issue_title.text());
+ return false;
+ }
- $.post($(this).data('update-url'), {
- "_csrf": csrf,
- "title": $edit_input.val()
- },
- function (data) {
- $edit_input.val(data.title);
- $issue_title.text(data.title);
- });
- return false;
- });
+ $.post($(this).data('update-url'), {
+ "_csrf": csrf,
+ "title": $edit_input.val()
+ },
+ function (data) {
+ $edit_input.val(data.title);
+ $issue_title.text(data.title);
+ });
+ return false;
+ });
// Edit issue or comment content
$('.edit-content').click(function () {
@@ -445,6 +450,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;
@@ -682,9 +734,9 @@ $(document).ready(function () {
// Show exact time
$('.time-since').each(function () {
$(this).addClass('poping up').
- attr('data-content', $(this).attr('title')).
- attr('data-variation', 'inverted tiny').
- attr('title', '');
+ attr('data-content', $(this).attr('title')).
+ attr('data-variation', 'inverted tiny').
+ attr('title', '');
});
// Semantic UI modules.
@@ -835,6 +887,7 @@ $(document).ready(function () {
initCommentForm();
initInstall();
initRepository();
+ initWiki();
initOrganization();
initUser();
initWebhook();