close menu again when clicking on avatar
Signed-off-by: Georg Ehrke <developer@georgehrke.com>
This commit is contained in:
parent
60f9ed6241
commit
c844b2931e
1 changed files with 26 additions and 29 deletions
|
@ -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));
|
||||
|
|
Loading…
Reference in a new issue