pattern-view.js
2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/* global $dj, slickgrid, edit, gettext, ngettext */
var text_ops = ['eq', 'ne', 'bw', 'bn', 'ew', 'en', 'cn', 'nc', 're', 'nr'];
var eqne = ['in', '-in'];
var column_names = {
name: gettext("name"),
type: gettext("type"),
inflection_type: gettext("infl. type"),
example: gettext("example")
};
var columns = {};
var main_field = 'name';
$.each(column_names, function(key, name) {
"use strict";
columns[key] = {id: key, field: key, name: name};
if (key === main_field)
columns[key].cssClass = 'main-column';
});
$.extend(slickgrid, {
grid_id: 'patterns',
grid_caption: gettext("Patterns"),
counter: function(count) {
"use strict";
return ngettext("pattern", "patterns", count);
},
grid_element_id: 'pattern-grid',
main_field: main_field,
initial_columns: $dj.initial_columns,
initial_sort_rules: [],
all_columns: columns,
filter_fields: {
'name': {name: gettext("Name"), gender: 'f', ops: text_ops},
'old_name': {name: gettext("Old name"), gender: 'f', ops: text_ops},
'inflection_type': {
name: gettext("Inflection type"),
gender: 'm',
ops: eqne,
options: $dj.inflection_type_options
},
'type': {
name: gettext("Type"),
gender: 'm',
ops: eqne,
optgroups: $dj.pattern_type_options
},
'base_form_label': {name: gettext("Base form label"), gender: 'm', ops: text_ops}
},
load_content: function(id) {
"use strict";
function check() {
return id === slickgrid.active_id();
}
edit.busy_on();
edit.load_content(id, check);
},
init_sort: function() {},
init: function() {},
query_params: function() {
"use strict";
return {
sort_rules: slickgrid.loader.getSort(),
filter: slickgrid.loader.getFilter(),
reader: edit.reader
};
}
});
$(function() {
"use strict";
$(document).on('click', '.switch-example', function () {
var $t = $(this);
var root = $t.attr('data-example');
$('.active-example').removeClass('active-example checked');
$t.addClass('checked active-example');
$('.root').text(root);
});
});