diff options
author | Georg Ehrke <developer@georgehrke.com> | 2017-04-24 13:03:52 +0200 |
---|---|---|
committer | Georg Ehrke <developer@georgehrke.com> | 2017-04-26 09:26:56 +0200 |
commit | c844b2931e72ae341b466a02509ef94c37568af6 (patch) | |
tree | 46acc093a638f94366f3de1f560a37170682e54d /core | |
parent | 60f9ed6241c3f7441f41bbd87d36c6f9e04c974b (diff) | |
download | nextcloud-server-c844b2931e72ae341b466a02509ef94c37568af6.tar.gz nextcloud-server-c844b2931e72ae341b466a02509ef94c37568af6.zip |
close menu again when clicking on avatar
Signed-off-by: Georg Ehrke <developer@georgehrke.com>
Diffstat (limited to 'core')
-rw-r--r-- | core/js/jquery.contactsmenu.js | 55 |
1 files changed, 26 insertions, 29 deletions
diff --git a/core/js/jquery.contactsmenu.js b/core/js/jquery.contactsmenu.js index 3c782cc5bfd..6e5f3228e3c 100644 --- a/core/js/jquery.contactsmenu.js +++ b/core/js/jquery.contactsmenu.js @@ -14,25 +14,18 @@ + ' </a>' + '</li>'; - $.fn.contactsMenu = function(shareWith, shareType, appendTo) { - if (typeof(shareWith) !== 'undefined') { - shareWith = String(shareWith); - } else { - if (typeof(this.data('share-with')) !== 'undefined') { - shareWith = this.data('share-with'); - } - } - if (typeof(shareType) !== 'undefined') { - shareType = Number(shareType); - } else { - if (typeof(this.data('share-type')) !== 'undefined') { - shareType = this.data('share-type'); - } - } - if (typeof(appendTo) === 'undefined') { - appendTo = this; - } + var LIST = '' + + '<div class="menu popovermenu bubble hidden contactsmenu-popover">' + + ' <ul>' + + ' <li>' + + ' <a>' + + ' <span class="icon-loading-small"></span>' + + ' </a>' + + ' </li>' + + ' </ul>' + + '</div>'; + $.fn.contactsMenu = function(shareWith, shareType, appendTo) { // 0 - user, 4 - email, 6 - remote var allowedTypes = [0, 4, 6]; if (allowedTypes.indexOf(shareType) === -1) { @@ -40,11 +33,17 @@ } var $div = this; - appendTo.append('<div class="menu popovermenu bubble hidden contactsmenu-popover"><ul><li><a><span class="icon-loading-small"></span></a></li></ul></div>'); + appendTo.append(LIST); var $list = appendTo.find('div.contactsmenu-popover'); - var url = OC.generateUrl('/contactsmenu/findOne'); $div.click(function() { + if (!$list.hasClass('hidden')) { + $list.addClass('hidden'); + $list.hide(); + return; + } + + $list.removeClass('hidden'); $list.show(); if ($list.hasClass('loaded')) { @@ -52,7 +51,7 @@ } $list.addClass('loaded'); - $.ajax(url, { + $.ajax(OC.generateUrl('/contactsmenu/findOne'), { method: 'POST', data: { shareType: shareType, @@ -80,28 +79,26 @@ } }); + }).catch(function(reason) { + // TODO }); $(document).click(function(event) { var clickedList = $.contains($list, event.target); - var clickedLi = $.contains($div, event.target); + var clickedTarget = $.contains($div, event.target); $div.each(function() { if ($(this).is(event.target)) { - clickedLi = true; + clickedTarget = true; } }); - if (clickedList) { - return; - } - - if (clickedLi) { + if (clickedList || clickedTarget) { return; } + $list.addClass('hidden'); $list.hide(); - }); }; }(jQuery)); |