MDL-58518 block_myoverview: use user's midnight for sort by courses
[moodle.git] / blocks / myoverview / amd / build / event_list_by_course.min.js
CommitLineData
f31240eb 1define(["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"]',EVENT_LIST_CONTAINER:'[data-region="event-list-container"]'},f=function(f){var g=f.find(e.EVENTS_BY_COURSE_CONTAINER);if(g.length){var h=g.find(e.EVENT_LIST_CONTAINER).first(),i=h.attr("data-midnight"),j=i-14*d,k=h.attr("data-limit"),l=g.map(function(){return a(this).attr("data-course-id")}).get(),m=c.queryByCourses({courseids:l,starttime:j,limit:k});g.each(function(c,d){d=a(d);var e=d.attr("data-course-id"),f=d.find(b.rootSelector),g=a.Deferred();m.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)}}});