Commit 52a51514 authored by Damyon Wiese's avatar Damyon Wiese
Browse files

MDL-56683 theme_boost: Popovers on dynamic content

parent cd4a6b8b
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
......@@ -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());
......
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
......@@ -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 {};
});
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment