Redesign the login form, preload all web font fonts on front page

This commit is contained in:
DanyLE 2022-12-16 11:45:33 +01:00 committed by Dany LE
parent 3c25d8b52e
commit b026b96bf2
9 changed files with 127 additions and 95 deletions

View File

@ -977,29 +977,33 @@ namespace OS {
.replace("[ANTOS_VERSION]", OS.VERSION.version_string) .replace("[ANTOS_VERSION]", OS.VERSION.version_string)
); );
$("#wrapper").append(scheme); $("#wrapper").append(scheme);
$("#btlogin").on("click", async function () { $("#login_form")[0].uify(undefined);
($("#btlogin")[0] as tag.ButtonTag).onbtclick = async function () {
const data: API.UserLoginType = { const data: API.UserLoginType = {
username: $("#txtuser").val() as string, username: $("#txtuser").val() as string,
password: $("#txtpass").val() as string, password: $("#txtpass").val() as string,
}; };
const err_label = $("#login_error")[0] as tag.LabelTag;
try { try {
const d = await API.handle.login(data); const d = await API.handle.login(data);
if (d.error) { if (d.error) {
return $("#login_error").html(d.error as string); err_label.iconclass = "bi bi-exclamation-diamond-fill";
return err_label.text = d.error as string;
} }
return startAntOS(d.result); return startAntOS(d.result);
} catch (e) { } catch (e) {
return $("#login_error").html("Login: server error"); err_label.iconclass = "bi bi-bug-fill";
return err_label.text = __("Login: server error");
}
};
($("#txtpass")[0] as tag.InputTag).on("keyup", function (e) {
if (e.which === 13) {
return $("#btlogin button").trigger("click");
} }
}); });
$("#txtpass").on("keyup", function (e) { ($("#txtuser")[0] as tag.InputTag).on("keyup",function (e) {
if (e.which === 13) { if (e.which === 13) {
return $("#btlogin").trigger("click"); return $("#btlogin button").trigger("click");
}
});
$("#txtuser").keyup(function (e) {
if (e.which === 13) {
return $("#btlogin").trigger("click");
} }
}); });
} }
@ -1107,13 +1111,19 @@ namespace OS {
`; `;
schemes.login = `\ schemes.login = `\
<div id = "login_form"> <afx-vbox id = "login_form">
<p>Welcome to AntOS, please login</p> <afx-label data-height="35" text="Welcome to AntOS, please login"></afx-label>
<input id = "txtuser" type = "text" value = "demo" ></input> <afx-vbox padding = "10">
<input id = "txtpass" type = "password" value = "demo" ></input> <afx-input data-height="52" id = "txtuser" type = "text" value = "demo" label="User name"></afx-input>
<button id = "btlogin">Login</button> <div data-height="10"></div>
<div id = "login_error"></div> <afx-input data-height="52" id = "txtpass" type = "password" value = "demo" label="Password"></afx-input>
</div> <div data-height="10"></div>
<afx-hbox>
<afx-label id = "login_error"></afx-label>
<afx-button id = "btlogin" text="Login" iconclass = "bi bi-box-arrow-in-right" data-width="content"></afx-button>
</afx-hbox>
</afx-vbox>
</afx-vbox>
<div id = "antos_build_id"><a href="${OS.REPOSITORY}/tree/[ANTOS_BUILD_ID]">AntOS v[ANTOS_VERSION]</div>\ <div id = "antos_build_id"><a href="${OS.REPOSITORY}/tree/[ANTOS_BUILD_ID]">AntOS v[ANTOS_VERSION]</div>\
`; `;
} }

View File

