]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - js/util.js
Let's you upload a file with a notice and have it shown with other attachments.
[quix0rs-gnu-social.git] / js / util.js
index 6511c0380da3215f0eff0972f431373896153cf4..85ab48b4c0887638a20cdaa75967b5ff2fe11100 100644 (file)
  */
 
 $(document).ready(function(){
-// attachments and attachment pages not used at the moment except for attachment_ajax version
-//    $('.attachments').click(function() {$().jOverlay({zIndex:999, success:function(html) {$('.attachment').click(function() {$().jOverlay({url:$(this).attr('href') + '/ajax'}); return false; });
-//        }, url:$(this).attr('href') + '/ajax'}); return false; });
-    $('.attachment').click(function() {$().jOverlay({url:'../attachment/' + ($(this).attr('id').substring('attachment'.length + 1)) + '/ajax'}); return false; });
+    $('input#notice_data-attach').toggle();
+    $('label[for=notice_data-attach]').text('Upload a file as an attachment?');
+    $('label[for=notice_data-attach]').click(function () {
+        if ('Upload a file as an attachment?' == $(this).text()) {
+            $(this).text('Upload: ');
+            $('input#notice_data-attach').slideDown('fast');
+        } else {
+            $('input#notice_data-attach').slideUp('fast', function() {$('label[for=notice_data-attach]').text('Upload a file as an attachment?');});
+        }
+    });
+
+    $('a.attachment').click(function() {$().jOverlay({url: $('address .url')[0].href+'/attachment/' + ($(this).attr('id').substring('attachment'.length + 1)) + '/ajax'}); return false; });
+    $("a.thumbnail").hover(
+        function() {
+            var anchor = $(this);
+            $("a.thumbnail").children('img').remove();
+
+            setTimeout(function() {
+                anchor.closest(".entry-title").addClass('ov');
+                $.get($('address .url')[0].href+'/attachment/' + (anchor.attr('id').substring('attachment'.length + 1)) + '/thumbnail', null, function(data) {
+                    anchor.append(data);
+                });
+            }, 250);
+
+            setTimeout(function() {
+                anchor.children('img').remove();
+                anchor.closest(".entry-title").removeClass('ov');
+            }, 3000);
+        },
+        function() {
+            $(this).children('img').remove();
+            $(this).closest(".entry-title").removeClass('ov');
+        }
+    );
 
        // count character on keyup
        function counter(event){
@@ -208,6 +238,7 @@ $(document).ready(function(){
                                                          }
                                                                                                        }
                                                                                                        $("#notice_data-text").val("");
+                                                                                               $("#notice_data-attach").val("");
                                                     counter();
                                                                                                }
                                                                                                $("#form_notice").removeClass("processing");