summaryrefslogtreecommitdiff
path: root/js/view
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2015-01-30 08:52:16 -0500
committerDavid Thompson <dthompson2@worcester.edu>2015-01-30 08:52:16 -0500
commitf5881f0fda30b96e3f6557c0677a02c2356be227 (patch)
tree701a4fb36abacd0449288f02879a9b8ac850c070 /js/view
parentb8448030adb6fa39b7fc962c4708553eb37aee93 (diff)
js: Factorize headerWithBadge function.
* js/view/ui.js (guix.ui.headerWithBadge): New function. * js/view/packages.js (guix.view.packages): Use it. * js/view/generations.js (guix.view.generations): Likewise.
Diffstat (limited to 'js/view')
-rw-r--r--js/view/generations.js5
-rw-r--r--js/view/packages.js5
-rw-r--r--js/view/ui.js7
3 files changed, 9 insertions, 8 deletions
diff --git a/js/view/generations.js b/js/view/generations.js
index 0ff52f1..73fbce7 100644
--- a/js/view/generations.js
+++ b/js/view/generations.js
@@ -18,10 +18,7 @@
(function(generations) {
generations.view = function(ctrl) {
return guix.withLayout([
- m("h2.header", [
- "Generations",
- m("span.badge", ctrl.generations().length)
- ]),
+ guix.ui.headerWithBadge("Generations", ctrl.generations().length),
m("table.table.table-bordered", [
m("thead", m("tr", [
m("th", "#"),
diff --git a/js/view/packages.js b/js/view/packages.js
index a006d29..c2cde74 100644
--- a/js/view/packages.js
+++ b/js/view/packages.js
@@ -225,10 +225,7 @@
}
return guix.withLayout(ctrl.pager().isEmpty() ? spinner : [
- m("h2.header", [
- "Packages",
- m("span.badge", ctrl.packageCount())
- ]),
+ guix.ui.headerWithBadge("Packages", ctrl.packageCount()),
renderModal(),
renderSearchBox(),
renderPackageTable(),
diff --git a/js/view/ui.js b/js/view/ui.js
index 49b02bc..196406a 100644
--- a/js/view/ui.js
+++ b/js/view/ui.js
@@ -35,4 +35,11 @@
]))
];
};
+
+ ui.headerWithBadge = function(title, badgeText) {
+ return m("h2.header", [
+ title,
+ m("span.badge", badgeText)
+ ]);
+ };
})();