mirror of
https://github.com/go-gitea/gitea.git
synced 2024-08-25 21:44:20 -04:00
issue content ajax preview
This commit is contained in:
parent
035facc564
commit
ecce694d77
@ -399,21 +399,24 @@ function initRepository() {
|
|||||||
|
|
||||||
function initInstall() {
|
function initInstall() {
|
||||||
// database type change
|
// database type change
|
||||||
$('#install-database').on("change", function () {
|
(function () {
|
||||||
var val = $(this).val();
|
$('#install-database').on("change", function () {
|
||||||
if (val != "sqlite") {
|
var val = $(this).val();
|
||||||
$('.server-sql').show();
|
if (val != "sqlite") {
|
||||||
$('.sqlite-setting').addClass("hide");
|
$('.server-sql').show();
|
||||||
if (val == "pgsql") {
|
$('.sqlite-setting').addClass("hide");
|
||||||
$('.pgsql-setting').removeClass("hide");
|
if (val == "pgsql") {
|
||||||
|
$('.pgsql-setting').removeClass("hide");
|
||||||
|
} else {
|
||||||
|
$('.pgsql-setting').addClass("hide");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$('.pgsql-setting').addClass("hide");
|
$('.server-sql').hide();
|
||||||
|
$('.sqlite-setting').removeClass("hide");
|
||||||
}
|
}
|
||||||
} else {
|
});
|
||||||
$('.server-sql').hide();
|
}());
|
||||||
$('.sqlite-setting').removeClass("hide");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function initIssue() {
|
function initIssue() {
|
||||||
@ -445,14 +448,32 @@ function initIssue() {
|
|||||||
}());
|
}());
|
||||||
|
|
||||||
// issue ajax update
|
// issue ajax update
|
||||||
$('.issue-edit-save').on("click", function () {
|
(function () {
|
||||||
$(this).toggleAjax(function(json){
|
$('.issue-edit-save').on("click", function () {
|
||||||
if(json.ok){
|
$(this).toggleAjax(function (json) {
|
||||||
$('.issue-head h1.title').text(json.title);
|
if (json.ok) {
|
||||||
$('.issue-main > .issue-content .content').html(json.content);
|
$('.issue-head h1.title').text(json.title);
|
||||||
}
|
$('.issue-main > .issue-content .content').html(json.content);
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
}());
|
||||||
|
|
||||||
|
// issue ajax preview
|
||||||
|
(function () {
|
||||||
|
$('[data-ajax-name=issue-preview]').on("click", function () {
|
||||||
|
var $this = $(this);
|
||||||
|
$this.toggleAjax(function (json) {
|
||||||
|
if (json.ok) {
|
||||||
|
$($this.data("preview")).html(json.content);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
});
|
||||||
|
$('.issue-write a[data-toggle]').on("click", function () {
|
||||||
|
$('.issue-preview-content').html("loading...");
|
||||||
|
});
|
||||||
|
}())
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
(function ($) {
|
(function ($) {
|
||||||
|
17
routers/preview.go
Normal file
17
routers/preview.go
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
// Copyright 2014 The Gogs Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a MIT-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package routers
|
||||||
|
|
||||||
|
import "github.com/gogits/gogs/modules/middleware"
|
||||||
|
|
||||||
|
func Preview(ctx *middleware.Context) {
|
||||||
|
content := ctx.Query("content")
|
||||||
|
// todo : gfm render content
|
||||||
|
// content = Markdown(content)
|
||||||
|
ctx.Render.JSON(200, map[string]interface{}{
|
||||||
|
"ok": true,
|
||||||
|
"content": "preview : " + content,
|
||||||
|
})
|
||||||
|
}
|
@ -18,16 +18,16 @@
|
|||||||
Content with <a href="#">Markdown</a>
|
Content with <a href="#">Markdown</a>
|
||||||
</div>
|
</div>
|
||||||
<ul class="nav nav-tabs" data-init="tabs">
|
<ul class="nav nav-tabs" data-init="tabs">
|
||||||
<li class="active"><a href="#issue-textarea" data-toggle="tab">Write</a></li>
|
<li class="active issue-write"><a href="#issue-textarea" data-toggle="tab">Write</a></li>
|
||||||
<li><a href="#issue-preview" data-toggle="tab">Preview</a></li>
|
<li class="issue-preview"><a href="#issue-preview" data-toggle="tab" data-ajax="/preview?repo=repo_id&issue=new" data-ajax-name="issue-preview" data-ajax-method="post" data-preview="#issue-preview">Preview</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<div class="tab-content">
|
<div class="tab-content">
|
||||||
<div class="tab-pane" id="issue-textarea">
|
<div class="tab-pane" id="issue-textarea">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<textarea class="form-control" name="content" id="issue-content" rows="10" placeholder="Write some content">{{.content}}</textarea>
|
<textarea class="form-control" name="content" id="issue-content" rows="10" placeholder="Write some content" data-ajax-rel="issue-preview" data-ajax-val="val" data-ajax-field="content">{{.content}}</textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="tab-pane" id="issue-preview">preview</div>
|
<div class="tab-pane issue-preview-content" id="issue-preview">loading...</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="text-right panel-body">
|
<div class="text-right panel-body">
|
||||||
|
@ -72,17 +72,17 @@
|
|||||||
Content with <a href="#">Markdown</a>
|
Content with <a href="#">Markdown</a>
|
||||||
</div>
|
</div>
|
||||||
<ul class="nav nav-tabs" data-init="tabs">
|
<ul class="nav nav-tabs" data-init="tabs">
|
||||||
<li class="active"><a href="#issue-textarea" data-toggle="tab">Write</a></li>
|
<li class="active issue-write"><a href="#issue-textarea" data-toggle="tab">Write</a></li>
|
||||||
<li><a href="#issue-preview" data-toggle="tab">Preview</a></li>
|
<li class="issue-preview"><a href="#issue-preview" data-toggle="tab" data-ajax="/preview?repo=repo_id&issue=issue_id&comment=new" data-ajax-name="issue-preview" data-ajax-method="post" data-preview="#issue-preview">Preview</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<div class="tab-content">
|
<div class="tab-content">
|
||||||
<div class="tab-pane" id="issue-textarea">
|
<div class="tab-pane" id="issue-textarea">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<input type="hidden" value="{{.Issue.Index}}" name="issueIndex"/>
|
<input type="hidden" value="{{.Issue.Index}}" name="issueIndex"/>
|
||||||
<textarea class="form-control" name="content" id="issue-reply-content" rows="10" placeholder="Write some content">{{.content}}</textarea>
|
<textarea class="form-control" name="content" id="issue-content" rows="10" placeholder="Write some content" data-ajax-rel="issue-preview" data-ajax-val="val" data-ajax-field="content">{{.content}}</textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="tab-pane" id="issue-preview">preview</div>
|
<div class="tab-pane issue-preview-content" id="issue-preview">loading...</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="text-right">
|
<div class="text-right">
|
||||||
|
1
web.go
1
web.go
@ -95,6 +95,7 @@ func runWeb(*cli.Context) {
|
|||||||
m.Get("/pulls", reqSignIn, user.Pulls)
|
m.Get("/pulls", reqSignIn, user.Pulls)
|
||||||
m.Get("/stars", reqSignIn, user.Stars)
|
m.Get("/stars", reqSignIn, user.Stars)
|
||||||
m.Get("/help", routers.Help)
|
m.Get("/help", routers.Help)
|
||||||
|
m.Post("/preview", routers.Preview)
|
||||||
|
|
||||||
avt := avatar.CacheServer("public/img/avatar/", "public/img/avatar_default.jpg")
|
avt := avatar.CacheServer("public/img/avatar/", "public/img/avatar_default.jpg")
|
||||||
m.Get("/avatar/:hash", avt.ServeHTTP)
|
m.Get("/avatar/:hash", avt.ServeHTTP)
|
||||||
|
Loading…
Reference in New Issue
Block a user