1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-07-08 17:34:26 +03:00
ifhub.club/engine/lib/internal/template/js/friend.js

68 lines
1.9 KiB
JavaScript
Raw Normal View History

2011-05-03 11:22:13 +03:00
var ls = ls || {};
/**
* Управление пользователями
*/
ls.user = (function ($) {
2011-04-01 10:49:36 +03:00
2011-05-03 11:22:13 +03:00
/**
* Добавление в друзья
*/
this.addFriend = function(obj, idUser, sAction){
if(sAction != 'link' && sAction != 'accept') {
2012-01-28 17:52:44 +02:00
var sText = $('#add_friend_text').val();
2011-05-03 11:22:13 +03:00
$('#add_friend_form').children().each(function(i, item){$(item).attr('disabled','disabled')});
} else {
2012-01-28 17:52:44 +02:00
var sText='';
2011-04-01 10:49:36 +03:00
}
2011-05-03 11:22:13 +03:00
if(sAction == 'accept') {
2012-01-28 17:52:44 +02:00
var url = aRouter.profile+'ajaxfriendaccept/';
2011-05-03 11:22:13 +03:00
} else {
2012-01-28 17:52:44 +02:00
var url = aRouter.profile+'ajaxfriendadd/';
2011-04-01 10:49:36 +03:00
}
2012-01-28 17:52:44 +02:00
var params = {idUser: idUser, userText: sText};
'*addFriendBefore*'; '*/addFriendBefore*';
ls.ajax(url, params, function(result){
2011-05-03 11:22:13 +03:00
$('#add_friend_form').children().each(function(i, item){$(item).removeAttr('disabled')});
if (!result) {
ls.msg.error('Error','Please try again later');
}
if (result.bStateError) {
ls.msg.error(null,result.sMsg);
} else {
ls.msg.notice(null,result.sMsg);
$('#add_friend_form').jqmHide();
$('#add_friend_item').remove();
$('#profile_actions').prepend($(result.sToggleText));
2012-01-28 17:52:44 +02:00
ls.hook.run('ls_friend_add_friend_after', [idUser,sAction,result], obj);
2011-05-03 11:22:13 +03:00
}
});
return false;
};
/**
* Удаление из друзей
*/
this.removeFriend = function(obj,idUser,sAction) {
2012-01-28 17:52:44 +02:00
var url = aRouter.profile+'ajaxfrienddelete/';
var params = {idUser: idUser,sAction: sAction};
'*removeFriendBefore*'; '*/removeFriendBefore*';
ls.ajax(url, params, function(result) {
2011-05-03 11:22:13 +03:00
if (result.bStateError) {
ls.msg.error(null,result.sMsg);
} else {
ls.msg.notice(null,result.sMsg);
$('#delete_friend_item').remove();
$('#profile_actions').prepend($(result.sToggleText));
2012-01-28 17:52:44 +02:00
ls.hook.run('ls_friend_remove_friend_after', [idUser,sAction,result], obj);
2011-05-03 11:22:13 +03:00
}
});
return false;
}
return this;
}).call(ls.user || {},jQuery);