Elgg  Version 3.0
Functions | Variables
ui.avatar_cropper.js File Reference

Go to the source code of this file.

Functions

elgg provide ('elgg.avatarCropper')
 Avatar cropping. More...
 
elgg register_hook_handler ('init', 'system', elgg.avatarCropper.init)
 

Variables

elgg avatarCropper init
 Register the avatar cropper. More...
 
elgg avatarCropper selectChange
 Handler for updating the form inputs after select ends. More...
 

Function Documentation

elgg provide ( 'elgg.avatarCropper'  )

Avatar cropping.

elgg register_hook_handler ( 'init ,
'system ,
elgg.avatarCropper.  init 
)

Variable Documentation

elgg avatarCropper init
Initial value:
= function() {
var $img = $('#user-avatar-cropper');
var img = $img.get(0);
var params = {
selectionOpacity: 0,
aspectRatio: '1:1',
onSelectEnd: elgg.avatarCropper.selectChange,
onSelectChange: elgg.avatarCropper.preview,
imageHeight: img.naturalHeight,
imageWidth: img.naturalWidth
};
if ($('input[name=x2]').val()) {
params.x1 = $('input[name=x1]').val();
params.x2 = $('input[name=x2]').val();
params.y1 = $('input[name=y1]').val();
params.y2 = $('input[name=y2]').val();
}
$img.imgAreaSelect(params);
}
if(elgg_extract('use_link', $vars, true)) if(!isset($vars['width'])) if(!isset($vars['height'])) if(!empty($class)) if(!empty($vars['width'])) if(!empty($vars['height'])) $img
Definition: default.php:62
var elgg
Definition: elgglib.js:4

Register the avatar cropper.

If the hidden inputs have the coordinates from a previous cropping, begin the selection and preview with that displayed.

Definition at line 13 of file ui.avatar_cropper.js.

elgg avatarCropper selectChange
Initial value:
= function(img, selection) {
var rounding_diff = selection.width - selection.height;
$('input[name=x1]').val(selection.x1);
$('input[name=x2]').val(selection.x2);
$('input[name=y1]').val(selection.y1);
$('input[name=y2]').val(selection.y2 + rounding_diff);
}

Handler for updating the form inputs after select ends.

Parameters
{Object}img reference to the image
{Object}selection imgareaselect selection object
Returns
void

Definition at line 44 of file ui.avatar_cropper.js.