Wedge

Public area => The Pub => Off-topic => Topic started by: Arantor on February 7th, 2011, 02:59 AM

Title: Odd little suggestion, not something I'd really encourage for us
Post by: Arantor on February 7th, 2011, 02:59 AM
Antechinus said something interesting - and useful.
Quote
Just had an idea and messed around with it a little bit. Since anyone using a decent browser these days is already used to having the nifty textarea click and drag resize by default (ie: without relying on 2.0's legacy code) it occurred to me that having the same resize ability on code blocks could be handy at times.
All it needs is the CSS3 resize property set to 'vertical'.
Quote
Not quite sure how to handle this at the moment. I'm certainly not planning on committing it to svn, but it's a nice touch in FF4 or Webkit as you can set the default height to whatever and then just drag when necessary. Might make a handy Greasemonkey addition for peeps on FF4 or Webkit. Just a thought.

ETA: Actually jQuery could probably handle this for all browsers, including auto shrink for height with one or two line snippets. < 2.1 feature
I took a few minutes out and stretched my brain, was quite nice.
Quote
Eh, what the hell.

Code: [Select]
// ==UserScript==
// @name           Code Block Resizer
// @namespace      http://www.simplemachines.org/
// @description    Adds the fancy resize element
// @include        http://www.simplemachines.org/community/index.php?topic=*
// ==/UserScript==

var divX = document.evaluate("//code[@class='bbc_code']", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);

if (divX.snapshotLength > 0)
for (i = 0, n = divX.snapshotLength; i < n; i++)
divX.snapshotItem(i).style.resize = 'vertical';

Didn't really want to make it work on lots of forums since the @include could easily hit way too many sites and slow them all down.


EDIT: I don't think jQuery can actually handle this for browsers that don't have the feature or something relating to it. But it IS a one-liner in jQuery if you go down that road:
Code: [Select]
$('code.bbc_code').css('resize', 'vertical');

Anything else is getting overly technical, I suspect, and unreliable when you consider how themers will want to play.
I don't write GM nearly enough.
Title: Re: Odd little suggestion, not something I'd really encourage for us
Post by: Nao on February 7th, 2011, 09:44 AM
Not supported in Opera... :(
Title: Re: Odd little suggestion, not something I'd really encourage for us
Post by: Arantor on February 7th, 2011, 01:13 PM
Sadly not, but it is in Chrome which is how I wrote that script ;)
Title: Re: Odd little suggestion, not something I'd really encourage for us
Post by: Arantor on February 8th, 2011, 10:42 AM
The snippet was for code, not for general divs, which has a max-height, and often you get very large code blocks posted. So if you resize the code block it's possible to see more of it.