summaryrefslogtreecommitdiffstats
path: root/public/js
diff options
context:
space:
mode:
authorFuXiaoHei <fuxiaohei@hexiaz.com>2014-05-12 20:35:26 +0800
committerFuXiaoHei <fuxiaohei@hexiaz.com>2014-05-12 20:35:26 +0800
commit3fe87cba85de888a00edbf4c4d2a182910e1ddec (patch)
tree549288983dc99d19cf50722b5e7d08b718756880 /public/js
parent0970d6cc38a79c57ffe8e3c85687f7c7c49059be (diff)
downloadgitea-3fe87cba85de888a00edbf4c4d2a182910e1ddec.tar.gz
gitea-3fe87cba85de888a00edbf4c4d2a182910e1ddec.zip
fix preview js
Diffstat (limited to 'public/js')
-rw-r--r--public/js/app.js19
1 files changed, 11 insertions, 8 deletions
diff --git a/public/js/app.js b/public/js/app.js
index f59442ee9c..02b6d46476 100644
--- a/public/js/app.js
+++ b/public/js/app.js
@@ -55,7 +55,7 @@ var Gogits = {};
toggleShow: function () {
$(this).removeClass("hidden");
},
- toggleAjax: function (successCallback) {
+ toggleAjax: function (successCallback, errorCallback) {
var url = $(this).data("ajax");
var method = $(this).data('ajax-method') || 'get';
var ajaxName = $(this).data('ajax-name');
@@ -91,6 +91,7 @@ var Gogits = {};
url: url,
method: method.toUpperCase(),
data: data,
+ error: errorCallback,
success: function (d) {
if (successCallback) {
successCallback(d);
@@ -527,6 +528,8 @@ function initIssue() {
var $this = $(this);
$this.toggleAjax(function (resp) {
$($this.data("preview")).html(resp);
+ },function(){
+ $($this.data("preview")).html("no content");
})
});
$('.issue-write a[data-toggle]').on("click", function () {
@@ -537,14 +540,14 @@ function initIssue() {
// assignee
var is_issue_bar = $('.issue-bar').length > 0;
var $a = $('.assignee');
- if($a.data("assigned") > 0){
+ if ($a.data("assigned") > 0) {
$('.clear-assignee').toggleShow();
}
$('.assignee', '#issue').on('click', 'li', function () {
var uid = $(this).data("uid");
- if(is_issue_bar){
+ if (is_issue_bar) {
var assignee = $a.data("assigned");
- if(uid != assignee){
+ if (uid != assignee) {
$.post($a.data("ajax"), {
issue: $('#issue').data("id"),
assigneeid: uid
@@ -574,9 +577,9 @@ function initRelease() {
$('[data-ajax-name=release-preview]').on("click", function () {
var $this = $(this);
$this.toggleAjax(function (json) {
- if (json.ok) {
- $($this.data("preview")).html(json.content);
- }
+ $($this.data("preview")).html(json.ok ? json.content : "no content");
+ }, function () {
+ $($this.data("preview")).html("no content");
})
});
$('.release-write a[data-toggle]').on("click", function () {
@@ -651,6 +654,6 @@ function initRepoSetting() {
});
})(jQuery);
-String.prototype.endsWith = function(suffix) {
+String.prototype.endsWith = function (suffix) {
return this.indexOf(suffix, this.length - suffix.length) !== -1;
};