aboutsummaryrefslogtreecommitdiff
path: root/mod/profile
diff options
context:
space:
mode:
Diffstat (limited to 'mod/profile')
-rw-r--r--mod/profile/actions/iconupload.php8
-rw-r--r--mod/profile/views/default/js/jquery.imgareaselect-0.4.2.js355
-rw-r--r--mod/profile/views/default/js/jquery.imgareaselect-0.4.2.min.js1
-rw-r--r--mod/profile/views/default/profile/editicon.php40
4 files changed, 401 insertions, 3 deletions
diff --git a/mod/profile/actions/iconupload.php b/mod/profile/actions/iconupload.php
index 00e766c1c..8dcfeea36 100644
--- a/mod/profile/actions/iconupload.php
+++ b/mod/profile/actions/iconupload.php
@@ -45,7 +45,7 @@
$filehandler->close();
$filehandler->setFilename("profile/" . $_SESSION['user']->username . "master.jpg");
$filehandler->open("write");
- $filehandler->write($master);
+ $filehandler->write($master);
$filehandler->close();
$_SESSION['user']->icontime = time();
@@ -62,6 +62,10 @@
}
- if (isloggedin()) forward($_SESSION['user']->getURL());
+ //forward the user back to the upload page to crop
+
+ $url = $vars['url'] . "mod/profile/editicon.php";
+
+ if (isloggedin()) forward($url);
?> \ No newline at end of file
diff --git a/mod/profile/views/default/js/jquery.imgareaselect-0.4.2.js b/mod/profile/views/default/js/jquery.imgareaselect-0.4.2.js
new file mode 100644
index 000000000..637332d07
--- /dev/null
+++ b/mod/profile/views/default/js/jquery.imgareaselect-0.4.2.js
@@ -0,0 +1,355 @@
+/*
+ * imgAreaSelect jQuery plugin
+ * version 0.4.2
+ *
+ * Copyright (c) 2008 Michal Wojciechowski (odyniec.net)
+ *
+ * Dual licensed under the MIT (MIT-LICENSE.txt)
+ * and GPL (GPL-LICENSE.txt) licenses.
+ *
+ * http://odyniec.net/projects/imgareaselect/
+ *
+ */
+
+jQuery.imgAreaSelect = function (img, options) {
+ var $area = jQuery('<div></div>'),
+ $border1 = jQuery('<div></div>'),
+ $border2 = jQuery('<div></div>'),
+ $outLeft = jQuery('<div></div>'),
+ $outTop = jQuery('<div></div>'),
+ $outRight = jQuery('<div></div>'),
+ $outBottom = jQuery('<div></div>'),
+ imgOfs, imgWidth, imgHeight, zIndex = 0, fixed = false, $p,
+ startX, startY, moveX, moveY,
+ resizeMargin = 10, resize = [ ], V = 0, H = 1,
+ d, aspectRatio,
+ x1, x2, y1, y2, x, y,
+ selection = { x1: 0, y1: 0, x2: 0, y2: 0, width: 0, height: 0 };
+
+ var $a = $area.add($border1).add($border2);
+ var $o = $outLeft.add($outTop).add($outRight).add($outBottom);
+
+ function update()
+ {
+ $a.css({
+ left: (selection.x1 + imgOfs.left) + 'px',
+ top: (selection.y1 + imgOfs.top) + 'px',
+ width: Math.max(selection.width - options.borderWidth * 2, 0) + 'px',
+ height: Math.max(selection.height - options.borderWidth * 2, 0) + 'px'
+ });
+ $outLeft.css({ left: imgOfs.left + 'px', top: imgOfs.top + 'px',
+ width: selection.x1 + 'px', height: imgHeight + 'px' });
+ $outTop.css({ left: imgOfs.left + selection.x1 + 'px', top: imgOfs.top + 'px',
+ width: selection.width + 'px', height: selection.y1 + 'px' });
+ $outRight.css({ left: imgOfs.left + selection.x2 + 'px', top: imgOfs.top + 'px',
+ width: imgWidth - selection.x2 + 'px', height: imgHeight + 'px' });
+ $outBottom.css({ left: imgOfs.left + selection.x1 + 'px', top: imgOfs.top + selection.y2 + 'px',
+ width: selection.width + 'px', height: imgHeight - selection.y2 + 'px' });
+ }
+
+ function areaMouseMove(event)
+ {
+ x = event.pageX - selection.x1 - imgOfs.left;
+ y = event.pageY - selection.y1 - imgOfs.top;
+
+ resize = [ ];
+
+ if (options.resizable) {
+ if (y <= resizeMargin)
+ resize[V] = 'n';
+ else if (y >= selection.height - resizeMargin)
+ resize[V] = 's';
+ if (x <= resizeMargin)
+ resize[H] = 'w';
+ else if (x >= selection.width - resizeMargin)
+ resize[H] = 'e';
+ }
+
+ $border2.css('cursor', resize.length ? resize.join('') + '-resize' :
+ options.movable ? 'move' : '');
+ }
+
+ function areaMouseDown(event)
+ {
+ if (event.which != 1) return false;
+
+ if (options.resizable && resize.length > 0) {
+ jQuery('body').css('cursor', resize.join('') + '-resize');
+
+ x1 = (resize[H] == 'w' ? selection.x2 : selection.x1) + imgOfs.left;
+ y1 = (resize[V] == 'n' ? selection.y2 : selection.y1) + imgOfs.top;
+
+ jQuery(document).mousemove(selectingMouseMove);
+ $border2.unbind('mousemove', areaMouseMove);
+
+ jQuery(document).one('mouseup', function () {
+ resize = [ ];
+
+ jQuery('body').css('cursor', '');
+
+ if (options.autoHide)
+ $a.add($o).hide();
+
+ options.onSelectEnd(img, selection);
+
+ jQuery(document).unbind('mousemove', selectingMouseMove);
+ $border2.mousemove(areaMouseMove);
+ });
+ }
+ else if (options.movable) {
+ moveX = selection.x1 + imgOfs.left;
+ moveY = selection.y1 + imgOfs.top;
+ startX = event.pageX;
+ startY = event.pageY;
+
+ jQuery(document)
+ .mousemove(movingMouseMove)
+ .one('mouseup', function () {
+ options.onSelectEnd(img, selection);
+
+ jQuery(document).unbind('mousemove', movingMouseMove);
+ });
+ }
+ else
+ jQuery(img).mousedown(event);
+
+ return false;
+ }
+
+ function aspectRatioXY()
+ {
+ x2 = Math.max(imgOfs.left, Math.min(imgOfs.left + imgWidth,
+ x1 + Math.abs(y2 - y1) * aspectRatio * (x2 > x1 ? 1 : -1)));
+ y2 = Math.round(Math.max(imgOfs.top, Math.min(imgOfs.top + imgHeight,
+ y1 + Math.abs(x2 - x1) / aspectRatio * (y2 > y1 ? 1 : -1))));
+ x2 = Math.round(x2);
+ }
+
+ function aspectRatioYX()
+ {
+ y2 = Math.max(imgOfs.top, Math.min(imgOfs.top + imgHeight,
+ y1 + Math.abs(x2 - x1) / aspectRatio * (y2 > y1 ? 1 : -1)));
+ x2 = Math.round(Math.max(imgOfs.left, Math.min(imgOfs.left + imgWidth,
+ x1 + Math.abs(y2 - y1) * aspectRatio * (x2 > x1 ? 1 : -1))));
+ y2 = Math.round(y2);
+ }
+
+ function selectingMouseMove(event)
+ {
+ x2 = !resize.length || resize[H] || aspectRatio ? event.pageX : selection.x2 + imgOfs.left;
+ y2 = !resize.length || resize[V] || aspectRatio ? event.pageY : selection.y2 + imgOfs.top;
+
+ if (options.minWidth && Math.abs(x2 - x1) < options.minWidth) {
+ x2 = x1 - options.minWidth * (x2 < x1 ? 1 : -1);
+
+ if (x2 < imgOfs.left)
+ x1 = imgOfs.left + options.minWidth;
+ else if (x2 > imgOfs.left + imgWidth)
+ x1 = imgOfs.left + imgWidth - options.minWidth;
+ }
+
+ if (options.minHeight && Math.abs(y2 - y1) < options.minHeight) {
+ y2 = y1 - options.minHeight * (y2 < y1 ? 1 : -1);
+
+ if (y2 < imgOfs.top)
+ y1 = imgOfs.top + options.minHeight;
+ else if (y2 > imgOfs.top + imgHeight)
+ y1 = imgOfs.top + imgHeight - options.minHeight;
+ }
+
+ x2 = Math.max(imgOfs.left, Math.min(x2, imgOfs.left + imgWidth));
+ y2 = Math.max(imgOfs.top, Math.min(y2, imgOfs.top + imgHeight));
+
+ if (aspectRatio)
+ if (Math.abs(x2 - x1) / aspectRatio > Math.abs(y2 - y1))
+ aspectRatioYX();
+ else
+ aspectRatioXY();
+
+ if (options.maxWidth && Math.abs(x2 - x1) > options.maxWidth) {
+ x2 = x1 - options.maxWidth * (x2 < x1 ? 1 : -1);
+ if (aspectRatio) aspectRatioYX();
+ }
+
+ if (options.maxHeight && Math.abs(y2 - y1) > options.maxHeight) {
+ y2 = y1 - options.maxHeight * (y2 < y1 ? 1 : -1);
+ if (aspectRatio) aspectRatioXY();
+ }
+
+ selection.x1 = Math.min(x1, x2) - imgOfs.left;
+ selection.x2 = Math.max(x1, x2) - imgOfs.left;
+ selection.y1 = Math.min(y1, y2) - imgOfs.top;
+ selection.y2 = Math.max(y1, y2) - imgOfs.top;
+ selection.width = Math.abs(x2 - x1);
+ selection.height = Math.abs(y2 - y1);
+
+ update();
+
+ options.onSelectChange(img, selection);
+
+ return false;
+ }
+
+ function movingMouseMove(event)
+ {
+ x1 = Math.max(imgOfs.left, Math.min(moveX + event.pageX - startX,
+ imgOfs.left + imgWidth - selection.width));
+ y1 = Math.max(imgOfs.top, Math.min(moveY + event.pageY - startY,
+ imgOfs.top + imgHeight - selection.height));
+ x2 = x1 + selection.width;
+ y2 = y1 + selection.height;
+
+ selection.x1 = x1 - imgOfs.left;
+ selection.y1 = y1 - imgOfs.top;
+ selection.x2 = x2 - imgOfs.left;
+ selection.y2 = y2 - imgOfs.top;
+
+ update();
+
+ options.onSelectChange(img, selection);
+ event.preventDefault();
+
+ return false;
+ }
+
+ function imgMouseDown(event)
+ {
+ if (event.which != 1) return false;
+
+ startX = x1 = event.pageX;
+ startY = y1 = event.pageY;
+ selection.x1 = selection.x2 = x1 - imgOfs.left;
+ selection.y1 = selection.y2 = y1 - imgOfs.top;
+ selection.width = 0;
+ selection.height = 0;
+
+ resize = [ ];
+
+ update();
+ $a.add($o).show();
+
+ jQuery(document).mousemove(selectingMouseMove);
+ $border2.unbind('mousemove', areaMouseMove);
+
+ options.onSelectStart(img, selection);
+
+ jQuery(document).one('mouseup', function () {
+ if (options.autoHide)
+ $a.add($o).hide();
+
+ options.onSelectEnd(img, selection);
+
+ jQuery(document).unbind('mousemove', selectingMouseMove);
+ $border2.mousemove(areaMouseMove);
+ });
+
+ return false;
+ }
+
+ this.setOptions = function(newOptions)
+ {
+ options = jQuery.extend(options, newOptions);
+
+ if (newOptions.x1 != null) {
+ selection.x1 = newOptions.x1;
+ selection.y1 = newOptions.y1;
+ selection.x2 = newOptions.x2;
+ selection.y2 = newOptions.y2;
+ newOptions.show = true;
+ }
+
+ imgWidth = jQuery(img).width();
+ imgHeight = jQuery(img).height();
+ imgOfs = jQuery(img).offset();
+
+ $p = jQuery(img);
+
+ while ($p.length && !$p.is('body')) {
+ if (!isNaN($p.css('z-index')) && $p.css('z-index') > zIndex)
+ zIndex = $p.css('z-index');
+ if ($p.css('position') == 'fixed') fixed = true;
+
+ $p = $p.parent();
+ }
+
+ x1 = selection.x1 + imgOfs.left;
+ y1 = selection.y1 + imgOfs.top;
+ x2 = selection.x2 + imgOfs.left;
+ y2 = selection.y2 + imgOfs.top;
+ selection.width = x2 - x1;
+ selection.height = y2 - y1;
+
+ update();
+
+ if (newOptions.hide)
+ $a.add($o).hide();
+ else if (newOptions.show)
+ $a.add($o).show();
+
+ $a.css({ borderWidth: options.borderWidth + 'px' });
+ $area.css({ backgroundColor: options.selectionColor, opacity: options.selectionOpacity });
+ $border1.css({ borderStyle: 'solid', borderColor: options.borderColor1 });
+ $border2.css({ borderStyle: 'dashed', borderColor: options.borderColor2 });
+ $o.css({ opacity: options.outerOpacity, backgroundColor: options.outerColor });
+
+ aspectRatio = options.aspectRatio && (d = options.aspectRatio.split(/:/)) ?
+ d[0] / d[1] : null;
+
+ if (options.disable || options.enable === false) {
+ $a.unbind('mousemove', areaMouseMove).unbind('mousedown', areaMouseDown);
+ jQuery(img).add($o).unbind('mousedown', imgMouseDown);
+ }
+ else if (options.enable || options.disable === false) {
+ if (options.resizable || options.movable)
+ $a.mousemove(areaMouseMove).mousedown(areaMouseDown);
+
+ jQuery(img).add($o).mousedown(imgMouseDown);
+ }
+
+ options.enable = options.disable = undefined;
+ };
+
+ if (jQuery.browser.msie)
+ jQuery(img).attr('unselectable', 'on');
+
+ $a.add($o).css({ display: 'none', position: fixed ? 'fixed' : 'absolute', overflow: 'hidden',
+ zIndex: zIndex > 0 ? zIndex : null });
+ $area.css({ borderStyle: 'solid' });
+
+ jQuery('body').append($o.add($a));
+
+ initOptions = {
+ borderColor1: '#000',
+ borderColor2: '#fff',
+ borderWidth: 1,
+ movable: true,
+ resizable: true,
+ selectionColor: '#fff',
+ selectionOpacity: 0.2,
+ outerColor: '#000',
+ outerOpacity: 0.2,
+ onSelectStart: function () {},
+ onSelectChange: function () {},
+ onSelectEnd: function () {}
+ };
+
+ options = jQuery.extend(initOptions, options);
+ this.setOptions(options);
+};
+
+jQuery.fn.imgAreaSelect = function (options) {
+ options = options || {};
+
+ this.each(function () {
+ if (jQuery(this).data('imgAreaSelect'))
+ jQuery(this).data('imgAreaSelect').setOptions(options);
+ else {
+ if (options.enable === undefined && options.disable === undefined)
+ options.enable = true;
+
+ jQuery(this).data('imgAreaSelect', new jQuery.imgAreaSelect(this, options));
+ }
+ });
+
+ return this;
+};
diff --git a/mod/profile/views/default/js/jquery.imgareaselect-0.4.2.min.js b/mod/profile/views/default/js/jquery.imgareaselect-0.4.2.min.js
new file mode 100644
index 000000000..0c07deebd
--- /dev/null
+++ b/mod/profile/views/default/js/jquery.imgareaselect-0.4.2.min.js
@@ -0,0 +1 @@
+jQuery.imgAreaSelect=function(img,options){var $area=jQuery('<div></div>'),$border1=jQuery('<div></div>'),$border2=jQuery('<div></div>'),$outLeft=jQuery('<div></div>'),$outTop=jQuery('<div></div>'),$outRight=jQuery('<div></div>'),$outBottom=jQuery('<div></div>'),imgOfs,imgWidth,imgHeight,zIndex=0,fixed=false,$p,startX,startY,moveX,moveY,resizeMargin=10,resize=[],V=0,H=1,d,aspectRatio,x1,x2,y1,y2,x,y,selection={x1:0,y1:0,x2:0,y2:0,width:0,height:0};var $a=$area.add($border1).add($border2);var $o=$outLeft.add($outTop).add($outRight).add($outBottom);function update(){$a.css({left:(selection.x1+imgOfs.left)+'px',top:(selection.y1+imgOfs.top)+'px',width:Math.max(selection.width-options.borderWidth*2,0)+'px',height:Math.max(selection.height-options.borderWidth*2,0)+'px'});$outLeft.css({left:imgOfs.left+'px',top:imgOfs.top+'px',width:selection.x1+'px',height:imgHeight+'px'});$outTop.css({left:imgOfs.left+selection.x1+'px',top:imgOfs.top+'px',width:selection.width+'px',height:selection.y1+'px'});$outRight.css({left:imgOfs.left+selection.x2+'px',top:imgOfs.top+'px',width:imgWidth-selection.x2+'px',height:imgHeight+'px'});$outBottom.css({left:imgOfs.left+selection.x1+'px',top:imgOfs.top+selection.y2+'px',width:selection.width+'px',height:imgHeight-selection.y2+'px'})}function areaMouseMove(event){x=event.pageX-selection.x1-imgOfs.left;y=event.pageY-selection.y1-imgOfs.top;resize=[];if(options.resizable){if(y<=resizeMargin)resize[V]='n';else if(y>=selection.height-resizeMargin)resize[V]='s';if(x<=resizeMargin)resize[H]='w';else if(x>=selection.width-resizeMargin)resize[H]='e'}$border2.css('cursor',resize.length?resize.join('')+'-resize':options.movable?'move':'')}function areaMouseDown(event){if(event.which!=1)return false;if(options.resizable&&resize.length>0){jQuery('body').css('cursor',resize.join('')+'-resize');x1=(resize[H]=='w'?selection.x2:selection.x1)+imgOfs.left;y1=(resize[V]=='n'?selection.y2:selection.y1)+imgOfs.top;jQuery(document).mousemove(selectingMouseMove);$border2.unbind('mousemove',areaMouseMove);jQuery(document).one('mouseup',function(){resize=[];jQuery('body').css('cursor','');if(options.autoHide)$a.add($o).hide();options.onSelectEnd(img,selection);jQuery(document).unbind('mousemove',selectingMouseMove);$border2.mousemove(areaMouseMove)})}else if(options.movable){moveX=selection.x1+imgOfs.left;moveY=selection.y1+imgOfs.top;startX=event.pageX;startY=event.pageY;jQuery(document).mousemove(movingMouseMove).one('mouseup',function(){options.onSelectEnd(img,selection);jQuery(document).unbind('mousemove',movingMouseMove)})}else jQuery(img).mousedown(event);return false}function aspectRatioXY(){x2=Math.max(imgOfs.left,Math.min(imgOfs.left+imgWidth,x1+Math.abs(y2-y1)*aspectRatio*(x2>x1?1:-1)));y2=Math.round(Math.max(imgOfs.top,Math.min(imgOfs.top+imgHeight,y1+Math.abs(x2-x1)/aspectRatio*(y2>y1?1:-1))));x2=Math.round(x2)}function aspectRatioYX(){y2=Math.max(imgOfs.top,Math.min(imgOfs.top+imgHeight,y1+Math.abs(x2-x1)/aspectRatio*(y2>y1?1:-1)));x2=Math.round(Math.max(imgOfs.left,Math.min(imgOfs.left+imgWidth,x1+Math.abs(y2-y1)*aspectRatio*(x2>x1?1:-1))));y2=Math.round(y2)}function selectingMouseMove(event){x2=!resize.length||resize[H]||aspectRatio?event.pageX:selection.x2+imgOfs.left;y2=!resize.length||resize[V]||aspectRatio?event.pageY:selection.y2+imgOfs.top;if(options.minWidth&&Math.abs(x2-x1)<options.minWidth){x2=x1-options.minWidth*(x2<x1?1:-1);if(x2<imgOfs.left)x1=imgOfs.left+options.minWidth;else if(x2>imgOfs.left+imgWidth)x1=imgOfs.left+imgWidth-options.minWidth}if(options.minHeight&&Math.abs(y2-y1)<options.minHeight){y2=y1-options.minHeight*(y2<y1?1:-1);if(y2<imgOfs.top)y1=imgOfs.top+options.minHeight;else if(y2>imgOfs.top+imgHeight)y1=imgOfs.top+imgHeight-options.minHeight}x2=Math.max(imgOfs.left,Math.min(x2,imgOfs.left+imgWidth));y2=Math.max(imgOfs.top,Math.min(y2,imgOfs.top+imgHeight));if(aspectRatio)if(Math.abs(x2-x1)/aspectRatio>Math.abs(y2-y1))aspectRatioYX();else aspectRatioXY();if(options.maxWidth&&Math.abs(x2-x1)>options.maxWidth){x2=x1-options.maxWidth*(x2<x1?1:-1);if(aspectRatio)aspectRatioYX()}if(options.maxHeight&&Math.abs(y2-y1)>options.maxHeight){y2=y1-options.maxHeight*(y2<y1?1:-1);if(aspectRatio)aspectRatioXY()}selection.x1=Math.min(x1,x2)-imgOfs.left;selection.x2=Math.max(x1,x2)-imgOfs.left;selection.y1=Math.min(y1,y2)-imgOfs.top;selection.y2=Math.max(y1,y2)-imgOfs.top;selection.width=Math.abs(x2-x1);selection.height=Math.abs(y2-y1);update();options.onSelectChange(img,selection);return false}function movingMouseMove(event){x1=Math.max(imgOfs.left,Math.min(moveX+event.pageX-startX,imgOfs.left+imgWidth-selection.width));y1=Math.max(imgOfs.top,Math.min(moveY+event.pageY-startY,imgOfs.top+imgHeight-selection.height));x2=x1+selection.width;y2=y1+selection.height;selection.x1=x1-imgOfs.left;selection.y1=y1-imgOfs.top;selection.x2=x2-imgOfs.left;selection.y2=y2-imgOfs.top;update();options.onSelectChange(img,selection);event.preventDefault();return false}function imgMouseDown(event){if(event.which!=1)return false;startX=x1=event.pageX;startY=y1=event.pageY;selection.x1=selection.x2=x1-imgOfs.left;selection.y1=selection.y2=y1-imgOfs.top;selection.width=0;selection.height=0;resize=[];update();$a.add($o).show();jQuery(document).mousemove(selectingMouseMove);$border2.unbind('mousemove',areaMouseMove);options.onSelectStart(img,selection);jQuery(document).one('mouseup',function(){if(options.autoHide)$a.add($o).hide();options.onSelectEnd(img,selection);jQuery(document).unbind('mousemove',selectingMouseMove);$border2.mousemove(areaMouseMove)});return false}this.setOptions=function(newOptions){options=jQuery.extend(options,newOptions);if(newOptions.x1!=null){selection.x1=newOptions.x1;selection.y1=newOptions.y1;selection.x2=newOptions.x2;selection.y2=newOptions.y2;newOptions.show=true}imgWidth=jQuery(img).width();imgHeight=jQuery(img).height();imgOfs=jQuery(img).offset();$p=jQuery(img);while($p.length&&!$p.is('body')){if(!isNaN($p.css('z-index'))&&$p.css('z-index')>zIndex)zIndex=$p.css('z-index');if($p.css('position')=='fixed')fixed=true;$p=$p.parent()}x1=selection.x1+imgOfs.left;y1=selection.y1+imgOfs.top;x2=selection.x2+imgOfs.left;y2=selection.y2+imgOfs.top;selection.width=x2-x1;selection.height=y2-y1;update();if(newOptions.hide)$a.add($o).hide();else if(newOptions.show)$a.add($o).show();$a.css({borderWidth:options.borderWidth+'px'});$area.css({backgroundColor:options.selectionColor,opacity:options.selectionOpacity});$border1.css({borderStyle:'solid',borderColor:options.borderColor1});$border2.css({borderStyle:'dashed',borderColor:options.borderColor2});$o.css({opacity:options.outerOpacity,backgroundColor:options.outerColor});aspectRatio=options.aspectRatio&&(d=options.aspectRatio.split(/:/))?d[0]/d[1]:null;if(options.disable||options.enable===false){$a.unbind('mousemove',areaMouseMove).unbind('mousedown',areaMouseDown);jQuery(img).add($o).unbind('mousedown',imgMouseDown)}else if(options.enable||options.disable===false){if(options.resizable||options.movable)$a.mousemove(areaMouseMove).mousedown(areaMouseDown);jQuery(img).add($o).mousedown(imgMouseDown)}options.enable=options.disable=undefined};if(jQuery.browser.msie)jQuery(img).attr('unselectable','on');$a.add($o).css({display:'none',position:fixed?'fixed':'absolute',overflow:'hidden',zIndex:zIndex>0?zIndex:null});$area.css({borderStyle:'solid'});jQuery('body').append($o.add($a));initOptions={borderColor1:'#000',borderColor2:'#fff',borderWidth:1,movable:true,resizable:true,selectionColor:'#fff',selectionOpacity:0.2,outerColor:'#000',outerOpacity:0.2,onSelectStart:function(){},onSelectChange:function(){},onSelectEnd:function(){}};options=jQuery.extend(initOptions,options);this.setOptions(options)};jQuery.fn.imgAreaSelect=function(options){options=options||{};this.each(function(){if(jQuery(this).data('imgAreaSelect'))jQuery(this).data('imgAreaSelect').setOptions(options);else{if(options.enable===undefined&&options.disable===undefined)options.enable=true;jQuery(this).data('imgAreaSelect',new jQuery.imgAreaSelect(this,options))}});return this};
diff --git a/mod/profile/views/default/profile/editicon.php b/mod/profile/views/default/profile/editicon.php
index 423227204..670cf83dc 100644
--- a/mod/profile/views/default/profile/editicon.php
+++ b/mod/profile/views/default/profile/editicon.php
@@ -14,6 +14,8 @@
*/
?>
+<!-- grab the required js for icon cropping -->
+<script type="text/javascript" src="<?php echo $vars['url']; ?>mod/profile/views/default/js/jquery.imgareaselect-0.4.2.js"></script>
<form action="<?php echo $vars['url']; ?>action/profile/iconupload" method="post" enctype="multipart/form-data">
<p>
@@ -29,4 +31,40 @@
<p>
<input type="submit" class="submit_button" value="<?php echo elgg_echo("upload"); ?>" />
</p>
- </form> \ No newline at end of file
+ </form>
+
+<?php
+
+ echo "Your current master photo: <br />";
+ //display the current user photo
+ $user_master_image = $vars['url'] . "pg/icon/" . $_SESSION['user']->username . "/master/" . $_SESSION['user']->icontime . ".jpg";
+
+?>
+
+<script>
+ function preview(img, selection) {
+ var scaleX = 100 / selection.width;
+ var scaleY = 100 / selection.height;
+ $('#user_avatar + div > img').css({
+ width: Math.round(scaleX * 600) + 'px',
+ height: Math.round(scaleY * 500) + 'px',
+ marginLeft: '-' + Math.round(scaleX * selection.x1) + 'px',
+ marginTop: '-' + Math.round(scaleY * selection.y1) + 'px'
+ }); }
+
+ $(document).ready(function () {
+ $('<div><img src="<?php echo $user_master_image; ?>" style="position: relative;" /></div>')
+ .css({ float: 'left', position: 'relative', overflow: 'hidden', width: '100px', height: '100px' })
+ .insertAfter($('#user_avatar'));
+ });
+
+ $(window).load(function () {
+ $('#user_avatar').imgAreaSelect({ aspectRatio: '1:1', onSelectChange: preview });
+ $('#user_avatar').imgAreaSelect({ x1: 100, y1: 100, x2: 200, y2: 200 });
+ });
+</script>
+
+<p>
+<img id="user_avatar" src="<?php echo $user_master_image; ?>" alt="User profile photo"
+ style="float: left; margin-right: 10px;" />
+</p> \ No newline at end of file