diff options
author | fuxiaohei <fuxiaohei@vip.qq.com> | 2014-07-07 18:13:42 +0800 |
---|---|---|
committer | fuxiaohei <fuxiaohei@vip.qq.com> | 2014-07-07 18:13:42 +0800 |
commit | c127d8477759d0236cb599b9bde3d8fe9449d723 (patch) | |
tree | 58a5640816a7867ae9fa3d2b07df40a74d8de07d /public/js | |
parent | 63cc14062a891a99a429f2eef0ee90a3f5795f47 (diff) | |
download | gitea-c127d8477759d0236cb599b9bde3d8fe9449d723.tar.gz gitea-c127d8477759d0236cb599b9bde3d8fe9449d723.zip |
add organization team-single page
Diffstat (limited to 'public/js')
-rw-r--r-- | public/js/app.js | 89 |
1 files changed, 71 insertions, 18 deletions
diff --git a/public/js/app.js b/public/js/app.js index 6edade445b..4c376ea088 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -301,6 +301,26 @@ var Gogits = {}; }).addClass("js-copy-bind"); } + // api working + Gogits.getUsers = function (val, $target) { + $.ajax({ + url: '/api/v1/users/search?q=' + val, + dataType: "json", + success: function (json) { + if (json.ok && json.data.length) { + var html = ''; + $.each(json.data, function (i, item) { + html += '<li><img src="' + item.avatar + '">' + item.username + '</li>'; + }); + $target.toggleShow(); + $target.find('ul').html(html); + } else { + $target.toggleHide(); + } + } + }); + } + })(jQuery); // ajax utils @@ -733,22 +753,23 @@ function initRepoSetting() { $this.next().toggleHide(); return; } - $.ajax({ - url: '/api/v1/users/search?q=' + $this.val(), - dataType: "json", - success: function (json) { - if (json.ok && json.data.length) { - var html = ''; - $.each(json.data, function (i, item) { - html += '<li><img src="' + item.avatar + '">' + item.username + '</li>'; - }); - $this.next().toggleShow(); - $this.next().find('ul').html(html); - } else { - $this.next().toggleHide(); - } - } - }); + Gogits.getUsers($this.val(), $this.next()); + /*$.ajax({ + url: '/api/v1/users/search?q=' + $this.val(), + dataType: "json", + success: function (json) { + if (json.ok && json.data.length) { + var html = ''; + $.each(json.data, function (i, item) { + html += '<li><img src="' + item.avatar + '">' + item.username + '</li>'; + }); + $this.next().toggleShow(); + $this.next().find('ul').html(html); + } else { + $this.next().toggleHide(); + } + } + });*/ }).on('focus', function () { if (!$(this).val()) { $(this).next().toggleHide(); @@ -771,14 +792,43 @@ function initRepoCreating() { $(this).addClass("checked"); } // set button group to show clicked owner - $('#repo-owner-avatar').attr("src",$(this).find('img').attr("src")); + $('#repo-owner-avatar').attr("src", $(this).find('img').attr("src")); $('#repo-owner-name').text($(this).text().trim()); - console.log("set repo owner to uid :",uid,$(this).text().trim()); + console.log("set repo owner to uid :", uid, $(this).text().trim()); }); }()); console.log("init repo-creating scripts"); } +function initOrganization() { + (function(){ + $('#org-team-add-user').on('keyup', function () { + var $this = $(this); + if (!$this.val()) { + $this.next().toggleHide(); + return; + } + Gogits.getUsers($this.val(), $this.next()); + }).on('focus', function () { + if (!$(this).val()) { + $(this).next().toggleHide(); + } + }).next().on("click", 'li', function () { + $('#org-team-add-user').val($(this).text()); + $('#org-team-add-user-form').submit(); + }).toggleHide(); + console.log("init script : add user to team"); + }()); + + (function(){ + $('#org-team-add-repo').next().toggleHide(); + console.log("init script : add repository to team"); + }()); + + + console.log("init script : organization done"); +} + (function ($) { $(function () { initCore(); @@ -804,6 +854,9 @@ function initRepoCreating() { if ($('#repo-create').length) { initRepoCreating(); } + if ($('#body-nav').hasClass("org-nav")) { + initOrganization(); + } }); })(jQuery); |