deprecate busy view, closes #41

This commit is contained in:
Pachira 2016-12-09 16:48:35 +01:00
parent 0624ea48ec
commit 5e9fafac58
8 changed files with 15 additions and 99 deletions

View file

@ -1,27 +0,0 @@
.busy {
background: #222;
background: linear-gradient(0deg, rgba(0, 0, 0, .4), transparent) rgba(0, 0, 0, .8);
position: fixed;
top: 0;
left: 0;
bottom: 0;
right: 0;
z-index: 5;
text-align: center;
opacity: 1;
display: flex;
align-items: center;
justify-content: center;
&__content {
line-height: 2em;
color: #FFF;
display: inline-block;
padding: 10px 20px 15px;
border-radius: 10px;
}
&__text {
line-height: 2em;
}
}

View file

@ -10,7 +10,6 @@
@import "bem/auth";
@import "bem/avatar";
@import "bem/bbcode";
@import "bem/busy";
@import "bem/comment";
@import "bem/container";
@import "bem/content";

View file

@ -1,47 +0,0 @@
namespace Yuuno
{
export class Busy
{
private static Container: HTMLElement;
private static Text: HTMLElement;
private static Icon: HTMLElement;
public static Init(): void
{
this.Container = Sakura.DOM.ID('busy-window');
this.Text = Sakura.DOM.ID('busy-status');
this.Icon = Sakura.DOM.ID('busy-icon');
}
public static Hide(): void
{
Sakura.DOM.AddClass(this.Container, ['hidden']);
}
public static Show(mode: BusyMode = BusyMode.BUSY, text: string = null, hideAfter: number = 0): void
{
var icon: string = "fa fa-4x ";
switch (mode) {
case BusyMode.OK:
icon += 'fa-check';
break;
case BusyMode.FAIL:
icon += 'fa-remove';
break;
case BusyMode.BUSY:
default:
icon += 'fa-refresh fa-spin';
}
Sakura.DOM.RemoveClass(this.Icon, Sakura.DOM.ClassNames(this.Icon));
Sakura.DOM.AddClass(this.Icon, icon.split(' '));
this.Text.innerText = text || '';
Sakura.DOM.RemoveClass(this.Container, ['hidden']);
if (hideAfter > 0) {
setTimeout(Busy.Hide, hideAfter);
}
}
}
}

View file

@ -1,9 +0,0 @@
namespace Yuuno
{
export enum BusyMode
{
OK,
FAIL,
BUSY
}
}

View file

@ -9,7 +9,6 @@ namespace Yuuno
Sakura.TimeAgo.Init();
Sakura.Friend.Init();
Notifications.Init();
Busy.Init();
}
}
}

View file

@ -42,21 +42,28 @@
commentClient.ContentType("application/x-www-form-urlencoded");
function commentError(text) {
var error = new Sakura.Dialogue;
error.Title = "Error";
error.Text = text;
error.AddCallback(Sakura.DialogueButton.Ok, function () {
this.Close();
});
error.Display();
}
function commentPost(element, url) {
var text = element.querySelector('[name="text"]'),
session = element.querySelector('[name="session"]');
commentClient.SetSend({"text":text.value,"session":session.value});
text.value = '';
commentClient.SetUrl(url);
commentClient.AddCallback(200, function () {
var resp = JSON.parse(commentClient.Response());
var resp = commentClient.JSON();
if (resp.error) {
Yuuno.Busy.Show(Yuuno.BusyMode.FAIL, resp.error, 1500);
commentError(resp.error);
} else {
commentAdd(resp);
}
@ -243,7 +250,7 @@
var resp = JSON.parse(commentClient.Response());
if (resp.error) {
Yuuno.Busy.Show(Yuuno.BusyMode.FAIL, resp.error, 1500);
commentError(resp.error);
} else {
Sakura.DOM.Remove(Sakura.DOM.ID('comment-' + id));
}
@ -263,7 +270,7 @@
var resp = JSON.parse(commentClient.Response());
if (resp.error) {
Yuuno.Busy.Show(Yuuno.BusyMode.FAIL, resp.error, 1500);
commentError(resp.error);
} else {
upvotes.innerText = resp.upvotes;
downvotes.innerText = resp.downvotes;

View file

@ -26,12 +26,6 @@
{% endif %}
>
<span id="top"></span>
<div id="busy-window" class="busy hidden">
<div class="busy__content">
<h2 id="busy-status" class="busy__text"></h2>
<div class="fa fa-4x fa-refresh fa-spin" id="busy-icon"></div>
</div>
</div>
<div class="header" id="header">
<a class="header__logo" href="{{ route('main.index') }}">
{% if config('general.logo') %}

View file

@ -31,7 +31,7 @@
<h1>Total: &#8364;<span id="totalAmount"></span></h1>
</div>
<div style="float: right;">
<button class="input__button" onclick="Yuuno.Busy.Show(Yuuno.BusyMode.BUSY, 'Please wait...');document.getElementById('purchaseForm').submit();">Get <span id="monthNoBtn">1</span> month<span id="monthsTrailingS"></span> of Tenshi</button>
<button class="input__button" onclick="document.getElementById('purchaseForm').submit();">Get <span id="monthNoBtn">1</span> month<span id="monthsTrailingS"></span> of Tenshi</button>
</div>
<div class="clear"></div>
</div>