plugin updates
This commit is contained in:
@@ -289,46 +289,65 @@ var wpmfFoldersModule = void 0,
|
||||
// call drag folderempty attachment
|
||||
wpmfFoldersModule.initializeDragAndDropAttachments();
|
||||
wpmfFoldersModule.openContextMenuFolder();
|
||||
// Select the node that will be observed for mutations
|
||||
// call open context menu when empty attachment
|
||||
$current_frame.find('.attachments-browser ul.attachments').on("DOMNodeInserted", function () {
|
||||
// Wait All DOMInserted events to be thrown before calling the initialization functions
|
||||
window.clearTimeout(timeout);
|
||||
timeout = window.setTimeout(function () {
|
||||
// Hovering image intialization
|
||||
wpmfFoldersModule.initHoverImage();
|
||||
wpmfFoldersModule.initAttachmentLabelS3();
|
||||
const targetNode = $current_frame.find('.attachments-browser ul.attachments')[0];
|
||||
// Options for the observer (which mutations to observe)
|
||||
const config = { attributes: true, childList: true, subtree: true };
|
||||
|
||||
// open / close context menu box
|
||||
wpmfFoldersModule.openContextMenuFile();
|
||||
wpmfFoldersModule.openContextMenuFolder();
|
||||
wpmfFoldersModule.getFrame().find('.attachments-browser ul.attachments .attachment .thumbnail').each(function (e) {
|
||||
var $this = $(this);
|
||||
if ($this.closest('.attachment-preview').hasClass('type-image') && !$this.closest('.attachment.loading').length) {
|
||||
var _id = $this.closest('.attachment').data('id');
|
||||
var cloud_media = wp.media.attachment(_id).get('cloud_media');
|
||||
var url = wp.media.attachment(_id).get('url');
|
||||
// Callback function to execute when mutations are observed
|
||||
const callback = (mutationList, observer) => {
|
||||
for (const mutation of mutationList) {
|
||||
if (mutation.type === "childList") {
|
||||
// Wait All DOMInserted events to be thrown before calling the initialization functions
|
||||
window.clearTimeout(timeout);
|
||||
timeout = window.setTimeout(function () {
|
||||
// Hovering image intialization
|
||||
wpmfFoldersModule.initHoverImage();
|
||||
wpmfFoldersModule.initAttachmentLabelS3();
|
||||
|
||||
if (typeof url !== "undefined") {
|
||||
if (url.indexOf('action=wpmf') !== -1 || url.indexOf('api.onedrive.com') !== -1 || url.indexOf('drive.google.com') !== -1 || url.indexOf('dropbox.com') !== -1) {
|
||||
$this.css('background', 'transparent url(' + wpmf.vars.img_url + 'spinner.gif) center no-repeat');
|
||||
$this.find('img').on('load', function () {
|
||||
$this.css('background', 'transparent');
|
||||
});
|
||||
// open / close context menu box
|
||||
wpmfFoldersModule.openContextMenuFile();
|
||||
wpmfFoldersModule.openContextMenuFolder();
|
||||
wpmfFoldersModule.getFrame().find('.attachments-browser ul.attachments .attachment .thumbnail').each(function (e) {
|
||||
var $this = $(this);
|
||||
if ($this.closest('.attachment-preview').hasClass('type-image') && !$this.closest('.attachment.loading').length) {
|
||||
var _id = $this.closest('.attachment').data('id');
|
||||
var cloud_media = wp.media.attachment(_id).get('cloud_media');
|
||||
var url = wp.media.attachment(_id).get('url');
|
||||
|
||||
if (typeof url !== "undefined") {
|
||||
if (url.indexOf('action=wpmf') !== -1 || url.indexOf('api.onedrive.com') !== -1 || url.indexOf('drive.google.com') !== -1 || url.indexOf('dropbox.com') !== -1) {
|
||||
$this.css('background', 'transparent url(' + wpmf.vars.img_url + 'spinner.gif) center no-repeat');
|
||||
$this.find('img').on('load', function () {
|
||||
$this.css('background', 'transparent');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (parseInt(cloud_media) === 1) {
|
||||
$this.closest('li').addClass('wpmf_cloud_media').removeClass('wpmf_local_media');
|
||||
} else {
|
||||
$this.closest('li').removeClass('wpmf_cloud_media').addClass('wpmf_local_media');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (parseInt(cloud_media) === 1) {
|
||||
$this.closest('li').addClass('wpmf_cloud_media').removeClass('wpmf_local_media');
|
||||
} else {
|
||||
$this.closest('li').removeClass('wpmf_cloud_media').addClass('wpmf_local_media');
|
||||
}
|
||||
}
|
||||
});
|
||||
// Attach drag and drop event to the attachments
|
||||
wpmfFoldersModule.initializeDragAndDropAttachments();
|
||||
}, 300);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Attach drag and drop event to the attachments
|
||||
wpmfFoldersModule.initializeDragAndDropAttachments();
|
||||
}, 300);
|
||||
});
|
||||
// Create an observer instance linked to the callback function
|
||||
const observer = new MutationObserver(callback);
|
||||
|
||||
// Start observing the target node for configured mutations
|
||||
observer.observe(targetNode, config);
|
||||
|
||||
// Later, you can stop observing
|
||||
// observer.disconnect();
|
||||
|
||||
// Add the creation gallery from folder button
|
||||
|
||||
|
||||
Reference in New Issue
Block a user