Added dynamic table overflow
authorAlexander Ebert <ebert@woltlab.com>
Fri, 2 Sep 2016 10:11:21 +0000 (12:11 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 2 Sep 2016 10:11:21 +0000 (12:11 +0200)
wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeTable.class.php [new file with mode: 0644]
wcfsetup/install/files/style/ui/message.scss

diff --git a/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeTable.class.php b/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeTable.class.php
new file mode 100644 (file)
index 0000000..d8f49aa
--- /dev/null
@@ -0,0 +1,43 @@
+<?php
+namespace wcf\system\html\output\node;
+use wcf\system\html\node\AbstractHtmlNodeProcessor;
+
+/**
+ * Adds wrapper div for tables to allow content overflow with scrollbars.
+ * 
+ * @author      Alexander Ebert
+ * @copyright   2001-2016 WoltLab GmbH
+ * @license     GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package     WoltLabSuite\Core\System\Html\Output\Node
+ * @since       3.0
+ */
+class HtmlOutputNodeTable extends AbstractHtmlOutputNode {
+       /**
+        * @inheritDoc
+        */
+       protected $tagName = 'table';
+       
+       /**
+        * @inheritDoc
+        */
+       public function process(array $elements, AbstractHtmlNodeProcessor $htmlNodeProcessor) {
+               if ($this->outputType === 'text/html' || $this->outputType === 'text/simplified-html') {
+                       /** @var \DOMElement $element */
+                       foreach ($elements as $element) {
+                               // check if table is not contained within another table
+                               $parent = $element;
+                               while ($parent = $parent->parentNode) {
+                                       if ($parent->nodeName === 'table') {
+                                               continue;
+                                       }
+                               }
+                               
+                               $div = $element->ownerDocument->createElement('div');
+                               $div->setAttribute('class', 'messageTableOverflow');
+                               
+                               $element->parentNode->insertBefore($div, $element);
+                               $div->appendChild($element);
+                       }
+               }
+       }
+}
index 1b27e715647956a9d265f7613833c72f1c624027..f52b324778f5b8cdbcd68ae9d8768435adb007ce 100644 (file)
                }
        }
 }
+
+@include screen-sm-down {
+       /* allow tables to overflow on small screens */
+       .messageTableOverflow {
+               overflow: auto;
+       }
+}