Permalink
Browse files

Loading & no item indicators

  • Loading branch information...
a-fung committed Oct 20, 2012
1 parent 9f90890 commit be701ab3a8badec2d7ecf8f8badb2caa297844e6
@@ -562,7 +562,6 @@ public static MangaListItemJson[] ToListItemJsonArray(Manga[] mangas)
objs.Add(manga.ToMangaListItemJson());
}
- objs.Sort((a, b) => Utility.StrCmpLogicalW(a.title, b.title));
return objs.ToArray();
}
@@ -170,3 +170,6 @@
<p id="StackTrace">Stack Trace</p>
<p id="Show">Show</p>
<p id="TimeFormat">{0:M/d H:mm:ss}</p>
+<p id="Loading">Loading...</p>
+<p id="NoItem">No Item</p>
+<p id="GuestNotAllowed">This may indicate that no guest is allow to access anything. Please try to login as a user.</p>
@@ -170,3 +170,6 @@
<p id="StackTrace">堆疊追蹤</p>
<p id="Show">顯示</p>
<p id="TimeFormat">{0:M月d日 H:mm:ss}</p>
+<p id="Loading">載入中...</p>
+<p id="NoItem">沒有項目</p>
+<p id="GuestNotAllowed">可能是因為不允許客人訪問,請嘗試登入。</p>
@@ -62,6 +62,14 @@ <h1>
</td>
<td class="text-center td-small"><a href="#" class="msg msg-Details btn admin-collections-users"></a></td>
</tr>
+ <tr id="loading-trow">
+ <td colspan="99">
+ <span class="msg msg-Loading"></span>
+ <img src="img/loading.gif" /></td>
+ </tr>
+ <tr id="notiem-trow">
+ <td colspan="99" class="msg msg-NoItem"></td>
+ </tr>
</tbody>
</table>
<div class="row row-after-table">
@@ -111,6 +111,8 @@ <h3 class="msg msg-Login"></h3>
<span class="mangas-breadcrumb-tag-name"></span>
</li>
</ul>
+ <div class="mangas-loading">
+ </div>
<div class="mangas-pagination">
</div>
<div id="mangas-list" class="row-fluid">
@@ -471,3 +473,14 @@ <h3 class="msg msg-ChangePassword"></h3>
</a>
</div>
</div>
+<div class="well" id="loading-well">
+ <span class="msg msg-Loading"></span>
+ <img src="img/loading.gif" />
+</div>
+<div class="well" id="noitem-well">
+ <span class="msg msg-NoItem"></span>
+ <span id="noguest-warning">
+ <br />
+ <span class="msg msg-GuestNotAllowed"></span>
+ </span>
+</div>
@@ -530,10 +530,6 @@ class Manga
objs.push(manga.ToMangaListItemJson());
}
- objs.sort(function(a:MangaListItemJson, b:MangaListItemJson):Int
- {
- return untyped __call__("strnatcmp", a.title, b.title);
- });
return objs;
}
@@ -31,6 +31,7 @@ private FoldersModule()
{
jQuery.Select("#folders-all-folders-btn").Click(AllFoldersButtonClicked);
Request.Send(new FolderRequest(), FolderRequestSuccess);
+ Template.Get("client", "loading-well", true).AppendTo(jQuery.Select("#folders-area"));
}
protected override void OnShow()
@@ -48,6 +49,11 @@ private void AllFoldersButtonClicked(jQueryEvent e)
private void FolderRequestSuccess(FolderResponse response)
{
jQuery.Select("#folders-area").Children().Remove();
+ if (response.folders.Length == 0)
+ {
+ Template.Get("client", "noitem-well", true).AppendTo(jQuery.Select("#folders-area"));
+ }
+
new FoldersWidget(jQuery.Select("#folders-area"), response.folders, "");
}
}
@@ -121,6 +121,7 @@ public void Refresh(MangaFilter filter)
MangaListRequest request = new MangaListRequest();
request.filter = filter;
Request.Send(request, MangaListRequestSuccess);
+ Template.Get("client", "loading-well", true).AppendTo(jQuery.Select("#mangas-loading"));
};
if (!attachedObject.Is(":visible"))
@@ -152,12 +153,20 @@ private void BreadcrumbFolderClicked(jQueryEvent e)
private extern void MangaListRequestSuccess(JsonResponse response);
private void MangaListRequestSuccess(MangaListResponse response)
{
+ jQuery.Select("#mangas-loading").Children().Remove();
+
items = response.items;
CompareCallback<MangaListItemJson> compare = null;
switch (Settings.Sort)
{
+ case 0:
+ compare = delegate(MangaListItemJson a, MangaListItemJson b)
+ {
+ return a.title.CompareTo(b.title);
+ };
+ break;
case 1:
compare = delegate(MangaListItemJson a, MangaListItemJson b)
{
@@ -182,7 +191,6 @@ private void MangaListRequestSuccess(MangaListResponse response)
return Math.Round(Math.Random() * 2 - 1);
};
break;
- case 0:
default:
break;
}
@@ -217,6 +225,15 @@ private void ChangePage(int page)
Action onReady = delegate
{
mangaList.Children().Remove();
+ if (items.Length == 0)
+ {
+ jQueryObject noItem = Template.Get("client", "noitem-well", true).AppendTo(mangaList);
+ if (currentFolder == "")
+ {
+ Template.Get("client", "noguest-warning", true).AppendTo(noItem);
+ }
+ }
+
for (int i = (page - 1) * Environment.ElementsPerPage; i < items.Length && i < page * Environment.ElementsPerPage; i++)
{
if (j % Environment.MangaListItemPerRow == 0)
@@ -32,6 +32,9 @@ public class Template
new Dictionary<string, string[]>(
"client",
new string[] {
+ "noguest-warning",
+ "noitem-well",
+ "loading-well",
"read-module",
"change-password-modal",
"settings-module",
@@ -13,6 +13,8 @@ protected override void StartStage2()
{
Template.Templates[Template.Templates.Length] = "admin";
Template.TemplateIds["admin"] = new string[] {
+ "noitem-trow",
+ "loading-trow",
"admin-stacktrace-modal",
"admin-errorlogs-trow",
"admin-errorlogs-module",
@@ -82,6 +82,8 @@ public void Refresh()
request.id = cid;
Request.Send(request, GetRequestSuccess);
+ jQuery.Select("#admin-collection-users-tbody").Children().Remove();
+ Template.Get("admin", "loading-trow", true).AppendTo(jQuery.Select("#admin-collection-users-tbody"));
}
[AlternateSignature]
@@ -101,6 +103,11 @@ private void ChangePage(int page)
{
currentPage = page;
jQuery.Select("#admin-collection-users-tbody").Children().Remove();
+ if (data.Length == 0)
+ {
+ Template.Get("admin", "noitem-trow", true).AppendTo(jQuery.Select("#admin-collection-users-tbody"));
+ }
+
for (int i = (page - 1) * Environment.ModalElementsPerPage; i < data.Length && i < page * Environment.ModalElementsPerPage; i++)
{
jQueryObject row = Template.Get("admin", "admin-collection-users-trow", true).AppendTo(jQuery.Select("#admin-collection-users-tbody"));
@@ -82,6 +82,8 @@ public void Refresh()
request.id = uid;
Request.Send(request, GetRequestSuccess);
+ jQuery.Select("#admin-user-collections-tbody").Children().Remove();
+ Template.Get("admin", "loading-trow", true).AppendTo(jQuery.Select("#admin-user-collections-tbody"));
}
[AlternateSignature]
@@ -101,6 +103,11 @@ private void ChangePage(int page)
{
currentPage = page;
jQuery.Select("#admin-user-collections-tbody").Children().Remove();
+ if (data.Length == 0)
+ {
+ Template.Get("admin", "noitem-trow", true).AppendTo(jQuery.Select("#admin-user-collections-tbody"));
+ }
+
for (int i = (page - 1) * Environment.ModalElementsPerPage; i < data.Length && i < page * Environment.ModalElementsPerPage; i++)
{
jQueryObject row = Template.Get("admin", "admin-user-collections-trow", true).AppendTo(jQuery.Select("#admin-user-collections-tbody"));
@@ -61,6 +61,8 @@ private void AddButtonClicked(jQueryEvent e)
public void Refresh()
{
Request.Send(new AdminCollectionsGetRequest(), GetRequestSuccess);
+ jQuery.Select("#admin-collections-tbody").Children().Remove();
+ Template.Get("admin", "loading-trow", true).AppendTo(jQuery.Select("#admin-collections-tbody"));
}
[AlternateSignature]
@@ -76,6 +78,11 @@ private void ChangePage(int page)
{
currentPage = page;
jQuery.Select("#admin-collections-tbody").Children().Remove();
+ if (collections.Length == 0)
+ {
+ Template.Get("admin", "noitem-trow", true).AppendTo(jQuery.Select("#admin-collections-tbody"));
+ }
+
for (int i = (page - 1) * Environment.ElementsPerPage; i < collections.Length && i < page * Environment.ElementsPerPage; i++)
{
jQueryObject row = Template.Get("admin", "admin-collections-trow", true).AppendTo(jQuery.Select("#admin-collections-tbody"));
@@ -56,6 +56,8 @@ private void ChangePage(int page)
request.page = page - 1;
request.elementsPerPage = Environment.ElementsPerPage;
Request.Send(request, GetRequestSuccess);
+ jQuery.Select("#admin-errorlogs-tbody").Children().Remove();
+ Template.Get("admin", "loading-trow", true).AppendTo(jQuery.Select("#admin-errorlogs-tbody"));
}
[AlternateSignature]
@@ -66,6 +68,11 @@ private void GetRequestSuccess(AdminErrorLogsGetResponse response)
pagination.Refresh();
jQuery.Select("#admin-errorlogs-tbody").Children().Remove();
+ if (response.logs.Length == 0)
+ {
+ Template.Get("admin", "noitem-trow", true).AppendTo(jQuery.Select("#admin-errorlogs-tbody"));
+ }
+
for (int i = 0; i < response.logs.Length; i++)
{
jQueryObject row = Template.Get("admin", "admin-errorlogs-trow", true).AppendTo(jQuery.Select("#admin-errorlogs-tbody"));
@@ -71,6 +71,8 @@ public void Refresh(bool useFilter, AdminMangaFilterJson filter)
}
Request.Send(request, GetRequestSuccess);
+ jQuery.Select("#admin-mangas-tbody").Children().Remove();
+ Template.Get("admin", "loading-trow", true).AppendTo(jQuery.Select("#admin-mangas-tbody"));
}
[AlternateSignature]
@@ -100,6 +102,11 @@ private void ChangePage(int page)
{
currentPage = page;
jQuery.Select("#admin-mangas-tbody").Children().Remove();
+ if (mangas.Length == 0)
+ {
+ Template.Get("admin", "noitem-trow", true).AppendTo(jQuery.Select("#admin-mangas-tbody"));
+ }
+
for (int i = (page - 1) * Environment.ElementsPerPage; i < mangas.Length && i < page * Environment.ElementsPerPage; i++)
{
jQueryObject row = Template.Get("admin", "admin-mangas-trow", true).AppendTo(jQuery.Select("#admin-mangas-tbody"));
@@ -59,6 +59,11 @@ private void ChangePage(int page)
{
currentPage = page;
jQuery.Select("#admin-users-tbody").Children().Remove();
+ if (users.Length == 0)
+ {
+ Template.Get("admin", "noitem-trow", true).AppendTo(jQuery.Select("#admin-users-tbody"));
+ }
+
for (int i = (page - 1) * Environment.ElementsPerPage; i < users.Length && i < page * Environment.ElementsPerPage; i++)
{
jQueryObject row = Template.Get("admin", "admin-users-trow", true).AppendTo(jQuery.Select("#admin-users-tbody"));
@@ -89,6 +94,8 @@ private int GetTotalPage()
public void Refresh()
{
Request.Send(new AdminUsersGetRequest(), GetRequestSuccess);
+ jQuery.Select("#admin-users-tbody").Children().Remove();
+ Template.Get("admin", "loading-trow", true).AppendTo(jQuery.Select("#admin-users-tbody"));
}
[AlternateSignature]

0 comments on commit be701ab

Please sign in to comment.