Elgg  Version 2.2
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 preview
 Handler for changing select area. 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 params = {
selectionOpacity: 0,
aspectRatio: '1:1',
onSelectEnd: elgg.avatarCropper.selectChange,
onSelectChange: elgg.avatarCropper.preview
};
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();
}
$('#user-avatar-cropper').imgAreaSelect(params);
if ($('input[name=x2]').val()) {
$(window).on('load', function () {
var ias = $('#user-avatar-cropper').imgAreaSelect({instance: true});
var selection = ias.getSelection();
elgg.avatarCropper.preview($('#user-avatar-cropper'), selection);
});
}
}
elgg
Definition: install.js:23
imgAreaSelect
imgAreaSelect initialization
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two distribute and or modify the software for each author s protection and we want to make certain that everyone understands that there is no warranty for this free software If the software is modified by someone else and passed on
Definition: GPL-LICENSE.txt:43

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 preview
Initial value:
= function(img, selection) {
if (selection.width === 0 || selection.height === 0) {
return;
}
var origWidth = $("#user-avatar-cropper").width();
var origHeight = $("#user-avatar-cropper").height();
var scaleX = 100 / selection.width;
var scaleY = 100 / selection.height;
$('#user-avatar-preview > img').css({
width: Math.round(scaleX * origWidth) + 'px',
height: Math.round(scaleY * origHeight) + 'px',
marginLeft: '-' + Math.round(scaleX * selection.x1) + 'px',
marginTop: '-' + Math.round(scaleY * selection.y1) + 'px'
});
}
line height
Definition: admin.css.php:82
img
Definition: admin.css.php:40
min width
Definition: admin.css.php:166

Handler for changing select area.

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

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

elgg avatarCropper selectChange
Initial value:
= function(img, selection) {
$('input[name=x1]').val(selection.x1);
$('input[name=x2]').val(selection.x2);
$('input[name=y1]').val(selection.y1);
$('input[name=y2]').val(selection.y2);
}
img
Definition: admin.css.php:40

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 73 of file ui.avatar_cropper.js.