drupal/core/themes/claro/js/media-library.ui.js

46 lines
1.5 KiB
JavaScript

/**
* DO NOT EDIT THIS FILE.
* See the following change record for more information,
* https://www.drupal.org/node/2815083
* @preserve
**/
(function ($, Drupal, window) {
Drupal.behaviors.MediaLibraryItemSelectionClaro = {
attach: function attach() {
$(window).once('media-library-selection-info-claro-event').on('dialog:aftercreate', function (event, dialog, $element, settings) {
var moveCounter = function moveCounter($selectedCount, $buttonPane) {
var $moveSelectedCount = $selectedCount.detach();
$buttonPane.prepend($moveSelectedCount);
};
var $buttonPane = $element.closest('.media-library-widget-modal').find('.ui-dialog-buttonpane');
if (!$buttonPane.length) {
return;
}
var $selectedCount = $buttonPane.find('.js-media-library-selected-count');
if ($selectedCount.length) {
moveCounter($selectedCount, $buttonPane);
} else {
var selectedCountObserver = new MutationObserver(function () {
var $selectedCountFind = $buttonPane.find('.js-media-library-selected-count');
if ($selectedCountFind.length) {
moveCounter($selectedCountFind, $buttonPane);
selectedCountObserver.disconnect();
}
});
selectedCountObserver.observe($buttonPane[0], {
attributes: false,
childList: true,
characterData: false,
subtree: true
});
}
});
}
};
})(jQuery, Drupal, window);