Lungo.Boot.Layout.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /**
  2. * Initialize the Layout of LungoJS (if it's a mobile environment)
  3. *
  4. * @namespace LUNGO.Boot
  5. * @class Layout
  6. *
  7. * @author Javier Jimenez Villar <javi@tapquo.com> || @soyjavi
  8. */
  9. LUNGO.Boot.Layout = (function(lng, undefined) {
  10. var _window = null;
  11. var _document = null;
  12. /**
  13. * Initializes the automatic subscription events by markup of the project.
  14. *
  15. * @method init
  16. *
  17. */
  18. var start = function() {
  19. if (!lng.Environment.isDesktop()) {
  20. _window = window;
  21. _document = _window.document;
  22. _resizeLayout();
  23. }
  24. };
  25. var _resizeLayout = function() {
  26. if (_window.innerHeight == 356) {
  27. var _height = 416;
  28. lng.Dom.query('body').css('height', _height + 'px');
  29. _hideNavigationBar();
  30. }
  31. };
  32. var _hideNavigationBar = function() {
  33. if( !location.hash || !_window.addEventListener ){
  34. _window.scrollTo( 0, 1 );
  35. var scrollTop = 1,
  36. //reset to 0 on bodyready, if needed
  37. bodycheck = setInterval(function(){
  38. if( _document.body ){
  39. clearInterval( bodycheck );
  40. scrollTop = 'scrollTop' in _document.body ? _document.body.scrollTop : 1;
  41. _window.scrollTo( 0, scrollTop === 1 ? 0 : 1 );
  42. }
  43. }, 15 );
  44. _window.addEventListener( 'load', function(){
  45. setTimeout(function(){
  46. _window.scrollTo( 0, scrollTop === 1 ? 0 : 1 );
  47. }, 0);
  48. }, false );
  49. }
  50. };
  51. return {
  52. start: start
  53. };
  54. })(LUNGO);