mirror of
https://github.com/Oreolek/ifhub.club.git
synced 2024-06-16 23:00:51 +03:00
Добавлена возможность изменять аватар на странице после кропа
This commit is contained in:
parent
97abe41cbd
commit
265db4e2e4
|
@ -255,9 +255,18 @@ class ActionSettings extends Action
|
|||
return $this->EventErrorDebug();
|
||||
}
|
||||
|
||||
if (true !== ($res = $this->User_CreateProfileAvatar($oUser->getProfileFoto(), $oUser, getRequest('size'),
|
||||
if (true === ($res = $this->User_CreateProfileAvatar($oUser->getProfileFoto(), $oUser, getRequest('size'),
|
||||
getRequestStr('canvas_width')))
|
||||
) {
|
||||
// Формируем массив с путями до аватаров
|
||||
$aAvatars = array();
|
||||
|
||||
foreach (Config::Get('module.blog.avatar_size') as $sSize) {
|
||||
$aAvatars[ $sSize ] = $oUser->getProfileAvatarPath( $sSize );
|
||||
}
|
||||
|
||||
$this->Viewer_AssignAjax('sFile', $aAvatars);
|
||||
} else {
|
||||
$this->Message_AddError(is_string($res) ? $res : $this->Lang_Get('error'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -292,6 +292,9 @@ jQuery(document).ready(function($){
|
|||
save_photo: aRouter.settings + 'ajax-crop-photo',
|
||||
save_avatar: aRouter.settings + 'ajax-change-avatar',
|
||||
cancel_photo: aRouter.settings + 'ajax-crop-cancel-photo',
|
||||
},
|
||||
cropavatar: function ( event, _this, avatars ) {
|
||||
$( '.js-user-profile-avatar' ).attr( 'src', avatars[ '64crop' ] + '?' + Math.random() );
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
{**
|
||||
* Блок с фотографией пользователя в профиле
|
||||
*
|
||||
* @styles css/blocks.css
|
||||
* @scripts <framework>/js/livestreet/user.js
|
||||
*}
|
||||
|
||||
{extends 'components/block/block.tpl'}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
{* Пользователь *}
|
||||
<div class="{$component}-user">
|
||||
<a href="{$user->getUserWebPath()}">
|
||||
<img src="{$user->getProfileAvatarPath(64)}" alt="{$user->getProfileName()}" class="{$component}-user-avatar" itemprop="photo">
|
||||
<img src="{$user->getProfileAvatarPath(64)}" alt="{$user->getProfileName()}" class="{$component}-user-avatar js-user-profile-avatar" itemprop="photo">
|
||||
</a>
|
||||
|
||||
<h2 class="{$component}-user-login word-wrap" itemprop="nickname">
|
||||
|
|
|
@ -45,6 +45,9 @@
|
|||
},
|
||||
// Параметры передаваемые в аякс запросах
|
||||
params: {}
|
||||
|
||||
// Успешный кроп аватара
|
||||
// cropavatar: function() {}
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -159,6 +162,9 @@
|
|||
minSize: [ 100, 100 ],
|
||||
aspectRatio: 1
|
||||
},
|
||||
save_callback : function( response, modal, image ) {
|
||||
this._trigger( 'cropavatar', null, [ this, response.sFile ] );
|
||||
},
|
||||
save_params : this.option( 'params' ),
|
||||
crop_url : this.option( 'urls.crop_avatar' ),
|
||||
save_url : this.option( 'urls.save_avatar' )
|
||||
|
|
Loading…
Reference in a new issue