aboutsummaryrefslogtreecommitdiff
path: root/views/default/js
diff options
context:
space:
mode:
authorcash <cash.costello@gmail.com>2012-01-02 14:34:58 -0500
committercash <cash.costello@gmail.com>2012-01-02 14:34:58 -0500
commitfbdaf2a33386e6746be4de50a0b4aceb06ff5e68 (patch)
tree7dd062f7ab03b565dc768a46b1df089e03fbad9f /views/default/js
parent20ab73de5248b3418bbbad27850e3d3e093c473c (diff)
downloadelgg-fbdaf2a33386e6746be4de50a0b4aceb06ff5e68.tar.gz
elgg-fbdaf2a33386e6746be4de50a0b4aceb06ff5e68.tar.bz2
displaying the tag on the photo but not a label for the tag
Diffstat (limited to 'views/default/js')
-rw-r--r--views/default/js/photos/tagging.php74
1 files changed, 70 insertions, 4 deletions
diff --git a/views/default/js/photos/tagging.php b/views/default/js/photos/tagging.php
index f831200e7..b00200e74 100644
--- a/views/default/js/photos/tagging.php
+++ b/views/default/js/photos/tagging.php
@@ -11,16 +11,27 @@
elgg.provide('elgg.tidypics.tagging');
elgg.tidypics.tagging.init = function() {
+ elgg.tidypics.tagging.active = false;
$('[rel=photo-tagging]').click(elgg.tidypics.tagging.start);
$('#tidypics-tagging-quit').click(elgg.tidypics.tagging.stop);
-}
+
+ $('.tidypics-tag').each(elgg.tidypics.tagging.position);
+
+ elgg.tidypics.tagging.tag_hover = false;
+ elgg.tidypics.tagging.toggleTagHover();
+};
/**
* Start a tagging session
*/
elgg.tidypics.tagging.start = function(event) {
+ if (elgg.tidypics.tagging.active) {
+ elgg.tidypics.tagging.stop(event);
+ return;
+ }
+
$('.tidypics-photo').imgAreaSelect({
disable : false,
hide : false,
@@ -31,12 +42,16 @@ elgg.tidypics.tagging.start = function(event) {
}
});
+ elgg.tidypics.tagging.toggleTagHover();
+
$('.tidypics-photo').css({"cursor" : "crosshair"});
$('#tidypics-tagging-help').toggle();
+ elgg.tidypics.tagging.active = true;
+
event.preventDefault();
-}
+};
/**
* Stop tagging
@@ -50,8 +65,11 @@ elgg.tidypics.tagging.stop = function(event) {
$('.tidypics-photo').imgAreaSelect({hide: true, disable: true});
$('.tidypics-photo').css({"cursor" : "pointer"});
+ elgg.tidypics.tagging.active = false;
+ elgg.tidypics.tagging.toggleTagHover();
+
event.preventDefault();
-}
+};
/**
* Start the selection stage of tagging
@@ -68,6 +86,54 @@ elgg.tidypics.tagging.startSelect = function(img, selection) {
'top' : selection.y2 + 10,
'left' : selection.x2
});
-}
+};
+
+/**
+ * Position the tags over the image
+ */
+elgg.tidypics.tagging.position = function() {
+ var tag_left = parseInt($(this).data('x1'));
+ var tag_top = parseInt($(this).data('y1'));
+ var tag_width = parseInt($(this).data('width'));
+ var tag_height = parseInt($(this).data('height'));
+
+ // add image offset
+ var image_pos = $('.tidypics-photo').position();
+ tag_left += image_pos.left;
+ tag_top += image_pos.top;
+
+ $(this).css({
+ left: tag_left + 'px',
+ top: tag_top + 'px',
+ width: tag_width + 'px',
+ height: tag_height + 'px'
+ });
+};
+
+/**
+ * Toggle whether tags are shown on hover over the image
+ */
+elgg.tidypics.tagging.toggleTagHover = function() {
+ if (elgg.tidypics.tagging.tag_hover == false) {
+ $('.tidypics-photo').hover(
+ function() {
+ $('.tidypics-tag').show();
+ },
+ function() {
+ $('.tidypics-tag').hide();
+ }
+ );
+ } else {
+ $('.tidypics-photo').hover(
+ function() {
+ $('.tidypics-tag').hide();
+ },
+ function() {
+ $('.tidypics-tag').hide();
+ }
+ );
+ }
+ elgg.tidypics.tagging.tag_hover = !elgg.tidypics.tagging.tag_hover;
+};
elgg.register_hook_handler('init', 'system', elgg.tidypics.tagging.init);