@@ -130,7 +130,11 @@ function _Array(conf) {
130
130
var i = 0 ;
131
131
var length = 0 ;
132
132
var del = [ ] ;
133
- var oldValue = JSON . stringify ( arrDb ) ;
133
+ var oldValue = null ;
134
+
135
+ if ( $history . isEnabled ( ) ) {
136
+ oldValue = JSON . stringify ( arrDb ) ;
137
+ }
134
138
135
139
if ( ! isReadOnly ) {
136
140
if ( isClassName ) {
@@ -158,7 +162,7 @@ function _Array(conf) {
158
162
break ;
159
163
}
160
164
161
- if ( classId . indexOf ( '_' ) !== 0 ) {
165
+ if ( $history . isEnabled ( ) && classId . indexOf ( '_' ) !== 0 ) {
162
166
$history . pushState ( {
163
167
action : 'update' ,
164
168
collection : classId ,
@@ -205,7 +209,7 @@ function _Array(conf) {
205
209
break ;
206
210
}
207
211
208
- if ( classId . indexOf ( '_' ) !== 0 ) {
212
+ if ( $history . isEnabled ( ) && classId . indexOf ( '_' ) !== 0 ) {
209
213
$history . pushState ( {
210
214
action : 'update' ,
211
215
collection : classId ,
@@ -252,7 +256,11 @@ function _Array(conf) {
252
256
function _remove ( action ) {
253
257
var result ;
254
258
var val = null ;
255
- var oldValue = JSON . stringify ( arrDb ) ;
259
+ var oldValue = null ;
260
+
261
+ if ( $history . isEnabled ( ) ) {
262
+ oldValue = JSON . stringify ( arrDb ) ;
263
+ }
256
264
257
265
if ( ! isReadOnly ) {
258
266
if ( arrDb . length !== 0 ) {
@@ -267,7 +275,7 @@ function _Array(conf) {
267
275
break ;
268
276
}
269
277
270
- if ( classId . indexOf ( '_' ) !== 0 ) {
278
+ if ( $history . isEnabled ( ) && classId . indexOf ( '_' ) !== 0 ) {
271
279
$history . pushState ( {
272
280
action : 'update' ,
273
281
collection : classId ,
@@ -394,10 +402,15 @@ function _Array(conf) {
394
402
* @description Override sort method
395
403
*/
396
404
arr . sort = function sort ( funct ) {
397
- var oldValue = JSON . stringify ( oldValue ) ;
405
+ var oldValue = null ;
406
+
407
+ if ( $history . isEnabled ( ) ) {
408
+ oldValue = JSON . stringify ( oldValue ) ;
409
+ }
410
+
398
411
arrDb . sort ( funct ) ;
399
412
400
- if ( classId . indexOf ( '_' ) !== 0 ) {
413
+ if ( $history . isEnabled ( ) && classId . indexOf ( '_' ) !== 0 ) {
401
414
$history . pushState ( {
402
415
action : 'update' ,
403
416
collection : classId ,
@@ -431,10 +444,14 @@ function _Array(conf) {
431
444
* @description Override reverse method
432
445
*/
433
446
arr . reverse = function reverse ( ) {
434
- var oldValue = JSON . stringify ( oldValue ) ;
447
+ var oldValue = null ;
448
+
449
+ if ( $history . isEnabled ( ) ) {
450
+ oldValue = JSON . stringify ( oldValue ) ;
451
+ }
435
452
arrDb . reverse ( ) ;
436
453
437
- if ( classId . indexOf ( '_' ) !== 0 ) {
454
+ if ( $history . isEnabled ( ) && classId . indexOf ( '_' ) !== 0 ) {
438
455
$history . pushState ( {
439
456
action : 'update' ,
440
457
collection : classId ,
@@ -468,18 +485,22 @@ function _Array(conf) {
468
485
* @description Override splice method
469
486
*/
470
487
arr . splice = function splice ( start , deleteCount , val ) {
471
- var oldValue = JSON . stringify ( oldValue ) ;
488
+ var oldValue = null ;
472
489
var result = [ ] ;
473
490
var i = 0 ;
474
491
var length = 0 ;
475
492
var data = null ;
476
493
494
+ if ( $history . isEnabled ( ) ) {
495
+ oldValue = JSON . stringify ( oldValue ) ;
496
+ }
497
+
477
498
if ( typeof val !== 'undefined' ) {
478
499
_add ( val , 'splice' , start , deleteCount ) ;
479
500
} else {
480
501
result = arrDb . splice ( start , deleteCount ) ;
481
502
482
- if ( classId . indexOf ( '_' ) !== 0 ) {
503
+ if ( $history . isEnabled ( ) && classId . indexOf ( '_' ) !== 0 ) {
483
504
$history . pushState ( {
484
505
action : 'update' ,
485
506
collection : classId ,
@@ -804,7 +825,7 @@ function createClass(classId) {
804
825
// create link to db
805
826
$db . store [ classId ] [ config [ $mson . ID ] ] = config ;
806
827
807
- if ( classId . indexOf ( '_' ) !== 0 ) {
828
+ if ( $history . isEnabled ( ) && classId . indexOf ( '_' ) !== 0 ) {
808
829
$history . pushState ( {
809
830
action : 'insert' ,
810
831
collection : classId ,
@@ -970,11 +991,13 @@ function addProperties(model, Class, classId) {
970
991
data : [ position , 'reset' ]
971
992
} ) ;
972
993
973
- oldValue = JSON . stringify ( component [ propertyName ] ) ;
994
+ if ( $history . isEnabled ( ) ) {
995
+ oldValue = JSON . stringify ( component [ propertyName ] ) ;
996
+ }
974
997
975
998
component [ propertyName ] = realVal ;
976
999
977
- if ( classId . indexOf ( '_' ) !== 0 ) {
1000
+ if ( $history . isEnabled ( ) && classId . indexOf ( '_' ) !== 0 ) {
978
1001
$history . pushState ( {
979
1002
action : 'update' ,
980
1003
collection : classId ,
@@ -1104,9 +1127,11 @@ function addProperties(model, Class, classId) {
1104
1127
component = search [ 0 ] ;
1105
1128
component [ propertyName ] [ position ] = realVal ;
1106
1129
1107
- oldValue = JSON . stringify ( component [ propertyName ] ) ;
1130
+ if ( $history . isEnabled ( ) ) {
1131
+ oldValue = JSON . stringify ( component [ propertyName ] ) ;
1132
+ }
1108
1133
1109
- if ( classId . indexOf ( '_' ) !== 0 ) {
1134
+ if ( $history . isEnabled ( ) && classId . indexOf ( '_' ) !== 0 ) {
1110
1135
$history . pushState ( {
1111
1136
action : 'update' ,
1112
1137
collection : classId ,
@@ -1214,7 +1239,10 @@ function addProperties(model, Class, classId) {
1214
1239
} ) ;
1215
1240
if ( search . length ) {
1216
1241
component = search [ 0 ] ;
1217
- oldValue = JSON . stringify ( component [ propertyName ] ) ;
1242
+
1243
+ if ( $history . isEnabled ( ) ) {
1244
+ oldValue = JSON . stringify ( component [ propertyName ] ) ;
1245
+ }
1218
1246
1219
1247
switch ( true ) {
1220
1248
case $metamodel . isClassName ( propertyType ) :
@@ -1236,7 +1264,7 @@ function addProperties(model, Class, classId) {
1236
1264
break ;
1237
1265
}
1238
1266
1239
- if ( classId . indexOf ( '_' ) !== 0 ) {
1267
+ if ( $history . isEnabled ( ) && classId . indexOf ( '_' ) !== 0 ) {
1240
1268
$history . pushState ( {
1241
1269
action : 'update' ,
1242
1270
collection : classId ,
@@ -1378,7 +1406,10 @@ function addStructure(path, name, model, id) {
1378
1406
_id : id
1379
1407
} ) ;
1380
1408
if ( search . length ) {
1381
- oldValue = getStructureValue ( model , id , fullPath ) ;
1409
+ if ( $history . isEnabled ( ) ) {
1410
+ oldValue = getStructureValue ( model , id , fullPath ) ;
1411
+ }
1412
+
1382
1413
setStructureValue ( model , id , fullPath , position ) ;
1383
1414
1384
1415
// all element
@@ -1397,7 +1428,7 @@ function addStructure(path, name, model, id) {
1397
1428
data : [ position , 'reset' ]
1398
1429
} ) ;
1399
1430
1400
- if ( model . indexOf ( '_' ) !== 0 ) {
1431
+ if ( $history . isEnabled ( ) && model . indexOf ( '_' ) !== 0 ) {
1401
1432
$history . pushState ( {
1402
1433
action : 'update' ,
1403
1434
collection : model ,
@@ -1543,10 +1574,13 @@ function addStructure(path, name, model, id) {
1543
1574
break ;
1544
1575
}
1545
1576
1546
- oldValue = getStructureValue ( model , id , fullPath ) ;
1577
+ if ( $history . isEnabled ( ) ) {
1578
+ oldValue = getStructureValue ( model , id , fullPath ) ;
1579
+ }
1580
+
1547
1581
setStructureValue ( model , id , fullPath , arr ) ;
1548
1582
1549
- if ( model . indexOf ( '_' ) !== 0 ) {
1583
+ if ( $history . isEnabled ( ) && model . indexOf ( '_' ) !== 0 ) {
1550
1584
$history . pushState ( {
1551
1585
action : 'update' ,
1552
1586
collection : model ,
@@ -1668,7 +1702,9 @@ function addStructure(path, name, model, id) {
1668
1702
if ( search . length ) {
1669
1703
component = search [ 0 ] ;
1670
1704
1671
- oldValue = getStructureValue ( model , id , fullPath ) ;
1705
+ if ( $history . isEnabled ( ) ) {
1706
+ oldValue = getStructureValue ( model , id , fullPath ) ;
1707
+ }
1672
1708
1673
1709
switch ( true ) {
1674
1710
case $metamodel . isClassName ( propertyType ) :
@@ -1687,7 +1723,7 @@ function addStructure(path, name, model, id) {
1687
1723
break ;
1688
1724
}
1689
1725
1690
- if ( model . indexOf ( '_' ) !== 0 ) {
1726
+ if ( $history . isEnabled ( ) && model . indexOf ( '_' ) !== 0 ) {
1691
1727
$history . pushState ( {
1692
1728
action : 'update' ,
1693
1729
collection : model ,
0 commit comments