I was browsing John's blog (because I sometimes like a good read) and I came upon this post I hadn't seen before: <a href="http://ejohn.org/blog/google-groups-is-dead/">http://ejohn.org/blog/google-groups-is-dead/</a> First of all, thanks to all those that moderate this list and the others (I wasn't aware of the nightmare behind). I was curious, though, as to the state of the migration. Where, what, when? Just being curious after a looooooong day of work.
Just curious, do the event module unit tests pass in IE ? Acts all weird for me (including a nasty redirection) but I'm not sure if it's because of my ajax rewriting or not.
Just comitted version 2 of the ajax refactoring for those interested. The tree is in sync with latest jQuery tree. No more global transport selection function: transports are now bound to dataTypes through jQuery.ajax.bindTransport( dataTypeSelector, factoryFunction ). The dataTypeSelector is a string containing dataType names separated by spaces. If you put a + sign in front of the dataType name, then the transport will be the first one to be tested for that specific dataType. For instance: jQuery.ajax.bindTransport( "+json text", myTransportFactoryFunction ) ensures myTransportFactoryFunction is the first one called for a request with json dataType and the last one called for a request with test dataType. The factory function is in charge of determining if its transport is suitable for the given request (it gets the request options object as its only parameter). It can return the transport object (with a mandatory send method and an optional abort method) or nothing (or false). If it does the latter, two cases : 1) the dataType in the options object hasn't been changed, in which case the selector looks for the next transport in line 2) the dataType has been changed and the selector intelligently redirects to the transports for this new dataType. Transports are tested for the dataType and, if non was found, for the catchall "*" transports. An exception is raised if no transport is found. Edge cases, such as cumbersome request type detections, can be handled using jQuery.ajax.prefilter( prefilteringFunction ): you can see an example of that in transports/jsonp.js.
While refactoring $.ajax, I realized aborting a request doesn't fire complete. While this could make sense for early abort (beforeSend) since ajaxStart hasn't been fired yet, it is quite awkward later on when timeout does fire the event while being nothing more than an automated abort. I also noticed no unit test breaks if I fire the event anyway so I was wondering if this was on purpose or if I could just fire the event for consistency's sake (and, if so, should I handle early and onload aborts differently?).
Hi all,<div> </div><div>I'm turning to you once more for a problem I think you can help me with.</div><div> </div><div>So far, for my jsonp plugin (for those who don't know of it: <a href="http://code.google.com/p/jquery-jsonp/">http://code.google.com/p/jquery-jsonp/</a>), I just made a simple test page using the YouTube data API. I have the plugin working in production so I know it's solid but, unfortunately, the site I use it on doesn't cover the whole feature set.</div> <div> </div><div>So, I'd like to have unit tests for $.jsonp() and was curious as to how you would construct such tests. The main issue I have is that it involves network traffic. How were the $.ajax unit tests constructed? Is there some sort of server-side code to test timeouts or programmatic aborts?</div> <div> </div><div>Any hint is welcome :)</div><div> </div><div>-- Julian</div>
Hi all,<div> </div><div>I'm in the process of migrating a site from 1.2.7 to 1.3.2.</div><div> </div><div>So far, I just ran into a bug in webkit browsers that forced me to rewrite "expr1, expr2, ... exprN" selectors into loops (I suppose you're aware of this one).</div> <div>I also have trouble with attaching event handlers to dynamically created elements, but I guess it's all a question of timing (and probably the correct spot to look into $.live() ).</div><div> </div><div>Anyway, I had some simple code to get the position for a div to appear at the center of the viewport:</div> <div> </div><div><div> getCenterPosition: function(targetWidth,targetHeight) {</div><div> var win = $(window);</div><div> var target = {</div><div> top: Math.round((win.height()-targetHeight)/2)+win.scrollTop(),</div> <div> left: Math.round((win.width()-targetWidth)/2)+win.scrollLeft()</div><div> }</div><div> if (target.top<0) target.top = 0;</div><div> if (target.left<0) target.left = 0;</div><div> return target;</div> <div> },</div><div> </div><div>It was cross-browser and quite simple indeed.</div><div> </div><div>Problem is, in 1.3.2, windows dimensions are those of the whole body, not just the viewport. I turned the code upside/down but just can't find the proper mean to do the exact same thing with the changes that probably occured at 1.3.0.</div> <div> </div><div>Since you all know the internals of jQuery, I guess this is as good a place to ask for ideas or pointers.</div><div> </div><div>Take care all,</div><div> </div><div>-- Julian</div></div>
Hey all,<div> </div><div>I'm working on a site that offers some customizability regarding elements colors (background & font). Rather then setting the color with .css(), I use classes like color-red, color-green, etc (and of course, red is not the css "red" and green is not the css "green"). I find it much cleaner since I need not have color values referenced within javascript or php (it's simply in the css).</div> <div> </div><div>However, the code seems unnecessarily bloated for switching classes. What would be very useful imo, is to have hasClass accept regexp & return the array of found classes and also a .replaceClass() function that would change a class into another. That way I could do the following:</div> <div> </div><div>var colorClasses = $.hasClass(/color-.+/);</div><div>if (colorClasses!==false) {</div><div> var currentColorClass = colorClasses[0];</div><div>}</div><div>// Do stuff with the color class</div><div>$.replaceClass(currentColorClass,"color-"+newColor);</div> <div> </div><div>As of today, I have only two solutions:</div><div>- keep the current color using $.data() or any other custom data container</div><div>- OR search the class attribute by hand (hoping classes are in a specific order, you can imagine the mess)</div> <div> </div><div>If that wasn't bad enough, after that, to replace the class, I have to call $.removeClass() and $.addClass() which seems pretty inefficient to me.</div><div> </div><div>I know I could probably do a plugin for that but I have the feeling that, if embedded in jQuery with its class related code, it would be much more efficient.</div> <div> </div><div>I also know I could switch back to the .css("background-color",color) but it kinda defeats the purpose of having the presentation information in the css and ONLY in the css which I find pretty nice for maintenance.</div> <div> </div><div>Yes, and finally, am I crazy or couldn't this be quite useful?</div><div> </div><div>Take care, all,</div><div> </div><div>-- Julian</div><div> </div><div> </div><div> </div><div> </div><div> </div>
<div>Hi all,</div><div> </div>Just a note to let you know I finally released my jsonp plugin for jquery.<div> </div><div>It's located here: <a href="http://code.google.com/p/jquery-jsonp/">http://code.google.com/p/jquery-jsonp/</a></div> <div>API documentation can be found here: <a href="http://code.google.com/p/jquery-jsonp/wiki/APIDocumentation">http://code.google.com/p/jquery-jsonp/wiki/APIDocumentation</a></div><div>and some "tips" are described here: <a href="http://code.google.com/p/jquery-jsonp/wiki/TipsAndTricks">http://code.google.com/p/jquery-jsonp/wiki/TipsAndTricks</a></div> <div> </div><div>I went to great length to have its behavior as close as possible to $.ajax() and, also, to make its size as insignificant as possible (2,089 bytes minified as of version 1.0).</div><div> </div><div> Hope some of you will find it useful.. and any feedback is welcome of course :)</div><div> </div><div>Take care,</div><div> </div><div>-- Julian</div><div> </div>
Working on a jsonp plugin (that will supercede my getJSON mess of a replacement).<div> </div><div>I'd like it to be as similar to $.ajax behavior as possible and I'm wondering what happens exactly when the abort method of the xhr object is called while the request is still active.</div> <div>More precisely, are the success/error and complete callbacks called or not?</div><div> </div><div>That's really the only little thing I have left before I make some documentation and release it.</div><div> </div><div>Thanks in advance,</div><div> </div><div>-- Julian</div>