From 500215ea0e76979d629af9824e13109bc58637ae Mon Sep 17 00:00:00 2001 From: webzwo0i Date: Fri, 19 Feb 2021 23:18:04 +0100 Subject: [PATCH] add files to pad.js package and avoid requiring rjquery from pad.html --- src/node/utils/tar.json | 55 +++++++++++++++++++++++++++-------------- src/static/js/pad.js | 5 ++-- src/templates/pad.html | 10 ++++---- 3 files changed, 44 insertions(+), 26 deletions(-) diff --git a/src/node/utils/tar.json b/src/node/utils/tar.json index 7ea9d5f12..055961a9e 100644 --- a/src/node/utils/tar.json +++ b/src/node/utils/tar.json @@ -1,28 +1,47 @@ { "pad.js": [ "pad.js" - , "pad_utils.js" , "browser.js" - , "pad_cookie.js" - , "pad_editor.js" - , "pad_editbar.js" - , "vendors/nice-select.js" - , "pad_modals.js" - , "pad_automatic_reconnect.js" - , "ace.js" - , "collab_client.js" - , "pad_userlist.js" - , "pad_impexp.js" - , "pad_savedrevs.js" - , "pad_connectionstatus.js" - , "chat.js" - , "gritter.js" - , "$js-cookie/src/js.cookie.js" - , "$tinycon/tinycon.js" , "farbtastic.js" + , "skiplist.js" + , "contentcollector.js" + , "scroll.js" + , "caretPosition.js" + , "undomodule.js" + , "ace2_inner.js" + , "gritter.js" + , "rjquery.js" + , "jquery.js" + , "changesettracker.js" + , "pad_utils.js" + , "pluginfw/shared.js" + , "pluginfw/client_plugins.js" + , "pluginfw/hooks.js" + , "pluginfw/plugin_defs.js" + , "chat.js" + , "$security.js" + , "security.js" + , "$unorm/lib/unorm.js" + , "ace2_common.js" + , "$tinycon/tinycon.js" + , "$js-cookie/src/js.cookie.js" + , "collab_client.js" + , "pad_cookie.js" + , "pad_connectionstatus.js" + , "pad_userlist.js" , "skin_variants.js" - , "socketio.js" + , "pad_editor.js" + , "pad_modals.js" + , "pad_editbar.js" + , "ace.js" + , "pad_savedrevs.js" + , "underscore.js" + , "$underscore/underscore.js" + , "vendors/nice-select.js" + , "pad_automatic_reconnect.js" + , "pad_impexp.js" , "colorutils.js" + , "socketio.js" ] , "timeslider.js": [ "timeslider.js" diff --git a/src/static/js/pad.js b/src/static/js/pad.js index d8aaa4fef..5c41087f4 100644 --- a/src/static/js/pad.js +++ b/src/static/js/pad.js @@ -24,9 +24,8 @@ let socket; -// These jQuery things should create local references, but for now `require()` -// assigns to the global `$` and augments it with plugins. -require('./jquery'); +// TODO: these globals should be removed when possible +window.$ = window.jQuery = require('./rjquery').$; require('./farbtastic'); require('./gritter'); diff --git a/src/templates/pad.html b/src/templates/pad.html index 58bf5fbf7..8816b3302 100644 --- a/src/templates/pad.html +++ b/src/templates/pad.html @@ -481,7 +481,8 @@ require.setLibraryURI(baseURL + "javascripts/lib"); require.setGlobalKeyPath("require"); - $ = jQuery = require('ep_etherpad-lite/static/js/rjquery').jQuery; // Expose jQuery #HACK + // intentionally moved here before first using $/jQuery + pad = require('ep_etherpad-lite/static/js/pad').pad; browser = require('ep_etherpad-lite/static/js/browser'); var plugins = require('ep_etherpad-lite/static/js/pluginfw/client_plugins'); @@ -494,13 +495,12 @@ hooks.aCallAll('documentReady'); }); - var pad = require('ep_etherpad-lite/static/js/pad'); - pad.baseURL = baseURL; - pad.init(); + const _pad = require('ep_etherpad-lite/static/js/pad'); + _pad.baseURL = baseURL; + _pad.init(); }); /* TODO: These globals shouldn't exist. */ - pad = require('ep_etherpad-lite/static/js/pad').pad; chat = require('ep_etherpad-lite/static/js/chat').chat; padeditbar = require('ep_etherpad-lite/static/js/pad_editbar').padeditbar; padimpexp = require('ep_etherpad-lite/static/js/pad_impexp').padimpexp;