tpr 3,235 Posted April 6, 2016 This is a simple addition to the admin to automatically resize textareas according to their content. It doesn't work with CKE fields tough. All it needs is a hook in ready.php + copying autosize.min.js to the "site" folder (or elsewhere if you feel so). /site/ready.php: // autosize textareas in admin $page->addHookAfter('render', function ($event) { if ($this->page->template != 'admin') return; $autoSizeJsUrl = wire('config')->urls->site . 'autosize.min.js'; $js = <<< HTML <script> var autosizeTextareas = document.querySelectorAll('textarea'); if (autosizeTextareas.length) { $.getScript("$autoSizeJsUrl", function () { autosize(autosizeTextareas); }); } $('.langTabs').on('tabsactivate', function(event, ui) { var textareas = ui.newPanel.get(0).querySelectorAll('textarea'); if(textareas.length && window.autosize && window.autosize.update) { autosize.update(textareas); } }); </script> HTML; $event->return = str_replace('</body>', $js . PHP_EOL . '</body>', $event->return); }); Edit: fixed updating textareas on activating language tabs (heights weren't updated) 10 Share this post Link to post Share on other sites
netcarver 2,704 Posted April 6, 2016 Now available as a module on Github. 7 Share this post Link to post Share on other sites
kongondo 7,383 Posted April 6, 2016 Now available as a module on Github. I had a feeling you'd do that Share this post Link to post Share on other sites
tpr 3,235 Posted April 6, 2016 Thanks netcarver. I have an idea to collect such mini-modules into a one admin helper module but as usual I don't know when will I have to do that 1 Share this post Link to post Share on other sites
tpr 3,235 Posted April 6, 2016 Just tried the AutoGrow CKEditor plugin and works fine (PW 3.013, CKEditor with Lightwire theme). You can add options like these to the "Custom Config Options" to the CKEditor PW field settings: autoGrow_onStartup: true autoGrow_bottomSpace: 20 Or to "/site/modules/InputfieldCKEditor/config.js" if you prefer: CKEDITOR.editorConfig = function (config) { config.autoGrow_onStartup = true; config.autoGrow_bottomSpace = 20; }; 5 Share this post Link to post Share on other sites
hellomoto 45 Posted October 9, 2016 Anyone have this working on PW3? Share this post Link to post Share on other sites
tpr 3,235 Posted October 9, 2016 Yes, it was made using PW3. netcarver's module should work fine too, or you can use AdminOnSteroids in which there are some improvements too. 1 Share this post Link to post Share on other sites
hellomoto 45 Posted October 9, 2016 I was afraid you would say that... Any idea offhand as to why it might not? Share this post Link to post Share on other sites
tpr 3,235 Posted October 9, 2016 My best guess is that you try I on a CKEditor field and not on a simple textarea. In this case you need the Auto Grow plugin (see above). If not, do you have any js error in the browser console? Share this post Link to post Share on other sites
hellomoto 45 Posted October 9, 2016 Ah, yes: Quote Uncaught ReferenceError: autosize is not defined How about that Share this post Link to post Share on other sites
tpr 3,235 Posted October 9, 2016 Have you copied autosize.min.js to the "site" folder? Share this post Link to post Share on other sites
tires 29 Posted February 4 Do i have to throw the autosize.min.js manually into the "site" folder? Or into the sites/templates? Or the root of the site? Share this post Link to post Share on other sites
adrian 12,074 Posted February 5 16 hours ago, tires said: Do i have to throw the autosize.min.js manually into the "site" folder? Or into the sites/templates? Or the root of the site? Try @tpr's essential AdminOnSteroids module which packages everything needed for this to work. 2 Share this post Link to post Share on other sites
tires 29 Posted February 5 Thanks! This seems to work pretty well. But its a big module for such a little problem ... 1 Share this post Link to post Share on other sites
adrian 12,074 Posted February 5 3 hours ago, tires said: Thanks! This seems to work pretty well. But its a big module for such a little problem ... Perhaps, but I would play around with it - you'll find many of its other features invaluable 🙂 Share this post Link to post Share on other sites
bernhard 5,143 Posted February 6 19 hours ago, adrian said: Perhaps, but I would play around with it - you'll find many of its other features invaluable 🙂 I thought so as well for quite some time, but I also had several problems related to AOS and wasted too much time for debugging just to find out, that AOS was the reason... That's why I don't use it any more and I was surprised - I don't really miss it 😉 It's nice in many ways, but it's not essential imho and I personally don't want to take the risk of getting too used to a module that does not seem to be maintained any more and potentially brings in too many problems. No AOS bashing here - just trying to support his concern 🙂 22 hours ago, tires said: But its a big module for such a little problem ... I'd much more prefer to get some of AOS features into the core... 1 Share this post Link to post Share on other sites