diff options
author | Unknwon <u@gogs.io> | 2015-08-10 21:47:23 +0800 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2015-08-10 21:47:23 +0800 |
commit | 75aff60c903c2c5ab92d75c9f067d6815f3daa2e (patch) | |
tree | e12104d0fbb25f15c41ee83c6c47acf9841df703 /public/js | |
parent | 09a1b2a1f5ca4c510be2828635a790b2a775ac94 (diff) | |
download | gitea-75aff60c903c2c5ab92d75c9f067d6815f3daa2e.tar.gz gitea-75aff60c903c2c5ab92d75c9f067d6815f3daa2e.zip |
finish create issue with milestone and assignee
Diffstat (limited to 'public/js')
-rw-r--r-- | public/js/gogs.js | 51 |
1 files changed, 32 insertions, 19 deletions
diff --git a/public/js/gogs.js b/public/js/gogs.js index 413bc43853..758b5cf60d 100644 --- a/public/js/gogs.js +++ b/public/js/gogs.js @@ -65,29 +65,42 @@ function initCommentForm() { $($(this).parent().data('id')).val(''); }); - var $milestone_menu = $('.select-milestone .menu'); - var $milestone_list = $('.ui.select-milestone.list') - // Milestones - $milestone_menu.find('.item:not(.no-select)').click(function () { - $(this).parent().find('.item').each(function () { - $(this).removeClass('selected active') + function selectItem(select_id, input_id) { + var $menu = $(select_id + ' .menu'); + var $list = $('.ui' + select_id + '.list') + $menu.find('.item:not(.no-select)').click(function () { + $(this).parent().find('.item').each(function () { + $(this).removeClass('selected active') + }); + + $(this).addClass('selected active'); + switch (input_id) { + case '#milestone_id': + $list.find('.selected').html('<a class="item" href=' + $(this).data('href') + '>' + + $(this).text() + '</a>'); + break; + case '#assignee_id': + $list.find('.selected').html('<a class="item" href=' + $(this).data('href') + '>' + + '<img class="ui avatar image" src=' + $(this).data('avatar') + '>' + + $(this).text() + '</a>'); + } + $('.ui' + select_id + '.list .no-select').addClass('hide'); + $(input_id).val($(this).data('id')); }); + $menu.find('.no-select.item').click(function () { + $(this).parent().find('.item:not(.no-select)').each(function () { + $(this).removeClass('selected active') + }); - $(this).addClass('selected active'); - $milestone_list.find('.selected').html('<a class="item" href=' + $(this).data('href') + '>' + - $(this).text() + '</a>'); - $('.ui.select-milestone.list .no-select').addClass('hide'); - $('#milestone_id').val($(this).data('id')); - }); - $milestone_menu.find('.no-select.item').click(function () { - $(this).parent().find('.item:not(.no-select)').each(function () { - $(this).removeClass('selected active') + $list.find('.selected').html(''); + $list.find('.no-select').removeClass('hide'); + $(input_id).val(''); }); + } - $milestone_list.find('.selected').html(''); - $milestone_list.find('.no-select').removeClass('hide'); - $('#milestone_id').val(''); - }); + // Milestone and assignee + selectItem('.select-milestone', '#milestone_id'); + selectItem('.select-assignee', '#assignee_id'); } function initInstall() { |