4abb4fbf81b7ffe73ac6c2b4c11aa91a320d14a6
[moodle.git] / blocks / myoverview / amd / build / event_list_by_course.min.js
1 define(["jquery","block_myoverview/event_list","block_myoverview/calendar_events_repository"],function(a,b,c){var d=86400,e={EVENTS_BY_COURSE_CONTAINER:'[data-region="course-events-container"]'},f=function(f){var g=f.find(e.EVENTS_BY_COURSE_CONTAINER);if(g.length){var h=f.attr("data-midnight"),i=h-14*d,j=g.attr("data-limit"),k=g.map(function(){return a(this).attr("data-course-id")}).get(),l=c.queryByCourses({courseids:k,starttime:i,limit:j});g.each(function(c,d){d=a(d);var e=d.attr("data-course-id"),f=d.find(b.rootSelector),g=a.Deferred();l.done(function(a){var b=[],c=a.groupedbycourse.filter(function(a){return a.courseid==e});c.length&&(b=c[0].events),g.resolve({events:b})}).fail(function(a){g.reject(a)}),b.load(f,g)})}};return{init:function(b){b=a(b),f(b)}}});