Gallery 3 + jQuery

doublerebel

Joined: 2010-03-31
Posts: 3
Posted: Thu, 2010-04-01 15:44

First let me say a huge thanks, Gallery is a great piece of software and I've been using it on and off to manage photos since version 1. It's always been a breeze to install and use, for all levels of users. Kudos to all who have contributed.

I too would like to help bring Gallery3 to its full potential. As a long-time web developer and jQuery user I'm really excited about the use of PHP5, Kohana and jQuery in this version. I started viewing the sources yesterday in order to theme my new Gallery3 installation and I noticed that some of the jQuery code could be even more efficient and concise, so I went to work.

I forked the project, and you can see my commits here:
http://github.com/doublerebel/gallery3

I have the above version of Gallery3 running in production here:
http://gallery.bassdrivearchive.com

Although it was once necessary to eval() JSON, or to add custom DOM Element properties to store code, jQuery has now taken care of that for us with its .getJSON() and .data() methods. However, I didn't need to store data with any elements because of jQuery's ability to pass 'this' when an event is fired, it now applies the AJAX functions relative to the clicked element. I found a number of places where I could cache DOM lookups to save speed and memory, those jQuery element(s) variables are designated with a leading $. In other places I was able to use jQuery to chain several methods together for efficiency. Lastly, there were several hover events that are attached during the hover event of other elements. These hover events can be attached instead at page load, providing the same functionality while increasing hover responsiveness. (I also started namespacing the Gallery functions inside $.gallery.)

As I get further into the code I will continue to update my repo. Thanks again for Gallery, and let me know whatever questions you have.

Cheers,

Charles