| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- /* exported initializeRoutes */
- function initializeRoutes()
- {
- router('/login', routes.login);
- router('/sd', routes.sd);
-
- router('*', routes.login);
- }
- //add a 'firstLoad' setup function into the route's middleware chain
- var routes =
- {
- login: function()
- {
- showPage('login');
- },
-
- sd: function()
- {
- showPage('sd');
- }
- };
- function showPage(page)
- {
- console.log('show page', page);
-
- var $page_old = $('.screen.active');
- var $page_new = $('#screen-' + page);
-
- //do nothing if we are already on the page
- if($page_old.is($page_new))
- return;
-
- $('body').attr('class', 'screen-' + page);
-
-
- //put new page on top of old
- $page_new.insertAfter('.screen.active');
- //slide it to the right while crossfading
- $page_old
- .one('animationend', function(event) //jshint ignore:line, unused
- {
- $(this).hide();
- }) //TODO: add detect webkitanimationend or animationend
- .removeClass('active');
- //slide from left while crossfading
- $page_new
- .show()
- .off('animationend')
- .addClass('active')
- .focus(); //this needs to be used in conjunction with a "tabindex" field on the html object to maintain keyboard focus
- }
|