-
Notifications
You must be signed in to change notification settings - Fork 1
/
listeners.js
125 lines (109 loc) · 3.69 KB
/
listeners.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
/**
* Creates the listeners for different objects of the dashboard.
*/
exports.create = function() {
tagTooltip = $("#tag-tooltip");
sparklineTooltip = d3.select("#sparkline-tooltip");
filterTooltip = d3.select("#filter-tooltip");
chordTooltip = d3.select("#chord-tooltip");
$("#legalSearchForm").submit(function () {
textFilter(legalDim2, $("#legalSearch").val(), legalTable);
return false;
});
$("#mediaSearchForm").submit(function () {
textFilter(mediaDim2, $("#mediaSearch").val(), mediaTable);
return false;
});
function lastGlyphUpdate(table)
{
var lastglyph = $(table + " .sorted");
lastglyph.removeClass("sorted");
}
function legalTableOnClickUpdate(table, orderId) {
lastGlyphUpdate("#legal-table");
var glyph = orderId.children().first();
glyph.removeClass();
glyph.addClass( "sorted glyphicon " + legalTableSortingStatus[legalTableSorting] );
table
.order(legalTableOrdering[legalTableSorting])
.sortBy(tableSorting[legalTableSorting])
.redraw();
}
function mediaTableOnClickUpdate(table, orderId) {
lastGlyphUpdate("#media-table");
var glyph = orderId.children().first();
glyph.removeClass();
glyph.addClass( "sorted glyphicon " + mediaTableSortingStatus[mediaTableSorting] );
table
.order(mediaTableOrdering[mediaTableSorting])
.sortBy(tableSorting[mediaTableSorting])
.redraw();
}
function changeOrderingState(legal, ordinal, orderId)
{
if(legal)
{
if(legalTableOrdering[legalTableSorting] == d3.descending)
{
legalTableOrdering[legalTableSorting] = d3.ascending;
legalTableSortingStatus[legalTableSorting] = ordinal ? ordinalAscendingGlyph : numericAscendingGlyph;;
}
else
{
legalTableOrdering[legalTableSorting] = d3.descending;
legalTableSortingStatus[legalTableSorting] = ordinal ? ordinalDescendingGlyph : numericDescendingGlyph;;
}
legalTableOnClickUpdate(legalTable,orderId)
}
else
{
if(mediaTableOrdering[mediaTableSorting] == d3.descending)
{
mediaTableOrdering[mediaTableSorting] = d3.ascending;
mediaTableSortingStatus[mediaTableSorting] = ordinal ? ordinalAscendingGlyph : numericAscendingGlyph;
}
else
{
mediaTableOrdering[mediaTableSorting] = d3.descending;
mediaTableSortingStatus[mediaTableSorting] = ordinal ? ordinalDescendingGlyph : numericDescendingGlyph;
}
mediaTableOnClickUpdate(mediaTable,orderId)
}
}
$('#legalAlphabetOrder').click( function () {
legalTableSorting = "alphabet";
changeOrderingState(true,true,$(this));
});
$('#legalRelationOrder').click( function () {
legalTableSorting = "relation";
changeOrderingState(true,false,$(this));
});
$('#legalSumOrder').click( function () {
legalTableSorting = "sum";
changeOrderingState(true,false,$(this));
});
$('#legalTrendOrder').click( function () {
legalTableSorting = "trend";
changeOrderingState(true,false,$(this));
});
$('#mediaAlphabetOrder').click( function () {
mediaTableSorting = "alphabet";
changeOrderingState(false,true,$(this));
});
$('#mediaRelationOrder').click( function () {
mediaTableSorting = "relation";
changeOrderingState(false,false,$(this));
});
$('#mediaSumOrder').click( function () {
mediaTableSorting = "sum";
changeOrderingState(false,false,$(this));
});
$('#mediaTrendOrder').click( function () {
mediaTableSorting = "trend";
changeOrderingState(false,false,$(this));
});
$(window).on('resize', function(){
rescaleAll();
updateAll();
});
};