diff options
author | Unknown <joe2010xtmf@163.com> | 2014-07-12 00:55:35 -0400 |
---|---|---|
committer | Unknown <joe2010xtmf@163.com> | 2014-07-12 00:55:35 -0400 |
commit | 3969d704a014c54e55281cd9b30e622acbd447c4 (patch) | |
tree | 7547f6a6672a4d22fe2844ca24285b83d7384a86 /public/js | |
parent | 0f907301b7fbd05faf07bc22b3316ae1093c6724 (diff) | |
parent | 590f9e599c9a1d544623c79a0064a09ca005f2d8 (diff) |
Merge branch 'dev' of github.com:gogits/gogs into dev
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 6edade44..4c376ea0 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); |