mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
Merge branch 'MDL-58536-master' of git://github.com/ryanwyllie/moodle
This commit is contained in:
commit
07e5b34c95
@ -1 +1 @@
|
||||
define(["jquery","core/notification","core/templates","core/custom_interaction_events","block_myoverview/calendar_events_repository"],function(a,b,c,d,e){var f=86400,g={EMPTY_MESSAGE:'[data-region="empty-message"]',ROOT:'[data-region="event-list-container"]',EVENT_LIST:'[data-region="event-list"]',EVENT_LIST_CONTENT:'[data-region="event-list-content"]',EVENT_LIST_GROUP_CONTAINER:'[data-region="event-list-group-container"]',LOADING_ICON_CONTAINER:'[data-region="loading-icon-container"]',VIEW_MORE_BUTTON:'[data-action="view-more"]'},h={EVENT_LIST_ITEMS:"block_myoverview/event-list-items",COURSE_EVENT_LIST_ITEMS:"block_myoverview/course-event-list-items"},i=function(a){a.attr("data-loaded-all",!0)},j=function(a){return!!a.attr("data-loaded-all")},k=function(a){var b=a.find(g.LOADING_ICON_CONTAINER),c=a.find(g.VIEW_MORE_BUTTON);a.addClass("loading"),b.removeClass("hidden"),c.prop("disabled",!0)},l=function(a){var b=a.find(g.LOADING_ICON_CONTAINER),c=a.find(g.VIEW_MORE_BUTTON);a.removeClass("loading"),b.addClass("hidden"),j(a)||c.prop("disabled",!1)},m=function(a){return a.hasClass("loading")},n=function(a){a.attr("data-has-events",!0)},o=function(a){return!!a.attr("data-has-events")},p=function(a,b){b?n(a):o(a)||q(a)},q=function(a){a.find(g.EVENT_LIST_CONTENT).addClass("hidden"),a.find(g.EMPTY_MESSAGE).removeClass("hidden")},r=function(a,b,d){return a.removeClass("hidden"),c.render(d,{events:b}).done(function(b,d){c.appendNodeContents(a.find(g.EVENT_LIST),b,d)})},s=function(a,b){var c=b.timesort||0;return c-a},t=function(a,b){var c=Math.floor((new Date).setHours(0,0,0,0)/1e3),d=+b.attr("data-start-day")*f,e=+b.attr("data-end-day")*f,g=s(c,a);return""===b.attr("data-end-day")?d<=g:d<=g&&g<e},u=function(b){return function(c){return t(c,a(b))}},v=function(b,c){var d=0,e=h.EVENT_LIST_ITEMS;return b.attr("data-course-id")&&(e=h.COURSE_EVENT_LIST_ITEMS),a.when.apply(a,a.map(b.find(g.EVENT_LIST_GROUP_CONTAINER),function(b){var f=c.filter(u(b));return f.length?(d+=f.length,r(a(b),f,e)):null})).then(function(){return d})},w=function(c,d){c=a(c);var f,g=+c.attr("data-limit"),h=+c.attr("data-course-id"),j=c.attr("data-last-id"),n=new Date;if(n.setDate(n.getDate()-14),n.setHours(0,0,0,0),f=Math.floor(n/1e3),m(c))return a.Deferred().resolve();if(k(c),"undefined"==typeof d){var o={starttime:f,limit:g};j&&(o.aftereventid=j),h?(o.courseid=h,d=e.queryByCourse(o)):d=e.queryByTime(o)}return d.then(function(a){return a.events}).then(function(a){return(!a.length||a.length<g)&&i(c),a.length?(c.attr("data-last-id",a[a.length-1].id),v(c,a).then(function(b){p(c,a.length),b<a.length&&i(c)})):void p(c,a.length)}).fail(b.exception).always(function(){l(c)})},x=function(a){d.define(a,[d.events.activate]),a.on(d.events.activate,g.VIEW_MORE_BUTTON,function(){w(a)})};return{init:function(b){b=a(b),w(b),x(b)},registerEventListeners:x,load:w,rootSelector:g.ROOT}});
|
||||
define(["jquery","core/notification","core/templates","core/custom_interaction_events","block_myoverview/calendar_events_repository"],function(a,b,c,d,e){var f=86400,g={EMPTY_MESSAGE:'[data-region="empty-message"]',ROOT:'[data-region="event-list-container"]',EVENT_LIST:'[data-region="event-list"]',EVENT_LIST_CONTENT:'[data-region="event-list-content"]',EVENT_LIST_GROUP_CONTAINER:'[data-region="event-list-group-container"]',LOADING_ICON_CONTAINER:'[data-region="loading-icon-container"]',VIEW_MORE_BUTTON:'[data-action="view-more"]'},h={EVENT_LIST_ITEMS:"block_myoverview/event-list-items",COURSE_EVENT_LIST_ITEMS:"block_myoverview/course-event-list-items"},i=function(a){a.attr("data-loaded-all",!0)},j=function(a){return!!a.attr("data-loaded-all")},k=function(a){var b=a.find(g.LOADING_ICON_CONTAINER),c=a.find(g.VIEW_MORE_BUTTON);a.addClass("loading"),b.removeClass("hidden"),c.prop("disabled",!0)},l=function(a){var b=a.find(g.LOADING_ICON_CONTAINER),c=a.find(g.VIEW_MORE_BUTTON);a.removeClass("loading"),b.addClass("hidden"),j(a)||c.prop("disabled",!1)},m=function(a){return a.hasClass("loading")},n=function(a){a.attr("data-has-events",!0)},o=function(a){return!!a.attr("data-has-events")},p=function(a,b){b?n(a):o(a)||q(a)},q=function(a){a.find(g.EVENT_LIST_CONTENT).addClass("hidden"),a.find(g.EMPTY_MESSAGE).removeClass("hidden")},r=function(a,b,d){return a.removeClass("hidden"),c.render(d,{events:b}).done(function(b,d){c.appendNodeContents(a.find(g.EVENT_LIST),b,d)})},s=function(a,b){var c=b.timesort||0;return c-a},t=function(a,b,c){var d=a.attr("data-midnight"),e=+c.attr("data-start-day")*f,g=+c.attr("data-end-day")*f,h=s(d,b);return""===c.attr("data-end-day")?e<=h:e<=h&&h<g},u=function(b,c){return function(d){return t(b,d,a(c))}},v=function(b,c){var d=0,e=h.EVENT_LIST_ITEMS;return b.attr("data-course-id")&&(e=h.COURSE_EVENT_LIST_ITEMS),a.when.apply(a,a.map(b.find(g.EVENT_LIST_GROUP_CONTAINER),function(f){var g=c.filter(u(b,f));return g.length?(d+=g.length,r(a(f),g,e)):null})).then(function(){return d})},w=function(c,d){c=a(c);var g=+c.attr("data-limit"),h=+c.attr("data-course-id"),j=c.attr("data-last-id"),n=c.attr("data-midnight"),o=n-14*f;if(m(c))return a.Deferred().resolve();if(k(c),"undefined"==typeof d){var q={starttime:o,limit:g};j&&(q.aftereventid=j),h?(q.courseid=h,d=e.queryByCourse(q)):d=e.queryByTime(q)}return d.then(function(a){return a.events}).then(function(a){return(!a.length||a.length<g)&&i(c),a.length?(c.attr("data-last-id",a[a.length-1].id),v(c,a).then(function(b){p(c,a.length),b<a.length&&i(c)})):void p(c,a.length)}).fail(b.exception).always(function(){l(c)})},x=function(a){d.define(a,[d.events.activate]),a.on(d.events.activate,g.VIEW_MORE_BUTTON,function(){w(a)})};return{init:function(b){b=a(b),w(b),x(b)},registerEventListeners:x,load:w,rootSelector:g.ROOT}});
|
@ -1 +1 @@
|
||||
define(["jquery","block_myoverview/event_list","block_myoverview/calendar_events_repository"],function(a,b,c){var d={EVENTS_BY_COURSE_CONTAINER:'[data-region="course-events-container"]'},e=function(e){var f=e.find(d.EVENTS_BY_COURSE_CONTAINER);if(f.length){var g=new Date;g.setDate(g.getDate()-14),g.setHours(0,0,0,0);var h=Math.floor(g/1e3),i=f.attr("data-limit"),j=f.map(function(){return a(this).attr("data-course-id")}).get(),k=c.queryByCourses({courseids:j,starttime:h,limit:i});f.each(function(c,d){d=a(d);var e=d.attr("data-course-id"),f=d.find(b.rootSelector),g=a.Deferred();k.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),e(b)}}});
|
||||
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)}}});
|
@ -222,12 +222,13 @@ define(['jquery', 'core/notification', 'core/templates',
|
||||
*
|
||||
* @method eventBelongsInContainer
|
||||
* @private
|
||||
* @param {object} root The root element
|
||||
* @param {object} event The calendar event
|
||||
* @param {object} container The group event list container
|
||||
* @return {bool}
|
||||
*/
|
||||
var eventBelongsInContainer = function(event, container) {
|
||||
var todayTime = Math.floor(new Date().setHours(0, 0, 0, 0) / 1000),
|
||||
var eventBelongsInContainer = function(root, event, container) {
|
||||
var todayTime = root.attr('data-midnight'),
|
||||
timeUntilContainerStart = +container.attr('data-start-day') * SECONDS_IN_DAY,
|
||||
timeUntilContainerEnd = +container.attr('data-end-day') * SECONDS_IN_DAY,
|
||||
timeUntilEventNeedsAction = timeUntilEvent(todayTime, event);
|
||||
@ -246,12 +247,13 @@ define(['jquery', 'core/notification', 'core/templates',
|
||||
*
|
||||
* @method getFilterCallbackForContainer
|
||||
* @private
|
||||
* @param {object} root The root element
|
||||
* @param {object} container Event list group container
|
||||
* @return {function}
|
||||
*/
|
||||
var getFilterCallbackForContainer = function(container) {
|
||||
var getFilterCallbackForContainer = function(root, container) {
|
||||
return function(event) {
|
||||
return eventBelongsInContainer(event, $(container));
|
||||
return eventBelongsInContainer(root, event, $(container));
|
||||
};
|
||||
};
|
||||
|
||||
@ -278,7 +280,7 @@ define(['jquery', 'core/notification', 'core/templates',
|
||||
// that belong to that group (as defined by the group's day range). The matching
|
||||
// list of calendar events are rendered and added to the DOM within that group.
|
||||
return $.when.apply($, $.map(root.find(SELECTORS.EVENT_LIST_GROUP_CONTAINER), function(container) {
|
||||
var events = calendarEvents.filter(getFilterCallbackForContainer(container));
|
||||
var events = calendarEvents.filter(getFilterCallbackForContainer(root, container));
|
||||
|
||||
if (events.length) {
|
||||
renderCount += events.length;
|
||||
@ -314,12 +316,8 @@ define(['jquery', 'core/notification', 'core/templates',
|
||||
var limit = +root.attr('data-limit'),
|
||||
courseId = +root.attr('data-course-id'),
|
||||
lastId = root.attr('data-last-id'),
|
||||
date = new Date(),
|
||||
startTime;
|
||||
|
||||
date.setDate(date.getDate() - 14);
|
||||
date.setHours(0, 0, 0, 0);
|
||||
startTime = Math.floor(date / 1000);
|
||||
midnight = root.attr('data-midnight'),
|
||||
startTime = midnight - (14 * SECONDS_IN_DAY);
|
||||
|
||||
// Don't load twice.
|
||||
if (isLoading(root)) {
|
||||
|
@ -29,6 +29,8 @@ define(
|
||||
],
|
||||
function($, EventList, EventsRepository) {
|
||||
|
||||
var SECONDS_IN_DAY = 60 * 60 * 24;
|
||||
|
||||
var SELECTORS = {
|
||||
EVENTS_BY_COURSE_CONTAINER: '[data-region="course-events-container"]',
|
||||
};
|
||||
@ -46,10 +48,8 @@ function($, EventList, EventsRepository) {
|
||||
return;
|
||||
}
|
||||
|
||||
var date = new Date();
|
||||
date.setDate(date.getDate() - 14);
|
||||
date.setHours(0, 0, 0, 0);
|
||||
var startTime = Math.floor(date / 1000);
|
||||
var midnight = root.attr('data-midnight');
|
||||
var startTime = midnight - (14 * SECONDS_IN_DAY);
|
||||
var limit = courseBlocks.attr('data-limit');
|
||||
var courseIds = courseBlocks.map(function() {
|
||||
return $(this).attr('data-course-id');
|
||||
|
@ -62,6 +62,7 @@ class main implements renderable, templatable {
|
||||
$noeventsurl = $output->image_url('activities', 'block_myoverview')->out();
|
||||
|
||||
return [
|
||||
'midnight' => usergetmidnight(time()),
|
||||
'coursesview' => $coursesview->export_for_template($output),
|
||||
'urls' => [
|
||||
'nocourses' => $nocoursesurl,
|
||||
|
@ -28,6 +28,7 @@
|
||||
data-limit="{{$limit}}20{{/limit}}"
|
||||
data-course-id="{{$courseid}}{{/courseid}}"
|
||||
data-last-id="{{$lastid}}{{/lastid}}"
|
||||
data-midnight="{{midnight}}"
|
||||
id="event-list-container-{{$courseid}}{{/courseid}}">
|
||||
|
||||
<div data-region="event-list-content">
|
||||
|
@ -27,6 +27,7 @@
|
||||
data-limit="{{$limit}}20{{/limit}}"
|
||||
data-course-id="{{$courseid}}{{/courseid}}"
|
||||
data-last-id="{{$lastid}}{{/lastid}}"
|
||||
data-midnight="{{midnight}}"
|
||||
id="event-list-container-{{$courseid}}{{/courseid}}">
|
||||
|
||||
<div data-region="event-list-content">
|
||||
|
Loading…
x
Reference in New Issue
Block a user