Sign up | Lost password? | Help

[ advanced search ]


Go to last post

Saturday, 23. September 2006, 03:09:38

xErath

avatar

javascript guru

Posts: 6401

Norway

Opera Software

Textarea resizer

OK, ladies and gentleman: new toy. This one is veeeeeeeeeeeeeeery useful.

resize-textarea-util.js
Just, hover your mouse over a textarea, and press ctrl at the same time. A pop up menu will appear with several options to resize the current textarea. Play a bit and you'll quickly find out what each of the options do.

Note: there are still a few tweaks I must do, like using the current Opera skin as theme for the menu, and providing a more robust CSS, to deal well with as many webpages as possible.

Saturday, 23. September 2006, 09:04:02

tatepa

avatar

Wake Up From Your Slumber

Posts: 357

Neat - what does the "Auto" option do? Does this..., oh, guess I've just figured that one out LOL!

Saturday, 23. September 2006, 17:21:41

d.i.z.

avatar

bug hunter

Posts: 2935

Poland

Really usefull, thanks a lot.

Saturday, 14. October 2006, 19:11:24

Medium

avatar

women

Posts: 3769

Poland

Very good work! :yes: Thanks xErath! :smile:

Tuesday, 2. January 2007, 10:14:05

xErath

avatar

javascript guru

Posts: 6401

Norway

Opera Software

New version:
  • Deals much better with page styles ! (uses custom elements)
  • Uses system colors and fonts
  • Probably some bug squashed.
resize-textarea-util.js Have fun :smile:

Tuesday, 2. January 2007, 18:06:08

d.i.z.

avatar

bug hunter

Posts: 2935

Poland

