Improve the toolbar style and the way the userlist is displayed
This commit is contained in:
@@ -19,18 +19,22 @@
|
||||
html, body {
|
||||
overflow-y: hidden;
|
||||
}
|
||||
#iframe-container {
|
||||
position: fixed;
|
||||
top: 2.5em;
|
||||
bottom: 0px;
|
||||
right: 0px;
|
||||
left: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
#pad-iframe {
|
||||
position:fixed;
|
||||
top:2.5em;
|
||||
left:0px;
|
||||
bottom:0px;
|
||||
right:0px;
|
||||
width:100%;
|
||||
height:100%;
|
||||
border:none;
|
||||
margin:0;
|
||||
padding:0;
|
||||
overflow:hidden;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
/* We use !important here to override the 96% set to the element in DecorateToolbar.js
|
||||
when we enter fullscreen mode. It allows us to avoid changing the iframe's size in JS */
|
||||
@@ -38,10 +42,16 @@
|
||||
top: 0px;
|
||||
height: 100% !important;
|
||||
}
|
||||
</style>
|
||||
#iframe-container.fullscreen {
|
||||
top: 0px;
|
||||
height: 100% !important;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<iframe id="pad-iframe" src="inner.html"></iframe>
|
||||
<div id="iframe-container">
|
||||
<iframe id="pad-iframe" src="inner.html"></iframe>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
@@ -41,6 +41,10 @@
|
||||
box-sizing: border-box;
|
||||
position: relative;
|
||||
}
|
||||
body {
|
||||
display: flex;
|
||||
flex-flow: column;
|
||||
}
|
||||
#bar > button {
|
||||
margin: 5px;
|
||||
}
|
||||
@@ -111,21 +115,11 @@
|
||||
html {
|
||||
height: 100%;
|
||||
}
|
||||
body {
|
||||
height: 100%;
|
||||
margin: 0px;
|
||||
}
|
||||
.CodeMirror {
|
||||
position: absolute;
|
||||
top: 25px;
|
||||
bottom: 0px;
|
||||
left: 0px;
|
||||
right: 0px;
|
||||
height: auto;
|
||||
height: 100%;
|
||||
}
|
||||
#cme_toolbox {
|
||||
font: 12px Arial,Helvetica,Tahoma,Verdana,sans-serif;
|
||||
height: 25px;
|
||||
background: -webkit-linear-gradient(#EEEEEE, #DADADA); /* For Safari 5.1 to 6.0 */
|
||||
background: -o-linear-gradient(white, #DDDDDD); /* For Opera 11.1 to 12.0 */
|
||||
background: -moz-linear-gradient(white, #DDDDDD); /* For Firefox 3.6 to 15 */
|
||||
|
||||
@@ -328,195 +328,6 @@ define([
|
||||
onLocal();
|
||||
};
|
||||
|
||||
var onInit = config.onInit = function (info) {
|
||||
var $bar = $('#pad-iframe')[0].contentWindow.$('#cme_toolbox');
|
||||
toolbarList = info.userList;
|
||||
var config = {
|
||||
userData: userList,
|
||||
readOnly: readOnly
|
||||
};
|
||||
if (readOnly) {delete config.changeNameID; }
|
||||
toolbar = module.toolbar = Toolbar.create($bar, info.myID, info.realtime, info.getLag, info.userList, config);
|
||||
|
||||
var $rightside = $bar.find('.' + Toolbar.constants.rightside);
|
||||
|
||||
var editHash;
|
||||
var viewHash = Cryptpad.getViewHashFromKeys(info.channel, secret.keys);
|
||||
|
||||
if (!readOnly) {
|
||||
editHash = Cryptpad.getEditHashFromKeys(info.channel, secret.keys);
|
||||
}
|
||||
|
||||
/* add a "change username" button */
|
||||
getLastName(function (err, lastName) {
|
||||
var usernameCb = function (newName) {
|
||||
setName (newName);
|
||||
};
|
||||
var $username = Cryptpad.createButton('username', true, {lastName: lastName}, usernameCb);
|
||||
$rightside.append($username);
|
||||
});
|
||||
|
||||
/* add an export button */
|
||||
var $export = Cryptpad.createButton('export', true, {}, exportText);
|
||||
$rightside.append($export);
|
||||
|
||||
if (!readOnly) {
|
||||
/* add an import button */
|
||||
var $import = Cryptpad.createButton('import', true, {}, importText);
|
||||
$rightside.append($import);
|
||||
|
||||
/* add a rename button */
|
||||
var renameCb = function (err, title) {
|
||||
if (err) { return; }
|
||||
APP.title = title;
|
||||
setTabTitle();
|
||||
onLocal();
|
||||
};
|
||||
var $setTitle = Cryptpad.createButton('rename', true, {suggestName: suggestName}, renameCb);
|
||||
$rightside.append($setTitle);
|
||||
}
|
||||
|
||||
/* add a forget button */
|
||||
var forgetCb = function (err, title) {
|
||||
if (err) { return; }
|
||||
APP.title = title;
|
||||
setTabTitle();
|
||||
};
|
||||
var $forgetPad = Cryptpad.createButton('forget', true, {}, forgetCb);
|
||||
$rightside.append($forgetPad);
|
||||
|
||||
if (!readOnly && viewHash) {
|
||||
/* add a 'links' button */
|
||||
var $links = Cryptpad.createButton('readonly', true, {viewHash: viewHash + '/present'});
|
||||
$rightside.append($links);
|
||||
}
|
||||
|
||||
var $present = Cryptpad.createButton('present', true)
|
||||
.click(function () {
|
||||
enterPresentationMode(true);
|
||||
});
|
||||
if (presentMode) {
|
||||
$present.hide();
|
||||
}
|
||||
$rightside.append($present);
|
||||
|
||||
var $leavePresent = Cryptpad.createButton('source', true)
|
||||
.click(leavePresentationMode);
|
||||
if (!presentMode) {
|
||||
$leavePresent.hide();
|
||||
}
|
||||
$rightside.append($leavePresent);
|
||||
|
||||
var $language = $('<span>', {
|
||||
'style': "margin-right: 10px;"
|
||||
}).text(Messages.type.slide + " (Markdown)");
|
||||
$rightside.append($language);
|
||||
|
||||
|
||||
var configureTheme = function () {
|
||||
/* Remember the user's last choice of theme using localStorage */
|
||||
var themeKey = 'CRYPTPAD_CODE_THEME';
|
||||
var lastTheme = localStorage.getItem(themeKey) || 'default';
|
||||
|
||||
/* Let the user select different themes */
|
||||
var $themeDropdown = $('<select>', {
|
||||
title: 'color theme',
|
||||
id: 'display-theme',
|
||||
});
|
||||
Themes.forEach(function (o) {
|
||||
$themeDropdown.append($('<option>', {
|
||||
selected: o.name === lastTheme,
|
||||
}).val(o.name).text(o.name));
|
||||
});
|
||||
|
||||
|
||||
$rightside.append($themeDropdown);
|
||||
|
||||
var $theme = $bar.find('select#display-theme');
|
||||
|
||||
setTheme(lastTheme, $theme);
|
||||
|
||||
$theme.on('change', function () {
|
||||
var theme = $theme.val();
|
||||
console.log("Setting theme to %s", theme);
|
||||
setTheme(theme, $theme);
|
||||
// remember user choices
|
||||
localStorage.setItem(themeKey, theme);
|
||||
});
|
||||
};
|
||||
|
||||
var configureColors = function () {
|
||||
$back = $('<button>', {
|
||||
id: SLIDE_BACKCOLOR_ID,
|
||||
'class': 'fa fa-square',
|
||||
'style': 'font-family: FontAwesome; color: #000;',
|
||||
title: Messages.backgroundButton + '\n' + Messages.backgroundButtonTitle
|
||||
});
|
||||
$text = $('<button>', {
|
||||
id: SLIDE_COLOR_ID,
|
||||
'class': 'fa fa-i-cursor',
|
||||
'style': 'font-family: FontAwesome; font-weight: bold; color: #fff; background: #000;',
|
||||
title: Messages.colorButton + '\n' + Messages.colorButtonTitle
|
||||
});
|
||||
$testColor = $('<input>', { type: 'color', value: '!' });
|
||||
var $check = $pad.contents().find("#colorPicker_check");
|
||||
if ($testColor.attr('type') !== "color" || $testColor.val() === '!') { return; } // TODO
|
||||
$back.on('click', function() {
|
||||
var $picker = $('<input>', { type: 'color', value: backColor })
|
||||
.on('change', function() {
|
||||
updateColors(undefined, this.value);
|
||||
onLocal();
|
||||
});
|
||||
$check.append($picker);
|
||||
setTimeout(function() {
|
||||
$picker.click();
|
||||
}, 0);
|
||||
});
|
||||
$text.on('click', function() {
|
||||
var $picker = $('<input>', { type: 'color', value: textColor })
|
||||
.on('change', function() {
|
||||
updateColors(this.value, undefined);
|
||||
onLocal();
|
||||
$check.html('');
|
||||
});
|
||||
$check.append($picker);
|
||||
setTimeout(function() {
|
||||
$picker.click();
|
||||
}, 0);
|
||||
});
|
||||
|
||||
$rightside.append($back).append($text);
|
||||
};
|
||||
|
||||
configureTheme();
|
||||
configureColors();
|
||||
|
||||
if (presentMode) {
|
||||
$('#top-bar').hide();
|
||||
}
|
||||
|
||||
// set the hash
|
||||
if (!window.location.hash || window.location.hash === '#') {
|
||||
window.location.hash = editHash;
|
||||
}
|
||||
|
||||
Cryptpad.getPadTitle(function (err, title) {
|
||||
if (err) {
|
||||
console.log("Unable to get pad title");
|
||||
console.error(err);
|
||||
return;
|
||||
}
|
||||
document.title = APP.title = title || info.channel.slice(0, 8);
|
||||
Cryptpad.setPadTitle(title, function (err, data) {
|
||||
if (err) {
|
||||
console.log("Unable to set pad title");
|
||||
console.error(err);
|
||||
return;
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
var updateTitle = function (newTitle) {
|
||||
if (newTitle === APP.title) { return; }
|
||||
// Change the title now, and set it back to the old value if there is an error
|
||||
@@ -564,6 +375,209 @@ define([
|
||||
}
|
||||
};
|
||||
|
||||
var onInit = config.onInit = function (info) {
|
||||
var $bar = $('#pad-iframe')[0].contentWindow.$('#cme_toolbox');
|
||||
toolbarList = info.userList;
|
||||
var config = {
|
||||
userData: userList,
|
||||
readOnly: readOnly,
|
||||
ifrw: $('#pad-iframe')[0].contentWindow
|
||||
};
|
||||
if (readOnly) {delete config.changeNameID; }
|
||||
toolbar = module.toolbar = Toolbar.create($bar, info.myID, info.realtime, info.getLag, info.userList, config);
|
||||
|
||||
var $rightside = $bar.find('.' + Toolbar.constants.rightside);
|
||||
var $userBlock = $bar.find('.' + Toolbar.constants.username);
|
||||
var $editShare = $bar.find('.' + Toolbar.constants.editShare);
|
||||
var $viewShare = $bar.find('.' + Toolbar.constants.viewShare);
|
||||
|
||||
var editHash;
|
||||
var viewHash = Cryptpad.getViewHashFromKeys(info.channel, secret.keys);
|
||||
|
||||
if (!readOnly) {
|
||||
editHash = Cryptpad.getEditHashFromKeys(info.channel, secret.keys);
|
||||
}
|
||||
|
||||
/* add a "change username" button */
|
||||
getLastName(function (err, lastName) {
|
||||
var usernameCb = function (newName) {
|
||||
setName (newName);
|
||||
};
|
||||
var $username = Cryptpad.createButton('username', false, {lastName: lastName}, usernameCb);
|
||||
$userBlock.append($username).hide();
|
||||
});
|
||||
|
||||
/* add an export button */
|
||||
var $export = Cryptpad.createButton('export', true, {}, exportText);
|
||||
$rightside.append($export);
|
||||
|
||||
if (!readOnly) {
|
||||
/* add an import button */
|
||||
var $import = Cryptpad.createButton('import', true, {}, importText);
|
||||
$rightside.append($import);
|
||||
|
||||
/* add a rename button */
|
||||
var renameCb = function (err, title) {
|
||||
if (err) { return; }
|
||||
APP.title = title;
|
||||
setTabTitle();
|
||||
onLocal();
|
||||
};
|
||||
var $setTitle = Cryptpad.createButton('rename', true, {suggestName: suggestName}, renameCb);
|
||||
$rightside.append($setTitle);
|
||||
}
|
||||
|
||||
/* add a forget button */
|
||||
var forgetCb = function (err, title) {
|
||||
if (err) { return; }
|
||||
APP.title = title;
|
||||
setTabTitle();
|
||||
};
|
||||
var $forgetPad = Cryptpad.createButton('forget', true, {}, forgetCb);
|
||||
$rightside.append($forgetPad);
|
||||
|
||||
if (!readOnly) {
|
||||
var $links = Cryptpad.createButton('editshare', false, {editHash: editHash});
|
||||
$editShare.append($links);
|
||||
}
|
||||
if (viewHash) {
|
||||
/* add a 'links' button */
|
||||
var $links = Cryptpad.createButton('viewshare', false, {viewHash: viewHash + '/present'});
|
||||
$viewShare.append($links);
|
||||
if (!readOnly) {
|
||||
var $links = Cryptpad.createButton('viewopen', false, {viewHash: viewHash + '/present'});
|
||||
$viewShare.append($links);
|
||||
}
|
||||
}
|
||||
|
||||
var $present = Cryptpad.createButton('present', true)
|
||||
.click(function () {
|
||||
enterPresentationMode(true);
|
||||
});
|
||||
if (presentMode) {
|
||||
$present.hide();
|
||||
}
|
||||
$rightside.append($present);
|
||||
|
||||
var $leavePresent = Cryptpad.createButton('source', true)
|
||||
.click(leavePresentationMode);
|
||||
if (!presentMode) {
|
||||
$leavePresent.hide();
|
||||
}
|
||||
$rightside.append($leavePresent);
|
||||
|
||||
|
||||
var configureTheme = function () {
|
||||
/*var $language = $('<span>', {
|
||||
'style': "margin-right: 10px;",
|
||||
'class': 'rightside-element'
|
||||
}).text("Markdown");
|
||||
$rightside.append($language);*/
|
||||
|
||||
/* Remember the user's last choice of theme using localStorage */
|
||||
var themeKey = 'CRYPTPAD_CODE_THEME';
|
||||
var lastTheme = localStorage.getItem(themeKey) || 'default';
|
||||
|
||||
/* Let the user select different themes */
|
||||
var $themeDropdown = $('<select>', {
|
||||
title: 'color theme',
|
||||
id: 'display-theme',
|
||||
'class': 'rightside-element'
|
||||
});
|
||||
Themes.forEach(function (o) {
|
||||
$themeDropdown.append($('<option>', {
|
||||
selected: o.name === lastTheme,
|
||||
}).val(o.name).text(o.name));
|
||||
});
|
||||
|
||||
|
||||
$rightside.append($themeDropdown);
|
||||
|
||||
var $theme = $bar.find('select#display-theme');
|
||||
|
||||
setTheme(lastTheme, $theme);
|
||||
|
||||
$theme.on('change', function () {
|
||||
var theme = $theme.val();
|
||||
console.log("Setting theme to %s", theme);
|
||||
setTheme(theme, $theme);
|
||||
// remember user choices
|
||||
localStorage.setItem(themeKey, theme);
|
||||
});
|
||||
};
|
||||
|
||||
var configureColors = function () {
|
||||
var $back = $('<button>', {
|
||||
id: SLIDE_BACKCOLOR_ID,
|
||||
'class': 'fa fa-square rightside-button',
|
||||
'style': 'font-family: FontAwesome; color: #000;',
|
||||
title: Messages.backgroundButton + '\n' + Messages.backgroundButtonTitle
|
||||
});
|
||||
var $text = $('<button>', {
|
||||
id: SLIDE_COLOR_ID,
|
||||
'class': 'fa fa-i-cursor rightside-button',
|
||||
'style': 'font-family: FontAwesome; font-weight: bold; color: #fff; background: #000;',
|
||||
title: Messages.colorButton + '\n' + Messages.colorButtonTitle
|
||||
});
|
||||
var $testColor = $('<input>', { type: 'color', value: '!' });
|
||||
var $check = $pad.contents().find("#colorPicker_check");
|
||||
if ($testColor.attr('type') !== "color" || $testColor.val() === '!') { return; } // TODO
|
||||
$back.on('click', function() {
|
||||
var $picker = $('<input>', { type: 'color', value: backColor })
|
||||
.on('change', function() {
|
||||
updateColors(undefined, this.value);
|
||||
onLocal();
|
||||
});
|
||||
$check.append($picker);
|
||||
setTimeout(function() {
|
||||
$picker.click();
|
||||
}, 0);
|
||||
});
|
||||
$text.on('click', function() {
|
||||
var $picker = $('<input>', { type: 'color', value: textColor })
|
||||
.on('change', function() {
|
||||
updateColors(this.value, undefined);
|
||||
onLocal();
|
||||
$check.html('');
|
||||
});
|
||||
$check.append($picker);
|
||||
setTimeout(function() {
|
||||
$picker.click();
|
||||
}, 0);
|
||||
});
|
||||
|
||||
$rightside.append($back).append($text);
|
||||
};
|
||||
|
||||
configureColors();
|
||||
configureTheme();
|
||||
|
||||
if (presentMode) {
|
||||
$('#top-bar').hide();
|
||||
}
|
||||
|
||||
// set the hash
|
||||
if (!window.location.hash || window.location.hash === '#') {
|
||||
window.location.hash = editHash;
|
||||
}
|
||||
|
||||
Cryptpad.getPadTitle(function (err, title) {
|
||||
if (err) {
|
||||
console.log("Unable to get pad title");
|
||||
console.error(err);
|
||||
return;
|
||||
}
|
||||
document.title = APP.title = title || info.channel.slice(0, 8);
|
||||
Cryptpad.setPadTitle(title, function (err, data) {
|
||||
if (err) {
|
||||
console.log("Unable to set pad title");
|
||||
console.error(err);
|
||||
return;
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
var unnotify = module.unnotify = function () {
|
||||
if (module.tabNotification &&
|
||||
typeof(module.tabNotification.cancel) === 'function') {
|
||||
|
||||
@@ -18,13 +18,6 @@ define([
|
||||
var $modal;
|
||||
var $content;
|
||||
var $pad;
|
||||
Slide.setModal = function ($m, $c, $p, iframe) {
|
||||
$modal = Slide.$modal = $m;
|
||||
$content = Slide.$content = $c;
|
||||
$pad = Slide.$pad = $p;
|
||||
ifrw = Slide.ifrw = iframe;
|
||||
addEvent();
|
||||
};
|
||||
|
||||
Slide.onChange = function (f) {
|
||||
if (typeof(f) === 'function') {
|
||||
@@ -135,6 +128,7 @@ define([
|
||||
$pad.contents().find('.cryptpad-present-button').hide();
|
||||
$pad.contents().find('.cryptpad-source-button').show();
|
||||
$pad.addClass('fullscreen');
|
||||
$('#iframe-container').addClass('fullscreen');
|
||||
$('.top-bar').hide();
|
||||
return;
|
||||
}
|
||||
@@ -143,6 +137,7 @@ define([
|
||||
$pad.contents().find('.cryptpad-present-button').show();
|
||||
$pad.contents().find('.cryptpad-source-button').hide();
|
||||
$pad.removeClass('fullscreen');
|
||||
$('#iframe-container').removeClass('fullscreen');
|
||||
$('.top-bar').show();
|
||||
$modal.removeClass('shown');
|
||||
};
|
||||
@@ -174,7 +169,7 @@ define([
|
||||
Slide.draw(i);
|
||||
};
|
||||
|
||||
var first = Slide.first = function () {$
|
||||
var first = Slide.first = function () {
|
||||
console.log('first');
|
||||
Slide.lastIndex = Slide.index;
|
||||
|
||||
@@ -210,7 +205,7 @@ define([
|
||||
break;
|
||||
case 35: // end
|
||||
Slide.last();
|
||||
break
|
||||
break;
|
||||
case 27: // esc
|
||||
show(false);
|
||||
break;
|
||||
@@ -220,5 +215,13 @@ define([
|
||||
});
|
||||
};
|
||||
|
||||
Slide.setModal = function ($m, $c, $p, iframe) {
|
||||
$modal = Slide.$modal = $m;
|
||||
$content = Slide.$content = $c;
|
||||
$pad = Slide.$pad = $p;
|
||||
ifrw = Slide.ifrw = iframe;
|
||||
addEvent();
|
||||
};
|
||||
|
||||
return Slide;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user