', {
- 'class': 'cp-modal-close fa fa-times',
- 'title': Messages.filePicker_close
- }).click(hide).appendTo($block);
- $body.click(hide);
- $block.click(function (e) {
- e.stopPropagation();
- });
- $body.keydown(function (e) {
- if (e.which === 27) {
- 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-modal-form'}).appendTo($block);
- var $container = $('', {'class': 'fileContainer'}).appendTo($block);
- var updateContainer = function () {
- $container.html('');
- var filter = $filter.find('.filter').val().trim();
- var list = common.getUserFilesList();
- var fo = common.getFO();
- list.forEach(function (id) {
- var data = fo.getFileData(id);
- var name = fo.getTitle(id);
- if (filter && name.toLowerCase().indexOf(filter.toLowerCase()) === -1) {
- return;
- }
- var $span = $('', {
- 'class': 'element',
- 'title': name,
- }).appendTo($container);
- $span.append(getFileIcon(data));
- $span.append(name);
- $span.click(function () {
- if (typeof cfg.onSelect === "function") { cfg.onSelect(data.href); }
- $blockContainer.hide();
- });
- });
- };
- var to;
- $('', {
- type: 'text',
- 'class': 'filter',
- 'placeholder': Messages.filePicker_filter
- }).appendTo($filter).on('keypress', function () {
- if (to) { window.clearTimeout(to); }
- to = window.setTimeout(updateContainer, 300);
- });
- //$filter.append(' '+Messages.or+' ');
- var data = {FM: cfg.data.FM};
- $filter.append(common.createButton('upload', false, data, function () {
- $blockContainer.hide();
- }));
- updateContainer();
- $blockContainer.show();
- };
-
-
-
-
common.getShareHashes = function (secret, cb) {
if (!window.location.hash) {
var hashes = common.getHashes(secret.channel, secret);
@@ -1443,7 +1288,6 @@ define([
(parseInt(verArr[0]) === parseInt(storedArr[0]) &&
parseInt(verArr[1]) > parseInt(storedArr[1]));
if (!shouldUpdate) { return; }
- //UI.alert(Messages._getKey('newVersion', [verArr.join('.')]), null, true);
localStorage[CRYPTPAD_VERSION] = ver;
};
@@ -1464,12 +1308,6 @@ define([
common.initialPath = sessionStorage[newPadPathKey];
delete sessionStorage[newPadPathKey];
}
- common.onFriendRequest = function (confirmText, cb) {
- UI.confirm(confirmText, cb, null, true);
- };
- common.onFriendComplete = function (data) {
- UI.log(data.logText);
- };
var proxy;
var network;
@@ -1515,12 +1353,6 @@ define([
}).nThen(function (waitFor) {
$(waitFor());
}).nThen(function (waitFor) {
- // Race condition : if document.body is undefined when alertify.js is loaded, Alertify
- // won't work. We have to reset it now to make sure it uses a correct "body"
- UI.Alertify.reset();
- // clear any tooltips that might get hung
- setInterval(function () { common.clearTooltips(); }, 5000);
-
// Load the new pad when the hash has changed
var oldHref = document.location.href;
window.onhashchange = function () {
@@ -1644,7 +1476,6 @@ define([
}
}).nThen(function () {
updateLocalVersion();
- common.addTooltips();
f(void 0, env);
if (typeof(window.onhashchange) === 'function') { window.onhashchange(); }
});
diff --git a/www/common/fsStore.js b/www/common/fsStore.js
index e554ca1de..df56e849a 100644
--- a/www/common/fsStore.js
+++ b/www/common/fsStore.js
@@ -312,12 +312,13 @@ define([
} else if (o && !n) {
$(window).on('keyup', function (e) {
if (e.keyCode === 27) {
- Cryptpad.removeLoadingScreen();
+ //UI.removeLoadingScreen();
}
});
Cryptpad.logout();
- Cryptpad.addLoadingScreen({hideTips: true});
- Cryptpad.errorLoadingScreen(Cryptpad.Messages.onLogout, true);
+ UI.alert(Cryptpad.Messages.onLogout, null, true);
+ //UI.addLoadingScreen({hideTips: true});
+ //UI.errorLoadingScreen(Cryptpad.Messages.onLogout, true);
if (exp.info) {
exp.info.network.disconnect();
}
diff --git a/www/common/sframe-app-framework.js b/www/common/sframe-app-framework.js
index 72a51d37e..3b68cf0ce 100644
--- a/www/common/sframe-app-framework.js
+++ b/www/common/sframe-app-framework.js
@@ -50,7 +50,7 @@ define([
AppConfig.badStateTimeout : 30000;
var onConnectError = function () {
- Cryptpad.errorLoadingScreen(Messages.websocketError);
+ UI.errorLoadingScreen(Messages.websocketError);
};
var create = function (options, cb) {
@@ -153,7 +153,7 @@ define([
evContentUpdate.fire(newContent);
} catch (e) {
console.log(e.stack);
- Cryptpad.errorLoadingScreen(e.message);
+ UI.errorLoadingScreen(e.message);
}
};
@@ -266,7 +266,7 @@ define([
if (!readOnly) { onLocal(); }
evOnReady.fire(newPad);
- Cryptpad.removeLoadingScreen(emitResize);
+ UI.removeLoadingScreen(emitResize);
var privateDat = cpNfInner.metadataMgr.getPrivateData();
if (options.thumbnail && privateDat.thumbnails) {
@@ -375,7 +375,7 @@ define([
};
nThen(function (waitFor) {
- Cryptpad.addLoadingScreen();
+ UI.addLoadingScreen();
SFCommon.create(waitFor(function (c) { common = c; }));
}).nThen(function (waitFor) {
cpNfInner = common.startRealtime({
diff --git a/www/common/sframe-common-history.js b/www/common/sframe-common-history.js
index 547e564d1..30d389816 100644
--- a/www/common/sframe-common-history.js
+++ b/www/common/sframe-common-history.js
@@ -85,7 +85,6 @@ define([
var onReady = function () { };
var Messages = common.Messages;
- var Cryptpad = common.getCryptpadCommon();
var realtime;
@@ -102,7 +101,7 @@ define([
$right.hide();
$cke.hide();
- Cryptpad.spinner($hist).get().show();
+ UI.spinner($hist).get().show();
var onUpdate;
diff --git a/www/common/sframe-common-outer.js b/www/common/sframe-common-outer.js
index 494386c61..e5e344053 100644
--- a/www/common/sframe-common-outer.js
+++ b/www/common/sframe-common-outer.js
@@ -18,6 +18,7 @@ define([
var sframeChan;
var FilePicker;
var Messenger;
+ var Notifier;
nThen(function (waitFor) {
// Load #2, the loading screen is up so grab whatever you need...
@@ -29,14 +30,16 @@ define([
'/common/sframe-channel.js',
'/filepicker/main.js',
'/common/common-messenger.js',
+ '/common/common-notifier.js',
], waitFor(function (_CpNfOuter, _Cryptpad, _Crypto, _Cryptget, SFrameChannel,
- _FilePicker, _Messenger) {
+ _FilePicker, _Messenger, _Notifier) {
CpNfOuter = _CpNfOuter;
Cryptpad = _Cryptpad;
Crypto = _Crypto;
Cryptget = _Cryptget;
FilePicker = _FilePicker;
Messenger = _Messenger;
+ Notifier = _Notifier;
if (localStorage.CRYPTPAD_URLARGS !== ApiConfig.requireConf.urlArgs) {
console.log("New version, flushing cache");
@@ -176,7 +179,7 @@ define([
currentTitle = newTitle;
setDocumentTitle();
Cryptpad.renamePad(newTitle, undefined, function (err) {
- if (err) { cb('ERROR'); } else { cb(); }
+ cb(err);
});
});
sframeChan.on('EV_SET_TAB_TITLE', function (newTabTitle) {
@@ -203,7 +206,7 @@ define([
});
sframeChan.on('EV_NOTIFY', function () {
- Cryptpad.notify();
+ Notifier.notify();
});
sframeChan.on('Q_SET_LOGIN_REDIRECT', function (data, cb) {
diff --git a/www/common/sframe-common-title.js b/www/common/sframe-common-title.js
index b0f5a654e..317944993 100644
--- a/www/common/sframe-common-title.js
+++ b/www/common/sframe-common-title.js
@@ -1,7 +1,9 @@
define([
'jquery',
- '/common/common-util.js'
-], function ($, Util) {
+ '/common/common-util.js',
+ '/common/common-interface.js',
+ '/customize/messages.js'
+], function ($, Util, UI, Messages) {
var module = {};
module.create = function (Common, cfg) {
@@ -54,7 +56,9 @@ define([
});
metadataMgr.onTitleChange(function (title) {
sframeChan.query('Q_SET_PAD_TITLE_IN_DRIVE', title, function (err) {
- if (err) { return; }
+ if (err === 'E_OVER_LIMIT') {
+ return void UI.alert(Messages.pinLimitNotPinned, null, true);
+ } else if (err) { return; }
evTitleChange.fire(title);
if (titleUpdated) { titleUpdated(undefined, title); }
});
diff --git a/www/common/sframe-common.js b/www/common/sframe-common.js
index 2b2db6c4e..2d39d8ef4 100644
--- a/www/common/sframe-common.js
+++ b/www/common/sframe-common.js
@@ -359,7 +359,7 @@ define([
};
});
- UIElements.addTooltips();
+ UI.addTooltips();
ctx.sframeChan.on('EV_RT_CONNECT', function () { CommonRealtime.setConnectionState(true); });
ctx.sframeChan.on('EV_RT_DISCONNECT', function () { CommonRealtime.setConnectionState(false); });
diff --git a/www/common/toolbar3.js b/www/common/toolbar3.js
index d7455be81..fb3bd72e2 100644
--- a/www/common/toolbar3.js
+++ b/www/common/toolbar3.js
@@ -529,10 +529,10 @@ define([
$('').text(Messages.fileEmbedTitle).appendTo($content);
var $script = $('
').text(Messages.fileEmbedScript).appendTo($content);
$('
').appendTo($script);
- $script.append(Cryptpad.dialog.selectable(Common.getMediatagScript()));
+ $script.append(UI.dialog.selectable(Common.getMediatagScript()));
var $tag = $('
').text(Messages.fileEmbedTag).appendTo($content);
$('
').appendTo($tag);
- $tag.append(Cryptpad.dialog.selectable(Common.getMediatagFromHref(url)));
+ $tag.append(UI.dialog.selectable(Common.getMediatagFromHref(url)));
UI.alert($content[0], null, true);
});
@@ -787,7 +787,7 @@ define([
'target': '_blank',
'href': origin + '/' + p + '/',
},
- content: $('
').append(Cryptpad.getIcon(p)).html() + Messages.type[p]
+ content: $('
').append(UI.getIcon(p)).html() + Messages.type[p]
});
});
var dropdownConfig = {
diff --git a/www/contacts/inner.js b/www/contacts/inner.js
index 68558909f..ae12ad665 100644
--- a/www/contacts/inner.js
+++ b/www/contacts/inner.js
@@ -29,13 +29,13 @@ define([
var Messages = Cryptpad.Messages;
var APP = {};
var onConnectError = function () {
- Cryptpad.errorLoadingScreen(Messages.websocketError);
+ UI.errorLoadingScreen(Messages.websocketError);
};
var common;
var sFrameChan;
nThen(function (waitFor) {
- $(waitFor(Cryptpad.addLoadingScreen));
+ $(waitFor(UI.addLoadingScreen));
SFCommon.create(waitFor(function (c) { APP.common = common = c; }));
}).nThen(function (waitFor) {
sFrameChan = common.getSframeChannel();
@@ -87,13 +87,13 @@ define([
UI.create(messenger, $(friendList), $(messaging), common);
- Cryptpad.removeLoadingScreen();
+ UI.removeLoadingScreen();
/*
sFrameChan.query('Q_HEY_BUDDY', null, function (err, data) {
if (!data) { return; }
if (data.error) {
- Cryptpad.warn(data.error);
+ UI.warn(data.error);
} else {
UI.log(data.response);
}
diff --git a/www/contacts/messenger-ui.js b/www/contacts/messenger-ui.js
index cb65644ec..3f8c8d09c 100644
--- a/www/contacts/messenger-ui.js
+++ b/www/contacts/messenger-ui.js
@@ -4,13 +4,14 @@ define([
'/customize/messages.js',
'/common/common-util.js',
'/common/common-interface.js',
+ '/common/common-notifier.js',
'/common/hyperscript.js',
'/bower_components/marked/marked.min.js',
'/common/media-tag.js',
-], function ($, Cryptpad, Messages, Util, UI, h, Marked, MediaTag) {
+], function ($, Cryptpad, Messages, Util, UI, Notifier, h, Marked, MediaTag) {
'use strict';
- var UI = {};
+ var MessengerUI = {};
var m = function (md) {
var d = h('div.cp-app-contacts-content');
@@ -42,7 +43,7 @@ define([
};
};
- UI.create = function (messenger, $userlist, $messages, common) {
+ MessengerUI.create = function (messenger, $userlist, $messages, common) {
var origin = common.getMetadataMgr().getPrivateData().origin;
var state = window.state = {
@@ -391,7 +392,7 @@ define([
var initializing = true;
messenger.on('message', function (message) {
- if (!initializing) { Cryptpad.notify(); }
+ if (!initializing) { Notifier.notify(); }
var curvePublic = message.curve;
var name = displayNames[curvePublic];
@@ -516,7 +517,7 @@ define([
count--;
if (count === 0) {
initializing = false;
- Cryptpad.removeLoadingScreen();
+ UI.removeLoadingScreen();
}
};
ready();
@@ -526,5 +527,5 @@ define([
});
};
- return UI;
+ return MessengerUI;
});
diff --git a/www/drive/inner.js b/www/drive/inner.js
index 40b622b03..9c756cb18 100644
--- a/www/drive/inner.js
+++ b/www/drive/inner.js
@@ -48,7 +48,7 @@ define([
};
var onConnectError = function () {
- Cryptpad.errorLoadingScreen(Messages.websocketError);
+ UI.errorLoadingScreen(Messages.websocketError);
};
var E_OVER_LIMIT = 'E_OVER_LIMIT';
@@ -1215,9 +1215,9 @@ define([
// This is duplicated in cryptpad-common, it should be unified
var getFileIcon = function (id) {
var data = filesOp.getFileData(id);
- return Cryptpad.getFileIcon(data);
+ return UI.getFileIcon(data);
};
- var getIcon = Cryptpad.getIcon;
+ var getIcon = UI.getIcon;
// Create the "li" element corresponding to the file/folder located in "path"
var createElement = function (path, elPath, root, isFolder) {
@@ -1803,7 +1803,7 @@ define([
.text(Messages.fm_newFile));
$element.attr('title', Messages.fm_newFile);
$element.click(function () {
- var $modal = Cryptpad.createModal({
+ var $modal = UIElements.createModal({
id: 'cp-app-drive-new-ghost-dialog',
$body: $('body')
});
@@ -2481,7 +2481,7 @@ define([
$('
').appendTo($d);
if (!ro) {
$('