|
|
@ -21,9 +21,13 @@ $(document).ready(function() {
|
|
|
|
NProgress.set(0.7);
|
|
|
|
NProgress.set(0.7);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
$(window).on('action:ajaxify.end', function() {
|
|
|
|
$(window).on('action:ajaxify.end', function(ev, data) {
|
|
|
|
NProgress.done();
|
|
|
|
NProgress.done();
|
|
|
|
setupHoverCards();
|
|
|
|
setupHoverCards();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (data.url.match('user/')) {
|
|
|
|
|
|
|
|
setupFavouriteButtonOnProfile();
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -198,29 +202,7 @@ $(document).ready(function() {
|
|
|
|
if (parseInt(app.user.uid, 10) === parseInt(data.uid, 10) || !app.user.uid) {
|
|
|
|
if (parseInt(app.user.uid, 10) === parseInt(data.uid, 10) || !app.user.uid) {
|
|
|
|
card.find('.btn-morph').hide();
|
|
|
|
card.find('.btn-morph').hide();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
card.find('.btn-morph').click(function(ev) {
|
|
|
|
setupFavouriteMorph(card, data.uid, data.username);
|
|
|
|
var type = $(this).hasClass('plus') ? 'follow' : 'unfollow';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
socket.emit('user.' + type, {uid: data.uid}, function(err) {
|
|
|
|
|
|
|
|
if (err) {
|
|
|
|
|
|
|
|
return app.alertError(err.message);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.alertSuccess('[[global:alert.' + type + ', ' + data.username + ']]');
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$(this).toggleClass('plus').toggleClass('heart');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($(this).find('b.drop').length === 0) {
|
|
|
|
|
|
|
|
$(this).prepend('<b class="drop"></b>');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var drop = $(this).find('b.drop').removeClass('animate'),
|
|
|
|
|
|
|
|
x = ev.pageX - drop.width() / 2 - $(this).offset().left,
|
|
|
|
|
|
|
|
y = ev.pageY - drop.height() / 2 - $(this).offset().top;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
drop.css({top: y + 'px', left: x + 'px'}).addClass('animate');
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isFollowing) {
|
|
|
|
if (isFollowing) {
|
|
|
|
$('.btn-morph').addClass('heart');
|
|
|
|
$('.btn-morph').addClass('heart');
|
|
|
@ -239,6 +221,10 @@ $(document).ready(function() {
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function setupFavouriteButtonOnProfile() {
|
|
|
|
|
|
|
|
setupFavouriteMorph($('[component="account/cover"]'), ajaxify.data.uid, ajaxify.data.username);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function setupCardRemoval(card) {
|
|
|
|
function setupCardRemoval(card) {
|
|
|
|
function removeCard(ev) {
|
|
|
|
function removeCard(ev) {
|
|
|
|
if ($(ev.target).closest('.persona-usercard').length === 0) {
|
|
|
|
if ($(ev.target).closest('.persona-usercard').length === 0) {
|
|
|
@ -252,4 +238,30 @@ $(document).ready(function() {
|
|
|
|
|
|
|
|
|
|
|
|
$(document).on('click', removeCard);
|
|
|
|
$(document).on('click', removeCard);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function setupFavouriteMorph(parent, uid, username) {
|
|
|
|
|
|
|
|
parent.find('.btn-morph').click(function(ev) {
|
|
|
|
|
|
|
|
var type = $(this).hasClass('plus') ? 'follow' : 'unfollow';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
socket.emit('user.' + type, {uid: uid}, function(err) {
|
|
|
|
|
|
|
|
if (err) {
|
|
|
|
|
|
|
|
return app.alertError(err.message);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.alertSuccess('[[global:alert.' + type + ', ' + username + ']]');
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$(this).toggleClass('plus').toggleClass('heart');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($(this).find('b.drop').length === 0) {
|
|
|
|
|
|
|
|
$(this).prepend('<b class="drop"></b>');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var drop = $(this).find('b.drop').removeClass('animate'),
|
|
|
|
|
|
|
|
x = ev.pageX - drop.width() / 2 - $(this).offset().left,
|
|
|
|
|
|
|
|
y = ev.pageY - drop.height() / 2 - $(this).offset().top;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
drop.css({top: y + 'px', left: x + 'px'}).addClass('animate');
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|