|
1 | 1 | /** |
2 | 2 | * Plugin statusbar for JSpreadsheet Pro |
3 | 3 | * |
4 | | - * @version 2.3.5 |
| 4 | + * @version 2.3.6 |
5 | 5 | * @author Guillaume Bonnaire <contact@gbonnaire.fr> |
6 | 6 | * @website https://repo.gbonnaire.fr |
7 | 7 | * @summary Add status bar on bottom of JSpreadsheet |
|
30 | 30 | * |
31 | 31 | * @description Status bar is a plugin for add a status bar on bottom of the sheet like Excel. On this status bar you can add new row with button, and show information on selection (Range selected, Formulas, etc.) |
32 | 32 | * Release notes |
| 33 | + * Version 2.3.6: Fix #18 |
33 | 34 | * Version 2.3.5: Fix #17 |
34 | 35 | * Version 2.3.4: Fix #16 |
35 | 36 | * Version 2.3.3: Manage after change cell content |
|
165 | 166 | if (worksheet.options.allowInsertRow) { |
166 | 167 | // Detect if need insert or add the end |
167 | 168 | if((worksheet.getSelectedRows(true).length == 1 && worksheet.getSelectedColumns().length == worksheet.options.data[0].length) || plugin.options.closeInsertionOnly) { |
168 | | - worksheet.insertRow(parseInt(inputAddQuantity.value), getMaxPosition(worksheet.getSelectedRows(true))); |
| 169 | + if(worksheet.selectedCell) { |
| 170 | + worksheet.insertRow(parseInt(inputAddQuantity.value), getMaxPosition(worksheet.getSelectedRows(true))); |
| 171 | + } |
169 | 172 | } else { |
170 | 173 | worksheet.goto(worksheet.options.data.length,getMinPosition(worksheet.getSelectedColumns())); |
171 | 174 | worksheet.insertRow(parseInt(inputAddQuantity.value)); |
|
182 | 185 | if (worksheet.options.allowInsertRow) { |
183 | 186 | // Detect if need insert or add the end |
184 | 187 | if((worksheet.getSelectedRows(true).length == 1 && worksheet.getSelectedColumns().length == worksheet.options.data[0].length) || plugin.options.closeInsertionOnly) { |
185 | | - worksheet.insertRow(parseInt(inputAddQuantity.value), getMinPosition(worksheet.getSelectedRows(true)), true); |
| 188 | + if(worksheet.selectedCell) { |
| 189 | + worksheet.insertRow(parseInt(inputAddQuantity.value), getMinPosition(worksheet.getSelectedRows(true)), true); |
| 190 | + } |
186 | 191 | } else { |
187 | 192 | worksheet.goto(0,getMinPosition(worksheet.getSelectedColumns())); |
188 | 193 | worksheet.insertRow(parseInt(inputAddQuantity.value), 0 , true); |
|
199 | 204 | if (worksheet.options.allowInsertColumn) { |
200 | 205 | // Detect if need insert or add the end |
201 | 206 | if((worksheet.getSelectedColumns().length == 1 && worksheet.getSelectedRows(true).length == worksheet.options.data.length) || plugin.options.closeInsertionOnly) { |
202 | | - worksheet.insertColumn(parseInt(inputAddQuantity.value), getMaxPosition(worksheet.getSelectedColumns())); |
| 207 | + if(worksheet.selectedCell) { |
| 208 | + worksheet.insertColumn(parseInt(inputAddQuantity.value), getMaxPosition(worksheet.getSelectedColumns())); |
| 209 | + } |
203 | 210 | } else { |
204 | 211 | worksheet.goto(getMinPosition(worksheet.getSelectedRows(true)),worksheet.options.data[0].length); |
205 | 212 | worksheet.insertColumn(parseInt(inputAddQuantity.value)); |
|
216 | 223 | if (worksheet.options.allowInsertColumn) { |
217 | 224 | // Detect if need insert or add the end |
218 | 225 | if((worksheet.getSelectedColumns().length == 1 && worksheet.getSelectedRows(true).length == worksheet.options.data.length) || plugin.options.closeInsertionOnly) { |
219 | | - worksheet.insertColumn(parseInt(inputAddQuantity.value), getMinPosition(worksheet.getSelectedColumns()), true); |
| 226 | + if(worksheet.selectedCell) { |
| 227 | + worksheet.insertColumn(parseInt(inputAddQuantity.value), getMinPosition(worksheet.getSelectedColumns()), true); |
| 228 | + } |
220 | 229 | } else { |
221 | 230 | worksheet.goto(getMinPosition(worksheet.getSelectedRows(true)),0); |
222 | 231 | worksheet.insertColumn(parseInt(inputAddQuantity.value), 0, true); |
|
406 | 415 | return spreadsheet.worksheets[0]; |
407 | 416 | } |
408 | 417 |
|
| 418 | + /** |
| 419 | + * get max position |
| 420 | + */ |
409 | 421 | function getMaxPosition(values) { |
410 | 422 | if(typeof values == "object" && !Array.isArray(values)) { |
411 | 423 | values = Object.values(values); |
|
423 | 435 | } |
424 | 436 | } |
425 | 437 |
|
| 438 | + /** |
| 439 | + * get min position |
| 440 | + */ |
426 | 441 | function getMinPosition(values) { |
427 | 442 | if(typeof values == "object" && !Array.isArray(values)) { |
428 | 443 | values = Object.values(values); |
|
0 commit comments