Small fixes for the new toolbar

This commit is contained in:
yflory
2017-06-29 15:15:40 +02:00
parent 877c5a8d0e
commit 56a25e1036
12 changed files with 300 additions and 143 deletions

View File

@@ -263,5 +263,28 @@ define([
};
};
var $fileIcon = $('<span>', {"class": "fa fa-file-text-o file icon"});
var $fileAppIcon = $('<span>', {"class": "fa fa-file-text-o file icon fileColor"});
var $padIcon = $('<span>', {"class": "fa fa-file-word-o file icon padColor"});
var $codeIcon = $('<span>', {"class": "fa fa-file-code-o file icon codeColor"});
var $slideIcon = $('<span>', {"class": "fa fa-file-powerpoint-o file icon slideColor"});
var $pollIcon = $('<span>', {"class": "fa fa-calendar file icon pollColor"});
var $whiteboardIcon = $('<span>', {"class": "fa fa-paint-brush whiteboardColor"});
UI.getIcon = function (type) {
var $icon;
switch(type) {
case 'pad': $icon = $padIcon.clone(); break;
case 'file': $icon = $fileAppIcon.clone(); break;
case 'code': $icon = $codeIcon.clone(); break;
case 'slide': $icon = $slideIcon.clone(); break;
case 'poll': $icon = $pollIcon.clone(); break;
case 'whiteboard': $icon = $whiteboardIcon.clone(); break;
default: $icon = $fileIcon.clone();
}
return $icon;
};
return UI;
});

View File

@@ -66,6 +66,7 @@ define([
common.errorLoadingScreen = UI.errorLoadingScreen;
common.notify = UI.notify;
common.unnotify = UI.unnotify;
common.getIcon = UI.getIcon;
// import common utilities for export
common.find = Util.find;
@@ -850,8 +851,9 @@ define([
common.createUsageBar = function (cb) {
// getPinnedUsage updates common.account.usage, and other values
// so we can just use those and only check for errors
var $container = $('<span>', {'class':'limit-container'});
var todo = function (err) {
var $container = $('<span>', {'class':'limit-container'});
$container.html('');
if (err) {
return void window.setTimeout(function () {
common.getPinnedUsage(todo);
@@ -867,8 +869,7 @@ define([
var $limit = $('<span>', {'class': 'cryptpad-limit-bar'}).appendTo($container);
var quota = usage/limit;
var width = Math.floor(Math.min(quota, 1)*$limit.width()); // the bar is 200px width
var $usage = $('<span>', {'class': 'usage'}).css('width', width+'px');
var $usage = $('<span>', {'class': 'usage'}).css('width', quota*100+'%');
var makeDonateButton = function () {
$('<a>', {
@@ -921,9 +922,9 @@ define([
window.setTimeout(function () {
common.getPinnedUsage(todo);
}, LIMIT_REFRESH_RATE);
cb(err, $container);
};
common.getPinnedUsage(todo);
cb(null, $container);
};
var prepareFeedback = common.prepareFeedback = function (key) {
@@ -1104,8 +1105,7 @@ define([
}
button = $('<button>', {
title: Messages.historyButton,
'class': "fa fa-history",
style: 'font:'+size+' FontAwesome'
'class': "fa fa-history history",
});
if (data.histConfig) {
button

View File

@@ -71,7 +71,7 @@ define([
$('<span>', {'class': STATE_CLS}).hide().appendTo($userContainer);
$('<span>', {'class': LAG_CLS}).hide().appendTo($userContainer);
$('<span>', {'class': LIMIT_CLS}).hide().appendTo($userContainer);
//$('<span>', {'class': NEWPAD_CLS + ' dropdown-bar'}).hide().appendTo($userContainer);
$('<span>', {'class': NEWPAD_CLS + ' dropdown-bar'}).hide().appendTo($userContainer);
$('<span>', {'class': USERADMIN_CLS + ' dropdown-bar'}).hide().appendTo($userContainer);
$toolbar.append($topContainer)
@@ -177,9 +177,8 @@ define([
var numberOfViewUsers = numberOfUsers - userList.length;
// Update the userlist
var $usersTitle = $('<h2>').text(Messages.users);
var $editUsers = $userlistContent;
$editUsers.html('').append($usersTitle);
var $editUsers = $userlistContent.find('.' + USERLIST_CLS).html('');
var $editUsersList = $('<div>', {'class': 'userlist-others'});
@@ -248,7 +247,10 @@ define([
throw new Error("You must provide a `userList` object to display the userlist");
}
var $content = $('<div>', {'class': 'userlist-drawer'});
var $closeIcon = $('<span>', {"class": "fa fa-window-close close"}).appendTo($content);
$('<h2>').text(Messages.users).appendTo($content);
$('<p>', {'class': USERLIST_CLS}).appendTo($content);
toolbar.userlistContent = $content;
var $container = $('<span>', {id: 'userButtons'});
@@ -263,13 +265,39 @@ define([
config.$contentContainer.prepend($content);
}
var $ck = config.$container.find('.cke_toolbox_main');
var hide = function () {
$content.hide();
$button.removeClass('active');
$ck.css({
'display': '',
'padding-left': '',
'margin-bottom': ''
});
};
var show = function () {
$content.show();
$button.addClass('active');
$ck.css({
'display': 'inline-block',
'padding-left': '175px',
'margin-bottom': '-3px'
});
$content.css('margin-top', (-$ck.height())+'px');
};
$closeIcon.click(hide);
$button.click(function () {
$content.toggle();
var visible = $content.is(':visible');
if (visible) { hide(); }
else { show(); }
Cryptpad.setAttribute('userlist-drawer', $content.is(':visible'));
});
Cryptpad.getAttribute('userlist-drawer', function (err, val) {
if (val === false) { $content.hide(); }
if (val === false) { return void hide(); }
show();
});
return $container;
@@ -655,9 +683,10 @@ define([
};
var createNewPad = function (toolbar) {
var $newPad = $('<span>', {
/*var $newPad = $('<span>', {
'class': NEWPAD_CLS + " dropdown-bar"
}).appendTo(toolbar.$top);
}).appendTo(toolbar.$top);*/
var $newPad = toolbar.$top.find('.'+NEWPAD_CLS).show();
var pads_options = [];
Config.availablePadTypes.forEach(function (p) {
@@ -670,17 +699,18 @@ define([
'target': '_blank',
'href': '/' + p + '/',
},
content: Messages.type[p]
content: $('<div>').append(Cryptpad.getIcon(p)).html() + Messages.type[p]
});
});
var dropdownConfig = {
text: '', // Button initial text
options: pads_options, // Entries displayed in the menu
container: $newPad
container: $newPad,
left: true
};
var $newPadBlock = Cryptpad.createDropdown(dropdownConfig);
$newPadBlock.find('button').attr('title', Messages.newButtonTitle);
$newPadBlock.find('button').addClass('fa fa-plus');
$newPadBlock.find('button').addClass('fa fa-th');
return $newPadBlock;
};