(args)
| 170 | } |
| 171 | |
| 172 | private handleClick(args) { |
| 173 | const index = args.rowNum * this.numColumns + args.columnNum; |
| 174 | const row = args.rowNum; |
| 175 | const column = args.columnNum; |
| 176 | let idx: [number, number][] = Array.from(this.model.get('selected') || []); |
| 177 | let selected = this.indicesToCellNums(idx); |
| 178 | const elem_index = selected.indexOf(index); |
| 179 | const accelKey = d3GetEvent().ctrlKey || d3GetEvent().metaKey; |
| 180 | //TODO: This is a shim for when accelKey is supported by chrome. |
| 181 | // index of slice i. Checking if it is already present in the |
| 182 | // list |
| 183 | if (elem_index > -1 && accelKey) { |
| 184 | // if the index is already selected and if ctrl key is |
| 185 | // pressed, remove the element from the list |
| 186 | idx.splice(elem_index, 1); |
| 187 | } else { |
| 188 | if (!accelKey) { |
| 189 | selected = []; |
| 190 | idx = []; |
| 191 | } |
| 192 | idx.push([row, column]); |
| 193 | selected.push(this.indicesToCellNums([[row, column]])[0]); |
| 194 | if (d3GetEvent().shiftKey) { |
| 195 | //If shift is pressed and the element is already |
| 196 | //selected, do not do anything |
| 197 | if (elem_index > -1) { |
| 198 | return; |
| 199 | } |
| 200 | //Add elements before or after the index of the current |
| 201 | //slice which has been clicked |
| 202 | const row_index = selected.length !== 0 ? this.anchorCellIndex[0] : row; |
| 203 | const col_index = |
| 204 | selected.length !== 0 ? this.anchorCellIndex[1] : column; |
| 205 | _.range(Math.min(row, row_index), Math.max(row, row_index) + 1).forEach( |
| 206 | (i) => { |
| 207 | _.range( |
| 208 | Math.min(column, col_index), |
| 209 | Math.max(column, col_index) + 1 |
| 210 | ).forEach((j) => { |
| 211 | const cell_num = this.indicesToCellNums([[i, j]])[0]; |
| 212 | if (selected.indexOf(cell_num) === -1) { |
| 213 | selected.push(cell_num); |
| 214 | idx.push([i, j]); |
| 215 | } |
| 216 | }); |
| 217 | } |
| 218 | ); |
| 219 | } else { |
| 220 | // updating the array containing the slice indexes selected |
| 221 | // and updating the style |
| 222 | this.anchorCellIndex = [row, column]; |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | this.model.set('selected', idx.length === 0 ? null : idx, { |
| 227 | updated_view: this, |
| 228 | }); |
| 229 | this.touch(); |
nothing calls this directly
no test coverage detected