From 43dc1e9dcc762be0f0e24c80f862f8425b093133 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Wed, 15 Oct 2014 22:36:58 -0400 Subject: js: Add loading spinner to packages page. * css/guix.css: Add spinner styles. * js/controller/packages.js (guix.packages.view): Explicitly redraw after loading packages. * js/model/packages.js (guix.packages.Packages): Load packages in the background. * js/view/layout.js (guix.withLayout): Cast elem to array if needed. * js/view/packages.js (guix.packages.view): Render spinner when there are no packages to display. --- js/view/layout.js | 4 ++++ js/view/packages.js | 8 +++++--- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'js/view') diff --git a/js/view/layout.js b/js/view/layout.js index 1ff641a..aa7834b 100644 --- a/js/view/layout.js +++ b/js/view/layout.js @@ -42,6 +42,10 @@ guix.withLayout = (function() { ])); return function(elem) { + if(!_.isArray(elem)) { + elem = [elem]; + } + return [ m("nav.navbar.navbar-default.navbar-static-top", { role: "navigation" diff --git a/js/view/packages.js b/js/view/packages.js index e356984..e202471 100644 --- a/js/view/packages.js +++ b/js/view/packages.js @@ -16,6 +16,8 @@ // . (function(packages) { + var spinner = m(".spinner-container", m(".spinner")); + packages.view = function(ctrl) { function renderName(package) { var name = package.name; @@ -95,7 +97,7 @@ }, m("a", { href: "#" }, text)); } - return m("ul.pagination", [ + return m("div", m("ul.pagination", [ // Back page renderPage("«", { class: ctrl.isFirstPage() ? "disabled" : "", @@ -125,7 +127,7 @@ return false; } }) - ])); + ]))); } function renderSearchBox() { @@ -237,7 +239,7 @@ return null; } - return guix.withLayout([ + return guix.withLayout(_.isEmpty(ctrl.pages()) ? spinner : [ m("h2", [ "Packages", m("span.badge", ctrl.packageCount()) -- cgit v1.2.3