From 0abf8b3f5075c5f5b36cf55d28774c7585372d9a Mon Sep 17 00:00:00 2001 From: Keith Irwin Date: Wed, 12 Apr 2017 14:32:28 -0400 Subject: [PATCH] Added formatting to push footer to bottom --- config/routes/test.js | 42 +++++++++++++++++++++---------------- static/js/footer.js | 17 +++++++++++++++ views/short.html | 14 +++++++++++++ views/templates/footer.html | 4 +++- views/templates/header.html | 6 +++--- 5 files changed, 61 insertions(+), 22 deletions(-) create mode 100644 static/js/footer.js create mode 100644 views/short.html diff --git a/config/routes/test.js b/config/routes/test.js index e570462..b603706 100644 --- a/config/routes/test.js +++ b/config/routes/test.js @@ -4,24 +4,30 @@ const router = require('express').Router(), mw = require('../middleware.js'), mail = require('../mail.js'); -router.route('/mail').get(function(req,res,next){ - mail.send({ - to: `"Keith Irwin" `, - from: mail.from, - subject: 'Test email', - text: mail.text("Looks like everything's working! "), - html: mail.html("

Looks like everything's working!

") - }).then(function(){ - console.log("Test email should have sent..."); - res.sendStatus(200); - }).catch(function(err){ - mw.throwErr(err,req); - next(); - }); -}); +router -router.route('/password').get(function(req,res){ - res.render('password'); -}); + .get('/mail', function(req,res,next){ + mail.send({ + to: `"Keith Irwin" `, + from: mail.from, + subject: 'Test email', + text: mail.text("Looks like everything's working! "), + html: mail.html("

Looks like everything's working!

") + }).then(function(){ + console.log("Test email should have sent..."); + res.sendStatus(200); + }).catch(function(err){ + mw.throwErr(err,req); + next(); + }); + }) + + .get('/password', function(req,res){ + res.render('password'); + }) + + .get('/short',function(req,res){ + res.render('short'); + }); module.exports = router; \ No newline at end of file diff --git a/static/js/footer.js b/static/js/footer.js new file mode 100644 index 0000000..ba40624 --- /dev/null +++ b/static/js/footer.js @@ -0,0 +1,17 @@ +'use strict'; +/* global $ */ + +// Push footer to bottom on pages with little content +function setFooter(){ + var windowHeight = $(window).height(), + footerBottom = $("footer").offset().top + $("footer").height(); + if (windowHeight > footerBottom){ + $("footer").css( "margin-top", windowHeight-footerBottom ); + } +} + +// Execute on page load +$(function(){ setFooter(); }); + +// Execute on window resize +$(window).resize(function(){ setFooter(); }); \ No newline at end of file diff --git a/views/short.html b/views/short.html new file mode 100644 index 0000000..f1d27c7 --- /dev/null +++ b/views/short.html @@ -0,0 +1,14 @@ +{% extends 'templates/base.html' %} +{% block title %}{{super()}} | Short page test{% endblock %} + +{% block main %} + +
+ +

Test

+ +

This is a test of a short page.

+ +
+ +{% endblock %} \ No newline at end of file diff --git a/views/templates/footer.html b/views/templates/footer.html index b27fe5b..1a61fd7 100644 --- a/views/templates/footer.html +++ b/views/templates/footer.html @@ -13,4 +13,6 @@ - \ No newline at end of file + + + \ No newline at end of file diff --git a/views/templates/header.html b/views/templates/header.html index 9163335..32f0c97 100644 --- a/views/templates/header.html +++ b/views/templates/header.html @@ -1,5 +1,3 @@ - -
@@ -53,4 +51,6 @@ Success! {{ success | safe }} -{% endfor %} \ No newline at end of file +{% endfor %} + + \ No newline at end of file