From e7349cc3f1c24a74da359058a5719712f6d613e6 Mon Sep 17 00:00:00 2001 From: Alon Levy Date: Wed, 8 Apr 2015 00:49:44 +0300 Subject: client/graph_view, index: filter checkboxes: remove hardcoding --- src/client/view/graph_view.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'src/client/view/graph_view.js') diff --git a/src/client/view/graph_view.js b/src/client/view/graph_view.js index 2874125d..06f038c9 100644 --- a/src/client/view/graph_view.js +++ b/src/client/view/graph_view.js @@ -55,16 +55,35 @@ function enableDebugViewOfDiffs(graph) }); } +function capitalize(word) { + if (word.length == 0) return ''; + return word.slice(0, 1).toUpperCase() + word.slice(1, word.length); +} + function init_checkboxes(update_view) { var // FIXME take filter names from index.html or both from graph db filter_states = _.object(_.map(model_types.nodetypes, function (type) { return [type, null]; })); + function create_checkboxes() { + var root = $('#menu__type-filter'); + + _.each(model_types.nodetypes, function (type) { + var input = $(''), + div = $(''); + + input.attr("name", type); + div.append(input); + div.append(capitalize(type)); + root.append(div); + }); + } + function read_checkboxes() { var name, value, // jquery map does flattens, and we don't want that checkboxes = _.map($('#menu__type-filter input'), - function (checkbox){ + function (checkbox) { return [checkbox.name, checkbox.checked]; } ); @@ -90,6 +109,7 @@ function init_checkboxes(update_view) { }); } + create_checkboxes(); read_checkboxes(); redraw__set_on_checkbox_change(); -- cgit v1.3.1