Mercurial > hg > cmmr2012-drupal-site
comparison 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 |
comparison
equal
deleted
inserted
replaced
4:a9cd425dd02b | 5:12f9dff5fda9 |
---|---|
4 * https://www.drupal.org/node/2815083 | 4 * https://www.drupal.org/node/2815083 |
5 * @preserve | 5 * @preserve |
6 **/ | 6 **/ |
7 | 7 |
8 (function ($, Drupal) { | 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 = { | 9 Drupal.behaviors.MediaLibrarySelectAll = { |
32 attach: function attach(context) { | 10 attach: function attach(context) { |
33 var $view = $('.media-library-view', context).once('media-library-select-all'); | 11 var $view = $('.js-media-library-view', context).once('media-library-select-all'); |
34 if ($view.length && $view.find('.media-library-item').length) { | 12 if ($view.length && $view.find('.js-media-library-item').length) { |
35 var $checkbox = $('<input type="checkbox" class="form-checkbox" />').on('click', function (_ref3) { | 13 var $checkbox = $('<input type="checkbox" class="form-checkbox" />').on('click', function (_ref) { |
36 var currentTarget = _ref3.currentTarget; | 14 var currentTarget = _ref.currentTarget; |
37 | 15 |
38 var $checkboxes = $(currentTarget).closest('.media-library-view').find('.media-library-item input[type="checkbox"]'); | 16 var $checkboxes = $(currentTarget).closest('.media-library-view').find('.js-media-library-item input[type="checkbox"]'); |
39 $checkboxes.prop('checked', $(currentTarget).prop('checked')).trigger('change'); | 17 $checkboxes.prop('checked', $(currentTarget).prop('checked')).trigger('change'); |
40 | 18 |
41 var announcement = $(currentTarget).prop('checked') ? Drupal.t('Zero items selected') : Drupal.t('All @count items selected', { | 19 var announcement = $(currentTarget).prop('checked') ? Drupal.t('Zero items selected') : Drupal.t('All @count items selected', { |
42 '@count': $checkboxes.length | 20 '@count': $checkboxes.length |
43 }); | 21 }); |
44 Drupal.announce(announcement); | 22 Drupal.announce(announcement); |
45 }); | 23 }); |
46 var $label = $('<label class="media-library-select-all"></label>').text(Drupal.t('Select all media')); | 24 var $label = $('<label class="media-library-select-all"></label>').text(Drupal.t('Select all media')); |
47 $label.prepend($checkbox); | 25 $label.prepend($checkbox); |
48 $view.find('.media-library-item').first().before($label); | 26 $view.find('.js-media-library-item').first().before($label); |
49 } | 27 } |
50 } | 28 } |
51 }; | 29 }; |
52 })(jQuery, Drupal); | 30 })(jQuery, Drupal); |