/
_table.scala.html
75 lines (70 loc) · 2.07 KB
/
_table.scala.html
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
@(model: IndexModel)
<table id="table">
<thead>
<th>@Messages("datatable.key")</th>
@for(key <- model.langs){
<th name="@key">@key @if(model.defaultLang == key) { (@Messages("index.defaultlang")) }</th>
}
</thead>
<tbody>
@for((key, value) <- model.list.groupBy(_.key)){
@_row(key, value, model)
}
</tbody>
</table>
</div>
<script type="text/javascript">
function makejEditable(obj) {
obj.editable('@routes.MessagesController.save()', {
//type: "textarea",
//cancel: "Cancel",
//submit: "Save",
//onblur: "ignore",
indicator: "<div class='loading-small'></div>",
intercept: function(result) {
result = jQuery.parseJSON(result);
handleResult(result);
return result.value;
},
callback: function(value, settings) {
var td = $(this).closest("td");
if ($(this).text()) {
if(td.hasClass("new")) {
td.removeClass("new");
$(this).closest("tr").removeClass("new");
$(this).siblings("td.edit").removeClass("new").addClass("missing");
}
td.removeClass("missing");
} else {
td.addClass("missing");
}
},
submitdata: function(value, settings) {
var oTable = $('#table').dataTable();
var index = oTable.fnGetPosition(this)[2];
var col = $("#table th:nth-child(" + (index + 1) + ")");
return {
key: this.parentNode.getAttribute('name'),
locale: col.attr("name")
};
},
height: "100%",
width: "100%"
});
}
$(document).ready(function() {
var oTable = $('#table').dataTable({
bAutoWidth: false,
iDisplayLength: 50,
sDom: 'C<"clear">lfrtip',
oColVis: {
"activate": "mouseover",
"aiExclude": [0]
}
});
new FixedHeader(oTable, {
//left: true
});
makejEditable(oTable.$('td.edit'));
});
</script>