and again
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
/*global opener */
|
||||
(function () {
|
||||
'use strict';
|
||||
const dataElement = document.getElementById('django-admin-popup-response-constants');
|
||||
let initData;
|
||||
|
||||
if (dataElement) {
|
||||
initData = JSON.parse(dataElement.dataset.popupResponse);
|
||||
switch (initData.action) {
|
||||
case 'change':
|
||||
// Specific function for file editing popup opened from widget
|
||||
opener.dismissRelatedImageLookupPopup(window, initData.new_value, null, initData.obj, null);
|
||||
break;
|
||||
case 'delete':
|
||||
opener.dismissDeleteRelatedObjectPopup(window, initData.value);
|
||||
break;
|
||||
default:
|
||||
opener.dismissAddRelatedObjectPopup(window, initData.value, initData.obj);
|
||||
break;
|
||||
}
|
||||
}
|
||||
})();
|
||||
Vendored
+57
@@ -0,0 +1,57 @@
|
||||
/*!
|
||||
* Dropzone.js
|
||||
* https://www.dropzonejs.com/
|
||||
*/
|
||||
LICENSE
|
||||
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2021 Matias Meno <m@tias.me>
|
||||
Logo (c) 2015 "1910" www.weare1910.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
* Mediator.js
|
||||
* https://github.com/ajacksified/Mediator.js
|
||||
*/
|
||||
MIT License Terms
|
||||
=================
|
||||
|
||||
Copyright (c) 2013 Jack Lawson
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
File diff suppressed because one or more lines are too long
+13
File diff suppressed because one or more lines are too long
@@ -0,0 +1,30 @@
|
||||
// Admin File Widget JavaScript
|
||||
'use strict';
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
// Find all file widgets and clean up "add new" buttons
|
||||
const cleanupAddButtons = () => {
|
||||
document.querySelectorAll('.filer-widget').forEach((widget) => {
|
||||
const hiddenInput = widget.querySelector('input[type="text"][id]');
|
||||
if (hiddenInput) {
|
||||
const widgetId = hiddenInput.id;
|
||||
const addButton = document.querySelector(`#add_${widgetId}`);
|
||||
if (addButton) {
|
||||
addButton.remove();
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
cleanupAddButtons();
|
||||
|
||||
// Also handle dynamically added widgets (e.g., in inline formsets)
|
||||
const observer = new MutationObserver(() => {
|
||||
cleanupAddButtons();
|
||||
});
|
||||
|
||||
observer.observe(document.body, {
|
||||
childList: true,
|
||||
subtree: true
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,64 @@
|
||||
// Admin Folder Widget JavaScript
|
||||
'use strict';
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const initFolderWidget = (widget) => {
|
||||
const clearButton = widget.querySelector('.filerClearer');
|
||||
const input = widget.querySelector('input[type="text"]');
|
||||
const folderName = widget.querySelector('.description_text');
|
||||
const thumbnailImg = widget.querySelector('.thumbnail_img');
|
||||
const addFolderButton = widget.querySelector('.related-lookup');
|
||||
|
||||
if (!clearButton || !input) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Avoid duplicate initialization
|
||||
if (clearButton.dataset.initialized) {
|
||||
return;
|
||||
}
|
||||
clearButton.dataset.initialized = 'true';
|
||||
|
||||
clearButton.addEventListener('click', (e) => {
|
||||
e.preventDefault();
|
||||
|
||||
if (folderName) {
|
||||
folderName.textContent = '';
|
||||
}
|
||||
if (input) {
|
||||
input.removeAttribute('value');
|
||||
input.value = '';
|
||||
}
|
||||
if (thumbnailImg) {
|
||||
thumbnailImg.classList.add('hidden');
|
||||
}
|
||||
clearButton.classList.add('hidden');
|
||||
if (addFolderButton) {
|
||||
addFolderButton.classList.remove('hidden');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// Initialize all folder widgets
|
||||
document.querySelectorAll('.filer-dropzone-folder').forEach(initFolderWidget);
|
||||
|
||||
// Handle dynamically added widgets (e.g., in inline formsets)
|
||||
const observer = new MutationObserver((mutations) => {
|
||||
mutations.forEach((mutation) => {
|
||||
mutation.addedNodes.forEach((node) => {
|
||||
if (node.nodeType === 1) { // Element node
|
||||
if (node.classList?.contains('filer-dropzone-folder')) {
|
||||
initFolderWidget(node);
|
||||
}
|
||||
// Also check child nodes
|
||||
node.querySelectorAll?.('.filer-dropzone-folder').forEach(initFolderWidget);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
observer.observe(document.body, {
|
||||
childList: true,
|
||||
subtree: true
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user