[TASK] Uses single-asset insertion when only one asset has been selected to be inserted
refs #651
This commit is contained in:
committed by
Garvin Hicking
parent
27703c5482
commit
6a268e2b5f
@ -1,6 +1,12 @@
|
|||||||
Version 2.4-alpha1 ()
|
Version 2.4-alpha1 ()
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
|
|
||||||
|
* #651: When using checkboxes to insert multiple media files, if only
|
||||||
|
one asset has been selected, do not use the gallery mode,
|
||||||
|
but instead single-asset view. Also improves to click the title
|
||||||
|
of an asset to select its checkbox, and hides the 'Insert all'
|
||||||
|
button when no assets are selected. (garvinhicking)
|
||||||
|
|
||||||
* Fix: [bbcode] Get roman numerals working in bbcode plugin.
|
* Fix: [bbcode] Get roman numerals working in bbcode plugin.
|
||||||
Thanks to Fabien Chabreuil!
|
Thanks to Fabien Chabreuil!
|
||||||
|
|
||||||
|
@ -1387,8 +1387,39 @@ $(function() {
|
|||||||
$('.multidelete, .multiinsert').click(function() {
|
$('.multidelete, .multiinsert').click(function() {
|
||||||
var $el = $(this);
|
var $el = $(this);
|
||||||
serendipity.highlightComment($el.attr('data-multidelid'), $el.attr('checked'));
|
serendipity.highlightComment($el.attr('data-multidelid'), $el.attr('checked'));
|
||||||
$('#media_galleryinsert').fadeIn();
|
var selectionAmount = $('.multidelete:checked, .multiinsert:checked').length;
|
||||||
|
if (selectionAmount > 0) {
|
||||||
|
$('#media_galleryinsert').fadeIn();
|
||||||
|
} else {
|
||||||
|
$('#media_galleryinsert').fadeOut();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Also marks checkbox when header is clicked
|
||||||
|
$('.media_file h3').on('click', function() {
|
||||||
|
$(this).parent().find('.multiinsert').click();
|
||||||
|
});
|
||||||
|
|
||||||
|
// When clicking the 'Insert all' button, check whether only one or multiple
|
||||||
|
// images are selected
|
||||||
|
$('#media_galleryinsert .image_insert').on('click', function(e) {
|
||||||
|
var selectionAmount = $('.multidelete:checked, .multiinsert:checked').length;
|
||||||
|
if (selectionAmount == 0) {
|
||||||
|
e.preventDefault();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Actually do a single insert
|
||||||
|
if (selectionAmount == 1) {
|
||||||
|
e.preventDefault();
|
||||||
|
var actualTargetElement = $('.multidelete:checked, .multiinsert:checked').closest('.media_file').find('.media_file_preview a').first();
|
||||||
|
// This below is a hack. Triggering actualTargetElement.click() does not work. Probably because MFP overrides click events within a modal popup.
|
||||||
|
// So we need to do something dirty and directly access the location href. Don't tell my mom.
|
||||||
|
location.href = actualTargetElement.attr('href');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// hide gallery insert button until an image is selected
|
// hide gallery insert button until an image is selected
|
||||||
$('#media_galleryinsert').hide();
|
$('#media_galleryinsert').hide();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user