plate-map 2.0.6 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,271 +0,0 @@
1
- var plateMapWidget = plateMapWidget || {};
2
-
3
- (function($) {
4
-
5
- plateMapWidget.bottomTable = function() {
6
- // for bottom table
7
- return {
8
- _bottomScreen: function() {
9
- this.bottomContainer = this._createElement("<div></div>").addClass("plate-setup-bottom-container");
10
- this.bottomTableContainer = this._createElement("<div></div>").addClass("plate-setup-bottom-table-container");
11
- this.bottomTable = this._createElement("<table></table>").addClass("plate-setup-bottom-table");
12
- this.bottomTableHead = this._createElement("<thead></thead>");
13
- this.bottomTableBody = this._createElement("<tbody></tbody>");
14
- this.bottomTable.append(this.bottomTableHead);
15
- this.bottomTable.append(this.bottomTableBody);
16
- this.bottomTableContainer.append(this.bottomTable);
17
- this.bottomContainer.append(this.bottomTableContainer);
18
- this.container.append(this.bottomContainer);
19
- },
20
-
21
- addBottomTableHeadings: function() {
22
-
23
- let row = this._createElement("<tr></tr>");
24
-
25
- let singleField = this._createElement("<th></th>")
26
- .text("Group");
27
- row.prepend(singleField);
28
-
29
- this.rowCounter = 1;
30
-
31
- for (let i = 0; i < this.globalSelectedAttributes.length; i++) {
32
- let attr = this.globalSelectedAttributes[i];
33
- let field = this.fieldMap[attr];
34
- let singleField = this._createElement("<th></th>").text(field.name);
35
- row.append(singleField);
36
- this.rowCounter = this.rowCounter + 1;
37
- }
38
-
39
- // Now we append all the captions at the place.
40
- this.bottomTableBody.empty();
41
- this.bottomTableHead.empty();
42
- this.bottomTableHead.append(row);
43
- this.adjustFieldWidth(row);
44
- },
45
-
46
- tileAttrText: function(tile, attr) {
47
- let well = this.engine.derivative[tile.index];
48
- let field = this.fieldMap[attr];
49
- return field.getText(well[attr]);
50
- },
51
-
52
- addBottomTableRow: function(color, singleStack) {
53
- let that = this;
54
- let modelTile = this.allTiles[singleStack[0]];
55
- let row = this._createElement("<tr></tr>");
56
- let plateIdDiv = this._createElement("<td></td>").addClass("plate-setup-bottom-id");
57
- let numberText = this._createElement("<button/>");
58
- numberText.addClass("plate-setup-color-text");
59
- numberText.text(color);
60
- plateIdDiv.append(numberText);
61
-
62
- numberText.click(function(evt) {
63
- let addressToSelect = singleStack.map(that.indexToAddress, that);
64
- if (evt.ctrlKey) {
65
- that.getSelectedAddresses().forEach(function(val) {
66
- if (addressToSelect.indexOf(val) < 0) {
67
- addressToSelect.push(val);
68
- }
69
- })
70
- }
71
- that.setSelectedAddresses(addressToSelect);
72
- });
73
-
74
- if (color > 0) {
75
- color = ((color - 1) % (this.colorPairs.length - 1)) + 1;
76
- }
77
- let colorStops = this.colorPairs[color];
78
-
79
- plateIdDiv.css("background", "linear-gradient(to right, " + colorStops[0] + " , " + colorStops[1] + ")");
80
-
81
- row.append(plateIdDiv);
82
-
83
- for (let i = 0; i < this.globalSelectedAttributes.length; i++) {
84
- let attr = this.globalSelectedAttributes[i];
85
- let text = this.tileAttrText(modelTile, attr);
86
- let dataDiv = this._createElement("<td></td>").text(text);
87
- row.append(dataDiv);
88
- }
89
- this.bottomTableBody.append(row);
90
- this.adjustFieldWidth(row);
91
- },
92
-
93
- bottomForFirstTime: function() {
94
- this.addBottomTableHeadings();
95
- // This is executed for the very first time.. !
96
- let row = this._createElement("<tr></tr>");
97
-
98
- let colorStops = this.colorPairs[0];
99
- let plateIdDiv = this._createElement("<td></td>");
100
- plateIdDiv.css("background", "-webkit-linear-gradient(left, " + colorStops[0] + " , " + colorStops[1] + ")");
101
- row.append(plateIdDiv);
102
- this.bottomTableBody.append(row);
103
- this.createExportButton();
104
- },
105
-
106
- adjustFieldWidth: function(row) {
107
-
108
- let length = this.rowCounter;
109
- if ((length) * 150 > 1024) {
110
- row.css("width", (length) * 152 + "px");
111
- }
112
- },
113
-
114
- downloadCSV: function(csv, filename) {
115
- let csvFile;
116
- let downloadLink;
117
-
118
- // CSV file
119
- csvFile = new Blob([csv], {
120
- type: "text/csv"
121
- });
122
-
123
- // Download link
124
- downloadLink = document.createElement("a");
125
-
126
- // File name
127
- downloadLink.download = filename;
128
-
129
- // Create a link to the file
130
- downloadLink.href = window.URL.createObjectURL(csvFile);
131
-
132
- // Hide download link
133
- downloadLink.style.display = "none";
134
-
135
- // Add the link to DOM
136
- document.body.appendChild(downloadLink);
137
-
138
- // Click download link
139
- downloadLink.click();
140
- },
141
-
142
- exportData: function(format) {
143
- let data = [];
144
- let rows = document.querySelectorAll("table tr");
145
-
146
- let colorLocMap = {};
147
- let colorLocIdxMap = this.engine.stackUpWithColor;
148
- for (let colorIdx in colorLocIdxMap) {
149
- if (colorLocIdxMap.hasOwnProperty(colorIdx)) {
150
- colorLocMap[colorIdx] = colorLocIdxMap[colorIdx].map(this.indexToAddress, this);
151
- }
152
- }
153
-
154
- for (let i = 0; i < rows.length; i++) {
155
- let row = [],
156
- cols = rows[i].querySelectorAll("td, th");
157
-
158
- for (let j = 0; j < cols.length; j++) {
159
- let v = "";
160
- if (cols[j].innerText) {
161
- if (format === "csv") {
162
- v = '"' + cols[j].innerText.replace(/"/g, '""') + '"';
163
- } else {
164
- v = cols[j].innerText;
165
- }
166
- }
167
- row.push(v);
168
-
169
- // add location column
170
- if (i === 0 && j === 0) {
171
- if (format === "csv") {
172
- row.push('"Location"');
173
- } else if (format === 'clipboard') {
174
- row.push("Location");
175
- }
176
-
177
- }
178
- if (i !== 0 && j === 0) {
179
- let loc = '';
180
- if (colorLocMap[parseInt(cols[j].innerText)]) {
181
- if (format === "csv") {
182
- loc = '"' + colorLocMap[parseInt(cols[j].innerText)].join(",") + '"';
183
- } else if (format === 'clipboard') {
184
- loc = colorLocMap[parseInt(cols[j].innerText)].join(",");
185
- }
186
- }
187
- row.push(loc);
188
- }
189
- }
190
-
191
- if (format === "csv") {
192
- data.push(row.join(","));
193
- } else if (format === 'clipboard') {
194
- data.push(row.join("\t"));
195
- //data.push(row); // for text type
196
- }
197
-
198
- }
199
- if (format === "csv") {
200
- // Download CSV file
201
- this.downloadCSV(data.join("\n"), 'table.csv');
202
- } else if (format === 'clipboard') {
203
- //return formatTableToString(data); // for text type
204
- return data.join("\n");
205
- }
206
- },
207
-
208
- createExportButton: function() {
209
- let that = this;
210
- let overlayContainer = $("<div>").addClass("plate-setup-bottom-control-container");
211
-
212
- let descriptionDiv = $("<div>").addClass("plate-setup-overlay-text-container");
213
- descriptionDiv.text("Color groups");
214
- overlayContainer.append(descriptionDiv);
215
-
216
- let buttonContainer = $("<div>").addClass("plate-setup-overlay-bottom-button-container");
217
-
218
- // create export csv option
219
- let exportButton = $("<button/>").addClass("plate-setup-button");
220
- exportButton.text("Export CSV");
221
- buttonContainer.append(exportButton);
222
-
223
- exportButton.click(function() {
224
- that.exportData('csv');
225
- exportButton.text("Exported");
226
- exportButton[0].classList.remove("plate-setup-button");
227
- exportButton.addClass("plate-setup-clicked-button");
228
- setTimeout(resetExportText, 3000);
229
- });
230
-
231
- function resetExportText() {
232
- exportButton.text("Export CSV");
233
- exportButton[0].classList.remove("plate-setup-clicked-button");
234
- exportButton.addClass("plate-setup-button");
235
- }
236
-
237
- // creat clipboard option, CLipboard is an external js file located in vendor/asset/javascripts
238
- let clipboardButton = $("<button/>").addClass("plate-setup-button");
239
- clipboardButton.text("Copy To Clipboard");
240
- buttonContainer.append(clipboardButton);
241
-
242
- let clipboard = new ClipboardJS(clipboardButton.get(0), {
243
- text: function() {
244
- return that.exportData("clipboard");
245
- }
246
- });
247
-
248
- clipboard.on('success', function() {
249
- clipboardButton.text("Copied as tab-delimited format");
250
- clipboardButton[0].classList.remove("plate-setup-button");
251
- clipboardButton.addClass("plate-setup-clicked-button");
252
- setTimeout(resetClipboardText, 3000);
253
- });
254
-
255
- function resetClipboardText() {
256
- clipboardButton.text("Copy To Clipboard");
257
- clipboardButton[0].classList.remove("plate-setup-clicked-button");
258
- clipboardButton.addClass("plate-setup-button");
259
- }
260
-
261
- clipboard.on('error', function() {
262
- clipboardButton.text("Failed to copy table to clipboard: browser may be incompatible");
263
- setTimeout(resetClipboardText, 3000);
264
- });
265
-
266
- overlayContainer.append(buttonContainer);
267
- this.bottomContainer.prepend(overlayContainer);
268
- }
269
- };
270
- }
271
- })(jQuery);
@@ -1,159 +0,0 @@
1
- var plateMapWidget = plateMapWidget || {};
2
-
3
- (function($) {
4
-
5
- plateMapWidget.checkBox = function() {
6
- // For those check boxes associated with every field in the tab
7
- return {
8
-
9
- globalSelectedAttributes: [],
10
- globalSelectedMultiplexSubfield: [],
11
- allCheckboxes: [],
12
-
13
- _addCheckBox: function(field) {
14
- let checkImage = $("<span>").html(this._assets.dontImg).addClass("plate-setup-tab-check-box bg-light")
15
- .data("clicked", false);
16
- let linkedFieldId = field.full_id;
17
- checkImage.data("linkedFieldId", linkedFieldId);
18
- field.root.find(".plate-setup-tab-field-left-side").empty().append(checkImage);
19
- this._applyCheckboxHandler(checkImage); // Adding handler for change the image when clicked
20
- field.checkbox = checkImage;
21
- this.allCheckboxes.push(linkedFieldId);
22
- },
23
-
24
- _applyCheckboxHandler: function(checkBoxImage) {
25
- let that = this;
26
- checkBoxImage.click(function() {
27
- let checkBox = $(this);
28
-
29
- let changes = {};
30
- changes[checkBox.data("linkedFieldId")] = !checkBox.data("clicked");
31
-
32
- that.changeCheckboxes(changes);
33
- });
34
- },
35
-
36
- getCheckboxes: function () {
37
- return this.allCheckboxes.filter(function (fieldId) {
38
- let field = this.fieldMap[fieldId];
39
- if (field.mainMultiplexField) {
40
- let subfields = this.globalSelectedMultiplexSubfield[field.mainMultiplexField.id] || [];
41
- return subfields.indexOf(field.id);
42
- } else {
43
- return this.globalSelectedAttributes.indexOf(field.id) >= 0;
44
- }
45
- }, this);
46
- },
47
-
48
- changeSubFieldsCheckboxes: function(field, changes) {
49
- let that = this;
50
- let subFieldToInclude = [];
51
-
52
- field.subFieldList.forEach(function(subField) {
53
- let checkImage = subField.checkbox;
54
- let fieldId = checkImage.data("linkedFieldId");
55
- let clicked = checkImage.data("clicked");
56
- if (fieldId in changes) {
57
- clicked = Boolean(changes[fieldId]);
58
- }
59
- checkImage.data("clicked", clicked);
60
- if (clicked) {
61
- checkImage.html(that._assets.doImg);
62
- subFieldToInclude.push(subField.id);
63
- } else {
64
- checkImage.html(that._assets.dontImg);
65
- }
66
- });
67
- return subFieldToInclude;
68
- },
69
-
70
- changeCheckboxes: function(changes, noUndoRedo) {
71
- let gsa = [];
72
- let multiplexCheckedSubField = {};
73
- for (let i = 0; i < this.fieldList.length; i++) {
74
- let field = this.fieldList[i];
75
- if (field.checkbox) {
76
- if (field.subFieldList) {
77
- multiplexCheckedSubField[field.id] = this.changeSubFieldsCheckboxes(field, changes);
78
- }
79
-
80
- let checkImage = field.checkbox;
81
- let fieldId = checkImage.data("linkedFieldId");
82
- let clicked = checkImage.data("clicked");
83
- if (fieldId in changes) {
84
- clicked = Boolean(changes[fieldId]);
85
- }
86
- checkImage.data("clicked", clicked);
87
- if (clicked) {
88
- gsa.push(fieldId);
89
- checkImage.html(this._assets.doImg);
90
- } else {
91
- checkImage.html(this._assets.dontImg);
92
- }
93
- }
94
- }
95
- this.globalSelectedMultiplexSubfield = multiplexCheckedSubField;
96
- this.globalSelectedAttributes = gsa;
97
- this._clearPresetSelection();
98
- this._colorMixer();
99
- if (!noUndoRedo) {
100
- this.addToUndoRedo();
101
- }
102
- },
103
-
104
- setSubFieldCheckboxes: function(field, fieldIds) {
105
- let that = this;
106
- let subFieldToInclude = [];
107
- field.subFieldList.forEach(function(subField) {
108
- let checkImage = subField.checkbox;
109
- let fieldId = checkImage.data("linkedFieldId");
110
- let clicked = fieldIds.indexOf(fieldId) >= 0;
111
- checkImage.data("clicked", clicked);
112
- if (clicked) {
113
- checkImage.html(that._assets.doImg);
114
- subFieldToInclude.push(subField.id);
115
- } else {
116
- checkImage.html(that._assets.dontImg);
117
- }
118
- });
119
- return subFieldToInclude;
120
- },
121
-
122
- setCheckboxes: function(fieldIds, noUndoRedo) {
123
- fieldIds = fieldIds || [];
124
- let gsa = [];
125
- let multiplexCheckedSubField = {};
126
-
127
- for (let i = 0; i < this.fieldList.length; i++) {
128
- let field = this.fieldList[i];
129
- if (field.checkbox) {
130
- // special handling for multiplex field
131
- if (field.subFieldList) {
132
- multiplexCheckedSubField[field.id] = this.setSubFieldCheckboxes(field, fieldIds);
133
- }
134
-
135
- let checkImage = field.checkbox;
136
- let fieldId = checkImage.data("linkedFieldId");
137
- let clicked = fieldIds.indexOf(fieldId) >= 0;
138
- checkImage.data("clicked", clicked);
139
- if (clicked) {
140
- gsa.push(fieldId);
141
- checkImage.html(this._assets.doImg);
142
- } else {
143
-
144
- checkImage.html(this._assets.dontImg);
145
- }
146
- }
147
- }
148
- this.globalSelectedMultiplexSubfield = multiplexCheckedSubField;
149
- this.globalSelectedAttributes = gsa;
150
- this._clearPresetSelection();
151
- this._colorMixer();
152
- if (!noUndoRedo) {
153
- this.addToUndoRedo();
154
- }
155
- }
156
-
157
- };
158
- }
159
- })(jQuery);
@@ -1,59 +0,0 @@
1
- var plateMapWidget = plateMapWidget || {};
2
-
3
- plateMapWidget.colorManager = function() {
4
-
5
- return {
6
- // See these are color pairs for the gradient.
7
- colorPairs: [
8
- ["#e6e6e6", "#808080"],
9
- ["#66e8ff", "#0082c8"],
10
- ["#ff7fb1", "#e6194b"],
11
- ["#a2ffb1", "#3cb44b"],
12
- ["#f784ff", "#911eb4"],
13
- ["#ffe897", "#f58231"],
14
- ["#6666ff", "#0000FF"],
15
- ["#ffff7f", "#ffe119"],
16
- ["#acffff", "#46f0f0"],
17
- ["#ff98ff", "#f032e6"],
18
- ["#ffffa2", "#d2f53c"],
19
- ["#ffffff", "#fabebe"],
20
- ["#66e6e6", "#008080"],
21
- ["#ffffff", "#e6beff"],
22
- ["#ffd48e", "#aa6e28"],
23
- ["#e66666", "#800000"],
24
- ["#ffffff", "#aaffc3"],
25
- ["#e6e666", "#808000"],
26
- ["#ffffff", "#ffd8b1"],
27
- ["#66a9ef", "#004389"],
28
- ["#ff6672", "#a7000c"],
29
- ["#66db72", "#00750c"],
30
- ["#b866db", "#520075"],
31
- ["#ffa966", "#b64300"],
32
- ["#ffff66", "#c0a200"],
33
- ["#6dffff", "#07b1b1"],
34
- ["#ff66ff", "#b100a7"],
35
- ["#f9ff66", "#93b600"],
36
- ["#ffe5e5", "#bb7f7f"],
37
- ["#66a7a7", "#004141"],
38
- ["#ffe5ff", "#a77fc0"],
39
- ["#d19566", "#6b2f00"],
40
- ["#ffffef", "#c0bb89"],
41
- ["#d1ffea", "#6bc084"],
42
- ["#a7a766", "#414100"],
43
- ["#ffffd8", "#c09972"],
44
- ["#a5ffff", "#3fc1ff"],
45
- ["#ffbef0", "#ff588a"],
46
- ["#e1fff0", "#7bf38a"],
47
- ["#ffc3ff", "#d05df3"],
48
- ["#ffffd6", "#ffc170"],
49
- ["#a5a5ff", "#3f3fff"],
50
- ["#ffffbe", "#ffff58"],
51
- ["#ebffff", "#85ffff"],
52
- ["#ffd7ff", "#ff71ff"],
53
- ["#a5ffff", "#3fbfbf"],
54
- ["#ffffcd", "#e9ad67"],
55
- ["#ffa5a5", "#bf3f3f"],
56
- ["#ffffa5", "#bfbf3f"]
57
- ]
58
- }
59
- };