1
0
Fork 0
forked from forgejo/forgejo

finish create issue with labels

This commit is contained in:
Unknwon 2015-08-10 16:52:08 +08:00
parent 17de3ab0a3
commit 922f3f3062
9 changed files with 160 additions and 41 deletions

View file

@ -134,24 +134,65 @@ $(document).ready(function () {
$('.poping.up').popup();
// Comment form
$('.comment.form .tabular.menu .item').tab();
$('.comment.form .tabular.menu .item[data-tab="preview"]').click(function () {
var $this = $(this);
console.log($('.comment.form .tab.segment[data-tab="write"] textarea').val())
console.log($('.comment.form .tab.segment[data-tab="preview"]').html())
$.post($this.data('url'), {
"_csrf": csrf,
"mode": "gfm",
"context": $this.data('context'),
"text": $('.comment.form .tab.segment[data-tab="write"] textarea').val()
},
function (data) {
console.log(data)
$('.comment.form .tab.segment[data-tab="preview"]').html(data);
if ($('.comment.form').length > 0) {
var $form = $(this);
$form.find('.tabular.menu .item').tab();
$form.find('.tabular.menu .item[data-tab="preview"]').click(function () {
var $this = $(this);
$.post($this.data('url'), {
"_csrf": csrf,
"mode": "gfm",
"context": $this.data('context'),
"text": $form.find('.tab.segment[data-tab="write"] textarea').val()
},
function (data) {
$form.find('.tab.segment[data-tab="preview"]').html(data);
}
);
});
// Labels
var $list = $('.ui.labels.list');
var $no_select = $list.find('.no-select');
$('.select-label .item:not(.no-select)').click(function () {
if ($(this).hasClass('checked')) {
$(this).removeClass('checked')
$(this).find('.octicon').removeClass('octicon-check')
} else {
$(this).addClass('checked')
$(this).find('.octicon').addClass('octicon-check')
}
)
;
})
var label_ids = "";
$(this).parent().find('.item').each(function () {
if ($(this).hasClass('checked')) {
label_ids += $(this).data('id') + ",";
$($(this).data('id-selector')).removeClass('hide');
} else {
$($(this).data('id-selector')).addClass('hide');
}
});
if (label_ids.length == 0) {
$no_select.removeClass('hide');
} else {
$no_select.addClass('hide');
}
$($(this).parent().data('id')).val(label_ids);
return false;
});
$('.select-label .no-select.item').click(function () {
$(this).parent().find('.item').each(function () {
$(this).removeClass('checked');
$(this).find('.octicon').removeClass('octicon-check');
});
$list.find('.item').each(function () {
$(this).addClass('hide');
});
$no_select.removeClass('hide');
$($(this).parent().data('id')).val('');
});
}
// Helpers.
$('.delete-button').click(function () {