mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-11-01 10:56:08 +01:00
More fixes towards independency of media resizer/collapser
This commit is contained in:
@@ -140,7 +140,7 @@ export default class PageMedia extends FilesField {
|
|||||||
|
|
||||||
if (status.width) {
|
if (status.width) {
|
||||||
const input = this.container.closest('.pagemedia-field').find('.media-resizer');
|
const input = this.container.closest('.pagemedia-field').find('.media-resizer');
|
||||||
updateMediaSizes(input, status.width, false);
|
updateMediaSizes(input[0], status.width, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -231,16 +231,17 @@ export default class PageMedia extends FilesField {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const updateMediaSizes = (input, width, store = true) => {
|
export const updateMediaSizes = (input, width, store = true) => {
|
||||||
const status = JSON.parse(Cookies.get('grav-admin-pagemedia') || '{}');
|
const storageLocation = input.dataset.storageLocation || 'grav-admin-pagemedia';
|
||||||
|
const status = JSON.parse(Cookies.get(storageLocation) || '{}');
|
||||||
|
|
||||||
const height = 150 * width / 200;
|
const height = 150 * width / 200;
|
||||||
const media = input.closest('.pagemedia-field').find('.dz-details, [data-dz-thumbnail]');
|
const media = $(input).closest('.pagemedia-field').find('.dz-details, [data-dz-thumbnail]');
|
||||||
|
|
||||||
media.css({ width, height });
|
media.css({ width, height });
|
||||||
|
|
||||||
if (store) {
|
if (store) {
|
||||||
const data = Object.assign({}, status, { width });
|
const data = Object.assign({}, status, { width });
|
||||||
Cookies.set('grav-admin-pagemedia', JSON.stringify(data), { expires: Infinity });
|
Cookies.set(storageLocation, JSON.stringify(data), { expires: Infinity });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -271,7 +272,7 @@ $(document).on('input', '.media-resizer', (event) => {
|
|||||||
const target = $(event.currentTarget);
|
const target = $(event.currentTarget);
|
||||||
const width = target.val();
|
const width = target.val();
|
||||||
|
|
||||||
updateMediaSizes(target, width);
|
updateMediaSizes(event.currentTarget, width);
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on('click', '.media-collapser', (event) => {
|
$(document).on('click', '.media-collapser', (event) => {
|
||||||
@@ -279,13 +280,14 @@ $(document).on('click', '.media-collapser', (event) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$(document).ready(() => {
|
$(document).ready(() => {
|
||||||
const status = JSON.parse(Cookies.get('grav-admin-pagemedia') || '{}');
|
$('.media-resizer').each((index, input) => {
|
||||||
if (status.width) {
|
const storageLocation = input.dataset.storageLocation || 'grav-admin-pagemedia';
|
||||||
$('.media-resizer').each((index, input) => {
|
const status = JSON.parse(Cookies.get(storageLocation) || '{}');
|
||||||
input = $(input);
|
|
||||||
|
if (status.width) {
|
||||||
updateMediaSizes(input, status.width, false);
|
updateMediaSizes(input, status.width, false);
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
export let Instance = new PageMedia();
|
export let Instance = new PageMedia();
|
||||||
|
|||||||
16179
themes/grav/js/admin.min.js
vendored
16179
themes/grav/js/admin.min.js
vendored
File diff suppressed because one or more lines are too long
90574
themes/grav/js/vendor.min.js
vendored
90574
themes/grav/js/vendor.min.js
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user