mirror of
https://github.com/wagtail/wagtail.git
synced 2024-12-01 11:41:20 +01:00
lint image-chooser.js
This commit is contained in:
parent
fcddbfd58a
commit
bbc61fb2bc
@ -1,34 +1,37 @@
|
||||
/* eslint-disable */
|
||||
import $ from 'jquery';
|
||||
|
||||
function createImageChooser(id) {
|
||||
var chooserElement = $('#' + id + '-chooser');
|
||||
var previewImage = chooserElement.find('.preview-image img');
|
||||
var input = $('#' + id);
|
||||
var editLink = chooserElement.find('.edit-link');
|
||||
const chooserElement = $('#' + id + '-chooser');
|
||||
const previewImage = chooserElement.find('.preview-image img');
|
||||
const input = $('#' + id);
|
||||
const editLink = chooserElement.find('.edit-link');
|
||||
|
||||
$('.action-choose', chooserElement).on('click', function() {
|
||||
ModalWorkflow({
|
||||
url: chooserElement.data('chooserUrl'),
|
||||
onload: IMAGE_CHOOSER_MODAL_ONLOAD_HANDLERS,
|
||||
responses: {
|
||||
imageChosen: function(imageData) {
|
||||
input.val(imageData.id);
|
||||
previewImage.attr({
|
||||
src: imageData.preview.url,
|
||||
width: imageData.preview.width,
|
||||
height: imageData.preview.height,
|
||||
alt: imageData.title,
|
||||
title: imageData.title
|
||||
});
|
||||
chooserElement.removeClass('blank');
|
||||
editLink.attr('href', imageData.edit_link);
|
||||
}
|
||||
}
|
||||
});
|
||||
$('.action-choose', chooserElement).on('click', () => {
|
||||
// eslint-disable-next-line no-undef, new-cap
|
||||
ModalWorkflow({
|
||||
url: chooserElement.data('chooserUrl'),
|
||||
// eslint-disable-next-line no-undef
|
||||
onload: IMAGE_CHOOSER_MODAL_ONLOAD_HANDLERS,
|
||||
responses: {
|
||||
imageChosen: (imageData) => {
|
||||
input.val(imageData.id);
|
||||
previewImage.attr({
|
||||
src: imageData.preview.url,
|
||||
width: imageData.preview.width,
|
||||
height: imageData.preview.height,
|
||||
alt: imageData.title,
|
||||
title: imageData.title
|
||||
});
|
||||
chooserElement.removeClass('blank');
|
||||
editLink.attr('href', imageData.edit_link);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('.action-clear', chooserElement).on('click', function() {
|
||||
input.val('');
|
||||
chooserElement.addClass('blank');
|
||||
});
|
||||
$('.action-clear', chooserElement).on('click', () => {
|
||||
input.val('');
|
||||
chooserElement.addClass('blank');
|
||||
});
|
||||
}
|
||||
window.createImageChooser = createImageChooser;
|
||||
|
Loading…
Reference in New Issue
Block a user