| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | /** |
| 2 | - * Jspreadsheet v4.2.1 | |
| 2 | + * Jspreadsheet v4.15.0 | |
| 3 | 3 | * |
| 4 | 4 | * Website: https://bossanova.uk/jspreadsheet/ |
| 5 | 5 | * Description: Create amazing web based spreadsheets. |
| 6 | 6 | * |
| @@ -6,9 +6,12 @@ | ||
| 6 | 6 | * |
| 7 | 7 | * This software is distributed under MIT License |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -// TablePress: var formula = ... removed. | |
| 10 | +/* TablePress: | |
| 11 | + * - var formula = ... removed. | |
| 12 | + * - obj.updateTablePressToolbarUndoRedoState(); added | |
| 13 | + */ | |
| 11 | 14 | |
| 12 | 15 | ;(function (global, factory) { |
| 13 | 16 | // TablePress: Comment out next to lines to force creation of a global jspreadsheet object. |
| 14 | 17 | // typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : |
| @@ -22,9 +25,9 @@ | ||
| 22 | 25 | var Version = function() { |
| 23 | 26 | // Information |
| 24 | 27 | var info = { |
| 25 | 28 | title: 'Jspreadsheet', |
| 26 | - version: '4.2.1', | |
| 29 | + version: '4.15.0', | |
| 27 | 30 | type: 'CE', |
| 28 | 31 | host: 'https://bossanova.uk/jspreadsheet', |
| 29 | 32 | license: 'MIT', |
| 30 | 33 | print: function() { |
| @@ -689,19 +692,9 @@ | ||
| 689 | 692 | var ads = document.createElement('a'); |
| 690 | 693 | ads.setAttribute('href', 'https://bossanova.uk/jspreadsheet/'); |
| 691 | 694 | obj.ads = document.createElement('div'); |
| 692 | 695 | obj.ads.className = 'jexcel_about'; |
| 693 | - /* // TablePress: Remove this as it loads a file from the Jspreadsheet server. | |
| 694 | - try { | |
| 695 | - if (typeof(sessionStorage) !== "undefined" && ! sessionStorage.getItem('jexcel')) { | |
| 696 | - sessionStorage.setItem('jexcel', true); | |
| 697 | - var img = document.createElement('img'); | |
| 698 | - img.src = '//bossanova.uk/jspreadsheet/logo.png'; | |
| 699 | - ads.appendChild(img); | |
| 700 | - } | |
| 701 | - } catch (exception) { | |
| 702 | - } | |
| 703 | - */ | |
| 696 | + | |
| 704 | 697 | var span = document.createElement('span'); |
| 705 | 698 | span.innerHTML = 'Jspreadsheet CE'; |
| 706 | 699 | ads.appendChild(span); |
| 707 | 700 | obj.ads.appendChild(ads); |
| @@ -3954,17 +3947,20 @@ | ||
| 3954 | 3947 | newValue[j] = temp[j][0]; |
| 3955 | 3948 | } |
| 3956 | 3949 | |
| 3957 | 3950 | // TablePress: Keep Table Head and Table Foot row at the top/bottom, if used. |
| 3958 | - if ( window?.tp?.table?.options?.table_head ) { | |
| 3959 | - const first_row_idx = 0; | |
| 3960 | - newValue = newValue.filter( ( row_idx ) => ( row_idx > first_row_idx ) ); | |
| 3961 | - newValue.unshift( first_row_idx ); | |
| 3951 | + if ( window?.tp?.table?.options?.table_head > 0 ) { | |
| 3952 | + const last_head_row_idx = window?.tp?.table?.options?.table_head - 1; | |
| 3953 | + newValue = newValue.filter( ( row_idx ) => ( row_idx > last_head_row_idx ) ); | |
| 3954 | + newValue.unshift( ...Array( window?.tp?.table?.options?.table_head ).keys() ); | |
| 3962 | 3955 | } |
| 3963 | - if ( window?.tp?.table?.options?.table_foot ) { | |
| 3956 | + if ( window?.tp?.table?.options?.table_foot > 0) { | |
| 3964 | 3957 | const last_row_idx = newValue.length - 1; |
| 3965 | - newValue = newValue.filter( ( row_idx ) => ( row_idx < last_row_idx ) ); | |
| 3966 | - newValue.push( last_row_idx ); | |
| 3958 | + const first_foot_row_idx = newValue.length - window?.tp?.table?.options?.table_foot; | |
| 3959 | + newValue = newValue.filter( ( row_idx ) => ( row_idx < first_foot_row_idx ) ); | |
| 3960 | + for ( let idx = first_foot_row_idx; idx <= last_row_idx; idx++ ) { | |
| 3961 | + newValue.push( idx ); | |
| 3962 | + } | |
| 3967 | 3963 | } |
| 3968 | 3964 | |
| 3969 | 3965 | // Save history |
| 3970 | 3966 | obj.setHistory({ |
| @@ -5354,9 +5350,9 @@ | ||
| 5354 | 5350 | obj.formula[tokens[i]].push(parentId); |
| 5355 | 5351 | } |
| 5356 | 5352 | |
| 5357 | 5353 | // Do not calculate again |
| 5358 | - if (eval('typeof(' + tokens[i] + ') == "undefined"')) { | |
| 5354 | + if (typeof globalThis[tokens[i]] === 'undefined') { | |
| 5359 | 5355 | // Coords |
| 5360 | 5356 | var position = jexcel.getIdFromColumnName(tokens[i], 1); |
| 5361 | 5357 | // Get value |
| 5362 | 5358 | if (typeof(obj.options.data[position[1]]) != 'undefined' && typeof(obj.options.data[position[1]][position[0]]) != 'undefined') { |
| @@ -6271,8 +6267,36 @@ | ||
| 6271 | 6267 | } |
| 6272 | 6268 | } |
| 6273 | 6269 | |
| 6274 | 6270 | /** |
| 6271 | + * TablePress: Initialize the toolbar state for undo/redo buttons. | |
| 6272 | + */ | |
| 6273 | + obj.tablePressToolbarUndoRedoState = { | |
| 6274 | + undoDisabled: true, | |
| 6275 | + redoDisabled: true, | |
| 6276 | + }; | |
| 6277 | + | |
| 6278 | + /** | |
| 6279 | + * TablePress: Updates the toolbar state for undo/redo buttons, if the state has changed. | |
| 6280 | + * | |
| 6281 | + * @return null | |
| 6282 | + */ | |
| 6283 | + obj.updateTablePressToolbarUndoRedoState = function() { | |
| 6284 | + const newToolbarUndoRedoState = { | |
| 6285 | + undoDisabled: ( -1 === obj.historyIndex ), | |
| 6286 | + redoDisabled: ( obj.historyIndex === obj.history.length - 1 ), | |
| 6287 | + }; | |
| 6288 | + | |
| 6289 | + if ( | |
| 6290 | + newToolbarUndoRedoState.undoDisabled !== obj.tablePressToolbarUndoRedoState.undoDisabled | |
| 6291 | + || newToolbarUndoRedoState.redoDisabled !== obj.tablePressToolbarUndoRedoState.redoDisabled | |
| 6292 | + ) { | |
| 6293 | + obj.tablePressToolbarUndoRedoState = newToolbarUndoRedoState; | |
| 6294 | + wp?.hooks?.doAction?.( 'tablepress.toolbarUndoRedoStateUpdate', newToolbarUndoRedoState ); | |
| 6295 | + } | |
| 6296 | + }; | |
| 6297 | + | |
| 6298 | + /** | |
| 6275 | 6299 | * Initializes a new history record for undo/redo |
| 6276 | 6300 | * |
| 6277 | 6301 | * @return null |
| 6278 | 6302 | */ |
| @@ -6285,8 +6309,11 @@ | ||
| 6285 | 6309 | obj.history = (obj.history = obj.history.slice(0, index + 1)); |
| 6286 | 6310 | |
| 6287 | 6311 | // Keep history |
| 6288 | 6312 | obj.history[index] = changes; |
| 6313 | + | |
| 6314 | + // TablePress: Update the toolbar state for undo/redo buttons. | |
| 6315 | + obj.updateTablePressToolbarUndoRedoState(); | |
| 6289 | 6316 | } |
| 6290 | 6317 | } |
| 6291 | 6318 | |
| 6292 | 6319 | /** |
| @@ -6875,8 +6902,11 @@ | ||
| 6875 | 6902 | obj.ignoreHistory = ignoreHistory; |
| 6876 | 6903 | |
| 6877 | 6904 | // Events |
| 6878 | 6905 | obj.dispatch('onundo', el, historyRecord); |
| 6906 | + | |
| 6907 | + // TablePress: Update the toolbar state for undo/redo buttons. | |
| 6908 | + obj.updateTablePressToolbarUndoRedoState(); | |
| 6879 | 6909 | } |
| 6880 | 6910 | |
| 6881 | 6911 | /** |
| 6882 | 6912 | * Redo previously undone action |
| @@ -6942,8 +6972,11 @@ | ||
| 6942 | 6972 | obj.ignoreHistory = ignoreHistory; |
| 6943 | 6973 | |
| 6944 | 6974 | // Events |
| 6945 | 6975 | obj.dispatch('onredo', el, historyRecord); |
| 6976 | + | |
| 6977 | + // TablePress: Update the toolbar state for undo/redo buttons. | |
| 6978 | + obj.updateTablePressToolbarUndoRedoState(); | |
| 6946 | 6979 | } |
| 6947 | 6980 | |
| 6948 | 6981 | /** |
| 6949 | 6982 | * Get dropdown value from key |