@ -415,21 +415,21 @@ namespace OS {
this.items[index].app.trigger("focus"); this.items[index].app.trigger("focus");
}); });
$(this).on("touchstart", e => { this.addEventListener("touchstart", e => {
this._previous_touch.x = e.touches[0].pageX; this._previous_touch.x = e.touches[0].pageX;
this._previous_touch.y = e.touches[0].pageY; this._previous_touch.y = e.touches[0].pageY;
}); }, { passive: true});
$(this).on("touchmove", e => { this.addEventListener("touchmove", e => {
const offset = {x:0, y:0}; const offset = {x:0, y:0};
offset.x = this._previous_touch.x - e.touches[0].pageX ; offset.x = this._previous_touch.x - e.touches[0].pageX ;
offset.y = this._previous_touch.y - e.touches[0].pageY; offset.y = this._previous_touch.y - e.touches[0].pageY;
(this as any).scrollLeft += offset.x; (this as any).scrollLeft += offset.x;
this._previous_touch.x = e.touches[0].pageX; this._previous_touch.x = e.touches[0].pageX;
this._previous_touch.y = e.touches[0].pageY; this._previous_touch.y = e.touches[0].pageY;
}); }, { passive: true});
$(this).on("wheel", (evt)=>{ this.addEventListener("wheel", (evt)=>{
(this as any).scrollLeft += (evt.originalEvent as WheelEvent).deltaY; (this as any).scrollLeft += (evt as WheelEvent).deltaY;
}); },{ passive: true});
announcer.on("app-pinned", (_) => { announcer.on("app-pinned", (_) => {
this.refresh_pinned_app(); this.refresh_pinned_app();
}); });

View File

