From f5881f0fda30b96e3f6557c0677a02c2356be227 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Fri, 30 Jan 2015 08:52:16 -0500 Subject: 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. --- js/view/generations.js | 5 +---- js/view/packages.js | 5 +---- js/view/ui.js | 7 +++++++ 3 files changed, 9 insertions(+), 8 deletions(-) (limited to 'js') 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) + ]); + }; })(); -- cgit v1.2.3