annotate core/modules/media_library/js/media_library.view.js @ 5:12f9dff5fda9 tip

Update to Drupal core 8.7.1
author Chris Cannam
date Thu, 09 May 2019 15:34:47 +0100
parents a9cd425dd02b
children
rev   line source
Chris@4 1 /**
Chris@4 2 * DO NOT EDIT THIS FILE.
Chris@4 3 * See the following change record for more information,
Chris@4 4 * https://www.drupal.org/node/2815083
Chris@4 5 * @preserve
Chris@4 6 **/
Chris@4 7
Chris@4 8 (function ($, Drupal) {
Chris@4 9 Drupal.behaviors.MediaLibrarySelectAll = {
Chris@4 10 attach: function attach(context) {
Chris@5 11 var $view = $('.js-media-library-view', context).once('media-library-select-all');
Chris@5 12 if ($view.length && $view.find('.js-media-library-item').length) {
Chris@5 13 var $checkbox = $('<input type="checkbox" class="form-checkbox" />').on('click', function (_ref) {
Chris@5 14 var currentTarget = _ref.currentTarget;
Chris@4 15
Chris@5 16 var $checkboxes = $(currentTarget).closest('.media-library-view').find('.js-media-library-item input[type="checkbox"]');
Chris@4 17 $checkboxes.prop('checked', $(currentTarget).prop('checked')).trigger('change');
Chris@4 18
Chris@4 19 var announcement = $(currentTarget).prop('checked') ? Drupal.t('Zero items selected') : Drupal.t('All @count items selected', {
Chris@4 20 '@count': $checkboxes.length
Chris@4 21 });
Chris@4 22 Drupal.announce(announcement);
Chris@4 23 });
Chris@4 24 var $label = $('<label class="media-library-select-all"></label>').text(Drupal.t('Select all media'));
Chris@4 25 $label.prepend($checkbox);
Chris@5 26 $view.find('.js-media-library-item').first().before($label);
Chris@4 27 }
Chris@4 28 }
Chris@4 29 };
Chris@4 30 })(jQuery, Drupal);