Further Drupal 8.6.4 changes. Some core files were not committed before a commit...
[yaffs-website] / web / core / modules / media_library / js / media_library.view.js
1 /**
2 * DO NOT EDIT THIS FILE.
3 * See the following change record for more information,
4 * https://www.drupal.org/node/2815083
5 * @preserve
6 **/
7
8 (function ($, Drupal) {
9   Drupal.behaviors.MediaLibraryHover = {
10     attach: function attach(context) {
11       $('.media-library-item .js-click-to-select-trigger,.media-library-item .js-click-to-select-checkbox', context).once('media-library-item-hover').on('mouseover mouseout', function (_ref) {
12         var currentTarget = _ref.currentTarget,
13             type = _ref.type;
14
15         $(currentTarget).closest('.media-library-item').toggleClass('is-hover', type === 'mouseover');
16       });
17     }
18   };
19
20   Drupal.behaviors.MediaLibraryFocus = {
21     attach: function attach(context) {
22       $('.media-library-item .js-click-to-select-checkbox input', context).once('media-library-item-focus').on('focus blur', function (_ref2) {
23         var currentTarget = _ref2.currentTarget,
24             type = _ref2.type;
25
26         $(currentTarget).closest('.media-library-item').toggleClass('is-focus', type === 'focus');
27       });
28     }
29   };
30
31   Drupal.behaviors.MediaLibrarySelectAll = {
32     attach: function attach(context) {
33       var $view = $('.media-library-view', context).once('media-library-select-all');
34       if ($view.length && $view.find('.media-library-item').length) {
35         var $checkbox = $('<input type="checkbox" class="form-checkbox" />').on('click', function (_ref3) {
36           var currentTarget = _ref3.currentTarget;
37
38           var $checkboxes = $(currentTarget).closest('.media-library-view').find('.media-library-item input[type="checkbox"]');
39           $checkboxes.prop('checked', $(currentTarget).prop('checked')).trigger('change');
40
41           var announcement = $(currentTarget).prop('checked') ? Drupal.t('Zero items selected') : Drupal.t('All @count items selected', {
42             '@count': $checkboxes.length
43           });
44           Drupal.announce(announcement);
45         });
46         var $label = $('<label class="media-library-select-all"></label>').text(Drupal.t('Select all media'));
47         $label.prepend($checkbox);
48         $view.find('.media-library-item').first().before($label);
49       }
50     }
51   };
52 })(jQuery, Drupal);