Lungo.Boot.Layout.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. var ELEMENT = lng.Constants.ELEMENT;
  13. var ATTRIBUTE = lng.Constants.ATTRIBUTE;
  14. /**
  15. * Initializes the automatic subscription events by markup of the project.
  16. *
  17. * @method init
  18. *
  19. */
  20. var init = function() {
  21. if (lng.Core.isMobile()) {
  22. _window = window;
  23. _document = _window.document;
  24. _resizeLayout();
  25. }
  26. };
  27. var _resizeLayout = function() {
  28. if (_window.innerHeight == 356) {
  29. var _height = 416;
  30. lng.dom(ELEMENT.BODY).style(ATTRIBUTE.HEIGHT, _height + ATTRIBUTE.PIXEL);
  31. _hideNavigationBar();
  32. }
  33. };
  34. var _hideNavigationBar = function() {
  35. if( !location.hash || !_window.addEventListener ){
  36. _window.scrollTo( 0, 1 );
  37. var scrollTop = 1,
  38. //reset to 0 on bodyready, if needed
  39. bodycheck = setInterval(function(){
  40. if( _document.body ){
  41. clearInterval( bodycheck );
  42. scrollTop = 'scrollTop' in _document.body ? _document.body.scrollTop : 1;
  43. _window.scrollTo( 0, scrollTop === 1 ? 0 : 1 );
  44. }
  45. }, 15 );
  46. _window.addEventListener('load', function(){
  47. setTimeout(function(){
  48. _window.scrollTo( 0, scrollTop === 1 ? 0 : 1 );
  49. }, 0);
  50. }, false );
  51. }
  52. };
  53. return {
  54. init: init
  55. };
  56. })(Lungo);