Closed domchristie closed 10 years ago
I've tagged the current release as 0.0.1, and will look through this. I'm not opposed to refactoring the code base, but will have to check out the registry and constructor usage before merging. From first glance it looks pretty good though.
OK, thanks: I appreciate there’s a lot going on!
First of all - thanks! This looks great. I'm going to leave some notes inline
That should be all the points covered.
Some further testing has revealed that triggering a custom event called update
causes problems in IE when Prototype.js is included (see: http://bugs.jquery.com/ticket/14770)
Bit of an edge case I know, but thought it might be worth changing this event name. I know that resize
was used before, but I’m not sure it really reflects what’s actually going on.
Or perhaps we don’t trigger an update event at all, and just call the callback directly?
Some further testing has revealed that triggering a custom event called update causes problems in IE when Prototype.js is included (see: http://bugs.jquery.com/ticket/14770)
Weird... I always prefer triggering the event, than simply calling a callback, it makes it easier for people to use in different cases (like delegating events and stuff). We could call it resize
or maybe reflow
(which definitely shouldn't have any issues).
The jQuery ticket has been updated, which includes the following:
This is because Prototype adds an
.update()
method to the element.
And references the jQuery docs:
Note: For both plain objects and DOM objects other than
window
, if a triggered event name matches the name of a property on the object, jQuery will attempt to invoke the property as a method if no event handler callsevent.preventDefault()
. If this behavior is not desired, use.triggerHandler()
instead.
So perhaps .triggerHandler()
is an option?
So perhaps .triggerHandler() is an option?
Sure, that sounds good. Will pull down latest code now
This looks great! The one thing I notice using it is that the 'reenable' button in the demo isn't working in the Destroying section of the home page
b98aa1c fixes destroy
example on homepage
Just merged and tagged, thanks again! Were there other issues that can now be resolved with this change?
Thanks!
This PR refactors the plugin to use the constructor pattern. It supercedes #37.
Apologies: there’s a lot going on. It seemed to make the most sense to bundle it as one PR.
.expanding()
.expanding
,.expanding-wrapper
,.expanding-clone
).expanding-init
class name in favour of storing initialised textareas in an arrayExpanding._registry
.$('textarea').expanding('isExpanding')
method to check for expanding behaviourspan
+br
instead ofdiv
in clone: removes trailing' '
, and improves testability$('textarea').expanding('resize')
method, it was not documented, and didn’t do much more than:$('textarea').trigger('input')
(?)resize
toupdate
, (more descriptive, and avoids confusion withwindow.onresize
)keyup
event if input not supported to prevent excessive update callsoverflow: auto
(scrollbars will still appear when height exceedsmax-height
e.g.)There is one failing tests in IE8 (minor min-height discrepancy),
and one failing in IE9 (clone border top/bottom width off by 1px). Neither seem to affect the perceived behaviour.I totally understand if it’s too much, but thought I’d get it out there.