diff --git a/lib/amd/build/event.min.js b/lib/amd/build/event.min.js index 5f05de6aeec..310efb4ee96 100644 --- a/lib/amd/build/event.min.js +++ b/lib/amd/build/event.min.js @@ -1 +1 @@ -define(["jquery","core/yui"],function(a,b){return{Events:{FORM_FIELD_VALIDATION:"core_form-field-validation"},notifyFilterContentUpdated:function(c){c=a(c),b.use("event","moodle-core-event",function(b){a(document).trigger(M.core.event.FILTER_CONTENT_UPDATED,c);var d=new b.NodeList(c.get());b.fire(M.core.event.FILTER_CONTENT_UPDATED,{nodes:d})})},notifyEditorContentRestored:function(){b.use("event","moodle-core-event",function(b){a(document).trigger(M.core.event.EDITOR_CONTENT_RESTORED),b.fire(M.core.event.EDITOR_CONTENT_RESTORED)})}}}); \ No newline at end of file +define(["jquery","core/yui"],function(a,b){return{Events:{FORM_FIELD_VALIDATION:"core_form-field-validation"},getLegacyEvents:function(){var c=a.Deferred();return b.use("event","moodle-core-event",function(){c.resolve(window.M.core.event)}),c.promise()},notifyFilterContentUpdated:function(c){c=a(c),b.use("event","moodle-core-event",function(b){a(document).trigger(M.core.event.FILTER_CONTENT_UPDATED,[c]);var d=new b.NodeList(c.get());b.fire(M.core.event.FILTER_CONTENT_UPDATED,{nodes:d})})},notifyEditorContentRestored:function(){b.use("event","moodle-core-event",function(b){a(document).trigger(M.core.event.EDITOR_CONTENT_RESTORED),b.fire(M.core.event.EDITOR_CONTENT_RESTORED)})}}}); \ No newline at end of file diff --git a/lib/amd/src/event.js b/lib/amd/src/event.js index 568f4df3aa6..c67b5dd3209 100644 --- a/lib/amd/src/event.js +++ b/lib/amd/src/event.js @@ -35,6 +35,20 @@ define(['jquery', 'core/yui'], FORM_FIELD_VALIDATION: "core_form-field-validation" }, + /** + * Load the legacy YUI module which defines events in M.core.event and return it. + * + * @method getLegacyEvents + * @return {Promise} + */ + getLegacyEvents: function() { + var result = $.Deferred(); + Y.use('event', 'moodle-core-event', function() { + result.resolve(window.M.core.event); + }); + return result.promise(); + }, + /** * Trigger an event using both JQuery and YUI * @@ -45,7 +59,7 @@ define(['jquery', 'core/yui'], nodes = $(nodes); Y.use('event', 'moodle-core-event', function(Y) { // Trigger it the JQuery way. - $(document).trigger(M.core.event.FILTER_CONTENT_UPDATED, nodes); + $(document).trigger(M.core.event.FILTER_CONTENT_UPDATED, [nodes]); // Create a YUI NodeList from our JQuery Object. var yuiNodes = new Y.NodeList(nodes.get()); diff --git a/theme/boost/amd/build/loader.min.js b/theme/boost/amd/build/loader.min.js index d3adac7e361..a4885a44fbd 100644 --- a/theme/boost/amd/build/loader.min.js +++ b/theme/boost/amd/build/loader.min.js @@ -1 +1 @@ -define(["jquery","./tether"],function(a,b){return window.jQuery=a,window.Tether=b,require(["theme_boost/util","theme_boost/alert","theme_boost/button","theme_boost/carousel","theme_boost/collapse","theme_boost/dropdown","theme_boost/modal","theme_boost/scrollspy","theme_boost/tab","theme_boost/tooltip","theme_boost/popover"],function(){a("body").popover({selector:'[data-toggle="popover"]',trigger:"focus"})}),{}}); \ No newline at end of file +define(["jquery","./tether","core/event"],function(a,b,c){return window.jQuery=a,window.Tether=b,require(["theme_boost/util","theme_boost/alert","theme_boost/button","theme_boost/carousel","theme_boost/collapse","theme_boost/dropdown","theme_boost/modal","theme_boost/scrollspy","theme_boost/tab","theme_boost/tooltip","theme_boost/popover"],function(){a("body").popover({selector:'[data-toggle="popover"]',trigger:"focus"}),c.getLegacyEvents().done(function(b){a(document).on(b.FILTER_CONTENT_UPDATED,function(){a("body").popover({selector:'[data-toggle="popover"]',trigger:"focus"})})})}),{}}); \ No newline at end of file diff --git a/theme/boost/amd/src/loader.js b/theme/boost/amd/src/loader.js index cf908f83427..ac95dea3560 100644 --- a/theme/boost/amd/src/loader.js +++ b/theme/boost/amd/src/loader.js @@ -23,7 +23,7 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @since 2.9 */ -define(['jquery', './tether'], function(jQuery, Tether) { +define(['jquery', './tether', 'core/event'], function(jQuery, Tether, Event) { window.jQuery = jQuery; window.Tether = Tether; @@ -40,11 +40,23 @@ define(['jquery', './tether'], function(jQuery, Tether) { 'theme_boost/tooltip', 'theme_boost/popover'], function() { + + jQuery('body').popover({ + selector: '[data-toggle="popover"]', + trigger: 'focus' + }); + + // We need to call popover automatically if nodes are added to the page later. + Event.getLegacyEvents().done(function(events) { + jQuery(document).on(events.FILTER_CONTENT_UPDATED, function() { jQuery('body').popover({ selector: '[data-toggle="popover"]', trigger: 'focus' }); + }); + }); }); + return {}; });