Works kinda erratic. Won't display menu most of the time on my.opera's quick reply textarea (I'm holding ctrl and moving mouse into textarea).

And really gets in the way when copying/pasting text with ctrl+c/ctrl+v. I'm talking about previous version now, which was actually showing the menu all the time.

Tuesday, 2. January 2007, 18:10:32

d.i.z.

avatar

bug hunter

Posts: 2935

Poland

Oh, I see now, that you have changed shortcut to Shift. I image this might cause annoyance too.

Maybe just invoke the menu when hovering _into_ textarea from some other element. So don't invoke menu when we are inside textarea and we press shift. What do you think? It should be doable from what I know.

Tuesday, 2. January 2007, 22:37:19

xErath

avatar

javascript guru

Posts: 6401

Norway

Opera Software

I changed to shift because it's less likely for one to use shift shortcuts with the mouse interaction too.
I realized of the annoyance of using Ctrl when I selected text and immediately pressed Ctrl+c/v.

Wednesday, 3. January 2007, 08:23:37

GT500

avatar

Security Industry

Posts: 3450

Fighting Malware

That could be useful. I hate to scroll with a long post, so this nifty JS might be just they key to avoiding confusion... :wink:

Thursday, 4. January 2007, 22:05:37

armbar

avatar

Off with your head!

Posts: 102

Addison, Texas, United States

It would be nice if the menu came up on the release of the shift key, so that typing quotes and parenthesis doesn't trigger the event.

Thursday, 4. January 2007, 22:22:25

AyushJ

avatar

Posts: 4754

Originally posted by armbar:

It would be nice if the menu came up on the release of the shift key, so that typing quotes and parenthesis doesn't trigger the event.



The menu comes when you hold shift key then move the mouse OR when you move the mouse and press shift. Anyway, you can change it so that menu comes when you hold Ctrl+Shift :

Change this :
var shortcut = { eventType:'mousemove', shiftKey:true, ctrlKey:false, altKey:false };


to
var shortcut = { eventType:'mousemove', shiftKey:true, ctrlKey:true, altKey:false };


Thursday, 4. January 2007, 22:28:58

armbar

avatar

Off with your head!

Posts: 102

Addison, Texas, United States

Yeah, I know how to change it for me, but I figured xErath would want to change his own script. It happens most for me when I'm pasting a quote as the first thing in a text box.

Either way, just a suggestion.

Tuesday, 8. May 2007, 22:33:11

andn

avatar

Posts: 30

Handy script, but for me, when navigating a page with SHIFT + Arrows, it messes up..

Example: http://en.wikipedia.org/wiki/Opera_browser
Navigate through the table of contents, it selects "1 History", then "History", then "2 Future development", then "Future development"
but it should select "1 History", then "2 Future Development" and so on.
And this happens not only on wikipedia.

Is there a chance that this will be fixed in the future?

Tuesday, 8. May 2007, 22:58:56

xErath

avatar

javascript guru

Posts: 6401

Norway

Opera Software

Originally posted by __A_n_d_y_N__:

Handy script, but for me, when navigating a page with SHIFT + Arrows, it messes up..


For sure it's not the script that's affecting that.

Thursday, 10. May 2007, 12:23:49

andn

avatar

Posts: 30

Originally posted by xErath:

For sure it's not the script that's affecting that.

Still it seems to be this script..
I just deleted my userjs folder, and then the shift + arrows worked just fine, then I put the textarea resizer back in and the same thing that I described in my last post happened again. =/

Thursday, 10. May 2007, 12:50:02

AyushJ

avatar

Posts: 4754

Originally posted by __A_n_d_y_N__:

Still it seems to be this script..



Yup. Confirmed. xErath's script is causing problem with that

Monday, 14. May 2007, 02:22:15

Medium

avatar

women

Posts: 3769

Poland

Originally posted by AyushJ:

Yup. Confirmed. xErath's script is causing problem with that

I confirm, that better to use the key “Ctrl”.
First version of script looks for me better. I have changed values for increase/decrease to 5-10-20 columns/lines. :smile:

Thursday, 13. September 2007, 22:06:06

svivian

avatar

needs more cowbell

Posts: 1269

United Kingdom

Is it possible to make a version of this script that adds a resize icon to the textarea? i.e. so I can just click-and-drag to resize?

Sunday, 16. September 2007, 19:27:37

xErath

avatar

javascript guru

Posts: 6401

Norway

Opera Software

There's another script like this one floating around the forums, which enables the textarea corner to be dragged.
I've picked that one up and editted it to prevent many problems I encountered, like not pickig up dinamically generated textareas, or the script messing with the textarea's css. I had some problems with it.
textarea-drag-resizer.js

Sunday, 16. September 2007, 22:09:57

svivian

avatar

needs more cowbell

Posts: 1269

United Kingdom

Awesome! That fixed up the problem I mentioned in one of the other threads. Cheers, xerath :cheers:

Tuesday, 18. September 2007, 07:28:24

tatepa

avatar

Wake Up From Your Slumber

Posts: 357

Originally posted by xErath:

There's another script like this one floating around the forums, which enables the textarea corner to be dragged.



Excellent! :yes:

Glad I dropped by this thread again. The drag option is much better for me - I used to invoke the resize menu by mistake too many times using the CTRL key.

Thanks!

Thursday, 20. September 2007, 09:34:55

tatepa

avatar

Wake Up From Your Slumber

Posts: 357

Hmmm.... probably best not to use "Drag to Scroll" in Opera 9.50 with this. It still works but it's a bit awkward. In fact Drag to Scroll makes it REALLY awkward to select text too, in case anyone's interested.

Thursday, 20. September 2007, 18:33:02

Maulkin

avatar

French Section Moderator

Posts: 257

France

Wow! this button is a killer!

Friday, 21. September 2007, 03:35:50

GT500

avatar

Security Industry

Posts: 3450

Fighting Malware

An excellent job once again xErath. :wink:

Sunday, 30. September 2007, 23:05:18

xErath

avatar

javascript guru

Posts: 6401

Norway

Opera Software

New version of the drag resizer script, and this one is the initial version with new license and proper crediting :smile:
Drag the lower-right corner to resize, and double click it to restore the original dimensions.
Works with inputs and textareas :headbang:
textarea-drag-resizer.js

Monday, 1. October 2007, 00:30:19

AyushJ

avatar

Posts: 4754

You forgot to exclude input@type=image xErath :wink:

Monday, 1. October 2007, 08:21:56

xErath

avatar

javascript guru

Posts: 6401

Norway

Opera Software

Originally posted by AyushJ:

You forgot to exclude input@type=image xErath


hum.. It might be good to keep those. What do you think ?
And, Homer: Doh! I forgot to include images p:

Monday, 1. October 2007, 22:03:39

GT500

avatar

Security Industry

Posts: 3450

Fighting Malware

Originally posted by xErath:

hum.. It might be good to keep those. What do you think ?
And, Homer: Doh! I forgot to include images p:



We won't hold it against you. :wink:

BTW: Reply to this topic or quote me without using the Quick Reply field, and hover your mouse over the submit button. Notice anything odd?

Monday, 1. October 2007, 22:47:33

xErath

avatar

javascript guru

Posts: 6401

Norway

Opera Software

Originally posted by GT500:

Notice anything odd?


image inputs.

Tuesday, 2. October 2007, 00:08:32

GT500

avatar

Security Industry

Posts: 3450

Fighting Malware

Originally posted by xErath:

image inputs.



Sorry, I guess I didn't notice that. :wink:

Saturday, 13. October 2007, 18:35:04 (edited)

d.i.z.

avatar

bug hunter

Posts: 2935

Poland

Some problems:
  1. Different width/height calculations have to be applied for textarea in quirks mode. Right now script is bassically broken in quirks mode when textareas have padding/border set. Look where drag handler appears on most of this textareas: http://east.portland.ne.jp/~sigekazu/css/test/textarea2.htm .
  2. Opera have some bug that makes images added to documentElement sometimes invsible. I had the same problem with OrangooSpellCheck before. I've changed
    document.documentElement.appendChild
    to
    (document.body||document.documentElement).appendChild
    back then. Same could me made for drag resizer.
  3. Textareas with big padding and/or border have this annoying effect when starting resizing. Needs some more refined size calculations.
  4. Little comsetic nitpicking. When we click on drag handler and move mouse a bit, text area bottom right corner is aligning to cursor. It's basically same thing as previous point but on smaller scale.


I have fixed those problems (excluding the first one but it's a metter of adding few if's). If you want I can post fixed version or send it to you so that you could review and polish it.

EDIT: And file input seems to have wrong box model applied in latest build (9594).
http://files.myopera.com/d.i.z./bugs/inputs_boxmodel.html

Saturday, 13. October 2007, 22:38:55

svivian

avatar

needs more cowbell

Posts: 1269

United Kingdom

Originally posted by d.i.z.:

Different width/height calculations have to be applied for textarea in quirks mode. Right now script is bassically broken in quirks mode when textareas have padding/border set. Look where drag handler appears on most of this textareas: http://east.portland.ne.jp/~sigekazu/css/test/textarea2.htm .


They all appear fine to me.

Originally posted by d.i.z.:

Textareas with big padding and/or border have this annoying effect when starting resizing. Needs some more refined size calculations.


Confirmed.

A couple of suggestions from me:
1. I'd like to turn off the corner image altogether (I find it a little distracting) but keep the cursor change. [EDIT: ok found the bit in the code with the image, commenting it out seems to work without any errors]
2. A Creative Commons license is not for software, as I recently discovered. Use GPL instead.

Sunday, 14. October 2007, 10:57:06

d.i.z.

avatar

bug hunter

Posts: 2935

Poland

Originally posted by svivian:

Originally posted by d.i.z.:

Different width/height calculations have to be applied for textarea in quirks mode. Right now script is bassically broken in quirks mode when textareas have padding/border set. Look where drag handler appears on most of this textareas: http://east.portland.ne.jp/~sigekazu/css/test/textarea2.htm .


They all appear fine to me.


Because you are using O9.23. Latest alphas have some fixes for textarea so that border-box boxmodel is properly applied in quirksmode. This breaks script.

Sunday, 14. October 2007, 15:34:20

svivian

avatar

needs more cowbell

Posts: 1269

United Kingdom

Originally posted by d.i.z.:

Because you are using O9.23. Latest alphas have some fixes for textarea so that border-box boxmodel is properly applied in quirksmode. This breaks script.


OK well you didn't say that you were using alpha verison :wink:

Sunday, 21. October 2007, 08:02:23

vinczej

avatar

Az Internet zenéje

Posts: 2256

Hungary

I copied this new textarea resizer JS replacing of expandarea.js. I'm happy to use it instead of expandarea (although it is a nice JS, too), because...

- ...Textarea resizer doesn't cover the right-below corner, so I can use NoScript.js, too.
- ...Textarea resizer doesn't "ignore" the Ospell.js. (Expandarea can't cooperate with ospell correctly)

