This repository has been archived by the owner on Feb 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.js
152 lines (142 loc) · 5.26 KB
/
config.js
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
//
// OSC Datatables Config
//
// OSC.data is configured in config.php
OSC.table_id = "template_table";
OSC.table_name = "The Table";
OSC.table_caption = "A table to demonstrate DataTables as used by the Harvard Library Office for Scholarly Communication"
// Column filters:
// ... basic (appears on page load),
// ... advanced (appears in advanced mode),
// ... none
OSC.filters = "advanced";
// Load in advanced mode:
// ... true/false
OSC.advanced_mode = false;
// Table controls:
// ... top
// ... bottom
// ... (undefined defaults to bottom)
OSC.table_controls = "bottom";
// Permit column headers to wrap:
// ... true
// ... false
OSC.headers_wrap = false;
// Responsive?
// (collapses columns to toggling child rows, when you run out of room)
// ... true
// ... false
OSC.responsive = true;
// DataTables column autoWidth?
// ... true
// ... false
OSC.auto_width = true;
// Best practices, defining columns:
// ... Always include a "defaultContent" attribute. (It's sort/searchable.)
// ... Always include a "name" attribute. It must be unique. It must not be "q" or start with "SS".
// ... For performance, specify non-orderable (non-sorting) where possible.
// ... But, if you disable sort on the first column, do sort by another column by default.
// ... Please don't specify non-searchable in particular columns.
// ... To make editable:
// ... ... for tag functionality, className must include "tags".
// ... ... the id created in cellcallback must be formatted 'fieldname_' + rowData.id
// ... ... supply the db path, table name, and column name in config.php
// ... If you care, configure what'll happen at small screen sizes.
// ... ... https://datatables.net/extensions/responsive/classes
// ... Hidden columns don't work with the Responsive plugin. Instead,
// ... ... you can make it a permanent child row by adding className: "none".
// ... ... or disapper it with className: "never". But,
// ... ... consider whether you really need a column. Access the data object directly.
// ... If slow to load, try reducing number of columns.
OSC.table_columns = [
{
"title": "ID",
"name": "id",
"data": "id",
"defaultContent": "(unknown)",
"orderable": true,
"render": {
"display": function(data, type, row, meta){
// UX/A11y helper: this column toggles children rows. Make it real buttons, instead of just css buttons
return '<button type="button" class="child-control btn-link">' + data + '</button>';
}
}
},
{
"title": "Last Name",
"name": "last_name",
"data": "values.last_name",
"defaultContent": "(unknown)",
"orderable": true,
},
{
"title": "First Name",
"name": "first_name",
"data": "values.first_name",
"defaultContent": "(unknown)",
"orderable": true,
},
{
"title": "Email",
"name": "email",
"data": "values.email",
"defaultContent": "(unknown)",
"orderable": false,
},
{
"title": "OA Faculty",
"name": "oa_faculty",
"data": "values.OA_faculty?",
"defaultContent": "(unknown)",
"orderable": false,
},
{
"title": "AA",
"name": "aa",
"data": "values.aa",
"defaultContent": "(unknown)",
"orderable": false,
},
{
"title": "Comments",
"name": "comments",
"data": "values.comments",
"render": function(data, type, row, meta){
return OSC.breaks_to_br(data);
},
"defaultContent": "",
"orderable": false,
"createdCell": function( cell, cellData, rowData, rowIndex, colIndex ) {
var cell_id = 'comments_' + rowData.id;
$(cell).attr('id', cell_id ).attr('contenteditable', "true" );
},
},
{
"title": "Tags",
"name":"tags",
"data": "values.tags",
"defaultContent": "",
"orderable": false,
"className": "tags",
"createdCell": function( cell, cellData, rowData, rowIndex, colIndex ) {
var cell_id = 'tags_' + rowData.id;
$(cell).attr('id', cell_id ).attr('contenteditable', "true" );
},
"render": {
"display": function( data, type, full, meta) {
return OSC.parse_tags(data);
},
"filter": function (data, type, full, meta){
return OSC.filter_tags(data);
}
},
},
{
"title": "A Boolean, Hidden From View",
"name": "special",
"data": "values.special",
"defaultContent": "(unknown)",
"orderable": false,
"className": "none",
},
];