enyojs/enyo — pull request #951 by graynorton (2014-12-04 20:45:05+00:00)
Title: ENYO-591: Clean up DataList page assignment logic

We have recently had some issues (e.g. ENYO-575, BHV-18217) that
arose because DataList would sometimes assign invalid (negative)
page indices.

We made point fixes to address these specific issues (including
one fix that we knew was just a quickfix for a deeper issue), but
in the process it became apparent that some general cleanup in this
area would yield more understandable / maintainable code and
probably nip similar issues in the bud.

In this change, we:

* Consolidate page assignment logic, which was formerly done
partially in refresh() and partially in resetToPosition(), into
a single new method, assignPageIndices()

* Incorporate logic originally implemented in Moonstone to be
smarter about choosing whether to generate the preceding or
following page along with our target page

* Document page assignment logic thoroughly with inline comments

* Refactor reset(), refresh() and resetToPosition() to be
independent of one another while sharing common functionality

* Add a new optional argument, scrollerArgs, to scrollToIndex().
This allows scrollToIndex() to be easily overridden in Moonstone
(and potentially other libraries) without copying and pasting a lot of code.

Enyo-DCO-1.1-Signed-Off-By: Gray Norton (gray.norton@lge.com)