aboutsummaryrefslogtreecommitdiff
path: root/views/default
diff options
context:
space:
mode:
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-12-18 20:15:24 +0000
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-12-18 20:15:24 +0000
commit9ac841f26e05af3515643e44eb5fde30bcfb1b75 (patch)
tree65db9ad52cd03922e2451f85b8e8e56c2b4770fe /views/default
parent569f19d8ff89539eb8d38b1ca1b07a2baa41852c (diff)
downloadelgg-9ac841f26e05af3515643e44eb5fde30bcfb1b75.tar.gz
elgg-9ac841f26e05af3515643e44eb5fde30bcfb1b75.tar.bz2
moved the avatar forms and actions into core from profile plugin
git-svn-id: http://code.elgg.org/elgg/trunk@7670 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'views/default')
-rw-r--r--views/default/forms/avatar/crop.php71
-rw-r--r--views/default/forms/avatar/upload.php15
2 files changed, 86 insertions, 0 deletions
diff --git a/views/default/forms/avatar/crop.php b/views/default/forms/avatar/crop.php
new file mode 100644
index 000000000..1082ab803
--- /dev/null
+++ b/views/default/forms/avatar/crop.php
@@ -0,0 +1,71 @@
+<?php
+/**
+ * Avatar crop form
+ *
+ * @uses $vars['entity']
+ */
+
+$master_image = $vars['entity']->getIcon('master');
+
+?>
+<p>
+ <?php echo elgg_echo("avatar:create:instructions"); ?>
+</p>
+<p>
+ <img id="user_avatar" src="<?php echo $master_image; ?>" alt="<?php echo elgg_echo('avatar'); ?>" />
+</p>
+
+<div class="clearfloat"></div>
+<?php
+$coords = array('x1', 'x2', 'y1', 'y2');
+foreach ($coords as $coord) {
+ echo elgg_view('input/hidden', array('internalname' => $coord, 'value' => $vars['entity']->$coord));
+}
+
+echo elgg_view('input/hidden', array('internalname' => 'guid', 'value' => $vars['entity']->guid));
+
+echo elgg_view('input/submit', array('value' => elgg_echo('avatar:create')));
+
+?>
+<!-- grab the required js for icon cropping -->
+<script type="text/javascript" src="<?php echo elgg_get_site_url(); ?>mod/profile/views/default/js/jquery.imgareaselect-0.8.min.js"></script>
+
+<script type="text/javascript">
+
+ // display a preview of the users cropped section
+ function preview(img, selection) {
+ // catch for the first click on the image
+ if (selection.width == 0 || selection.height == 0) {
+ return;
+ }
+
+ var origWidth = $("#user_avatar").width(); //get the width of the users master photo
+ var origHeight = $("#user_avatar").height(); //get the height of the users master photo
+ 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'
+ });
+ }
+
+ function selectChange(img, selection) {
+ // populate the form with the correct coordinates once a user has cropped their image
+ $('input[name=x1]').val(selection.x1);
+ $('input[name=x2]').val(selection.x2);
+ $('input[name=y1]').val(selection.y1);
+ $('input[name=y2]').val(selection.y2);
+ }
+
+ $(document).ready(function() {
+ $('<div id="user_avatar_preview"><img src="<?php echo $master_image; ?>" /></div>').insertAfter($('#user_avatar'));
+ $('<div id="user_avatar_preview_title"><label><?php echo elgg_echo('avatar:preview'); ?></label></div>').insertBefore($('#user_avatar_preview'));
+
+ // this produces the coordinates
+ $('#user_avatar').imgAreaSelect({ selectionOpacity: 0, onSelectEnd: selectChange });
+ // show the preview
+ $('#user_avatar').imgAreaSelect({ aspectRatio: '1:1', onSelectChange: preview });
+ });
+</script>
diff --git a/views/default/forms/avatar/upload.php b/views/default/forms/avatar/upload.php
new file mode 100644
index 000000000..733e2996c
--- /dev/null
+++ b/views/default/forms/avatar/upload.php
@@ -0,0 +1,15 @@
+<?php
+/**
+ * Avatar upload form
+ *
+ * @uses $vars['entity']
+ */
+
+echo elgg_view('input/hidden', array('internalname' => 'guid', 'value' => $vars['entity']->guid));
+?>
+<p>
+ <label><?php echo elgg_echo("profile:editicon"); ?></label><br />
+ <?php echo elgg_view("input/file",array('internalname' => 'avatar')); ?>
+<br />
+ <?php echo elgg_view('input/submit', array('value' => elgg_echo('upload'))); ?>
+</p>