2011-05-03 11:22:13 +03:00
|
|
|
|
/**
|
2012-06-16 02:43:47 +03:00
|
|
|
|
* Управление пользователями
|
2013-08-29 12:30:04 +03:00
|
|
|
|
*
|
|
|
|
|
* @module ls/user
|
|
|
|
|
*
|
|
|
|
|
* @license GNU General Public License, version 2
|
|
|
|
|
* @copyright 2013 OOO "ЛС-СОФТ" {@link http://livestreetcms.com}
|
|
|
|
|
* @author Denis Shakhov <denis.shakhov@gmail.com>
|
2012-06-16 02:43:47 +03:00
|
|
|
|
*/
|
2013-08-29 12:30:04 +03:00
|
|
|
|
|
|
|
|
|
var ls = ls || {};
|
|
|
|
|
|
2011-05-03 11:22:13 +03:00
|
|
|
|
ls.user = (function ($) {
|
2012-03-17 13:48:29 +02:00
|
|
|
|
|
2013-07-29 07:28:52 +03:00
|
|
|
|
this.jcropImage = null;
|
2012-03-17 16:53:37 +02:00
|
|
|
|
|
2013-05-30 16:34:30 +03:00
|
|
|
|
/**
|
|
|
|
|
* Инициализация
|
|
|
|
|
*/
|
|
|
|
|
this.init = function() {
|
2013-07-29 07:28:52 +03:00
|
|
|
|
var self = this;
|
2013-05-30 16:34:30 +03:00
|
|
|
|
|
2013-07-29 07:28:52 +03:00
|
|
|
|
/* Авторизация */
|
2013-10-02 17:05:44 +03:00
|
|
|
|
ls.ajax.form(aRouter.login + 'ajax-login', '.js-form-login', function (result, status, xhr, form) {
|
2013-07-29 07:28:52 +03:00
|
|
|
|
result.sUrlRedirect && (window.location = result.sUrlRedirect);
|
|
|
|
|
ls.hook.run('ls_user_login_after', [form, result]);
|
2013-05-30 16:34:30 +03:00
|
|
|
|
});
|
|
|
|
|
|
2013-07-29 07:28:52 +03:00
|
|
|
|
/* Регистрация */
|
2013-10-02 17:21:20 +03:00
|
|
|
|
ls.ajax.form(aRouter.registration + 'ajax-registration', '.js-form-registration', function (result, status, xhr, form) {
|
2013-09-27 04:53:39 +03:00
|
|
|
|
result.sUrlRedirect && (window.location = result.sUrlRedirect);
|
|
|
|
|
ls.hook.run('ls_user_registration_after', [form, result]);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/* Регистрация Modal */
|
2013-10-02 17:05:44 +03:00
|
|
|
|
ls.ajax.form(aRouter.registration + 'ajax-registration', '.js-form-signup', function (result, status, xhr, form) {
|
2013-07-29 07:28:52 +03:00
|
|
|
|
result.sUrlRedirect && (window.location = result.sUrlRedirect);
|
|
|
|
|
ls.hook.run('ls_user_registration_after', [form, result]);
|
2013-05-30 16:34:30 +03:00
|
|
|
|
});
|
|
|
|
|
|
2013-07-29 07:28:52 +03:00
|
|
|
|
/* Восстановление пароля */
|
2013-10-02 17:05:44 +03:00
|
|
|
|
ls.ajax.form(aRouter.login + 'ajax-reminder', '.js-form-recovery', function (result, status, xhr, form) {
|
2013-07-29 07:28:52 +03:00
|
|
|
|
result.sUrlRedirect && (window.location = result.sUrlRedirect);
|
|
|
|
|
ls.hook.run('ls_user_recovery_after', [form, result]);
|
2013-05-30 16:34:30 +03:00
|
|
|
|
});
|
|
|
|
|
|
2013-07-29 07:28:52 +03:00
|
|
|
|
/* Повторный запрос на ссылку активации */
|
2013-10-02 17:05:44 +03:00
|
|
|
|
ls.ajax.form(aRouter.login + 'ajax-reactivation', '.js-form-reactivation', function (result, status, xhr, form) {
|
2013-07-29 07:28:52 +03:00
|
|
|
|
form.find('input').val('');
|
|
|
|
|
ls.hook.run('ls_user_reactivation_after', [form, result]);
|
|
|
|
|
});
|
2013-05-30 16:34:30 +03:00
|
|
|
|
|
2013-07-29 07:28:52 +03:00
|
|
|
|
/* Аякс загрузка изображений */
|
|
|
|
|
this.ajaxUploadImageInit({
|
|
|
|
|
selectors: {
|
|
|
|
|
element: '.js-ajax-avatar-upload'
|
|
|
|
|
},
|
|
|
|
|
cropOptions: {
|
|
|
|
|
aspectRatio: 1
|
|
|
|
|
},
|
|
|
|
|
urls: {
|
|
|
|
|
upload: aRouter['settings'] + 'profile/upload-avatar/',
|
|
|
|
|
remove: aRouter['settings'] + 'profile/remove-avatar/',
|
|
|
|
|
cancel: aRouter['settings'] + 'profile/cancel-avatar/',
|
|
|
|
|
crop: aRouter['settings'] + 'profile/resize-avatar/'
|
2013-05-30 16:34:30 +03:00
|
|
|
|
}
|
2013-07-29 07:28:52 +03:00
|
|
|
|
});
|
2013-05-30 16:34:30 +03:00
|
|
|
|
|
2013-07-29 07:28:52 +03:00
|
|
|
|
this.ajaxUploadImageInit({
|
|
|
|
|
selectors: {
|
|
|
|
|
element: '.js-ajax-photo-upload'
|
|
|
|
|
},
|
|
|
|
|
urls: {
|
|
|
|
|
upload: aRouter['settings'] + 'profile/upload-foto/',
|
|
|
|
|
remove: aRouter['settings'] + 'profile/remove-foto/',
|
|
|
|
|
cancel: aRouter['settings'] + 'profile/cancel-foto/',
|
|
|
|
|
crop: aRouter['settings'] + 'profile/resize-foto/'
|
2013-05-30 16:34:30 +03:00
|
|
|
|
}
|
2013-07-29 07:28:52 +03:00
|
|
|
|
});
|
2013-05-30 16:34:30 +03:00
|
|
|
|
|
2013-07-29 07:28:52 +03:00
|
|
|
|
$('.js-ajax-image-upload-crop-cancel').on('click', function (e) {
|
|
|
|
|
self.ajaxUploadImageCropCancel();
|
2013-05-30 16:34:30 +03:00
|
|
|
|
});
|
|
|
|
|
|
2013-07-29 07:28:52 +03:00
|
|
|
|
$('.js-ajax-image-upload-crop-submit').on('click', function (e) {
|
|
|
|
|
self.ajaxUploadImageCropSubmit();
|
|
|
|
|
});
|
2013-08-29 12:30:04 +03:00
|
|
|
|
|
|
|
|
|
$('.js-modal-toggle-registration').on('click', function (e) {
|
2013-10-02 17:05:44 +03:00
|
|
|
|
$('[data-tab-target=tab-pane-registration]').tab('activate');
|
2013-08-29 12:30:04 +03:00
|
|
|
|
ls.captcha.update();
|
2013-10-02 17:05:44 +03:00
|
|
|
|
$('#modal-login').modal('show');
|
|
|
|
|
e.preventDefault();
|
2013-08-29 12:30:04 +03:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('.js-modal-toggle-login').on('click', function (e) {
|
2013-10-02 17:05:44 +03:00
|
|
|
|
$('[data-tab-target=tab-pane-login]').tab('activate');
|
|
|
|
|
$('#modal-login').modal('show');
|
|
|
|
|
e.preventDefault();
|
2013-08-29 12:30:04 +03:00
|
|
|
|
});
|
2013-05-30 16:34:30 +03:00
|
|
|
|
};
|
|
|
|
|
|
2011-05-03 11:22:13 +03:00
|
|
|
|
/**
|
2012-06-16 02:43:47 +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-06-13 11:46:40 +03:00
|
|
|
|
|
2012-01-28 17:52:44 +02:00
|
|
|
|
var params = {idUser: idUser, userText: sText};
|
2012-06-13 11:46:40 +03:00
|
|
|
|
|
2012-04-28 18:40:06 +03:00
|
|
|
|
ls.hook.marker('addFriendBefore');
|
2013-10-02 17:05:44 +03:00
|
|
|
|
ls.ajax.load(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();
|
2013-04-12 06:55:43 +03:00
|
|
|
|
$('#profile_actions').prepend($($.trim(result.sToggleText)));
|
2012-03-17 13:48:29 +02:00
|
|
|
|
ls.hook.run('ls_user_add_friend_after', [idUser,sAction,result], obj);
|
2011-05-03 11:22:13 +03:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return false;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
2012-06-16 02:43:47 +03:00
|
|
|
|
* Удаление из друзей
|
|
|
|
|
*/
|
2011-05-03 11:22:13 +03:00
|
|
|
|
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};
|
2012-06-13 11:46:40 +03:00
|
|
|
|
|
2012-04-28 18:40:06 +03:00
|
|
|
|
ls.hook.marker('removeFriendBefore');
|
2013-10-02 17:05:44 +03:00
|
|
|
|
ls.ajax.load(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();
|
2013-04-30 17:47:45 +03:00
|
|
|
|
$('#profile_actions').prepend($($.trim(result.sToggleText)));
|
2012-03-17 13:48:29 +02:00
|
|
|
|
ls.hook.run('ls_user_remove_friend_after', [idUser,sAction,result], obj);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return false;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
2013-07-29 07:28:52 +03:00
|
|
|
|
* Поиск пользователей по началу логина
|
2012-03-17 13:48:29 +02:00
|
|
|
|
*/
|
2013-07-29 07:28:52 +03:00
|
|
|
|
this.searchUsersByPrefix = function(sPrefix,obj) {
|
|
|
|
|
obj=$(obj);
|
|
|
|
|
var url = aRouter['people']+'ajax-search/';
|
|
|
|
|
var params = {user_login: sPrefix, isPrefix: 1};
|
|
|
|
|
$('#search-user-login').addClass('loader');
|
2012-03-17 13:48:29 +02:00
|
|
|
|
|
2013-07-29 07:28:52 +03:00
|
|
|
|
ls.hook.marker('searchUsersByPrefixBefore');
|
2013-10-02 17:05:44 +03:00
|
|
|
|
ls.ajax.load(url, params, function(result){
|
2013-07-29 07:28:52 +03:00
|
|
|
|
$('#search-user-login').removeClass('loader');
|
|
|
|
|
$('#user-prefix-filter').find('.active').removeClass('active');
|
|
|
|
|
obj.parent().addClass('active');
|
|
|
|
|
if (result.bStateError) {
|
|
|
|
|
$('#users-list-search').hide();
|
|
|
|
|
$('#users-list-original').show();
|
2012-03-17 13:48:29 +02:00
|
|
|
|
} else {
|
2013-07-29 07:28:52 +03:00
|
|
|
|
$('#users-list-original').hide();
|
|
|
|
|
$('#users-list-search').html(result.sText).show();
|
|
|
|
|
ls.hook.run('ls_user_search_users_by_prefix_after',[sPrefix, obj, result]);
|
2012-03-17 13:48:29 +02:00
|
|
|
|
}
|
|
|
|
|
});
|
2013-07-29 07:28:52 +03:00
|
|
|
|
return false;
|
2012-03-17 13:48:29 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
2013-07-29 07:28:52 +03:00
|
|
|
|
* Подписка
|
2012-03-17 13:48:29 +02:00
|
|
|
|
*/
|
2013-07-29 07:28:52 +03:00
|
|
|
|
this.followToggle = function(obj, iUserId) {
|
|
|
|
|
if ($(obj).hasClass('followed')) {
|
|
|
|
|
ls.stream.unsubscribe(iUserId);
|
|
|
|
|
$(obj).toggleClass('followed').text(ls.lang.get('profile_user_follow'));
|
|
|
|
|
} else {
|
|
|
|
|
ls.stream.subscribe(iUserId);
|
|
|
|
|
$(obj).toggleClass('followed').text(ls.lang.get('profile_user_unfollow'));
|
2012-03-17 13:48:29 +02:00
|
|
|
|
}
|
2011-05-03 11:22:13 +03:00
|
|
|
|
return false;
|
2012-03-17 13:48:29 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
2013-07-29 07:28:52 +03:00
|
|
|
|
* Поиск пользователей
|
2012-03-17 13:48:29 +02:00
|
|
|
|
*/
|
2013-07-29 07:28:52 +03:00
|
|
|
|
this.searchUsers = function(form) {
|
|
|
|
|
var url = aRouter['people']+'ajax-search/';
|
|
|
|
|
var inputSearch=$('#'+form).find('input');
|
|
|
|
|
inputSearch.addClass('loader');
|
2012-03-17 13:48:29 +02:00
|
|
|
|
|
2013-07-29 07:28:52 +03:00
|
|
|
|
ls.hook.marker('searchUsersBefore');
|
2013-10-02 17:05:44 +03:00
|
|
|
|
ls.ajax.submit(url, form, function(result){
|
2013-07-29 07:28:52 +03:00
|
|
|
|
inputSearch.removeClass('loader');
|
2012-03-17 13:48:29 +02:00
|
|
|
|
if (result.bStateError) {
|
2013-07-29 07:28:52 +03:00
|
|
|
|
$('#users-list-search').hide();
|
|
|
|
|
$('#users-list-original').show();
|
2012-03-17 13:48:29 +02:00
|
|
|
|
} else {
|
2013-07-29 07:28:52 +03:00
|
|
|
|
$('#users-list-original').hide();
|
|
|
|
|
$('#users-list-search').html(result.sText).show();
|
|
|
|
|
ls.hook.run('ls_user_search_users_after',[form, result]);
|
2012-03-17 13:48:29 +02:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2013-07-30 11:36:48 +03:00
|
|
|
|
|
2013-07-29 07:28:52 +03:00
|
|
|
|
|
2012-03-17 13:48:29 +02:00
|
|
|
|
/**
|
2013-07-29 07:28:52 +03:00
|
|
|
|
* Загрузка временной аватарки
|
|
|
|
|
* @param form
|
|
|
|
|
* @param input
|
2012-03-17 13:48:29 +02:00
|
|
|
|
*/
|
2013-07-29 07:28:52 +03:00
|
|
|
|
this.ajaxUploadImageInit = function(options) {
|
|
|
|
|
var self = this;
|
|
|
|
|
|
|
|
|
|
var defaults = {
|
|
|
|
|
cropOptions: {
|
|
|
|
|
minSize: [32, 32]
|
|
|
|
|
},
|
|
|
|
|
selectors: {
|
|
|
|
|
element: '.js-ajax-image-upload',
|
|
|
|
|
image: '.js-ajax-image-upload-image',
|
|
|
|
|
image_crop: '.js-image-crop',
|
|
|
|
|
remove_button: '.js-ajax-image-upload-remove',
|
|
|
|
|
choose_button: '.js-ajax-image-upload-choose',
|
|
|
|
|
input_file: '.js-ajax-image-upload-file',
|
|
|
|
|
crop_cancel_button: '.js-ajax-image-upload-crop-cancel',
|
2013-07-29 08:11:36 +03:00
|
|
|
|
crop_submit_button: '.js-ajax-image-upload-crop-submit'
|
2013-07-29 07:28:52 +03:00
|
|
|
|
},
|
|
|
|
|
urls: {
|
|
|
|
|
upload: aRouter['settings'] + 'profile/upload-avatar/',
|
|
|
|
|
remove: aRouter['settings'] + 'profile/remove-avatar/',
|
|
|
|
|
cancel: aRouter['settings'] + 'profile/cancel-avatar/',
|
2013-07-29 08:11:36 +03:00
|
|
|
|
crop: aRouter['settings'] + 'profile/resize-avatar/'
|
2012-03-17 13:48:29 +02:00
|
|
|
|
}
|
2013-07-29 07:28:52 +03:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var options = $.extend(true, {}, defaults, options);
|
|
|
|
|
|
|
|
|
|
$(options.selectors.element).each(function () {
|
|
|
|
|
var $element = $(this);
|
2013-07-30 11:36:48 +03:00
|
|
|
|
|
2013-07-29 07:28:52 +03:00
|
|
|
|
var elements = {
|
|
|
|
|
element: $element,
|
|
|
|
|
remove_button: $element.find(options.selectors.remove_button),
|
|
|
|
|
choose_button: $element.find(options.selectors.choose_button),
|
|
|
|
|
image: $element.find(options.selectors.image),
|
2013-07-29 08:11:36 +03:00
|
|
|
|
image_crop: $element.find(options.selectors.image_crop)
|
2013-07-29 07:28:52 +03:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$element.find(options.selectors.input_file).on('change', function () {
|
|
|
|
|
self.currentElements = elements;
|
|
|
|
|
self.currentOptions = options;
|
|
|
|
|
self.ajaxUploadImage(null, $(this), options);
|
|
|
|
|
});
|
2012-03-17 13:48:29 +02:00
|
|
|
|
|
2013-07-29 07:28:52 +03:00
|
|
|
|
elements.remove_button.on('click', function (e) {
|
|
|
|
|
self.ajaxUploadImageRemove(options, elements);
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
});
|
|
|
|
|
});
|
2012-03-17 13:48:29 +02:00
|
|
|
|
};
|
2012-03-17 16:53:37 +02:00
|
|
|
|
|
|
|
|
|
/**
|
2013-07-29 07:28:52 +03:00
|
|
|
|
* Загрузка временной аватарки
|
2012-03-17 16:53:37 +02:00
|
|
|
|
* @param form
|
|
|
|
|
* @param input
|
|
|
|
|
*/
|
2013-07-29 07:28:52 +03:00
|
|
|
|
this.ajaxUploadImage = function(form, input, options) {
|
|
|
|
|
if ( ! form && input ) {
|
|
|
|
|
var form = $('<form method="post" enctype="multipart/form-data"></form>').hide().appendTo('body');
|
|
|
|
|
|
|
|
|
|
input.clone(true).insertAfter(input);
|
2012-04-08 01:21:23 +03:00
|
|
|
|
input.appendTo(form);
|
2012-03-17 16:53:37 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-10-02 17:05:44 +03:00
|
|
|
|
ls.ajax.submit(options.urls.upload, form, function (data) {
|
2012-03-17 16:53:37 +02:00
|
|
|
|
if (data.bStateError) {
|
|
|
|
|
ls.msg.error(data.sMsgTitle,data.sMsg);
|
|
|
|
|
} else {
|
2013-07-29 07:28:52 +03:00
|
|
|
|
this.ajaxUploadImageModalCrop(data.sTmpFile, options);
|
2012-03-17 16:53:37 +02:00
|
|
|
|
}
|
2013-07-30 11:36:48 +03:00
|
|
|
|
form.remove();
|
2012-03-17 16:53:37 +02:00
|
|
|
|
}.bind(this));
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
2013-07-29 07:28:52 +03:00
|
|
|
|
* Показывает форму для ресайза аватарки
|
2012-03-17 16:53:37 +02:00
|
|
|
|
* @param sImgFile
|
|
|
|
|
*/
|
2013-07-29 07:28:52 +03:00
|
|
|
|
this.ajaxUploadImageModalCrop = function(sImgFile, options) {
|
|
|
|
|
var self = this;
|
2012-03-17 16:53:37 +02:00
|
|
|
|
|
2013-07-29 07:28:52 +03:00
|
|
|
|
this.jcropImage && this.jcropImage.destroy();
|
2012-03-17 16:53:37 +02:00
|
|
|
|
|
2013-07-29 07:28:52 +03:00
|
|
|
|
$('.js-image-crop').attr('src', sImgFile + '?' + Math.random()).css({
|
|
|
|
|
'width': 'auto',
|
|
|
|
|
'height': 'auto'
|
2012-03-17 16:53:37 +02:00
|
|
|
|
});
|
|
|
|
|
|
2013-07-29 07:28:52 +03:00
|
|
|
|
if ($('#modal-image-crop').length)
|
|
|
|
|
$('#modal-image-crop').modal('show');
|
|
|
|
|
else {
|
|
|
|
|
ls.debug('Error [Ajax Image Upload]:\nМодальное окно ресайза изображения не найдено');
|
|
|
|
|
}
|
2012-03-17 16:53:37 +02:00
|
|
|
|
|
2013-07-29 07:28:52 +03:00
|
|
|
|
$('.js-image-crop').Jcrop(options.cropOptions, function () {
|
|
|
|
|
self.jcropImage = this;
|
|
|
|
|
this.setSelect([0, 0, 500, 500]);
|
2012-03-17 16:53:37 +02:00
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
2013-07-29 07:28:52 +03:00
|
|
|
|
* Удаление аватарки
|
2012-03-17 16:53:37 +02:00
|
|
|
|
*/
|
2013-07-29 07:28:52 +03:00
|
|
|
|
this.ajaxUploadImageRemove = function(options, elements) {
|
|
|
|
|
ls.hook.marker('removeAvatarBefore');
|
2012-03-17 16:53:37 +02:00
|
|
|
|
|
2013-10-02 17:05:44 +03:00
|
|
|
|
ls.ajax.load(options.urls.remove, {}, function(result) {
|
2012-03-17 16:53:37 +02:00
|
|
|
|
if (result.bStateError) {
|
|
|
|
|
ls.msg.error(null,result.sMsg);
|
|
|
|
|
} else {
|
2013-07-29 07:28:52 +03:00
|
|
|
|
elements.image.attr('src', result.sFile + '?' + Math.random());
|
|
|
|
|
elements.remove_button.hide();
|
|
|
|
|
elements.choose_button.text(result.sTitleUpload);
|
2012-03-21 20:44:58 +02:00
|
|
|
|
|
2013-07-29 07:28:52 +03:00
|
|
|
|
ls.hook.run('ls_user_remove_avatar_after', [result]);
|
2012-04-05 11:52:13 +03:00
|
|
|
|
}
|
2012-03-21 20:44:58 +02:00
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2012-03-22 07:54:46 +02:00
|
|
|
|
/**
|
2013-07-29 07:28:52 +03:00
|
|
|
|
* Отмена ресайза аватарки, подчищаем временный данные
|
2012-03-22 07:54:46 +02:00
|
|
|
|
*/
|
2013-07-29 07:28:52 +03:00
|
|
|
|
this.ajaxUploadImageCropCancel = function() {
|
|
|
|
|
ls.hook.marker('cancelAvatarBefore');
|
2012-03-22 07:54:46 +02:00
|
|
|
|
|
2013-10-02 17:05:44 +03:00
|
|
|
|
ls.ajax.load(this.currentOptions.urls.cancel, {}, function(result) {
|
2012-03-22 07:54:46 +02:00
|
|
|
|
if (result.bStateError) {
|
|
|
|
|
ls.msg.error(null,result.sMsg);
|
|
|
|
|
} else {
|
2013-07-29 07:28:52 +03:00
|
|
|
|
$('#modal-image-crop').modal('hide');
|
|
|
|
|
ls.hook.run('ls_user_cancel_avatar_after', [result]);
|
2012-07-07 11:13:59 +03:00
|
|
|
|
}
|
2012-04-05 13:15:33 +03:00
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2012-04-05 13:47:47 +03:00
|
|
|
|
/**
|
2013-07-29 07:28:52 +03:00
|
|
|
|
* Выполняет ресайз аватарки
|
2012-04-05 13:47:47 +03:00
|
|
|
|
*/
|
2013-07-29 07:28:52 +03:00
|
|
|
|
this.ajaxUploadImageCropSubmit = function() {
|
|
|
|
|
var self = this;
|
2012-04-05 13:47:47 +03:00
|
|
|
|
|
2013-07-29 07:28:52 +03:00
|
|
|
|
if ( ! this.jcropImage ) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2012-06-13 11:46:40 +03:00
|
|
|
|
|
2013-07-29 07:28:52 +03:00
|
|
|
|
var params = {
|
|
|
|
|
size: this.jcropImage.tellSelect()
|
|
|
|
|
};
|
2012-06-13 11:46:40 +03:00
|
|
|
|
|
2013-07-29 07:28:52 +03:00
|
|
|
|
ls.hook.marker('resizeAvatarBefore');
|
2012-03-30 17:09:32 +03:00
|
|
|
|
|
2013-10-02 17:05:44 +03:00
|
|
|
|
ls.ajax.load(self.currentOptions.urls.crop, params, function(result) {
|
2012-03-30 17:09:32 +03:00
|
|
|
|
if (result.bStateError) {
|
2013-07-29 07:28:52 +03:00
|
|
|
|
ls.msg.error(null,result.sMsg);
|
2012-03-30 17:09:32 +03:00
|
|
|
|
} else {
|
2013-07-29 07:28:52 +03:00
|
|
|
|
self.currentElements.image.attr('src',result.sFile+'?'+Math.random());
|
|
|
|
|
$('#modal-image-crop').modal('hide');
|
|
|
|
|
self.currentElements.remove_button.show();
|
|
|
|
|
self.currentElements.choose_button.text(result.sTitleUpload);
|
2012-04-06 12:30:02 +03:00
|
|
|
|
|
2013-07-29 07:28:52 +03:00
|
|
|
|
ls.hook.run('ls_user_resize_avatar_after', [params, result]);
|
2012-04-06 12:30:02 +03:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2012-04-15 05:58:14 +03:00
|
|
|
|
return false;
|
|
|
|
|
};
|
|
|
|
|
|
2012-04-06 12:30:02 +03:00
|
|
|
|
|
2011-05-03 11:22:13 +03:00
|
|
|
|
return this;
|
2013-09-27 04:53:39 +03:00
|
|
|
|
}).call(ls.user || {},jQuery);
|