mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-20 15:36:16 -04:00
Implement require
of dependencies for all pad_*
modules.
Create a lazily-defined local reference for pad on initialization in each pad module in order to avoid circular dependency. At some point in the future this dependency should instead be injected into each module on initialization.
This commit is contained in:
parent
7f98116a43
commit
fa2a6e9ee6
11 changed files with 62 additions and 5 deletions
|
@ -34,6 +34,16 @@ settings.rtlIsTrue = false;
|
||||||
|
|
||||||
var chat = require('/chat').chat;
|
var chat = require('/chat').chat;
|
||||||
var getCollabClient = require('/collab_client').getCollabClient;
|
var getCollabClient = require('/collab_client').getCollabClient;
|
||||||
|
var padconnectionstatus = require('/pad_connectionstatus').padconnectionstatus;
|
||||||
|
var padcookie = require('/pad_cookie').padcookie;
|
||||||
|
var paddocbar = require('/pad_docbar').paddocbar;
|
||||||
|
var padeditbar = require('/pad_editbar').padeditbar;
|
||||||
|
var padeditor = require('/pad_editor').padeditor;
|
||||||
|
var padimpexp = require('/pad_impexp').padimpexp;
|
||||||
|
var padmodals = require('/pad_modals').padmodals;
|
||||||
|
var padsavedrevs = require('/pad_savedrevs').padsavedrevs;
|
||||||
|
var paduserlist = require('/pad_userlist').paduserlist;
|
||||||
|
var padutils = require('/pad_utils').padutils;
|
||||||
|
|
||||||
$(document).ready(function()
|
$(document).ready(function()
|
||||||
{
|
{
|
||||||
|
@ -275,13 +285,13 @@ function handshake()
|
||||||
{
|
{
|
||||||
$("#editorloadingbox").html("<b>You need a password to access this pad</b><br>" +
|
$("#editorloadingbox").html("<b>You need a password to access this pad</b><br>" +
|
||||||
"<input id='passwordinput' type='password' name='password'>"+
|
"<input id='passwordinput' type='password' name='password'>"+
|
||||||
"<button type='button' onclick='savePassword()'>ok</button>");
|
"<button type='button' onclick=\"" + padutils.escapeHtml('require('+JSON.stringify(module.id)+").savePassword()") + "\">ok</button>");
|
||||||
}
|
}
|
||||||
else if(obj.accessStatus == "wrongPassword")
|
else if(obj.accessStatus == "wrongPassword")
|
||||||
{
|
{
|
||||||
$("#editorloadingbox").html("<b>You're password was wrong</b><br>" +
|
$("#editorloadingbox").html("<b>You're password was wrong</b><br>" +
|
||||||
"<input id='passwordinput' type='password' name='password'>"+
|
"<input id='passwordinput' type='password' name='password'>"+
|
||||||
"<button type='button' onclick='savePassword()'>ok</button>");
|
"<button type='button' onclick=\"" + padutils.escapeHtml('require('+JSON.stringify(module.id)+").savePassword()") + "\">ok</button>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
var padmodals = require('/pad_modals').padmodals;
|
||||||
|
|
||||||
var padconnectionstatus = (function()
|
var padconnectionstatus = (function()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -85,9 +85,12 @@ var padcookie = (function()
|
||||||
var alreadyWarnedAboutNoCookies = false;
|
var alreadyWarnedAboutNoCookies = false;
|
||||||
var inited = false;
|
var inited = false;
|
||||||
|
|
||||||
|
var pad = undefined;
|
||||||
var self = {
|
var self = {
|
||||||
init: function(prefsToSet)
|
init: function(prefsToSet)
|
||||||
{
|
{
|
||||||
|
pad = require('/pad2').pad; // Sidestep circular dependency (should be injected).
|
||||||
|
|
||||||
var rawCookie = getRawCookie();
|
var rawCookie = getRawCookie();
|
||||||
if (rawCookie)
|
if (rawCookie)
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
var padutils = require('/pad_utils').padutils;
|
||||||
|
|
||||||
var paddocbar = (function()
|
var paddocbar = (function()
|
||||||
{
|
{
|
||||||
|
@ -113,11 +114,14 @@ var paddocbar = (function()
|
||||||
self.renderPassword();
|
self.renderPassword();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var pad = undefined;
|
||||||
var self = {
|
var self = {
|
||||||
title: null,
|
title: null,
|
||||||
password: null,
|
password: null,
|
||||||
init: function(opts)
|
init: function(opts)
|
||||||
{
|
{
|
||||||
|
pad = require('/pad2').pad; // Sidestep circular dependency (should be injected).
|
||||||
|
|
||||||
panels = {
|
panels = {
|
||||||
impexp: {
|
impexp: {
|
||||||
animator: getPanelOpenCloseAnimator("impexp", 160)
|
animator: getPanelOpenCloseAnimator("impexp", 160)
|
||||||
|
@ -444,6 +448,8 @@ var paddocbar = (function()
|
||||||
},
|
},
|
||||||
handleResizePage: function()
|
handleResizePage: function()
|
||||||
{
|
{
|
||||||
|
// Side-step circular reference. This should be injected.
|
||||||
|
var padsavedrevs = require('/pad_savedrevs').padsavedrevs;
|
||||||
padsavedrevs.handleResizePage();
|
padsavedrevs.handleResizePage();
|
||||||
},
|
},
|
||||||
hideLaterIfNoOtherInteraction: function()
|
hideLaterIfNoOtherInteraction: function()
|
||||||
|
|
|
@ -20,6 +20,10 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
var padutils = require('/pad_utils').padutils;
|
||||||
|
var padeditor = require('/pad_editor').padeditor;
|
||||||
|
var padsavedrevs = require('/pad_savedrevs').padsavedrevs;
|
||||||
|
|
||||||
var padeditbar = (function()
|
var padeditbar = (function()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -20,16 +20,23 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var Ace2Editor = require('/ace').Ace2Editor;
|
var padcookie = require('/pad_cookie').padcookie;
|
||||||
|
var padutils = require('/pad_utils').padutils;
|
||||||
|
|
||||||
var padeditor = (function()
|
var padeditor = (function()
|
||||||
{
|
{
|
||||||
|
var Ace2Editor = undefined;
|
||||||
|
var pad = undefined;
|
||||||
|
var settings = undefined;
|
||||||
var self = {
|
var self = {
|
||||||
ace: null,
|
ace: null,
|
||||||
// this is accessed directly from other files
|
// this is accessed directly from other files
|
||||||
viewZoom: 100,
|
viewZoom: 100,
|
||||||
init: function(readyFunc, initialViewOptions)
|
init: function(readyFunc, initialViewOptions)
|
||||||
{
|
{
|
||||||
|
Ace2Editor = require('/ace').Ace2Editor;
|
||||||
|
pad = require('/pad2').pad; // Sidestep circular dependency (should be injected).
|
||||||
|
settings = require('/pad2').settings;
|
||||||
|
|
||||||
function aceReady()
|
function aceReady()
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
var paddocbar = require('/pad_docbar').paddocbar;
|
||||||
|
|
||||||
var padimpexp = (function()
|
var padimpexp = (function()
|
||||||
{
|
{
|
||||||
|
@ -233,9 +234,16 @@ var padimpexp = (function()
|
||||||
}
|
}
|
||||||
|
|
||||||
/////
|
/////
|
||||||
|
var pad = undefined;
|
||||||
var self = {
|
var self = {
|
||||||
init: function()
|
init: function()
|
||||||
{
|
{
|
||||||
|
try {
|
||||||
|
pad = require('/pad2').pad; // Sidestep circular dependency (should be injected).
|
||||||
|
} catch (e) {
|
||||||
|
// skip (doesn't require pad when required by timeslider)
|
||||||
|
}
|
||||||
|
|
||||||
//get /p/padname
|
//get /p/padname
|
||||||
var pad_root_path = new RegExp(/.*\/p\/[^\/]+/).exec(document.location.pathname)
|
var pad_root_path = new RegExp(/.*\/p\/[^\/]+/).exec(document.location.pathname)
|
||||||
//get http://example.com/p/padname
|
//get http://example.com/p/padname
|
||||||
|
|
|
@ -20,6 +20,9 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
var padutils = require('/pad_utils').padutils;
|
||||||
|
var paddocbar = require('/pad_docbar').paddocbar;
|
||||||
|
|
||||||
var padmodals = (function()
|
var padmodals = (function()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -70,9 +73,12 @@ var padmodals = (function()
|
||||||
clearShareBoxTo();
|
clearShareBoxTo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var pad = undefined;
|
||||||
var self = {
|
var self = {
|
||||||
init: function()
|
init: function()
|
||||||
{
|
{
|
||||||
|
pad = require('/pad2').pad; // Sidestep circular dependency (should be injected).
|
||||||
|
|
||||||
self.initFeedback();
|
self.initFeedback();
|
||||||
self.initShareBox();
|
self.initShareBox();
|
||||||
},
|
},
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
var padutils = require('/pad_utils').padutils;
|
||||||
|
var paddocbar = require('/pad_docbar').paddocbar;
|
||||||
|
|
||||||
var padsavedrevs = (function()
|
var padsavedrevs = (function()
|
||||||
{
|
{
|
||||||
|
@ -39,7 +41,7 @@ var padsavedrevs = (function()
|
||||||
box.find(".srauthor").html("by " + padutils.escapeHtml(revisionInfo.savedBy));
|
box.find(".srauthor").html("by " + padutils.escapeHtml(revisionInfo.savedBy));
|
||||||
var viewLink = '/ep/pad/view/' + pad.getPadId() + '/' + revisionInfo.id;
|
var viewLink = '/ep/pad/view/' + pad.getPadId() + '/' + revisionInfo.id;
|
||||||
box.find(".srview").attr('href', viewLink);
|
box.find(".srview").attr('href', viewLink);
|
||||||
var restoreLink = 'javascript:void padsavedrevs.restoreRevision(' + rnum + ');';
|
var restoreLink = 'javascript:void(require('+JSON.stringify(module.id)+').padsavedrevs.restoreRevision(' + JSON.stringify(rnum) + ');';
|
||||||
box.find(".srrestore").attr('href', restoreLink);
|
box.find(".srrestore").attr('href', restoreLink);
|
||||||
box.find(".srname").click(function(evt)
|
box.find(".srname").click(function(evt)
|
||||||
{
|
{
|
||||||
|
@ -345,9 +347,11 @@ var padsavedrevs = (function()
|
||||||
$(document).unbind('mouseup', clearScrollRepeatTimer);
|
$(document).unbind('mouseup', clearScrollRepeatTimer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var pad = undefined;
|
||||||
var self = {
|
var self = {
|
||||||
init: function(initialRevisions)
|
init: function(initialRevisions)
|
||||||
{
|
{
|
||||||
|
pad = require('/pad2').pad; // Sidestep circular dependency (should be injected).
|
||||||
self.newRevisionList(initialRevisions, true);
|
self.newRevisionList(initialRevisions, true);
|
||||||
|
|
||||||
$("#savedrevs-savenow").click(function()
|
$("#savedrevs-savenow").click(function()
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
var padutils = require('/pad_utils').padutils;
|
||||||
|
|
||||||
var myUserInfo = {};
|
var myUserInfo = {};
|
||||||
|
|
||||||
var colorPickerOpen = false;
|
var colorPickerOpen = false;
|
||||||
|
@ -460,9 +462,12 @@ var paduserlist = (function()
|
||||||
return true;
|
return true;
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
|
var pad = undefined;
|
||||||
var self = {
|
var self = {
|
||||||
init: function(myInitialUserInfo)
|
init: function(myInitialUserInfo)
|
||||||
{
|
{
|
||||||
|
pad = require('/pad2').pad; // Sidestep circular dependency (should be injected).
|
||||||
|
|
||||||
self.setMyUserInfo(myInitialUserInfo);
|
self.setMyUserInfo(myInitialUserInfo);
|
||||||
|
|
||||||
$("#otheruserstable tr").remove();
|
$("#otheruserstable tr").remove();
|
||||||
|
@ -652,7 +657,7 @@ var paduserlist = (function()
|
||||||
if (box.length == 0)
|
if (box.length == 0)
|
||||||
{
|
{
|
||||||
// make guest prompt box
|
// make guest prompt box
|
||||||
box = $('<div id="guestprompt-' + encodedUserId + '" class="guestprompt"><div class="choices"><a href="javascript:void(paduserlist.answerGuestPrompt(\'' + encodedUserId + '\',false))">Deny</a> <a href="javascript:void(paduserlist.answerGuestPrompt(\'' + encodedUserId + '\',true))">Approve</a></div><div class="guestname"><strong>Guest:</strong> ' + padutils.escapeHtml(displayName) + '</div></div>');
|
box = $('<div id="'+padutils.escapeHtml('guestprompt-' + encodedUserId) + '" class="guestprompt"><div class="choices"><a href="' + padutils.escapeHtml('javascript:void(require('+JSON.stringify(module.id)+').paduserlist.answerGuestPrompt(' + JSON.stringify(encodedUserId) + ',false))')+'">Deny</a> <a href="' + padutils.escapeHtml('javascript:void(require('+JSON.stringify(module.id)+').paduserlist.answerGuestPrompt(' + JSON.stringify(encodedUserId) + ',true))') + '">Approve</a></div><div class="guestname"><strong>Guest:</strong> ' + padutils.escapeHtml(displayName) + '</div></div>');
|
||||||
$("#guestprompts").append(box);
|
$("#guestprompts").append(box);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -34,6 +34,7 @@ var padutils = {
|
||||||
},
|
},
|
||||||
uniqueId: function()
|
uniqueId: function()
|
||||||
{
|
{
|
||||||
|
var pad = require('/pad2').pad; // Sidestep circular dependency
|
||||||
function encodeNum(n, width)
|
function encodeNum(n, width)
|
||||||
{
|
{
|
||||||
// returns string that is exactly 'width' chars, padding with zeros
|
// returns string that is exactly 'width' chars, padding with zeros
|
||||||
|
@ -226,6 +227,7 @@ var padutils = {
|
||||||
},
|
},
|
||||||
timediff: function(d)
|
timediff: function(d)
|
||||||
{
|
{
|
||||||
|
var pad = require('/pad2').pad; // Sidestep circular dependency
|
||||||
function format(n, word)
|
function format(n, word)
|
||||||
{
|
{
|
||||||
n = Math.round(n);
|
n = Math.round(n);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue