diff options
author | Unknwon <u@gogs.io> | 2015-08-10 16:52:08 +0800 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2015-08-10 16:52:08 +0800 |
commit | 922f3f306239aca309279dbdf1bdedfb9788b6e8 (patch) | |
tree | 410c6eb28335f9e0a213da59699053b159f607ea /public/js/gogs.js | |
parent | 17de3ab0a313819bdeb73f3985b61a791ae84696 (diff) | |
download | gitea-922f3f306239aca309279dbdf1bdedfb9788b6e8.tar.gz gitea-922f3f306239aca309279dbdf1bdedfb9788b6e8.zip |
finish create issue with labels
Diffstat (limited to 'public/js/gogs.js')
-rw-r--r-- | public/js/gogs.js | 75 |
1 files changed, 58 insertions, 17 deletions
diff --git a/public/js/gogs.js b/public/js/gogs.js index 9aa95203b1..3228076571 100644 --- a/public/js/gogs.js +++ b/public/js/gogs.js @@ -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 () { |