@ -205,10 +205,10 @@ namespace OS {
*/ */
protected calibrate(): void protected calibrate(): void
{ {
$(this.refs.area) /*$(this.refs.area)
.css("width", "100%"); .css("width", "100%");
$(this.refs.input) $(this.refs.input)
.css("width", "100%"); .css("width", "100%");*/
if(this.verbose) if(this.verbose)
{ {
$(this.refs.area).show(); $(this.refs.area).show();

View File

@ -225,11 +225,11 @@ namespace OS {
const list_container = $(".list-container", this.refs.list); const list_container = $(".list-container", this.refs.list);
list_container.each((i,el) => { list_container.each((i,el) => {
$(el).on("touchstart", e => { el.addEventListener("touchstart", e => {
this._previous_touch.x = e.touches[0].pageX; this._previous_touch.x = e.touches[0].pageX;
this._previous_touch.y = e.touches[0].pageY; this._previous_touch.y = e.touches[0].pageY;
}); }, {passive: true});
$(el).on("touchmove", e => { el.addEventListener("touchmove", e => {
const offset = {x:0, y:0}; const offset = {x:0, y:0};
offset.x = this._previous_touch.x - e.touches[0].pageX ; offset.x = this._previous_touch.x - e.touches[0].pageX ;
offset.y = this._previous_touch.y - e.touches[0].pageY; offset.y = this._previous_touch.y - e.touches[0].pageY;
@ -243,17 +243,17 @@ namespace OS {
} }
this._previous_touch.x = e.touches[0].pageX; this._previous_touch.x = e.touches[0].pageX;
this._previous_touch.y = e.touches[0].pageY; this._previous_touch.y = e.touches[0].pageY;
}); }, {passive: true});
$(el).on("wheel", (evt)=>{ el.addEventListener("wheel", (evt)=>{
if(this.dir == "horizontal") if(this.dir == "horizontal")
{ {
el.scrollLeft += (evt.originalEvent as WheelEvent).deltaY; el.scrollLeft += (evt as WheelEvent).deltaY;
} }
else else
{ {
el.scrollTop += (evt.originalEvent as WheelEvent).deltaY; el.scrollTop += (evt as WheelEvent).deltaY;
} }
}); }, {passive: true});
}); });
} }

View File

@ -161,7 +161,16 @@ namespace OS {
$(this).css("height", "100%"); $(this).css("height", "100%");
let attv = $(this).attr("data-width"); let attv = $(this).attr("data-width");
let dw = 0; let dw = 0;
if (attv && attv !== "grow") { if (!attv || attv == "grow") {
$(this).css("flex-grow", "1");
auto_width.push(this);
return;
}
if(attv == "content")
{
ocwidth += $(this).width();
return;
}
if (attv[attv.length - 1] === "%") { if (attv[attv.length - 1] === "%") {
dw = dw =
(parseInt(attv.slice(0, -1)) * (parseInt(attv.slice(0, -1)) *
@ -172,10 +181,6 @@ namespace OS {
} }
$(this).css("width", `${dw}px`); $(this).css("width", `${dw}px`);
ocwidth += dw; ocwidth += dw;
} else {
$(this).css("flex-grow", "1");
auto_width.push(this);
}
}); });
const csize = (avaiWidth - ocwidth) / auto_width.length; const csize = (avaiWidth - ocwidth) / auto_width.length;
@ -204,7 +209,16 @@ namespace OS {
let dh = 0; let dh = 0;
$(this).css("width", "100%"); $(this).css("width", "100%");
let attv = $(this).attr("data-height"); let attv = $(this).attr("data-height");
if (attv && attv !== "grow") { if (!attv || attv == "grow") {
$(this).css("flex-grow", "1");
auto_height.push(this);
return;
}
if(attv == "content")
{
ocheight += $(this).height();
return;
}
if (attv[attv.length - 1] === "%") { if (attv[attv.length - 1] === "%") {
dh = dh =
(parseInt(attv.slice(0, -1)) * (parseInt(attv.slice(0, -1)) *
@ -215,10 +229,6 @@ namespace OS {
} }
$(this).css("height", `${dh}px`); $(this).css("height", `${dh}px`);
ocheight += dh; ocheight += dh;
} else {
$(this).css("flex-grow", "1");
auto_height.push(this);
}
}); });
const csize = (avaiheight - ocheight) / auto_height.length; const csize = (avaiheight - ocheight) / auto_height.length;

View File

@ -23,6 +23,12 @@
<title>AntOS webOS</title> <title>AntOS webOS</title>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="preload" href="resources/themes/system/fonts/ubuntu-regular-webfont.woff2" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="resources/themes/system/fonts/ubuntu-italic-webfont.woff2" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="resources/themes/system/fonts/ubuntu-bolditalic-webfont.woff2" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="resources/themes/system/fonts/ubuntu-bold-webfont.woff2" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="resources/themes/system/fonts/fontawesome-webfont.woff2" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="resources/themes/system/fonts/bootstrap-icons.woff2" as="font" type="font/woff2" crossorigin>
<link href="resources/themes/system/system.css" rel="stylesheet"> <link href="resources/themes/system/system.css" rel="stylesheet">
<link id="ostheme" rel="stylesheet" href=""> <link id="ostheme" rel="stylesheet" href="">
<script src="scripts/jquery-3.4.1.min.js"></script> <script src="scripts/jquery-3.4.1.min.js"></script>

View File

@ -78,6 +78,7 @@ input {
font-size: 14px; font-size: 14px;
height: 35px; height: 35px;
font-family: "Ubuntu"; font-family: "Ubuntu";
outline: none;
} }
textarea { textarea {
@ -87,8 +88,7 @@ textarea {
#login_form{ #login_form{
width:300px; width:300px;
height: 180px; height: 215px;
display: block;
border:1px solid #262626; border:1px solid #262626;
border-radius: 6px; border-radius: 6px;
box-shadow: 0px 3px 6px 0px rgba(0,0,0,0.65); box-shadow: 0px 3px 6px 0px rgba(0,0,0,0.65);
@ -98,52 +98,56 @@ textarea {
right: 0; right: 0;
bottom: 0; bottom: 0;
left: 0; left: 0;
font-family:Verdana, Geneva, Tahoma, sans-serif;
font-size: 13px;
text-align: center;
background-color: #363636; background-color: #363636;
color: white; color: white;
} }
#login_form p{ #login_form > div > afx-label
display: inline-block; {
/* background-color:#dfdfdf; */
border-bottom: 1px solid #262626; border-bottom: 1px solid #262626;
padding:10px;
width: calc(100% - 20px);
border-top-left-radius: 6px; border-top-left-radius: 6px;
border-top-right-radius: 6px; border-top-right-radius: 6px;
font-weight: bold;
margin:0; margin:0;
}
#login_form > div > afx-label .label-text
{
text-align: center;
font-weight: bold;
}
#login_form afx-input afx-label
{
font-size: 13px;
color: #bb86fc;
background-color: #464646;
}
} #login_form afx-input input
#login_form input { {
width: 250px; border-radius: 0;
outline: none; border: 0;
margin-top:10px; border-bottom: 1px solid #262626;
border-radius: 6px;
box-sizing: border-box;
font-size: 13px;
padding: 5px;
color: white;
border: 1px solid #262626;
background-color: #464646; background-color: #464646;
color: white;
} }
#login_form afx-input input:focus
{
border-bottom: 1px solid #bb86fc;
}
#login_form button{ #login_form button{
margin-top:10px;
width: 250px;
height: 30px;
background-color: #464646;
border: 1px solid #262626;
color: white;
border-radius: 6px;
font-family: Verdana, Geneva, Tahoma, sans-serif;
font-size: 13px;
padding:5px;
outline: none; outline: none;
min-height: 35px;
min-width: 40px;
padding-left: 10px;
padding-right: 10px;
border: 1px solid #262626;
background-color: #464646;
color: white;
border-radius: 3px;
font-family: "Ubuntu";
} }
#login_error{ #login_error {
padding:3px;
color:chocolate; color:chocolate;
font-weight: normal; font-weight: normal;
} }

