Improve UI on mobile

pull/1/head
yflory 8 years ago
parent 5c8586f8a3
commit 5a21be8112

@ -388,6 +388,11 @@
right: 0; right: 0;
text-align: center; text-align: center;
} }
@media screen and (max-height: 600px) {
.cp #loadingTip {
display: none;
}
}
.cp #loadingTip span { .cp #loadingTip span {
background-color: #302B28; background-color: #302B28;
color: #fafafa; color: #fafafa;

@ -119,54 +119,57 @@ define([
}); });
$('button.login').click(function () { $('button.login').click(function () {
Cryptpad.addLoadingScreen(Messages.login_hashing); // setTimeout 100ms to remove the keyboard on mobile devices before the loading screen pops up
// We need a setTimeout(cb, 0) otherwise the loading screen is only displayed after hashing the password
window.setTimeout(function () { window.setTimeout(function () {
loginReady(function () { Cryptpad.addLoadingScreen(Messages.login_hashing);
var uname = $uname.val(); // We need a setTimeout(cb, 0) otherwise the loading screen is only displayed after hashing the password
var passwd = $passwd.val(); window.setTimeout(function () {
Login.loginOrRegister(uname, passwd, false, function (err, result) { loginReady(function () {
if (!err) { var uname = $uname.val();
var proxy = result.proxy; var passwd = $passwd.val();
Login.loginOrRegister(uname, passwd, false, function (err, result) {
// successful validation and user already exists if (!err) {
// set user hash in localStorage and redirect to drive var proxy = result.proxy;
if (proxy && !proxy.login_name) {
proxy.login_name = result.userName; // successful validation and user already exists
} // set user hash in localStorage and redirect to drive
if (proxy && !proxy.login_name) {
proxy.edPrivate = result.edPrivate; proxy.login_name = result.userName;
proxy.edPublic = result.edPublic; }
Cryptpad.whenRealtimeSyncs(result.realtime, function () { proxy.edPrivate = result.edPrivate;
Cryptpad.login(result.userHash, result.userName, function () { proxy.edPublic = result.edPublic;
document.location.href = '/drive/';
}); Cryptpad.whenRealtimeSyncs(result.realtime, function () {
}); Cryptpad.login(result.userHash, result.userName, function () {
return; document.location.href = '/drive/';
} });
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; return;
case 'INVAL_PASS': }
Cryptpad.removeLoadingScreen(function () { switch (err) {
Cryptpad.alert(Messages.login_invalPass); case 'NO_SUCH_USER':
}); Cryptpad.removeLoadingScreen(function () {
break; Cryptpad.alert(Messages.login_noSuchUser);
default: // UNHANDLED ERROR });
Cryptpad.errorLoadingScreen(Messages.login_unhandledError); 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 */ /* End Log in UI */

@ -36,6 +36,9 @@
left: 0; left: 0;
right: 0; right: 0;
text-align: center; text-align: center;
@media screen and (max-height: @media-medium-screen) {
display: none;
}
span { span {
background-color: @bg-loading; background-color: @bg-loading;
color: @color-loading; color: @color-loading;

@ -770,6 +770,7 @@ define([
var displayMenu = function (e, $menu) { var displayMenu = function (e, $menu) {
$menu.css({ display: "block" }); $menu.css({ display: "block" });
if (APP.mobile()) { return; }
var h = $menu.outerHeight(); var h = $menu.outerHeight();
var w = $menu.outerWidth(); var w = $menu.outerWidth();
var wH = window.innerHeight; var wH = window.innerHeight;
@ -1792,7 +1793,7 @@ define([
module.resetTree(); module.resetTree();
// in history mode we want to focus the version number input // in history mode we want to focus the version number input
if (!history.isHistoryMode) { $tree.find('#searchInput').focus(); } if (!history.isHistoryMode && !APP.mobile()) { $tree.find('#searchInput').focus(); }
$tree.find('#searchInput')[0].selectionStart = getSearchCursor(); $tree.find('#searchInput')[0].selectionStart = getSearchCursor();
$tree.find('#searchInput')[0].selectionEnd = getSearchCursor(); $tree.find('#searchInput')[0].selectionEnd = getSearchCursor();
@ -2066,6 +2067,7 @@ define([
if (!filesOp.comparePath(newLocation, currentPath.slice())) { displayDirectory(newLocation); } if (!filesOp.comparePath(newLocation, currentPath.slice())) { displayDirectory(newLocation); }
return; return;
} }
if (APP.mobile()) { return; }
search.to = window.setTimeout(function () { search.to = window.setTimeout(function () {
if (!isInSearchTmp) { search.oldLocation = currentPath.slice(); } if (!isInSearchTmp) { search.oldLocation = currentPath.slice(); }
var newLocation = [SEARCH, $input.val()]; var newLocation = [SEARCH, $input.val()];

@ -57,65 +57,68 @@ define([
}); });
$('button.login').click(function () { $('button.login').click(function () {
Cryptpad.addLoadingScreen(Messages.login_hashing); // setTimeout 100ms to remove the keyboard on mobile devices before the loading screen pops up
// We need a setTimeout(cb, 0) otherwise the loading screen is only displayed after hashing the password
window.setTimeout(function () { window.setTimeout(function () {
loginReady(function () { Cryptpad.addLoadingScreen(Messages.login_hashing);
var uname = $uname.val(); // We need a setTimeout(cb, 0) otherwise the loading screen is only displayed after hashing the password
var passwd = $passwd.val(); window.setTimeout(function () {
Login.loginOrRegister(uname, passwd, false, function (err, result) { loginReady(function () {
if (!err) { var uname = $uname.val();
var proxy = result.proxy; var passwd = $passwd.val();
Login.loginOrRegister(uname, passwd, false, function (err, result) {
if (!err) {
var proxy = result.proxy;
// successful validation and user already exists // successful validation and user already exists
// set user hash in localStorage and redirect to drive // set user hash in localStorage and redirect to drive
if (!proxy.login_name) { if (!proxy.login_name) {
result.proxy.login_name = result.userName; result.proxy.login_name = result.userName;
} }
proxy.edPrivate = result.edPrivate; proxy.edPrivate = result.edPrivate;
proxy.edPublic = result.edPublic; proxy.edPublic = result.edPublic;
Cryptpad.feedback('LOGIN', true); Cryptpad.feedback('LOGIN', true);
Cryptpad.whenRealtimeSyncs(result.realtime, function() { Cryptpad.whenRealtimeSyncs(result.realtime, function() {
Cryptpad.login(result.userHash, result.userName, function () { Cryptpad.login(result.userHash, result.userName, function () {
if (sessionStorage.redirectTo) { if (sessionStorage.redirectTo) {
var h = sessionStorage.redirectTo; var h = sessionStorage.redirectTo;
var parser = document.createElement('a'); var parser = document.createElement('a');
parser.href = h; parser.href = h;
if (parser.origin === window.location.origin) { if (parser.origin === window.location.origin) {
delete sessionStorage.redirectTo; delete sessionStorage.redirectTo;
window.location.href = h; window.location.href = h;
return; return;
}
} }
} window.location.href = '/drive/';
window.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);
}); });
break; return;
case 'INVAL_PASS': }
Cryptpad.removeLoadingScreen(function () { switch (err) {
Cryptpad.alert(Messages.login_invalPass); case 'NO_SUCH_USER':
}); Cryptpad.removeLoadingScreen(function () {
break; Cryptpad.alert(Messages.login_noSuchUser);
default: // UNHANDLED ERROR });
Cryptpad.errorLoadingScreen(Messages.login_unhandledError); 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);
}); });
}); });
}); });

@ -101,57 +101,63 @@ define([
function (yes) { function (yes) {
if (!yes) { return; } if (!yes) { return; }
Cryptpad.addLoadingScreen(Messages.login_hashing); // setTimeout 100ms to remove the keyboard on mobile devices before the loading screen pops up
Login.loginOrRegister(uname, passwd, true, function (err, result) { window.setTimeout(function () {
var proxy = result.proxy; Cryptpad.addLoadingScreen(Messages.login_hashing);
// We need a setTimeout(cb, 0) otherwise the loading screen is only displayed after hashing the password
if (err) { window.setTimeout(function () {
switch (err) { Login.loginOrRegister(uname, passwd, true, function (err, result) {
case 'NO_SUCH_USER': var proxy = result.proxy;
Cryptpad.removeLoadingScreen(function () {
Cryptpad.alert(Messages.login_noSuchUser); if (err) {
}); switch (err) {
break; case 'NO_SUCH_USER':
case 'INVAL_USER': Cryptpad.removeLoadingScreen(function () {
Cryptpad.removeLoadingScreen(function () { Cryptpad.alert(Messages.login_noSuchUser);
Cryptpad.alert(Messages.login_invalUser); });
}); break;
break; case 'INVAL_USER':
case 'INVAL_PASS': Cryptpad.removeLoadingScreen(function () {
Cryptpad.removeLoadingScreen(function () { Cryptpad.alert(Messages.login_invalUser);
Cryptpad.alert(Messages.login_invalPass); });
}); break;
break; case 'INVAL_PASS':
case 'ALREADY_REGISTERED': Cryptpad.removeLoadingScreen(function () {
Cryptpad.removeLoadingScreen(function () { Cryptpad.alert(Messages.login_invalPass);
Cryptpad.confirm(Messages.register_alreadyRegistered, function (yes) { });
if (!yes) { return; } break;
proxy.login_name = uname; case 'ALREADY_REGISTERED':
Cryptpad.removeLoadingScreen(function () {
if (!proxy[Cryptpad.displayNameKey]) { Cryptpad.confirm(Messages.register_alreadyRegistered, function (yes) {
proxy[Cryptpad.displayNameKey] = uname; if (!yes) { return; }
} proxy.login_name = uname;
Cryptpad.eraseTempSessionValues();
logMeIn(result); if (!proxy[Cryptpad.displayNameKey]) {
}); proxy[Cryptpad.displayNameKey] = uname;
}); }
break; Cryptpad.eraseTempSessionValues();
default: // UNHANDLED ERROR logMeIn(result);
Cryptpad.errorLoadingScreen(Messages.login_unhandledError); });
} });
return; break;
} default: // UNHANDLED ERROR
Cryptpad.eraseTempSessionValues(); Cryptpad.errorLoadingScreen(Messages.login_unhandledError);
if (shouldImport) { }
sessionStorage.migrateAnonDrive = 1; return;
} }
Cryptpad.eraseTempSessionValues();
proxy.login_name = uname; if (shouldImport) {
proxy[Cryptpad.displayNameKey] = uname; sessionStorage.migrateAnonDrive = 1;
sessionStorage.createReadme = 1; }
logMeIn(result); proxy.login_name = uname;
}); proxy[Cryptpad.displayNameKey] = uname;
sessionStorage.createReadme = 1;
logMeIn(result);
});
}, 0);
}, 100);
}, { }, {
ok: Messages.register_writtenPassword, ok: Messages.register_writtenPassword,
cancel: Messages.register_cancel, cancel: Messages.register_cancel,

Loading…
Cancel
Save