Skip to content

Refactor: changepage outline

StevenBlack edited this page Apr 19, 2011 · 1 revision

changepage:

arguments:

  • to: page you're changing to types:

      - string: page url or id
    
      - object: jquery element or form object containing {url, data, type}
    
      - array: defines from and to (allows you to transition from a different page than current - deprecate?)
    
  • transition: which transition class to use (defaults to global default transition)

  • direction: forward/reverse

  • changeHash: update the hash on complete?

  • fromHashChange: changePage came from hashchange event

  1. determine type of "to" arg (one call to $.type(to) is best)

  2. try to determine "from" page: should either be active page, or first item of "to" if it's an array

  3. if to is a string, strip the leading #

  4. define fileURL as the request URL minus any internal params at the end

  5. Attempt to guess whether it's a back/forward

  6. reset base url to match new page before request goes out

  7. define functions to be used once page is available

    • enhancePage

    • pageTransitionLock

    • transitionPages

      • addContainerClass
      • removeContainerClass
    • changePageComplete

8 . figure out of page is local or needs to be requested, get page either way - if ajax, call pageLoading to show the loader - call page plugin to enhance page - see if url pointed at a subpage, if so, change "to" to reference that

  1. transitionPages procedure:

    1. get current scroll position
    2. scroll to top
    3. add container classes for 3d transition, if needed
    4. if there's a from page, set data on it for current scroll
    5. trigger pagebeforehide on from page
    6. trigger pagebeforeshow on to page
    7. call $.mobile.pageLoading( true ); to kill the page loader
    8. if there's a transition set, call