Congrats for the fine work :yes:

Tuesday, 30. October 2007, 00:31:29

xErath

avatar

javascript guru

Posts: 6401

Norway

Opera Software

Hi again.
I fixed the bugs d.i.z. reported, but I still need a better way to get the computed box-sizing value for textareas, else textareas like the ones on gmail will have the drag anchor mispositioned.

textarea-drag-resizer.js

Tuesday, 30. October 2007, 11:48:06

d.i.z.

avatar

bug hunter

Posts: 2935

Poland

Not good: http://files.myopera.com/d.i.z./bugs/inputs_boxmodel.html

When I get home, I will send you my version which works great both in quirks and standards mode unless one forces different box model for textarea (or input) with box-sizing. And this is because I base my calculations on document.compatMode.

Friday, 2. November 2007, 20:39:46

Pure_BY

avatar

Posts: 5

xErath: it's very nice to see you continuing to develop this very, very nice script!

Keep up the good work, we are enjoying it! ;-)

Monday, 5. November 2007, 21:35:47 (edited)

xErath

avatar

javascript guru

Posts: 6401

Norway

Opera Software

textarea-drag-resizer.js
More another small update.
Now textarea's in gmail work ok p:, d.i.z. testcase looks better and selects are resized too.

@d.i.z., it's too cumbersome and ineficcient to check stylesheets for the proper rules which affect box-sizing for each element.
The script deals with most common cases, and I added a sniff for when Opera supports boxSizing in CSSStyleDeclaration objects.

