MDL-30811 javascript: alert JS should be in template
authorAndrew Nicols <andrew@nicols.co.uk>
Thu, 3 Mar 2016 06:37:40 +0000 (14:37 +0800)
committerAndrew Nicols <andrew@nicols.co.uk>
Thu, 3 Mar 2016 07:09:17 +0000 (15:09 +0800)
By moving the JS required for an alert to the JavaScript we make it
possible for themers to use frameworks other than bootstrap if they so
wish.

lib/amd/build/notification.min.js
lib/amd/src/notification.js
lib/templates/notification_error.mustache
lib/templates/notification_info.mustache
lib/templates/notification_success.mustache
lib/templates/notification_warning.mustache

index d6b1ee7..f03cbbb 100644 (file)
Binary files a/lib/amd/build/notification.min.js and b/lib/amd/build/notification.min.js differ
index bb8cdb4..da34f43 100644 (file)
@@ -26,8 +26,8 @@
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  * @since      2.9
  */
-define(['core/yui', 'jquery', 'theme_bootstrapbase/bootstrap', 'core/log'],
-function(Y, $, bootstrap, log) {
+define(['core/yui', 'jquery', 'core/log'],
+function(Y, $, log) {
     var notificationModule = {
         types: {
             'success':  'core/notification_success',
@@ -114,8 +114,9 @@ function(Y, $, bootstrap, log) {
             }
             require(['core/templates'], function(templates) {
                 templates.render(template, variables)
-                    .done(function(html) {
+                    .done(function(html, js) {
                         $('#' + notificationModule.fieldName).prepend(html);
+                        templates.runTemplateJS(js);
                     })
                     .fail(notificationModule.exception)
                     ;
@@ -178,9 +179,6 @@ function(Y, $, bootstrap, log) {
             // Setup the message target region if it isn't setup already
             notificationModule.setupTargetRegion();
 
-            // Setup closing of bootstrap alerts.
-            $().alert();
-
             // Add provided notifications.
             notificationModule.addNotifications(notifications);
 
index 0e7a8c8..8eb9884 100644 (file)
@@ -42,3 +42,9 @@
     {{# closebutton }}<button type="button" class="close" data-dismiss="alert">&times;</button>{{/ closebutton }}
     {{{ message }}}
 </div>
+{{# js }}
+require(['jquery', 'theme_bootstrapbase/bootstrap'], function($) {
+    // Setup closing of bootstrap alerts.
+    $().alert();
+});
+{{/ js }}
index 39cd151..4a59649 100644 (file)
@@ -42,3 +42,9 @@
     {{# closebutton }}<button type="button" class="close" data-dismiss="alert">&times;</button>{{/ closebutton }}
     {{{ message }}}
 </div>
+{{# js }}
+require(['jquery', 'theme_bootstrapbase/bootstrap'], function($) {
+    // Setup closing of bootstrap alerts.
+    $().alert();
+});
+{{/ js }}
index 65b7e48..150fc3f 100644 (file)
@@ -42,3 +42,9 @@
     {{# closebutton }}<button type="button" class="close" data-dismiss="alert">&times;</button>{{/ closebutton }}
     {{{ message }}}
 </div>
+{{# js }}
+require(['jquery', 'theme_bootstrapbase/bootstrap'], function($) {
+    // Setup closing of bootstrap alerts.
+    $().alert();
+});
+{{/ js }}
index b359d83..c5c9944 100644 (file)
@@ -42,3 +42,9 @@
     {{# closebutton }}<button type="button" class="close" data-dismiss="alert">&times;</button>{{/ closebutton }}
     {{{ message }}}
 </div>
+{{# js }}
+require(['jquery', 'theme_bootstrapbase/bootstrap'], function($) {
+    // Setup closing of bootstrap alerts.
+    $().alert();
+});
+{{/ js }}