blob: bb6371dff39530d2edf6af7d7c6672116be2adb2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
(function ($) {
'use strict';
var last = null;
// Open action menu on click on the icon
$(document).on('click', '.action-menu-icon', function (event) {
// Choose correct root element if menu was positioned absolutely
let root_element = $(this).closest('.action-menu');
if ($(this).closest('.action-menu-wrapper').length > 0) {
root_element = $(this).data('action-menu-element');
}
var position = root_element.data('action-menu-reposition');
if (position === undefined) {
position = true;
}
// Obtain unique id for the root element and close other menus if neccessary
const id = root_element.uniqueId().attr('id');
if (last !== id) {
STUDIP.ActionMenu.closeAll();
last = id;
}
STUDIP.ActionMenu.create(root_element, position).toggle();
// Stop event so the following close event will not be fired
return false;
});
// Close action menu on click outside
$(document).on('click', (event) => {
if ($(event.target).closest('.action-menu-content').length === 0) {
STUDIP.ActionMenu.closeAll();
}
});
}(jQuery));
|