BoomTownROI/boomqueries — pull request #1 by jbenesch (2014-12-04 01:07:53+00:00)
Title: Reworked a bit

When checking out this branch, open tests/kitchensink.hml in your browser and open your console. I run through a set of tests and examples of usage.

The main distinguishing change in this branch is how the updates to each DOM node are performed. We used to perform a document.querySelectorAll to grab all nodes on window resize and then change their class based on their offsetWidth.

The change now grabs the DOM nodes on add/refresh and attaches event listeners to them. When the window resizes, we simply trigger the checkyourself event on each of the nodes.

With a small amount of elements, there probably isn't a huge performance gain, but the concept of DOM nodes listening to events instead of having to grab them each time you want to apply a transformation is typically the modern way of thinking about handling heavy JS apps.

As far as adding the functionality to the prototype, that isn't necessary and is simply a syntax I tend to prefer. I do find it incredibly helpful in code organization and references to function calls though. For instance: this.get() this.save(), etc makes much more sense to me then btQueriesGet() btQueriesSave(), etc.