MDL-57101 media_videojs: Dynamic loader works on self-matching nodes

This commit is contained in:
Frederic Massart 2016-12-01 14:33:58 +08:00
parent 36e6789b27
commit b52c562a8c
No known key found for this signature in database
GPG Key ID: AC343CE142B12FB9
2 changed files with 10 additions and 3 deletions

View File

@ -1 +1 @@
define(["jquery","media_videojs/video"],function(a,b){var c=function(){a(document).on(M.core.event.FILTER_CONTENT_UPDATED,d)},d=function(c,d){d.find(".mediaplugin_videojs audio, .mediaplugin_videojs video").each(function(){var c=a(this).attr("id"),d=a(this).data("setup");b(c,d)})};return{setUp:c}});
define(["jquery","media_videojs/video"],function(a,b){var c=function(){a(document).on(M.core.event.FILTER_CONTENT_UPDATED,d)},d=function(c,d){var e=".mediaplugin_videojs";d.find(e).addBack(e).find("audio, video").each(function(){var c=a(this).attr("id"),d=a(this).data("setup");b(c,d)})};return{setUp:c}});

View File

@ -40,8 +40,15 @@ define(['jquery', 'media_videojs/video'], function($, videojs) {
* @param {NodeList} nodes List of new nodes.
*/
var notifyVideoJS = function(e, nodes) {
nodes.find('.mediaplugin_videojs audio, .mediaplugin_videojs video')
.each(function() {
var selector = '.mediaplugin_videojs';
// Find the descendants matching the expected parent of the audio and video
// tags. Then also addBack the nodes matching the same selector. Finally,
// we find the audio and video tags contained in those parents. Kind thanks
// to jQuery for the simplicity.
nodes.find(selector)
.addBack(selector)
.find('audio, video').each(function() {
var id = $(this).attr('id'),
config = $(this).data('setup');