]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Display thumbnail on hover over links in notices when appropriate.
authorRobin Millette <millette@controlyourself.ca>
Mon, 25 May 2009 15:13:13 +0000 (11:13 -0400)
committerRobin Millette <millette@controlyourself.ca>
Mon, 25 May 2009 15:13:13 +0000 (11:13 -0400)
js/util.js
lib/attachmentlist.php
lib/router.php
lib/util.php
theme/base/css/display.css

index b6848abaa271b69bbd89df6b4578d9db72e25907..9ee2a19635da2d7b5b968221a7d8106f83aba479 100644 (file)
@@ -25,6 +25,19 @@ $(document).ready(function(){
     //need to link to proper url depending on site config (path name and theme, for instance)
     $('a.attachment').click(function() {$().jOverlay({url:'/attachment/' + ($(this).attr('id').substring('attachment'.length + 1)) + '/ajax'}); return false; });
     $('.entry-title a.attachment').append('&nbsp;<img style="display: inline; vertical-align: middle" src="/theme/base/images/icons/clip-inline.png" alt="Attachment" />');
+    $('a.thumbnail').hover(function() {
+    anchor = $(this);
+    $.get('/attachment/' + ($(this).attr('id').substring('attachment'.length + 1)) + '/thumbnail', null, function(data) {
+        anchor.append(data);
+        $('#thumbnail').fadeIn('def');
+    });
+    },
+    function() {
+        setTimeout(function() {
+            $('#thumbnail').fadeOut('slow', function() {$(this).remove();});
+        }, 500);
+    }
+    );
 
        // count character on keyup
        function counter(event){
index 1be7b2fee94962190c2ac6054d323c2e4830a82a..52aa5d9ee58ab61fea2e21de5ac6a3e0fca34512 100644 (file)
@@ -171,7 +171,7 @@ class AttachmentListItem extends Widget
     }
 
     function linkTitle() {
-        return 'Our page for ' . $this->title();
+        return $this->title();
     }
 
     /**
@@ -256,7 +256,7 @@ class Attachment extends AttachmentListItem
     }
 
     function linkTitle() {
-        return 'Direct link to ' . $this->title();
+        return $this->attachment->url;
     }
 
     function showRepresentation() {
index 39c005609ed6919399a412071b748b6138eacf9f..d1e2970c5f421b059c4639c1952952a11068366a 100644 (file)
@@ -159,6 +159,10 @@ class Router
                     array('action' => 'attachment_ajax'),
                     array('attachment' => '[0-9]+'));
 
+        $m->connect('attachment/:attachment/thumbnail',
+                    array('action' => 'attachment_thumbnail'),
+                    array('attachment' => '[0-9]+'));
+
 /*
         TODO
         not used right now, will revisit later
index 4a55cbfe5921000ea573a4ffb3ab34e1b0799542..d56f44f7b45c39a948f8cd4ed488eb081ff783a1 100644 (file)
@@ -503,8 +503,18 @@ function common_linkify($url) {
     $file = new File;
     $file->query($query);
     $file->fetch();
+
     if (!empty($file->file_id)) {
-        $attrs['class'] = 'attachment';
+        $query = "select file_thumbnail.file_id as file_id from file join file_thumbnail on file.id = file_thumbnail.file_id where file.url='$longurl'";
+        $file2 = new File;
+        $file2->query($query);
+        $file2->fetch();
+
+        if (empty($file2->file_id)) {
+            $attrs['class'] = 'attachment';
+        } else {
+            $attrs['class'] = 'attachment thumbnail';
+        }
         $attrs['id'] = "attachment-{$file->file_id}";
     }
     return XMLStringer::estring('a', $attrs, $display);
index 8f72460a807655541277b4ff90fd8d04ade92302..71a434c542fe11f4784ef6a012e6043057f3a98e 100644 (file)
@@ -1205,3 +1205,11 @@ display:none;
 .guide {
 clear:both;
 }
+
+#thumbnail {
+position:absolute;
+z-index: 999;
+display: none;
+left: 100px;
+}
+