kopia lustrzana https://github.com/wagtail/wagtail
Move all legacy JS into client folder
rodzic
8edd590ea0
commit
160d66ca93
|
@ -1,3 +1,5 @@
|
|||
/* eslint-disable */
|
||||
|
||||
(function($) {
|
||||
window.ListBlock = function(opts) {
|
||||
/* contents of 'opts':
|
|
@ -12,6 +12,7 @@ For example, they don't assume the presence of a 'delete' button - it's up to th
|
|||
CODE FOR SETTING UP SPECIFIC UI WIDGETS, SUCH AS DELETE BUTTONS OR MENUS, DOES NOT BELONG HERE.
|
||||
|
||||
*/
|
||||
/* eslint-disable */
|
||||
(function($) {
|
||||
window.SequenceMember = function(sequence, prefix) {
|
||||
var self = {};
|
||||
|
@ -356,7 +357,7 @@ CODE FOR SETTING UP SPECIFIC UI WIDGETS, SUCH AS DELETE BUTTONS OR MENUS, DOES N
|
|||
/* block capacity is already reached on initialization */
|
||||
opts.onDisableAdd(members)
|
||||
}
|
||||
|
||||
|
||||
return self;
|
||||
};
|
||||
})(jQuery);
|
|
@ -1,3 +1,4 @@
|
|||
/* eslint-disable */
|
||||
(function($) {
|
||||
var StreamBlockMenu = function(opts) {
|
||||
/*
|
||||
|
@ -131,7 +132,7 @@
|
|||
onDisableMoveDown: function(sequenceMember) {
|
||||
$('#' + sequenceMember.prefix + '-movedown').addClass('disabled');
|
||||
},
|
||||
|
||||
|
||||
onDisableAdd: function(members) {
|
||||
for (var i = 0; i < members.length; i++){
|
||||
$('#' + members[i].prefix + '-appendmenu-openclose')
|
||||
|
@ -143,7 +144,7 @@
|
|||
|
||||
onEnableAdd: function(members) {
|
||||
for (var i = 0; i < members.length; i++){
|
||||
|
||||
|
||||
$('#' + members[i].prefix + '-appendmenu-openclose')
|
||||
.addClass('c-sf-add-button--visible').delay(300).slideDown()
|
||||
}
|
|
@ -1,3 +1,4 @@
|
|||
/* eslint-disable */
|
||||
window.StructBlock = function(childInitializersByName) {
|
||||
return function(prefix) {
|
||||
for (var childName in childInitializersByName) {
|
|
@ -1,3 +1,4 @@
|
|||
/* eslint-disable */
|
||||
/* generic function for adding a message to message area through JS alone */
|
||||
function addMessage(status, text) {
|
||||
$('.messages').addClass('new').empty().append('<ul><li class="' + status + '">' + text + '</li></ul>');
|
||||
|
@ -6,6 +7,7 @@ function addMessage(status, text) {
|
|||
clearTimeout(addMsgTimeout);
|
||||
}, 100);
|
||||
}
|
||||
window.addMessage = addMessage;
|
||||
|
||||
function escapeHtml(text) {
|
||||
var map = {
|
||||
|
@ -20,6 +22,7 @@ function escapeHtml(text) {
|
|||
return map[m];
|
||||
});
|
||||
}
|
||||
window.escapeHtml = escapeHtml;
|
||||
|
||||
function initTagField(id, autocompleteUrl, options) {
|
||||
var finalOptions = Object.assign({
|
||||
|
@ -37,6 +40,7 @@ function initTagField(id, autocompleteUrl, options) {
|
|||
|
||||
$('#' + id).tagit(finalOptions);
|
||||
}
|
||||
window.initTagField = initTagField;
|
||||
|
||||
/*
|
||||
* Enables a "dirty form check", prompting the user if they are navigating away
|
||||
|
@ -81,6 +85,7 @@ function enableDirtyFormCheck(formSelector, options) {
|
|||
}
|
||||
});
|
||||
}
|
||||
window.enableDirtyFormCheck = enableDirtyFormCheck;
|
||||
|
||||
$(function() {
|
||||
// Add class to the body from which transitions may be hung so they don't appear to transition as the page loads
|
||||
|
@ -342,19 +347,18 @@ $(function() {
|
|||
// Wagtail global module, mainly useful for debugging.
|
||||
// =============================================================================
|
||||
|
||||
var wagtail = window.wagtail = null;
|
||||
|
||||
// =============================================================================
|
||||
// Inline dropdown module
|
||||
// =============================================================================
|
||||
|
||||
wagtail = (function(document, window, wagtail) {
|
||||
window.wagtail = (function(document, window, wagtail) {
|
||||
|
||||
// Module pattern
|
||||
if (!wagtail) {
|
||||
wagtail = {
|
||||
ui: {}
|
||||
};
|
||||
wagtail = {};
|
||||
}
|
||||
if (!wagtail.ui) {
|
||||
wagtail.ui = {};
|
||||
}
|
||||
|
||||
// Constants
|
|
@ -1,3 +1,4 @@
|
|||
/* eslint-disable */
|
||||
$.fn.datetimepicker.defaults.i18n.wagtail_custom_locale = {
|
||||
months: wagtailConfig.STRINGS.MONTHS,
|
||||
dayOfWeek: wagtailConfig.STRINGS.WEEKDAYS,
|
||||
|
@ -11,6 +12,7 @@ function dateEqual(x, y) {
|
|||
x.getMonth() === y.getMonth() &&
|
||||
x.getYear() === y.getYear()
|
||||
}
|
||||
window.dateEqual = dateEqual;
|
||||
|
||||
/*
|
||||
Remove the xdsoft_current css class from markup unless the selected date is currently in view.
|
||||
|
@ -22,6 +24,7 @@ function hideCurrent(current, input) {
|
|||
$(this).find('.xdsoft_datepicker .xdsoft_current:not(.xdsoft_today)').removeClass('xdsoft_current');
|
||||
}
|
||||
}
|
||||
window.hideCurrent = hideCurrent;
|
||||
|
||||
function initDateChooser(id, opts) {
|
||||
if (window.dateTimePickerTranslations) {
|
||||
|
@ -47,6 +50,7 @@ function initDateChooser(id, opts) {
|
|||
}, opts || {}));
|
||||
}
|
||||
}
|
||||
window.initDateChooser = initDateChooser;
|
||||
|
||||
function initTimeChooser(id, opts) {
|
||||
if (window.dateTimePickerTranslations) {
|
||||
|
@ -69,6 +73,7 @@ function initTimeChooser(id, opts) {
|
|||
}, opts || {}));
|
||||
}
|
||||
}
|
||||
window.initTimeChooser = initTimeChooser;
|
||||
|
||||
function initDateTimeChooser(id, opts) {
|
||||
if (window.dateTimePickerTranslations) {
|
||||
|
@ -91,3 +96,4 @@ function initDateTimeChooser(id, opts) {
|
|||
}, opts || {}));
|
||||
}
|
||||
}
|
||||
window.initDateTimeChooser = initDateTimeChooser;
|
|
@ -1,3 +1,4 @@
|
|||
/* eslint-disable */
|
||||
function buildExpandingFormset(prefix, opts) {
|
||||
if (!opts) {
|
||||
opts = {};
|
||||
|
@ -34,3 +35,4 @@ function buildExpandingFormset(prefix, opts) {
|
|||
totalFormsInput.val(formCount);
|
||||
});
|
||||
}
|
||||
window.buildExpandingFormset = buildExpandingFormset;
|
|
@ -24,6 +24,7 @@
|
|||
</select>
|
||||
</div>
|
||||
*/
|
||||
/* eslint-disable */
|
||||
|
||||
$(function() {
|
||||
$('[data-widget="filtered-select"]').each(function() {
|
|
@ -1,5 +1,4 @@
|
|||
'use strict';
|
||||
|
||||
/* eslint-disable */
|
||||
function makeHalloRichTextEditable(id, plugins) {
|
||||
var input = $('#' + id);
|
||||
var editor = $('<div class="halloeditor" data-hallo-editor></div>').html(input.val());
|
||||
|
@ -60,6 +59,7 @@ function makeHalloRichTextEditable(id, plugins) {
|
|||
|
||||
setupLinkTooltips(editor);
|
||||
}
|
||||
window.makeHalloRichTextEditable = makeHalloRichTextEditable;
|
||||
|
||||
function setupLinkTooltips(elem) {
|
||||
elem.tooltip({
|
||||
|
@ -72,6 +72,7 @@ function setupLinkTooltips(elem) {
|
|||
selector: 'a'
|
||||
});
|
||||
}
|
||||
window.setupLinkTooltips = setupLinkTooltips;
|
||||
|
||||
function insertRichTextDeleteControl(elem) {
|
||||
var a = $('<a class="icon icon-cross text-replace halloembed__delete">Delete</a>');
|
||||
|
@ -86,6 +87,7 @@ function insertRichTextDeleteControl(elem) {
|
|||
});
|
||||
});
|
||||
}
|
||||
window.insertRichTextDeleteControl = insertRichTextDeleteControl;
|
||||
|
||||
$(function() {
|
||||
$('[data-hallo-editor] [contenteditable="false"]').each(function() {
|
|
@ -1,3 +1,4 @@
|
|||
/* eslint-disable */
|
||||
// Generated by CoffeeScript 1.6.2
|
||||
(function() {
|
||||
(function(jQuery) {
|
|
@ -1,3 +1,4 @@
|
|||
/* eslint-disable */
|
||||
(function() {
|
||||
(function(jQuery) {
|
||||
return jQuery.widget('IKS.hallorequireparagraphs', {
|
|
@ -1,3 +1,4 @@
|
|||
/* eslint-disable */
|
||||
// Generated by CoffeeScript 1.6.2
|
||||
(function() {
|
||||
(function($) {
|
|
@ -1,5 +1,6 @@
|
|||
/* When a lock/unlock action button is clicked, make a POST request to the relevant view */
|
||||
|
||||
/* eslint-disable */
|
||||
function LockUnlockAction(csrfToken, next) {
|
||||
document.querySelectorAll('[data-locking-action]').forEach(function (buttonElement) {
|
||||
buttonElement.addEventListener('click', function (e) {
|
||||
|
@ -31,3 +32,4 @@ function LockUnlockAction(csrfToken, next) {
|
|||
}, {capture: true});
|
||||
});
|
||||
}
|
||||
window.LockUnlockAction = LockUnlockAction;
|
|
@ -2,6 +2,7 @@
|
|||
subpages to happen within the lightbox, and returning a response to the calling page,
|
||||
possibly after several navigation steps
|
||||
*/
|
||||
/* eslint-disable */
|
||||
|
||||
function ModalWorkflow(opts) {
|
||||
/* options passed in 'opts':
|
||||
|
@ -89,3 +90,4 @@ function ModalWorkflow(opts) {
|
|||
|
||||
return self;
|
||||
}
|
||||
window.ModalWorkflow = ModalWorkflow;
|
|
@ -1,4 +1,5 @@
|
|||
PAGE_CHOOSER_MODAL_ONLOAD_HANDLERS = {
|
||||
/* eslint-disable */
|
||||
const PAGE_CHOOSER_MODAL_ONLOAD_HANDLERS = {
|
||||
'browse': function(modal, jsonData) {
|
||||
/* Set up link-types links to open in the modal */
|
||||
$('.link-types a', modal.body).on('click', function() {
|
||||
|
@ -160,3 +161,4 @@ PAGE_CHOOSER_MODAL_ONLOAD_HANDLERS = {
|
|||
modal.close();
|
||||
},
|
||||
};
|
||||
window.PAGE_CHOOSER_MODAL_ONLOAD_HANDLERS = PAGE_CHOOSER_MODAL_ONLOAD_HANDLERS;
|
|
@ -1,3 +1,4 @@
|
|||
/* eslint-disable */
|
||||
function createPageChooser(id, pageTypes, openAtParentId, canChooseRoot, userPerms) {
|
||||
var chooserElement = $('#' + id + '-chooser');
|
||||
var pageTitle = chooserElement.find('.title');
|
||||
|
@ -40,3 +41,4 @@ function createPageChooser(id, pageTypes, openAtParentId, canChooseRoot, userPer
|
|||
chooserElement.addClass('blank');
|
||||
});
|
||||
}
|
||||
window.createPageChooser = createPageChooser;
|
|
@ -1,11 +1,13 @@
|
|||
'use strict';
|
||||
/* eslint-disable */
|
||||
|
||||
window.halloPlugins = {};
|
||||
|
||||
var halloPlugins = {}; // lgtm[js/unused-local-variable]
|
||||
function registerHalloPlugin(name, opts) { // lgtm[js/unused-local-variable]
|
||||
/* Obsolete - used on Wagtail <1.12 to register plugins for the hallo.js editor.
|
||||
Defined here so that third-party plugins can continue to call it to provide Wagtail <1.12
|
||||
compatibility, without throwing an error on later versions. */
|
||||
}
|
||||
window.registerHalloPlugin = registerHalloPlugin;
|
||||
|
||||
function InlinePanel(opts) { // lgtm[js/unused-local-variable]
|
||||
var self = {};
|
||||
|
@ -167,6 +169,7 @@ function InlinePanel(opts) { // lgtm[js/unused-local-variable]
|
|||
|
||||
return self;
|
||||
}
|
||||
window.InlinePanel = InlinePanel;
|
||||
|
||||
function cleanForSlug(val, useURLify) {
|
||||
if (useURLify) {
|
||||
|
@ -188,6 +191,7 @@ function cleanForSlug(val, useURLify) {
|
|||
return val.replace(/\s/g, '-').replace(/[^A-Za-z0-9\-\_]/g, '').toLowerCase();
|
||||
}
|
||||
}
|
||||
window.cleanForSlug = cleanForSlug;
|
||||
|
||||
function initSlugAutoPopulate() {
|
||||
var slugFollowsTitle = false;
|
||||
|
@ -206,6 +210,7 @@ function initSlugAutoPopulate() {
|
|||
}
|
||||
});
|
||||
}
|
||||
window.initSlugAutoPopulate = initSlugAutoPopulate;
|
||||
|
||||
function initSlugCleaning() {
|
||||
$('#id_slug').on('blur', function() {
|
||||
|
@ -213,6 +218,7 @@ function initSlugCleaning() {
|
|||
$(this).val(cleanForSlug($(this).val(), false));
|
||||
});
|
||||
}
|
||||
window.initSlugCleaning = initSlugCleaning;
|
||||
|
||||
function initErrorDetection() {
|
||||
var errorSections = {};
|
||||
|
@ -233,6 +239,7 @@ function initErrorDetection() {
|
|||
$('.tab-nav a[href="#' + index + '"]').addClass('errors').attr('data-count', errorSections[index]);
|
||||
}
|
||||
}
|
||||
window.initErrorDetection = initErrorDetection;
|
||||
|
||||
function initCollapsibleBlocks() {
|
||||
$('.object.multi-field.collapsible').each(function() {
|
||||
|
@ -253,6 +260,7 @@ function initCollapsibleBlocks() {
|
|||
});
|
||||
});
|
||||
}
|
||||
window.initCollapsibleBlocks = initCollapsibleBlocks;
|
||||
|
||||
function initKeyboardShortcuts() {
|
||||
Mousetrap.bind(['mod+p'], function(e) {
|
||||
|
@ -265,6 +273,7 @@ function initKeyboardShortcuts() {
|
|||
return false;
|
||||
});
|
||||
}
|
||||
window.initKeyboardShortcuts = initKeyboardShortcuts;
|
||||
|
||||
$(function() {
|
||||
/* Only non-live pages should auto-populate the slug from the title */
|
|
@ -1,5 +1,6 @@
|
|||
window.$ = require('./vendor/jquery-3.5.1.min');
|
||||
require('./vendor/urlify').default;
|
||||
/* eslint-disable */
|
||||
window.$ = require('../../../wagtail/admin/static_src/wagtailadmin/js/vendor/jquery-3.5.1.min');
|
||||
require('../../../wagtail/admin/static_src/wagtailadmin/js/vendor/urlify').default;
|
||||
|
||||
const cleanForSlug = require('./page-editor').cleanForSlug;
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
/* eslint-disable */
|
||||
$(function() {
|
||||
/* Interface to set permissions from the explorer / editor */
|
||||
$('button.action-set-privacy').on('click', function() {
|
|
@ -1,4 +1,5 @@
|
|||
TASK_CHOOSER_MODAL_ONLOAD_HANDLERS = {
|
||||
/* eslint-disable */
|
||||
const TASK_CHOOSER_MODAL_ONLOAD_HANDLERS = {
|
||||
'chooser': function(modal, jsonData) {
|
||||
function ajaxifyLinks (context) {
|
||||
$('a.task-type-choice, a.choose-different-task-type, a.task-choice', context).on('click', function() {
|
||||
|
@ -112,3 +113,4 @@ TASK_CHOOSER_MODAL_ONLOAD_HANDLERS = {
|
|||
modal.close();
|
||||
}
|
||||
};
|
||||
window.TASK_CHOOSER_MODAL_ONLOAD_HANDLERS = TASK_CHOOSER_MODAL_ONLOAD_HANDLERS;
|
|
@ -1,3 +1,4 @@
|
|||
/* eslint-disable */
|
||||
function createTaskChooser(id) {
|
||||
var chooserElement = $('#' + id + '-chooser');
|
||||
var taskName = chooserElement.find('.name');
|
||||
|
@ -19,3 +20,4 @@ function createTaskChooser(id) {
|
|||
});
|
||||
});
|
||||
}
|
||||
window.createTaskChooser = createTaskChooser;
|
|
@ -1,4 +1,4 @@
|
|||
'use strict';
|
||||
/* eslint-disable */
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function userBar(e) {
|
||||
var userbar = document.querySelector('[data-wagtail-userbar]');
|
|
@ -1,3 +1,4 @@
|
|||
/* eslint-disable */
|
||||
function _addHiddenInput(form, name, val) {
|
||||
var element = document.createElement('input');
|
||||
element.type = 'hidden';
|
||||
|
@ -5,6 +6,7 @@ function _addHiddenInput(form, name, val) {
|
|||
element.value = val;
|
||||
form.appendChild(element);
|
||||
}
|
||||
window._addHiddenInput = _addHiddenInput;
|
||||
|
||||
/* When a workflow action button is clicked, either show a modal or make a POST request to the workflow action view */
|
||||
function ActivateWorkflowActionsForDashboard(csrfToken) {
|
||||
|
@ -47,7 +49,7 @@ function ActivateWorkflowActionsForDashboard(csrfToken) {
|
|||
}, {capture: true});
|
||||
});
|
||||
}
|
||||
|
||||
window.ActivateWorkflowActionsForDashboard = ActivateWorkflowActionsForDashboard;
|
||||
|
||||
function ActivateWorkflowActionsForEditView(formSelector) {
|
||||
var form = $(formSelector).get(0);
|
||||
|
@ -88,3 +90,4 @@ function ActivateWorkflowActionsForEditView(formSelector) {
|
|||
}, {capture: true});
|
||||
});
|
||||
}
|
||||
window.ActivateWorkflowActionsForEditView = ActivateWorkflowActionsForEditView;
|
|
@ -1,3 +1,4 @@
|
|||
/* eslint-disable */
|
||||
$(function() {
|
||||
/* Interface to view the workflow status from the explorer / editor */
|
||||
$('button.action-workflow-status').on('click', function() {
|
|
@ -26,6 +26,39 @@ module.exports = function exports() {
|
|||
getEntryPath('admin', 'draftail.entry.js'),
|
||||
];
|
||||
|
||||
const entrypoints = [
|
||||
'blocks/list',
|
||||
'blocks/sequence',
|
||||
'blocks/stream',
|
||||
'blocks/struct',
|
||||
'core',
|
||||
'date-time-chooser',
|
||||
'expanding_formset',
|
||||
'filtered-select',
|
||||
'hallo-bootstrap',
|
||||
'hallo-plugins/hallo-hr',
|
||||
'hallo-plugins/hallo-requireparagraphs',
|
||||
'hallo-plugins/hallo-wagtaillink',
|
||||
'lock-unlock-action',
|
||||
'modal-workflow',
|
||||
'page-chooser-modal',
|
||||
'page-chooser',
|
||||
'page-editor',
|
||||
'privacy-switch',
|
||||
'task-chooser-modal',
|
||||
'task-chooser',
|
||||
'userbar',
|
||||
'workflow-action',
|
||||
'workflow-status',
|
||||
];
|
||||
|
||||
entrypoints.forEach(moduleName => {
|
||||
entry[getOutputPath('admin', moduleName)] = [
|
||||
'./client/src/utils/polyfills.js',
|
||||
`./client/src/entrypoints/${moduleName}.js`,
|
||||
];
|
||||
});
|
||||
|
||||
return {
|
||||
entry: entry,
|
||||
output: {
|
||||
|
|
Ładowanie…
Reference in New Issue