forked from nebiolabs/plate-map
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bottom-table.js
85 lines (64 loc) · 3.2 KB
/
bottom-table.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
var plateLayOutWidget = plateLayOutWidget || {};
(function($, fabric) {
plateLayOutWidget.bottomTable = function() {
// for bottom table
return {
_bottomScreen: function() {
this.bottomContainer = this._createElement("<div></div>").addClass("plate-setup-bottom-container");
$(this.container).append(this.bottomContainer);
},
addBottomTableHeadings: function() {
this.bottomRow = this._createElement("<div></div>").addClass("plate-setup-bottom-row");
var singleField = this._createElement("<div></div>").addClass("plate-setup-bottom-single-field")
.html("<div>" + "Plate ID" + "</div>");
$(this.bottomRow).addClass("plate-setup-bottom-row-seperate")
.prepend(singleField);
// Now we append all the captions at the place.
$(this.bottomContainer).html(this.bottomRow);
this.rowCounter = 1;
for(var attr in this.globalSelectedAttributes) {
var fieldName = $("#" + attr).data("caption");
var singleField = this._createElement("<div></div>").addClass("plate-setup-bottom-single-field")
.html("<div>" + fieldName + "</div>");
$(this.bottomRow).append(singleField);
this.rowCounter = this.rowCounter + 1;
}
this.adjustFieldWidth(this.bottomRow);
},
addBottomTableRow: function(colors, singleStack) {
var modelTile = this.allTiles[singleStack[0]];
var row = this._createElement("<div></div>").addClass("plate-setup-bottom-row-data");
var plateIdDiv = this._createElement("<div></div>").addClass("plate-setup-bottom-single-field-data");
if(this.engine.stackPointer <= (this.colorPairs.length / 2) +1){
$(plateIdDiv).css("background", "-webkit-linear-gradient(left, "+ this.valueToColor[color] +" , "+ this.colorPairObject[this.valueToColor[color]] +")");
} else {
$(plateIdDiv).html(colors);
}
$(row).append(plateIdDiv);
for(var attr in this.globalSelectedAttributes) {
var data = (modelTile.wellData[attr] == "NULL") ? "" : modelTile.wellData[attr];
var dataDiv = this._createElement("<div></div>").addClass("plate-setup-bottom-single-field-data").html(data);
$(row).append(dataDiv);
}
$(this.bottomContainer).append(row);
this.adjustFieldWidth(row);
},
bottomForFirstTime: function() {
this.addBottomTableHeadings();
// This is executed for the very first time.. !
var row = this._createElement("<div></div>").addClass("plate-setup-bottom-row-data");
var colorStops = {0: this.colorPairs[0], 1: this.colorPairs[1]};
var plateIdDiv = this._createElement("<div></div>").addClass("plate-setup-bottom-single-field-data");
$(plateIdDiv).css("background", "-webkit-linear-gradient(left, "+ colorStops[0] +" , "+ colorStops[1] +")");
$(row).append(plateIdDiv);
$(this.bottomContainer).append(row);
},
adjustFieldWidth: function(row) {
var length = this.rowCounter;
if((length) * 150 > 1024) {
$(row).css("width", (length) * 152 + "px");
}
}
};
}
})(jQuery, fabric);