diff --git a/customize.dist/main.css b/customize.dist/main.css index 026649207..d54ec6a98 100644 --- a/customize.dist/main.css +++ b/customize.dist/main.css @@ -388,6 +388,11 @@ right: 0; text-align: center; } +@media screen and (max-height: 600px) { + .cp #loadingTip { + display: none; + } +} .cp #loadingTip span { background-color: #302B28; color: #fafafa; diff --git a/customize.dist/main.js b/customize.dist/main.js index cdaeedfdb..088e1f51a 100644 --- a/customize.dist/main.js +++ b/customize.dist/main.js @@ -119,54 +119,57 @@ define([ }); $('button.login').click(function () { - Cryptpad.addLoadingScreen(Messages.login_hashing); - // We need a setTimeout(cb, 0) otherwise the loading screen is only displayed after hashing the password + // setTimeout 100ms to remove the keyboard on mobile devices before the loading screen pops up window.setTimeout(function () { - loginReady(function () { - var uname = $uname.val(); - var passwd = $passwd.val(); - Login.loginOrRegister(uname, passwd, false, function (err, result) { - if (!err) { - var proxy = result.proxy; - - // successful validation and user already exists - // set user hash in localStorage and redirect to drive - if (proxy && !proxy.login_name) { - proxy.login_name = result.userName; - } - - proxy.edPrivate = result.edPrivate; - proxy.edPublic = result.edPublic; - - Cryptpad.whenRealtimeSyncs(result.realtime, function () { - Cryptpad.login(result.userHash, result.userName, function () { - document.location.href = '/drive/'; - }); - }); - return; - } - switch (err) { - case 'NO_SUCH_USER': - Cryptpad.removeLoadingScreen(function () { - Cryptpad.alert(Messages.login_noSuchUser); - }); - break; - case 'INVAL_USER': - Cryptpad.removeLoadingScreen(function () { - Cryptpad.alert(Messages.login_invalUser); + Cryptpad.addLoadingScreen(Messages.login_hashing); + // We need a setTimeout(cb, 0) otherwise the loading screen is only displayed after hashing the password + window.setTimeout(function () { + loginReady(function () { + var uname = $uname.val(); + var passwd = $passwd.val(); + Login.loginOrRegister(uname, passwd, false, function (err, result) { + if (!err) { + var proxy = result.proxy; + + // successful validation and user already exists + // set user hash in localStorage and redirect to drive + if (proxy && !proxy.login_name) { + proxy.login_name = result.userName; + } + + proxy.edPrivate = result.edPrivate; + proxy.edPublic = result.edPublic; + + Cryptpad.whenRealtimeSyncs(result.realtime, function () { + Cryptpad.login(result.userHash, result.userName, function () { + document.location.href = '/drive/'; + }); }); - break; - case 'INVAL_PASS': - Cryptpad.removeLoadingScreen(function () { - Cryptpad.alert(Messages.login_invalPass); - }); - break; - default: // UNHANDLED ERROR - Cryptpad.errorLoadingScreen(Messages.login_unhandledError); - } + return; + } + switch (err) { + case 'NO_SUCH_USER': + Cryptpad.removeLoadingScreen(function () { + Cryptpad.alert(Messages.login_noSuchUser); + }); + break; + case 'INVAL_USER': + Cryptpad.removeLoadingScreen(function () { + Cryptpad.alert(Messages.login_invalUser); + }); + break; + case 'INVAL_PASS': + Cryptpad.removeLoadingScreen(function () { + Cryptpad.alert(Messages.login_invalPass); + }); + break; + default: // UNHANDLED ERROR + Cryptpad.errorLoadingScreen(Messages.login_unhandledError); + } + }); }); - }); - }, 0); + }, 0); + }, 100); }); /* End Log in UI */ diff --git a/customize.dist/src/less/loading.less b/customize.dist/src/less/loading.less index b48045622..6dcf2491a 100644 --- a/customize.dist/src/less/loading.less +++ b/customize.dist/src/less/loading.less @@ -36,6 +36,9 @@ left: 0; right: 0; text-align: center; + @media screen and (max-height: @media-medium-screen) { + display: none; + } span { background-color: @bg-loading; color: @color-loading; diff --git a/www/code/main.js b/www/code/main.js index d8b9903f4..85cd26db3 100644 --- a/www/code/main.js +++ b/www/code/main.js @@ -150,34 +150,17 @@ define([ } /* add a history button */ - var histConfig = {}; - histConfig.onRender = function (val) { - if (typeof val === "undefined") { return; } - try { - var hjson = JSON.parse(val || '{}'); - var remoteDoc = hjson.content; + var histConfig = { + onLocal: config.onLocal(), + onRemote: config.onRemote(), + setHistory: setHistory, + applyVal: function (val) { + var remoteDoc = JSON.parse(val || '{}').content; editor.setValue(remoteDoc || ''); editor.save(); - } catch (e) { - // Probably a parse error - console.error(e); - } - }; - histConfig.onClose = function () { - // Close button clicked - setHistory(false, true); - }; - histConfig.onRevert = function () { - // Revert button clicked - setHistory(false, false); - config.onLocal(); - config.onRemote(); - }; - histConfig.onReady = function () { - // Called when the history is loaded and the UI displayed - setHistory(true); + }, + $toolbar: $bar }; - histConfig.$toolbar = $bar; var $hist = Cryptpad.createButton('history', true, {histConfig: histConfig}); $rightside.append($hist); diff --git a/www/common/common-history.js b/www/common/common-history.js index 1cd0e6555..8597598c1 100644 --- a/www/common/common-history.js +++ b/www/common/common-history.js @@ -24,7 +24,6 @@ define([ var wcId = common.hrefToHexChannelId(config.href || window.location.href); - console.log(wcId); var createRealtime = function () { return ChainPad.create({ userName: 'history', @@ -80,11 +79,32 @@ define([ if (History.loading) { return void console.error("History is already being loaded..."); } History.loading = true; var $toolbar = config.$toolbar; - var noFunc = function () {}; - var render = config.onRender || noFunc; - var onClose = config.onClose || noFunc; - var onRevert = config.onRevert || noFunc; - var onReady = config.onReady || noFunc; + + if (!config.applyVal || !config.setHistory || !config.onLocal || !config.onRemote) { + throw new Error("Missing config element: applyVal, onLocal, onRemote, setHistory"); + } + + // config.setHistory(bool, bool) + // - bool1: history value + // - bool2: reset old content? + var render = function (val) { + if (typeof val === "undefined") { return; } + try { + config.applyVal(val); + } catch (e) { + // Probably a parse error + console.error(e); + } + }; + var onClose = function () { config.setHistory(false, true); }; + var onRevert = function () { + config.setHistory(false, false); + config.onLocal(); + config.onRemote(); + }; + var onReady = function () { + config.setHistory(true); + }; var Messages = common.Messages; diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index a1daa8b17..73b51e8b3 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -84,6 +84,7 @@ define([ common.getEditHashFromKeys = Hash.getEditHashFromKeys; common.getViewHashFromKeys = Hash.getViewHashFromKeys; + common.getFileHashFromKeys = Hash.getFileHashFromKeys; common.getSecrets = Hash.getSecrets; common.getHashes = Hash.getHashes; common.createChannelId = Hash.createChannelId; diff --git a/www/common/toolbar2.js b/www/common/toolbar2.js index 9d7d43aa9..49e2376e8 100644 --- a/www/common/toolbar2.js +++ b/www/common/toolbar2.js @@ -367,7 +367,7 @@ define([ return "Loading share button"; }; - var createFileShare = function () { + var createFileShare = function (toolbar) { if (!window.location.hash) { throw new Error("Unable to display the share button: hash required in the URL"); } @@ -380,6 +380,7 @@ define([ if (success) { Cryptpad.log(Messages.shareSuccess); } }); + toolbar.$leftside.append($button); return $button; }; @@ -852,7 +853,7 @@ define([ tb['useradmin'] = createUserAdmin; - var addElement = function (arr, additionnalCfg, init) { + var addElement = toolbar.addElement = function (arr, additionnalCfg, init) { if (typeof additionnalCfg === "object") { $.extend(true, config, additionnalCfg); } arr.forEach(function (el) { if (typeof el !== "string" || !el.trim()) { return; } diff --git a/www/drive/file.css b/www/drive/file.css index 431cecd60..fed050db1 100644 --- a/www/drive/file.css +++ b/www/drive/file.css @@ -43,6 +43,9 @@ body { margin-top: 0.5em; } } +div:focus { + outline: none; +} .fa { /*min-width: 17px;*/ margin-right: 3px; diff --git a/www/drive/file.less b/www/drive/file.less index fc6985802..fe506ae35 100644 --- a/www/drive/file.less +++ b/www/drive/file.less @@ -70,6 +70,10 @@ body { } } +div:focus { + outline: none; +} + .fa { /*min-width: 17px;*/ margin-right: 3px; diff --git a/www/drive/inner.html b/www/drive/inner.html index 859ae3391..c7f63f860 100644 --- a/www/drive/inner.html +++ b/www/drive/inner.html @@ -14,7 +14,7 @@
-
+