annotate core/modules/media_library/js/media_library.widget.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.MediaLibraryWidgetSortable = {
Chris@4 10 attach: function attach(context) {
Chris@4 11 $('.js-media-library-selection', context).once('media-library-sortable').sortable({
Chris@4 12 tolerance: 'pointer',
Chris@4 13 helper: 'clone',
Chris@4 14 handle: '.js-media-library-item-preview',
Chris@4 15 stop: function stop(_ref) {
Chris@4 16 var target = _ref.target;
Chris@4 17
Chris@4 18 $(target).children().each(function (index, child) {
Chris@4 19 $(child).find('.js-media-library-item-weight').val(index);
Chris@4 20 });
Chris@4 21 }
Chris@4 22 });
Chris@4 23 }
Chris@4 24 };
Chris@4 25
Chris@4 26 Drupal.behaviors.MediaLibraryWidgetToggleWeight = {
Chris@4 27 attach: function attach(context) {
Chris@4 28 var strings = {
Chris@4 29 show: Drupal.t('Show media item weights'),
Chris@4 30 hide: Drupal.t('Hide media item weights')
Chris@4 31 };
Chris@4 32 $('.js-media-library-widget-toggle-weight', context).once('media-library-toggle').on('click', function (e) {
Chris@4 33 e.preventDefault();
Chris@4 34 $(e.currentTarget).toggleClass('active').text($(e.currentTarget).hasClass('active') ? strings.hide : strings.show).parent().find('.js-media-library-item-weight').parent().toggle();
Chris@4 35 }).text(strings.show);
Chris@4 36 $('.js-media-library-item-weight', context).once('media-library-toggle').parent().hide();
Chris@4 37 }
Chris@4 38 };
Chris@4 39
Chris@5 40 Drupal.behaviors.MediaLibraryWidgetDisableButton = {
Chris@4 41 attach: function attach(context) {
Chris@5 42 $('.js-media-library-open-button[data-disabled-focus="true"]', context).once('media-library-disable').each(function () {
Chris@5 43 var _this = this;
Chris@4 44
Chris@5 45 $(this).focus();
Chris@5 46
Chris@5 47 setTimeout(function () {
Chris@5 48 $(_this).attr('disabled', 'disabled');
Chris@5 49 }, 50);
Chris@4 50 });
Chris@4 51 }
Chris@4 52 };
Chris@4 53 })(jQuery, Drupal);