diff options
author | David Thompson <dthompson2@worcester.edu> | 2015-01-30 08:52:16 -0500 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2015-01-30 08:52:16 -0500 |
commit | f5881f0fda30b96e3f6557c0677a02c2356be227 (patch) | |
tree | 701a4fb36abacd0449288f02879a9b8ac850c070 /js | |
parent | b8448030adb6fa39b7fc962c4708553eb37aee93 (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')
-rw-r--r-- | js/view/generations.js | 5 | ||||
-rw-r--r-- | js/view/packages.js | 5 | ||||
-rw-r--r-- | js/view/ui.js | 7 |
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) + ]); + }; })(); |