Added auto-collapse feature for code bbcode boxes
authorAlexander Ebert <ebert@woltlab.com>
Fri, 30 May 2014 09:38:15 +0000 (11:38 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 30 May 2014 09:38:15 +0000 (11:38 +0200)
com.woltlab.wcf/templates/codeBBCodeTag.tpl
wcfsetup/install/files/lib/system/bbcode/CodeBBCode.class.php
wcfsetup/install/files/style/bbcode.less
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index d2f6f258db2f7199e93ff9330c144b6398d9f8ea..587fed48ee0d428d147887d295c308566af7f87b 100644 (file)
@@ -1,4 +1,4 @@
-<div class="container codeBox {$highlighter|get_class|substr:30|lcfirst}">
+<div class="container codeBox {$highlighter|get_class|substr:30|lcfirst}{if $lines > 10} minimized{/if}">
        <div>
                <div>
                        <h3>{@$highlighter->getTitle()}{if $filename}: {@$filename}{/if}</h3>
                        {/foreach}
                </ol>
        </div>
+       
+       {if $lines > 10}
+               <span class="codeBoxExpand jsButtonCodeBoxExpand">{lang}wcf.bbcode.button.showAll{/lang}</span>
+               <script data-relocate="true">
+                       $(function() {
+                               $('.jsButtonCodeBoxExpand').removeClass('jsButtonCodeBoxExpand').click(function() {
+                                       $(this).parent().removeClass('minimized').end().remove();
+                               });
+                       });
+               </script>
+       {/if}
 </div>
index 708886d5bb1c45a7c14e59e23dcdd226241cec8b..d76f00683b608652c8b7b8af32fcdde8cdcb9459 100644 (file)
@@ -130,7 +130,8 @@ class CodeBBCode extends AbstractBBCode {
                                'startLineNumber' => $this->startLineNumber,
                                'content' => $highlightedContent,
                                'highlighter' => $className::getInstance(),
-                               'filename' => $this->filename
+                               'filename' => $this->filename,
+                               'lines' => substr_count($content, "\n") + 1
                        ));
                        return WCF::getTPL()->fetch('codeBBCodeTag');
                }
index e42fda215363f8a3969e6d36dae36bd7ad82dcb1..6986d4c45f80f60b492d782555b49e1fae9cd4b5 100644 (file)
                        }
                }
        }
+       
+       &.minimized {
+               max-height: 200px;
+               overflow: hidden;
+               position: relative;
+               
+               > .codeBoxExpand {
+                       background-color: @wcfContainerBackgroundColor;
+                       border-top: 1px solid @wcfContainerBorderColor;
+                       bottom: 0;
+                       cursor: pointer;
+                       display: block;
+                       height: 20px;
+                       left: 0;
+                       padding: 4px;
+                       position: absolute;
+                       right: 0;
+                       text-align: center;
+                       
+                       .boxShadow(0, -10px, @wcfContainerBackgroundColor, 25px, 5px);
+               }
+       }
 }
 
 // rtl fix
index 4687660c6a0c277795cfd6582bf1b25c9e1abbb7..f98bcd1fed71836af9e8ed72e1a02522fd37dd0a 100644 (file)
@@ -1538,6 +1538,7 @@ Erlaubte Dateiendungen: {', '|implode:$attachmentHandler->getFormattedAllowedExt
                <item name="wcf.bbcode.button.code"><![CDATA[Code]]></item>
                <item name="wcf.bbcode.button.inlineCode"><![CDATA[Inline-Code]]></item>
                <item name="wcf.bbcode.button.quote"><![CDATA[Zitat]]></item>
+               <item name="wcf.bbcode.button.showAll"><![CDATA[Alles anzeigen]]></item>
                <item name="wcf.bbcode.button.spoiler"><![CDATA[Spoiler]]></item>
                <item name="wcf.bbcode.code.text"><![CDATA[{@$highlighterTitle} ({#$lines} Zeile{if $lines != 1}n{/if})]]></item>
                <item name="wcf.bbcode.code.bash.title"><![CDATA[Shell-Script]]></item>
index 91e5adf1f74f6f2bec94a836396e7f5b806eb381..b0a213331d47529aed0651c990c51870eaf34086 100644 (file)
@@ -1481,6 +1481,7 @@ Allowed extensions: {', '|implode:$attachmentHandler->getFormattedAllowedExtensi
                <item name="wcf.bbcode.button.code"><![CDATA[Code]]></item>
                <item name="wcf.bbcode.button.inlineCode"><![CDATA[Inline-Code]]></item>
                <item name="wcf.bbcode.button.quote"><![CDATA[Quote]]></item>
+               <item name="wcf.bbcode.button.showAll"><![CDATA[Show All]]></item>
                <item name="wcf.bbcode.button.spoiler"><![CDATA[Spoiler]]></item>
                <item name="wcf.bbcode.code.text"><![CDATA[{@$highlighterTitle} ({#$lines} line{if $lines != 1}s{/if})]]></item>
                <item name="wcf.bbcode.code.bash.title"><![CDATA[Shell-Script]]></item>