MDL-59383 core_calendar: create main calendar AMD module
[moodle.git] / calendar / amd / build / calendar.min.js
1 define(["jquery","core/ajax","core/str","core/templates","core/notification","core/custom_interaction_events","core/modal_factory","core_calendar/summary_modal","core_calendar/calendar_repository"],function(a,b,c,d,e,f,g,h,i){var j={ROOT:"[data-region='calendar']",EVENT_LINK:"[data-action='view-event']"},k=null,l=function(a){var b="type"+a;return c.get_string(b,"core_calendar").then(function(a){return a}).fail(e.exception)},m=function(a){var b=i.getEventById(a);return b.then(function(a){return a.event?a.event:void b.fail(e.exception)}).then(function(a){return l(a.eventtype).then(function(b){return a.eventtype=b,a})}).then(function(a){return k.done(function(b){b.setTitle(a.name),b.setBody(d.render("core_calendar/event_summary_body",a)),0==a.caneditevent&&b.setFooter(""),b.show()})})},n=function(b){b=a(b);var c=!1;b.on("click",j.EVENT_LINK,function(b){if(!c){c=!0,b.preventDefault();var d=a(b.target).closest(j.EVENT_LINK),e=d.attr("data-event-id");m(e).done(function(){c=!1})}})};return{init:function(){k=g.create({type:h.TYPE}),n(j.ROOT)}}});