]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
displaying the tag on the photo but not a label for the tag
authorcash <cash.costello@gmail.com>
Mon, 2 Jan 2012 19:34:58 +0000 (14:34 -0500)
committercash <cash.costello@gmail.com>
Mon, 2 Jan 2012 19:34:58 +0000 (14:34 -0500)
classes/TidypicsImage.php
views/default/js/photos/tagging.php
views/default/object/image/full.php
views/default/photos/css.php
views/default/photos/tagging/tag.php [new file with mode: 0644]
views/default/photos/tagging/tags.php [new file with mode: 0644]

index 49585fd0c867be844859a066959537422788caca..7eca2f7c3622b14a39e51d6fb12729220d6010b5 100644 (file)
@@ -341,15 +341,16 @@ class TidypicsImage extends ElggFile {
         * @return array of json representations of the tags and the tag link text
         */
        public function getPhotoTags() {
-               global $CONFIG;
 
-               // get tags as annotations
-               $photo_tags = get_annotations($this->getGUID(), 'object', 'image', 'phototag');
-               if (!$photo_tags) {
-                       // no tags or user doesn't have permission to tags, so return
-                       return false;
+               $tags = array();
+               $annotations = get_annotations($this->getGUID(), 'object', 'image', 'phototag');
+               foreach ($annotations as $annotation) {
+                       $tags[] = unserialize($annotation->value);
                }
 
+               return $tags;
+
+               /*
                $photo_tags_json = "[";
                foreach ($photo_tags as $p) {
                        $photo_tag = unserialize($p->value);
@@ -385,6 +386,7 @@ class TidypicsImage extends ElggFile {
 
                $ret_data = array('json' => $photo_tags_json, 'links' => $photo_tag_links);
                return $ret_data;
+               */
        }
 
        /**
index f831200e721df3c2d170374667a38b3d9622921b..b00200e740ef3b15167009cd73104626120b7608 100644 (file)
 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);
index 33ba497393f3155d02f1145a44626e295eb31e06..e12e968068cf7314d77925d4903a2baae14df3d9 100644 (file)
@@ -54,6 +54,7 @@ echo elgg_view('object/image/navigation', $vars);
 echo elgg_view('photos/tagging/help', $vars);
 echo elgg_view('photos/tagging/select', $vars);
 echo $img;
+echo elgg_view('photos/tagging/tags', $vars);
 echo '</div>';
 
 if ($photo->description) {
index 31e3d9b537c027d5383551658ea3e80cecb1415c..23926adbc8e8779b0f27e7fa85676b762970521c 100644 (file)
        max-width: 300px;
 }
 
+.tidypics-tag {
+       display: none;
+       position: absolute;
+       border: 2px solid white;
+}
+
 <?php
 return true;
 ?>
diff --git a/views/default/photos/tagging/tag.php b/views/default/photos/tagging/tag.php
new file mode 100644 (file)
index 0000000..4d3affe
--- /dev/null
@@ -0,0 +1,24 @@
+<?php
+/**
+ * Photo tag view
+ *
+ * @uses $vars['tag'] Tag object
+ */
+
+$coords = json_decode('{' . $vars['tag']->coords . '}');
+
+$attributes = elgg_format_attributes(array(
+       'class' => 'tidypics-tag',
+       'data-x1' => $coords->x1,
+       'data-y1' => $coords->y1,
+       'data-width' => $coords->width,
+       'data-height' => $coords->height,
+));
+
+//var_dump($vars['tag']);
+//$text = "This is a something";
+
+echo <<<HTML
+<div $attributes>
+</div>
+HTML;
diff --git a/views/default/photos/tagging/tags.php b/views/default/photos/tagging/tags.php
new file mode 100644 (file)
index 0000000..7a4aa3a
--- /dev/null
@@ -0,0 +1,11 @@
+<?php
+/**
+ * View the tags for this image
+ *
+ * @uses $vars['entity']
+ */
+
+$tags = $vars['entity']->getPhotoTags();
+foreach ($tags as $tag) {
+       echo elgg_view('photos/tagging/tag', array('tag' => $tag));
+}