(window.webpackJsonp=window.webpackJsonp||[]).push([[206],{4:function(e,a,t){"use strict";Object.defineProperty(a,"__esModule",{value:!0}),a.initialize=a.setupDTP=a.setupPost=void 0;var s=t(1),n=o(t(2)),d=o(t(0));function o(e){return e&&e.__esModule?e:{default:e}}t(7);const r=(e,a)=>{const t=e.find(".plugin-calendar-event-responses-day input");if(!t.length)return;const s=a?d.default.utc(a):(0,d.default)();t.datetimepicker({icons:{time:"fa fa-clock-o",date:"fa fa-calendar",up:"fa fa-arrow-up",down:"fa fa-arrow-down",previous:"fa fa-arrow-left",next:"fa fa-arrow-right",today:"fa fa-crosshairs",clear:"fa fa-trash",close:"fa fa-times"},allowInputToggle:!0,locale:(config.userLang||config.defaultLang).toLowerCase().replace(/_/g,"-"),format:"L",useCurrent:!0}).data("DateTimePicker").date(s)};a.setupDTP=r;const i=()=>{},l=({pid:e,e:a},t=i)=>{let s=$(`[data-pid=${e}] .plugin-calendar-event-responses-user`);const n=s.closest("[data-day]"),d=n.attr("data-day")||null;if(s.length){if(a||r(n,d),!app.user.uid)return s.remove(),void t();socket.emit("plugins.calendar.getUserResponse",{pid:e,day:d},(a,n)=>{if(a&&"[[error:no-privileges]]"===a.message)return void t();if(a)throw app.alertError(a),a;const d=(s=$(`[data-pid=${e}] .plugin-calendar-event-responses-user`)).find(`[data-value=${n||"no"}]`);d.siblings().removeClass("active"),d.addClass("active"),t()})}else t()};a.setupPost=l;let p=!1;a.initialize=()=>{if(p)return;$(document.body).on("click",".plugin-calendar-event-responses-user .btn",e=>{const a=$(e.target),t=a.data("value"),s=a.closest("[data-pid]").attr("data-pid"),n=a.closest("[data-day]").attr("data-day");socket.emit("plugins.calendar.submitResponse",{pid:s,value:t,day:n},e=>{if(e)throw e.message&&app.alertError(e),e;app.alertSuccess(),a.siblings().removeClass("active"),a.addClass("active")})}),$(document.body).on("change dp.change",".plugin-calendar-event-responses-day input",e=>{const a=$(e.target),t=a.data("DateTimePicker"),s=t&&t.date().utc().format("YYYY-MM-DD"),n=a.closest("[data-pid]").attr("data-pid"),d=a.closest("[data-day]");d.attr("data-day",s),d.find(".plugin-calendar-event-responses-lists").attr("data-loaded","false").find(".panel").addClass("closed"),l({pid:n,e:e})});const e=(e,a)=>{const t=a.posts||a.post||ajaxify.data.posts;t&&t.length>0&&setTimeout(()=>{t.forEach(e=>l({pid:e.pid}))},200)};$(document.body).on("click","[data-pid] .plugin-calendar-event-responses-lists .panel-heading a",e=>{const a=$(e.target).closest("a"),t=a.is("[data-loaded=false] a"),d=parseInt(a.closest("[data-pid]").attr("data-pid"),10),o=()=>{const e=a.closest(".panel"),t=e.find(".panel-collapse"),s=t.children()[0].scrollHeight;t.css("height",`${s}px`),e.toggleClass("closed")};t?(((e,a)=>{const t=$(`[data-pid=${e}] .plugin-calendar-event-responses-lists`),d=$(`[data-pid=${e}] [data-day]`).attr("data-day");t.length&&socket.emit("plugins.calendar.getResponses",{pid:e,day:d},(e,d)=>{if(e)throw e.message&&app.alertError(e),e;if(!(d&&d.yes&&d.maybe&&d.no))return;const o=t.find(".plugin-calendar-event-responses-list-yes"),r=t.find(".plugin-calendar-event-responses-list-maybe"),i=t.find(".plugin-calendar-event-responses-list-no");Promise.all([{responseType:"yes",users:d.yes},{responseType:"maybe",users:d.maybe},{responseType:"no",users:d.no}].map(e=>n.default.render("partials/calendar/event/response-list",e).then(e=>(0,s.translate)(e)))).then(([e,t,s])=>{o.empty().append(e),r.empty().append(t),i.empty().append(s),a()})})})(d,o),a.closest(".plugin-calendar-event-responses-lists").attr("data-loaded","true")):o(),e.preventDefault()}),$(window).on(["action:posts.loaded","action:ajaxify.end","action:posts.edited"].join(" "),e),e(0,ajaxify.data),p=!0}}}]);
//# sourceMappingURL=206.87854ddeef29fe0b6c56.js.map