define(["jquery","core_calendar/selectors","core_calendar/events","core_calendar/view_manager"],function(a,b,c,d){var e=function(b){var d=a("body"),e="."+b.attr("id");d.on(c.created+e,b,f),d.on(c.deleted+e,b,f),d.on(c.updated+e,b,f),d.on(c.eventMoved+e,b,f)},f=function(b){var e=b.data,f=a("body"),g="."+e.attr("id");e.is(":visible")?d.reloadCurrentMonth(e):(f.off(c.created+g),f.off(c.deleted+g),f.off(c.updated+g),f.off(c.eventMoved+g))},g=function(e){a("body").on(c.filterChanged,function(a,c){var d=e.find(b.eventType[c.type]);d.toggleClass("calendar_event_"+c.type,!c.hidden)});var f="."+e.attr("id");a("body").on("change"+f,b.elements.courseSelector,function(){if(e.is(":visible")){var b=a(this),c=b.val(),g=null;d.reloadCurrentMonth(e,c,g)}else a("body").off("change"+f)})};return{init:function(b,c){b=a(b),d.init(b),g(b),e(b),c&&d.reloadCurrentMonth(b)}}});