Update Composer, update everything
This commit is contained in:
parent
ea3e94409f
commit
dda5c284b6
19527 changed files with 1135420 additions and 351004 deletions
|
@ -0,0 +1,31 @@
|
|||
/**
|
||||
* @file media_library.click_to_select.es6.js
|
||||
*/
|
||||
|
||||
(($, Drupal) => {
|
||||
/**
|
||||
* Allows users to select an element which checks a hidden checkbox.
|
||||
*/
|
||||
Drupal.behaviors.ClickToSelect = {
|
||||
attach(context) {
|
||||
$('.js-click-to-select-trigger', context)
|
||||
.once('media-library-click-to-select')
|
||||
.on('click', event => {
|
||||
// Links inside the trigger should not be click-able.
|
||||
event.preventDefault();
|
||||
// Click the hidden checkbox when the trigger is clicked.
|
||||
const $input = $(event.currentTarget)
|
||||
.closest('.js-click-to-select')
|
||||
.find('.js-click-to-select-checkbox input');
|
||||
$input.prop('checked', !$input.prop('checked')).trigger('change');
|
||||
});
|
||||
$('.js-click-to-select-checkbox input', context)
|
||||
.once('media-library-click-to-select')
|
||||
.on('change', ({ currentTarget }) => {
|
||||
$(currentTarget)
|
||||
.closest('.js-click-to-select')
|
||||
.toggleClass('checked', $(currentTarget).prop('checked'));
|
||||
});
|
||||
},
|
||||
};
|
||||
})(jQuery, Drupal);
|
|
@ -0,0 +1,24 @@
|
|||
/**
|
||||
* DO NOT EDIT THIS FILE.
|
||||
* See the following change record for more information,
|
||||
* https://www.drupal.org/node/2815083
|
||||
* @preserve
|
||||
**/
|
||||
|
||||
(function ($, Drupal) {
|
||||
Drupal.behaviors.ClickToSelect = {
|
||||
attach: function attach(context) {
|
||||
$('.js-click-to-select-trigger', context).once('media-library-click-to-select').on('click', function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
var $input = $(event.currentTarget).closest('.js-click-to-select').find('.js-click-to-select-checkbox input');
|
||||
$input.prop('checked', !$input.prop('checked')).trigger('change');
|
||||
});
|
||||
$('.js-click-to-select-checkbox input', context).once('media-library-click-to-select').on('change', function (_ref) {
|
||||
var currentTarget = _ref.currentTarget;
|
||||
|
||||
$(currentTarget).closest('.js-click-to-select').toggleClass('checked', $(currentTarget).prop('checked'));
|
||||
});
|
||||
}
|
||||
};
|
||||
})(jQuery, Drupal);
|
76
web/core/modules/media_library/js/media_library.view.es6.js
Normal file
76
web/core/modules/media_library/js/media_library.view.es6.js
Normal file
|
@ -0,0 +1,76 @@
|
|||
/**
|
||||
* @file media_library.view.es6.js
|
||||
*/
|
||||
(($, Drupal) => {
|
||||
/**
|
||||
* Adds hover effect to media items.
|
||||
*/
|
||||
Drupal.behaviors.MediaLibraryHover = {
|
||||
attach(context) {
|
||||
$(
|
||||
'.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', ({ currentTarget, type }) => {
|
||||
$(currentTarget)
|
||||
.closest('.media-library-item')
|
||||
.toggleClass('is-hover', type === 'mouseover');
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Adds focus effect to media items.
|
||||
*/
|
||||
Drupal.behaviors.MediaLibraryFocus = {
|
||||
attach(context) {
|
||||
$('.media-library-item .js-click-to-select-checkbox input', context)
|
||||
.once('media-library-item-focus')
|
||||
.on('focus blur', ({ currentTarget, type }) => {
|
||||
$(currentTarget)
|
||||
.closest('.media-library-item')
|
||||
.toggleClass('is-focus', type === 'focus');
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Adds checkbox to select all items in the library.
|
||||
*/
|
||||
Drupal.behaviors.MediaLibrarySelectAll = {
|
||||
attach(context) {
|
||||
const $view = $('.media-library-view', context).once(
|
||||
'media-library-select-all',
|
||||
);
|
||||
if ($view.length && $view.find('.media-library-item').length) {
|
||||
const $checkbox = $(
|
||||
'<input type="checkbox" class="form-checkbox" />',
|
||||
).on('click', ({ currentTarget }) => {
|
||||
// Toggle all checkboxes.
|
||||
const $checkboxes = $(currentTarget)
|
||||
.closest('.media-library-view')
|
||||
.find('.media-library-item input[type="checkbox"]');
|
||||
$checkboxes
|
||||
.prop('checked', $(currentTarget).prop('checked'))
|
||||
.trigger('change');
|
||||
// Announce the selection.
|
||||
const announcement = $(currentTarget).prop('checked')
|
||||
? Drupal.t('Zero items selected')
|
||||
: Drupal.t('All @count items selected', {
|
||||
'@count': $checkboxes.length,
|
||||
});
|
||||
Drupal.announce(announcement);
|
||||
});
|
||||
const $label = $(
|
||||
'<label class="media-library-select-all"></label>',
|
||||
).text(Drupal.t('Select all media'));
|
||||
$label.prepend($checkbox);
|
||||
$view
|
||||
.find('.media-library-item')
|
||||
.first()
|
||||
.before($label);
|
||||
}
|
||||
},
|
||||
};
|
||||
})(jQuery, Drupal);
|
52
web/core/modules/media_library/js/media_library.view.js
Normal file
52
web/core/modules/media_library/js/media_library.view.js
Normal file
|
@ -0,0 +1,52 @@
|
|||
/**
|
||||
* DO NOT EDIT THIS FILE.
|
||||
* See the following change record for more information,
|
||||
* https://www.drupal.org/node/2815083
|
||||
* @preserve
|
||||
**/
|
||||
|
||||
(function ($, Drupal) {
|
||||
Drupal.behaviors.MediaLibraryHover = {
|
||||
attach: function attach(context) {
|
||||
$('.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) {
|
||||
var currentTarget = _ref.currentTarget,
|
||||
type = _ref.type;
|
||||
|
||||
$(currentTarget).closest('.media-library-item').toggleClass('is-hover', type === 'mouseover');
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Drupal.behaviors.MediaLibraryFocus = {
|
||||
attach: function attach(context) {
|
||||
$('.media-library-item .js-click-to-select-checkbox input', context).once('media-library-item-focus').on('focus blur', function (_ref2) {
|
||||
var currentTarget = _ref2.currentTarget,
|
||||
type = _ref2.type;
|
||||
|
||||
$(currentTarget).closest('.media-library-item').toggleClass('is-focus', type === 'focus');
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Drupal.behaviors.MediaLibrarySelectAll = {
|
||||
attach: function attach(context) {
|
||||
var $view = $('.media-library-view', context).once('media-library-select-all');
|
||||
if ($view.length && $view.find('.media-library-item').length) {
|
||||
var $checkbox = $('<input type="checkbox" class="form-checkbox" />').on('click', function (_ref3) {
|
||||
var currentTarget = _ref3.currentTarget;
|
||||
|
||||
var $checkboxes = $(currentTarget).closest('.media-library-view').find('.media-library-item input[type="checkbox"]');
|
||||
$checkboxes.prop('checked', $(currentTarget).prop('checked')).trigger('change');
|
||||
|
||||
var announcement = $(currentTarget).prop('checked') ? Drupal.t('Zero items selected') : Drupal.t('All @count items selected', {
|
||||
'@count': $checkboxes.length
|
||||
});
|
||||
Drupal.announce(announcement);
|
||||
});
|
||||
var $label = $('<label class="media-library-select-all"></label>').text(Drupal.t('Select all media'));
|
||||
$label.prepend($checkbox);
|
||||
$view.find('.media-library-item').first().before($label);
|
||||
}
|
||||
}
|
||||
};
|
||||
})(jQuery, Drupal);
|
120
web/core/modules/media_library/js/media_library.widget.es6.js
Normal file
120
web/core/modules/media_library/js/media_library.widget.es6.js
Normal file
|
@ -0,0 +1,120 @@
|
|||
/**
|
||||
* @file media_library.widget.js
|
||||
*/
|
||||
(($, Drupal) => {
|
||||
/**
|
||||
* Allows users to re-order their selection with drag+drop.
|
||||
*/
|
||||
Drupal.behaviors.MediaLibraryWidgetSortable = {
|
||||
attach(context) {
|
||||
// Allow media items to be re-sorted with drag+drop in the widget.
|
||||
$('.js-media-library-selection', context)
|
||||
.once('media-library-sortable')
|
||||
.sortable({
|
||||
tolerance: 'pointer',
|
||||
helper: 'clone',
|
||||
handle: '.js-media-library-item-preview',
|
||||
stop: ({ target }) => {
|
||||
// Update all the hidden "weight" fields.
|
||||
$(target)
|
||||
.children()
|
||||
.each((index, child) => {
|
||||
$(child)
|
||||
.find('.js-media-library-item-weight')
|
||||
.val(index);
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Allows selection order to be set without drag+drop for accessibility.
|
||||
*/
|
||||
Drupal.behaviors.MediaLibraryWidgetToggleWeight = {
|
||||
attach(context) {
|
||||
const strings = {
|
||||
show: Drupal.t('Show media item weights'),
|
||||
hide: Drupal.t('Hide media item weights'),
|
||||
};
|
||||
$('.js-media-library-widget-toggle-weight', context)
|
||||
.once('media-library-toggle')
|
||||
.on('click', e => {
|
||||
e.preventDefault();
|
||||
$(e.currentTarget)
|
||||
.toggleClass('active')
|
||||
.text(
|
||||
$(e.currentTarget).hasClass('active')
|
||||
? strings.hide
|
||||
: strings.show,
|
||||
)
|
||||
.parent()
|
||||
.find('.js-media-library-item-weight')
|
||||
.parent()
|
||||
.toggle();
|
||||
})
|
||||
.text(strings.show);
|
||||
$('.js-media-library-item-weight', context)
|
||||
.once('media-library-toggle')
|
||||
.parent()
|
||||
.hide();
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Warn users when clicking outgoing links from the library or widget.
|
||||
*/
|
||||
Drupal.behaviors.MediaLibraryWidgetWarn = {
|
||||
attach(context) {
|
||||
$('.js-media-library-item a[href]', context)
|
||||
.once('media-library-warn-link')
|
||||
.on('click', e => {
|
||||
const message = Drupal.t(
|
||||
'Unsaved changes to the form will be lost. Are you sure you want to leave?',
|
||||
);
|
||||
const confirmation = window.confirm(message);
|
||||
if (!confirmation) {
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Prevent users from selecting more items than allowed in the view.
|
||||
*/
|
||||
Drupal.behaviors.MediaLibraryWidgetRemaining = {
|
||||
attach(context, settings) {
|
||||
const $view = $('.js-media-library-view', context).once(
|
||||
'media-library-remaining',
|
||||
);
|
||||
$view
|
||||
.find('.js-media-library-item input[type="checkbox"]')
|
||||
.on('change', () => {
|
||||
if (
|
||||
settings.media_library &&
|
||||
settings.media_library.selection_remaining
|
||||
) {
|
||||
const $checkboxes = $view.find(
|
||||
'.js-media-library-item input[type="checkbox"]',
|
||||
);
|
||||
if (
|
||||
$checkboxes.filter(':checked').length ===
|
||||
settings.media_library.selection_remaining
|
||||
) {
|
||||
$checkboxes
|
||||
.not(':checked')
|
||||
.prop('disabled', true)
|
||||
.closest('.js-media-library-item')
|
||||
.addClass('media-library-item--disabled');
|
||||
} else {
|
||||
$checkboxes
|
||||
.prop('disabled', false)
|
||||
.closest('.js-media-library-item')
|
||||
.removeClass('media-library-item--disabled');
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
};
|
||||
})(jQuery, Drupal);
|
67
web/core/modules/media_library/js/media_library.widget.js
Normal file
67
web/core/modules/media_library/js/media_library.widget.js
Normal file
|
@ -0,0 +1,67 @@
|
|||
/**
|
||||
* DO NOT EDIT THIS FILE.
|
||||
* See the following change record for more information,
|
||||
* https://www.drupal.org/node/2815083
|
||||
* @preserve
|
||||
**/
|
||||
|
||||
(function ($, Drupal) {
|
||||
Drupal.behaviors.MediaLibraryWidgetSortable = {
|
||||
attach: function attach(context) {
|
||||
$('.js-media-library-selection', context).once('media-library-sortable').sortable({
|
||||
tolerance: 'pointer',
|
||||
helper: 'clone',
|
||||
handle: '.js-media-library-item-preview',
|
||||
stop: function stop(_ref) {
|
||||
var target = _ref.target;
|
||||
|
||||
$(target).children().each(function (index, child) {
|
||||
$(child).find('.js-media-library-item-weight').val(index);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Drupal.behaviors.MediaLibraryWidgetToggleWeight = {
|
||||
attach: function attach(context) {
|
||||
var strings = {
|
||||
show: Drupal.t('Show media item weights'),
|
||||
hide: Drupal.t('Hide media item weights')
|
||||
};
|
||||
$('.js-media-library-widget-toggle-weight', context).once('media-library-toggle').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
$(e.currentTarget).toggleClass('active').text($(e.currentTarget).hasClass('active') ? strings.hide : strings.show).parent().find('.js-media-library-item-weight').parent().toggle();
|
||||
}).text(strings.show);
|
||||
$('.js-media-library-item-weight', context).once('media-library-toggle').parent().hide();
|
||||
}
|
||||
};
|
||||
|
||||
Drupal.behaviors.MediaLibraryWidgetWarn = {
|
||||
attach: function attach(context) {
|
||||
$('.js-media-library-item a[href]', context).once('media-library-warn-link').on('click', function (e) {
|
||||
var message = Drupal.t('Unsaved changes to the form will be lost. Are you sure you want to leave?');
|
||||
var confirmation = window.confirm(message);
|
||||
if (!confirmation) {
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Drupal.behaviors.MediaLibraryWidgetRemaining = {
|
||||
attach: function attach(context, settings) {
|
||||
var $view = $('.js-media-library-view', context).once('media-library-remaining');
|
||||
$view.find('.js-media-library-item input[type="checkbox"]').on('change', function () {
|
||||
if (settings.media_library && settings.media_library.selection_remaining) {
|
||||
var $checkboxes = $view.find('.js-media-library-item input[type="checkbox"]');
|
||||
if ($checkboxes.filter(':checked').length === settings.media_library.selection_remaining) {
|
||||
$checkboxes.not(':checked').prop('disabled', true).closest('.js-media-library-item').addClass('media-library-item--disabled');
|
||||
} else {
|
||||
$checkboxes.prop('disabled', false).closest('.js-media-library-item').removeClass('media-library-item--disabled');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
})(jQuery, Drupal);
|
Reference in a new issue