From 915035e9bad5c339c5ca49efb9bd784ce0d34219 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Mon, 27 May 2019 15:12:14 +0200 Subject: [PATCH] Small code simplification --- plugins/calendar/calendar_ui.js | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/plugins/calendar/calendar_ui.js b/plugins/calendar/calendar_ui.js index 02807837..b0688c3f 100644 --- a/plugins/calendar/calendar_ui.js +++ b/plugins/calendar/calendar_ui.js @@ -3609,25 +3609,19 @@ function rcube_calendar_ui(settings) } var id = this.value; - if (me.calendars[id]) { // add or remove event source on click - var action; - if (this.checked) { - action = 'addEventSource'; - me.calendars[id].active = true; - } - else { - action = 'removeEventSource'; - me.calendars[id].active = false; - } + // add or remove event source on click + if (me.calendars[id]) { // adjust checked state of original list item if (calendars_list.is_search()) { calendars_list.container.find('input[value="'+id+'"]').prop('checked', this.checked); } + me.calendars[id].active = this.checked; + // add/remove event source - fc.fullCalendar(action, me.calendars[id]); - rcmail.http_post('calendar', { action:'subscribe', c:{ id:id, active:me.calendars[id].active?1:0 } }); + fc.fullCalendar(this.checked ? 'addEventSource' : 'removeEventSource', me.calendars[id]); + rcmail.http_post('calendar', {action: 'subscribe', c: {id: id, active: this.checked ? 1 : 0}}); } }) .on('keypress', 'input[type=checkbox]', function(e) {