Merge branch 'MDL-68833-master' of git://github.com/andrewnicols/moodle
authorSara Arjona <sara@moodle.com>
Wed, 3 Jun 2020 15:57:57 +0000 (17:57 +0200)
committerSara Arjona <sara@moodle.com>
Wed, 3 Jun 2020 15:57:57 +0000 (17:57 +0200)
12 files changed:
theme/boost/amd/build/loader.min.js
theme/boost/amd/build/loader.min.js.map
theme/boost/amd/build/pending.min.js
theme/boost/amd/build/pending.min.js.map
theme/boost/amd/src/loader.js
theme/boost/amd/src/pending.js
theme/boost/templates/columns1.mustache
theme/boost/templates/columns2.mustache
theme/boost/templates/secure.mustache
theme/classic/templates/columns.mustache
theme/classic/templates/contentonly.mustache
theme/classic/templates/secure.mustache

index ca24dd7..baacba5 100644 (file)
Binary files a/theme/boost/amd/build/loader.min.js and b/theme/boost/amd/build/loader.min.js differ
index bf9bf8d..bcde39c 100644 (file)
Binary files a/theme/boost/amd/build/loader.min.js.map and b/theme/boost/amd/build/loader.min.js.map differ
index d231b81..3630be6 100644 (file)
Binary files a/theme/boost/amd/build/pending.min.js and b/theme/boost/amd/build/pending.min.js differ
index 74549e2..09b04e7 100644 (file)
Binary files a/theme/boost/amd/build/pending.min.js.map and b/theme/boost/amd/build/pending.min.js.map differ
index 6d5f9d8..a050c6f 100644 (file)
 
 import $ from 'jquery';
 import Aria from './aria';
-import Scroll from './scroll';
 import Bootstrap from './bootstrap/index';
