Add messageFloatObject(Left|Right) CSS classes
authorMatthias Schmidt <gravatronics@live.com>
Fri, 13 Feb 2015 19:58:53 +0000 (20:58 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Fri, 13 Feb 2015 19:58:53 +0000 (20:58 +0100)
wcfsetup/install/files/lib/system/bbcode/AttachmentBBCode.class.php
wcfsetup/install/files/style/message.less

index 191f14fc3c2b4dcc0674118bc4f055db241e0055..2323cc28405639ce59a90b385541045dc614984e 100644 (file)
@@ -75,18 +75,15 @@ class AttachmentBBCode extends AbstractBBCode {
                                
                                $result = '';
                                if ($width > 0) {
-                                       $style = '';
-                                       if ($alignment == 'left') {
-                                               $style .= 'float: left; margin: 0 15px 7px 0';
-                                       }
-                                       else if ($alignment == 'right') {
-                                               $style .= 'float: right; margin: 0 0 7px 15px';
+                                       $class = '';
+                                       if ($alignment == 'left' || $alignment == 'right') {
+                                               $class = 'messageFloatObject'.ucfirst($alignment);
                                        }
                                        
                                        $source = StringUtil::encodeHTML(LinkHandler::getInstance()->getLink('Attachment', array('object' => $attachment)));
                                        $title = StringUtil::encodeHTML($attachment->filename);
                                        
-                                       $result = '<a href="' . $source . '" title="' . $title . '" class="embeddedAttachmentLink jsImageViewer"' . ($style ? ' style="' . $style . '"' : '') . '><img src="' . $source . '" style="width: '.$width.'px" alt="" /></a>';
+                                       $result = '<a href="' . $source . '" title="' . $title . '" class="embeddedAttachmentLink jsImageViewer' . ($class ? ' '.$class : '') . '"><img src="' . $source . '" style="width: '.$width.'px" alt="" /></a>';
                                }
                                else {
                                        $linkParameters = array(
@@ -94,17 +91,23 @@ class AttachmentBBCode extends AbstractBBCode {
                                        );
                                        if ($attachment->hasThumbnail()) $linkParameters['thumbnail'] = 1;
                                        
-                                       $style = '';
-                                       if ($alignment == 'left') {
-                                               $style .= 'float: left; margin: 0 15px 7px 0';
+                                       $class = '';
+                                       if ($alignment == 'left' || $alignment == 'right') {
+                                               $class = 'messageFloatObject'.ucfirst($alignment);
+                                       }
+                                       
+                                       $imageClasses = '';
+                                       if (!$attachment->hasThumbnail()) {
+                                               $imageClasses = 'embeddedAttachmentLink jsResizeImage';
                                        }
-                                       else if ($alignment == 'right') {
-                                               $style .= 'float: right; margin: 0 0 7px 15px';
+                                       
+                                       if ($class && (!$attachment->hasThumbnail() || !$attachment->canDownload())) {
+                                               $imageClasses .= ' '.$class;
                                        }
                                        
-                                       $result = '<img src="'.StringUtil::encodeHTML(LinkHandler::getInstance()->getLink('Attachment', $linkParameters)).'"'.(!$attachment->hasThumbnail() ? ' class="embeddedAttachmentLink jsResizeImage"' : '').' style="width: '.($attachment->hasThumbnail() ? $attachment->thumbnailWidth : $attachment->width).'px; height: '.($attachment->hasThumbnail() ? $attachment->thumbnailHeight: $attachment->height).'px;' . ((!$attachment->hasThumbnail() || !$attachment->canDownload()) ? $style : '').'" alt="" />';
+                                       $result = '<img src="'.StringUtil::encodeHTML(LinkHandler::getInstance()->getLink('Attachment', $linkParameters)).'"'.($imageClasses ? ' class="'.$imageClasses.'"' : '').' style="width: '.($attachment->hasThumbnail() ? $attachment->thumbnailWidth : $attachment->width).'px; height: '.($attachment->hasThumbnail() ? $attachment->thumbnailHeight : $attachment->height).'px;" alt="" />';
                                        if ($attachment->hasThumbnail() && $attachment->canDownload()) {
-                                               $result = '<a href="'.StringUtil::encodeHTML(LinkHandler::getInstance()->getLink('Attachment', array('object' => $attachment))).'" title="'.StringUtil::encodeHTML($attachment->filename).'" class="embeddedAttachmentLink jsImageViewer"' . ($style ? ' style="'.$style.'"' : '') . '>'.$result.'</a>';
+                                               $result = '<a href="'.StringUtil::encodeHTML(LinkHandler::getInstance()->getLink('Attachment', array('object' => $attachment))).'" title="'.StringUtil::encodeHTML($attachment->filename).'" class="embeddedAttachmentLink jsImageViewer' . ($class ? ' '.$class : '') . '">'.$result.'</a>';
                                        }
                                }
                                
index 2c687bf1a7da2ae30e76c57f46f6dc408e1be54b..6c3f33d5058d1496ddf08c138400a8722e258df2 100644 (file)
@@ -1106,4 +1106,14 @@ li:nth-child(2n+1) .message {
                        display: none;
                }
        }
-}
\ No newline at end of file
+}
+
+.messageFloatObjectLeft {
+       float: left;
+       margin: 0 @wcfGapMedium @wcfGapSmall 0;
+}
+
+.messageFloatObjectRight {
+       float: right;
+       margin: 0 0 @wcfGapSmall @wcfGapMedium;
+}