From 7a47df4e7425f05257e70ffe242afef78fe92c95 Mon Sep 17 00:00:00 2001 From: Michael Q Larson Date: Mon, 5 Jan 2015 19:01:58 -0800 Subject: [PATCH] start using angular on form --- public/js/main.js | 7 +++++++ views/account/profile.jade | 19 +++++++------------ views/account/show.jade | 11 +++++++++-- views/layout.jade | 2 +- 4 files changed, 24 insertions(+), 15 deletions(-) diff --git a/public/js/main.js b/public/js/main.js index f1d9507b1b8..dd14e952dea 100644 --- a/public/js/main.js +++ b/public/js/main.js @@ -42,3 +42,10 @@ $(document).ready(function() { }); }); +var profileValidation = angular.module('profileValidation',[]); +profileValidation.controller('profileValidationController', ['$scope', + function($scope) { + $scope.twitterHandle = '@yournamehere'; + $scope.user.name = req.user.name; + } +]); diff --git a/views/account/profile.jade b/views/account/profile.jade index ee5fc45c147..30056b1ab14 100644 --- a/views/account/profile.jade +++ b/views/account/profile.jade @@ -1,23 +1,18 @@ extends ../layout -script. - var freecodecamp = angular.module('freecodecamp',[]); - freecodecamp.controller('freecodecampController', ['$scope', - function($scope) { - $scope.twitterHandle = '@yournamehere' - } - ]); - - block content - .panel(ng-controller="freecodecampController") + .panel(ng-controller="profileValidationController") .container.text-center h1 Update your profile here: form.form-horizontal(action='/account/profile', method='POST') - input(type='hidden', name='_csrf', value=_csrf) + //input(type='hidden', name='_csrf', value=_csrf) + //.form-group + // label.col-sm-3.col-sm-offset-2.control-label(for='name') Name + // .col-sm-4 + // input.form-control(type='text', name='name', id='name', value='#{user.profile.name}') .form-group label.col-sm-3.col-sm-offset-2.control-label(for='name') Name .col-sm-4 - input.form-control(type='text', name='name', id='name', value='#{user.profile.name}') + input.form-control(type='text', placeholder='Name', name='name', ng-model='user.name', ng-minlength='3', ng-maxlength='20', required='required', ng-focus='ng-focus', id='name', value='{{user.name}}') .form-group label.col-sm-3.col-sm-offset-2.control-label(for='username') Username (use letters, numbers, underscore) * .col-sm-4 diff --git a/views/account/show.jade b/views/account/show.jade index 40c3d149b36..71e740bd235 100644 --- a/views/account/show.jade +++ b/views/account/show.jade @@ -5,7 +5,7 @@ block content .panel-body .row .col-xs-2.col-sm-1.col-md-1 - img(src="#{picture}") + img(src="#{user.picture}") .col-xs-4.col-sm-2.col-md-2 h2.nameline = "[ " + user.points + " ]" @@ -13,8 +13,15 @@ block content h2.nameline = name h4= location - a(href="#{coderbyteProfile") + a(href="http://twitter.com/#{user.profile.twitterHandle}") + |= "@#{twitterHandle} on Twitter" + a(href="#{user.profile.coderbyteProfile") | Coderbyte Profile + a(href="#{user.profile.linkedin") + | LinkedIn Profile + a(href="#{user.profile.codepen") + | Codepen Portfolio + a(href=linkedin) - if (ch[0] > 0) .container h1 Completed Challenges diff --git a/views/layout.jade b/views/layout.jade index 9d99ff173d6..fafcb655f39 100644 --- a/views/layout.jade +++ b/views/layout.jade @@ -1,5 +1,5 @@ doctype html -html(ng-app='freecodecamp') +html(ng-app='profileValidation') head script(src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js") script(src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.8/angular.min.js")