addyosmani/backbone.paginator — pull request #61 by alexwolfe (2012-07-22 22:23:22+00:00)
Title: Cleanup & Refactoring 

Hey Addy,

I made some updates to the Paginator library and will probably be making quite a few more. I did not change any of the APIs for Paginator but did cleanup, refactor, bug fix, and add a new feature (allowing paginator to be populated with models without calling fetch())

Unfortunately the file was a mix of tabs & spaces. I converted everything to spaces and js linted. I know this might make the changes a little harder to read but I have provided a list of all the changes below.

I really only updated Paginator.clientPager from the beginning of the class until the nextPage method. I will make updates to the other sections in a different commit. I have some other bug fixes for adding/removing models and sorting that will be included in next round.

Thanks for putting together this great library, really useful so far. Here's my list of changes:

1. Fixed Typo "lastFieldFilterRiles" should be lastFieldFilterRules (Rules not Riles)
2. Moved default values outside of initialize (no need to set them during initialization, can be set as part of class definition)
3. Moved creating of paginator_ui defaults and object into a separate function so it can be called during initialize and sync. This allows the user to populate the collection without fetch() (ie manually). Previously if you populated Client.Paginator with models without calling fetch it would not work.
4. Removed unneeded references to "self" when "this" could be used. Often times "this" could have been set as the "context" for the underscore method making "self" unnecessary
5. Moved defaults for "paginator_ui" into the class definition so it does not need to be combined, it can just be defined then overwritten
6. Updated functions that loop through "paginator_ui" and attaches values as collection properties. Previously was using _.each, change simply to _.defaults(this, paginator_ui). Does the same thing, easier to read.
7. Updated nextPage method so it doesn't call pager when on the last page.
8. Js linted
9. Add blank definition of server_api object at top of Class