View File

@ -1,6 +1,6 @@
@font-face { @font-face {
font-family: "bootstrap-icons"; font-family: "bootstrap-icons";
src: url("./fonts/bootstrap-icons.woff2?a74547b2f0863226942ff8ded57db345") format("woff2"), src: url("./fonts/bootstrap-icons.woff2") format("woff2"),
url("./fonts/bootstrap-icons.woff?a74547b2f0863226942ff8ded57db345") format("woff"); url("./fonts/bootstrap-icons.woff?a74547b2f0863226942ff8ded57db345") format("woff");
} }

View File

@ -6,8 +6,10 @@
* -------------------------- */ * -------------------------- */
@font-face { @font-face {
font-family: 'FontAwesome'; font-family: 'FontAwesome';
src: url('fonts/fontawesome-webfont.eot?v=4.7.0'); src: url('fonts/fontawesome-webfont.woff2') format('woff2'), url('fonts/fontawesome-webfont.woff?v=4.7.0') format('woff');
src: url('fonts/fontawesome-webfont.eot?#iefix&v=4.7.0') format('embedded-opentype'), url('fonts/fontawesome-webfont.woff2?v=4.7.0') format('woff2'), url('fonts/fontawesome-webfont.woff?v=4.7.0') format('woff'), url('fonts/fontawesome-webfont.ttf?v=4.7.0') format('truetype'), url('fonts/fontawesome-webfont.svg?v=4.7.0#fontawesomeregular') format('svg'); /*src: url('fonts/fontawesome-webfont.eot?v=4.7.0');
src: url('fonts/fontawesome-webfont.eot?#iefix&v=4.7.0') format('embedded-opentype'), url('fonts/fontawesome-webfont.woff?v=4.7.0') format('woff'), url('fonts/fontawesome-webfont.ttf?v=4.7.0') format('truetype'), url('fonts/fontawesome-webfont.svg?v=4.7.0#fontawesomeregular') format('svg');
*/
font-weight: normal; font-weight: normal;
font-style: normal; font-style: normal;
} }