mirror of https://github.com/zulip/zulip.git
Revert "Temporarily remove "Share the love" from DOM & JS"
This reverts commit fc7af47400f6c96161913dcc98be128c116d90c5. (imported from commit 8f58425ec3bd95220e109eeb7be21fa449508427)
This commit is contained in:
parent
5c2599e157
commit
5e1d893509
|
@ -1,4 +1,83 @@
|
|||
var referral = (function () {
|
||||
|
||||
return {}; // temporarily disable due to bugs
|
||||
var exports = {};
|
||||
|
||||
var placeholder_invitees = ['guglielmo@marconi.com',
|
||||
'heinrich@hertz.com',
|
||||
'nikola@tesla.com',
|
||||
'samuel@morse.com',
|
||||
'claude@shannon.com',
|
||||
'thomas@edison.com',
|
||||
'hedy@lamarr.com',
|
||||
'grace@hopper.com',
|
||||
'martha@coston.com',
|
||||
'ada@lovelace.com',
|
||||
'hanna@hammarstrom.com',
|
||||
'hertha@ayrton.com'
|
||||
];
|
||||
|
||||
exports.update_state = function (granted, used) {
|
||||
if (granted <= 0) {
|
||||
$("#share-the-love").hide();
|
||||
return;
|
||||
}
|
||||
|
||||
$("#referral-form input").attr('placeholder', _.shuffle(placeholder_invitees).pop());
|
||||
$("#invite-hearts").empty();
|
||||
var i;
|
||||
for (i = 0; i < used; i++) {
|
||||
$("#invite-hearts").append($('<i class="icon-vector-heart"> </i>'));
|
||||
}
|
||||
|
||||
var invites_left = Math.max(0, granted - used);
|
||||
for (i = 0; i < invites_left; i++) {
|
||||
$("#invite-hearts").append($('<i class="icon-vector-heart-empty"> </i>'));
|
||||
}
|
||||
$(".invite-count").text(invites_left);
|
||||
if (invites_left === 1) {
|
||||
$(".invite-count-is-plural").hide();
|
||||
} else {
|
||||
$(".invite-count-is-plural").show();
|
||||
}
|
||||
|
||||
if (invites_left > 0) {
|
||||
$(".still-have-invites").show();
|
||||
$(".no-more-invites").hide();
|
||||
} else {
|
||||
$(".still-have-invites").hide();
|
||||
$(".no-more-invites").show();
|
||||
}
|
||||
$("#share-the-love").show();
|
||||
};
|
||||
|
||||
function show_and_fade_elem(elem) {
|
||||
elem.stop();
|
||||
elem.css({opacity: 100});
|
||||
elem.show().delay(4000).fadeOut(1000);
|
||||
}
|
||||
|
||||
$(function () {
|
||||
$("#referral-form").validate({
|
||||
errorClass: 'text-error',
|
||||
submitHandler: function () {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/json/refer_friend",
|
||||
dataType: "json",
|
||||
data: { email: $("#referral-form input").val() },
|
||||
success: function () {
|
||||
show_and_fade_elem($("#tell-a-friend-success"));
|
||||
$("#referral-form input").val('');
|
||||
},
|
||||
error: function () {
|
||||
show_and_fade_elem($("#tell-a-friend-error"));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
exports.update_state(page_params.referrals.granted, page_params.referrals.used);
|
||||
});
|
||||
|
||||
return exports;
|
||||
}());
|
||||
|
|
|
@ -322,7 +322,9 @@ function get_new_heights() {
|
|||
res.bottom_sidebar_height
|
||||
- $("#global_filters").outerHeight(true)
|
||||
- $("#streams_header").outerHeight(true)
|
||||
- 10; // stream_filters margin-bottom
|
||||
- $("#share-the-love").outerHeight(true)
|
||||
- 10 // stream_filters margin-bottom
|
||||
- 5;// share-the-love margin-bottom
|
||||
|
||||
// Don't let us crush the stream sidebar completely out of view
|
||||
res.stream_filters_max_height = Math.max(40, res.stream_filters_max_height);
|
||||
|
|
|
@ -869,6 +869,9 @@ function get_updates_success(data) {
|
|||
users[event.email] = event.presence;
|
||||
activity.set_user_statuses(users, event.server_timestamp);
|
||||
break;
|
||||
case 'referral':
|
||||
referral.update_state(event.referrals.granted, event.referrals.used);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -26,6 +26,44 @@
|
|||
</div>
|
||||
<ul id="stream_filters" class="filters scrolling_list"></ul>
|
||||
</div>
|
||||
<div id="share-the-love">
|
||||
<div>
|
||||
<h4 class="streams_title">SHARE THE LOVE</h4>
|
||||
</div>
|
||||
<div id="tell-a-friend-success" class="alert alert-success">
|
||||
<strong>Thanks!</strong>
|
||||
<p>Our engineers will artisanally handcraft
|
||||
and send them an invitation.</p>
|
||||
</div>
|
||||
<div id="tell-a-friend-error" class="alert alert-error">
|
||||
Oops. Something went wrong. Don't worry,
|
||||
we won't charge you an invite for our mistake.
|
||||
</div>
|
||||
<div class="still-have-invites">
|
||||
{# Many of these values are set by the initialization code in referral.js #}
|
||||
<form id="referral-form">
|
||||
<input class="input-block-level" type="email" name="email" />
|
||||
</form>
|
||||
</div>
|
||||
<div class="invite-count-area">
|
||||
<span id="invite-hearts"></span>
|
||||
<small class="pull-right"><span class="invite-count">0</span> invite<span class="invite-count-is-plural">s</span> remaining</small>
|
||||
</div>
|
||||
<div class="still-have-invites" id="encouraging-invite-message">
|
||||
<p>
|
||||
Know someone who would love Zulip for their company or group? Invite 'em!
|
||||
</p>
|
||||
</div>
|
||||
<div class="no-more-invites">
|
||||
<p>
|
||||
We'll have more invites for you soon, but
|
||||
for now, enjoy this <a target="_blank"
|
||||
href="http://www.youtube.com/watch?v=PW71En5Pa5s#t=2m01s">song
|
||||
that expresses how we feel when you're
|
||||
logged out</a>.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue