', {
- 'class': 'close fa fa-times',
+ 'class': 'cp-modal-close fa fa-times',
'title': Messages.filePicker_close
}).click(function () {
$blockContainer.hide();
}).appendTo($block);
+ $body.keydown(function (e) {
+ if (e.which === 27) { $blockContainer.hide(); }
+ });
+ return $blockContainer;
+ };
+ common.createFileDialog = function (cfg) {
+ var $blockContainer = common.createModal({
+ id: 'fileDialog',
+ $body: cfg.$body
+ });
+ var $block = $blockContainer.find('.cp-modal');
var $description = $('').text(Messages.filePicker_description);
$block.append($description);
- var $filter = $('
', {'class': 'cp-form'}).appendTo($block);
+ var $filter = $('
', {'class': 'cp-modal-form'}).appendTo($block);
var $container = $('', {'class': 'fileContainer'}).appendTo($block);
var updateContainer = function () {
$container.html('');
@@ -1483,9 +1498,6 @@ define([
$blockContainer.hide();
}));
updateContainer();
- $body.keydown(function (e) {
- if (e.which === 27) { $blockContainer.hide(); }
- });
$blockContainer.show();
};
diff --git a/www/common/file-dialog.less b/www/common/file-dialog.less
index 936152f8b..99bd49f0b 100644
--- a/www/common/file-dialog.less
+++ b/www/common/file-dialog.less
@@ -1,63 +1,8 @@
@import (once) '../customize/src/less2/include/colortheme.less';
+@import '../customize/src/less2/include/modal.less';
#fileDialog {
- display: none;
-
- z-index: 100000;
- position: absolute;
- top: 0;
- bottom: 0;
- left: 0;
- right: 0;
- background-color: @colortheme_modal-dim;
-
.cp-modal {
- background-color: @colortheme_modal-bg;
- color: @colortheme_modal-fg;
- box-shadow: @colortheme_modal-shadow;
-
- padding: @colortheme_modal-padding;
-
- position: absolute;
- top: 15vh; bottom: 15vh;
- left: 10vw; right: 10vw;
-
- overflow: auto;
-
- font-family: @colortheme_font;
- text-align: center;
-
- & > p {
- margin-bottom: 1em;
- }
-
- .cp-form {
- display: flex;
- flex-wrap: wrap;
- align-items: center;
- justify-content: center;
- }
-
- input {
- background-color: @colortheme_modal-input;
- color: @colortheme_modal-fg;
- border: 0;
- padding: 8px 12px;
- margin: 1em;
- width: 300px;
- }
-
- .close {
- text-shadow: none;
- color: inherit;
-
- position: absolute;
- top: 0;
- right: 0;
- margin: @colortheme_modal-padding;
- cursor: pointer;
- }
-
.fileContainer {
display: flex;
flex-wrap: wrap;
diff --git a/www/common/rpc.js b/www/common/rpc.js
index f088ec0fd..9f04d7663 100644
--- a/www/common/rpc.js
+++ b/www/common/rpc.js
@@ -24,6 +24,10 @@ types of messages:
var hkn = network.historyKeeper;
var txid = uid();
+ if (typeof(cb) !== 'function') {
+ return console.error('expected callback');
+ }
+
var pending = ctx.pending[txid] = function (err, response) {
cb(err, response);
};
diff --git a/www/contacts/main.js b/www/contacts/main.js
index 4803a812a..29583c07e 100644
--- a/www/contacts/main.js
+++ b/www/contacts/main.js
@@ -4,9 +4,12 @@ define([
'/common/toolbar2.js',
'/common/cryptpad-common.js',
+ '/common/common-messenger.js',
+ '/contacts/messenger-ui.js',
+
'css!/bower_components/components-font-awesome/css/font-awesome.min.css',
'less!/customize/src/less/cryptpad.less',
-], function ($, Crypto, Toolbar, Cryptpad) {
+], function ($, Crypto, Toolbar, Cryptpad, Messenger, UI) {
var Messages = Cryptpad.Messages;
var APP = window.APP = {
@@ -20,7 +23,6 @@ define([
var ifrw = $('#pad-iframe')[0].contentWindow;
var $iframe = $('#pad-iframe').contents();
- //var $appContainer = $iframe.find('#app');
var $list = $iframe.find('#friendList');
var $messages = $iframe.find('#messaging');
var $bar = $iframe.find('.toolbar-container');
@@ -40,28 +42,20 @@ define([
Cryptpad.getProxy().on('disconnect', function () {
Cryptpad.alert(Messages.common_connectionLost, undefined, true);
- Cryptpad.enableMessaging(false);
});
Cryptpad.getProxy().on('reconnect', function (uid) {
console.error('reconnecting: ', uid);
Cryptpad.findOKButton().click();
-
- APP.messenger.cleanFriendChannels();
- APP.messenger.openFriendChannels();
- APP.messenger.setEditable(true);
});
- var ui = APP.ui = Cryptpad.initMessagingUI(Cryptpad, $list, $messages);
- APP.messenger = Cryptpad.initMessaging(Cryptpad, ui);
-
var $infoBlock = $('', {'class': 'info'}).appendTo($messages);
$('
').text(Messages.contacts_info1).appendTo($infoBlock);
var $ul = $('').appendTo($infoBlock);
$('- ').text(Messages.contacts_info2).appendTo($ul);
$('
- ').text(Messages.contacts_info3).appendTo($ul);
- //$('
- ').text(Messages.contacts_info4).appendTo($ul);
- Cryptpad.removeLoadingScreen();
+ var messenger = window.messenger = Messenger.messenger(Cryptpad);
+ UI.create(messenger, $list, $messages);
};
Cryptpad.ready(function () {
diff --git a/www/contacts2/messenger-ui.js b/www/contacts/messenger-ui.js
similarity index 96%
rename from www/contacts2/messenger-ui.js
rename to www/contacts/messenger-ui.js
index 573ac2110..b2ce5cd9c 100644
--- a/www/contacts2/messenger-ui.js
+++ b/www/contacts/messenger-ui.js
@@ -242,7 +242,13 @@ define([
var $status = find.inList(curvePublic).find('.status');
// FIXME this stopped working :(
messenger.getStatus(curvePublic, function (e, online) {
- if (e) { return void console.error(curvePublic, e); }
+ // if error maybe you shouldn't display this friend...
+ if (e) {
+ find.inList(curvePublic).hide();
+ getChat(curvePublic).hide();
+
+ return void console.error(curvePublic, e);
+ }
if (online) {
return void $status
.removeClass('offline').addClass('online');
@@ -286,14 +292,11 @@ define([
var removeFriend = function (curvePublic) {
messenger.removeFriend(curvePublic, function (e, removed) {
if (e) { return void console.error(e); }
+ find.inList(curvePublic).remove();
console.log(removed);
});
};
-/* var friendExistsInUserList = function (curvePublic) {
- return !!$userlist.find(dataQuery(curvePublic)).length;
- }; */
-
markup.friend = function (data) {
var curvePublic = data.curvePublic;
var friend = h('div.friend.avatar', {
@@ -323,7 +326,9 @@ define([
Cryptpad.fixHTML(data.displayName)
]), function (yes) {
if (!yes) { return; }
- removeFriend(curvePublic);
+ removeFriend(curvePublic, function (e) {
+ if (e) { return void console.error(e); }
+ });
// TODO remove friend from userlist ui
// FIXME seems to trigger EJOINED from netflux-websocket (from server);
// (tried to join a channel in which you were already present)
@@ -384,19 +389,16 @@ define([
});
messenger.on('join', function (curvePublic, channel) {
- //console.log('join', curvePublic, channel);
channel = channel;
updateStatus(curvePublic);
});
messenger.on('leave', function (curvePublic, channel) {
- //console.log('leave', curvePublic, channel);
channel = channel;
updateStatus(curvePublic);
});
// change in your friend list
messenger.on('update', function (info, curvePublic) {
- console.log(info, curvePublic);
var name = displayNames[curvePublic] = info.displayName;
// update label in friend list
@@ -407,6 +409,10 @@ define([
dataQuery(curvePublic) + ' div.sender').text(name).text(name);
});
+ messenger.on('unfriend', function (curvePublic) {
+ console.log(curvePublic);
+ });
+
Cryptpad.onDisplayNameChanged(function () {
messenger.checkNewFriends();
messenger.updateMyData();
diff --git a/www/contacts2/index.html b/www/contacts2/index.html
deleted file mode 100644
index a76879a6d..000000000
--- a/www/contacts2/index.html
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
- CryptPad
-
-
-
-
-
-
-
-
diff --git a/www/contacts2/inner.html b/www/contacts2/inner.html
deleted file mode 100644
index ebfb164c8..000000000
--- a/www/contacts2/inner.html
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/www/contacts2/main.js b/www/contacts2/main.js
deleted file mode 100644
index 664ffc333..000000000
--- a/www/contacts2/main.js
+++ /dev/null
@@ -1,75 +0,0 @@
-define([
- 'jquery',
- '/bower_components/chainpad-crypto/crypto.js',
- '/common/toolbar2.js',
- '/common/cryptpad-common.js',
-
- '/common/common-messenger.js',
- '/contacts2/messenger-ui.js',
-
- 'css!/bower_components/components-font-awesome/css/font-awesome.min.css',
- 'less!/customize/src/less/cryptpad.less',
-], function ($, Crypto, Toolbar, Cryptpad, Messenger, UI) {
- var Messages = Cryptpad.Messages;
-
- var APP = window.APP = {
- Cryptpad: Cryptpad
- };
-
- $(function () {
-
- var andThen = function () {
- Cryptpad.addLoadingScreen();
-
- var ifrw = $('#pad-iframe')[0].contentWindow;
- var $iframe = $('#pad-iframe').contents();
- //var $appContainer = $iframe.find('#app');
- var $list = $iframe.find('#friendList');
- var $messages = $iframe.find('#messaging');
- var $bar = $iframe.find('.toolbar-container');
-
- var displayed = ['useradmin', 'newpad', 'limit', 'pageTitle'];
-
-
- var configTb = {
- displayed: displayed,
- ifrw: ifrw,
- common: Cryptpad,
- $container: $bar,
- network: Cryptpad.getNetwork(),
- pageTitle: Messages.contacts_title,
- };
- var toolbar = APP.toolbar = Toolbar.create(configTb);
- toolbar.$rightside.html(''); // Remove the drawer if we don't use it to hide the toolbar
-
- Cryptpad.getProxy().on('disconnect', function () {
- Cryptpad.alert(Messages.common_connectionLost, undefined, true);
- Cryptpad.enableMessaging(false);
- });
- Cryptpad.getProxy().on('reconnect', function (uid) {
- console.error('reconnecting: ', uid);
- Cryptpad.findOKButton().click();
-
- //APP.messenger.cleanFriendChannels();
- //APP.messenger.openFriendChannels();
- //APP.messenger.setEditable(true);
- });
-
- var $infoBlock = $('
', {'class': 'info'}).appendTo($messages);
- $('
').text(Messages.contacts_info1).appendTo($infoBlock);
- var $ul = $('').appendTo($infoBlock);
- $('- ').text(Messages.contacts_info2).appendTo($ul);
- $('
- ').text(Messages.contacts_info3).appendTo($ul);
- //$('
- ').text(Messages.contacts_info4).appendTo($ul);
-
- var messenger = window.messenger = Messenger.messenger(Cryptpad);
- UI.create(messenger, $list, $messages);
- };
-
- Cryptpad.ready(function () {
- andThen();
- Cryptpad.reportAppUsage();
- });
-
- });
-});
diff --git a/www/drive/file.less b/www/drive/file.less
index 41896d755..7cb891419 100644
--- a/www/drive/file.less
+++ b/www/drive/file.less
@@ -506,9 +506,9 @@ span {
}
.fa {
cursor: pointer;
- font-size: 100px;
- line-height: 140px;
- margin: 0;
+ font-size: 90px;
+ margin-top: 5px;
+ margin-bottom: 0;
}
}
}
@@ -597,6 +597,34 @@ span {
flex: 1;
}
+#addPadDialog.cp-modal-container {
+ .fileIcon;
+
+ li:not(.selected):hover {
+ border: 1px solid white;
+ }
+ .cp-modal {
+ display: flex;
+ flex-flow: column;
+ li, li .fa {
+ cursor: pointer;
+ }
+ &> p {
+ margin: 50px;
+ }
+ &> div {
+ display: flex;
+ flex-wrap: wrap;
+ justify-content: center;
+ align-content: center;
+ .uploadFile {
+ break-after: always;
+ page-break-after: always;
+ }
+ }
+ }
+}
+
/* Toolbar */
diff --git a/www/drive/main.js b/www/drive/main.js
index 97d67a03d..e611579ca 100644
--- a/www/drive/main.js
+++ b/www/drive/main.js
@@ -52,7 +52,7 @@ define([
var TRASH = "trash";
var TRASH_NAME = Messages.fm_trashName;
var RECENT = "recent";
- var RECENT_NAME = "Recent pads";
+ var RECENT_NAME = Messages.fm_recentPadsName;
var LOCALSTORAGE_LAST = "cryptpad-file-lastOpened";
var LOCALSTORAGE_OPENED = "cryptpad-file-openedFolders";
@@ -163,6 +163,7 @@ define([
//var $upIcon = $('', {"class": "fa fa-arrow-circle-up"});
var $unsortedIcon = $('', {"class": "fa fa-files-o"});
var $templateIcon = $('', {"class": "fa fa-cubes"});
+ var $recentIcon = $('', {"class": "fa fa-clock-o"});
var $trashIcon = $('', {"class": "fa fa-trash-o"});
var $trashEmptyIcon = $('', {"class": "fa fa-trash-o"});
//var $collapseIcon = $('', {"class": "fa fa-minus-square-o expcol"});
@@ -1324,7 +1325,7 @@ define([
msg = Messages.fm_info_allFiles;
break;
case RECENT:
- msg = Messages.fm_info_recent || 'TODO';
+ msg = Messages.fm_info_recent;
break;
default:
msg = undefined;
@@ -1388,10 +1389,63 @@ define([
$container.append($listButton).append($gridButton);
};
+ var getNewPadTypes = function () {
+ var arr = [];
+ AppConfig.availablePadTypes.forEach(function (type) {
+ if (type === 'drive') { return; }
+ if (type === 'contacts') { return; }
+ if (type === 'todo') { return; }
+ if (type === 'file') { return; }
+ if (!Cryptpad.isLoggedIn() && AppConfig.registeredOnlyTypes &&
+ AppConfig.registeredOnlyTypes.indexOf(type) !== -1) {
+ return;
+ }
+ arr.push(type);
+ });
+ return arr;
+ };
+ var addNewPadHandlers = function ($block, isInRoot) {
+ // Handlers
+ if (isInRoot) {
+ var onCreated = function (err, info) {
+ if (err) {
+ if (err === E_OVER_LIMIT) {
+ return void Cryptpad.alert(Messages.pinLimitDrive, null, true);
+ }
+ return void Cryptpad.alert(Messages.fm_error_cantPin);
+ }
+ module.newFolder = info.newPath;
+ refresh();
+ };
+ $block.find('a.newFolder, li.newFolder').click(function () {
+ filesOp.addFolder(currentPath, null, onCreated);
+ });
+ $block.find('a.uploadFile, li.uploadFile').click(function () {
+ var $input = $('', {
+ 'type': 'file',
+ 'style': 'display: none;'
+ }).on('change', function (e) {
+ var file = e.target.files[0];
+ var ev = {
+ target: $content[0]
+ };
+ APP.FM.handleFile(file, ev);
+ });
+ $input.click();
+ });
+ }
+ $block.find('a.newdoc, li.newdoc').click(function () {
+ var type = $(this).attr('data-type') || 'pad';
+ sessionStorage[Cryptpad.newPadPathKey] = filesOp.isPathIn(currentPath, [TRASH]) ? '' : currentPath;
+ window.open('/' + type + '/');
+ });
+ };
var createNewButton = function (isInRoot, $container) {
if (!APP.editable) { return; }
if (!APP.loggedIn) { return; } // Anonymous users can use the + menu in the toolbar
+ if (!filesOp.isPathIn(currentPath, [ROOT, 'hrefArray'])) { return; }
+
// Create dropdown
var options = [];
if (isInRoot) {
@@ -1408,13 +1462,7 @@ define([
});
options.push({tag: 'hr'});
}
- AppConfig.availablePadTypes.forEach(function (type) {
- if (type === 'drive') { return; }
- if (type === 'contacts') { return; }
- if (!Cryptpad.isLoggedIn() && AppConfig.registeredOnlyTypes &&
- AppConfig.registeredOnlyTypes.indexOf(type) !== -1) {
- return;
- }
+ getNewPadTypes().forEach(function (type) {
var attributes = {
'class': 'newdoc',
'data-type': type,
@@ -1440,40 +1488,7 @@ define([
$block.find('button').addClass('new');
$block.find('button').attr('title', Messages.fm_newButtonTitle);
- // Handlers
- if (isInRoot) {
- var onCreated = function (err, info) {
- if (err) {
- if (err === E_OVER_LIMIT) {
- return void Cryptpad.alert(Messages.pinLimitDrive, null, true);
- }
- return void Cryptpad.alert(Messages.fm_error_cantPin);
- }
- module.newFolder = info.newPath;
- refresh();
- };
- $block.find('a.newFolder').click(function () {
- filesOp.addFolder(currentPath, null, onCreated);
- });
- $block.find('a.uploadFile').click(function () {
- var $input = $('', {
- 'type': 'file',
- 'style': 'display: none;'
- }).on('change', function (e) {
- var file = e.target.files[0];
- var ev = {
- target: $content[0]
- };
- APP.FM.handleFile(file, ev);
- });
- $input.click();
- });
- }
- $block.find('a.newdoc').click(function () {
- var type = $(this).attr('data-type') || 'pad';
- sessionStorage[Cryptpad.newPadPathKey] = filesOp.isPathIn(currentPath, [TRASH]) ? '' : currentPath;
- window.open('/' + type + '/');
- });
+ addNewPadHandlers($block, isInRoot);
$container.append($block);
};
@@ -1646,6 +1661,58 @@ define([
return keys;
};
+ // Create the ghost icon to add pads/folders
+ var createNewPadIcons = function ($block, isInRoot) {
+ var $container = $('
');
+ if (isInRoot) {
+ // Folder
+ var $element1 = $('
- ', {
+ 'class': 'newFolder element-row grid-element'
+ }).prepend($folderIcon.clone()).appendTo($container);
+ $element1.append($('', {'class': 'name'}).text(Messages.fm_folder));
+ // File
+ var $element2 = $('
- ', {
+ 'class': 'uploadFile element-row grid-element'
+ }).prepend(getIcon('file')).appendTo($container);
+ $element2.append($('', {'class': 'name'}).text(Messages.uploadButton));
+ }
+ // Pads
+ getNewPadTypes().forEach(function (type) {
+ var $element = $('
- ', {
+ 'class': 'newdoc element-row grid-element'
+ }).prepend(getIcon(type)).appendTo($container);
+ $element.append($('', {'class': 'name'}).text(Messages.type[type]));
+ $element.attr('data-type', type);
+ });
+
+ $container.find('.element-row').click(function () {
+ $block.hide();
+ });
+ return $container;
+ };
+ var createGhostIcon = function ($list) {
+ var isInRoot = currentPath[0] === ROOT;
+ var $element = $('
- ', {
+ 'class': 'element-row grid-element addpad'
+ }).prepend($addIcon.clone()).appendTo($list);
+ $element.append($('', {'class': 'name'}).text(Messages.fm_newFile));
+ $element.attr('title', Messages.fm_newFile);
+ $element.click(function () {
+ var $modal = Cryptpad.createModal({
+ id: 'addPadDialog',
+ $body: $iframe.find('body')
+ });
+ var $title = $('
').text(Messages.fm_newFile);
+ var $description = $('
').text(Messages.fm_newButtonTitle);
+ $modal.find('.cp-modal').append($title);
+ $modal.find('.cp-modal').append($description);
+ var $content = createNewPadIcons($modal, isInRoot);
+ $modal.find('.cp-modal').append($content);
+ $modal.show();
+ addNewPadHandlers($modal, isInRoot);
+ });
+ };
+
// Drive content toolbar
var createToolbar = function () {
var $toolbar = $driveToolbar;
@@ -1704,6 +1771,7 @@ define([
}
$container.append($element);
});
+ createGhostIcon($container);
};
var displayAllFiles = function ($container) {
@@ -1997,22 +2065,8 @@ define([
$element.appendTo($list);
});
- var $element = $('
- ', {
- 'class': 'element-row grid-element addpad'
- }).prepend($addIcon.clone()).appendTo($list);
- $element.attr('title', "TODO: Add a pad");
- $element.click(function () {
- window.setTimeout(function () {
- $driveToolbar.find('.leftside .dropdown-bar-content').show();
- });
- /*var $content = $driveToolbar.find('.leftside .dropdown-bar-content').html();
- var $container = $('
').append($('
', {id:'cryptpad-add-pad'}));
- Cryptpad.alert($container.html(),null,true);
- var $c = $('body > .alertify').last().find('#cryptpad-add-pad');
- $c.append($content);*/
- });
+ createGhostIcon($list);
}
- //$content.append($toolbar).append($title).append($info).append($dirContent);
$content.append($info).append($dirContent);
var $truncated = $('', {'class': 'truncated'}).text('...');
@@ -2168,7 +2222,7 @@ define([
};
var createRecent = function ($container, path) {
- var $icon = $templateIcon.clone(); //TODO
+ var $icon = $recentIcon.clone();
var isOpened = filesOp.comparePath(path, currentPath);
var $element = createTreeElement(RECENT_NAME, $icon, [RECENT], false, false, false, isOpened);
$element.addClass('root');