Monday, 5. November 2007, 22:44:17

d.i.z.

avatar

bug hunter

Posts: 2935

Poland

Originally posted by xErath:

@d.i.z., it's too cumbersome and ineficcient to check stylesheets for the proper rules which affect box-sizing for each element.


Of course, I would never suggest anything like this. :smile:

It works really well now, better then mine, thanks to exceptions for 'file' and 'select'. Moose explained to me that it's not really a bug with quirks box-model for them so I have settled this in my mind now.

But please take image from my version where I have cropped graphic. Yours is resized with css and that makes it look bad. And add a bit of opacity maybe?

And sorry for off topic but I hate that bug in Opera 9.50 when scripts contain non-ascii characters and you edit them and they no longer work. If I save your script without modifying anything, my editor removes all trailing spaces. And this makes script not work anymore because of parsing error. Is this bug on it's way to be fixed?
And I wonder how you make your scripts so they work initially? I guess that these white spaces compensate those non-ascii characters in some way but how do you know where to put those spaces and how much of them? :smile:

Tuesday, 6. November 2007, 22:05:27

xErath

avatar

javascript guru

Posts: 6401

Norway

Opera Software

Originally posted by d.i.z.:

And this makes script not work anymore because of parsing error. Is this bug on it's way to be fixed?


known and reported #288115

Originally posted by d.i.z.:

And I wonder how you make your scripts so they work initially?

Having an accented char makes the last byte of the file being ignored.

Originally posted by d.i.z.:

And I wonder how you make your scripts so they work initially?

My editor keeps all white-space p:
Just leave a newline in the end.

Thursday, 8. November 2007, 01:52:38

xErath

avatar

javascript guru

Posts: 6401

Norway

Opera Software

The script now uses d.i.z. image. It looks a bit better than my previous squeezed anchor.
Thanks :wink:
textarea-drag-resizer.js

Saturday, 10. November 2007, 22:34:07

mark_poleon

avatar

Darkstar

Posts: 5108

China

thanks for this great script :up:

Sunday, 11. November 2007, 06:06:41

DreamRyderX

avatar

Universal Inspirer

Banned User

Up To My Eyeballs In Crocodiles

Excellent Script xErath!!:cheers:

I've always wanted a way to do this on a lot of pages & now I can!!

Now, my next JS type task/wish is to get this problem resolved. :confused:

Thanks again :yes:

Thursday, 15. November 2007, 20:13:48

skye11

avatar

Posts: 416

nice script!
but the resized box returns to its usual size when leaving and later returning to a site
it would be great if the script could retain the resized dimensions of the input/text boxes
perhaps an option to either 'Discard' or 'Remember' a site's resized dimensions...

Thursday, 15. November 2007, 20:31:10

vinczej

avatar

Az Internet zenéje

Posts: 2256

Hungary

Originally posted by skye11:

nice script!
but the resized box returns to its usual size when leaving and later returning to a site
it would be great if the script could retain the resized dimensions of the input/text boxes
perhaps an option to either 'Discard' or 'Remember' a site's resized dimensions...



As default I prefer to return to the original size. But as on option, nothing exception. :wink:

Thursday, 15. November 2007, 21:09:05

skye11

avatar

Posts: 416

viniczej,
many websites' input boxes are just way too short (ie. google)
esp. since there's plenty of room (unused space) across the page to accomodate a longer one
it's a pain to have to resize Google's input box every time I input lengthy search parameters
a site-specific resizing option would be ideal :smile:

Friday, 16. November 2007, 00:03:57

xErath

avatar

javascript guru

Posts: 6401

Norway

Opera Software

Originally posted by skye11:

nice script!but the resized box returns to its usual size when leaving and later returning to a siteit would be great if the script could retain the resized dimensions of the input/text boxesperhaps an option to either 'Discard' or 'Remember' a site's resized dimensions...


This case fits much better with a user stylesheet.

Saturday, 1. December 2007, 20:49:20

arashpour

avatar

Posts: 29

Unfortunatelly it doesnt work on Y!360 and many other sites

Thursday, 13. December 2007, 10:37:28

Engelium

avatar

Lo Stallone di Shinjuku

Posts: 181

Italy

Very useful ... tanks :smile:

Tuesday, 25. December 2007, 20:19:15

M3CSL

avatar

Posts: 204

Germany

Originally posted by skye11:

many websites' input boxes are just way too short (ie. google)
esp. since there's plenty of room (unused space) across the page to accomodate a longer one
it's a pain to have to resize Google's input box every time I input lengthy search parameters
a site-specific resizing option would be ideal :smile:



Just create a CSS file with this content and add its location to your site preferences for Google:

input[type="text"] {
     width:600px !important;
}

Forums » Opera Community » General Opera topics » User JavaScript