-import CustomEvents from 'core/custom_interaction_events';
-
-/**
- * Set up the search.
- *
- * @method init
- */
-export {
-    init,
-    Bootstrap
-};
-
-/**
- * Bootstrap init function
- */
-const init = () => {
-    rememberTabs();
-
-    enablePopovers();
-
-    enableTooltips();
-
-    const scroll = new Scroll();
-    scroll.init();
-
-    // Disables flipping the dropdowns up and getting hidden behind the navbar.
-    $.fn.dropdown.Constructor.Default.flip = false;
-
-    Aria.init();
-};
+import Pending from 'core/pending';
+import Scroll from './scroll';
+import setupBootstrapPendingChecks from './pending';
 
 /**
  * Rember the last visited tabs.
@@ -83,17 +55,15 @@ const rememberTabs = () => {
  */
 const enablePopovers = () => {
     $('body').popover({
+        container: 'body',
         selector: '[data-toggle="popover"]',
-        trigger: 'focus hover',
-        placement: 'auto'
+        trigger: 'focus',
     });
 
-    CustomEvents.define($('body'), [
-        CustomEvents.events.escape,
-    ]);
-    $('body').on(CustomEvents.events.escape, '[data-toggle=popover]', function() {
-
-        $(this).trigger('blur');
+    document.addEventListener('keydown', e => {
+        if (e.key === 'Escape' && e.target.closest('[data-toggle="popover"]')) {
+            $(e.target).popover('hide');
+        }
     });
 };
 
@@ -104,6 +74,35 @@ const enablePopovers = () => {
 const enableTooltips = () => {
     $('body').tooltip({
         container: 'body',
-        selector: '[data-toggle="tooltip"]'
+        selector: '[data-toggle="tooltip"]',
     });
-};
\ No newline at end of file
+};
+
+const pendingPromise = new Pending('theme_boost/loader:init');
+
+// Add pending promise event listeners to relevant Bootstrap custom events.
+setupBootstrapPendingChecks();
+
+// Remember the last visited tabs.
+rememberTabs();
+
+// Enable all popovers.
+enablePopovers();
+
+// Enable all tooltips.
+enableTooltips();
+
+// Add scroll handling.
+(new Scroll()).init();
+
+// Disables flipping the dropdowns up and getting hidden behind the navbar.
+$.fn.dropdown.Constructor.Default.flip = false;
+
+// Setup Aria helpers for Bootstrap features.
+Aria.init();
+
+pendingPromise.resolve();
+
+export {
+    Bootstrap,
+};
index 2e25c81..4b3a548 100644 (file)
  * @copyright  2019 Andrew Nicols <andrew@nicols.co.uk>
  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  */
-define(['jquery'], function($) {
-    var moduleTransitions = {
-        alert: [
-            // Alert.
-            {
-                start: 'close',
-                end: 'closed',
-            },
-        ],
 
-        carousel: [
-            {
-                start: 'slide',
-                end: 'slid',
-            },
-        ],
+import jQuery from 'jquery';
+const moduleTransitions = {
+    alert: [
+        // Alert.
+        {
+            start: 'close',
+            end: 'closed',
+        },
+    ],
 
-        collapse: [
-            {
-                start: 'hide',
-                end: 'hidden',
-            },
-            {
-                start: 'show',
-                end: 'shown',
-            },
-        ],
+    carousel: [
+        {
+            start: 'slide',
+            end: 'slid',
+        },
+    ],
 
-        dropdown: [
-            {
-                start: 'hide',
-                end: 'hidden',
-            },
-            {
-                start: 'show',
-                end: 'shown',
-            },
-        ],
+    collapse: [
+        {
+            start: 'hide',
+            end: 'hidden',
+        },
+        {
+            start: 'show',
+            end: 'shown',
+        },
+    ],
 
-        modal: [
-            {
-                start: 'hide',
-                end: 'hidden',
-            },
-            {
-                start: 'show',
-                end: 'shown',
-            },
-        ],
+    dropdown: [
+        {
+            start: 'hide',
+            end: 'hidden',
+        },
+        {
+            start: 'show',
+            end: 'shown',
+        },
+    ],
 
-        popover: [
-            {
-                start: 'hide',
-                end: 'hidden',
-            },
-            {
-                start: 'show',
-                end: 'shown',
-            },
-        ],
+    modal: [
+        {
+            start: 'hide',
+            end: 'hidden',
+        },
+        {
+            start: 'show',
+            end: 'shown',
+        },
+    ],
 
-        tab: [
-            {
-                start: 'hide',
-                end: 'hidden',
-            },
-            {
-                start: 'show',
-                end: 'shown',
-            },
-        ],
+    popover: [
+        {
+            start: 'hide',
+            end: 'hidden',
+        },
+        {
+            start: 'show',
+            end: 'shown',
+        },
+    ],
 
-        toast: [
-            {
-                start: 'hide',
-                end: 'hidden',
-            },
-            {
-                start: 'show',
-                end: 'shown',
-            },
-        ],
+    tab: [
+        {
+            start: 'hide',
+            end: 'hidden',
+        },
+        {
+            start: 'show',
+            end: 'shown',
+        },
+    ],
 
-        tooltip: [
-            {
-                start: 'hide',
-                end: 'hidden',
-            },
-            {
-                start: 'show',
-                end: 'shown',
-            },
-        ],
-    };
+    toast: [
+        {
+            start: 'hide',
+            end: 'hidden',
+        },
+        {
+            start: 'show',
+            end: 'shown',
+        },
+    ],
 
-    Object.keys(moduleTransitions).forEach(function(key) {
-        moduleTransitions[key].forEach(function(pair) {
-            var eventStart = pair.start + '.bs.' + key;
-            var eventEnd = pair.end + '.bs.' + key;
-            $(document.body).on(eventStart, function() {
+    tooltip: [
+        {
+            start: 'hide',
+            end: 'hidden',
+        },
+        {
+            start: 'show',
+            end: 'shown',
+        },
+    ],
+};
+
+export default () => {
+    Object.entries(moduleTransitions).forEach(([key, pairs]) => {
+        pairs.forEach(pair => {
+            const eventStart = `${pair.start}.bs.${key}`;
+            const eventEnd = `${pair.end}.bs.${key}`;
+            jQuery(document.body).on(eventStart, () => {
                 M.util.js_pending(eventEnd);
             });
 
-            $(document.body).on(eventEnd, function() {
+            jQuery(document.body).on(eventEnd, () => {
                 M.util.js_complete(eventEnd);
             });
         });
     });
-});
+};
index 08a0a12..51fb23e 100644 (file)
@@ -64,8 +64,9 @@
 {{{ output.standard_end_of_body_html }}}
 </body>
 </html>
+{{#js}}
 M.util.js_pending('theme_boost/loader');
-require(['theme_boost/loader'], function(loader) {
-    loader.init();
+require(['theme_boost/loader'], function() {
     M.util.js_complete('theme_boost/loader');
 });
+{{/js}}
index fcb9b2c..5feab1c 100644 (file)
@@ -97,8 +97,7 @@
 </html>
 {{#js}}
 M.util.js_pending('theme_boost/loader');
-require(['theme_boost/loader'], function(loader) {
-    loader.init();
+require(['theme_boost/loader'], function() {
     M.util.js_complete('theme_boost/loader');
 });
 
index 9d8b289..c4ccb98 100644 (file)
@@ -87,8 +87,9 @@
 
 </body>
 </html>
+{{#js}}
 M.util.js_pending('theme_boost/loader');
-require(['theme_boost/loader'], function(loader) {
-    loader.init();
+require(['theme_boost/loader'], function() {
     M.util.js_complete('theme_boost/loader');
 });
+{{/js}}
index 1ae3fc6..787b41f 100644 (file)
@@ -97,8 +97,7 @@
 </html>
 {{#js}}
 M.util.js_pending('theme_boost/loader');
-require(['theme_boost/loader'], function(loader) {
-    loader.init();
+require(['theme_boost/loader'], function() {
     M.util.js_complete('theme_boost/loader');
 });
 {{/js}}
index 4d8ca86..cb5d9c2 100644 (file)
@@ -69,8 +69,7 @@
 </html>
 {{#js}}
 M.util.js_pending('theme_boost/loader');
-require(['theme_boost/loader'], function(loader) {
-    loader.init();
+require(['theme_boost/loader'], function() {
     M.util.js_complete('theme_boost/loader');
 });
 {{/js}}
index 1d06183..b237592 100644 (file)
 </html>
 {{#js}}
 M.util.js_pending('theme_boost/loader');
-require(['theme_boost/loader'], function(loader) {
-    loader.init();
+require(['theme_boost/loader'], function() {
     M.util.js_complete('theme_boost/loader');
 });
 {{/js}}