mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
hide Add Group when clicking away or pressing ESC
This commit is contained in:
parent
a4cfa95545
commit
853ced644d
1 changed files with 22 additions and 1 deletions
|
|
@ -74,6 +74,11 @@
|
|||
OC.Notification.showHtml(t('settings', 'deleted') + ' ' + escapeHTML(gid) + '<span class="undo">' + t('settings', 'undo') + '</span>');
|
||||
},
|
||||
|
||||
elementBelongsToAddGroup: function(el) {
|
||||
return !(el !== $('#newgroup-form').get(0)
|
||||
&& $('#newgroup-form').find($(el)).length === 0);
|
||||
},
|
||||
|
||||
showGroup: function (gid) {
|
||||
UserList.empty();
|
||||
UserList.update(gid);
|
||||
|
|
@ -84,8 +89,12 @@
|
|||
}
|
||||
},
|
||||
|
||||
isAddGroupButtonVisible: function() {
|
||||
return $('#newgroup-init').is(":visible");
|
||||
},
|
||||
|
||||
toggleAddGroup: function(event) {
|
||||
if($('#newgroup-init').is(":visible")) {
|
||||
if(GroupList.isAddGroupButtonVisible()) {
|
||||
event.stopPropagation();
|
||||
$('#newgroup-form').show();
|
||||
$('#newgroup-init').hide();
|
||||
|
|
@ -149,6 +158,18 @@ $(document).ready( function () {
|
|||
GroupList.toggleAddGroup(e);
|
||||
});
|
||||
|
||||
$(document).on('click keydown keyup', function(event) {
|
||||
if(!GroupList.isAddGroupButtonVisible()
|
||||
&& !GroupList.elementBelongsToAddGroup(event.target)) {
|
||||
GroupList.toggleAddGroup();
|
||||
}
|
||||
// Escape
|
||||
if(!GroupList.isAddGroupButtonVisible() && event.keyCode && event.keyCode === 27) {
|
||||
GroupList.toggleAddGroup();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Responsible for Creating Groups.
|
||||
$('#newgroup-form form').submit(function (event) {
|
||||
event.preventDefault();
|
||||
|
|
|
|||
Loading…
Reference in a new issue