jQuery Curtain v0.5

It has been bothering me that the plugin required you to specify the dimensions of the image. The reason I wrote it that way was because the image wasn't loaded yet when it was added to the page, so we didn't have the dimensions. I have finally had the opportunity to enhance it to calculate those dimensions for you whether the image was preloaded or not. The fix was to attach the javascript that gets the image size in a "load" event handler on the new image. Since it is added to the DOM every time, it will always be fired. Enjoy the new version and let me know if you have any feature requests or bugs!

jQuery Curtain v0.4

I rolled out version 0.3 on a site I am working on last night and found an annoying issue. I had to override the default settings in every call with the same new defaults. That wasn't cool. So tonight is another release with a small but handy little addition to the plugin. You can now call $.curtainSetup(options) and override the default options. That means you can just add it once to your document ready handler and not have to keep passing in the options with every call. My code that calls curtain is now a little cleaner, which makes me happy and everyone else appreciates, too.

jQuery Curtain v0.3

When I first wrote the documentation for Curtain, it hit me that the plugin had a fatal flaw. I originally wrote it to append the curtain into the dom element being curtained. It seemed reasonable at the time. It made it such that I could easily keep track of what curtain belonged to what element without having to track ids or anything. Well as it turns out, that was a big mistake. That implementation carried with it the "feature" of not being able to add it to elements that cannot accept a child div element or to elements that had an absolute position. I have wanted to use it on table rows a few times since I released it and finally had the chance this evening to redo the implementation. If you upgrade to version 0.3, it will now append all the curtain elements to the body tag, so they are completely independent of the element being curtained. Each one receives a unique id, which is stored in the id attribute of the curtain and in a data element in the element being curtained. It actually makes the code a lot cleaner and the implementation a lot more robust. With the new way of linking curtains to the curtained elements, I added a .curtain("get") function to allow easy access to the curtain in case you need it for some reason. I needed it for the tests and I can't imagine why you would want to access it in code, but it is there for you nonetheless. On a side note, I did a little TDD and added the test for adding to absolutely positioned elements before fixing the bug. TDD rocks the house, BTW. If you aren't doing it, you should totally give it a try. Screw.Unit for javascript testing is awesome as well and fits really well with jQuery plugins. If you want to see an example of it in action, check out the spec directory under the project root on github. Just render the suite.html file in your browser to run the tests.

Cool Rails Plugin: Scrooge

I have known about this plugin for a while but only recently had the opportunity to play with it a little. The idea behind it is that when we query the database, most of the time we only need a handful of the columns in a table. Rails, however, runs a "select *" anyway because it doesn't know what you will need. The amount of database overhead can be significantly reduced, however, by only selecting the specific columns that our applications needs. To combat this, Scrooge watches the queries the application makes at runtime and dynamically adjusts the select statements to only include the columns you are actually using. Your first thought upon hearing that is, "what if it makes a mistake or a different path through the code uses a different field?" Well, if that happens, the plugin will requery the row using the id and get the additional fields it missed. It will also make a note of that and get those fields to begin with next time. It is extremely easy to use, too. All you need to do is install it as either a gem or plugin and it starts working for you immediately. No configurations, no code to add...it just works. If you don't like it, just back it out and it is all gone. Piece of cake. Depending on your schema, this could be a large or marginal performance improvement. I expect that in most cases you will see a good performance increase, especially for not having to really do anything to your application. I highly recommend checking it out. Take a look at the project homepage for more details. http://github.com/methodmissing/scrooge/tree/master

jQuery Plugin: Curtain

For a project I am working on, I needed to be able to put a very obvious ajax loading indicator on top of the element being updated via the ajax call.  I wrote a simple plugin that will darken the selected elements and put an ajax loader graphic on them.  All you need to do to invoke it is call: [js]$("#element_to_curtain").curtain();[/js] The only configuration on it right now is for the ajax loader image.  With all the current options, the call looks like this: [js]$("element_to_curtain").curtain({ loader_image: '/images/ajax-loader.gif', loader_height: 100, loader_width: 100 });[/js] If loader_image is an empty string, then the loader image will not be added. The loader_height and loader_width are the size in pixels of the loader image. This is only used to calculate the offsets when placing the graphic in the center of the curtain. If you want to check it out for yourself, you can either visit the project homepage or the github page: http://github.com/paulelliott/jquery-curtain/tree/master