summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/js/jquery.contactsmenu.js55
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));