top | item 5114055

Show HN: Behave.js – Coding Behaviors for textarea elements

180 points| jakiestfu | 13 years ago |jakiestfu.github.com | reply

72 comments

order
[+] danso|13 years ago|reply
Ok I'll be the pendant that says it...you probably can't appropriate the image of Austin Powers for your open source library. Not that Mike Myers seems the type to flip out about it, but his movie studio probably is.

Otherwise, great work...and it behaves reasonably well even on iOS

[+] tripzilch|13 years ago|reply
Someone had to point it out, yes. I had the same thought and it made me sad. That page is beautiful, quirky and funny, made with DIY love. It's a perfect example of the value of remix culture, adding a touch of originality (yes, originality) to brighten up an otherwise boring github page.

I believe the author picked the cross hatched texture background to match the rest, as well as the font and the muted retro green and orange-red, so it's not like it was a mere copy/paste job, either. More like (apart from the name pun) Austin Powers is just another ingredient, like the colour to paint with, the texture, the font, etc.

Further--this is a personal belief so take it cum grano salis--if one releases a blockbuster film, one of the (intended!) effects is having its iconography engrained in the public's mind and culture. Saying you cannot use imagery that has been force-fed into the public consciousness at all, is like getting hit by a fire hose and being told you're not allowed to drink or wash with the water. And I had this thought, having to fear being punished for using a certain icon to communicate your ideas, is a lot (but not exactly, I do hope you can see the similarities though) like what the Danish cartoonist had to fear when drawing Muhammed. (let me repeat: there's a lot of differences between the situations, but also an eerie similarity)

Anyway, it's a really great library, I'm looking forward to having an excuse to use it.

[+] gojomo|13 years ago|reply
I'd guess a non-profit project with such small, incidental, reverent-without-being-misleading image reuse can wait until they receive a souvenir cease-and-desist letter, if ever, before worrying about the rights issues.
[+] the1|13 years ago|reply
how do you know if that's Mike Myers in Austin Powers? It's the author in Halloween costume.
[+] Permit|13 years ago|reply
I like this a lot. I really wish they'd add the tab functionality to Stack Overflow. I can't count the times I've tabbed out of the text box there.
[+] evincarofautumn|13 years ago|reply
You should have the option to make backspace delete a full level of indentation, if soft tabs are on.
[+] jakiestfu|13 years ago|reply
Yes, I will implement that tomorrow, thank you
[+] MasterScrat|13 years ago|reply
Keeping the indentation level on new lines would be nice too.
[+] nbashaw|13 years ago|reply
This is awesome. I'm using http://ace.ajax.org/ right now in production and it's a huge heavyweight pain (but still the best thing out there). If only this had syntax highlighting i'd switch in an instant.
[+] evoxed|13 years ago|reply
Hey, this looks handy! I just wrote something kinda similar as part of an ad-hoc UI layer that just had to be done in HTML/JS. At first I was horrified, but by a couple hundred lines in I realized how nice it would feel to finally tame those meager input boxes into full on forces of good. ;)
[+] jamiebicknell|13 years ago|reply
Good work, like it a lot. I almost feel allowing tabs should be a browser based setting, I'd have it enabled, but I can imagine other people wouldn't never need to use a tab.

I built something similar for keeping indentation/bullets/lists on new lines to assist with Markdown in an ordinary textarea -> http://jamiebicknell.github.com/Markdown-Helper/

ps: long time lurker, first time poster.

[+] jakiestfu|13 years ago|reply
The option to disable tabs behavior is there. When to do that is up to you;]
[+] valgaze|13 years ago|reply
Great tool and I'm enamored with the layout- scrolling background, AP stays with you.

Not sure how to repeat it every time but weird artifact quirk if one scrolls to the bottom on iPad safari & scrolls back up: http://i.imgur.com/Hby2ZsL.jpg

[+] WickyNilliams|13 years ago|reply
Question: What does this do for accessibility if navigating with a keyboard? How would one genuinely tab out of the field?

Suggestion: Big notice somewhere saying "NO JQUERY DEPENDENCY". Things are so bad these days I assume jQuery dependency until I see something stating otherwise!

[+] jakiestfu|13 years ago|reply
Since posting and receiving positive feedback, I have added support for unindentation, and multi-line indent/unindent. Will see about adding more features tomorrow! Want to keep this light, it's almost there though. Next is IE support.
[+] Ygg2|13 years ago|reply
Auto expanding for ', [, { (, " is great, but this should be configurable on a language basis. In other languages it's not uncommon to have things like `http://uri.com` or |Special syntax|
[+] bink-lynch|13 years ago|reply
This is great! I removed Ace because it was too heavy for my purpose.

Indent Issue:

Type in at least 3 lines, highlight the middle lines using shift+down-arrow, tab(indent), notice the line below the highlighted lines indents too.

[+] jakiestfu|13 years ago|reply
I see what you're talking about. Coda and Aptana both do the same thing, and the reason is you're selecting the \n new line character when you do shit+down-arrow. Try shift + down-arrow + left-arrow
[+] hilti|13 years ago|reply
Great landing page. Just add syntax highlighting and it'll be perfect.
[+] user24|13 years ago|reply
It absolutely crashed Firefox 18.0.1 under Mac. I typed

hgjj]{return}{return}{return}{return}

and it just beachballed. I had to force quit the browser. Happened the second time I tried it too.

[+] chewmieser|13 years ago|reply
Chromium 24.0.1302.0 (162733) on OS X 10.8.2: Same issue as above, although I just had to close out the tab instead of forcing the browser to close.

The issue is with the ']', and ONLY after I hit the return key. The entire page becomes unresponsive afterwards.

[+] jakiestfu|13 years ago|reply
Thank you for catching this, there are multiple instances where the same bug causes an infinite loop, muahaha. Will fix soon
[+] tantalor|13 years ago|reply
> var editor = new Behave({

> var editor = Behave({

Is it a constructor or not?

[+] tantalor|13 years ago|reply
On further inspection, it must be a constructor.

The second case is incorrect. The function assigns to "this", which would be undefined in strict mode, or the global object. Very bad either way.

Remember kids: objects are your friend.

[+] jakiestfu|13 years ago|reply
Thank you good sir. It is a constructor, I've fixed the sites
[+] state|13 years ago|reply
I wish it could be var editor = now Behave({
[+] tantalor|13 years ago|reply
Auto indent should indent when a newline is nested in parentheses, like this:

  foo(1,
      2,
      3)
[+] jakiestfu|13 years ago|reply
Right now, it is easy to add support for indentation breaks, but it would function like braces or brackets. I'll look into this for parenthesis tomorrow, thanks!