Merge branch 'MDL-59515' of https://github.com/NeillM/moodle
authorDan Poltawski <dan@moodle.com>
Mon, 17 Jul 2017 08:42:27 +0000 (09:42 +0100)
committerDan Poltawski <dan@moodle.com>
Mon, 17 Jul 2017 08:42:27 +0000 (09:42 +0100)
message/output/popup/amd/build/message_popover_controller.min.js
message/output/popup/amd/build/notification_area_control_area.min.js
message/output/popup/amd/build/notification_popover_controller.min.js
message/output/popup/amd/src/message_popover_controller.js
message/output/popup/amd/src/notification_area_control_area.js
message/output/popup/amd/src/notification_popover_controller.js

index 313d911..dd61230 100644 (file)
Binary files a/message/output/popup/amd/build/message_popover_controller.min.js and b/message/output/popup/amd/build/message_popover_controller.min.js differ
index 0361c24..f9b3794 100644 (file)
Binary files a/message/output/popup/amd/build/notification_area_control_area.min.js and b/message/output/popup/amd/build/notification_area_control_area.min.js differ
index dadaa7f..d0fadcf 100644 (file)
Binary files a/message/output/popup/amd/build/notification_popover_controller.min.js and b/message/output/popup/amd/build/notification_popover_controller.min.js differ
index 5699698..d731c0f 100644 (file)
@@ -176,16 +176,23 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str',
                 id: message.userid,
             });
 
-            var promise = Templates.render('message_popup/message_content_item', message)
-            .then(function(html, js) {
-                container.append(html);
-                Templates.runTemplateJS(js);
-                return;
-            });
+            var promise = Templates.render('message_popup/message_content_item', message);
             promises.push(promise);
         }.bind(this));
 
-        return $.when.apply($, promises);
+        return $.when.apply($, promises).then(function() {
+            // Each of the promises in the when will pass its results as an argument to the function.
+            // The order of the arguments will be the order that the promises are passed to when()
+            // i.e. the first promise's results will be in the first argument.
+            $.each(arguments, function(index, argument) {
+                // The promises will return an array containing two values.
+                // The first value is the html that should be attached to the page.
+                // The second will be any JavaScript that needs to be run.
+                container.append(argument[0]);
+                Templates.runTemplateJS(argument[1]);
+            });
+            return;
+        });
     };
 
     /**
index 5feea45..ac94b17 100644 (file)
@@ -317,17 +317,28 @@ define(['jquery', 'core/templates', 'core/notification', 'core/custom_interactio
 
             var promise = Templates.render(TEMPLATES.NOTIFICATION, notification)
             .then(function(html, js) {
-                container.append(html);
-                Templates.runTemplateJS(js);
                 // Restore it for the cache.
                 notification.contexturl = contextUrl;
                 this.setCacheNotification(notification);
-                return;
+                // Pass the Rendered content out.
+                return [html, js];
             }.bind(this));
             promises.push(promise);
         }.bind(this));
 
-        return $.when.apply($, promises);
+        return $.when.apply($, promises).then(function() {
+            // Each of the promises in the when will pass its results as an argument to the function.
+            // The order of the arguments will be the order that the promises are passed to when()
+            // i.e. the first promise's results will be in the first argument.
+            $.each(arguments, function(index, argument) {
+                // The promises will return an array containing two values.
+                // The first value is the html that should be attached to the page.
+                // The second will be any JavaScript that needs to be run.
+                container.append(argument[0]);
+                Templates.runTemplateJS(argument[1]);
+            });
+            return;
+        });
     };
 
     /**
index 2d5a2c4..7507d9c 100644 (file)
@@ -237,16 +237,23 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/str', 'core/url',
                 offset: offset,
             });
 
-            var promise = Templates.render('message_popup/notification_content_item', notification)
-            .then(function(html, js) {
-                container.append(html);
-                Templates.runTemplateJS(js);
-                return;
-            });
+            var promise = Templates.render('message_popup/notification_content_item', notification);
             promises.push(promise);
         }.bind(this));
 
-        return $.when.apply($, promises);
+        return $.when.apply($, promises).then(function() {
+            // Each of the promises in the when will pass its results as an argument to the function.
+            // The order of the arguments will be the order that the promises are passed to when()
+            // i.e. the first promise's results will be in the first argument.
+            $.each(arguments, function(index, argument) {
+                // The promises will return an array containing two values.
+                // The first value is the html that should be attached to the page.
+                // The second will be any JavaScript that needs to be run.
+                container.append(argument[0]);
+                Templates.runTemplateJS(argument[1]);
+            });
+            return;
+        });
     };
 
     /**