1
1
/*
2
- * Mixpanel JS Library v2.3-beta
2
+ * Mixpanel JS Library v2.3.0
3
3
*
4
4
* Copyright 2012, Mixpanel, Inc. All Rights Reserved
5
5
* http://mixpanel.com/
12
12
13
13
// ==ClosureCompiler==
14
14
// @compilation_level ADVANCED_OPTIMIZATIONS
15
- // @output_file_name mixpanel-2.2 .min.js
15
+ // @output_file_name mixpanel-2.3 .min.js
16
16
// ==/ClosureCompiler==
17
17
18
18
/*
@@ -74,15 +74,19 @@ Globals should be all caps
74
74
/*
75
75
* Dynamic... constants? Is that an oxymoron?
76
76
*/
77
- var HTTP_PROTOCOL = ( ( "https:" == document . location . protocol ) ? "https://" : "http://" )
78
- , SNIPPET_VERSION = ( mixpanel && mixpanel [ '__SV' ] ) || 0
77
+ var HTTP_PROTOCOL = ( ( "https:" == document . location . protocol ) ? "https://" : "http://" ) ,
78
+
79
+ LIB_VERSION = '2.3.0' ,
80
+ SNIPPET_VERSION = ( mixpanel && mixpanel [ '__SV' ] ) || 0 ,
81
+
79
82
// http://hacks.mozilla.org/2009/07/cross-site-xmlhttprequest-with-cors/
80
83
// https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest#withCredentials
81
- , USE_XHR = ( window . XMLHttpRequest && 'withCredentials' in new XMLHttpRequest ( ) )
84
+ USE_XHR = ( window . XMLHttpRequest && 'withCredentials' in new XMLHttpRequest ( ) ) ,
85
+
82
86
// IE<10 does not support cross-origin XHR's but script tags
83
87
// with defer won't block window.onload; ENQUEUE_REQUESTS
84
88
// should only be true for Opera<12
85
- , ENQUEUE_REQUESTS = ! USE_XHR && ( userAgent . indexOf ( 'MSIE' ) == - 1 ) && ( userAgent . indexOf ( 'Mozilla' ) == - 1 ) ;
89
+ ENQUEUE_REQUESTS = ! USE_XHR && ( userAgent . indexOf ( 'MSIE' ) == - 1 ) && ( userAgent . indexOf ( 'Mozilla' ) == - 1 ) ;
86
90
87
91
/*
88
92
* Closure-level globals
@@ -1332,7 +1336,8 @@ Globals should be all caps
1332
1336
} ) , {
1333
1337
'$screen_height' : screen . height ,
1334
1338
'$screen_width' : screen . width ,
1335
- 'mp_lib' : 'web'
1339
+ 'mp_lib' : 'web' ,
1340
+ '$lib_version' : LIB_VERSION
1336
1341
} ) ;
1337
1342
} ,
1338
1343
@@ -2553,18 +2558,18 @@ Globals should be all caps
2553
2558
} ;
2554
2559
2555
2560
MixpanelLib . prototype . _check_and_handle_notifications = function ( distinct_id ) {
2556
- if ( this . _flags . identify_called ) {
2561
+ if ( this . _flags . identify_called || this . get_config ( 'disable_notifications' ) ) {
2557
2562
return ;
2558
2563
}
2559
2564
2560
2565
console . log ( "MIXPANEL NOTIFICATION CHECK" ) ;
2561
2566
2562
- data = {
2563
- verbose : true ,
2564
- version : '1' ,
2565
- lib : 'web' ,
2566
- token : this . get_config ( 'token' ) ,
2567
- distinct_id : distinct_id
2567
+ var data = {
2568
+ ' verbose' : true ,
2569
+ ' version' : '1' ,
2570
+ ' lib' : 'web' ,
2571
+ ' token' : this . get_config ( 'token' ) ,
2572
+ ' distinct_id' : distinct_id
2568
2573
} ;
2569
2574
var self = this ;
2570
2575
this . _send_request (
@@ -2969,7 +2974,7 @@ Globals should be all caps
2969
2974
_ . bind_instance_methods ( this ) ;
2970
2975
2971
2976
this . mixpanel = mixpanel_instance ;
2972
- this . cookie = this . mixpanel . cookie ;
2977
+ this . cookie = this . mixpanel [ ' cookie' ] ;
2973
2978
2974
2979
this . campaign_id = _ . escapeHTML ( notif_data [ 'id' ] ) ;
2975
2980
this . message_id = _ . escapeHTML ( notif_data [ 'message_id' ] ) ;
@@ -3040,8 +3045,7 @@ Globals should be all caps
3040
3045
var exiting_el = this . showing_video ? this . _get_el ( 'video' ) : this . _get_notification_display_el ( ) ;
3041
3046
if ( this . use_transitions ) {
3042
3047
this . _remove_class ( 'bg' , 'visible' ) ;
3043
- this . _remove_class ( exiting_el , 'visible' ) ;
3044
- this . _add_class ( exiting_el , 'hidden' ) ;
3048
+ this . _add_class ( exiting_el , 'exiting' ) ;
3045
3049
setTimeout ( this . _remove_notification_el , MPNotif . ANIM_TIME ) ;
3046
3050
} else {
3047
3051
var notif_attr , notif_start , notif_goal ;
@@ -3444,6 +3448,8 @@ Globals should be all caps
3444
3448
'overflow' : 'visible'
3445
3449
} ,
3446
3450
'#overlay a' : {
3451
+ 'width' : 'initial' ,
3452
+ 'padding' : '0' ,
3447
3453
'text-decoration' : 'none' ,
3448
3454
'text-transform' : 'none' ,
3449
3455
'color' : 'inherit'
@@ -3500,6 +3506,10 @@ Globals should be all caps
3500
3506
'opacity' : '1.0' ,
3501
3507
'top' : MPNotif . NOTIF_TOP + 'px'
3502
3508
} ,
3509
+ '#takeover.exiting' : {
3510
+ 'opacity' : '0.0' ,
3511
+ 'top' : MPNotif . NOTIF_START_TOP + 'px'
3512
+ } ,
3503
3513
'#thumbspacer' : {
3504
3514
'height' : MPNotif . THUMB_OFFSET + 'px'
3505
3515
} ,
@@ -3539,12 +3549,16 @@ Globals should be all caps
3539
3549
'backface-visibility' : 'hidden' ,
3540
3550
'opacity' : '0.0' ,
3541
3551
'transform' : 'rotateX(90deg)' ,
3542
- 'transition' : 'opacity 0.3s, transform 0.3s'
3552
+ 'transition' : 'opacity 0.3s, transform 0.3s, right 0.3s '
3543
3553
} ,
3544
3554
'#mini.visible' : {
3545
3555
'opacity' : '1.0' ,
3546
3556
'transform' : 'rotateX(0deg)'
3547
3557
} ,
3558
+ '#mini.exiting' : {
3559
+ 'opacity' : '0.0' ,
3560
+ 'right' : '-150px'
3561
+ } ,
3548
3562
'#mainbox' : {
3549
3563
'border-radius' : '4px' ,
3550
3564
'box-shadow' : shadow ,
@@ -3756,7 +3770,7 @@ Globals should be all caps
3756
3770
'transform' : 'translateZ(1px)' , // webkit rendering bug http://stackoverflow.com/questions/18167981/clickable-link-area-unexpectedly-smaller-after-css-transform
3757
3771
'transition' : 'opacity ' + anim_seconds + ', top ' + anim_seconds
3758
3772
} ,
3759
- '#video.hidden ' : {
3773
+ '#video.exiting ' : {
3760
3774
'opacity' : '0.0' ,
3761
3775
'top' : this . video_height + 'px'
3762
3776
} ,
@@ -3954,7 +3968,13 @@ Globals should be all caps
3954
3968
}
3955
3969
} ) ;
3956
3970
3957
- MPNotif . prototype . _mark_as_shown = function ( ) {
3971
+ MPNotif . prototype . _mark_as_shown = _ . safewrap ( function ( ) {
3972
+ // click on background to dismiss
3973
+ var self = this ;
3974
+ _ . register_event ( self . _get_el ( 'bg' ) , 'click' , function ( e ) {
3975
+ self . dismiss ( ) ;
3976
+ } ) ;
3977
+
3958
3978
var get_style = function ( el , style_name ) {
3959
3979
var styles = { } ;
3960
3980
if ( document . defaultView && document . defaultView . getComputedStyle ) {
@@ -3976,24 +3996,18 @@ Globals should be all caps
3976
3996
this . _track_event ( '$campaign_delivery' ) ;
3977
3997
3978
3998
// mark notification shown (mixpanel property)
3979
- this . mixpanel . people . append ( {
3980
- $campaigns : this . campaign_id ,
3981
- $notifications : {
3982
- campaign_id : this . campaign_id ,
3983
- message_id : this . message_id ,
3984
- type : 'web' ,
3985
- time : new Date ( )
3999
+ this . mixpanel [ ' people' ] [ ' append' ] ( {
4000
+ ' $campaigns' : this . campaign_id ,
4001
+ ' $notifications' : {
4002
+ ' campaign_id' : this . campaign_id ,
4003
+ ' message_id' : this . message_id ,
4004
+ ' type' : 'web' ,
4005
+ ' time' : new Date ( )
3986
4006
}
3987
4007
} ) ;
3988
4008
}
3989
4009
}
3990
-
3991
- // click on background to dismiss
3992
- var self = this ;
3993
- _ . register_event ( self . _get_el ( 'bg' ) , 'click' , function ( e ) {
3994
- self . dismiss ( ) ;
3995
- } ) ;
3996
- } ;
4010
+ } ) ;
3997
4011
3998
4012
MPNotif . prototype . _preload_images = function ( all_loaded_cb ) {
3999
4013
var self = this ;
@@ -4137,7 +4151,7 @@ Globals should be all caps
4137
4151
bg . style . height = '100%' ;
4138
4152
overlay . style . width = '100%' ;
4139
4153
4140
- self . _remove_class ( self . _get_notification_display_el ( ) , 'visible ' ) ;
4154
+ self . _add_class ( self . _get_notification_display_el ( ) , 'exiting ' ) ;
4141
4155
self . _add_class ( bg , 'visible' ) ;
4142
4156
4143
4157
anims . push ( {
@@ -4168,11 +4182,11 @@ Globals should be all caps
4168
4182
4169
4183
MPNotif . prototype . _track_event = function ( event_name , cb ) {
4170
4184
if ( this . campaign_id ) {
4171
- this . mixpanel . track ( event_name , {
4172
- campaign_id : this . campaign_id ,
4173
- message_id : this . message_id ,
4174
- message_type : 'web_inapp' ,
4175
- message_subtype : this . notif_type
4185
+ this . mixpanel [ ' track' ] ( event_name , {
4186
+ ' campaign_id' : this . campaign_id ,
4187
+ ' message_id' : this . message_id ,
4188
+ ' message_type' : 'web_inapp' ,
4189
+ ' message_subtype' : this . notif_type
4176
4190
} , cb ) ;
4177
4191
} else {
4178
4192
cb && cb . call ( ) ;
@@ -4332,6 +4346,7 @@ Globals should be all caps
4332
4346
} else if ( token ) {
4333
4347
// intialize the main mixpanel lib
4334
4348
instance = create_mplib ( token , config , PRIMARY_INSTANCE_NAME ) ;
4349
+ instance . _loaded ( ) ;
4335
4350
}
4336
4351
4337
4352
window [ PRIMARY_INSTANCE_NAME ] = mixpanel = instance ;
0 commit comments