Use the new toolbar and move the userlist code in a separate file
This commit is contained in:
@@ -41,6 +41,7 @@ define([
|
||||
var ret = {};
|
||||
|
||||
if (!href) { return ret; }
|
||||
if (href.slice(-1) !== '/') { href += '/'; }
|
||||
|
||||
if (!/^https*:\/\//.test(href)) {
|
||||
var idx = href.indexOf('/#');
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
define([
|
||||
'jquery',
|
||||
'/common/cryptget.js',
|
||||
], function ($, Cryptget) {
|
||||
], function ($) {
|
||||
var module = {};
|
||||
|
||||
module.create = function (info, onLocal, Cryptpad) {
|
||||
module.create = function (info, onLocal, Cryptget, Cryptpad) {
|
||||
var exp = {};
|
||||
|
||||
var userData = exp.userData = {};
|
||||
@@ -13,6 +12,9 @@ define([
|
||||
var myUserName = exp.myUserName = info.myID;
|
||||
var myNetfluxId = exp.myNetfluxId = info.myID;
|
||||
|
||||
var parsed = Cryptpad.parsePadUrl(window.location.href);
|
||||
var appType = parsed ? parsed.type : undefined;
|
||||
|
||||
var users = userList.users;
|
||||
var addToUserData = exp.addToUserData = function(data) {
|
||||
for (var attrname in data) { userData[attrname] = data[attrname]; }
|
||||
@@ -41,7 +43,7 @@ define([
|
||||
var setName = exp.setName = function (newName, cb) {
|
||||
if (typeof(newName) !== 'string') { return; }
|
||||
var myUserNameTemp = newName.trim();
|
||||
if(newName.trim().length > 32) {
|
||||
if(myUserNameTemp.length > 32) {
|
||||
myUserNameTemp = myUserNameTemp.substr(0, 32);
|
||||
}
|
||||
myUserName = myUserNameTemp;
|
||||
@@ -56,7 +58,7 @@ define([
|
||||
console.error(err);
|
||||
return;
|
||||
}
|
||||
if (typeof cb === "function") { onLocal(); }
|
||||
if (typeof cb === "function") { cb(); }
|
||||
});
|
||||
};
|
||||
|
||||
@@ -80,8 +82,8 @@ define([
|
||||
onLocal();
|
||||
$changeNameButton.click();
|
||||
}
|
||||
if (isNew) {
|
||||
Cryptpad.selectTemplate('code', info.realtime, Cryptget);
|
||||
if (isNew && appType) {
|
||||
Cryptpad.selectTemplate(appType, info.realtime, Cryptget);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -558,7 +558,8 @@ define([
|
||||
$userButton.click(function (e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
Cryptpad.getLastName(function (lastName) {
|
||||
Cryptpad.getLastName(function (err, lastName) {
|
||||
if (err) { return void console.error("Cannot get last name", err); }
|
||||
Cryptpad.prompt(Messages.changeNamePrompt, lastName || '', function (newName) {
|
||||
if (newName === null && typeof(lastName) === "string") { return; }
|
||||
if (newName === null) { newName = ''; }
|
||||
|
||||
@@ -102,7 +102,7 @@ define([
|
||||
var checkSynchronizing = function (toolbar, config) {
|
||||
if (!toolbar.state) { return; }
|
||||
var userList = config.userList.list.users;
|
||||
var userNetfluxId = config.userList.userNetfluxId; // TODO
|
||||
var userNetfluxId = config.userList.userNetfluxId;
|
||||
var meIdx = userList.indexOf(userNetfluxId);
|
||||
if (meIdx === -1) {
|
||||
toolbar.state.text(Messages.synchronizing);
|
||||
@@ -113,7 +113,7 @@ define([
|
||||
var getOtherUsers = function(config) {
|
||||
var userList = config.userList.list.users;
|
||||
var userData = config.userList.data;
|
||||
var userNetfluxId = config.userList.userNetfluxId; // TODO
|
||||
var userNetfluxId = config.userList.userNetfluxId;
|
||||
|
||||
var i = 0; // duplicates counter
|
||||
var list = [];
|
||||
@@ -260,8 +260,6 @@ define([
|
||||
$block.attr('id', 'userButtons');
|
||||
toolbar.$leftside.prepend($block);
|
||||
|
||||
initUserList(toolbar, config);
|
||||
|
||||
return $block;
|
||||
};
|
||||
|
||||
@@ -596,7 +594,7 @@ define([
|
||||
'class': 'synced fa fa-check',
|
||||
title: Messages.synced
|
||||
}).appendTo($spin);
|
||||
toolbar.$userAdmin.prepend($spin); // TODO: put at the corretc position in userAdmin
|
||||
toolbar.$userAdmin.prepend($spin);
|
||||
if (config.realtime) {
|
||||
config.realtime.onPatch(ks(toolbar, config));
|
||||
config.realtime.onMessage(ks(toolbar, config, true));
|
||||
@@ -677,7 +675,8 @@ define([
|
||||
$userButton.click(function (e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
Cryptpad.getLastName(function (lastName) {
|
||||
Cryptpad.getLastName(function (err, lastName) {
|
||||
if (err) { return void console.error("Cannot get last name", err); }
|
||||
Cryptpad.prompt(Messages.changeNamePrompt, lastName || '', function (newName) {
|
||||
if (newName === null && typeof(lastName) === "string") { return; }
|
||||
if (newName === null) { newName = ''; }
|
||||
@@ -844,7 +843,7 @@ define([
|
||||
tb['userlist'] = createUserList;
|
||||
tb['share'] = createShare;
|
||||
tb['fileshare'] = createFileShare;
|
||||
tb['title'] = createTitle; // TODO: New one, add it to the displayed in main.js ?
|
||||
tb['title'] = createTitle;
|
||||
tb['lag'] = createLag;
|
||||
tb['spinner'] = createSpinner;
|
||||
tb['state'] = createState;
|
||||
@@ -866,6 +865,7 @@ define([
|
||||
};
|
||||
|
||||
addElement(config.displayed, {}, true);
|
||||
initUserList(toolbar, config);
|
||||
|
||||
toolbar['linkToMain'] = createLinkToMain(toolbar, config);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user