diff --git a/www/common/toolbar.js b/www/common/toolbar.js
index a86cb102b..212480710 100644
--- a/www/common/toolbar.js
+++ b/www/common/toolbar.js
@@ -1,160 +1,88 @@
define([
- '/common/messages.js'
+ '/common/messages.js',
+ '/bower_components/jquery/dist/jquery.min.js',
], function (Messages) {
+ var $ = window.jQuery;
- /** Id of the element for getting debug info. */
- var DEBUG_LINK_CLS = 'rtwysiwyg-debug-link';
+ var Bar = {
+ constants: {},
+ };
/** Id of the div containing the user list. */
- var USER_LIST_CLS = 'rtwysiwyg-user-list';
+ var USER_LIST_CLS = Bar.constants.userlist = 'cryptpad-user-list';
/** Id of the button to change my username. */
- var USERNAME_BUTTON_GROUP = 'cryptpad-changeName';
+ var USERNAME_BUTTON_GROUP = Bar.constants.changeName = 'cryptpad-changeName';
/** Id of the div containing the lag info. */
- var LAG_ELEM_CLS = 'rtwysiwyg-lag';
+ var LAG_ELEM_CLS = Bar.constants.lag = 'cryptpad-lag';
/** The toolbar class which contains the user list, debug link and lag. */
- var TOOLBAR_CLS = 'rtwysiwyg-toolbar';
+ var TOOLBAR_CLS = Bar.constants.toolbar = 'cryptpad-toolbar';
+
+ var LEFTSIDE_CLS = Bar.constants.leftside = 'cryptpad-toolbar-leftside';
+ var RIGHTSIDE_CLS = Bar.constants.rightside = 'cryptpad-toolbar-rightside';
+
+ var BACK_CLS = Bar.constants.back = 'cryptpad-back';
+
+ var SPINNER_CLS = Bar.constants.spinner = 'cryptpad-spinner';
/** Key in the localStore which indicates realtime activity should be disallowed. */
- var LOCALSTORAGE_DISALLOW = 'rtwysiwyg-disallow';
+ // TODO remove? will never be used in cryptpad
+ var LOCALSTORAGE_DISALLOW = Bar.constants.localstorageDisallow = 'cryptpad-disallow';
var SPINNER_DISAPPEAR_TIME = 3000;
var SPINNER = [ '-', '\\', '|', '/' ];
var uid = function () {
- return 'rtwysiwyg-uid-' + String(Math.random()).substring(2);
+ return 'cryptpad-uid-' + String(Math.random()).substring(2);
+ };
+
+ var $style;
+
+ var styleToolbar = function ($container, href) {
+ href = href || '/customize/toolbar.css';
+
+ $.ajax({
+ url: href,
+ dataType: 'text',
+ success: function (data) {
+ $container.append($('
- */}.toString().slice(14,-3), {
- TOOLBAR_CLS: TOOLBAR_CLS,
- USERNAME_BUTTON_GROUP: USERNAME_BUTTON_GROUP,
- DEBUG_LINK_CLS: DEBUG_LINK_CLS,
- }).trim();
-
- toolbar.append(css);
- return toolbar;
+ $container.prepend($toolbar);
+ styleToolbar($container);
+ return $toolbar;
};
var createEscape = function ($container) {
- var id = uid();
- $container.append('
⇐ Back
');
- var $ret = $container.find('#'+id);
- $ret.on('click', function () {
+ var $back = $('
', {
+ 'class': BACK_CLS,
+ id: uid(),
+ }).html('⇐ Back').click(function () {
window.location.href = '/';
});
- return $ret[0];
+ $container.append($back);
+ return $back[0];
};
var createSpinner = function ($container) {
- var id = uid();
- $container.append('');
- return $container.find('#'+id)[0];
+ var $spinner = $('
', {
+ id: uid(),
+ 'class': SPINNER_CLS,
+ });
+ $container.append($spinner);
+ return $spinner[0];
};
var kickSpinner = function (spinnerElement, reversed) {
@@ -168,9 +96,12 @@ define([
};
var createUserList = function ($container) {
- var id = uid();
- $container.append('');
- return $container.find('#'+id)[0];
+ var $userlist = $('