diff options
author | Unknwon <joe2010xtmf@163.com> | 2014-08-26 18:11:15 +0800 |
---|---|---|
committer | Unknwon <joe2010xtmf@163.com> | 2014-08-26 18:11:15 +0800 |
commit | 74b31566cf5caaf6bf73584e621d56ca99c048d1 (patch) | |
tree | 078a8428e5241d13600482301444684720a77283 /public/ng/js/gogs.js | |
parent | f2c263c54facdcbc9375a47535c0389fd7d05875 (diff) | |
download | gitea-74b31566cf5caaf6bf73584e621d56ca99c048d1.tar.gz gitea-74b31566cf5caaf6bf73584e621d56ca99c048d1.zip |
Finsih add/remove repo in organization
Diffstat (limited to 'public/ng/js/gogs.js')
-rw-r--r-- | public/ng/js/gogs.js | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/public/ng/js/gogs.js b/public/ng/js/gogs.js index 52000f3664..d4c3224eee 100644 --- a/public/ng/js/gogs.js +++ b/public/ng/js/gogs.js @@ -218,6 +218,26 @@ var Gogs = {}; } }); } + + // Search repositories by keyword. + Gogs.searchRepos = function (val, $target, $param) { + $.ajax({ + url: '/api/v1/repos/search?q=' + val + '&' + $param, + dataType: "json", + success: function (json) { + if (json.ok && json.data.length) { + var html = ''; + $.each(json.data, function (i, item) { + html += '<li><a><span class="octicon octicon-repo"></span> ' + item.repolink + '</a></li>'; + }); + $target.html(html); + $target.toggleShow(); + } else { + $target.toggleHide(); + } + } + }); + } })(jQuery); function initCore() { @@ -358,7 +378,7 @@ function initOrgTeamCreate() { e.preventDefault(); return true; } - var $form = $('#team-create-form') + var $form = $('#team-create-form'); $form.attr('action', $form.data('delete-url')); }); } @@ -383,7 +403,28 @@ function initTeamMembersList() { $('#org-team-members-add').val($(this).text()); $ul.toggleHide(); }); +} +function initTeamRepositoriesList() { + // Add team repository. + var $ul = $('#org-team-repositories-list'); + $('#org-team-repositories-add').on('keyup', function () { + var $this = $(this); + if (!$this.val()) { + $ul.toggleHide(); + return; + } + Gogs.searchRepos($this.val(), $ul, 'uid=' + $this.data('uid')); + }).on('focus', function () { + if (!$(this).val()) { + $ul.toggleHide(); + } else { + $ul.toggleShow(); + } + }).next().next().find('ul').on("click", 'li', function () { + $('#org-team-repositories-add').val($(this).text()); + $ul.toggleHide(); + }); } $(document).ready(function () { @@ -409,6 +450,9 @@ $(document).ready(function () { if ($('#team-members-list').length) { initTeamMembersList(); } + if ($('#team-repositories-list').length) { + initTeamRepositoriesList(); + } Tabs('#dashboard-sidebar-menu'); |