Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Replace our custom textarea.js with jQuery UI Resizable. This keeps the same design we had before, along with our the same grippie, but just replaces the JavaScript code by using jQuery UI Resizable instead.
In the end, it's less code for us to maintain.
Comment | File | Size | Author |
---|---|---|---|
#43 | 1138258.patch | 5.53 KB | RobLoach |
#41 | 1138258.patch | 5.33 KB | RobLoach |
#40 | 1138258-diff.patch | 5.33 KB | RobLoach |
#40 | 1138258-formatpatch.patch | 7.22 KB | RobLoach |
#30 | 1138258-30-textarea-js.patch | 3.95 KB | ericduran |
Comments
Comment #1
mfer CreditAttribution: mfer commentedsub.
Comment #2
Crell CreditAttribution: Crell commentedThis makes sense to me visually, but I'm not a JS expert so I will not RTBC it. I will, however, hand it to the bot. :-)
Comment #3
RobLoachCleaned up the patch a bit.
Comment #4
idflood CreditAttribution: idflood commentedMake sense and looks good. This will even fix #835820: Don't set CSS directly in JS, make it themable . The behaviour is the same after applying the patch, however it make a little visual difference. Before and after screenshots attached. It would also be better to keep the same css classes if possible.
Comment #5
mfer CreditAttribution: mfer commented@idflood what browser did you test this in?
Comment #6
RobLoachidflood, you might have to clear your caches. It looks like it didn't apply correctly as it's missing the grippie.
Comment #7
idflood CreditAttribution: idflood commentedSorry, I forgot to clean the caches. After clearing both drupal and browser caches the result looks different. I attached a screenshot of the new result. I tested this on firefox 4.0 / safari / chrome and the result is consistent across browsers. Maybe I did something wrong with the patch but it applied successfully without warnings.
Comment #8
RobLoachCleaned up the patch a bit more and brought in the CSS changes from #835820: Don't set CSS directly in JS, make it themable (filter and zoom). Not sure why, but it looks like the right border of the textarea is being pushed by about 5px. Anyone else see that?
Comment #9
idflood CreditAttribution: idflood commentedI've added two "width: 100% !important;" to fix the textarea width. The issue was most visible by loading node/add/article with a small browser window and then making it bigger after the page has loaded.
Comment #10
Crell CreditAttribution: Crell commentedAs a side note, I've just filed #1153300: Deprecate Drupal's textarea resizer as a related issue. I think it's technically separate from this issue but I defer to the JS gurus.
(Actually it might be nice to bake that functionality right into jQuery Resizable. That's a good way to contribute back to a sister project.)
Comment #11
wmostrey CreditAttribution: wmostrey commentedComment #12
nod_How awesome is that, it works really well :)
With this we don't have to worry about #1301952: Objectify textarea js anymore.
Comment #13
sunLet's remove the 'div' in the selector.
Typo in "textare"
What means "bottom right", and why? The grippie was only at the bottom before?
A hard-coded pixel size is a bit unfortunate. Any ways around that?
No !important in core CSS.
#1269586: Use .js instead of html.js in CSS
Comment #14
sunThe layout tweaks going on for resizable textareas are quite advanced and went through extensive testing. See #735628: Resizable textarea behavior leads to unpredictable results
Comment #15
nod_Here is a patch, use CSS resize if possible, if not fall back to jquery ui. I kept the
resizable-textarea
to simplify CSS styling and be able to differenciate between a CSS resize and jquery resize.Comment #16
sunInteresting.
Looks like we need to load jQuery UI Resizable anyway as polyfill? (that said, would be highly interesting to investigate whether we can introduce a lazy-load mechanism for polyfill code [which would have to integrate deeply with Drupal.ajaxPageState])
Comment #17
nod_1)
a. I assumed it wasn't applicable to everything but it is :p resize won't help jquery ui, there is no way to make all events/options available with only a CSS resize and the actual width / height resizing is pretty trivial compared to animations and other crazy things ui does.
b. totally agree, and with loaders it's actually really easy to do, cf. the whole script loader issue.
2) nothing helpfull inside $.support for this, since ui-resize won't be able to use it, there is no need for jquery to test it.
So yeah unifying them all sounds like a good idea but it's not actually possible.
Comment #18
nod_a side note about ajaxpagestate integration, I don't get it. Here is what a conditional loading would look like :
That would work that way for any loader (curl, requirejs, etc.)
Where does it involve something like ajaxpagestate ?
I know this has nothing to do here but it's such a good example I can't leave it alone.
Comment #19
sunSorry for the ajaxPageState/script-loader confusion. Looks like I have to make myself way more familiar with the anatomy of those script loaders. Anyway, thanks for noting, and yeah, let's discuss that elsewhere.
I thought the idea of $.support is to have central feature detection? Hence, by using $.support contributed and custom modules and themes can (re-)use the condition?
Comment #20
nod_My understanding is that the feature detection is always run to be always available. Since this is not included in all of the pages 3rd party scripts can't rely on it anyway. And they won't/souldn't be loading textarea.js just for that.
From what I read over at jquery this is used for jquery or plugins. I have a huge plugin or set of plugins and I need a global thing for browser features: use $.support instead of a global var. I have nothing against adding the result to $.support but since the scope is so tiny and it won't be added on most of the pages, it's just not worth it.
worst case people starts using it, we have to take it out because somehow it slows js too much you have many people not happy about it, a bit like the global $ thing.
Comment #21
Crell CreditAttribution: Crell commentedThought: If we want to be an HTML5-centric system (my understanding is that we do) and embrace modern web conventions (my understanding is that we do), then why have a JS fallback? If a browser doesn't support resize, then those users don't get resize. That's the conventional approach these days for optional stuff like that, is it not? The form still works, the user loses no capability to interact with the page, but he is limited by his browser. Aw.
Opera is hardly a major market, and will get resize support soon enough anyway I expect, so why go to all that work when we can just say "HTML5 takes care of it, let's go have a beer"?
Comment #22
nod_meh, fine with me. Just need someone to decied between #1153300: Deprecate Drupal's textarea resizer and this one there are patches for both. You might want to talk to UX people before though, the browser native resize handle is tiny tiny. As much as I hate grippie it has the advantage of being easy to find, click and drag.
Comment #23
RobLoachPeople are probably more accustomed to something that comes native with their operating system rather than what's on a Drupal website ;-) . Twitter and Gmail don't include one and just use the native operating system's design.
I might be biased here, as I usually opt for the route to less code, but I think my vote is in for dropping it. I really do hate dropping an opportunity to actually use some jQuery UI in Drupal Core here though! Your above patch does look mighty mighty fine too! When there are tools native to browsers to support something like this though, we should probably opt to use it.
Comment #24
sunI support the idea and stated reasoning for removing it.
FWIW, the spec: http://www.w3.org/TR/css3-ui/#resize
Indeed, this means to load less code in the frontend (which is way more important than "less code to maintain"), and it's not like users wouldn't be able to edit the textarea content anymore. And, if absolutely necessary on your own site, you can happily and very easily overload this with jQuery UI or your custom forward-port of textarea.js (doh ;)).
We still want to retain compatibility with the #resizable textarea Form API property though. For that, I'd suggest to change the property's value into a string, its default value to 'vertical', and lastly, apply a corresponding CSS class according to that; i.e.:
which is turned into
ends up as:
and lastly gets triggered:
Comment #25
Crell CreditAttribution: Crell commented#24 is exactly what I was talking about. I presume we would add support for the other resize values as well (horizontal, both, and none)? It looks like it would be a trivial patch.
(We may want to fold this issue into #1153300: Deprecate Drupal's textarea resizer at this point.)
We may also want to ping Jacine as HTML5 lead in case she disagrees, but I suspect she'd be OK with this approach.
Comment #26
JacineCool. Tagging this for the current sprint.
Comment #27
Crell CreditAttribution: Crell commentedIn the sprint meeting today, Jacine gave a thumbs-up to switching to pure-CSS with no shiv on this issue. Who wants to write the patch? :-) (Basically implement #23 and #24.)
Comment #28
Crell CreditAttribution: Crell commentedOopsies.
Comment #29
cosmicdreams CreditAttribution: cosmicdreams commentedI'll give it a shot tonight, unless someone beats me to it.
Comment #30
ericduran CreditAttribution: ericduran commentedHere's a first pass.
Comment #31
ericduran CreditAttribution: ericduran commentedComment #32
webchickHey, neat! :) Here's a screenshot:
One thing I ran into when I was testing (Chrome 17, OSX Snow Leopard): it will only let you make the box bigger, you can't move the corner up in order to collapse the box and make it smaller. At first, this made me think the patch wasn't working. It'd be nice to retain this functionality, for the purpose of taking screenshots and other things. Not sure if this is just a quirk with this specific implementation or not; http://robertnyman.com/css3/resize/resize.html shows that this property can even re-size things to stupid levels, so hopefully it can be fixed in a way that doesn't screw non-CSS3-compatible browsers. :)
Comment #33
ericduran CreditAttribution: ericduran commentedYea I notice that too :-/. Seems like a weird implementation coming from this line in the spec.
So essentially the smallest an element can go seems to be it's initial width :-/
Here are a couple of stackoverflow questions related to this exact same issue.
http://stackoverflow.com/questions/8771650/html5-resize-only-on-makes-it...
http://stackoverflow.com/questions/6313358/css3-resize-property-allows-o...
:-(
Comment #34
nod_CSS resize is not supported in opera nor IE. That makes me a little sad (I like opera) but I'm sure IE people will be angry.
Can we discuss (maybe somewhere else) how we handle js fall-backs for this kind of things?
Patch at #30 is tested and works well.
Comment #35
ericduran CreditAttribution: ericduran commented@nod in the last html5 meetup we discuss supporting ie in a contrib module that people can install if they want ie support. So we can have a contrib module that brings ie support for all these functionality. You can see more detail about this in the meeting notes (http://groups.drupal.org/node/206193#comment-687768).
The idea behind this is we support the native functionality which is nicer/cleaner/leaner out of the box and if you need ie support you can just install the extra module. Also we talk about this not being such a big deal being that technically the form is still usable and doesn't really harm anyone if an ie user can't resize a specific textbox.
Comment #36
nod_Thanks, I wasn't aware of that. That's good enough for me :)
Comment #37
webchickThe UX team might have something to say about this patch. Tagging for them.
Comment #38
sunGentle reminder that we had something along the lines being proposed in #35 in core some time ago:
Legacy module
(different purpose, but otherwise comparable)
Definitely a discussion for a separate issue, but I wanted to point out early that it might make sense to provide legacy/polyfill/fallback support within core.
Comment #39
RobLoachNot sure we need to append the "resizable-none" class to every textarea element. Let's just have that the default and save ourselves having to apply the class and CSS attribute each time. Patch coming up.
Comment #40
RobLoachAh, I understand. The defaults are
resize: both
and some browsers (FireFox/WebKit), andresize: none
on some others, so this needs to be explicit.Either way, I noticed a few other things:
Comment #41
RobLoachNot sure why the patch couldn't apply. Sun suggested uploading a simple diff rather than what I did in the Advanced patch workflow.
Comment #43
RobLoachWebflo suggested --binary....
Comment #44
cosmicdreams CreditAttribution: cosmicdreams commentedManually tested #43, works in Chrome Canary, Chrome Stable, and Firefox. However, I see inconsistent behavior:
1. Only Firefox provided a mouse icon that looked like an up arrow combined with a down arrow.
2. Firefox and Chrome Stable allowed me to change the height of the textarea, Chrome Canary allowed me to change the height and the width.
Other than that it was fine. I wasn't able to reduce the height or width beyond the default.
Doesn't work in Opera 11.61, IE9, or IE8
Comment #45
ericduran CreditAttribution: ericduran commentedI didn't put the min-height or max-width because it didn't make sense to me.
This is good, changing back to RTBC.
Comment #46
catchThis looks great! Committed/pushed to 8.x.
Let's add a change notification - there may be themes out there doing custom styling of this etc.
Comment #47
ericduran CreditAttribution: ericduran commented@catch it looks like this commit didn't actually make it up to drupal.org. Same thing with a couple of other issues.
Comment #48
xjm@ericduran is correct. (Fixing priority.)
Comment #49
catchLet's try that again. Committed/pushed!
Comment #50
cosmicdreams CreditAttribution: cosmicdreams commentedMy first Change notification. Please let me know if I've done anything wrong: http://drupal.org/node/1465840
Comment #51
cosmicdreams CreditAttribution: cosmicdreams commentedProblem/Motivation
Drupal 8 aspires to rely more on the foundations of the internet such as CSS3 and HTML5 and no longer needs to support old-IE browsers that required JavaScript driven implementations for textarea resizing. We want to reduce our code weight by reducing that amount of additional behaviors we apply to form elements such as resizing a textarea.
Proposed Resolution
Remove the textarea.js script that enabled the ability to resize textareas and instead rely on a pure CSS 3 and HTML5 based solution.
Comment #52
webchickI think maybe a before/after screenshot would be nice so people see what the difference is. This is more visual than anything else.
Comment #53
Crell CreditAttribution: Crell commentedIt's probably easiest to steal the picture from #32. webchick already did the work for us. Thanks, webchick! :-)
Comment #54
xjmI polished the change notice formatting a bit more, moved the screenshots below the description, and added a sample textarea implementation using the new
#resizable
allowed values.Comment #55
JacineThanks @xjm and @cosmicdreams! Removing the sprint tag.
Comment #57
RobW CreditAttribution: RobW commentedWhat do people think about backporting this to 7 (there was a little note about it in #1153300: Deprecate Drupal's textarea resizer)?