mirror of
https://github.com/friendica/friendica
synced 2024-06-08 09:50:16 +02:00
Improve contactgroupChangeMember() javascript function
- Add usage of new /group/123/add|remove/123 URL - Add checkbox revert in case of error
This commit is contained in:
parent
6376293218
commit
0a58e4c952
|
@ -793,11 +793,25 @@ function profChangeMember(gid,cid) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function contactgroupChangeMember(gid,cid) {
|
function contactgroupChangeMember(checkbox, gid, cid) {
|
||||||
|
let url;
|
||||||
|
// checkbox.checked is the checkbox state after the click
|
||||||
|
if (checkbox.checked) {
|
||||||
|
url = 'group/' + gid + '/add/' + cid;
|
||||||
|
} else {
|
||||||
|
url = 'group/' + gid + '/remove/' + cid;
|
||||||
|
}
|
||||||
$('body').css('cursor', 'wait');
|
$('body').css('cursor', 'wait');
|
||||||
$.get('contactgroup/' + gid + '/' + cid, function(data) {
|
$.post(url)
|
||||||
$('body').css('cursor', 'auto');
|
.error(function () {
|
||||||
|
// Restores previous state in case of error
|
||||||
|
checkbox.checked = !checkbox.checked;
|
||||||
|
})
|
||||||
|
.always(function() {
|
||||||
|
$('body').css('cursor', 'auto');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkboxhighlight(box) {
|
function checkboxhighlight(box) {
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
{{if $group.cid}}
|
{{if $group.cid}}
|
||||||
<input type="checkbox"
|
<input type="checkbox"
|
||||||
class="{{if $group.selected}}ticked{{else}}unticked {{/if}} action"
|
class="{{if $group.selected}}ticked{{else}}unticked {{/if}} action"
|
||||||
onclick="contactgroupChangeMember('{{$group.id}}','{{$group.cid}}');return true;"
|
onclick="return contactgroupChangeMember(this, '{{$group.id}}','{{$group.cid}}');"
|
||||||
{{if $group.ismember}}checked="checked"{{/if}}
|
{{if $group.ismember}}checked="checked"{{/if}}
|
||||||
/>
|
/>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
<input type="checkbox"
|
<input type="checkbox"
|
||||||
id="sidebar-group-checkbox-{{$group.id}}"
|
id="sidebar-group-checkbox-{{$group.id}}"
|
||||||
class="{{if $group.selected}}ticked{{else}}unticked {{/if}} action"
|
class="{{if $group.selected}}ticked{{else}}unticked {{/if}} action"
|
||||||
onclick="contactgroupChangeMember('{{$group.id}}','{{$group.cid}}');return true;"
|
onclick="return contactgroupChangeMember(this, '{{$group.id}}','{{$group.cid}}');"
|
||||||
{{if $group.ismember}}checked="checked"{{/if}}
|
{{if $group.ismember}}checked="checked"{{/if}}
|
||||||
aria-checked="{{if $group.ismember}}true{{else}}false{{/if}}"
|
aria-checked="{{if $group.ismember}}true{{else}}false{{/if}}"
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
{{if $group.cid}}
|
{{if $group.cid}}
|
||||||
<input type="checkbox"
|
<input type="checkbox"
|
||||||
class="{{if $group.selected}}ticked{{else}}unticked {{/if}} action"
|
class="{{if $group.selected}}ticked{{else}}unticked {{/if}} action"
|
||||||
onclick="contactgroupChangeMember('{{$group.id}}','{{$group.cid}}');return true;"
|
onclick="return contactgroupChangeMember(this, '{{$group.id}}','{{$group.cid}}');"
|
||||||
{{if $group.ismember}}checked="checked"{{/if}}
|
{{if $group.ismember}}checked="checked"{{/if}}
|
||||||
/>
|
/>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
Loading…
Reference in a new issue