If the behavior of hide or other functions bother you,there's no reason why you can't override those methods with your own in, say, jquery-customized.js that you include after jquery.js.
You can also do it similarly for other stuff that bothers you. There's already an "API" to the backend, in that you can modify the guts on jQuery with your own code at whim. Of course, things are likely to break with various releases, so do it at your own peril since you're relying on internal code structure that might always remain consistent. On Tue, Jan 20, 2009 at 9:05 PM, Elijah Insua <[email protected]> wrote: > >> >> Has there been any thought, discussion, or interest in providing >> jQuery as a backend, or being able to provide another library as >> another API to jQuery. > > Sizzle might be of interest to you, although it is *just* a selector > engine.. > >> >> >> jQuery is quite mature (even though a bug I couldn't track down forced >> us to discard use of it at work), > > I'm sure there are people here/[email protected] or in the irc channel > that would be willing to help! > >> >> >> Beyond rolling a library as a modified API using jQuery as a backend >> does have potential use elsewhere. One of the special things about the >> system I have at work is that the JavaScript framework being used >> (since it's part of the system) can do nice things like taking a >> Widget object as input, and knowing how to handle the actual nodes >> it's associated with. > > Dojo does have this sort of feature set.. however dojo is not 'light' > >> >> If you were wondering what irked me a bit, it was primarily show/hide. >> $('#foo').hide(); does have the connotation of hiding something. >> However it always annoyed me how 'hide' was actually a very specific >> "scale diagonally to the upper left, and disappear". Rather than a >> simple 'hide me' like it implies. >> >> And for just sliding something closed, $('#foo').slideUp(); is used, >> even though 'slideUp' is basically a type of 'hide' with a different >> animation. While over on the other hand to actually 'hide' something >> without animation (I have had to do this many a time) I have to >> verbosely type in $('#foo').css('display', 'none'); > > Stolen from : http://jqueryjs.googlecode.com/files/jquery-1.3.js > > hide: function(speed,callback){ > if ( speed ) { > return this.animate( genFx("hide", 3), speed, callback); > } else { > for ( var i = 0, l = this.length; i < l; i++ ){ > var old = jQuery.data(this[i], "olddisplay"); > if ( !old && old !== "none" ) > jQuery.data(this[i], "olddisplay", jQuery.css(this[i], > "display")); > this[i].style.display = "none"; > } > return this; > } > }, > >> >> >> It honestly makes much more sense to me if: >> $('#foo').hide(); just set display: none; >> animating something to slide shut was $('#foo').hide >> ({animate:'slideup'}); >> and if you actually wanted .hide() to animate you would tell it to >> have a default: >> $.defaults.hide.animate = 'slideup'; > > stolen shamelessly from : http://docs.jquery.com/Effects/animate#examples > > $("p").animate({ > "height": "toggle", "opacity": "toggle" > }, "slow"); > > This could actually be wrapped with a plugin if it made you happy. > > $.fn.hideSlide = function(speed) > { > return $(this).each(function() > { > $(this).animate( > { > "height": "toggle", "opacity": "toggle" > }, "slow"); > }); > } > > (thank you firebug!) > >> >> Basically the thought I've had is. "Keeping code short and sweet is >> nice, but only if you do it without losing information. Sometimes you >> go to far in shortening the size of code, and end up losing >> information that makes it readable." >> Along with that 'toggle' irks me as well. For the very well integrated >> jQuery user, "Huh, 'toggle', that just flips my visibility.", but for >> anyone that is just looking at the code "Toggle? What does it >> toggle?" > > reading the documentation suggests : http://docs.jquery.com/Effects/toggle > > "Toggle displaying each of the set of matched elements." > > I don't know how one would properly use anything without reading the > documentation! > >> >> . Toggle could flip a checkbox, it could show or hide >> something, if it shows or hides something then how does it do it? does >> it slide, does it fade, or does it just disappear? >> Honestly toggleVisibility working like the .hide I mentioned above >> makes more sense to me. > > $.fn.toggleVisibility = function () > { > return $(this).each(function() > { > $(this).toggle(); > }; > } > > > I hope this helps! > > -- Elijah > > > > -- -- dz --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "jQuery Development" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en -~----------~----~----~----~------~----~------~--~---
