* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @since 2.9
*/
-define(['core/yui', 'jquery', 'theme_bootstrapbase/bootstrap', 'core/templates', 'core/ajax', 'core/log'],
-function(Y, $, bootstrap, templates, ajax, log) {
+define(['core/yui', 'jquery', 'theme_bootstrapbase/bootstrap', 'core/log'],
+function(Y, $, bootstrap, log) {
var notificationModule = {
types: {
'success': 'core/notification_success',
fieldName: 'user-notifications',
fetchNotifications: function() {
- var promises = ajax.call([{
- methodname: 'core_fetch_notifications',
- args: {
- contextid: notificationModule.contextid
- }
- }]);
-
- promises[0]
- .done(notificationModule.addNotifications)
- ;
-
+ require(['core/ajax'], function(ajax) {
+ var promises = ajax.call([{
+ methodname: 'core_fetch_notifications',
+ args: {
+ contextid: notificationModule.contextid
+ }
+ }]);
+
+ promises[0]
+ .done(notificationModule.addNotifications)
+ ;
+ });
},
addNotifications: function(notifications) {
log.debug('Notification received without content. Skipping.');
return;
}
- templates.render(template, variables)
- .done(function(html) {
- $('#' + notificationModule.fieldName).prepend(html);
- })
- .fail(notificationModule.exception)
- ;
+ require(['core/templates'], function(templates) {
+ templates.render(template, variables)
+ .done(function(html) {
+ $('#' + notificationModule.fieldName).prepend(html);
+ })
+ .fail(notificationModule.exception)
+ ;
+ });
},
alert: function(title, message, yesLabel) {