3
3
* See COPYING.txt for license details.
4
4
*/
5
5
6
- define ( [ 'underscore' ] , function ( _underscore ) {
6
+ define ( [ 'underscore' ] , function ( _ ) {
7
7
'use strict' ;
8
8
9
9
return function ( target ) {
@@ -25,8 +25,8 @@ define(['underscore'], function (_underscore) {
25
25
target . trigger = function ( name , args ) {
26
26
originalTarget . apply ( originalTarget , [ name , args ] ) ;
27
27
isAdminAnalyticsEnabled =
28
- ! _underscore . isUndefined ( window . digitalData ) &&
29
- ! _underscore . isUndefined ( window . _satellite ) ;
28
+ ! _ . isUndefined ( window . digitalData ) &&
29
+ ! _ . isUndefined ( window . _satellite ) ;
30
30
31
31
if ( name . indexOf ( 'readyAfter' ) !== - 1 && isAdminAnalyticsEnabled ) {
32
32
window . digitalData . page . url = window . location . href ;
@@ -38,7 +38,7 @@ define(['underscore'], function (_underscore) {
38
38
39
39
setupEventAttributes ( name , args ) ;
40
40
41
- if ( action !== '' && ! _underscore . isEmpty ( eventAttributes ) ) {
41
+ if ( action !== '' && ! _ . isEmpty ( eventAttributes ) ) {
42
42
event = {
43
43
element : eventAttributes . label ,
44
44
type : eventAttributes . name ,
@@ -50,7 +50,7 @@ define(['underscore'], function (_underscore) {
50
50
feature : 'page-builder-tracker'
51
51
} ;
52
52
53
- if ( isAdminAnalyticsEnabled && ! _underscore . isUndefined ( window . digitalData . event ) ) {
53
+ if ( isAdminAnalyticsEnabled && ! _ . isUndefined ( window . digitalData . event ) ) {
54
54
window . digitalData . event . push ( event ) ;
55
55
window . _satellite . track ( 'event' ) ;
56
56
}
@@ -70,41 +70,46 @@ define(['underscore'], function (_underscore) {
70
70
action = '' ;
71
71
eventAttributes = { } ;
72
72
73
- if ( _underscore . isUndefined ( args ) ) {
73
+ if ( _ . isUndefined ( args ) ) {
74
74
return ;
75
75
}
76
76
77
77
if ( arrayName . length === 3 ) {
78
78
arrayNameObject = arrayName [ 1 ] ;
79
79
action = hasVisibilityChanged ( args [ arrayNameObject ] ) ? 'hide/show' : '' ;
80
80
eventAttributes =
81
- ! _underscore . isUndefined ( args [ arrayNameObject ] ) &&
82
- ! _underscore . isUndefined ( args [ arrayNameObject ] . config ) ?
81
+ ! _ . isUndefined ( args [ arrayNameObject ] ) &&
82
+ ! _ . isUndefined ( args [ arrayNameObject ] . config ) ?
83
83
args [ arrayNameObject ] . config : { } ;
84
84
} else if ( arrayName . length === 2 ) {
85
- if ( name . indexOf ( 'duplicateAfter' ) !== - 1 ) {
86
- action = 'duplicate' ;
87
- eventAttributes =
88
- ! _underscore . isUndefined ( args . originalContentType ) &&
89
- ! _underscore . isUndefined ( args . originalContentType . config ) ?
90
- args . originalContentType . config : { } ;
91
- }
92
-
93
- if ( name . indexOf ( 'removeAfter' ) !== - 1 ) {
94
- action = 'remove' ;
95
- }
96
-
97
- if ( name . indexOf ( 'createAfter' ) !== - 1 ) {
98
- action = 'create' ;
99
- }
100
-
101
- if ( name . indexOf ( 'renderAfter' ) !== - 1 ) {
102
- action = 'edit' ;
85
+ switch ( arrayName [ arrayName . length - 1 ] ) {
86
+ case 'duplicateAfter' :
87
+ action = 'duplicate' ;
88
+ eventAttributes =
89
+ ! _ . isUndefined ( args . originalContentType ) &&
90
+ ! _ . isUndefined ( args . originalContentType . config ) ?
91
+ args . originalContentType . config : { } ;
92
+ break ;
93
+
94
+ case 'removeAfter' :
95
+ action = 'remove' ;
96
+ break ;
97
+
98
+ case 'createAfter' :
99
+ action = 'create' ;
100
+ break ;
101
+
102
+ case 'renderAfter' :
103
+ action = 'edit' ;
104
+ break ;
105
+
106
+ default :
107
+ break ;
103
108
}
104
109
105
110
eventAttributes =
106
- ! _underscore . isUndefined ( args . contentType ) &&
107
- ! _underscore . isUndefined ( args . contentType . config ) ?
111
+ ! _ . isUndefined ( args . contentType ) &&
112
+ ! _ . isUndefined ( args . contentType . config ) ?
108
113
args . contentType . config : { } ;
109
114
}
110
115
} ;
@@ -118,12 +123,12 @@ define(['underscore'], function (_underscore) {
118
123
var state ,
119
124
previousState ;
120
125
121
- if ( ! _underscore . isUndefined ( objectWrapper ) &&
122
- ! _underscore . isUndefined ( objectWrapper ) . dataStore
126
+ if ( ! _ . isUndefined ( objectWrapper ) &&
127
+ ! _ . isUndefined ( objectWrapper ) . dataStore
123
128
) {
124
- previousState = ! _underscore . isUndefined ( objectWrapper . dataStore . previousState ) ?
129
+ previousState = ! _ . isUndefined ( objectWrapper . dataStore . previousState ) ?
125
130
objectWrapper . dataStore . previousState . display : '' ;
126
- state = ! _underscore . isUndefined ( objectWrapper . dataStore . state ) ?
131
+ state = ! _ . isUndefined ( objectWrapper . dataStore . state ) ?
127
132
objectWrapper . dataStore . state . display : '' ;
128
133
129
134
if ( previousState !== state && previousState !== '' && state !== '' ) {
0 commit comments