Skip to content

Commit

Permalink
Merge branch 'MDL-59884-master' of git://github.com/lameze/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
junpataleta committed Aug 30, 2017
2 parents a85c077 + b31a169 commit 9e22016
Show file tree
Hide file tree
Showing 9 changed files with 140 additions and 8 deletions.
2 changes: 1 addition & 1 deletion calendar/amd/build/calendar.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion calendar/amd/build/view_manager.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions calendar/amd/src/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,13 +249,13 @@ define([
var body = $('body');

body.on(CalendarEvents.created, function() {
CalendarViewManager.reloadCurrentMonth();
CalendarViewManager.reloadCurrentMonth(root);
});
body.on(CalendarEvents.deleted, function() {
CalendarViewManager.reloadCurrentMonth();
CalendarViewManager.reloadCurrentMonth(root);
});
body.on(CalendarEvents.updated, function() {
CalendarViewManager.reloadCurrentMonth();
CalendarViewManager.reloadCurrentMonth(root);
});
body.on(CalendarEvents.editActionEvent, function(e, url) {
// Action events needs to be edit directly on the course module.
Expand Down
37 changes: 34 additions & 3 deletions calendar/amd/src/view_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ define(['jquery', 'core/templates', 'core/notification', 'core_calendar/reposito
ROOT: "[data-region='calendar']",
CALENDAR_NAV_LINK: "span.calendarwrapper .arrow_link",
CALENDAR_MONTH_WRAPPER: ".calendarwrapper",
LOADING_ICON_CONTAINER: '[data-region="overlay-icon-container"]'
};

/**
Expand Down Expand Up @@ -55,13 +56,20 @@ define(['jquery', 'core/templates', 'core/notification', 'core_calendar/reposito
* @return {promise}
*/
var refreshMonthContent = function(time, courseid) {
var root = $(SELECTORS.ROOT);

startLoading(root);

return CalendarRepository.getCalendarMonthData(time, courseid)
.then(function(context) {
return Templates.render('core_calendar/month_detailed', context);
})
.then(function(html, js) {
return Templates.replaceNode(SELECTORS.CALENDAR_MONTH_WRAPPER, html, js);
})
.always(function() {
return stopLoading(root);
})
.fail(Notification.exception);
};

Expand Down Expand Up @@ -90,14 +98,37 @@ define(['jquery', 'core/templates', 'core/notification', 'core_calendar/reposito
*
* @return {promise}
*/
var reloadCurrentMonth = function() {
var root = $(SELECTORS.ROOT),
courseid = root.find(SELECTORS.CALENDAR_MONTH_WRAPPER).data('courseid'),
var reloadCurrentMonth = function(root) {
var courseid = root.find(SELECTORS.CALENDAR_MONTH_WRAPPER).data('courseid'),
time = root.find(SELECTORS.CALENDAR_MONTH_WRAPPER).data('current-time');

return refreshMonthContent(time, courseid);
};

/**
* Set the element state to loading.
*
* @param {object} root The container element
* @method startLoading
*/
var startLoading = function(root) {
var loadingIconContainer = root.find(SELECTORS.LOADING_ICON_CONTAINER);

loadingIconContainer.removeClass('hidden');
};

/**
* Remove the loading state from the element.
*
* @param {object} root The container element
* @method stopLoading
*/
var stopLoading = function(root) {
var loadingIconContainer = root.find(SELECTORS.LOADING_ICON_CONTAINER);

loadingIconContainer.addClass('hidden');
};

return {
init: function() {
registerEventListeners(SELECTORS.ROOT);
Expand Down
1 change: 1 addition & 0 deletions calendar/templates/month_detailed.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<div id="month-detailed-{{uniqid}}" class="calendarwrapper" data-courseid="{{courseid}}" data-current-time="{{time}}">
{{> core_calendar/month_header }}
{{> core_calendar/month_navigation }}
{{> core/overlay_loading}}
<table class="calendarmonth calendartable card-deck m-b-0">
<thead>
<tr>
Expand Down
38 changes: 38 additions & 0 deletions lib/templates/overlay_loading.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{{!
This file is part of Moodle - http://moodle.org/
Moodle is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Moodle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
@template core/overlay_loading
Moodle overlay loading template.
The purpose of this template is to render a loading animation using a overlay effect.
Classes required for JS:
* none
Data attributes required for JS:
* none
Context variables required for this template:
*
Example context (json):
{}
}}
<span class="overlay-icon-container hidden" data-region="overlay-icon-container">
{{> core/loading }}
</span>
22 changes: 22 additions & 0 deletions theme/boost/scss/moodle/core.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2159,3 +2159,25 @@ $footer-link-color: $bg-inverse-link-color !default;
.clickable {
cursor: pointer;
}

.overlay-icon-container {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(255, 255, 255, 0.6);

.loading-icon {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);

.icon {
height: 40px;
width: 40px;

}
}
}
22 changes: 22 additions & 0 deletions theme/bootstrapbase/less/moodle/core.less
Original file line number Diff line number Diff line change
Expand Up @@ -2385,3 +2385,25 @@ h3.sectionname .inplaceeditable.inplaceeditingon .editinstructions {
.clickable {
cursor: pointer;
}

.overlay-icon-container {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(255, 255, 255, 0.6);

.loading-icon {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);

.icon {
height: 40px;
width: 40px;

}
}
}
18 changes: 18 additions & 0 deletions theme/bootstrapbase/style/moodle.css
Original file line number Diff line number Diff line change
Expand Up @@ -4777,6 +4777,24 @@ h3.sectionname .inplaceeditable.inplaceeditingon .editinstructions {
.clickable {
cursor: pointer;
}
.overlay-icon-container {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(255, 255, 255, 0.6);
}
.overlay-icon-container .loading-icon {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.overlay-icon-container .loading-icon .icon {
height: 40px;
width: 40px;
}
/* admin.less */
.formtable tbody th {
font-weight: normal;
Expand Down

0 comments on commit 9e22016

Please sign in to comment.