homepage.page.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. parasails.registerPage('homepage', {
  2. // ╦╔╗╔╦╔╦╗╦╔═╗╦ ╔═╗╔╦╗╔═╗╔╦╗╔═╗
  3. // ║║║║║ ║ ║╠═╣║ ╚═╗ ║ ╠═╣ ║ ║╣
  4. // ╩╝╚╝╩ ╩ ╩╩ ╩╩═╝ ╚═╝ ╩ ╩ ╩ ╩ ╚═╝
  5. data: {
  6. heroHeightSet: false,
  7. },
  8. // ╦ ╦╔═╗╔═╗╔═╗╦ ╦╔═╗╦ ╔═╗
  9. // ║ ║╠╣ ║╣ ║ ╚╦╝║ ║ ║╣
  10. // ╩═╝╩╚ ╚═╝╚═╝ ╩ ╚═╝╩═╝╚═╝
  11. beforeMount: function() {
  12. // Attach any initial data from the server.
  13. _.extend(this, SAILS_LOCALS);
  14. },
  15. mounted: function(){
  16. this._setHeroHeight();
  17. },
  18. // ╦╔╗╔╔╦╗╔═╗╦═╗╔═╗╔═╗╔╦╗╦╔═╗╔╗╔╔═╗
  19. // ║║║║ ║ ║╣ ╠╦╝╠═╣║ ║ ║║ ║║║║╚═╗
  20. // ╩╝╚╝ ╩ ╚═╝╩╚═╩ ╩╚═╝ ╩ ╩╚═╝╝╚╝╚═╝
  21. methods: {
  22. // Private methods not tied to a particular DOM event are prefixed with _
  23. _setHeroHeight: function() {
  24. var $hero = this.$find('[full-page-hero]');
  25. var headerHeight = $('#page-header').outerHeight();
  26. var heightToSet = $(window).height();
  27. heightToSet = Math.max(heightToSet, 600);
  28. heightToSet = Math.min(heightToSet, 1000);
  29. $hero.css('min-height', heightToSet - headerHeight+'px');
  30. this.heroHeightSet = true;
  31. },
  32. clickHeroButton: function() {
  33. // Scroll to the 'get started' section:
  34. $('html, body').animate({
  35. scrollTop: this.$find('[role="scroll-destination"]').offset().top
  36. }, 500);
  37. }
  38. }
  39. });