Version 3.3.4
This commit is contained in:
1 parent
78706903a2
commit
fb6b5baabc
2206 files changed
+409828
-382984
No files matched your search
@@ -35,7 +35,8 @@ var _photoEditor = window.IPBoard;
|
||||
|
||||
_photoEditor.prototype.photoEditor = {
|
||||
cropPhoto: { 'cropper': false },
|
||||
|
||||
scaled: {},
|
||||
|
||||
init: function()
|
||||
{
|
||||
Debug.write("Initializing ips.photoEditor.js");
|
||||
@@ -56,9 +57,12 @@ _photoEditor.prototype.photoEditor = {
|
||||
ipb.delegate.register('.cropperCancel', ipb.photoEditor.photoCropCancel );
|
||||
ipb.delegate.register('.ips_photoSubmit', ipb.photoEditor.photoDone );
|
||||
ipb.delegate.register('.ips_photoRemove', ipb.photoEditor.photoRemove );
|
||||
|
||||
|
||||
/* Watch form */
|
||||
ipb.inlineUploader.watch( 'photoEditorForm', 'upload_photo', ipb.photoEditor.photoUploaded );
|
||||
if ( $('upload_photo') )
|
||||
{
|
||||
ipb.inlineUploader.watch( 'photoEditorForm', 'upload_photo', ipb.photoEditor.photoUploaded );
|
||||
}
|
||||
|
||||
/* Watch for radio buttons */
|
||||
new Array( 'upload_photo', 'gravatar', 'facebook', 'twitter' ).each( function(item)
|
||||
@@ -96,6 +100,8 @@ _photoEditor.prototype.photoEditor = {
|
||||
$('url_photo').value = '';
|
||||
$('url_photo').defaultize( ipb.lang['photo_editor_enterurl'] );
|
||||
|
||||
$('ips_ptype_custom').checked = true;
|
||||
|
||||
ipb.photoEditor.photoUploaded( t.responseJSON, e );
|
||||
}
|
||||
}
|
||||
@@ -189,10 +195,16 @@ _photoEditor.prototype.photoEditor = {
|
||||
if ( t.responseJSON && t.responseJSON['status'] == 'deleted' )
|
||||
{
|
||||
ipb.photoEditor.updatePagePhotos( ipb.vars['member_id'], t.responseJSON['oldThumb'], t.responseJSON['thumb'], t.responseJSON['pp_main_photo'] );
|
||||
|
||||
if ( ! Object.isUndefined( ipb.global.popups['photoEditor'] ) )
|
||||
{
|
||||
ipb.global.popups['photoEditor'].hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -228,6 +240,7 @@ _photoEditor.prototype.photoEditor = {
|
||||
{
|
||||
var img = $('ips_currentPhoto').down('img');
|
||||
img.identify();
|
||||
var maxSize = 200;
|
||||
|
||||
/* Already cropping? */
|
||||
if ( ipb.photoEditor.cropPhoto['cropper'] !== false )
|
||||
@@ -239,10 +252,29 @@ _photoEditor.prototype.photoEditor = {
|
||||
var width = parseInt( img.readAttribute('width') );
|
||||
var size = height;
|
||||
|
||||
if ( width < height )
|
||||
/* Scale it down? */
|
||||
if ( width > maxSize )
|
||||
{
|
||||
size = width;
|
||||
ipb.photoEditor.scaled = { 'origWidth': width, 'origHeight': height };
|
||||
|
||||
height = Math.ceil( ( height * ( ( maxSize * 100 ) / width ) ) / 100 );
|
||||
width = maxSize;
|
||||
|
||||
img.width = width;
|
||||
img.height = height;
|
||||
}
|
||||
else
|
||||
{
|
||||
ipb.photoEditor.scaled = { 'origWidth': width, 'origHeight': height };
|
||||
|
||||
width = Math.ceil( ( width * ( ( maxSize * 100 ) / height ) ) / 100 );
|
||||
height = maxSize;
|
||||
|
||||
img.width = width;
|
||||
img.height = height;
|
||||
}
|
||||
|
||||
size = ( width < height ) ? width : height;
|
||||
|
||||
/* Show ok/cancel */
|
||||
$('ips_cropperStart').hide();
|
||||
@@ -250,12 +282,12 @@ _photoEditor.prototype.photoEditor = {
|
||||
|
||||
/* Init cropper */
|
||||
ipb.photoEditor.cropPhoto['cropper'] = new Cropper.Img( img.id, { ratioDim: { x: size, y: size },
|
||||
minWidth: size,
|
||||
minHeight: size,
|
||||
maxWidth: size,
|
||||
maxHeight: size,
|
||||
displayOnInit: true,
|
||||
onEndCrop: ipb.photoEditor.photoOnEndCrop } );
|
||||
minWidth: size,
|
||||
minHeight: size,
|
||||
maxWidth: size,
|
||||
maxHeight: size,
|
||||
displayOnInit: true,
|
||||
onEndCrop: ipb.photoEditor.photoOnEndCrop } );
|
||||
|
||||
|
||||
},
|
||||
@@ -281,14 +313,31 @@ _photoEditor.prototype.photoEditor = {
|
||||
var _url = ipb.vars['base_url'] + '&app=members&module=ajax§ion=photo&do=cropPhoto&secure_key=' + ipb.vars['secure_hash'];
|
||||
Debug.write( _url );
|
||||
|
||||
/* is it scaled? */
|
||||
var img = $('ips_currentPhoto').down('img');
|
||||
|
||||
var w = img.width;
|
||||
var h = img.height;
|
||||
var xFactor, yFactor = 1;
|
||||
|
||||
if ( w < ipb.photoEditor.scaled['origWidth'] )
|
||||
{
|
||||
xFactor = ipb.photoEditor.scaled['origWidth'] / w;
|
||||
}
|
||||
|
||||
if ( h < ipb.photoEditor.scaled['origHeight'] )
|
||||
{
|
||||
yFactor =ipb.photoEditor.scaled['origHeight'] / h;
|
||||
}
|
||||
|
||||
new Ajax.Request( _url,
|
||||
{
|
||||
method: 'post',
|
||||
evalJSON: 'force',
|
||||
parameters: { x1: ipb.photoEditor.cropPhoto['coords'].x1,
|
||||
x2: ipb.photoEditor.cropPhoto['coords'].x2,
|
||||
y1: ipb.photoEditor.cropPhoto['coords'].y1,
|
||||
y2: ipb.photoEditor.cropPhoto['coords'].y2 },
|
||||
parameters: { x1: parseInt( ipb.photoEditor.cropPhoto['coords'].x1 ) * xFactor,
|
||||
x2: parseInt( ipb.photoEditor.cropPhoto['coords'].x2 ) * xFactor,
|
||||
y1: parseInt( ipb.photoEditor.cropPhoto['coords'].y1 ) * yFactor,
|
||||
y2: parseInt( ipb.photoEditor.cropPhoto['coords'].y2 ) * yFactor },
|
||||
onSuccess: function(t)
|
||||
{
|
||||
/* No Permission */
|
||||
@@ -363,10 +412,23 @@ _photoEditor.prototype.photoEditor = {
|
||||
|
||||
/* Update mini */
|
||||
rand = Math.round( Math.random() * 100000000 );
|
||||
$$('.ips_photoPreview._custom' ).first().down('img').writeAttribute( 'src', newThumb + '?t=' + rand );
|
||||
$$('.ips_photoPreview._custom' ).first().down('img').writeAttribute( 'width', 100 );
|
||||
$$('.ips_photoPreview._custom' ).first().down('img').writeAttribute( 'height', 100 );
|
||||
|
||||
if ( ! newThumb.match( /gravatar\.com/ ) )
|
||||
{
|
||||
$$('.ips_photoPreview._custom' ).first().down('img').writeAttribute( 'src', newThumb + '?t=' + rand );
|
||||
|
||||
if ( ! Object.isUndefined( newFullSize ) && newFullSize < 100 )
|
||||
{
|
||||
$$('.ips_photoPreview._custom' ).first().down('img').writeAttribute( 'width', newFullSize[0] );
|
||||
$$('.ips_photoPreview._custom' ).first().down('img').writeAttribute( 'height', newFullSize[1] );
|
||||
}
|
||||
else
|
||||
{
|
||||
$$('.ips_photoPreview._custom' ).first().down('img').writeAttribute( 'width', 100 );
|
||||
$$('.ips_photoPreview._custom' ).first().down('img').writeAttribute( 'height', 100 );
|
||||
}
|
||||
}
|
||||
Debug.write( newFull);
|
||||
/* Update profile pic */
|
||||
if ( $('ips_currentPhoto') )
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user