Skip to content

Commit eb8acd7

Browse files
committed
Merge pull request #12 from mixpanel/versioning
v2.3.0
2 parents e176c04 + ef30f42 commit eb8acd7

File tree

3 files changed

+159
-132
lines changed

3 files changed

+159
-132
lines changed

mixpanel.js

Lines changed: 55 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Mixpanel JS Library v2.3-beta
2+
* Mixpanel JS Library v2.3.0
33
*
44
* Copyright 2012, Mixpanel, Inc. All Rights Reserved
55
* http://mixpanel.com/
@@ -12,7 +12,7 @@
1212

1313
// ==ClosureCompiler==
1414
// @compilation_level ADVANCED_OPTIMIZATIONS
15-
// @output_file_name mixpanel-2.2.min.js
15+
// @output_file_name mixpanel-2.3.min.js
1616
// ==/ClosureCompiler==
1717

1818
/*
@@ -74,15 +74,19 @@ Globals should be all caps
7474
/*
7575
* Dynamic... constants? Is that an oxymoron?
7676
*/
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+
7982
// http://hacks.mozilla.org/2009/07/cross-site-xmlhttprequest-with-cors/
8083
// 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+
8286
// IE<10 does not support cross-origin XHR's but script tags
8387
// with defer won't block window.onload; ENQUEUE_REQUESTS
8488
// 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);
8690

8791
/*
8892
* Closure-level globals
@@ -1332,7 +1336,8 @@ Globals should be all caps
13321336
}), {
13331337
'$screen_height': screen.height,
13341338
'$screen_width': screen.width,
1335-
'mp_lib': 'web'
1339+
'mp_lib': 'web',
1340+
'$lib_version': LIB_VERSION
13361341
});
13371342
},
13381343

@@ -2553,18 +2558,18 @@ Globals should be all caps
25532558
};
25542559

25552560
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')) {
25572562
return;
25582563
}
25592564

25602565
console.log("MIXPANEL NOTIFICATION CHECK");
25612566

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
25682573
};
25692574
var self = this;
25702575
this._send_request(
@@ -2969,7 +2974,7 @@ Globals should be all caps
29692974
_.bind_instance_methods(this);
29702975

29712976
this.mixpanel = mixpanel_instance;
2972-
this.cookie = this.mixpanel.cookie;
2977+
this.cookie = this.mixpanel['cookie'];
29732978

29742979
this.campaign_id = _.escapeHTML(notif_data['id']);
29752980
this.message_id = _.escapeHTML(notif_data['message_id']);
@@ -3040,8 +3045,7 @@ Globals should be all caps
30403045
var exiting_el = this.showing_video ? this._get_el('video') : this._get_notification_display_el();
30413046
if (this.use_transitions) {
30423047
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');
30453049
setTimeout(this._remove_notification_el, MPNotif.ANIM_TIME);
30463050
} else {
30473051
var notif_attr, notif_start, notif_goal;
@@ -3444,6 +3448,8 @@ Globals should be all caps
34443448
'overflow': 'visible'
34453449
},
34463450
'#overlay a': {
3451+
'width': 'initial',
3452+
'padding': '0',
34473453
'text-decoration': 'none',
34483454
'text-transform': 'none',
34493455
'color': 'inherit'
@@ -3500,6 +3506,10 @@ Globals should be all caps
35003506
'opacity': '1.0',
35013507
'top': MPNotif.NOTIF_TOP + 'px'
35023508
},
3509+
'#takeover.exiting': {
3510+
'opacity': '0.0',
3511+
'top': MPNotif.NOTIF_START_TOP + 'px'
3512+
},
35033513
'#thumbspacer': {
35043514
'height': MPNotif.THUMB_OFFSET + 'px'
35053515
},
@@ -3539,12 +3549,16 @@ Globals should be all caps
35393549
'backface-visibility': 'hidden',
35403550
'opacity': '0.0',
35413551
'transform': 'rotateX(90deg)',
3542-
'transition': 'opacity 0.3s, transform 0.3s'
3552+
'transition': 'opacity 0.3s, transform 0.3s, right 0.3s'
35433553
},
35443554
'#mini.visible': {
35453555
'opacity': '1.0',
35463556
'transform': 'rotateX(0deg)'
35473557
},
3558+
'#mini.exiting': {
3559+
'opacity': '0.0',
3560+
'right': '-150px'
3561+
},
35483562
'#mainbox': {
35493563
'border-radius': '4px',
35503564
'box-shadow': shadow,
@@ -3756,7 +3770,7 @@ Globals should be all caps
37563770
'transform': 'translateZ(1px)', // webkit rendering bug http://stackoverflow.com/questions/18167981/clickable-link-area-unexpectedly-smaller-after-css-transform
37573771
'transition': 'opacity ' + anim_seconds + ', top ' + anim_seconds
37583772
},
3759-
'#video.hidden': {
3773+
'#video.exiting': {
37603774
'opacity': '0.0',
37613775
'top': this.video_height + 'px'
37623776
},
@@ -3954,7 +3968,13 @@ Globals should be all caps
39543968
}
39553969
});
39563970

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+
39583978
var get_style = function(el, style_name) {
39593979
var styles = {};
39603980
if (document.defaultView && document.defaultView.getComputedStyle) {
@@ -3976,24 +3996,18 @@ Globals should be all caps
39763996
this._track_event('$campaign_delivery');
39773997

39783998
// 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()
39864006
}
39874007
});
39884008
}
39894009
}
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+
});
39974011

39984012
MPNotif.prototype._preload_images = function(all_loaded_cb) {
39994013
var self = this;
@@ -4137,7 +4151,7 @@ Globals should be all caps
41374151
bg.style.height = '100%';
41384152
overlay.style.width = '100%';
41394153

4140-
self._remove_class(self._get_notification_display_el(), 'visible');
4154+
self._add_class(self._get_notification_display_el(), 'exiting');
41414155
self._add_class(bg, 'visible');
41424156

41434157
anims.push({
@@ -4168,11 +4182,11 @@ Globals should be all caps
41684182

41694183
MPNotif.prototype._track_event = function(event_name, cb) {
41704184
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
41764190
}, cb);
41774191
} else {
41784192
cb && cb.call();
@@ -4332,6 +4346,7 @@ Globals should be all caps
43324346
} else if (token) {
43334347
// intialize the main mixpanel lib
43344348
instance = create_mplib(token, config, PRIMARY_INSTANCE_NAME);
4349+
instance._loaded();
43354350
}
43364351

43374352
window[PRIMARY_INSTANCE_NAME] = mixpanel = instance;

0 commit comments

Comments
 (0)