11/**
2- * (c) jExcel v3.4.2
2+ * (c) jExcel v3.4.3
33 *
44 * Author: Paul Hodel <[email protected] > 55 * Website: https://bossanova.uk/jexcel/
@@ -111,10 +111,13 @@ var jexcel = (function(el, options) {
111111 meta : null ,
112112 // Style
113113 style :null ,
114+ // Execute formulas
115+ parseFormulas :true ,
114116 // Event handles
115117 onload :null ,
116118 onchange :null ,
117119 onbeforechange :null ,
120+ onafterchange :null ,
118121 onbeforeinsertrow : null ,
119122 oninsertrow :null ,
120123 onbeforeinsertcolumn : null ,
@@ -220,6 +223,7 @@ var jexcel = (function(el, options) {
220223 obj . style = [ ] ;
221224 obj . meta = [ ] ;
222225 obj . data = null ;
226+ obj . border = { } ;
223227
224228 // Internal controllers
225229 obj . cursor = null ;
@@ -830,7 +834,7 @@ var jexcel = (function(el, options) {
830834 td . appendChild ( img ) ;
831835 }
832836 } else {
833- if ( ( '' + value ) . substr ( 0 , 1 ) == '=' ) {
837+ if ( ( '' + value ) . substr ( 0 , 1 ) == '=' && obj . options . parseFormulas == true ) {
834838 value = obj . executeFormula ( value , i , j )
835839 }
836840 if ( obj . options . columns [ i ] . mask ) {
@@ -1668,6 +1672,13 @@ var jexcel = (function(el, options) {
16681672
16691673 // Update table with custom configurations if applicable
16701674 obj . updateTable ( ) ;
1675+
1676+ // On after change
1677+ if ( ! obj . ignoreEvents ) {
1678+ if ( typeof ( obj . options . onafterchange ) == 'function' ) {
1679+ obj . options . onafterchange ( el , records , value ) ;
1680+ }
1681+ }
16711682 }
16721683
16731684 /**
@@ -1694,6 +1705,13 @@ var jexcel = (function(el, options) {
16941705
16951706 // Update table with custom configurations if applicable
16961707 obj . updateTable ( ) ;
1708+
1709+ // On after change
1710+ if ( ! obj . ignoreEvents ) {
1711+ if ( typeof ( obj . options . onafterchange ) == 'function' ) {
1712+ obj . options . onafterchange ( el , records , value ) ;
1713+ }
1714+ }
16971715 }
16981716
16991717 /**
@@ -1719,6 +1737,13 @@ var jexcel = (function(el, options) {
17191737 records :records ,
17201738 selection :obj . selectedCell ,
17211739 } ) ;
1740+
1741+ // On after change
1742+ if ( ! obj . ignoreEvents ) {
1743+ if ( typeof ( obj . options . onafterchange ) == 'function' ) {
1744+ obj . options . onafterchange ( el , records ) ;
1745+ }
1746+ }
17221747 }
17231748 }
17241749
@@ -1812,7 +1837,7 @@ var jexcel = (function(el, options) {
18121837 obj . options . data [ y ] [ x ] = value ;
18131838 }
18141839 // Label
1815- if ( ( '' + value ) . substr ( 0 , 1 ) == '=' ) {
1840+ if ( ( '' + value ) . substr ( 0 , 1 ) == '=' && obj . options . parseFormulas == true ) {
18161841 value = obj . executeFormula ( value , x , y ) ;
18171842 }
18181843 if ( obj . options . columns [ x ] . mask ) {
@@ -1973,6 +1998,42 @@ var jexcel = (function(el, options) {
19731998
19741999 // Update table with custom configuration if applicable
19752000 obj . updateTable ( ) ;
2001+
2002+ // On after change
2003+ if ( ! obj . ignoreEvents ) {
2004+ if ( typeof ( obj . options . onafterchange ) == 'function' ) {
2005+ obj . options . onafterchange ( el , records ) ;
2006+ }
2007+ }
2008+ }
2009+
2010+ obj . setBorder = function ( x1 , y1 , x2 , y2 , border ) {
2011+ if ( ! obj . border [ border ] ) {
2012+ obj . border [ border ] = document . createElement ( 'div' ) ;
2013+ obj . border [ border ] . classList . add ( 'jexcel_border' ) ;
2014+ if ( border == 'copying' ) {
2015+ obj . border [ border ] . classList . add ( 'jexcel_copying' ) ;
2016+ } else {
2017+ obj . border [ border ] . style . borderColor = border ;
2018+ //obj.border[border].style.backgroundColor = 'rgba(0,0,0,0.1)';
2019+ }
2020+ el . appendChild ( obj . border [ border ] ) ;
2021+ }
2022+
2023+ // Get last cell
2024+ var first = obj . records [ x1 ] [ y1 ] . getBoundingClientRect ( ) ;
2025+ var x1 = first . left ;
2026+ var y1 = first . top ;
2027+
2028+ var last = obj . records [ x2 ] [ y2 ] . getBoundingClientRect ( ) ;
2029+ var w1 = ( last . left + last . width ) - first . left - 2 ;
2030+ var h1 = ( last . top + last . height ) - first . top - 2 ;
2031+
2032+ // Place the corner in the correct place
2033+ obj . border [ border ] . style . top = y1 + 'px' ;
2034+ obj . border [ border ] . style . left = x1 + 'px' ;
2035+ obj . border [ border ] . style . width = w1 + 'px' ;
2036+ obj . border [ border ] . style . height = h1 + 'px' ;
19762037 }
19772038
19782039 /**
@@ -5121,34 +5182,14 @@ var jexcel = (function(el, options) {
51215182 obj . textarea . value = str ;
51225183 }
51235184 obj . textarea . select ( ) ;
5124- jexcel . copyControls . enabled = false ;
51255185 document . execCommand ( "copy" ) ;
5126- jexcel . copyControls . enabled = true ;
51275186 }
51285187
51295188 // Keep data
51305189 obj . data = str ;
51315190 // Keep non visible information
51325191 obj . hashString = obj . hash ( obj . textarea . value ) ;
51335192
5134- // Highlight
5135- /*for (var i = 0; i < obj.highlighted.length; i++) {
5136- obj.highlighted[i].classList.add('copying');
5137-
5138- if (obj.highlighted[i].classList.contains('highlight-top')) {
5139- obj.highlighted[i].classList.add('copying-top');
5140- }
5141- if (obj.highlighted[i].classList.contains('highlight-right')) {
5142- obj.highlighted[i].classList.add('copying-right');
5143- }
5144- if (obj.highlighted[i].classList.contains('highlight-bottom')) {
5145- obj.highlighted[i].classList.add('copying-bottom');
5146- }
5147- if (obj.highlighted[i].classList.contains('highlight-left')) {
5148- obj.highlighted[i].classList.add('copying-left');
5149- }
5150- }*/
5151-
51525193 return str ;
51535194 }
51545195
@@ -5238,13 +5279,13 @@ var jexcel = (function(el, options) {
52385279 oldStyle :oldStyle ,
52395280 } ) ;
52405281
5282+ // Update table
5283+ obj . updateTable ( ) ;
5284+
52415285 // Paste event
52425286 if ( typeof ( obj . options . onpaste ) == 'function' ) {
52435287 obj . options . onpaste ( el , records ) ;
52445288 }
5245-
5246- // Update table
5247- obj . updateTable ( ) ;
52485289 }
52495290 }
52505291
@@ -5912,8 +5953,6 @@ jexcel.destroy = function(element, destroyEventHandlers) {
59125953 document . removeEventListener ( "mousemove" , jexcel . mouseMoveControls ) ;
59135954 document . removeEventListener ( "mouseover" , jexcel . mouseOverControls ) ;
59145955 document . removeEventListener ( "dblclick" , jexcel . doubleClickControls ) ;
5915- document . removeEventListener ( "copy" , jexcel . copyControls ) ;
5916- document . removeEventListener ( "cut" , jexcel . cutControls ) ;
59175956 document . removeEventListener ( "paste" , jexcel . pasteControls ) ;
59185957 document . removeEventListener ( "contextmenu" , jexcel . contextMenuControls ) ;
59195958 document . removeEventListener ( "touchstart" , jexcel . touchStartControls ) ;
@@ -5931,8 +5970,6 @@ jexcel.build = function() {
59315970 document . addEventListener ( "mousemove" , jexcel . mouseMoveControls ) ;
59325971 document . addEventListener ( "mouseover" , jexcel . mouseOverControls ) ;
59335972 document . addEventListener ( "dblclick" , jexcel . doubleClickControls ) ;
5934- document . addEventListener ( "copy" , jexcel . copyControls ) ;
5935- document . addEventListener ( "cut" , jexcel . cutControls ) ;
59365973 document . addEventListener ( "paste" , jexcel . pasteControls ) ;
59375974 document . addEventListener ( "contextmenu" , jexcel . contextMenuControls ) ;
59385975 document . addEventListener ( "touchstart" , jexcel . touchStartControls ) ;
@@ -6198,6 +6235,25 @@ jexcel.keyDownControls = function(e) {
61986235 // Ctrl + Z
61996236 jexcel . current . undo ( ) ;
62006237 e . preventDefault ( ) ;
6238+ } else if ( e . which == 67 ) {
6239+ // Ctrl + C
6240+ jexcel . current . copy ( true ) ;
6241+ e . preventDefault ( ) ;
6242+ } else if ( e . which == 67 ) {
6243+ // Ctrl + C
6244+ jexcel . current . copy ( true ) ;
6245+ e . preventDefault ( ) ;
6246+ } else if ( e . which == 88 ) {
6247+ // Ctrl + X
6248+ if ( jexcel . current . options . editable == true ) {
6249+ jexcel . cutControls ( ) ;
6250+ } else {
6251+ jexcel . copyControls ( ) ;
6252+ }
6253+ e . preventDefault ( ) ;
6254+ } else if ( e . which == 86 ) {
6255+ // Ctrl + V
6256+ jexcel . pasteControls ( ) ;
62016257 }
62026258 } else {
62036259 if ( jexcel . current . selectedCell ) {
@@ -6829,11 +6885,13 @@ jexcel.cutControls = function(e) {
68296885jexcel . pasteControls = function ( e ) {
68306886 if ( jexcel . current && jexcel . current . selectedCell ) {
68316887 if ( ! jexcel . current . edition ) {
6832- if ( e . clipboardData ) {
6833- if ( jexcel . current . options . editable == true ) {
6888+ if ( jexcel . current . options . editable == true ) {
6889+ if ( e && e . clipboardData ) {
68346890 jexcel . current . paste ( jexcel . current . selectedCell [ 0 ] , jexcel . current . selectedCell [ 1 ] , e . clipboardData . getData ( 'text' ) ) ;
6891+ e . preventDefault ( ) ;
6892+ } else if ( window . clipboardData ) {
6893+ jexcel . current . paste ( jexcel . current . selectedCell [ 0 ] , jexcel . current . selectedCell [ 1 ] , window . clipboardData . getData ( 'text' ) ) ;
68356894 }
6836- e . preventDefault ( ) ;
68376895 }
68386896 }
68396897 }
@@ -6911,8 +6969,6 @@ jexcel.touchEndControls = function(e) {
69116969 }
69126970}
69136971
6914- jexcel . copyControls . enabled = true ;
6915-
69166972/**
69176973 * Jquery Support
69186974 */
0 commit comments