summaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
authorAlon Levy <alon@pobox.com>2015-04-08 00:49:44 +0300
committerAlon Levy <alon@pobox.com>2015-04-09 06:39:22 +0300
commite7349cc3f1c24a74da359058a5719712f6d613e6 (patch)
tree6d98e8729543cc76cc969f0d865984b641943456 /src/client
parent8b6e6a963b83cbc5ec3e0e72b805aee8f7a94196 (diff)
client/graph_view, index: filter checkboxes: remove hardcoding
Diffstat (limited to 'src/client')
-rw-r--r--src/client/view/graph_view.js22
1 files changed, 21 insertions, 1 deletions
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 = $('<input type="checkbox" checked="checked">'),
+ div = $('<div class="menu__type-filter_item"></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();