diff options
Diffstat (limited to 'public/js/gogs.js')
-rw-r--r-- | public/js/gogs.js | 58 |
1 files changed, 56 insertions, 2 deletions
diff --git a/public/js/gogs.js b/public/js/gogs.js index e9714926..5dae3c0c 100644 --- a/public/js/gogs.js +++ b/public/js/gogs.js @@ -26,13 +26,30 @@ function initCommentForm() { // Labels var $list = $('.ui.labels.list'); var $no_select = $list.find('.no-select'); - $('.select-label .menu .item:not(.no-select)').click(function () { + var $label_menu = $('.select-label .menu'); + var has_label_update_action = $label_menu.data('action') == 'update'; + + function updateIssueMeta(url, action, id) { + $.post(url, { + "_csrf": csrf, + "action": action, + "id": id + }); + } + + $label_menu.find('.item:not(.no-select)').click(function () { if ($(this).hasClass('checked')) { $(this).removeClass('checked') $(this).find('.octicon').removeClass('octicon-check') + if (has_label_update_action) { + updateIssueMeta($label_menu.data('update-url'), "detach", $(this).data('id')); + } } else { $(this).addClass('checked') $(this).find('.octicon').addClass('octicon-check') + if (has_label_update_action) { + updateIssueMeta($label_menu.data('update-url'), "attach", $(this).data('id')); + } } var label_ids = ""; @@ -52,7 +69,11 @@ function initCommentForm() { $($(this).parent().data('id')).val(label_ids); return false; }); - $('.select-label .menu .no-select.item').click(function () { + $label_menu.find('.no-select.item').click(function () { + if (has_label_update_action) { + updateIssueMeta($label_menu.data('update-url'), "clear", ''); + } + $(this).parent().find('.item').each(function () { $(this).removeClass('checked'); $(this).find('.octicon').removeClass('octicon-check'); @@ -68,12 +89,17 @@ function initCommentForm() { function selectItem(select_id, input_id) { var $menu = $(select_id + ' .menu'); var $list = $('.ui' + select_id + '.list') + var has_update_action = $menu.data('action') == 'update'; + $menu.find('.item:not(.no-select)').click(function () { $(this).parent().find('.item').each(function () { $(this).removeClass('selected active') }); $(this).addClass('selected active'); + if (has_update_action) { + updateIssueMeta($menu.data('update-url'), '', $(this).data('id')); + } switch (input_id) { case '#milestone_id': $list.find('.selected').html('<a class="item" href=' + $(this).data('href') + '>' + @@ -92,6 +118,10 @@ function initCommentForm() { $(this).removeClass('selected active') }); + if (has_update_action) { + updateIssueMeta($menu.data('update-url'), '', ''); + } + $list.find('.selected').html(''); $list.find('.no-select').removeClass('hide'); $(input_id).val(''); @@ -203,6 +233,22 @@ function initRepository() { }); } + // Issues + if ($('.repository.view.issue').length > 0) { + var $status_btn = $('#status-button'); + $('#content').keyup(function () { + if ($(this).val().length == 0) { + $status_btn.text($status_btn.data('status')) + } else { + $status_btn.text($status_btn.data('status-and-comment')) + } + }); + $status_btn.click(function () { + $('#status').val($status_btn.data('status-val')); + $('#comment-form').submit(); + }) + } + // Pull request if ($('.repository.compare.pull').length > 0) { var $branch_dropdown = $('.choose.branch .dropdown') @@ -219,6 +265,14 @@ function initRepository() { $(document).ready(function () { csrf = $('meta[name=_csrf]').attr("content"); + // Show exact time + $('.time-since').each(function () { + $(this).addClass('poping up'). + attr('data-content', $(this).attr('title')). + attr('data-variation', 'inverted tiny'). + attr('title', ''); + }); + // Semantic UI modules. $('.dropdown').dropdown(); $('.jump.dropdown').dropdown({ |