From 5bafc6c0b573eab8dd0fc0497fab457fdcb5c5b4 Mon Sep 17 00:00:00 2001 From: akuma06 Date: Sun, 7 May 2017 03:00:05 +0200 Subject: [PATCH] Fixed register page --- public/css/style.css | 12 +++++++ public/js/registerPage.js | 65 ++++++++++++++++++++++++++++++++++++ router/userHandler.go | 2 +- templates/index.html | 1 + templates/user/register.html | 3 +- 5 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 public/js/registerPage.js diff --git a/public/css/style.css b/public/css/style.css index 79e51805..5cabbc1a 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -146,3 +146,15 @@ div.container div.blockBody:nth-of-type(2) table tr:first-of-type th:last-of-typ border: none; } } + +/* Credit to bootsnipp.com for the css for the color graph */ +.colorgraph { + height: 5px; + border-top: 0; + background: #c4e17f; + border-radius: 5px; + background-image: -webkit-linear-gradient(left, #c4e17f, #c4e17f 12.5%, #f7fdca 12.5%, #f7fdca 25%, #fecf71 25%, #fecf71 37.5%, #f0776c 37.5%, #f0776c 50%, #db9dbe 50%, #db9dbe 62.5%, #c49cde 62.5%, #c49cde 75%, #669ae1 75%, #669ae1 87.5%, #62c2e4 87.5%, #62c2e4); + background-image: -moz-linear-gradient(left, #c4e17f, #c4e17f 12.5%, #f7fdca 12.5%, #f7fdca 25%, #fecf71 25%, #fecf71 37.5%, #f0776c 37.5%, #f0776c 50%, #db9dbe 50%, #db9dbe 62.5%, #c49cde 62.5%, #c49cde 75%, #669ae1 75%, #669ae1 87.5%, #62c2e4 87.5%, #62c2e4); + background-image: -o-linear-gradient(left, #c4e17f, #c4e17f 12.5%, #f7fdca 12.5%, #f7fdca 25%, #fecf71 25%, #fecf71 37.5%, #f0776c 37.5%, #f0776c 50%, #db9dbe 50%, #db9dbe 62.5%, #c49cde 62.5%, #c49cde 75%, #669ae1 75%, #669ae1 87.5%, #62c2e4 87.5%, #62c2e4); + background-image: linear-gradient(to right, #c4e17f, #c4e17f 12.5%, #f7fdca 12.5%, #f7fdca 25%, #fecf71 25%, #fecf71 37.5%, #f0776c 37.5%, #f0776c 50%, #db9dbe 50%, #db9dbe 62.5%, #c49cde 62.5%, #c49cde 75%, #669ae1 75%, #669ae1 87.5%, #62c2e4 87.5%, #62c2e4); +} \ No newline at end of file diff --git a/public/js/registerPage.js b/public/js/registerPage.js new file mode 100644 index 00000000..81b6c659 --- /dev/null +++ b/public/js/registerPage.js @@ -0,0 +1,65 @@ +$(function () { + $('.button-checkbox').each(function () { + + // Settings + var $widget = $(this), + $button = $widget.find('button'), + $checkbox = $widget.find('input:checkbox'), + color = $button.data('color'), + settings = { + on: { + icon: 'glyphicon glyphicon-check' + }, + off: { + icon: 'glyphicon glyphicon-unchecked' + } + }; + + // Event Handlers + $button.on('click', function () { + $checkbox.prop('checked', !$checkbox.is(':checked')); + $checkbox.triggerHandler('change'); + updateDisplay(); + }); + $checkbox.on('change', function () { + updateDisplay(); + }); + + // Actions + function updateDisplay() { + var isChecked = $checkbox.is(':checked'); + + // Set the button's state + $button.data('state', (isChecked) ? "on" : "off"); + + // Set the button's icon + $button.find('.state-icon') + .removeClass() + .addClass('state-icon ' + settings[$button.data('state')].icon); + + // Update the button's color + if (isChecked) { + $button + .removeClass('btn-default') + .addClass('btn-' + color + ' active'); + } + else { + $button + .removeClass('btn-' + color + ' active') + .addClass('btn-default'); + } + } + + // Initialization + function init() { + + updateDisplay(); + + // Inject the icon if applicable + if ($button.find('.state-icon').length == 0) { + $button.prepend(''); + } + } + init(); + }); +}); \ No newline at end of file diff --git a/router/userHandler.go b/router/userHandler.go index 85e86ff0..7176bb4b 100644 --- a/router/userHandler.go +++ b/router/userHandler.go @@ -25,7 +25,7 @@ func UserRegisterFormHandler(w http.ResponseWriter, r *http.Request) { modelHelper.BindValueForm(&b, r) languages.SetTranslation("en-us", viewRegisterTemplate) htv := UserRegisterTemplateVariables{b, NewSearchForm(), Navigation{}, r.URL, mux.CurrentRoute(r)} - err := viewTemplate.ExecuteTemplate(w, "index.html", htv) + err := viewRegisterTemplate.ExecuteTemplate(w, "index.html", htv) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) } diff --git a/templates/index.html b/templates/index.html index d05faae5..1d3b5153 100755 --- a/templates/index.html +++ b/templates/index.html @@ -91,5 +91,6 @@ + {{block "js_footer" .}}{{end}} diff --git a/templates/user/register.html b/templates/user/register.html index e729d50e..f17ed0ff 100644 --- a/templates/user/register.html +++ b/templates/user/register.html @@ -63,4 +63,5 @@ -{{end}} \ No newline at end of file +{{end}} +{{define "js_footer"}}{{end}} \ No newline at end of file