Merge branch 'fontawesome' of github.com:xwiki-labs/cryptpad into fontawesome
This commit is contained in:
@@ -607,6 +607,69 @@ define([
|
||||
};
|
||||
};
|
||||
|
||||
/*
|
||||
* Buttons
|
||||
*/
|
||||
var createButton = common.createButton = function (type, rightside) {
|
||||
var button;
|
||||
var size = "17px";
|
||||
switch (type) {
|
||||
case 'export':
|
||||
button = $('<button>', {
|
||||
title: Messages.exportButtonTitle,
|
||||
'class': "fa fa-download",
|
||||
style: 'font:'+size+' FontAwesome'
|
||||
});
|
||||
break;
|
||||
case 'import':
|
||||
button = $('<button>', {
|
||||
title: Messages.importButtonTitle,
|
||||
'class': "fa fa-upload",
|
||||
style: 'font:'+size+' FontAwesome'
|
||||
});
|
||||
break;
|
||||
case 'rename':
|
||||
button = $('<button>', {
|
||||
id: 'name-pad',
|
||||
title: Messages.renameButtonTitle,
|
||||
'class': "fa fa-bookmark cryptpad-rename",
|
||||
style: 'font:'+size+' FontAwesome'
|
||||
});
|
||||
break;
|
||||
case 'forget':
|
||||
button = $('<button>', {
|
||||
id: 'cryptpad-forget',
|
||||
title: Messages.forgetButtonTitle,
|
||||
'class': "fa fa-trash cryptpad-forget",
|
||||
style: 'font:'+size+' FontAwesome'
|
||||
});
|
||||
break;
|
||||
case 'username':
|
||||
button = $('<button>', {
|
||||
title: Messages.changeNameButton,
|
||||
'class': "fa fa-user",
|
||||
style: 'font:'+size+' FontAwesome'
|
||||
});
|
||||
break;
|
||||
case 'readonly':
|
||||
button = $('<button>', {
|
||||
title: Messages.getViewButtonTitle,
|
||||
'class': "fa fa-eye",
|
||||
style: 'font:'+size+' FontAwesome'
|
||||
});
|
||||
break;
|
||||
default:
|
||||
button = $('<button>', {
|
||||
'class': "fa fa-question",
|
||||
style: 'font:'+size+' FontAwesome'
|
||||
});
|
||||
}
|
||||
if (rightside) {
|
||||
button.addClass('rightside-button')
|
||||
}
|
||||
return button;
|
||||
};
|
||||
|
||||
/*
|
||||
* Alertifyjs
|
||||
*/
|
||||
|
||||
@@ -43,6 +43,8 @@ define([
|
||||
|
||||
var $style;
|
||||
|
||||
var firstConnection = true;
|
||||
|
||||
var styleToolbar = function ($container, href) {
|
||||
href = href || '/customize/toolbar.css';
|
||||
|
||||
@@ -181,8 +183,12 @@ define([
|
||||
}
|
||||
}
|
||||
innerHTML += getViewers(numberOfViewUsers);
|
||||
if (userData[myUserName] && userData[myUserName].name) {
|
||||
innerHTML = '<span class="' + USERNAME_CLS + '">' + userData[myUserName].name + '</span> | ' + innerHTML;
|
||||
if (userData[myUserName]) {
|
||||
var name = userData[myUserName].name;
|
||||
if (!name) {
|
||||
name = '<span title="' + Messages.anonymous + '" class="fa fa-user-secret" style="font-family:FontAwesome"></span>';
|
||||
}
|
||||
innerHTML = '<span class="' + USERNAME_CLS + '">' + name + '</span> | ' + innerHTML;
|
||||
}
|
||||
listElement.innerHTML = innerHTML;
|
||||
};
|
||||
@@ -197,21 +203,31 @@ define([
|
||||
};
|
||||
|
||||
var checkLag = function (getLag, lagElement) {
|
||||
if(typeof getLag !== "function") { return; }
|
||||
var lag = getLag();
|
||||
var lagMsg = Messages.lag + ' ';
|
||||
var lag;
|
||||
if(typeof getLag === "function") {
|
||||
lag = getLag();
|
||||
}
|
||||
var lagLight = $('<div>', {
|
||||
'class': 'lag'
|
||||
});
|
||||
if(lag) {
|
||||
var lagSec = lag/1000;
|
||||
if (lag.waiting && lagSec > 1) {
|
||||
lagMsg += "?? " + Math.floor(lagSec);
|
||||
firstConnection = false;
|
||||
var title = Messages.lag + ' : ' + lag + ' ms\n';
|
||||
if (lag.waiting || lag > 1000) {
|
||||
lagLight.addClass('lag-orange');
|
||||
title += 'Your connection to the server is slow, it may impact the performance of the collaborative editor.';
|
||||
} else {
|
||||
lagMsg += lagSec;
|
||||
lagLight.addClass('lag-green');
|
||||
title += "Everything is working fine";
|
||||
}
|
||||
}
|
||||
else {
|
||||
lagMsg += "??";
|
||||
else if (!firstConnection){
|
||||
lagLight.addClass('lag-red');
|
||||
title = "You are disconnected from the server!";
|
||||
}
|
||||
lagElement.textContent = lagMsg;
|
||||
lagLight.attr('title', title);
|
||||
$(lagElement).html('');
|
||||
$(lagElement).append(lagLight);
|
||||
};
|
||||
|
||||
var create = Bar.create = function ($container, myUserName, realtime, getLag, userList, config) {
|
||||
@@ -256,6 +272,7 @@ define([
|
||||
// Try to filter out non-patch messages, doesn't have to be perfect this is just the spinner
|
||||
realtime.onMessage(function (msg) { if (msg.indexOf(':[2,') > -1) { ks(); } });
|
||||
|
||||
checkLag(getLag, lagElement);
|
||||
setInterval(function () {
|
||||
if (!connected) { return; }
|
||||
checkLag(getLag, lagElement);
|
||||
@@ -265,13 +282,13 @@ define([
|
||||
failed: function () {
|
||||
connected = false;
|
||||
userListElement.textContent = Messages.disconnected;
|
||||
lagElement.textContent = '';
|
||||
checkLag(undefined, lagElement);
|
||||
},
|
||||
reconnecting: function (userId) {
|
||||
myUserName = userId;
|
||||
connected = false;
|
||||
userListElement.textContent = Messages.reconnecting;
|
||||
lagElement.textContent = '';
|
||||
checkLag(getLag, lagElement);
|
||||
},
|
||||
connected: function () {
|
||||
connected = true;
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
}
|
||||
#pad-iframe {
|
||||
position:fixed;
|
||||
top:0px;
|
||||
top:2.5em;
|
||||
left:0px;
|
||||
bottom:0px;
|
||||
right:0px;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta content="text/html; charset=utf-8" http-equiv="content-type"/>
|
||||
<link rel="stylesheet" href="/bower_components/components-font-awesome/css/font-awesome.min.css">
|
||||
<script src="/bower_components/jquery/dist/jquery.min.js"></script>
|
||||
<script src="/bower_components/ckeditor/ckeditor.js"></script>
|
||||
</head>
|
||||
|
||||
@@ -297,13 +297,6 @@ define([
|
||||
var createChangeName = function(id, $container) {
|
||||
var buttonElmt = $container.find('#'+id)[0];
|
||||
//var lastName = getLastName();
|
||||
getLastName(function (err, lastName) {
|
||||
buttonElmt.addEventListener("click", function() {
|
||||
Cryptpad.prompt(Messages.changeNamePrompt, lastName, function (newName) {
|
||||
setName(newName);
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
var DD = new DiffDom(diffOptions);
|
||||
@@ -511,12 +504,12 @@ define([
|
||||
toolbarList = info.userList;
|
||||
var config = {
|
||||
userData: userList,
|
||||
changeNameID: Toolbar.constants.changeName,
|
||||
//changeNameID: Toolbar.constantdds.changeName,
|
||||
readOnly: readOnly
|
||||
};
|
||||
if (readOnly) {delete config.changeNameID; }
|
||||
toolbar = info.realtime.toolbar = Toolbar.create($bar, info.myID, info.realtime, info.getLag, info.userList, config);
|
||||
if (!readOnly) { createChangeName(Toolbar.constants.changeName, $bar); }
|
||||
//if (!readOnly) { createChangeName(Toolbar.constants.changeName, $bar); }
|
||||
|
||||
var $rightside = $bar.find('.' + Toolbar.constants.rightside);
|
||||
|
||||
@@ -527,22 +520,23 @@ define([
|
||||
editHash = Cryptpad.getEditHashFromKeys(info.channel, secret.keys);
|
||||
}
|
||||
|
||||
getLastName(function (err, lastName) {
|
||||
var $username = Cryptpad.createButton('username', true)
|
||||
.click(function() {
|
||||
Cryptpad.prompt(Messages.changeNamePrompt, lastName, function (newName) {
|
||||
setName(newName);
|
||||
});
|
||||
});
|
||||
$rightside.append($username);
|
||||
});
|
||||
|
||||
/* add an export button */
|
||||
var $export = $('<button>', {
|
||||
title: Messages.exportButtonTitle,
|
||||
})
|
||||
.text(Messages.exportButton)
|
||||
.addClass('rightside-button')
|
||||
.click(exportFile);
|
||||
var $export = Cryptpad.createButton('export', true).click(exportFile);
|
||||
$rightside.append($export);
|
||||
|
||||
if (!readOnly) {
|
||||
/* add an import button */
|
||||
var $import = $('<button>', {
|
||||
title: Messages.importButtonTitle
|
||||
})
|
||||
.text(Messages.importButton)
|
||||
.addClass('rightside-button')
|
||||
var $import = Cryptpad.createButton('import', true)
|
||||
.click(Cryptpad.importContent('text/plain', function (content) {
|
||||
var shjson = stringify(Hyperjson.fromDOM(domFromHTML(content).body));
|
||||
applyHjson(shjson);
|
||||
@@ -552,12 +546,7 @@ define([
|
||||
}
|
||||
|
||||
/* add a rename button */
|
||||
var $rename = $('<button>', {
|
||||
id: 'name-pad',
|
||||
title: Messages.renameButtonTitle,
|
||||
})
|
||||
.addClass('cryptpad-rename rightside-button')
|
||||
.text(Messages.renameButton)
|
||||
var $rename = Cryptpad.createButton('rename', true)
|
||||
.click(function () {
|
||||
var suggestion = suggestName();
|
||||
|
||||
@@ -584,12 +573,7 @@ define([
|
||||
$rightside.append($rename);
|
||||
|
||||
/* add a forget button */
|
||||
var $forgetPad = $('<button>', {
|
||||
id: 'cryptpad-forget',
|
||||
title: Messages.forgetButtonTitle,
|
||||
})
|
||||
.text(Messages.forgetButton)
|
||||
.addClass('cryptpad-forget rightside-button')
|
||||
var $forgetPad = Cryptpad.createButton('forget', true)
|
||||
.click(function () {
|
||||
var href = window.location.href;
|
||||
Cryptpad.confirm(Messages.forgetPrompt, function (yes) {
|
||||
@@ -604,11 +588,7 @@ define([
|
||||
|
||||
if (!readOnly && viewHash) {
|
||||
/* add a 'links' button */
|
||||
var $links = $('<button>', {
|
||||
title: Messages.getViewButtonTitle
|
||||
})
|
||||
.text(Messages.getViewButton)
|
||||
.addClass('rightside-button')
|
||||
var $links = Cryptpad.createButton('readonly', true)
|
||||
.click(function () {
|
||||
var baseUrl = window.location.origin + window.location.pathname + '#';
|
||||
var content = '<b>' + Messages.readonlyUrl + '</b><br><a>' + baseUrl + viewHash + '</a><br>';
|
||||
|
||||
Reference in New Issue
Block a user